MDL-31235 core_grades: use text filters for criterion fields

This commit is contained in:
Stephan Robotta 2023-02-09 14:25:29 +01:00
parent 8503f2cfd8
commit 75b8733197
2 changed files with 14 additions and 7 deletions

View File

@ -962,7 +962,7 @@ class gradingform_guide_instance extends gradingform_instance {
if (!empty($this->validationerrors)) {
foreach ($this->validationerrors as $id => $err) {
$a = new stdClass();
$a->criterianame = s($criteria[$id]['shortname']);
$a->criterianame = format_text($criteria[$id]['shortname'], FORMAT_HTML);
$a->maxscore = $criteria[$id]['maxscore'];
if ($this->validationerrors[$id]['score'] < 0) {
$html .= html_writer::tag('div', get_string('err_scoreisnegative', 'gradingform_guide', $a),

View File

@ -137,7 +137,11 @@ class gradingform_guide_renderer extends plugin_renderer_base {
'id' => '{NAME}[criteria][{CRITERION-id}][shortname]',
'aria-describedby' => '{NAME}-criterion-name-label'
);
$shortname = html_writer::div(s($criterion['shortname']), 'criterionshortname', $shortnameparams);
$shortname = html_writer::div(
format_text($criterion['shortname'], FORMAT_HTML),
'criterionshortname',
$shortnameparams
);
$descmarkerclass = '';
$descstudentclass = '';
@ -149,10 +153,12 @@ class gradingform_guide_renderer extends plugin_renderer_base {
$descstudentclass = ' hide';
}
}
$description = html_writer::tag('div', s($criterion['description']),
$description = html_writer::tag('div',
format_text($criterion['description'], $criterion['descriptionformat']),
array('class'=>'criteriondescription'.$descstudentclass,
'name' => '{NAME}[criteria][{CRITERION-id}][descriptionmarkers]'));
$descriptionmarkers = html_writer::tag('div', s($criterion['descriptionmarkers']),
$descriptionmarkers = html_writer::tag('div',
format_text($criterion['descriptionmarkers'], $criterion['descriptionmarkersformat']),
array('class'=>'criteriondescriptionmarkers'.$descmarkerclass,
'name' => '{NAME}[criteria][{CRITERION-id}][descriptionmarkers]'));
$maxscore = html_writer::tag('div', s($criterion['maxscore']),
@ -248,7 +254,7 @@ class gradingform_guide_renderer extends plugin_renderer_base {
foreach ($comments as $id => $comment) {
$commentoption = new stdClass();
$commentoption->id = $id;
$commentoption->description = $comment['description'];
$commentoption->description = html_to_text(format_text($comment['description'], $comment['descriptionformat']));
$commentoptions[] = $commentoption;
}
@ -264,7 +270,8 @@ class gradingform_guide_renderer extends plugin_renderer_base {
'class' => 'hidden',
'id' => '{NAME}-remarklabel{CRITERION-id}'
);
$remarklabeltext = get_string('criterionremark', 'gradingform_guide', $criterion['shortname']);
$remarklabeltext = get_string('criterionremark', 'gradingform_guide',
format_text($criterion['shortname'], FORMAT_HTML));
$remarklabel = html_writer::label($remarklabeltext, $remarkid, false, $remarklabelparams);
$criteriontemplate .= html_writer::tag('td', $remarklabel . $input . $commentchooser, array('class' => 'remark'));
@ -391,7 +398,7 @@ class gradingform_guide_renderer extends plugin_renderer_base {
'title' => get_string('clicktocopy', 'gradingform_guide'),
'id' => '{NAME}[comments][{COMMENT-id}]', 'class'=>'markingguidecomment'));
} else {
$description = s($comment['description']);
$description = format_text($comment['description'], $comment['descriptionformat']);
}
// Retain newlines as <br> tags when displaying 'frequently used comments'.
$description = nl2br($description);