MDL-50586 gradingform_rubric: 0-level warning during redirection
authorMarina Glancy <marina@moodle.com>
Wed, 17 Aug 2016 04:49:10 +0000 (12:49 +0800)
committerMarina Glancy <marina@moodle.com>
Wed, 17 Aug 2016 04:59:02 +0000 (12:59 +0800)
grade/grading/form/rubric/edit.php

index 2a6a33c..71f47b8 100644 (file)
@@ -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').'<br>'.
+                html_writer::link($manager->get_management_url(), get_string('back'));
+        }
+    }
+    redirect($returnurl, $warning, null, \core\output\notification::NOTIFY_ERROR);
 }
 
 echo $OUTPUT->header();