880a34144b1adac8a327f55b19229b74abe9c783
[moodle.git] / grade / report / grader / tests / behat / ajax_grader.feature
1 @gradereport @gradereport_grader
2 Feature: Using the AJAX grading feature of Grader report to update grades and feedback
3   In order to use AJAX grading
4   As a teacher
5   I need to be able to update and verify grades
8   Background:
9     Given the following "courses" exist:
10       | fullname | shortname | category | groupmode |
11       | Course 1 | C1 | 0 | 1 |
12     And the following "users" exist:
13       | username | firstname | lastname | email | idnumber |
14       | teacher1 | Teacher | 1 | teacher1@example.com | t1 |
15       | student1 | Student | 1 | student1@example.com | s1 |
16       | student2 | Student | 2 | student2@example.com | s2 |
17       | student3 | Student | 3 | student3@example.com | s3 |
18     And the following "course enrolments" exist:
19       | user | course | role |
20       | teacher1 | C1 | editingteacher |
21       | student1 | C1 | student |
22       | student2 | C1 | student |
23       | student3 | C1 | student |
24     And the following "scales" exist:
25       | name       | scale                                  |
26       | Test Scale | Disappointing,Good,Very good,Excellent |
27     And the following "grade categories" exist:
28       | fullname | course |
29       | Grade Cat | C1 |
30     And the following "grade items" exist:
31       | itemname | course | locked | gradetype | gradecategory |
32       | Item 1 | C1 | 0 | value | Grade Cat |
33       | Item VU | C1 | 0 | value | Grade Cat |
34       | Item VL | C1 | 1 | value | Grade Cat |
35       | Item TU | C1 | 0 | text | Grade Cat |
36       | Item TL | C1 | 1 | text | Grade Cat |
37     And the following "grade items" exist:
38       | itemname | course | locked | gradetype | scale | gradecategory |
39       | Item SU | C1 | 0 | scale | Test Scale | Grade Cat |
40       | Item SL | C1 | 1 | scale | Test Scale | Grade Cat |
41     And the following "grade items" exist:
42       | itemname | course | locked | gradetype | gradecategory |
43       | Item 3 | C1 | 0 | value | Grade Cat |
44     And the following config values are set as admin:
45       | grade_report_showaverages | 0 |
46       | grade_report_enableajax | 1 |
49   @javascript
50   Scenario: Use the grader report without editing, with AJAX on and quick feedback off
51     When the following config values are set as admin:
52       | grade_overridecat | 1 |
53       | grade_report_showquickfeedback | 0 |
54     And I log in as "teacher1"
55     And I follow "Course 1"
56     And I navigate to "Grades" node in "Course administration"
57     And I click on student "Student 2" for grade item "Item VU"
58     Then I should see a grade field for "Student 2" and grade item "Item VU"
59     And I should not see a feedback field for "Student 2" and grade item "Item VU"
60     And I set the field "ajaxgrade" to "33"
61     And I press key "13" in the field "ajaxgrade"
62     And I should not see a grade field for "Student 2" and grade item "Item VU"
63     And I should not see a feedback field for "Student 2" and grade item "Item VU"
64     And I click on student "Student 3" for grade item "Item VU"
65     And I set the field "ajaxgrade" to "50"
66     And I press key "13" in the field "ajaxgrade"
67     And I click on student "Student 3" for grade item "Item 1"
68     And I set the field "ajaxgrade" to "80"
69     And I press key "13" in the field "ajaxgrade"
70     And I click on student "Student 3" for grade item "Item SU"
71     And I set the field "ajaxgrade" to "Very good"
72     And I press key "13" in the field "ajaxgrade"
73     And the following should exist in the "user-grades" table:
74       | -1-                | -4-      | -5-      | -9-       | -13-         |
75       | Student 2          | -        | 33.00    | -         | 33.00        |
76       | Student 3          | 80.00    | 50.00    | Very good | 133.00       |
77     And I click on student "Student 3" for grade item "Item VL"
78     And I should not see a grade field for "Student 3" and grade item "Item VL"
79     And I should not see a feedback field for "Student 3" and grade item "Item VL"
80     And I click on student "Student 3" for grade item "Item SL"
81     And I should not see a grade field for "Student 3" and grade item "Item SL"
82     And I should not see a feedback field for "Student 3" and grade item "Item SL"
83     And I click on student "Student 3" for grade item "Item TU"
84     And I should not see a grade field for "Student 3" and grade item "Item TU"
85     And I should not see a feedback field for "Student 3" and grade item "Item TU"
86     And I click on student "Student 1" for grade item "Course total"
87     And I should see a grade field for "Student 1" and grade item "Course total"
88     And I should not see a feedback field for "Student 1" and grade item "Course total"
89     And I set the field "ajaxgrade" to "90"
90     And I press key "13" in the field "ajaxgrade"
91     And the following should exist in the "user-grades" table:
92       | -1-                | -13-      |
93       | Student 1          | 90.00     |
94     And I navigate to "Grader report" node in "Grade administration"
95     And the following should exist in the "user-grades" table:
96       | -1-                | -4-      | -5-      | -9-       | -13-         |
97       | Student 1          | -        | -        | -         | 90.00        |
98       | Student 2          | -        | 33.00    | -         | 33.00        |
99       | Student 3          | 80.00    | 50.00    | Very good | 133.00       |
101   @javascript
102   Scenario: Use the grader report without editing, with AJAX and quick feedback on
103     When the following config values are set as admin:
104       | grade_overridecat | 1 |
105       | grade_report_showquickfeedback | 1 |
106     And I log in as "teacher1"
107     And I follow "Course 1"
108     And I navigate to "Grades" node in "Course administration"
109     And I click on student "Student 2" for grade item "Item VU"
110     Then I should see a grade field for "Student 2" and grade item "Item VU"
111     And I should see a feedback field for "Student 2" and grade item "Item VU"
112     And I set the field "ajaxgrade" to "33"
113     And I set the field "ajaxfeedback" to "Student 2 VU feedback"
114     And I press key "13" in the field "ajaxfeedback"
115     And I click on student "Student 3" for grade item "Item VL"
116     And I should not see a grade field for "Student 3" and grade item "Item VL"
117     And I should not see a feedback field for "Student 3" and grade item "Item VL"
118     And I click on student "Student 3" for grade item "Item TU"
119     And I should not see a grade field for "Student 3" and grade item "Item TU"
120     And I should see a feedback field for "Student 3" and grade item "Item TU"
121     And I set the field "ajaxfeedback" to "Student 3 TU feedback"
122     And I press key "13" in the field "ajaxfeedback"
123     And I click on student "Student 2" for grade item "Item SU"
124     And I set the field "ajaxgrade" to "Very good"
125     And I set the field "ajaxfeedback" to "Student 2 SU feedback"
126     And I press key "13" in the field "ajaxfeedback"
127     And I navigate to "Grader report" node in "Grade administration"
128     And the following should exist in the "user-grades" table:
129       | -1-                | -5-      | -9-       | -13-         |
130       | Student 2          | 33.00    | Very good | 36.00        |
131     And I click on student "Student 3" for grade item "Item TU"
132     And the field "ajaxfeedback" matches value "Student 3 TU feedback"
133     And I click on student "Student 2" for grade item "Item SU"
134     And the field "ajaxfeedback" matches value "Student 2 SU feedback"
136   @javascript
137   Scenario: Use the grader report without editing, with AJAX and quick feedback on, without category override
138     When the following config values are set as admin:
139       | grade_overridecat | 0 |
140       | grade_report_showquickfeedback | 1 |
141     And I log in as "teacher1"
142     And I follow "Course 1"
143     And I navigate to "Grades" node in "Course administration"
144     And I click on student "Student 2" for grade item "Item VU"
145     Then I should see a grade field for "Student 2" and grade item "Item VU"
146     And I should see a feedback field for "Student 2" and grade item "Item VU"
147     And I set the field "ajaxgrade" to "33"
148     And I press key "13" in the field "ajaxgrade"
149     And I click on student "Student 2" for grade item "Course total"
150     And I should not see a grade field for "Student 3" and grade item "Course total"
151     And I should not see a feedback field for "Student 3" and grade item "Course total"
152     And the following should exist in the "user-grades" table:
153       | -1-                | -5-      | -13-    |
154       | Student 2          | 33.00    | 33.00   |
156   @javascript
157   Scenario: Use the grader report with editing, with AJAX and quick feedback on, with category override
158     When the following config values are set as admin:
159       | grade_overridecat | 1 |
160       | grade_report_showquickfeedback | 1 |
161     And I log in as "teacher1"
162     And I follow "Course 1"
163     And I navigate to "Grades" node in "Course administration"
164     And I turn editing mode on
165     Then I should not see a grade field for "Student 2" and grade item "Item VL"
166     And I should not see a feedback field for "Student 2" and grade item "Item VL"
167     And I should not see a grade field for "Student 2" and grade item "Item TU"
168     And I should see a feedback field for "Student 2" and grade item "Item TU"
169     And I should see a grade field for "Student 2" and grade item "Course total"
170     And I should see a feedback field for "Student 2" and grade item "Course total"
171     And I give the grade "20.00" to the user "Student 2" for the grade item "Item VU"
172     And I click away from student "Student 2" and grade item "Item VU" value
173     And I give the grade "30.00" to the user "Student 2" for the grade item "Item 1"
174     And I give the feedback "Some feedback" to the user "Student 2" for the grade item "Item 1"
175     And I click away from student "Student 2" and grade item "Item 1" feedback
176     And I give the grade "Very good" to the user "Student 2" for the grade item "Item SU"
177     And I click away from student "Student 2" and grade item "Item SU" value
178     And the grade for "Student 2" in grade item "Grade Cat" should match "53.00"
179     And the grade for "Student 2" in grade item "Course total" should match "53.00"
180     And I turn editing mode off
181     And the following should exist in the "user-grades" table:
182       | -1-                | -4-      | -5-     | -9-       | -12-     | -13-    |
183       | Student 2          | 30.00    | 20.00   | Very good | 53.00    | 53.00   |
184     And I click on student "Student 2" for grade item "Item 1"
185     And the field "ajaxfeedback" matches value "Some feedback"
187   @javascript
188   Scenario: Use the grader report with editing, with AJAX and quick feedback on, without category override
189     When the following config values are set as admin:
190       | grade_overridecat | 0 |
191       | grade_report_showquickfeedback | 1 |
192     And I log in as "teacher1"
193     And I follow "Course 1"
194     And I navigate to "Grades" node in "Course administration"
195     And I turn editing mode on
196     Then I should not see a grade field for "Student 2" and grade item "Course total"
197     And I should not see a feedback field for "Student 2" and grade item "Course total"
198     And I give the grade "20.00" to the user "Student 2" for the grade item "Item VU"
199     And I click away from student "Student 2" and grade item "Item VU" value
200     And I give the grade "30.00" to the user "Student 2" for the grade item "Item 1"
201     And I click away from student "Student 2" and grade item "Item 1" value
202     And I give the feedback "Some feedback" to the user "Student 2" for the grade item "Item 1"
203     And I click away from student "Student 2" and grade item "Item 1" feedback
204     And the following should exist in the "user-grades" table:
205       | -1-                | -13-     |
206       | Student 2          | 50.00    |
207     And I turn editing mode off
208     And the following should exist in the "user-grades" table:
209       | -1-                | -4-      | -5-      | -13-         |
210       | Student 2          | 30.00    | 20.00    | 50.00        |
211     And I click on student "Student 2" for grade item "Item 1"
212     And the field "ajaxfeedback" matches value "Some feedback"