MDL-60858 feedback: update behat tests for lang string change
[moodle.git] / mod / feedback / tests / behat / multichoice.feature
blob0b977934b8d32ff17ad3b580e01b0875ab70feac
1 @mod @mod_feedback
2 Feature: Testing multichoice questions in feedback
3   In order to create feedbacks
4   As a teacher
5   I need to be able to create different types of multichoice questions
7   Background:
8     Given the following "users" exist:
9       | username | firstname | lastname |
10       | teacher1 | Teacher   | 1        |
11       | student1 | Student   | 1        |
12       | student2 | Student   | 2        |
13     And the following "courses" exist:
14       | fullname | shortname |
15       | Course 1 | C1        |
16     And the following "course enrolments" exist:
17       | user     | course | role           |
18       | teacher1 | C1     | editingteacher |
19       | student1 | C1     | student        |
20       | student2 | C1     | student        |
21     And the following "activities" exist:
22       | activity   | name                | course | idnumber    |
23       | feedback   | Learning experience | C1     | feedback0   |
24     And I log in as "teacher1"
25     And I am on "Course 1" course homepage
26     And I follow "Learning experience"
27     And I click on "Edit questions" "link" in the "[role=main]" "css_element"
29   @javascript
30   Scenario: Non-rated single-answer multiple choice questions in feedback
31     When I add a "Multiple choice" question to the feedback with:
32       | Question         | this is a multiple choice 1 |
33       | Label            | multichoice1                |
34       | Multiple choice type | Multiple choice - single answer |
35       | Multiple choice values | option a\noption b\noption c  |
36     And I add a "Label" question to the feedback with:
37       | Contents | this is the first page of the feedback |
38     And I select "Add a page break" from the "Add question" singleselect
39     And I add a "Multiple choice" question to the feedback with:
40       | Question         | this is a multiple choice 2 |
41       | Label            | multichoice2                |
42       | Multiple choice type | Multiple choice - single answer |
43       | Multiple choice values | option d\noption e\noption f  |
44       | Required | 1 |
45     And I add a "Label" question to the feedback with:
46       | Contents | this is the second page of the feedback |
47     And I select "Add a page break" from the "Add question" singleselect
48     And I add a "Multiple choice" question to the feedback with:
49       | Question         | this is a multiple choice 3 |
50       | Label            | multichoice3                |
51       | Multiple choice type | Multiple choice - single answer |
52       | Multiple choice values | option g\noption h\noption i  |
53       | Hide the "Not selected" option | Yes                   |
54       | Dependence item                | multichoice2          |
55       | Dependence value               | option d              |
56     And I add a "Label" question to the feedback with:
57       | Contents | this is the third page of the feedback |
58     And I log out
59     And I log in as "student1"
60     And I am on "Course 1" course homepage
61     And I follow "Learning experience"
62     And I follow "Answer the questions"
63     # Examine the first page, select nothing, go to the next page
64     Then the following fields match these values:
65       | Not selected | 1 |
66       | option a     | 0 |
67       | option b     | 0 |
68       | option c     | 0 |
69     And "Previous page" "button" should not exist
70     And "Submit your answers" "button" should not exist
71     And I should see "this is the first page of the feedback"
72     And I should not see "this is the second page of the feedback"
73     And I should not see "this is the third page of the feedback"
74     And I press "Next page"
75     # Examine the second page, select nothing, try to go to the next page
76     And I should see "Not selected"
77     And the following fields match these values:
78       | Not selected | 1 |
79       | option d     | 0 |
80       | option e     | 0 |
81       | option f     | 0 |
82     And "Previous page" "button" should exist
83     And "Submit your answers" "button" should not exist
84     And I should not see "this is the first page of the feedback"
85     And I should see "this is the second page of the feedback"
86     And I should not see "this is the third page of the feedback"
87     And I press "Next page"
88     # We are still on the second page because the field is required
89     And I should see "Required" in the "form" "css_element"
90     And I should see "this is the second page of the feedback"
91     And I set the field "option e" to "1"
92     And the following fields match these values:
93       | Not selected | 0 |
94       | option d     | 0 |
95       | option e     | 1 |
96       | option f     | 0 |
97     And I press "Next page"
98     # Now we are on the third page, element is not shown because of wrong dependency.
99     And I should see "this is the third page of the feedback"
100     And I should not see "this is a multiple choice 3"
101     # Go back, check that values are preserved and change the option to enable dependency.
102     And I press "Previous page"
103     And the following fields match these values:
104       | Not selected | 0 |
105       | option d     | 0 |
106       | option e     | 1 |
107       | option f     | 0 |
108     And I set the field "option d" to "1"
109     And I press "Next page"
110     # Now third page contains all items.
111     And I should see "this is a multiple choice 3"
112     And I should see "this is the third page of the feedback"
113     And I should not see "Not selected"
114     And the following fields match these values:
115       | option g     | 0 |
116       | option h     | 0 |
117       | option i     | 0 |
118     And "Previous page" "button" should exist
119     And "Next page" "button" should not exist
120     And "Submit your answers" "button" should exist
121     And I set the field "option i" to "1"
122     And I press "Submit your answers"
123     And I log out
124     # Student 2 tries to trick - he answers the third question and then
125     # goes back and changes dependency question. Analysis should not show this answer!
126     And I log in as "student2"
127     And I am on "Course 1" course homepage
128     And I follow "Learning experience"
129     And I follow "Answer the questions"
130     And I set the field "option a" to "1"
131     And I press "Next page"
132     And I set the field "option d" to "1"
133     And I press "Next page"
134     And I set the field "option g" to "1"
135     And I press "Previous page"
136     And I set the field "option f" to "1"
137     And I press "Next page"
138     And I press "Submit your answers"
139     And I log out
140     # Login as teacher and check analysis
141     And I log in as "teacher1"
142     And I am on "Course 1" course homepage
143     And I follow "Learning experience"
144     And I navigate to "Analysis" in current page administration
145     And I should see "Submitted answers: 2"
146     And I should see "Questions: 3"
147     And I show chart data for the "multichoice1" feedback
148     And I should see "1 (50.00 %)" in the "option a" "table_row"
149     And I should not see "%" in the "option b" "table_row"
150     And I should not see "%" in the "option c" "table_row"
151     And I show chart data for the "multichoice2" feedback
152     And I should see "1 (50.00 %)" in the "option d" "table_row"
153     And I should not see "%" in the "option e" "table_row"
154     And I should see "1 (50.00 %)" in the "option f" "table_row"
155     And I show chart data for the "multichoice3" feedback
156     And I should not see "%" in the "option g" "table_row"
157     And I should not see "%" in the "option h" "table_row"
158     And I should see "1 (100.00 %)" in the "option i" "table_row"
159     # Change the settings so we don't analyse empty submits
160     And I click on "Edit questions" "link" in the "[role=main]" "css_element"
161     And I open the action menu in "//div[contains(@class, 'feedback_itemlist') and contains(.,'multichoice1')]" "xpath_element"
162     And I choose "Edit question" in the open action menu
163     And I set the field "Do not analyse empty submits" to "Yes"
164     And I press "Save changes to question"
165     And I follow "Analysis"
166     And I show chart data for the "multichoice1" feedback
167     And I should see "1 (100.00 %)" in the "option a" "table_row"
168     And I should not see "%" in the "option b" "table_row"
169     And I should not see "%" in the "option c" "table_row"
170     And I log out
172   @javascript
173   Scenario: Non-rated multiple-answers multiple choice questions in feedback
174     # Create a feedback with three pages, required and dependent questions.
175     When I add a "Multiple choice" question to the feedback with:
176       | Question         | this is a multiple choice 1 |
177       | Label            | multichoice1                |
178       | Multiple choice type | Multiple choice - multiple answers |
179       | Multiple choice values | option a\noption b\noption c  |
180     And I add a "Label" question to the feedback with:
181       | Contents | this is the first page of the feedback |
182     And I select "Add a page break" from the "Add question" singleselect
183     And I add a "Multiple choice" question to the feedback with:
184       | Question         | this is a multiple choice 2 |
185       | Label            | multichoice2                |
186       | Multiple choice type | Multiple choice - multiple answers |
187       | Multiple choice values | option d\noption e\noption f  |
188       | Required | 1 |
189     And I add a "Label" question to the feedback with:
190       | Contents | this is the second page of the feedback |
191     And I select "Add a page break" from the "Add question" singleselect
192     And I add a "Multiple choice" question to the feedback with:
193       | Question         | this is a multiple choice 3 |
194       | Label            | multichoice3                |
195       | Multiple choice type | Multiple choice - multiple answers |
196       | Multiple choice values | option g\noption h\noption i  |
197       | Dependence item                | multichoice2          |
198       | Dependence value               | option d              |
199     And I add a "Label" question to the feedback with:
200       | Contents | this is the third page of the feedback |
201     And I log out
202     # Login as the first student.
203     And I log in as "student1"
204     And I am on "Course 1" course homepage
205     And I follow "Learning experience"
206     And I follow "Answer the questions"
207     # Examine the first page, select nothing, go to the next page
208     And I should not see "Not selected"
209     And the following fields match these values:
210       | option a     | 0 |
211       | option b     | 0 |
212       | option c     | 0 |
213     And "Previous page" "button" should not exist
214     And "Submit your answers" "button" should not exist
215     And I should see "this is the first page of the feedback"
216     And I should not see "this is the second page of the feedback"
217     And I should not see "this is the third page of the feedback"
218     And I press "Next page"
219     # Examine the second page, select nothing, try to go to the next page
220     Then I should not see "Not selected"
221     And the following fields match these values:
222       | option d     | 0 |
223       | option e     | 0 |
224       | option f     | 0 |
225     And "Previous page" "button" should exist
226     And "Submit your answers" "button" should not exist
227     And I should not see "this is the first page of the feedback"
228     And I should see "this is the second page of the feedback"
229     And I should not see "this is the third page of the feedback"
230     And I press "Next page"
231     # We are still on the second page because the field is required
232     And I should see "Required" in the "form" "css_element"
233     And I should see "this is the second page of the feedback"
234     And I set the field "option e" to "1"
235     And I set the field "option f" to "1"
236     And the following fields match these values:
237       | option d     | 0 |
238       | option e     | 1 |
239       | option f     | 1 |
240     And I press "Next page"
241     # Now we are on the third page, element is not shown because of wrong dependency.
242     And I should see "this is the third page of the feedback"
243     And I should not see "this is a multiple choice 3"
244     # Go back, check that values are preserved and change the option to enable dependency.
245     And I press "Previous page"
246     And the following fields match these values:
247       | option d     | 0 |
248       | option e     | 1 |
249       | option f     | 1 |
250     And I set the field "option d" to "1"
251     And I set the field "option e" to "0"
252     And I press "Next page"
253     # Now third page contains all items.
254     And I should see "this is a multiple choice 3"
255     And I should see "this is the third page of the feedback"
256     And the following fields match these values:
257       | option g     | 0 |
258       | option h     | 0 |
259       | option i     | 0 |
260     And "Previous page" "button" should exist
261     And "Next page" "button" should not exist
262     And "Submit your answers" "button" should exist
263     And I set the field "option i" to "1"
264     And I press "Submit your answers"
265     And I log out
266     # Student 2 tries to trick - he answers the third question and then
267     # goes back and changes dependency question. Analysis should not show this answer!
268     And I log in as "student2"
269     And I am on "Course 1" course homepage
270     And I follow "Learning experience"
271     And I follow "Answer the questions"
272     And I set the field "option a" to "1"
273     And I set the field "option b" to "1"
274     And I press "Next page"
275     And I set the field "option d" to "1"
276     And I press "Next page"
277     And I set the field "option g" to "1"
278     And I press "Previous page"
279     And I set the field "option d" to "0"
280     And I set the field "option f" to "1"
281     And I press "Next page"
282     And I press "Submit your answers"
283     And I log out
284     # Login as teacher and check analysis
285     And I log in as "teacher1"
286     And I am on "Course 1" course homepage
287     And I follow "Learning experience"
288     And I navigate to "Analysis" in current page administration
289     And I should see "Submitted answers: 2"
290     And I should see "Questions: 3"
291     And I show chart data for the "multichoice1" feedback
292     And I should see "1 (50.00 %)" in the "option a" "table_row"
293     And I should see "1 (50.00 %)" in the "option b" "table_row"
294     And I should not see "%" in the "option c" "table_row"
295     And I show chart data for the "multichoice2" feedback
296     And I should see "1 (50.00 %)" in the "option d" "table_row"
297     And I should not see "%" in the "option e" "table_row"
298     And I should see "2 (100.00 %)" in the "option f" "table_row"
299     And I show chart data for the "multichoice3" feedback
300     And I should not see "%" in the "option g" "table_row"
301     And I should not see "%" in the "option h" "table_row"
302     And I should see "1 (100.00 %)" in the "option i" "table_row"
303     # Change the settings so we don't analyse empty submits
304     And I click on "Edit questions" "link" in the "[role=main]" "css_element"
305     And I open the action menu in "//div[contains(@class, 'feedback_itemlist') and contains(.,'multichoice1')]" "xpath_element"
306     And I choose "Edit question" in the open action menu
307     And I set the field "Do not analyse empty submits" to "Yes"
308     And I press "Save changes to question"
309     And I follow "Analysis"
310     And I show chart data for the "multichoice1" feedback
311     And I should see "1 (100.00 %)" in the "option a" "table_row"
312     And I should see "1 (100.00 %)" in the "option b" "table_row"
313     And I should not see "%" in the "option c" "table_row"
314     And I log out
316   @javascript
317   Scenario: Non-rated single-answer dropdown multiple choice questions in feedback
318     When I add a "Multiple choice" question to the feedback with:
319       | Question         | this is a multiple choice 1 |
320       | Label            | multichoice1                |
321       | Multiple choice type | Multiple choice - single answer allowed (dropdownlist) |
322       | Multiple choice values | option a\noption b\noption c  |
323     And I add a "Label" question to the feedback with:
324       | Contents | this is the first page of the feedback |
325     And I select "Add a page break" from the "Add question" singleselect
326     And I add a "Multiple choice" question to the feedback with:
327       | Question         | this is a multiple choice 2 |
328       | Label            | multichoice2                |
329       | Multiple choice type | Multiple choice - single answer allowed (dropdownlist) |
330       | Multiple choice values | option d\noption e\noption f  |
331       | Required | 1 |
332     And I add a "Label" question to the feedback with:
333       | Contents | this is the second page of the feedback |
334     And I select "Add a page break" from the "Add question" singleselect
335     And I add a "Multiple choice" question to the feedback with:
336       | Question         | this is a multiple choice 3 |
337       | Label            | multichoice3                |
338       | Multiple choice type | Multiple choice - single answer allowed (dropdownlist) |
339       | Multiple choice values | option g\noption h\noption i  |
340       | Dependence item                | multichoice2          |
341       | Dependence value               | option d              |
342     And I add a "Label" question to the feedback with:
343       | Contents | this is the third page of the feedback |
344     And I log out
345     And I log in as "student1"
346     And I am on "Course 1" course homepage
347     And I follow "Learning experience"
348     And I follow "Answer the questions"
349     # Examine the first page, select nothing, go to the next page
350     Then the following fields match these values:
351       | this is a multiple choice 1 | 0 |
352     And "Previous page" "button" should not exist
353     And "Submit your answers" "button" should not exist
354     And I should see "this is the first page of the feedback"
355     And I should not see "this is the second page of the feedback"
356     And I should not see "this is the third page of the feedback"
357     And I press "Next page"
358     # Examine the second page, select nothing, try to go to the next page
359     And the following fields match these values:
360       | this is a multiple choice 2 | 0 |
361     And "Previous page" "button" should exist
362     And "Submit your answers" "button" should not exist
363     And I should not see "this is the first page of the feedback"
364     And I should see "this is the second page of the feedback"
365     And I should not see "this is the third page of the feedback"
366     And I press "Next page"
367     # We are still on the second page because the field is required
368     And I should see "Required" in the "form" "css_element"
369     And I should see "this is the second page of the feedback"
370     And I set the field "this is a multiple choice 2" to "option e"
371     And I press "Next page"
372     # Now we are on the third page, element is not shown because of wrong dependency.
373     And I should see "this is the third page of the feedback"
374     And I should not see "this is a multiple choice 3"
375     # Go back, check that values are preserved and change the option to enable dependency.
376     And I press "Previous page"
377     And the following fields match these values:
378       | this is a multiple choice 2 | option e |
379     And I set the field "this is a multiple choice 2" to "option d"
380     And I press "Next page"
381     # Now third page contains all items.
382     And I should see "this is the third page of the feedback"
383     And the following fields match these values:
384       | this is a multiple choice 3 | 0 |
385     And "Previous page" "button" should exist
386     And "Next page" "button" should not exist
387     And "Submit your answers" "button" should exist
388     And I set the field "this is a multiple choice 3" to "option i"
389     And I press "Submit your answers"
390     And I log out
391     # Student 2 tries to trick - he answers the third question and then
392     # goes back and changes dependency question. Analysis should not show this answer!
393     And I log in as "student2"
394     And I am on "Course 1" course homepage
395     And I follow "Learning experience"
396     And I follow "Answer the questions"
397     And I set the field "this is a multiple choice 1" to "option a"
398     And I press "Next page"
399     And I set the field "this is a multiple choice 2" to "option d"
400     And I press "Next page"
401     And I set the field "this is a multiple choice 3" to "option g"
402     And I press "Previous page"
403     And I set the field "this is a multiple choice 2" to "option f"
404     And I press "Next page"
405     And I press "Submit your answers"
406     And I log out
407     # Login as teacher and check analysis
408     And I log in as "teacher1"
409     And I am on "Course 1" course homepage
410     And I follow "Learning experience"
411     And I navigate to "Analysis" in current page administration
412     And I should see "Submitted answers: 2"
413     And I should see "Questions: 3"
414     And I show chart data for the "multichoice1" feedback
415     And I should see "1 (50.00 %)" in the "option a" "table_row"
416     And I should not see "%" in the "option b" "table_row"
417     And I should not see "%" in the "option c" "table_row"
418     And I show chart data for the "multichoice2" feedback
419     And I should see "1 (50.00 %)" in the "option d" "table_row"
420     And I should not see "%" in the "option e" "table_row"
421     And I should see "1 (50.00 %)" in the "option f" "table_row"
422     And I show chart data for the "multichoice3" feedback
423     And I should not see "%" in the "option g" "table_row"
424     And I should not see "%" in the "option h" "table_row"
425     And I should see "1 (100.00 %)" in the "option i" "table_row"
426     # Change the settings so we don't analyse empty submits
427     And I click on "Edit questions" "link" in the "[role=main]" "css_element"
428     And I open the action menu in "//div[contains(@class, 'feedback_itemlist') and contains(.,'multichoice1')]" "xpath_element"
429     And I choose "Edit question" in the open action menu
430     And I set the field "Do not analyse empty submits" to "Yes"
431     And I press "Save changes to question"
432     And I follow "Analysis"
433     And I show chart data for the "multichoice1" feedback
434     And I should see "1 (100.00 %)" in the "option a" "table_row"
435     And I should not see "%" in the "option b" "table_row"
436     And I should not see "%" in the "option c" "table_row"
437     And I log out