From a87b2d70ecb8d0e5ea3fb113cee3d83a4987fcf1 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Wed, 17 Aug 2016 12:49:10 +0800 Subject: [PATCH] MDL-50586 gradingform_rubric: 0-level warning during redirection --- grade/grading/form/rubric/edit.php | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/grade/grading/form/rubric/edit.php b/grade/grading/form/rubric/edit.php index 2a6a33c1cf3..71f47b88ef1 100644 --- a/grade/grading/form/rubric/edit.php +++ b/grade/grading/form/rubric/edit.php @@ -50,9 +50,19 @@ $mform->set_data($data); if ($mform->is_cancelled()) { redirect($returnurl); } else if ($mform->is_submitted() && $mform->is_validated() && !$mform->need_confirm_regrading($controller)) { - // everything ok, validated, re-grading confirmed if needed. Make changes to the rubric - $controller->update_definition($mform->get_data()); - redirect($returnurl); + // Everything ok, validated, re-grading confirmed if needed. Make changes to the rubric. + $data = $mform->get_data(); + $controller->update_definition($data); + + // If we do not go back to management url and the minscore warning needs to be displayed, display it during redirection. + $warning = null; + if (!empty($data->returnurl)) { + if (($scores = $controller->get_min_max_score()) && $scores['minscore'] <> 0) { + $warning = get_string('zerolevelsabsent', 'gradingform_rubric').'
'. + html_writer::link($manager->get_management_url(), get_string('back')); + } + } + redirect($returnurl, $warning, null, \core\output\notification::NOTIFY_ERROR); } echo $OUTPUT->header();