MDL-51745 mod_lesson: Use format_text in response feedback
authorJosh Ebarvia <josh.ebarvia@blackboard.com>
Wed, 21 Jun 2017 02:14:41 +0000 (11:44 +0930)
committerJosh Ebarvia <josh.ebarvia@blackboard.com>
Mon, 7 Aug 2017 06:23:11 +0000 (15:53 +0930)
mod/lesson/continue.php
mod/lesson/locallib.php

index a743dc7..934e9f5 100644 (file)
@@ -92,7 +92,7 @@ if ($lesson->ongoing && !$reviewmode) {
     echo $lessonoutput->ongoing_score($lesson);
 }
 if (!$reviewmode) {
-    echo $result->feedback;
+    echo format_text($result->feedback, FORMAT_MOODLE, array('context' => $context));
 }
 
 // User is modifying attempts - save button and some instructions
index 7c7c379..8256004 100644 (file)
@@ -4091,13 +4091,8 @@ abstract class lesson_page extends lesson_base {
 
                 $result->feedback .= $OUTPUT->box(format_text($this->get_contents(), $this->properties->contentsformat, $options),
                         'generalbox boxaligncenter');
-                if (isset($result->studentanswerformat)) {
-                    // This is the student's answer so it should be cleaned.
-                    $studentanswer = format_text($result->studentanswer, $result->studentanswerformat,
-                            array('context' => $context, 'para' => true));
-                } else {
-                    $studentanswer = format_string($result->studentanswer);
-                }
+                $studentanswer = format_text($result->studentanswer, $result->studentanswerformat,
+                        array('context' => $context, 'para' => true));
                 $result->feedback .= '<div class="correctanswer generalbox"><em>'
                         . get_string("youranswer", "lesson").'</em> : ' . $studentanswer;
                 if (isset($result->responseformat)) {
@@ -4476,6 +4471,7 @@ abstract class lesson_page extends lesson_base {
         $result->response        = '';
         $result->newpageid       = 0;       // stay on the page
         $result->studentanswer   = '';      // use this to store student's answer(s) in order to display it on feedback page
+        $result->studentanswerformat = FORMAT_MOODLE;
         $result->userresponse    = null;
         $result->feedback        = '';
         $result->nodefaultresponse  = false; // Flag for redirecting when default feedback is turned off