MDL-48239 gradebook: Change to calculated grade item min and max.

Regardless of the setting 'Min and max grades used in calculation'
Calculated grade items will always update the min and max raw grade.
This commit is contained in:
Adrian Greeve
2015-07-02 11:13:26 +08:00
parent 716c081049
commit 6a7c8feb10
3 changed files with 38 additions and 25 deletions
@@ -105,8 +105,8 @@ Feature: Calculated grade items can be used in the gradebook
And the following should exist in the "user-grade" table:
| Grade item | Calculated weight | Grade | Range | Percentage | Contribution to course total |
| grade item 1 | - | 75.00 | 0100 | 75.00 % | - |
| Calc cat totalInclude empty grades. | 100.00 % | 37.50 | 050 | 75.00 % | - |
| Course total | - | 37.50 | 050 | 75.00 % | - |
| Calc cat totalInclude empty grades. | 100.00 % | 37.50 | 040 | 93.75 % | - |
| Course total | - | 37.50 | 040 | 93.75 % | - |
And I select "Student 2" from the "Select all or one user" singleselect
And the following should exist in the "user-grade" table:
| Grade item | Calculated weight | Grade | Range | Percentage | Contribution to course total |
@@ -153,9 +153,9 @@ Feature: Calculated grade items can be used in the gradebook
And I select "Student 1" from the "Select all or one user" singleselect
And the following should exist in the "user-grade" table:
| Grade item | Calculated weight | Grade | Range | Percentage | Contribution to course total |
| grade item 1 | 66.67 % | 75.00 | 0100 | 75.00 % | 50.00 % |
| calc item | 33.33 % | 37.50 | 050 | 75.00 % | 25.00 % |
| Course total | - | 112.50 | 0150 | 75.00 % | - |
| grade item 1 | 71.43 % | 75.00 | 0100 | 75.00 % | 53.57 % |
| calc item | 28.57 % | 37.50 | 040 | 93.75 % | 26.79 % |
| Course total | - | 112.50 | 0140 | 80.36 % | - |
And I select "Student 2" from the "Select all or one user" singleselect
And the following should exist in the "user-grade" table:
| Grade item | Calculated weight | Grade | Range | Percentage | Contribution to course total |
+12 -12
View File
@@ -148,20 +148,20 @@ Feature: We can choose what min or max grade to use when aggregating grades.
And I select "Student 1" from the "Select all or one user" singleselect
Then the following should exist in the "user-grade" table:
| Grade item | Calculated weight | Grade | Range | Percentage | Contribution to course total |
| MI 1 | 20.00 % | 75.00 | 0100 | 75.00 % | 15.00 % |
| MI 2 | 20.00 % | 25.00 | 0100 | 25.00 % | 5.00 % |
| MI 3 | 50.00 % | 50.00 | 0100 | 50.00 % | 10.00 % |
| MI 4 | 50.00 % | 100.00 | 0100 | 100.00 % | 20.00 % |
| MI 5 | 20.00 % | 150.00 | 0100 | 100.00 % | 30.00 % |
| CAT1 total | 40.00 % | 150.00 | 0200 | 75.00 % | - |
| Course total | - | 400.00 | 0500 | 80.00 % | - |
| MI 1 | 16.67 % | 75.00 | 0100 | 75.00 % | 12.50 % |
| MI 2 | 16.67 % | 25.00 | 0100 | 25.00 % | 4.17 % |
| MI 3 | 50.00 % | 50.00 | 0100 | 50.00 % | 8.33 % |
| MI 4 | 50.00 % | 100.00 | 0100 | 100.00 % | 16.67 % |
| MI 5 | 33.33 % | 150.00 | 0200 | 75.00 % | 25.00 % |
| CAT1 total | 33.33 % | 150.00 | 0200 | 75.00 % | - |
| Course total | - | 400.00 | 0600 | 66.67 % | - |
And I select "Student 2" from the "Select all or one user" singleselect
And the following should exist in the "user-grade" table:
| Grade item | Calculated weight | Grade | Range | Percentage | Contribution to course total |
| MI 1 | 33.33 % | 20.00 | 0100 | 20.00 % | 6.67 % |
| MI 1 | 25.00 % | 20.00 | 0100 | 20.00 % | 5.00 % |
| MI 2 | 0.00 % | - | 0100 | - | 0.00 % |
| MI 3 | 100.00 % | 10.00 | 0100 | 10.00 % | 3.33 % |
| MI 3 | 100.00 % | 10.00 | 0100 | 10.00 % | 2.50 % |
| MI 4 | 0.00 % | - | 0100 | - | 0.00 % |
| MI 5 | 33.33 % | 30.00 | 0100 | 30.00 % | 10.00 % |
| CAT1 total | 33.33 % | 10.00 | 0100 | 10.00 % | - |
| Course total | - | 60.00 | 0300 | 20.00 % | - |
| MI 5 | 50.00 % | 30.00 | 0200 | 15.00 % | 7.50 % |
| CAT1 total | 25.00 % | 10.00 | 0100 | 10.00 % | - |
| Course total | - | 60.00 | 0400 | 15.00 % | - |
+21 -8
View File
@@ -2013,17 +2013,30 @@ class grade_item extends grade_object {
// normalize
$grade->finalgrade = $this->bounded_grade($result);
}
}
// update in db if changed
if (grade_floats_different($grade->finalgrade, $oldfinalgrade)) {
$grade->timemodified = time();
$success = $grade->update('compute');
// Only run through this code if the gradebook isn't frozen.
if ($gradebookcalculationsfreeze && (int)$gradebookcalculationsfreeze <= 20150627) {
// Update in db if changed.
if (grade_floats_different($grade->finalgrade, $oldfinalgrade)) {
$grade->timemodified = time();
$success = $grade->update('compute');
// If successful trigger a user_graded event.
if ($success) {
\core\event\user_graded::create_from_grade($grade)->trigger();
// If successful trigger a user_graded event.
if ($success) {
\core\event\user_graded::create_from_grade($grade)->trigger();
}
}
} else {
// Update in db if changed.
if (grade_floats_different($grade->finalgrade, $oldfinalgrade) || $rawminandmaxchanged) {
$grade->timemodified = time();
$success = $grade->update('compute');
// If successful trigger a user_graded event.
if ($success) {
\core\event\user_graded::create_from_grade($grade)->trigger();
}
}
}