MDL-47703 core_grades: Prevent use of weights with non-aggregated scales

This commit is contained in:
Frederic Massart 2014-10-16 11:12:44 +08:00 committed by Frederic Massart
parent d63a81c507
commit 8b5c454562
4 changed files with 16 additions and 3 deletions

View file

@ -1419,6 +1419,7 @@ class grade_category extends grade_object {
* @return void
*/
private function auto_update_weights() {
global $CFG;
if ($this->aggregation != GRADE_AGGREGATE_SUM) {
// This is only required if we are using natural weights.
return;
@ -1457,6 +1458,9 @@ class grade_category extends grade_object {
} else if (!$this->aggregateoutcomes && $gradeitem->is_outcome_item()) {
// We will not aggregate outcome items, so we can ignore them.
continue;
} else if (empty($CFG->grade_includescalesinaggregation) && $gradeitem->gradetype == GRADE_TYPE_SCALE) {
// The scales are not included in the aggregation, ignore them.
continue;
}
// Record the ID and the weight for this grade item.
@ -1530,6 +1534,9 @@ class grade_category extends grade_object {
} else if (!$this->aggregateoutcomes && $gradeitem->is_outcome_item()) {
// We will not aggregate outcome items, so we can ignore updating their weights.
continue;
} else if (empty($CFG->grade_includescalesinaggregation) && $gradeitem->gradetype == GRADE_TYPE_SCALE) {
// We will not aggregate the scales, so we can ignore upating their weights.
continue;
}
if (!$gradeitem->weightoverride) {