Merge branch 'MDL-26571_lesson_scale' of git://github.com/andyjdavis/moodle
authorPetr Skoda <commits@skodak.org>
Mon, 21 Mar 2011 13:52:11 +0000 (14:52 +0100)
committerPetr Skoda <commits@skodak.org>
Mon, 21 Mar 2011 13:52:11 +0000 (14:52 +0100)
1  2 
mod/lesson/lib.php

diff --combined mod/lesson/lib.php
@@@ -469,6 -469,9 +469,9 @@@ function lesson_grade_item_update($less
          $params['gradetype']  = GRADE_TYPE_VALUE;
          $params['grademax']   = $lesson->grade;
          $params['grademin']   = 0;
+     } else if ($lesson->grade < 0) {
+         $params['gradetype']  = GRADE_TYPE_SCALE;
+         $params['scaleid']   = -$lesson->grade;
      } else {
          $params['gradetype']  = GRADE_TYPE_NONE;
      }
              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;
 +            }
          }
      }