MDL-54065 gradebook: correctly display module icon

This commit is contained in:
Marina Glancy 2016-05-10 14:17:57 +08:00
parent 6a74e76fb8
commit bc6a7431a2

View File

@ -1478,8 +1478,15 @@ class grade_structure {
$icon->pix = 'i/outcomes';
$icon->title = s(get_string('outcome', 'grades'));
} else {
$icon->pix = 'icon';
$icon->component = $element['object']->itemmodule;
$modinfo = get_fast_modinfo($element['object']->courseid);
$module = $element['object']->itemmodule;
$instanceid = $element['object']->iteminstance;
if (isset($modinfo->instances[$module][$instanceid])) {
$icon->url = $modinfo->instances[$module][$instanceid]->get_icon_url();
} else {
$icon->pix = 'icon';
$icon->component = $element['object']->itemmodule;
}
$icon->title = s(get_string('modulename', $element['object']->itemmodule));
}
} else if ($element['object']->itemtype == 'manual') {
@ -1504,6 +1511,8 @@ class grade_structure {
if ($spacerifnone) {
$outputstr = $OUTPUT->spacer() . ' ';
}
} else if (isset($icon->url)) {
$outputstr = html_writer::img($icon->url, $icon->title, $icon->attributes);
} else {
$outputstr = $OUTPUT->pix_icon($icon->pix, $icon->title, $icon->component, $icon->attributes);
}