mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 01:16:44 +02:00
MDL-47703 core_grades: Prevent use of weights with non-aggregated scales
This commit is contained in:
parent
d63a81c507
commit
8b5c454562
4 changed files with 16 additions and 3 deletions
|
@ -467,7 +467,9 @@ class edit_category_form extends moodleform {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove fields used by natural weighting if the parent category is not using natural weighting.
|
// Remove fields used by natural weighting if the parent category is not using natural weighting.
|
||||||
if ($parent_category->aggregation != GRADE_AGGREGATE_SUM) {
|
// Or if the item is a scale and scales are not used in aggregation.
|
||||||
|
if ($parent_category->aggregation != GRADE_AGGREGATE_SUM
|
||||||
|
|| (empty($CFG->grade_includescalesinaggregation) && $grade_item->gradetype == GRADE_TYPE_SCALE)) {
|
||||||
if ($mform->elementExists('grade_item_weightoverride')) {
|
if ($mform->elementExists('grade_item_weightoverride')) {
|
||||||
$mform->removeElement('grade_item_weightoverride');
|
$mform->removeElement('grade_item_weightoverride');
|
||||||
}
|
}
|
||||||
|
|
|
@ -310,7 +310,9 @@ class edit_item_form extends moodleform {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove fields used by natural weighting if the parent category is not using natural weighting.
|
// Remove fields used by natural weighting if the parent category is not using natural weighting.
|
||||||
if ($parent_category->aggregation != GRADE_AGGREGATE_SUM) {
|
// Or if the item is a scale and scales are not used in aggregation.
|
||||||
|
if ($parent_category->aggregation != GRADE_AGGREGATE_SUM
|
||||||
|
|| (empty($CFG->grade_includescalesinaggregation) && $grade_item->gradetype == GRADE_TYPE_SCALE)) {
|
||||||
if ($mform->elementExists('weightoverride')) {
|
if ($mform->elementExists('weightoverride')) {
|
||||||
$mform->removeElement('weightoverride');
|
$mform->removeElement('weightoverride');
|
||||||
}
|
}
|
||||||
|
|
|
@ -706,6 +706,7 @@ class grade_edit_tree_column_weight extends grade_edit_tree_column {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_item_cell($item, $params) {
|
public function get_item_cell($item, $params) {
|
||||||
|
global $CFG;
|
||||||
if (empty($params['element'])) {
|
if (empty($params['element'])) {
|
||||||
throw new Exception('Array key (element) missing from 2nd param of grade_edit_tree_column_weightorextracredit::get_item_cell($item, $params)');
|
throw new Exception('Array key (element) missing from 2nd param of grade_edit_tree_column_weightorextracredit::get_item_cell($item, $params)');
|
||||||
}
|
}
|
||||||
|
@ -715,7 +716,8 @@ class grade_edit_tree_column_weight extends grade_edit_tree_column {
|
||||||
|
|
||||||
if (!in_array($object->itemtype, array('courseitem', 'categoryitem', 'category'))
|
if (!in_array($object->itemtype, array('courseitem', 'categoryitem', 'category'))
|
||||||
&& !in_array($object->gradetype, array(GRADE_TYPE_NONE, GRADE_TYPE_TEXT))
|
&& !in_array($object->gradetype, array(GRADE_TYPE_NONE, GRADE_TYPE_TEXT))
|
||||||
&& (!$object->is_outcome_item() || $object->load_parent_category()->aggregateoutcomes)) {
|
&& (!$object->is_outcome_item() || $object->load_parent_category()->aggregateoutcomes)
|
||||||
|
&& ($object->gradetype != GRADE_TYPE_SCALE || !empty($CFG->grade_includescalesinaggregation))) {
|
||||||
$itemcell->text = grade_edit_tree::get_weight_input($item);
|
$itemcell->text = grade_edit_tree::get_weight_input($item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1419,6 +1419,7 @@ class grade_category extends grade_object {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
private function auto_update_weights() {
|
private function auto_update_weights() {
|
||||||
|
global $CFG;
|
||||||
if ($this->aggregation != GRADE_AGGREGATE_SUM) {
|
if ($this->aggregation != GRADE_AGGREGATE_SUM) {
|
||||||
// This is only required if we are using natural weights.
|
// This is only required if we are using natural weights.
|
||||||
return;
|
return;
|
||||||
|
@ -1457,6 +1458,9 @@ class grade_category extends grade_object {
|
||||||
} else if (!$this->aggregateoutcomes && $gradeitem->is_outcome_item()) {
|
} else if (!$this->aggregateoutcomes && $gradeitem->is_outcome_item()) {
|
||||||
// We will not aggregate outcome items, so we can ignore them.
|
// We will not aggregate outcome items, so we can ignore them.
|
||||||
continue;
|
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.
|
// 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()) {
|
} else if (!$this->aggregateoutcomes && $gradeitem->is_outcome_item()) {
|
||||||
// We will not aggregate outcome items, so we can ignore updating their weights.
|
// We will not aggregate outcome items, so we can ignore updating their weights.
|
||||||
continue;
|
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) {
|
if (!$gradeitem->weightoverride) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue