Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-39488 Lesson Module: Fixed PHP error matching question,

if one or more options have not been selected.
  • Loading branch information...
commit a6b0fc1c93483070f8b62c53280ce2b4bda79e2b 1 parent eff3864
@rwijaya rwijaya authored
Showing with 6 additions and 11 deletions.
  1. +1 −1  mod/lesson/lang/en/lesson.php
  2. +5 −10 mod/lesson/pagetypes/matching.php
View
2  mod/lesson/lang/en/lesson.php
@@ -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.';
View
15 mod/lesson/pagetypes/matching.php
@@ -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();
@@ -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) {

0 comments on commit a6b0fc1

Please sign in to comment.
Something went wrong with that request. Please try again.