Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'MDL-31266_m22' of git://github.com/rwijaya/moodle into …

…MOODLE_22_STABLE
  • Loading branch information...
commit 91e79a37cca29a48a0dc59fc2f9c6df90b00718f 2 parents a57b547 + 7f7aac7
@danpoltawski danpoltawski authored
Showing with 6 additions and 20 deletions.
  1. +6 −20 mod/lesson/pagetypes/multichoice.php
View
26 mod/lesson/pagetypes/multichoice.php
@@ -145,8 +145,7 @@ public function check_answer() {
$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 @@ public function check_answer() {
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 @@ public function check_answer() {
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 @@ public function check_answer() {
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 @@ public function check_answer() {
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 @@ public function check_answer() {
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;
}
Please sign in to comment.
Something went wrong with that request. Please try again.