$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
foreach ($studentanswers as $answerid) {
if ($answerid == $answer->id) {
$result->studentanswer .= '<br />'.format_text($answer->answer, $answer->answerformat, $formattextdefoptions);
+ if (trim(strip_tags($answer->response))) {
+ $responses[$answerid] = format_text($answer->response, $answer->responseformat, $formattextdefoptions);
+ }
}
}
}
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)) {
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 {
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)) {
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('<br />', $responses);
$result->newpageid = $correctpageid;
$result->answerid = $correctanswerid;
} else {
- $result->response = $wrongresponse;
+ $result->response = implode('<br />', $responses);
$result->newpageid = $wrongpageid;
$result->answerid = $wronganswerid;
}