From c5c16a2c81b00b0ed04302303341c818533fea2e Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Fri, 4 Mar 2011 17:48:13 +0000 Subject: [PATCH] MDL-26324 Existing overall feedback on non-graded quizzes prevents editing --- mod/quiz/mod_form.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/mod/quiz/mod_form.php b/mod/quiz/mod_form.php index 4a50ef6e0c6..f1f13557c1b 100644 --- a/mod/quiz/mod_form.php +++ b/mod/quiz/mod_form.php @@ -364,17 +364,26 @@ class mod_quiz_mod_form extends moodleform_mod { foreach ($this->_feedbacks as $feedback){ $draftid = file_get_submitted_draft_itemid('feedbacktext['.$key.']'); $toform['feedbacktext['.$key.']']['text'] = file_prepare_draft_area( - $draftid, // draftid - $this->context->id, // context - 'mod_quiz', // component + $draftid, // draftid + $this->context->id, // context + 'mod_quiz', // component 'feedback', // filarea - !empty($feedback->id)?(int)$feedback->id:null, // itemid + !empty($feedback->id) ? (int) $feedback->id : null, // itemid null, - $feedback->feedbacktext // text + $feedback->feedbacktext // text ); $toform['feedbacktext['.$key.']']['format'] = $feedback->feedbacktextformat; $toform['feedbacktext['.$key.']']['itemid'] = $draftid; + if ($toform['grade'] == 0) { + // When a quiz is un-graded, there can only be one lot of + // feedback. If the quiz previously had a maximum grade and + // several lots of feedback, we must now avoid putting text + // into input boxes that are disabled, but which the + // validation will insist are blank. + break; + } + if ($feedback->mingrade > 0) { $toform['feedbackboundaries['.$key.']'] = (100.0 * $feedback->mingrade / $toform['grade']) . '%'; } -- 2.17.1