MDL-50163 behat: Restart session after scenario with switch_window
[moodle.git] / mod / quiz / tests / behat / attempt_redo_questions.feature
CommitLineData
5e63b335
TH
1@mod @mod_quiz
2Feature: Allow students to redo questions in a practice quiz, without starting a whole new attempt
3 In order to practice particular skills I am struggling with
4 As a student
5 I need to be able to redo each question in a quiz as often as necessary without starting a whole new attempt, if my teacher allows it.
6
7 Background:
8 Given the following "users" exist:
0fe86bbd
RT
9 | username | firstname | lastname | email |
10 | student | Student | One | student@example.com |
11 | teacher | Teacher | One | teacher@example.com |
5e63b335
TH
12 And the following "courses" exist:
13 | fullname | shortname | category |
14 | Course 1 | C1 | 0 |
15 And the following "course enrolments" exist:
16 | user | course | role |
17 | student | C1 | student |
18 | teacher | C1 | teacher |
19 And the following "question categories" exist:
20 | contextlevel | reference | name |
21 | Course | C1 | Test questions |
22 And the following "questions" exist:
23 | questioncategory | qtype | name | questiontext |
24 | Test questions | truefalse | TF1 | First question |
25 | Test questions | truefalse | TF2 | Second question |
26 And the following "activities" exist:
27 | activity | name | intro | course | idnumber | preferredbehaviour | canredoquestions |
28 | quiz | Quiz 1 | Quiz 1 description | C1 | quiz1 | immediatefeedback | 1 |
29 And quiz "Quiz 1" contains the following questions:
30 | question | page | maxmark |
31 | TF1 | 1 | 2 |
32 | TF2 | 1 | 1 |
33 And I log in as "student"
34 And I follow "Course 1"
35
36 @javascript
37 Scenario: After completing a question, there is a redo question button that restarts the question
38 When I follow "Quiz 1"
39 And I press "Attempt quiz now"
40 And I click on "False" "radio" in the "First question" "question"
41 And I click on "Check" "button" in the "First question" "question"
42 And I press "Redo question"
43 Then the state of "First question" question is shown as "Not complete"
44 And I should see "Marked out of 2.00" in the "First question" "question"
45
46 @javascript
47 Scenario: The redo question button is visible but disabled for teachers
48 When I follow "Quiz 1"
49 And I press "Attempt quiz now"
50 And I click on "False" "radio" in the "First question" "question"
51 And I click on "Check" "button" in the "First question" "question"
52 And I log out
53 And I log in as "teacher"
54 And I follow "Course 1"
55 And I follow "Quiz 1"
56 And I follow "Attempts: 1"
57 And I follow "Review attempt"
58 Then the "Redo question" "button" should be disabled
59
60 @javascript
61 Scenario: The redo question buttons are no longer visible after the attempt is submitted.
62 When I follow "Quiz 1"
63 And I press "Attempt quiz now"
64 And I click on "False" "radio" in the "First question" "question"
65 And I click on "Check" "button" in the "First question" "question"
66 And I press "Next"
67 And I press "Submit all and finish"
68 And I click on "Submit all and finish" "button" in the "Confirmation" "dialogue"
69 Then "Redo question" "button" should not exist
70
131d4ac2 71 @javascript @_switch_window
5e63b335
TH
72 Scenario: Teachers reviewing can see all the qestions attempted in a slot
73 When I follow "Quiz 1"
74 And I press "Attempt quiz now"
75 And I click on "False" "radio" in the "First question" "question"
76 And I click on "Check" "button" in the "First question" "question"
77 And I press "Redo question"
78 And I press "Next"
79 And I press "Submit all and finish"
80 And I click on "Submit all and finish" "button" in the "Confirmation" "dialogue"
81 And I log out
82 And I log in as "teacher"
83 And I follow "Course 1"
84 And I follow "Quiz 1"
85 And I follow "Attempts: 1"
86 And I follow "Review attempt"
87 And I click on "1" "link" in the "First question" "question"
88 And I switch to "reviewquestion" window
89 Then the state of "First question" question is shown as "Incorrect"
90 And I click on "1" "link" in the "First question" "question"
91 And the state of "First question" question is shown as "Not complete"
92 And I switch to the main window
93 And the state of "First question" question is shown as "Not answered"
94 And I should not see "Submit" in the ".history" "css_element"
95 And I navigate to "Statistics" node in "Quiz administration > Results"
96 And I follow "TF1"
97 And "False" row "Frequency" column of "quizresponseanalysis" table should contain "100.00%"
98 And "True" row "Frequency" column of "quizresponseanalysis" table should contain "0.00%"
99 And "[No response]" row "Frequency" column of "quizresponseanalysis" table should contain "100.00%"
100
101 @javascript
102 Scenario: Redoing question 1 should save any changes to question 2 on the same page
103 When I follow "Quiz 1"
104 And I press "Attempt quiz now"
105 And I click on "False" "radio" in the "First question" "question"
106 And I click on "Check" "button" in the "First question" "question"
107 And I click on "True" "radio" in the "Second question" "question"
108 And I press "Redo question"
109 And I click on "Check" "button" in the "Second question" "question"
110 Then the state of "Second question" question is shown as "Correct"