Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

MDL-31266 Lesson module: Improve feedback so that the responses are c…

…oncatenated instead of overwritten
  • Loading branch information...
commit 5816961bde2968a89a6afb42ef5ff925a0bc00d8 1 parent 62b0af5
rwijaya authored March 13, 2012

Showing 1 changed file with 6 additions and 20 deletions. Show diff stats Hide diff stats

  1. 26  mod/lesson/pagetypes/multichoice.php
26  mod/lesson/pagetypes/multichoice.php
@@ -145,8 +145,7 @@ public function check_answer() {
145 145
             $answers = $this->get_used_answers();
146 146
             $ncorrect = 0;
147 147
             $nhits = 0;
148  
-            $correctresponse = '';
149  
-            $wrongresponse = '';
  148
+            $responses = array();
150 149
             $correctanswerid = 0;
151 150
             $wronganswerid = 0;
152 151
             // store student's answers for displaying on feedback page
@@ -155,6 +154,9 @@ public function check_answer() {
155 154
                 foreach ($studentanswers as $answerid) {
156 155
                     if ($answerid == $answer->id) {
157 156
                         $result->studentanswer .= '<br />'.format_text($answer->answer, $answer->answerformat, $formattextdefoptions);
  157
+                        if (trim(strip_tags($answer->response))) {
  158
+                            $responses[$answerid] = format_text($answer->response, $answer->responseformat, $formattextdefoptions);
  159
+                        }
158 160
                     }
159 161
                 }
160 162
             }
@@ -182,10 +184,6 @@ public function check_answer() {
182 184
                         if ($correctanswerid == 0) {
183 185
                             $correctanswerid = $answer->id;
184 186
                         }
185  
-                        // ...also save any response from the correct answers...
186  
-                        if (trim(strip_tags($answer->response))) {
187  
-                            $correctresponse = format_text($answer->response, $answer->responseformat, $formattextdefoptions);
188  
-                        }
189 187
                     } else {
190 188
                         // save the first jumpto page id, may be needed!...
191 189
                         if (!isset($wrongpageid)) {
@@ -196,10 +194,6 @@ public function check_answer() {
196 194
                         if ($wronganswerid == 0) {
197 195
                             $wronganswerid = $answer->id;
198 196
                         }
199  
-                        // ...and from the incorrect ones, don't know which to use at this stage
200  
-                        if (trim(strip_tags($answer->response))) {
201  
-                            $wrongresponse = format_text($answer->response, $answer->responseformat, $formattextdefoptions);
202  
-                        }
203 197
                     }
204 198
                 }
205 199
             } else {
@@ -220,10 +214,6 @@ public function check_answer() {
220 214
                         if ($correctanswerid == 0) {
221 215
                             $correctanswerid = $answer->id;
222 216
                         }
223  
-                        // ...also save any response from the correct answers...
224  
-                        if (trim(strip_tags($answer->response))) {
225  
-                            $correctresponse = format_text($answer->response, $answer->responseformat, $formattextdefoptions);
226  
-                        }
227 217
                     } else {
228 218
                         // save the first jumpto page id, may be needed!...
229 219
                         if (!isset($wrongpageid)) {
@@ -234,20 +224,16 @@ public function check_answer() {
234 224
                         if ($wronganswerid == 0) {
235 225
                             $wronganswerid = $answer->id;
236 226
                         }
237  
-                        // ...and from the incorrect ones, don't know which to use at this stage
238  
-                        if (trim(strip_tags($answer->response))) {
239  
-                            $wrongresponse = format_text($answer->response, $answer->responseformat, $formattextdefoptions);
240  
-                        }
241 227
                     }
242 228
                 }
243 229
             }
244 230
             if ((count($studentanswers) == $ncorrect) and ($nhits == $ncorrect)) {
245 231
                 $result->correctanswer = true;
246  
-                $result->response  = $correctresponse;
  232
+                $result->response  = implode('<br />', $responses);
247 233
                 $result->newpageid = $correctpageid;
248 234
                 $result->answerid  = $correctanswerid;
249 235
             } else {
250  
-                $result->response  = $wrongresponse;
  236
+                $result->response  = implode('<br />', $responses);
251 237
                 $result->newpageid = $wrongpageid;
252 238
                 $result->answerid  = $wronganswerid;
253 239
             }

0 notes on commit 5816961

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