Merge branch 'MDL-26768_0_grade' of git://github.com/andyjdavis/moodle
authorPetr Skoda <commits@skodak.org>
Mon, 21 Mar 2011 13:49:18 +0000 (14:49 +0100)
committerPetr Skoda <commits@skodak.org>
Mon, 21 Mar 2011 13:49:18 +0000 (14:49 +0100)
mod/lesson/lib.php

index ed5a0a0..4b31888 100644 (file)
@@ -487,7 +487,13 @@ function lesson_grade_item_update($lesson, $grades=NULL) {
             if (!is_array($grade)) {
                 $grades[$key] = $grade = (array) $grade;
             }
-            $grades[$key]['rawgrade'] = ($grade['rawgrade'] * $lesson->grade / 100);
+            //check raw grade isnt null otherwise we erroneously insert a grade of 0
+            if ($grade['rawgrade'] !== null) {
+                $grades[$key]['rawgrade'] = ($grade['rawgrade'] * $lesson->grade / 100);
+            } else {
+                //setting rawgrade to null just in case user is deleting a grade
+                $grades[$key]['rawgrade'] = null;
+            }
         }
     }