MDL-47676 core_grades: Negative positive weight combo working.
authorAdrian Greeve <adrian@moodle.com>
Wed, 15 Oct 2014 02:34:49 +0000 (10:34 +0800)
committerAdrian Greeve <adrian@moodle.com>
Fri, 24 Oct 2014 00:43:16 +0000 (08:43 +0800)
The combination of negative and positive weights was not normalising
properly.

lib/grade/grade_category.php

index f9cb3db..dc2f0b3 100644 (file)
@@ -1478,7 +1478,9 @@ class grade_category extends grade_object {
             if (!$gradeitemdetail['extracredit']) {
                 $normalisetotal += $gradeitemdetail['weight'];
             }
-            if ($gradeitemdetail['weightoverride'] && !$gradeitemdetail['extracredit']) {
+            // The overridden total comprises of items that are set as overridden, that aren't extra credit and have a value
+            // greater than zero.
+            if ($gradeitemdetail['weightoverride'] && !$gradeitemdetail['extracredit'] && $gradeitemdetail['weight'] > 0) {
                 // Add overriden weights up to see if they are greater than 1.
                 $overriddentotal += $gradeitemdetail['weight'];
             }