diff --git a/mod/lesson/pagetypes/multichoice.php b/mod/lesson/pagetypes/multichoice.php index 7ab9d2cd0e7..f9307560885 100644 --- a/mod/lesson/pagetypes/multichoice.php +++ b/mod/lesson/pagetypes/multichoice.php @@ -145,8 +145,7 @@ class lesson_page_type_multichoice extends lesson_page { $answers = $this->get_used_answers(); $ncorrect = 0; $nhits = 0; - $correctresponse = ''; - $wrongresponse = ''; + $responses = array(); $correctanswerid = 0; $wronganswerid = 0; // store student's answers for displaying on feedback page @@ -155,6 +154,9 @@ class lesson_page_type_multichoice extends lesson_page { foreach ($studentanswers as $answerid) { if ($answerid == $answer->id) { $result->studentanswer .= '
'.format_text($answer->answer, $answer->answerformat, $formattextdefoptions); + if (trim(strip_tags($answer->response))) { + $responses[$answerid] = format_text($answer->response, $answer->responseformat, $formattextdefoptions); + } } } } @@ -182,10 +184,6 @@ class lesson_page_type_multichoice extends lesson_page { if ($correctanswerid == 0) { $correctanswerid = $answer->id; } - // ...also save any response from the correct answers... - if (trim(strip_tags($answer->response))) { - $correctresponse = format_text($answer->response, $answer->responseformat, $formattextdefoptions); - } } else { // save the first jumpto page id, may be needed!... if (!isset($wrongpageid)) { @@ -196,10 +194,6 @@ class lesson_page_type_multichoice extends lesson_page { if ($wronganswerid == 0) { $wronganswerid = $answer->id; } - // ...and from the incorrect ones, don't know which to use at this stage - if (trim(strip_tags($answer->response))) { - $wrongresponse = format_text($answer->response, $answer->responseformat, $formattextdefoptions); - } } } } else { @@ -220,10 +214,6 @@ class lesson_page_type_multichoice extends lesson_page { if ($correctanswerid == 0) { $correctanswerid = $answer->id; } - // ...also save any response from the correct answers... - if (trim(strip_tags($answer->response))) { - $correctresponse = format_text($answer->response, $answer->responseformat, $formattextdefoptions); - } } else { // save the first jumpto page id, may be needed!... if (!isset($wrongpageid)) { @@ -234,20 +224,16 @@ class lesson_page_type_multichoice extends lesson_page { if ($wronganswerid == 0) { $wronganswerid = $answer->id; } - // ...and from the incorrect ones, don't know which to use at this stage - if (trim(strip_tags($answer->response))) { - $wrongresponse = format_text($answer->response, $answer->responseformat, $formattextdefoptions); - } } } } if ((count($studentanswers) == $ncorrect) and ($nhits == $ncorrect)) { $result->correctanswer = true; - $result->response = $correctresponse; + $result->response = implode('
', $responses); $result->newpageid = $correctpageid; $result->answerid = $correctanswerid; } else { - $result->response = $wrongresponse; + $result->response = implode('
', $responses); $result->newpageid = $wrongpageid; $result->answerid = $wronganswerid; }