mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-48938 grader: use pix_icon instead of raw html
This commit is contained in:
parent
88cd577ef3
commit
1ef4846924
1 changed files with 43 additions and 34 deletions
|
@ -1248,10 +1248,22 @@ class grade_structure {
|
||||||
global $CFG, $OUTPUT;
|
global $CFG, $OUTPUT;
|
||||||
require_once $CFG->libdir.'/filelib.php';
|
require_once $CFG->libdir.'/filelib.php';
|
||||||
|
|
||||||
|
$outputstr = '';
|
||||||
|
|
||||||
|
// Object holding pix_icon information before instantiation.
|
||||||
|
$icon = new stdClass();
|
||||||
|
$icon->attributes = array(
|
||||||
|
'class' => 'item itemicon'
|
||||||
|
);
|
||||||
|
$icon->component = 'moodle';
|
||||||
|
|
||||||
|
$none = true;
|
||||||
switch ($element['type']) {
|
switch ($element['type']) {
|
||||||
case 'item':
|
case 'item':
|
||||||
case 'courseitem':
|
case 'courseitem':
|
||||||
case 'categoryitem':
|
case 'categoryitem':
|
||||||
|
$none = false;
|
||||||
|
|
||||||
$is_course = $element['object']->is_course_item();
|
$is_course = $element['object']->is_course_item();
|
||||||
$is_category = $element['object']->is_category_item();
|
$is_category = $element['object']->is_category_item();
|
||||||
$is_scale = $element['object']->gradetype == GRADE_TYPE_SCALE;
|
$is_scale = $element['object']->gradetype == GRADE_TYPE_SCALE;
|
||||||
|
@ -1259,71 +1271,68 @@ class grade_structure {
|
||||||
$is_outcome = !empty($element['object']->outcomeid);
|
$is_outcome = !empty($element['object']->outcomeid);
|
||||||
|
|
||||||
if ($element['object']->is_calculated()) {
|
if ($element['object']->is_calculated()) {
|
||||||
$strcalc = get_string('calculatedgrade', 'grades');
|
$icon->pix = 'i/calc';
|
||||||
return '<img src="'.$OUTPUT->pix_url('i/calc') . '" class="icon itemicon" title="'.
|
$icon->title = s(get_string('calculatedgrade', 'grades'));
|
||||||
s($strcalc).'" alt="'.s($strcalc).'"/>';
|
|
||||||
|
|
||||||
} else if (($is_course or $is_category) and ($is_scale or $is_value)) {
|
} else if (($is_course or $is_category) and ($is_scale or $is_value)) {
|
||||||
if ($category = $element['object']->get_item_category()) {
|
if ($category = $element['object']->get_item_category()) {
|
||||||
$aggrstrings = grade_helper::get_aggregation_strings();
|
$aggrstrings = grade_helper::get_aggregation_strings();
|
||||||
$stragg = $aggrstrings[$category->aggregation];
|
$stragg = $aggrstrings[$category->aggregation];
|
||||||
|
|
||||||
|
$icon->pix = 'i/calc';
|
||||||
|
$icon->title = s($stragg);
|
||||||
|
|
||||||
switch ($category->aggregation) {
|
switch ($category->aggregation) {
|
||||||
case GRADE_AGGREGATE_MEAN:
|
case GRADE_AGGREGATE_MEAN:
|
||||||
case GRADE_AGGREGATE_MEDIAN:
|
case GRADE_AGGREGATE_MEDIAN:
|
||||||
case GRADE_AGGREGATE_WEIGHTED_MEAN:
|
case GRADE_AGGREGATE_WEIGHTED_MEAN:
|
||||||
case GRADE_AGGREGATE_WEIGHTED_MEAN2:
|
case GRADE_AGGREGATE_WEIGHTED_MEAN2:
|
||||||
case GRADE_AGGREGATE_EXTRACREDIT_MEAN:
|
case GRADE_AGGREGATE_EXTRACREDIT_MEAN:
|
||||||
return '<img src="'.$OUTPUT->pix_url('i/agg_mean') . '" ' .
|
$icon->pix = 'i/agg_mean';
|
||||||
'class="icon itemicon" title="'.s($stragg).'" alt="'.s($stragg).'"/>';
|
break;
|
||||||
case GRADE_AGGREGATE_SUM:
|
case GRADE_AGGREGATE_SUM:
|
||||||
return '<img src="'.$OUTPUT->pix_url('i/agg_sum') . '" ' .
|
$icon->pix = 'i/agg_sum';
|
||||||
'class="icon itemicon" title="'.s($stragg).'" alt="'.s($stragg).'"/>';
|
break;
|
||||||
default:
|
|
||||||
return '<img src="'.$OUTPUT->pix_url('i/calc') . '" ' .
|
|
||||||
'class="icon itemicon" title="'.s($stragg).'" alt="'.s($stragg).'"/>';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if ($element['object']->itemtype == 'mod') {
|
} else if ($element['object']->itemtype == 'mod') {
|
||||||
//prevent outcomes being displaying the same icon as the activity they are attached to
|
// Prevent outcomes displaying the same icon as the activity they are attached to.
|
||||||
if ($is_outcome) {
|
if ($is_outcome) {
|
||||||
$stroutcome = s(get_string('outcome', 'grades'));
|
$icon->pix = 'i/outcomes';
|
||||||
return '<img src="'.$OUTPUT->pix_url('i/outcomes') . '" ' .
|
$icon->title = s(get_string('outcome', 'grades'));
|
||||||
'class="icon itemicon" title="'.$stroutcome.
|
|
||||||
'" alt="'.$stroutcome.'"/>';
|
|
||||||
} else {
|
} else {
|
||||||
$strmodname = get_string('modulename', $element['object']->itemmodule);
|
$icon->pix = 'icon';
|
||||||
return '<img src="'.$OUTPUT->pix_url('icon',
|
$icon->component = $element['object']->itemmodule;
|
||||||
$element['object']->itemmodule) . '" ' .
|
$icon->title = s(get_string('modulename', $element['object']->itemmodule));
|
||||||
'class="icon itemicon" title="' .s($strmodname).
|
|
||||||
'" alt="' .s($strmodname).'"/>';
|
|
||||||
}
|
}
|
||||||
} else if ($element['object']->itemtype == 'manual') {
|
} else if ($element['object']->itemtype == 'manual') {
|
||||||
if ($element['object']->is_outcome_item()) {
|
if ($element['object']->is_outcome_item()) {
|
||||||
$stroutcome = get_string('outcome', 'grades');
|
$icon->pix = 'i/outcomes';
|
||||||
return '<img src="'.$OUTPUT->pix_url('i/outcomes') . '" ' .
|
$icon->title = s(get_string('outcome', 'grades'));
|
||||||
'class="icon itemicon" title="'.s($stroutcome).
|
|
||||||
'" alt="'.s($stroutcome).'"/>';
|
|
||||||
} else {
|
} else {
|
||||||
$strmanual = get_string('manualitem', 'grades');
|
$icon->pix = 'i/manual_item';
|
||||||
return '<img src="'.$OUTPUT->pix_url('i/manual_item') . '" '.
|
$icon->title = s(get_string('manualitem', 'grades'));
|
||||||
'class="icon itemicon" title="'.s($strmanual).
|
|
||||||
'" alt="'.s($strmanual).'"/>';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'category':
|
case 'category':
|
||||||
$strcat = get_string('category', 'grades');
|
$none = false;
|
||||||
return '<img src="'.$OUTPUT->pix_url('i/folder') . '" class="icon itemicon" ' .
|
$icon->pix = 'i/folder';
|
||||||
'title="'.s($strcat).'" alt="'.s($strcat).'" />';
|
$icon->title = s(get_string('category', 'grades'));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($spacerifnone) {
|
if ($none) {
|
||||||
return $OUTPUT->spacer().' ';
|
if ($spacerifnone) {
|
||||||
|
$outputstr = $OUTPUT->spacer() . ' ';
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return '';
|
$outputstr = $OUTPUT->pix_icon($icon->pix, $icon->title, $icon->component, $icon->attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $outputstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue