]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-18402 Put default value of 1 for grade item's aggregationcoef if parent category...
authornicolasconnault <nicolasconnault>
Fri, 8 May 2009 07:23:51 +0000 (07:23 +0000)
committernicolasconnault <nicolasconnault>
Fri, 8 May 2009 07:23:51 +0000 (07:23 +0000)
grade/edit/tree/item.php

index ac30d0ca351c9ed9c3b1af445b8cd63245d6ed84..5456e9f06eef96640e3d74107e6faf86b855edb1 100644 (file)
@@ -97,9 +97,21 @@ if ($mform->is_cancelled()) {
     redirect($returnurl);
 
 } else if ($data = $mform->get_data(false)) {
+    // If unset, give the aggregationcoef a default based on parent aggregation method
+    if (!isset($data->aggregationcoef) || $data->aggregationcoef == '') {
+        if ($parent_category->aggregation == GRADE_AGGREGATE_WEIGHTED_MEAN) {
+            $data->aggregationcoef = 1;
+        } else {
+            $data->aggregationcoef = 0;
+        }
+    }
+
+    if (!isset($data->gradepass) || $data->gradepass == '') {
+        $data->gradepass = 0;
+    }
 
-    if (!isset($data->aggregationcoef)) {
-        $data->aggregationcoef = 0;
+    if (!isset($data->grademin) || $data->grademin == '') {
+        $data->grademin = 0;
     }
 
     $hidden      = empty($data->hidden) ? 0: $data->hidden;