Fixed issue when scales are used (#242)
The grade item's type was being hard-coded to GRADE_TYPE_VALUE when this isn't always the case.
This commit is contained in:
parent
74a8a2f06c
commit
6f7ad60f09
1 changed files with 26 additions and 13 deletions
|
@ -542,31 +542,44 @@ class element_helper {
|
|||
return false;
|
||||
}
|
||||
|
||||
$gradeitem = grade_get_grades($cm->course, 'mod', $module->name, $cm->instance, $userid);
|
||||
$params = [
|
||||
'itemtype' => 'mod',
|
||||
'itemmodule' => $module->name,
|
||||
'iteminstance' => $cm->instance,
|
||||
'courseid' => $cm->course,
|
||||
'itemnumber' => 0
|
||||
];
|
||||
$gradeitem = \grade_item::fetch($params);
|
||||
|
||||
if (empty($gradeitem)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$item = new \grade_item();
|
||||
$item->gradetype = GRADE_TYPE_VALUE;
|
||||
$item->courseid = $cm->course;
|
||||
$itemproperties = reset($gradeitem->items);
|
||||
foreach ($itemproperties as $key => $value) {
|
||||
$item->$key = $value;
|
||||
$grade = grade_get_grades(
|
||||
$cm->course,
|
||||
'mod',
|
||||
$module->name,
|
||||
$cm->instance,
|
||||
$userid
|
||||
);
|
||||
|
||||
if (!isset($grade->items[0]->grades[$userid])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$objgrade = $item->grades[$userid];
|
||||
$gradebookgrade = $grade->items[0]->grades[$userid];
|
||||
|
||||
$dategraded = null;
|
||||
if (!empty($objgrade->dategraded)) {
|
||||
$dategraded = $objgrade->dategraded;
|
||||
if (!empty($gradebookgrade->dategraded)) {
|
||||
$dategraded = $gradebookgrade->dategraded;
|
||||
}
|
||||
|
||||
$displaygrade = grade_format_gradevalue($gradebookgrade->grade, $gradeitem, true, $gradeformat);
|
||||
|
||||
return new grade_information(
|
||||
$item->name,
|
||||
$objgrade->grade,
|
||||
grade_format_gradevalue($objgrade->grade, $item, true, $gradeformat),
|
||||
$gradeitem->get_name(),
|
||||
$gradebookgrade->grade,
|
||||
$displaygrade,
|
||||
$dategraded
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue