Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
MDL-39488 Lesson Module: Fixed PHP error matching question,
if one or more options have not been selected.
  • Loading branch information
Rossiani Wijaya committed May 8, 2013
1 parent b0e9cdd commit 51fce0f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion mod/lesson/lang/en/lesson.php
Expand Up @@ -279,7 +279,7 @@
$string['namereject'] = 'Sorry, your name has been rejected by the filter.<br />Please try another name.';
$string['new'] = 'new';
$string['nextpage'] = 'Next page';
$string['noanswer'] = 'No answer given. Please go back and submit an answer.';
$string['noanswer'] = 'One or more questions have no answer given. Please go back and submit an answer.';
$string['noattemptrecordsfound'] = 'No attempt records found: no grade given';
$string['nobranchtablefound'] = 'No content page found';
$string['nocommentyet'] = 'No comment yet.';
Expand Down
15 changes: 5 additions & 10 deletions mod/lesson/pagetypes/matching.php
Expand Up @@ -161,18 +161,13 @@ public function check_answer() {
}

$response = $data->response;
$empty = 0;

foreach ($response as $resp) {
if ($resp != '') {
break;
} else {
$empty ++;
if ($resp == '') {
$result->noanswer = true;
return $result;
}
}
if ($empty == count($response)) {
$result->noanswer = true;
return $result;
}

$answers = $this->get_answers();

Expand All @@ -191,7 +186,7 @@ public function check_answer() {
foreach ($response as $id => $value) {
$userresponse[] = $value;
// Make sure the user's answer exists in question's answer
if (array_key_exists($id, $answers) && $value) {
if (array_key_exists($id, $answers)) {
$answer = $answers[$id];
$result->studentanswer .= '<br />'.format_text($answer->answer, $answer->answerformat, $formattextdefoptions).' = '.$answers[$value]->response;
if ($id == $value) {
Expand Down

0 comments on commit 51fce0f

Please sign in to comment.