Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-43020: Lesson using a scale always gives the minimum scale value

  • Loading branch information...
commit ab077b368c7a551eb625d0cc81d35c3b2d4b5c10 1 parent 2b10fa0
@tlock tlock authored
Showing with 5 additions and 1 deletion.
  1. +5 −1 mod/lesson/lib.php
View
6 mod/lesson/lib.php
@@ -468,6 +468,10 @@ function lesson_grade_item_update($lesson, $grades=null) {
} else if ($lesson->grade < 0) {
$params['gradetype'] = GRADE_TYPE_SCALE;
$params['scaleid'] = -$lesson->grade;
+
+ // When converting a score to a scale, use scale's grade maximum to calculate it.
+ $grade = grade_get_grades($lesson->course, 'mod', 'lesson', $lesson->id, reset($grades)->userid);
+ $params['grademax'] = reset($grade->items)->grademax;
} else {
$params['gradetype'] = GRADE_TYPE_NONE;
}
@@ -488,7 +492,7 @@ function lesson_grade_item_update($lesson, $grades=null) {
}
//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);
+ $grades[$key]['rawgrade'] = ($grade['rawgrade'] * $params['grademax'] / 100);
} else {
//setting rawgrade to null just in case user is deleting a grade
$grades[$key]['rawgrade'] = null;
Please sign in to comment.
Something went wrong with that request. Please try again.