MDL-36804 Assignment attempt history: Fix warning on saving a new grade.
authorDamyon Wiese <damyon@moodle.com>
Fri, 5 Apr 2013 02:03:00 +0000 (10:03 +0800)
committerDamyon Wiese <damyon@moodle.com>
Fri, 5 Apr 2013 02:03:00 +0000 (10:03 +0800)
This is a fix for the case when there is a submission but no grade.

mod/assign/locallib.php

index 9f8bc37..04c8219 100644 (file)
@@ -1692,6 +1692,10 @@ class assign {
             }
         }
 
+        if (empty($grade->attemptnumber)) {
+            // Set it to the default.
+            $grade->attemptnumber = 0;
+        }
         $result = $DB->update_record('assign_grades', $grade);
 
         // Only push to gradebook if the update is for the latest attempt.