MDL-26324 Existing overall feedback on non-graded quizzes prevents editing
authorTim Hunt <T.J.Hunt@open.ac.uk>
Fri, 4 Mar 2011 17:48:13 +0000 (17:48 +0000)
committerTim Hunt <T.J.Hunt@open.ac.uk>
Fri, 4 Mar 2011 17:50:31 +0000 (17:50 +0000)
mod/quiz/mod_form.php

index 4a50ef6..f1f1355 100644 (file)
@@ -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(
             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
                     'feedback',             // filarea
-                    !empty($feedback->id)?(int)$feedback->id:null, // itemid
+                    !empty($feedback->id) ? (int) $feedback->id : null, // itemid
                     null,
                     null,
-                    $feedback->feedbacktext      // text
+                    $feedback->feedbacktext // text
                 );
                 $toform['feedbacktext['.$key.']']['format'] = $feedback->feedbacktextformat;
                 $toform['feedbacktext['.$key.']']['itemid'] = $draftid;
 
                 );
                 $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']) . '%';
                 }
                 if ($feedback->mingrade > 0) {
                     $toform['feedbackboundaries['.$key.']'] = (100.0 * $feedback->mingrade / $toform['grade']) . '%';
                 }