/** * Check if there are changes in the rubric and it is needed to ask user whether to * mark the current grades for re-grading. User may confirm re-grading and continue, * return to editing or cancel the changes * * @param gradingform_rubric_controller $controller */ public function need_confirm_regrading($controller) { $data = $this->get_data(); if (isset($data->rubric['regrade'])) { // we have already displayed the confirmation on the previous step return false; } if (!isset($data->saverubric) || !$data->saverubric) { // we only need confirmation when button 'Save rubric' is pressed return false; } if (!$controller->has_active_instances()) { // nothing to re-grade, confirmation not needed return false; } $changelevel = $controller->update_or_check_rubric($data); if ($changelevel == 0) { // no changes in the rubric, no confirmation needed return false; } // freeze form elements and pass the values in hidden fields // TODO MDL-29421 description_editor does not freeze the normal way, uncomment below when fixed $form = $this->_form; foreach (array('rubric', 'name') as $fieldname) { $el =& $form->getElement($fieldname); $el->freeze(); $el->setPersistantFreeze(true); if ($fieldname == 'rubric') { $el->add_regrade_confirmation($changelevel); } } // replace button text 'saverubric' and unfreeze 'Back to edit' button $this->findButton('saverubric')->setValue(get_string('continue')); $el =& $this->findButton('editrubric'); $el->setValue(get_string('backtoediting', 'gradingform_rubric')); $el->unfreeze(); return true; }