diff --git a/grade/edit/tree/lib.php b/grade/edit/tree/lib.php index 4a86cb3eec4..b9aec5d723c 100644 --- a/grade/edit/tree/lib.php +++ b/grade/edit/tree/lib.php @@ -698,9 +698,11 @@ class grade_edit_tree_column_weight extends grade_edit_tree_column { } $itemcell = parent::get_item_cell($item, $params); $itemcell->text = ' '; + $object = $params['element']['object']; - if (!in_array($params['element']['object']->itemtype, array('courseitem', 'categoryitem', 'category')) - && !in_array($params['element']['object']->gradetype, array(GRADE_TYPE_NONE, GRADE_TYPE_TEXT))) { + if (!in_array($object->itemtype, array('courseitem', 'categoryitem', 'category')) + && !in_array($object->gradetype, array(GRADE_TYPE_NONE, GRADE_TYPE_TEXT)) + && (!$object->is_outcome_item() || $object->load_parent_category()->aggregateoutcomes)) { $itemcell->text = grade_edit_tree::get_weight_input($item); } diff --git a/grade/edit/tree/outcomeitem_form.php b/grade/edit/tree/outcomeitem_form.php index aeece1fc75e..285acbed4c3 100644 --- a/grade/edit/tree/outcomeitem_form.php +++ b/grade/edit/tree/outcomeitem_form.php @@ -202,7 +202,7 @@ class edit_outcomeitem_form extends moodleform { $parent_category->apply_forced_settings(); - if (!$parent_category->is_aggregationcoef_used()) { + if (!$parent_category->is_aggregationcoef_used() || !$parent_category->aggregateoutcomes) { if ($mform->elementExists('aggregationcoef')) { $mform->removeElement('aggregationcoef'); } @@ -228,8 +228,11 @@ class edit_outcomeitem_form extends moodleform { $mform->addHelpButton('aggregationcoef', $aggcoef, 'grades'); } } - // Remove fields used by natural weighting if the parent category is not using natural weighting. - if ($parent_category->aggregation != GRADE_AGGREGATE_SUM) { + + // Remove the natural weighting fields for other aggregations, + // or when the category does not aggregate outcomes. + if ($parent_category->aggregation != GRADE_AGGREGATE_SUM || + !$parent_category->aggregateoutcomes) { if ($mform->elementExists('weightoverride')) { $mform->removeElement('weightoverride'); } diff --git a/lib/grade/grade_category.php b/lib/grade/grade_category.php index 3f78e0c111f..1b0e734af90 100644 --- a/lib/grade/grade_category.php +++ b/lib/grade/grade_category.php @@ -1454,6 +1454,9 @@ class grade_category extends grade_object { if ($gradeitem->gradetype == GRADE_TYPE_NONE || $gradeitem->gradetype == GRADE_TYPE_TEXT) { // Text items and none items do not have a weight. continue; + } else if (!$this->aggregateoutcomes && $gradeitem->is_outcome_item()) { + // We will not aggregate outcome items, so we can ignore them. + continue; } // Record the ID and the weight for this grade item. @@ -1524,6 +1527,9 @@ class grade_category extends grade_object { // Text items and none items do not have a weight, no need to set their weight to // zero as they must never be used during aggregation. continue; + } else if (!$this->aggregateoutcomes && $gradeitem->is_outcome_item()) { + // We will not aggregate outcome items, so we can ignore updating their weights. + continue; } if (!$gradeitem->weightoverride) {