Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-30867 Lesson module: fix lesson essay question formtting to be co…

…nsistent with user selection
  • Loading branch information...
commit 8af9ec6cb97532048568824da83815d885e1c9ca 1 parent f24a1a7
rwijaya authored March 09, 2012
2  mod/lesson/essay.php
@@ -393,7 +393,7 @@
393 393
         $data->id = $cm->id;
394 394
         $data->attemptid = $attemptid;
395 395
         $data->score = $essayinfo->score;
396  
-        $data->studentanswer = format_string($essayinfo->answer, FORMAT_MOODLE);
  396
+        $data->studentanswer = format_string($essayinfo->answer, $essayinfo->answerformat);
397 397
         $data->response = $essayinfo->response;
398 398
         $mform->set_data($data);
399 399
 
7  mod/lesson/pagetypes/essay.php
@@ -97,8 +97,10 @@ public function check_answer() {
97 97
 
98 98
         if (is_array($data->answer)) {
99 99
             $studentanswer = $data->answer['text'];
  100
+            $studentanswerformat = $data->answer['format'];
100 101
         } else {
101 102
             $studentanswer = $data->answer;
  103
+            $studentanswerformat = FORMAT_MOODLE;
102 104
         }
103 105
 
104 106
         if (trim($studentanswer) === '') {
@@ -117,9 +119,10 @@ public function check_answer() {
117 119
         $userresponse->graded = 0;
118 120
         $userresponse->score = 0;
119 121
         $userresponse->answer = $studentanswer;
  122
+        $userresponse->answerformat = $studentanswerformat;
120 123
         $userresponse->response = "";
121 124
         $result->userresponse = serialize($userresponse);
122  
-
  125
+        $result->studentanswerformat = $studentanswerformat;
123 126
         $result->studentanswer = s($studentanswer);
124 127
         return $result;
125 128
     }
@@ -220,7 +223,7 @@ public function report_answers($answerpage, $answerdata, $useranswer, $pagestats
220 223
                 // dont think this should ever be reached....
221 224
                 $avescore = get_string("nooneansweredthisquestion", "lesson");
222 225
             }
223  
-            $answerdata->answers[] = array(format_text($essayinfo->answer, FORMAT_MOODLE, $formattextdefoptions), $avescore);
  226
+            $answerdata->answers[] = array(format_text($essayinfo->answer, $essayinfo->answerformat, $formattextdefoptions), $avescore);
224 227
             $answerpage->answerdata = $answerdata;
225 228
         }
226 229
         return $answerpage;

0 notes on commit 8af9ec6

Please sign in to comment.
Something went wrong with that request. Please try again.