Skip to content
Browse files

MDL-43020: Fix lesson scale warnings when deleting user attempts

  • Loading branch information...
1 parent 20d1fea commit 6ba76e04dfd7550e5245c3cd749a7ce701363b1a @tlock tlock committed Nov 25, 2013
Showing with 12 additions and 2 deletions.
  1. +12 −2 mod/lesson/lib.php
View
14 mod/lesson/lib.php
@@ -469,9 +469,19 @@ function lesson_grade_item_update($lesson, $grades=null) {
$params['gradetype'] = GRADE_TYPE_SCALE;
$params['scaleid'] = -$lesson->grade;
- // When converting a score to a scale, use scale's grade maximum to calculate it.
+ // Make sure current grade fetched correctly from $grades
+ $currentgrade = null;
if (!empty($grades)) {
- $grade = grade_get_grades($lesson->course, 'mod', 'lesson', $lesson->id, reset($grades)->userid);
+ if (is_array($grades)) {
+ $currentgrade = reset($grades);
+ } else {
+ $currentgrade = $grades;
+ }
+ }
+
+ // When converting a score to a scale, use scale's grade maximum to calculate it.
+ if (!empty($currentgrade) && $currentgrade->rawgrade !== null) {
+ $grade = grade_get_grades($lesson->course, 'mod', 'lesson', $lesson->id, $currentgrade->userid);
$params['grademax'] = reset($grade->items)->grademax;
}
} else {

0 comments on commit 6ba76e0

Please sign in to comment.
Something went wrong with that request. Please try again.