2 Feature: We can use calculated grade totals
3 In order to calculate grade totals
5 I need to add aggregate columns to the gradebook
8 Given the following "courses" exist:
9 | fullname | shortname | category | groupmode |
10 | Course 1 | C1 | 0 | 1 |
11 And the following "users" exist:
12 | username | firstname | lastname | email | idnumber |
13 | teacher1 | Teacher | 1 | teacher1@asd.com | t1 |
14 | student1 | Student | 1 | student1@asd.com | s1 |
15 And the following "course enrolments" exist:
16 | user | course | role |
17 | teacher1 | C1 | editingteacher |
18 | student1 | C1 | student |
19 And the following "grade categories" exist:
21 | Sub category 1 | C1 |
22 | Sub category 2 | C1 |
23 And the following "activities" exist:
24 | activity | course | idnumber | name | intro | grade |
25 | assign | C1 | a1 | Test assignment one | Submit something! | 300 |
26 | assign | C1 | a2 | Test assignment two | Submit something! | 100 |
27 | assign | C1 | a3 | Test assignment three | Submit something! | 150 |
28 | assign | C1 | a4 | Test assignment four | Submit nothing! | 150 |
29 And the following "activities" exist:
30 | activity | course | idnumber | name | intro | gradecategory | grade |
31 | assign | C1 | a5 | Test assignment five | Submit something! | Sub category 1 | 20 |
32 | assign | C1 | a6 | Test assignment six | Submit something! | Sub category 1 | 10 |
33 | assign | C1 | a7 | Test assignment seven | Submit nothing! | Sub category 1 | 15 |
34 And the following "activities" exist:
35 | activity | course | idnumber | name | intro | gradecategory | grade |
36 | assign | C1 | a8 | Test assignment eight | Submit something! | Sub category 2 | 20 |
37 | assign | C1 | a9 | Test assignment nine | Submit something! | Sub category 2 | 10 |
38 | assign | C1 | 10 | Test assignment ten | Submit nothing! | Sub category 2 | 15 |
39 And I log in as "admin"
40 And I set the following administration settings values:
41 | grade_aggregations_visible | Mean of grades,Weighted mean of grades,Simple weighted mean of grades,Mean of grades (with extra credits),Median of grades,Lowest grade,Highest grade,Mode of grades,Natural |
43 And I log in as "teacher1"
44 And I follow "Course 1"
46 And I turn editing mode on
47 And I give the grade "60.00" to the user "Student 1" for the grade item "Test assignment one"
48 And I give the grade "20.00" to the user "Student 1" for the grade item "Test assignment two"
49 And I give the grade "40.00" to the user "Student 1" for the grade item "Test assignment three"
50 And I give the grade "10.00" to the user "Student 1" for the grade item "Test assignment five"
51 And I give the grade "5.00" to the user "Student 1" for the grade item "Test assignment six"
52 And I give the grade "10.00" to the user "Student 1" for the grade item "Test assignment eight"
53 And I give the grade "5.00" to the user "Student 1" for the grade item "Test assignment nine"
54 And I press "Save changes"
55 And I set the following settings for grade item "Test assignment two":
57 And I set the following settings for grade item "Test assignment five":
59 And I set the following settings for grade item "Test assignment eight":
61 And I navigate to "Course grade settings" node in "Grade administration > Settings"
62 And I set the field "Grade display type" to "Real (percentage)"
63 And I press "Save changes"
66 Scenario: Mean of grades aggregation
67 And I set the following settings for grade item "Course 1":
68 | Aggregation | Mean of grades |
69 And I set the following settings for grade item "Sub category 1":
70 | Aggregation | Mean of grades |
71 And I set the following settings for grade item "Sub category 2":
72 | Aggregation | Mean of grades |
73 | Exclude empty grades | 0 |
74 And I turn editing mode off
75 Then I should see "30.00 (30.00 %)" in the ".course" "css_element"
76 And I navigate to "Course grade settings" node in "Grade administration > Settings"
77 And I set the field "Hide totals if they contain hidden items" to "Show totals excluding hidden items"
78 And I press "Save changes"
80 And I log in as "student1"
81 And I follow "Course 1"
83 And I set the field "Grade report" to "Overview report"
84 And I should see "30.42 (30.42 %)" in the "overview-grade" "table"
87 Scenario: Weighted mean of grades aggregation
88 And I set the following settings for grade item "Course 1":
89 | Aggregation | Weighted mean of grades |
90 And I set the following settings for grade item "Sub category 1":
91 | Aggregation | Weighted mean of grades |
93 And I set the following settings for grade item "Sub category 2":
94 | Aggregation | Weighted mean of grades |
96 | Exclude empty grades | 0 |
97 And I set the following settings for grade item "Test assignment one":
99 And I turn editing mode off
100 Then I should see "27.14 (27.14 %)" in the ".course" "css_element"
101 And I navigate to "Course grade settings" node in "Grade administration > Settings"
102 And I set the field "Hide totals if they contain hidden items" to "Show totals excluding hidden items"
103 And I press "Save changes"
105 And I log in as "student1"
106 And I follow "Course 1"
107 And I follow "Grades"
108 And I set the field "Grade report" to "Overview report"
109 And I should see "26.94 (26.94 %)" in the "overview-grade" "table"
112 Scenario: Simple weighted mean of grades aggregation
113 And I set the following settings for grade item "Course 1":
114 | Aggregation | Simple weighted mean of grades |
115 And I set the following settings for grade item "Sub category 1":
116 | Aggregation | Simple weighted mean of grades |
117 And I set the following settings for grade item "Sub category 2":
118 | Aggregation | Simple weighted mean of grades |
119 | Exclude empty grades | 0 |
120 And I set the following settings for grade item "Test assignment one":
122 And I turn editing mode off
123 Then I should see "45.19 (45.19 %)" in the ".course" "css_element"
124 And I navigate to "Course grade settings" node in "Grade administration > Settings"
125 And I set the field "Hide totals if they contain hidden items" to "Show totals excluding hidden items"
126 And I press "Save changes"
128 And I log in as "student1"
129 And I follow "Course 1"
130 And I follow "Grades"
131 And I set the field "Grade report" to "Overview report"
132 And I should see "48.57 (48.57 %)" in the "overview-grade" "table"
135 Scenario: Mean of grades (with extra credits) aggregation
136 And I set the following settings for grade item "Course 1":
137 | Aggregation | Mean of grades (with extra credits) |
138 And I set the following settings for grade item "Sub category 1":
139 | Aggregation | Mean of grades (with extra credits) |
140 And I set the following settings for grade item "Sub category 2":
141 | Aggregation | Mean of grades (with extra credits) |
142 | Exclude empty grades | 0 |
143 And I set the following settings for grade item "Test assignment one":
144 | Extra credit weight | 2 |
145 And I turn editing mode off
146 Then I should see "42.50 (42.50 %)" in the ".course" "css_element"
147 And I navigate to "Course grade settings" node in "Grade administration > Settings"
148 And I set the field "Hide totals if they contain hidden items" to "Show totals excluding hidden items"
149 And I press "Save changes"
151 And I log in as "student1"
152 And I follow "Course 1"
153 And I follow "Grades"
154 And I set the field "Grade report" to "Overview report"
155 And I should see "47.22 (47.22 %)" in the "overview-grade" "table"
158 Scenario: Median of grades aggregation
159 And I set the following settings for grade item "Course 1":
160 | Aggregation | Median of grades |
161 And I set the following settings for grade item "Sub category 1":
162 | Aggregation | Median of grades |
163 And I set the following settings for grade item "Sub category 2":
164 | Aggregation | Median of grades |
165 | Exclude empty grades | 0 |
166 And I turn editing mode off
167 Then I should see "26.67 (26.67 %)" in the ".course" "css_element"
168 And I navigate to "Course grade settings" node in "Grade administration > Settings"
169 And I set the field "Hide totals if they contain hidden items" to "Show totals excluding hidden items"
170 And I press "Save changes"
172 And I log in as "student1"
173 And I follow "Course 1"
174 And I follow "Grades"
175 And I set the field "Grade report" to "Overview report"
176 And I should see "25.83 (25.83 %)" in the "overview-grade" "table"
179 Scenario: Lowest grade aggregation
180 And I set the following settings for grade item "Course 1":
181 | Aggregation | Lowest grade |
182 And I set the following settings for grade item "Sub category 1":
183 | Aggregation | Lowest grade |
184 And I set the following settings for grade item "Sub category 2":
185 | Aggregation | Lowest grade |
186 | Exclude empty grades | 0 |
187 And I set the following settings for grade item "Test assignment five":
189 And I set the following settings for grade item "Test assignment four":
191 And I turn editing mode off
192 Then I should see "0.00 (0.00 %)" in the ".course" "css_element"
193 And I navigate to "Course grade settings" node in "Grade administration > Settings"
194 And I set the field "Hide totals if they contain hidden items" to "Show totals excluding hidden items"
195 And I press "Save changes"
197 And I log in as "student1"
198 And I follow "Course 1"
199 And I follow "Grades"
200 And I set the field "Grade report" to "Overview report"
201 And I should see "0.00 (0.00 %)" in the "overview-grade" "table"
204 Scenario: Highest grade aggregation
205 And I set the following settings for grade item "Course 1":
206 | Aggregation | Highest grade |
207 And I set the following settings for grade item "Sub category 1":
208 | Aggregation | Highest grade |
209 And I set the following settings for grade item "Sub category 2":
210 | Aggregation | Highest grade |
211 | Exclude empty grades | 0 |
212 And I set the following settings for grade item "Test assignment one":
214 And I turn editing mode off
215 Then I should see "50.00 (50.00 %)" in the ".course" "css_element"
216 And I navigate to "Course grade settings" node in "Grade administration > Settings"
217 And I set the field "Hide totals if they contain hidden items" to "Show totals excluding hidden items"
218 And I press "Save changes"
220 And I log in as "student1"
221 And I follow "Course 1"
222 And I follow "Grades"
223 And I set the field "Grade report" to "Overview report"
224 And I should see "50.00 (50.00 %)" in the "overview-grade" "table"
227 Scenario: Mode of grades aggregation
228 And I set the following settings for grade item "Course 1":
229 | Aggregation | Mode of grades |
230 And I set the following settings for grade item "Sub category 1":
231 | Aggregation | Mode of grades |
232 And I set the following settings for grade item "Sub category 1":
233 | Aggregation | Mode of grades |
234 | Exclude empty grades | 0 |
235 And I set the following settings for grade item "Test assignment one":
237 And I turn editing mode off
238 Then I should see "50.00 (50.00 %)" in the ".course" "css_element"
239 And I navigate to "Course grade settings" node in "Grade administration > Settings"
240 And I set the field "Hide totals if they contain hidden items" to "Show totals excluding hidden items"
241 And I press "Save changes"
243 And I log in as "student1"
244 And I follow "Course 1"
245 And I follow "Grades"
246 And I set the field "Grade report" to "Overview report"
247 And I should see "50.00 (50.00 %)" in the "overview-grade" "table"
250 Scenario: Natural aggregation
251 And I set the following settings for grade item "Sub category 1":
252 | Aggregation | Natural |
253 | Exclude empty grades | 0 |
254 And I set the following settings for grade item "Sub category 2":
255 | Aggregation | Natural |
256 | Exclude empty grades | 1 |
257 And I set the following settings for grade item "Course 1":
258 | Aggregation | Natural |
259 | Exclude empty grades | 0 |
260 And I set the following settings for grade item "Test assignment six":
261 | Weight adjusted | 1 |
262 | aggregationcoef2 | 50 |
263 And I set the following settings for grade item "Test assignment three":
265 And I turn editing mode off
266 Then I should see "152.68 (24.43 %)" in the ".course" "css_element"
267 And I navigate to "Course grade settings" node in "Grade administration > Settings"
268 And I set the field "report_overview_showtotalsifcontainhidden" to "Show totals excluding hidden items"
269 And I set the field "report_user_showtotalsifcontainhidden" to "Show totals excluding hidden items"
270 And I set the field "Show contribution to course total" to "Show"
271 And I set the field "Show weightings" to "Show"
272 And I press "Save changes"
273 And I set the field "Grade report" to "User report"
274 And the following should exist in the "user-grade" table:
275 | Grade item | Calculated weight | Grade | Range |
276 | Test assignment five | 28.57 % | 10.00 (50.00 %) | 0–20 |
277 | Test assignment six | 50.00 % | 5.00 (50.00 %) | 0–10 |
278 | Test assignment seven | 21.43 % | - | 0–15 |
279 | Test assignment eight | 66.67 % | 10.00 (50.00 %) | 0–20 |
280 | Test assignment nine | 33.33 % | 5.00 (50.00 %) | 0–10 |
281 | Test assignment ten | -( Empty ) | - | 0–15 |
282 | Test assignment one | 48.00 % | 60.00 (20.00 %) | 0–300 |
283 | Test assignment two | 16.00 % | 20.00 (20.00 %) | 0–100 |
284 | Test assignment three | 24.00 %( Extra credit ) | 40.00 (26.67 %) | 0–150 |
285 | Test assignment four | 24.00 % | - | 0–150 |
287 And I log in as "student1"
288 And I follow "Course 1"
289 And I follow "Grades"
290 And I set the field "Grade report" to "Overview report"
291 And I should see "113.75 (23.45 %)" in the "overview-grade" "table"
292 And I set the field "Grade report" to "User report"
293 And the following should exist in the "user-grade" table:
294 | Grade item | Calculated weight | Grade | Range |
295 | Test assignment six | 70.00 % | 5.00 (50.00 %) | 0–10 |
296 | Test assignment seven | 30.00 % | - | 0–15 |
297 | Test assignment nine | 100.00 % | 5.00 (50.00 %) | 0–10 |
298 | Test assignment ten | -( Empty ) | - | 0–15 |
299 | Test assignment one | 61.86 % | 60.00 (20.00 %) | 0–300 |
300 | Test assignment three | 30.93 %( Extra credit ) | 40.00 (26.67 %) | 0–150 |
301 | Test assignment four | 30.93 % | - | 0–150 |
304 Scenario: Natural aggregation with drop lowest
306 And I log in as "admin"
307 And I follow "Course 1"
308 And I follow "Grades"
309 And I turn editing mode on
310 And I set the following settings for grade item "Sub category 1":
311 | Aggregation | Natural |
312 | Exclude empty grades | 0 |
313 And I set the following settings for grade item "Sub category 2":
314 | Aggregation | Natural |
315 | Exclude empty grades | 0 |
316 And I set the following settings for grade item "Course 1":
317 | Aggregation | Natural |
318 | Exclude empty grades | 0 |
319 And I navigate to "Set up grades layout" node in "Grade administration > Settings"
320 And I press "Add category"
321 And I click on "Show more" "link"
322 And I set the following fields to these values:
323 | Category name | Sub category 3 |
324 | Aggregation | Natural |
325 | Drop the lowest | 1 |
326 And I press "Save changes"
327 And I press "Add grade item"
328 And I set the following fields to these values:
329 | Item name | Manual item 1 |
330 | Grade category | Sub category 3 |
331 And I press "Save changes"
332 And I press "Add grade item"
333 And I set the following fields to these values:
334 | Item name | Manual item 2 |
335 | Grade category | Sub category 3 |
336 And I press "Save changes"
337 And I press "Add grade item"
338 And I set the following fields to these values:
339 | Item name | Manual item 3 |
340 | Grade category | Sub category 3 |
341 And I press "Save changes"
342 And I follow "Grader report"
343 And I give the grade "60.00" to the user "Student 1" for the grade item "Manual item 1"
344 And I give the grade "20.00" to the user "Student 1" for the grade item "Manual item 2"
345 And I give the grade "40.00" to the user "Student 1" for the grade item "Manual item 3"
346 And I press "Save changes"
347 And I turn editing mode off
348 Then I should see "250.00 (25.25 %)" in the ".course" "css_element"
349 And I turn editing mode on
350 And I set the following settings for grade item "Manual item 2":
352 And I turn editing mode off
353 And I should see "270.00 (27.27 %)" in the ".course" "css_element"
354 And I turn editing mode on
355 And I set the following settings for grade item "Manual item 2":
357 | Maximum grade | 200 |
358 And I give the grade "21.00" to the user "Student 1" for the grade item "Manual item 2"
359 And I press "Save changes"
360 And I give the grade "20.00" to the user "Student 1" for the grade item "Manual item 2"
361 And I press "Save changes"
362 And I turn editing mode off
363 And I should see "270.00 (22.69 %)" in the ".course" "css_element"
364 And I turn editing mode on
365 And I set the following settings for grade item "Manual item 2":
367 | Maximum grade | 100 |
368 And I give the grade "21.00" to the user "Student 1" for the grade item "Manual item 2"
369 And I press "Save changes"
370 And I give the grade "20.00" to the user "Student 1" for the grade item "Manual item 2"
371 And I press "Save changes"
372 And I turn editing mode off
373 And I should see "250.00 (25.25 %)" in the ".course" "css_element"
374 And I navigate to "Set up grades layout" node in "Grade administration > Settings"
375 And I press "Add category"
376 And I set the following fields to these values:
377 | Category name | Sub sub category 1 |
378 | Parent category | Sub category 3 |
379 And I press "Save changes"
380 And I follow "Grader report"
381 And I should see "270.00 (24.77 %)" in the ".course" "css_element"
384 Scenario: Natural aggregation from the setup screen
385 And I set the field "Grade report" to "Set up grades layout"
386 And I follow "Edit Course 1"
387 And I set the field "Aggregation" to "Natural"
388 And I press "Save changes"
389 And I follow "Edit Sub category 1"
390 And I set the field "Aggregation" to "Natural"
391 And I press "Save changes"
392 And I follow "Edit Sub category 2"
393 And I set the field "Aggregation" to "Natural"
394 And I press "Save changes"
396 And I set the field "Override weight of Test assignment one" to "1"
397 And the field "Weight of Test assignment one" matches value "37.975"
398 And I set the field "Weight of Test assignment one" to "10"
400 And I set the field "Override weight of Test assignment two" to "1"
401 And the field "Weight of Test assignment two" matches value "12.658"
402 And I set the field "Override weight of Test assignment two" to "0"
404 And I set the field "Override weight of Test assignment six" to "1"
405 And the field "Weight of Test assignment six" matches value "22.222"
406 And I set the field "Weight of Test assignment six" to "50"
407 And I set the field "Override weight of Test assignment six" to "0"
409 And I set the field "Override weight of Test assignment ten" to "1"
410 And the field "Weight of Test assignment ten" matches value "33.333"
411 And I set the field "Weight of Test assignment ten" to "50"
413 And I set the field "Override weight of Sub category 1" to "1"
414 And the field "Weight of Sub category 1" matches value "5.696"
415 And I set the field "Weight of Sub category 1" to "15"
417 When I press "Save changes"
418 And I set the field "Override weight of Test assignment two" to "1"
419 And I set the field "Override weight of Test assignment six" to "1"
421 Then the field "Weight of Test assignment one" matches value "10.0"
422 And the field "Weight of Test assignment two" matches value "16.854"
423 And the field "Weight of Test assignment six" matches value "22.222"
424 And the field "Weight of Test assignment ten" matches value "50.0"
425 And the field "Weight of Sub category 1" matches value "15.0"
426 And I set the field "Override weight of Test assignment one" to "0"
427 And I set the field "Override weight of Test assignment two" to "0"
428 And I set the field "Override weight of Test assignment six" to "0"
429 And I set the field "Override weight of Sub category 1" to "0"
430 And I press "Save changes"
431 And I set the field "Override weight of Test assignment one" to "1"
432 And I set the field "Override weight of Sub category 1" to "1"
433 And the field "Weight of Test assignment one" matches value "37.975"
434 And the field "Weight of Sub category 1" matches value "5.696"
435 And I click on "Reset weights of Sub category 2" "link"
436 And the field "Weight of Test assignment ten" matches value "33.333"