MDL-31266 Lesson module: Improve feedback so that the responses are concatenated instead of overwritten
This commit is contained in:
committed by
Dan Poltawski
parent
149da7724b
commit
e053583fc7
@@ -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 .= '<br />'.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('<br />', $responses);
|
||||
$result->newpageid = $correctpageid;
|
||||
$result->answerid = $correctanswerid;
|
||||
} else {
|
||||
$result->response = $wrongresponse;
|
||||
$result->response = implode('<br />', $responses);
|
||||
$result->newpageid = $wrongpageid;
|
||||
$result->answerid = $wronganswerid;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user