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.
This commit is contained in:
@@ -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->aggregationcoef)) {
|
||||
$data->aggregationcoef = 0;
|
||||
if (!isset($data->gradepass) || $data->gradepass == '') {
|
||||
$data->gradepass = 0;
|
||||
}
|
||||
|
||||
if (!isset($data->grademin) || $data->grademin == '') {
|
||||
$data->grademin = 0;
|
||||
}
|
||||
|
||||
$hidden = empty($data->hidden) ? 0: $data->hidden;
|
||||
|
||||
Reference in New Issue
Block a user