diff --git a/mod/lesson/lang/en/lesson.php b/mod/lesson/lang/en/lesson.php index baefd6a5b9c..fcc9ebbecb7 100644 --- a/mod/lesson/lang/en/lesson.php +++ b/mod/lesson/lang/en/lesson.php @@ -280,7 +280,7 @@ $string['nameapproved'] = 'Name approved'; $string['namereject'] = 'Sorry, your name has been rejected by the filter.
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.'; diff --git a/mod/lesson/pagetypes/matching.php b/mod/lesson/pagetypes/matching.php index 00b0dcb8ca3..e262f4473f0 100644 --- a/mod/lesson/pagetypes/matching.php +++ b/mod/lesson/pagetypes/matching.php @@ -161,11 +161,6 @@ class lesson_page_type_matching extends lesson_page { } $response = $data->response; - if (!is_array($response)) { - $result->noanswer = true; - return $result; - } - $answers = $this->get_answers(); $correct = array_shift($answers); @@ -177,12 +172,16 @@ class lesson_page_type_matching extends lesson_page { } unset($answers[$key]); } - // get he users exact responses for record keeping + // get the user's exact responses for record keeping $hits = 0; $userresponse = array(); foreach ($response as $id => $value) { + if ($value == '') { + $result->noanswer = true; + return $result; + } $userresponse[] = $value; - // Make sure the user's answer is exist in question's answer + // Make sure the user's answer exists in question's answer if (array_key_exists($id, $answers)) { $answer = $answers[$id]; $result->studentanswer .= '
'.format_text($answer->answer, $answer->answerformat, $formattextdefoptions).' = '.$answers[$value]->response;