Skip to content

Commit

Permalink
MDL-43020: Fix lesson scale warnings when deleting user attempts
Browse files Browse the repository at this point in the history
  • Loading branch information
tlock committed Nov 25, 2013
1 parent 7a2b156 commit 7ce782e
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions mod/lesson/lib.php
Expand Up @@ -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 {
Expand Down

0 comments on commit 7ce782e

Please sign in to comment.