From 846e7545253ac4f6e4e305993c28f70529e14b96 Mon Sep 17 00:00:00 2001 From: tjhunt Date: Tue, 27 Feb 2007 16:20:40 +0000 Subject: [PATCH] =?utf8?q?MDL-8671=20-=20better=20checking=20when=20creati?= =?utf8?q?ng=20short=20answer=20questions.=20Fix=20thanks=20to=20Joseph=20?= =?utf8?q?R=E9zeau.=20Merged=20from=20MOODLE=5F18=5FSTABLE.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- question/type/shortanswer/edit_shortanswer_form.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/question/type/shortanswer/edit_shortanswer_form.php b/question/type/shortanswer/edit_shortanswer_form.php index 1ba15cc773..54b9e6f9df 100644 --- a/question/type/shortanswer/edit_shortanswer_form.php +++ b/question/type/shortanswer/edit_shortanswer_form.php @@ -67,15 +67,25 @@ class question_edit_shortanswer_form extends question_edit_form { $errors = array(); $answers = $data['answer']; $answercount = 0; - foreach ($answers as $answer){ + $maxgrade = false; + foreach ($answers as $key => $answer){ $trimmedanswer = trim($answer); if (!empty($trimmedanswer)){ $answercount++; } + // Check grades + if ($answer != '') { + if ($data['fraction'][$key] == 1) { + $maxgrade = true; + } + } } if ($answercount==0){ $errors['answer[0]'] = get_string('notenoughanswers', 'quiz', 1); } + if ($maxgrade == false) { + $errors['fraction[0]'] = get_string('fractionsnomax', 'question'); + } return $errors; } function qtype() { -- 2.39.5