From 73ebb5d7ab95b0547411723351db05cbe628002d Mon Sep 17 00:00:00 2001 From: Andrew Robert Nicols Date: Tue, 18 Oct 2011 15:11:36 +0100 Subject: [PATCH] MDL-29818: Improve error message when a grade has no answer --- question/type/multichoice/edit_multichoice_form.php | 6 +++++- question/type/multichoice/lang/en/qtype_multichoice.php | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/question/type/multichoice/edit_multichoice_form.php b/question/type/multichoice/edit_multichoice_form.php index e2367e68367..e94c202d97e 100644 --- a/question/type/multichoice/edit_multichoice_form.php +++ b/question/type/multichoice/edit_multichoice_form.php @@ -109,9 +109,13 @@ class qtype_multichoice_edit_form extends question_edit_form { foreach ($answers as $key => $answer) { //check no of choices $trimmedanswer = trim($answer['text']); - if (empty($trimmedanswer)) { + $fraction = (float) $data['fraction'][$key]; + if (empty($trimmedanswer) && empty($fraction)) { continue; } + if (empty($trimmedanswer)) { + $errors['fraction['.$key.']'] = get_string('errgradesetanswerblank', 'qtype_multichoice'); + } $answercount++; diff --git a/question/type/multichoice/lang/en/qtype_multichoice.php b/question/type/multichoice/lang/en/qtype_multichoice.php index 091b62e9475..ae44717cc7e 100644 --- a/question/type/multichoice/lang/en/qtype_multichoice.php +++ b/question/type/multichoice/lang/en/qtype_multichoice.php @@ -41,6 +41,7 @@ $string['clozeaid'] = 'Enter missing word'; $string['correctansweris'] = 'The correct answer is: {$a}.'; $string['correctfeedback'] = 'For any correct response'; $string['editingmultichoice'] = 'Editing a Multiple choice question'; +$string['errgradesetanswerblank'] = 'Grade set, but the Answer is blank'; $string['errfractionsaddwrong'] = 'The positive grades you have chosen do not add up to 100%
Instead, they add up to {$a}%'; $string['errfractionsnomax'] = 'One of the choices should be 100%, so that it is
possible to get a full grade for this question.'; $string['feedback'] = 'Feedback';