From: nicolasconnault Date: Fri, 8 May 2009 07:23:51 +0000 (+0000) Subject: MDL-18402 Put default value of 1 for grade item's aggregationcoef if parent category... X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=33e2e924534834924d9c2bc0ebc8d7353489743f;p=moodle.git MDL-18402 Put default value of 1 for grade item's aggregationcoef if parent category's aggregation is weighted mean. Put 0 for gradepass if field is empty, and 0 for grademin if left empty. This prevents SQL errors because all three fields (aggregationcoef, gradepass and grademin) are non-NULL. Merged from MOODLE_19_STABLE --- diff --git a/grade/edit/tree/item.php b/grade/edit/tree/item.php index ac30d0ca35..5456e9f06e 100644 --- a/grade/edit/tree/item.php +++ b/grade/edit/tree/item.php @@ -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;