mirror of
https://github.com/moodle/moodle.git
synced 2025-04-13 12:32:08 +02:00
MDL-78066 enrol_lti: fix deep linking error in multiple grade items case
If an activity, like workshop or forum, has multiple grade items, declarative binding of the grade item (line item) isn't supported. Instead of throwing an exception, handle the case more elegantly and just omit the 'add to gradebook' option for these activities.
This commit is contained in:
parent
32a34f805f
commit
68b6ca2f69
@ -96,19 +96,20 @@ class published_resource_repository {
|
||||
$resource->supportsgrades = false;
|
||||
$resource->grademax = null;
|
||||
|
||||
// Only activities with GRADE_TYPE_VALUE are valid.
|
||||
// Only activities having a single grade item of GRADE_TYPE_VALUE are eligible for declarative binding.
|
||||
if (plugin_supports('mod', $mod->modname, FEATURE_GRADE_HAS_GRADE)) {
|
||||
$gradeitem = \grade_item::fetch([
|
||||
'courseid' => $resource->courseid,
|
||||
'itemtype' => 'mod',
|
||||
'itemmodule' => $mod->modname,
|
||||
'iteminstance' => $mod->instance
|
||||
]);
|
||||
if ($gradeitem && $gradeitem->gradetype == GRADE_TYPE_VALUE) {
|
||||
$gradinginfo = grade_get_grades($resource->courseid, 'mod', $mod->modname,
|
||||
$mod->instance);
|
||||
$resource->supportsgrades = true;
|
||||
$resource->grademax = (int) $gradinginfo->items[0]->grademax;
|
||||
$gradinginfo = grade_get_grades($resource->courseid, 'mod', $mod->modname, $mod->instance);
|
||||
if (count($gradinginfo->items) == 1) {
|
||||
$gradeitem = \grade_item::fetch([
|
||||
'courseid' => $resource->courseid,
|
||||
'itemtype' => 'mod',
|
||||
'itemmodule' => $mod->modname,
|
||||
'iteminstance' => $mod->instance
|
||||
]);
|
||||
if ($gradeitem && $gradeitem->gradetype == GRADE_TYPE_VALUE) {
|
||||
$resource->supportsgrades = true;
|
||||
$resource->grademax = (int)$gradinginfo->items[0]->grademax;
|
||||
}
|
||||
}
|
||||
}
|
||||
$availableresources[] = $resource;
|
||||
|
Loading…
x
Reference in New Issue
Block a user