Merge branch 'MDL-64286' of https://github.com/timhunt/moodle
[moodle.git] / question / type / gapselect / tests / behat / basic_test.feature
CommitLineData
8d892b1d 1@qtype @qtype_gapselect @_switch_window
45dba0d0
K
2Feature: Test all the basic functionality of this question type
3 In order to evaluate students responses, As a teacher I need to
4 create and preview gapselect (Select missing words) questions.
5
6 Background:
7 Given the following "users" exist:
8 | username | firstname | lastname | email |
9 | teacher1 | T1 | Teacher1 | teacher1@moodle.com |
10 And the following "courses" exist:
11 | fullname | shortname | category |
12 | Course 1 | C1 | 0 |
13 And the following "course enrolments" exist:
14 | user | course | role |
15 | teacher1 | C1 | editingteacher |
16
17 @javascript
18 Scenario: Create, edit then preview a gapselect question.
19 Given I log in as "teacher1"
fdeeaff9 20 And I am on "Course 1" course homepage
02fda279 21 And I navigate to "Question bank" in current page administration
45dba0d0
K
22
23 # Create a new question.
24 And I add a "Select missing words" question filling the form with:
25 | Question name | Select missing words 001 |
26 | Question text | The [[1]] [[2]] on the [[3]]. |
27 | General feedback | The cat sat on the mat. |
28 | id_choices_0_answer | cat |
29 | id_choices_1_answer | sat |
a3796190 30 | id_choices_1_choicegroup | 2 |
45dba0d0
K
31 | id_choices_2_answer | mat |
32 | id_choices_3_answer | dog |
33 | id_choices_4_answer | table |
a3796190
TH
34 | id_choices_5_answer | ran |
35 | id_choices_5_choicegroup | 2 |
45dba0d0
K
36 | Hint 1 | First hint |
37 | Hint 2 | Second hint |
38 Then I should see "Select missing words 001"
39
40 # Preview it.
41 When I click on "Preview" "link" in the "Select missing words 001" "table_row"
42 And I switch to "questionpreview" window
43
44 # Gaps (drop-down menus) do not have labels. ids and names are generated
45 # dynamically and therefore not reliable, i.e. this is an accessibility bug
46 # which need to be fixed at some stage. Meanwhile, I use the ids and increment
47 # them as appropriate (e.g.: q3_1_p1 become q4_1_p1, etc.).
48
49 # Set display and behaviour options
50 And I set the following fields to these values:
51 | How questions behave | Interactive with multiple tries |
52 | Marked out of | 3 |
53 | Marks | Show mark and max |
a3796190
TH
54 | Specific feedback | Shown |
55 | Right answer | Shown |
45dba0d0
K
56 And I press "Start again with these options"
57
58 # Answer question correctly
ac10e87b
TH
59 And I set space "1" to "cat" in the select missing words question
60 And I set space "2" to "sat" in the select missing words question
61 And I set space "3" to "mat" in the select missing words question
45dba0d0
K
62 And I press "Check"
63 Then I should see "Your answer is correct"
64 And I should see "The cat sat on the mat"
65 And I should see "The correct answer is: The [cat] [sat] on the [mat]."
66 And I press "Start again"
67
68 # Answer question partially correct twice and then correct
ac10e87b
TH
69 And I set space "1" to "cat" in the select missing words question
70 And I set space "2" to "sat" in the select missing words question
71 And I set space "3" to "dog" in the select missing words question
45dba0d0
K
72 And I press "Check"
73 Then I should see "Your answer is partially correct"
74 And I should see "First hint"
75
76 When I press "Try again"
ac10e87b 77 And I set space "3" to "table" in the select missing words question
45dba0d0
K
78 And I press "Check"
79 Then I should see "Your answer is partially correct"
80 And I should see "Second hint"
81
82 When I press "Try again"
ac10e87b 83 And I set space "3" to "mat" in the select missing words question
45dba0d0
K
84 And I press "Check"
85 Then I should see "Your answer is correct"
86 And I should see "The cat sat on the mat"
87 And I should see "The correct answer is: The [cat] [sat] on the [mat]."
88
89 # Set behaviour options
90 And I set the following fields to these values:
91 | behaviour | immediatefeedback |
92 And I press "Start again with these options"
93
94 # Answer question correctly
95 When I press "Check"
96 Then I should see "Please put an answer in each box."
ac10e87b
TH
97 And I set space "1" to "cat" in the select missing words question
98 And I set space "2" to "sat" in the select missing words question
99 And I set space "3" to "mat" in the select missing words question
45dba0d0
K
100 And I press "Check"
101 Then I should see "Your answer is correct"
102 And I should see "The cat sat on the mat"
103 And I should see "The correct answer is: The [cat] [sat] on the [mat]."
104 And I press "Start again"
105
106 # Answer question partially correct
ac10e87b
TH
107 And I set space "1" to "dog" in the select missing words question
108 And I set space "2" to "sat" in the select missing words question
109 And I set space "3" to "cat" in the select missing words question
45dba0d0
K
110 And I press "Check"
111 Then I should see "Your answer is partially correct"
112 And I should see "You have correctly selected 1."
113 And I should see "The cat sat on the mat"
114 And I should see "The correct answer is: The [cat] [sat] on the [mat]."
115 And I press "Start again"
116
117 # Answer question incorrectly
ac10e87b 118 And I set space "1" to "mat" in the select missing words question
a3796190
TH
119 And I set space "2" to "ran" in the select missing words question
120 And I set space "3" to "table" in the select missing words question
45dba0d0
K
121 And I press "Check"
122 Then I should see "Your answer is incorrect"
123 And I should see "The cat sat on the mat"
124 And I should see "The correct answer is: The [cat] [sat] on the [mat]."
125 And I switch to the main window
126
127 # Backup the course and restore it.
128 When I log out
129 And I log in as "admin"
130 When I backup "Course 1" course using this options:
131 | Confirmation | Filename | test_backup.mbz |
132 When I restore "test_backup.mbz" backup into a new course using this options:
133 | Schema | Course name | Course 2 |
134 Then I should see "Course 2"
02fda279 135 When I navigate to "Question bank" in current page administration
45dba0d0
K
136 Then I should see "Select missing words 001"
137
138 # Edit the copy and verify the form field contents.
139 When I click on "Edit" "link" in the "Select missing words 001" "table_row"
140 Then the following fields match these values:
141 | Question name | Select missing words 001 |
142 | Question text | The [[1]] [[2]] on the [[3]]. |
143 | General feedback | The cat sat on the mat. |
144 | id_choices_0_answer | cat |
145 | id_choices_1_answer | sat |
a3796190 146 | id_choices_1_choicegroup | 2 |
45dba0d0
K
147 | id_choices_2_answer | mat |
148 | id_choices_3_answer | dog |
149 | id_choices_4_answer | table |
a3796190
TH
150 | id_choices_5_answer | ran |
151 | id_choices_5_choicegroup | 2 |
45dba0d0
K
152 | Hint 1 | First hint |
153 | Hint 2 | Second hint |
154 And I set the following fields to these values:
155 | Question name | Edited question name |
156 And I press "id_submitbutton"
157 Then I should see "Edited question name"