MDL-47059 Grades: Update the grade_grade if the finalgrade/or the grademax has changed.
authorDamyon Wiese <damyon@moodle.com>
Fri, 19 Sep 2014 02:27:05 +0000 (10:27 +0800)
committerAdrian Greeve <adrian@moodle.com>
Fri, 3 Oct 2014 05:53:01 +0000 (13:53 +0800)
Part of: MDL-46576

lib/grade/grade_category.php

index 98720a8..9917e71 100644 (file)
@@ -677,10 +677,12 @@ class grade_category extends grade_object {
         $finalgrade = grade_grade::standardise_score($agg_grade, 0, 1, $result['grademin'], $result['grademax']);
 
         $grade->finalgrade = $this->grade_item->bounded_grade($finalgrade);
+        $oldrawgrademax = $grade->rawgrademax;
         $grade->rawgrademax = $result['grademax'];
 
         // update in db if changed
-        if (grade_floats_different($grade->finalgrade, $oldfinalgrade)) {
+        if (grade_floats_different($grade->finalgrade, $oldfinalgrade) ||
+            grade_floats_different($grade->rawgrademax, $oldrawgrademax)) {
             $grade->update('aggregation');
         }