Fixed issue with grade not displaying
This commit is contained in:
parent
5e29aebeb6
commit
e5f9f9e928
1 changed files with 11 additions and 10 deletions
|
@ -282,23 +282,24 @@ class customcert_element_grade extends customcert_element_base {
|
||||||
$cm = $DB->get_record('course_modules', array('id' => $moduleid), '*', MUST_EXIST);
|
$cm = $DB->get_record('course_modules', array('id' => $moduleid), '*', MUST_EXIST);
|
||||||
$module = $DB->get_record('modules', array('id' => $cm->module), '*', MUST_EXIST);
|
$module = $DB->get_record('modules', array('id' => $cm->module), '*', MUST_EXIST);
|
||||||
|
|
||||||
if ($gradeitem = grade_get_grades($cm->course, 'mod', $module->name, $cm->instance, $userid)) {
|
$gradeitem = grade_get_grades($cm->course, 'mod', $module->name, $cm->instance, $userid);
|
||||||
$gradeitem = new grade_item();
|
if (!empty($gradeitem)) {
|
||||||
$gradeitem->gradetype = GRADE_TYPE_VALUE;
|
$item = new grade_item();
|
||||||
$gradeitem->courseid = $cm->course;
|
$item->gradetype = GRADE_TYPE_VALUE;
|
||||||
$gradeitemproperties = reset($gradeitem->items);
|
$item->courseid = $cm->course;
|
||||||
foreach ($gradeitemproperties as $key => $value) {
|
$itemproperties = reset($gradeitem->items);
|
||||||
$gradeitem->$key = $value;
|
foreach ($itemproperties as $key => $value) {
|
||||||
|
$item->$key = $value;
|
||||||
}
|
}
|
||||||
// Grade for the user.
|
// Grade for the user.
|
||||||
$grade = $gradeitem->grades[$userid]->grade;
|
$grade = $item->grades[$userid]->grade;
|
||||||
// Create the object we will be returning.
|
// Create the object we will be returning.
|
||||||
$modinfo = new stdClass;
|
$modinfo = new stdClass;
|
||||||
$modinfo->name = $DB->get_field($module->name, 'name', array('id' => $cm->instance));
|
$modinfo->name = $DB->get_field($module->name, 'name', array('id' => $cm->instance));
|
||||||
$modinfo->gradetodisplay = grade_format_gradevalue($grade, $gradeitem, true, $gradeformat, 2);
|
$modinfo->gradetodisplay = grade_format_gradevalue($grade, $item, true, $gradeformat, 2);
|
||||||
|
|
||||||
if ($grade) {
|
if ($grade) {
|
||||||
$modinfo->dategraded = $gradeitem->grades[$userid]->dategraded;
|
$modinfo->dategraded = $item->grades[$userid]->dategraded;
|
||||||
} else {
|
} else {
|
||||||
$modinfo->dategraded = time();
|
$modinfo->dategraded = time();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue