Closed logan-reynolds closed 4 years ago
Hi Logan,
I solved by changing the $course_item variable in the rows 730, 731 anda 732 by $courseitem
case self::COURSE_GRADE: //Course grade -- if ($course_item = grade_item::fetch_course_item($this->get_course()->id)) { -- $grade = new grade_grade(array('itemid' => $course_item->id, 'userid' => $userid)); -- $course_item->gradetype = GRADE_TYPE_VALUE; ++ if ($courseitem = grade_item::fetch_course_item($this->get_course()->id)) { ++ $grade = new grade_grade(array('itemid' => $courseitem->id, 'userid' => $userid)); ++ $courseitem->gradetype = GRADE_TYPE_VALUE; $coursegrade = new stdClass();
$decimals = $courseitem->get_decimals();
// String used.
$coursegrade->points = grade_format_gradevalue($grade->finalgrade, $courseitem, true, GRADE_DISPLAY_TYPE_REAL, $decimals = 2);
$coursegrade->percentage = grade_format_gradevalue($grade->finalgrade, $courseitem, true, GRADE_DISPLAY_TYPE_PERCENTAGE, $decimals = 2);
$coursegrade->letter = grade_format_gradevalue($grade->finalgrade, $courseitem, true, GRADE_DISPLAY_TYPE_LETTER, $decimals = 0);
}
break;
Sorry, i can't reproduce this error in moodle3.9dev
Describe the bug On Totara 12 when using latest M3.3-compliant release 2.2.8 version 2018080400 of mod_certificate: The following error is encountered when Print grade is set to Course grade if no course grade exists (i.e. the course total grade has not been set yet.) Noting this error goes away if the mod_simplecertificate instance is switched back to it's default value of "No grade", so this appears to be happening because arithmetic-related operation get_decimals() is being called assuming a numeric value exists when it doesn't. I believe the fix would be to check the value is set to some numeric value instead of null, and take some alternate action if the value is null (assuming that would equate to 0 if no course grade has been calculated yet...): `` Exception - Call to a member function get_decimals() on null Debug info: Error code: generalexceptionmessage Stack trace:
Output buffer:
Notice: Undefined variable: courseitem in /var/www/html/TOTARA_120_STABLE/mod/simplecertificate/locallib.php on line 735
``
Moodle Version(s) Totara 12
To Reproduce
Expected behavior Certificate should display
Screenshots