MDL-52964 Qtype: Add behat tests to core question types
[moodle.git] / question / type / match / tests / behat / preview.feature
blob2d219104fc625a7b8e3659518465a486d81e91ac
1 @qtype @qtype_match
2 Feature: Preview a Matching question
3   As a teacher
4   In order to check my Matching questions will work for students
5   I need to preview them
7   Background:
8     Given the following "users" exist:
9       | username | firstname | lastname | email               |
10       | teacher1 | T1        | Teacher1 | teacher1@moodle.com |
11     And the following "courses" exist:
12       | fullname | shortname | category |
13       | Course 1 | C1        | 0        |
14     And the following "course enrolments" exist:
15       | user     | course | role           |
16       | teacher1 | C1     | editingteacher |
17     And the following "question categories" exist:
18       | contextlevel | reference | name           |
19       | Course       | C1        | Test questions |
20     And the following "questions" exist:
21       | questioncategory | qtype | name         | template |
22       | Test questions   | match | matching-001 | foursubq |
23     Given I log in as "teacher1"
24     And I follow "Course 1"
25     And I navigate to "Question bank" node in "Course administration"
27   @javascript
28   Scenario: Preview a question and submit a correct response.
29     When I click on "Edit" "link" in the "matching-001" "table_row"
30     And I set the following fields to these values:
31       | Shuffle    | 0   |
32     And I press "id_submitbutton"
33     When I click on "Preview" "link" in the "matching-001" "table_row"
34     And I switch to "questionpreview" window
35     And I set the field "How questions behave" to "Immediate feedback"
36     And I press "Start again with these options"
37     And I set the field with xpath "//table[@class='answer']//td[@class='control']//select[contains(@id, '1_sub0')]" to "amphibian"
38     And I set the field with xpath "//table[@class='answer']//td[@class='control']//select[contains(@id, '1_sub1')]" to "mammal"
39     And I set the field with xpath "//table[@class='answer']//td[@class='control']//select[contains(@id, '1_sub2')]" to "amphibian"
40     And I press "Check"
41     Then I should see "Well done!"
42     And I should see "General feedback."
43     And I switch to the main window
45   @javascript
46   Scenario: Preview a question and submit a partially correct response.
47     When I click on "Edit" "link" in the "matching-001" "table_row"
48     And I set the following fields to these values:
49       | Shuffle    | 0   |
50     And I press "id_submitbutton"
51     When I click on "Preview" "link" in the "matching-001" "table_row"
52     And I switch to "questionpreview" window
53     And I set the field "How questions behave" to "Immediate feedback"
54     And I press "Start again with these options"
55     And I set the field with xpath "//table[@class='answer']//td[@class='control']//select[contains(@id, '1_sub0')]" to "amphibian"
56     And I set the field with xpath "//table[@class='answer']//td[@class='control']//select[contains(@id, '1_sub1')]" to "insect"
57     And I set the field with xpath "//table[@class='answer']//td[@class='control']//select[contains(@id, '1_sub2')]" to "amphibian"
58     And I press "Check"
59     Then I should see "Parts, but only parts, of your response are correct."
60     And I should see "General feedback."
61     And I switch to the main window
63   @javascript
64   Scenario: Preview a question and submit an incorrect response.
65     When I click on "Edit" "link" in the "matching-001" "table_row"
66     And I set the following fields to these values:
67       | Shuffle    | 0   |
68     And I press "id_submitbutton"
69     When I click on "Preview" "link" in the "matching-001" "table_row"
70     And I switch to "questionpreview" window
71     And I set the field "How questions behave" to "Immediate feedback"
72     And I press "Start again with these options"
73     And I set the field with xpath "//table[@class='answer']//td[@class='control']//select[contains(@id, '1_sub0')]" to "mammal"
74     And I set the field with xpath "//table[@class='answer']//td[@class='control']//select[contains(@id, '1_sub1')]" to "insect"
75     And I set the field with xpath "//table[@class='answer']//td[@class='control']//select[contains(@id, '1_sub2')]" to "insect"
76     And I press "Check"
77     Then I should see "That is not right at all."
78     And I should see "General feedback."
79     And I switch to the main window