mirror of
https://github.com/moodle/moodle.git
synced 2025-04-20 16:04:25 +02:00
MDL-77326 gradereport_summary: Use appropriate icons.
This commit is contained in:
parent
f44338eda0
commit
9df50931e0
@ -129,55 +129,20 @@ class grade_items extends base {
|
||||
->set_type(column::TYPE_TEXT)
|
||||
->add_fields($selectsql)
|
||||
->add_callback(static function($value, $row): string {
|
||||
global $PAGE, $CFG;
|
||||
$gradeitem = grade_item::fetch(['id' => $row->id, 'courseid' => $row->courseid]);
|
||||
$element = ['type' => 'item', 'object' => $gradeitem, 'modinfo' => get_fast_modinfo($row->courseid)];
|
||||
$fullname = \grade_helper::get_element_header($element, true, false, true, true, true);
|
||||
|
||||
$renderer = new \core_renderer($PAGE, RENDERER_TARGET_GENERAL);
|
||||
if ($row->itemmodule) {
|
||||
$modinfo = get_fast_modinfo($row->courseid);
|
||||
$instances = $modinfo->get_instances();
|
||||
$cm = $instances[$row->itemmodule][$row->iteminstance];
|
||||
|
||||
if (file_exists($CFG->dirroot . '/mod/' . $row->itemmodule . '/grade.php')) {
|
||||
$args = ['id' => $cm->id, 'itemnumber' => $row->itemnumber];
|
||||
$url = new \moodle_url('/mod/' . $row->itemmodule . '/grade.php', $args);
|
||||
} else {
|
||||
$url = new \moodle_url('/mod/' . $row->itemmodule . '/view.php', ['id' => $cm->id]);
|
||||
}
|
||||
|
||||
$imagedata = $renderer->pix_icon('monologo', '', $row->itemmodule, ['class' => 'activityicon']);
|
||||
$purposeclass = plugin_supports('mod', $row->itemmodule, FEATURE_MOD_PURPOSE);
|
||||
$purposeclass .= ' activityiconcontainer';
|
||||
$purposeclass .= ' modicon_' . $row->itemmodule;
|
||||
$imagedata = \html_writer::tag('div', $imagedata, ['class' => $purposeclass]);
|
||||
|
||||
$dimmed = '';
|
||||
if ($row->hidden) {
|
||||
$dimmed = ' dimmed_text';
|
||||
}
|
||||
$html = \html_writer::start_div('page-context-header' . $dimmed);
|
||||
// Image data.
|
||||
$html .= \html_writer::div($imagedata, 'page-header-image mr-2');
|
||||
$prefix = \html_writer::div(get_string('pluginname', "mod_{$row->itemmodule}"),
|
||||
'text-muted text-uppercase small line-height-3');
|
||||
$name = $prefix . \html_writer::link($url, format_string($cm->name, true));
|
||||
$html .= \html_writer::tag('div', $name, ['class' => 'page-header-headings']);
|
||||
} else {
|
||||
// Manual grade item.
|
||||
$gradeitem = grade_item::fetch(['id' => $row->id, 'courseid' => $row->courseid]);
|
||||
if ($row->calculation) {
|
||||
$imagedata = $renderer->pix_icon('i/agg_sum', '');
|
||||
} else {
|
||||
$imagedata = $renderer->pix_icon('i/manual_item', '');
|
||||
}
|
||||
$imagedata = \html_writer::tag('div', $imagedata);
|
||||
|
||||
$html = \html_writer::start_div('page-context-header');
|
||||
// Image data.
|
||||
$html .= \html_writer::div($imagedata, 'page-header-image mr-2');
|
||||
$html .= \html_writer::tag('div', $gradeitem->get_name(), ['class' => 'page-header-headings']);
|
||||
$icon = \grade_helper::get_element_icon($element);
|
||||
$elementtype = \grade_helper::get_element_type_string($element);
|
||||
$itemtype = \html_writer::span($elementtype, 'd-block text-uppercase small dimmed_text',
|
||||
['title' => $elementtype]);
|
||||
$content = \html_writer::div($itemtype . $fullname);
|
||||
$dimmed = '';
|
||||
if ($row->hidden) {
|
||||
$dimmed = ' dimmed_text';
|
||||
}
|
||||
return $html;
|
||||
|
||||
return \html_writer::div($icon . $content, "item d-flex align-items-center" . $dimmed);
|
||||
});
|
||||
|
||||
$report = [
|
||||
|
Loading…
x
Reference in New Issue
Block a user