MDL-64161 gradereport_singleview: Stop updating grades with errors.
authorAdrian Greeve <abgreeve@gmail.com>
Mon, 26 Nov 2018 02:56:28 +0000 (10:56 +0800)
committerAdrian Greeve <abgreeve@gmail.com>
Mon, 26 Nov 2018 03:44:26 +0000 (11:44 +0800)
grade/report/singleview/classes/local/screen/screen.php
grade/report/singleview/classes/local/ui/finalgrade.php

index db3ecb6..44dcbc1 100644 (file)
@@ -355,6 +355,10 @@ abstract class screen {
             // Optional type.
             if (!empty($msg)) {
                 $warnings[] = $msg;
+                if ($element instanceof \gradereport_singleview\local\ui\finalgrade) {
+                    // This item wasn't changed so don't add to the changecount.
+                    continue;
+                }
             }
             if (preg_match('/_(\d+)_(\d+)/', $varname, $matchelement)) {
                 $changecount[$matchelement[0]] = 1;
index fe9a17e..fd5e026 100644 (file)
@@ -170,9 +170,11 @@ class finalgrade extends grade_attribute_format implements unique_value, be_disa
             }
             $gradestr->itemname = $this->grade->grade_item->get_name();
             $errorstr = get_string($errorstr, 'grades', $gradestr);
+            return $errorstr;
         }
 
+        // Only update grades if there are no errors.
         $gradeitem->update_final_grade($userid, $finalgrade, 'singleview', $feedback, FORMAT_MOODLE);
-        return $errorstr;
+        return '';
     }
 }