From 556e33d77c87d44032d15a33be663e7dd01d03c0 Mon Sep 17 00:00:00 2001 From: Davo Smith Date: Mon, 22 Jun 2015 08:14:02 +0100 Subject: [PATCH] MDL-49176 gradingform_guide: display newline characters as
tags --- grade/grading/form/guide/js/guideeditor.js | 3 ++- grade/grading/form/guide/renderer.php | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/grade/grading/form/guide/js/guideeditor.js b/grade/grading/form/guide/js/guideeditor.js index bd7229d1bd8..d298b15d35a 100644 --- a/grade/grading/form/guide/js/guideeditor.js +++ b/grade/grading/form/guide/js/guideeditor.js @@ -111,7 +111,8 @@ M.gradingform_guideeditor.editmode = function(el, editmode) { value = M.util.get_string('clicktoedit', 'gradingform_guide') taplain.addClass('empty') } - taplain.one('.textvalue').set('innerHTML', Y.Escape.html(value)) + // Replace newlines with
tags, when displaying in the page. + taplain.one('.textvalue').set('innerHTML', Y.Escape.html(value).replace(/(?:\r\n|\r|\n)/g, '
')) if (tb) { tbplain.one('.textvalue').set('innerHTML', Y.Escape.html(tb.get('value'))) } diff --git a/grade/grading/form/guide/renderer.php b/grade/grading/form/guide/renderer.php index 87e94de708e..c99219dcce9 100644 --- a/grade/grading/form/guide/renderer.php +++ b/grade/grading/form/guide/renderer.php @@ -145,6 +145,10 @@ class gradingform_guide_renderer extends plugin_renderer_base { 'name' => '{NAME}[criteria][{CRITERION-id}][descriptionmarkers]')); $maxscore = html_writer::tag('div', s($criterion['maxscore']), array('class'=>'criteriondescriptionscore', 'name' => '{NAME}[criteria][{CRITERION-id}][maxscore]')); + + // Retain newlines as
tags when displaying the marking guide. + $description = nl2br($description); + $descriptionmarkers = nl2br($descriptionmarkers); } if (isset($criterion['error_description'])) { @@ -290,6 +294,8 @@ class gradingform_guide_renderer extends plugin_renderer_base { } else { $description = s($comment['description']); } + // Retain newlines as
tags when displaying 'frequently used comments'. + $description = nl2br($description); } $descriptionclass = 'description'; if (isset($comment['error_description'])) {