MDL-39261 mod_lesson: Rewrite the answer URL for grading
[moodle.git] / mod / lesson / essay.php
index 19382e9..24e5094 100644 (file)
@@ -247,7 +247,9 @@ switch ($mode) {
                 // Set rest of the message values
                 $currentpage = $lesson->load_page($attempt->pageid);
                 $a->question = format_text($currentpage->contents, $currentpage->contentsformat, $formattextdefoptions);
-                $a->response = format_text($essayinfo->answer, $essayinfo->answerformat,
+                $answer = file_rewrite_pluginfile_urls($essayinfo->answer, 'pluginfile.php', $context->id,
+                    'mod_lesson', 'essay_responses', $attempt->id);
+                $a->response = format_text($answer, $essayinfo->answerformat,
                         array('context' => $context, 'para' => true));
                 $a->comment = $essayinfo->response;
                 $a->comment = file_rewrite_pluginfile_urls($a->comment, 'pluginfile.php', $context->id,
@@ -454,6 +456,8 @@ switch ($mode) {
         // Grading form
         // Expects the following to be set: $attemptid, $answer, $user, $page, $attempt
         $essayinfo = lesson_page_type_essay::extract_useranswer($attempt->useranswer);
+        $answer = file_rewrite_pluginfile_urls($essayinfo->answer, 'pluginfile.php', $context->id,
+            'mod_lesson', 'essay_responses', $attempt->id);
         $currentpage = $lesson->load_page($attempt->pageid);
 
         $mform = new essay_grading_form(null, array('scoreoptions'=>$scoreoptions, 'user'=>$user));
@@ -462,7 +466,7 @@ switch ($mode) {
         $data->attemptid = $attemptid;
         $data->score = $essayinfo->score;
         $data->question = format_text($currentpage->contents, $currentpage->contentsformat, $formattextdefoptions);
-        $data->studentanswer = format_text($essayinfo->answer, $essayinfo->answerformat,
+        $data->studentanswer = format_text($answer, $essayinfo->answerformat,
                 array('context' => $context, 'para' => true));
         $data->response = $essayinfo->response;
         $data->responseformat = $essayinfo->responseformat;