public function data_preprocessing(&$toform) { if (isset($toform['grade'])) { // Convert to a real number, so we don't get 0.0000. $toform['grade'] = $toform['grade'] + 0; } if (count($this->_feedbacks)) { $key = 0; foreach ($this->_feedbacks as $feedback) { $draftid = file_get_submitted_draft_itemid('feedbacktext[' . $key . ']'); $toform['feedbacktext[' . $key . ']']['text'] = file_prepare_draft_area($draftid, $this->context->id, 'mod_quiz', 'feedback', !empty($feedback->id) ? (int) $feedback->id : null, null, $feedback->feedbacktext); $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'] . '%'; } $key++; } } if (isset($toform['timelimit'])) { $toform['timelimitenable'] = $toform['timelimit'] > 0; } $this->preprocessing_review_settings($toform, 'during', mod_quiz_display_options::DURING); $this->preprocessing_review_settings($toform, 'immediately', mod_quiz_display_options::IMMEDIATELY_AFTER); $this->preprocessing_review_settings($toform, 'open', mod_quiz_display_options::LATER_WHILE_OPEN); $this->preprocessing_review_settings($toform, 'closed', mod_quiz_display_options::AFTER_CLOSE); $toform['attemptduring'] = true; $toform['overallfeedbackduring'] = false; // Password field - different in form to stop browsers that remember // passwords from getting confused. if (isset($toform['password'])) { $toform['quizpassword'] = $toform['password']; unset($toform['password']); } // Load any settings belonging to the access rules. if (!empty($toform['instance'])) { $accesssettings = quiz_access_manager::load_settings($toform['instance']); foreach ($accesssettings as $name => $value) { $toform[$name] = $value; } } }