mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-47681 core_grades: Ignore weights of grade items 'none' or 'text'
It can happen that some grade items with the type 'None' have a max grade different than 0, in which case we would have set a weight for them which is wrong as they must not have any. This patch always ignores the grade items 'None' and 'Text' when calculating the weights and locks the weight UI fields for those items too.
This commit is contained in:
parent
799190cd2d
commit
f8c8f980c7
3 changed files with 19 additions and 2 deletions
|
@ -178,11 +178,15 @@ class edit_item_form extends moodleform {
|
|||
|
||||
$mform->addElement('advcheckbox', 'weightoverride', get_string('adjustedweight', 'grades'));
|
||||
$mform->addHelpButton('weightoverride', 'weightoverride', 'grades');
|
||||
$mform->disabledIf('weightoverride', 'gradetype', 'eq', GRADE_TYPE_NONE);
|
||||
$mform->disabledIf('weightoverride', 'gradetype', 'eq', GRADE_TYPE_TEXT);
|
||||
|
||||
$mform->addElement('text', 'aggregationcoef2', get_string('weight', 'grades'));
|
||||
$mform->addHelpButton('aggregationcoef2', 'weight', 'grades');
|
||||
$mform->setType('aggregationcoef2', PARAM_RAW);
|
||||
$mform->disabledIf('aggregationcoef2', 'weightoverride');
|
||||
$mform->disabledIf('aggregationcoef2', 'gradetype', 'eq', GRADE_TYPE_NONE);
|
||||
$mform->disabledIf('aggregationcoef2', 'gradetype', 'eq', GRADE_TYPE_TEXT);
|
||||
|
||||
$options = array();
|
||||
$coefstring = '';
|
||||
|
@ -300,7 +304,8 @@ class edit_item_form extends moodleform {
|
|||
}
|
||||
$mform->addHelpButton('aggregationcoef', $coefstring, 'grades');
|
||||
}
|
||||
|
||||
$mform->disabledIf('aggregationcoef', 'gradetype', 'eq', GRADE_TYPE_NONE);
|
||||
$mform->disabledIf('aggregationcoef', 'gradetype', 'eq', GRADE_TYPE_TEXT);
|
||||
$mform->disabledIf('aggregationcoef', 'parentcategory', 'eq', $parent_category->id);
|
||||
}
|
||||
|
||||
|
|
|
@ -699,7 +699,8 @@ class grade_edit_tree_column_weight extends grade_edit_tree_column {
|
|||
$itemcell = parent::get_item_cell($item, $params);
|
||||
$itemcell->text = ' ';
|
||||
|
||||
if (!in_array($params['element']['object']->itemtype, array('courseitem', 'categoryitem', 'category'))) {
|
||||
if (!in_array($params['element']['object']->itemtype, array('courseitem', 'categoryitem', 'category'))
|
||||
&& !in_array($params['element']['object']->gradetype, array(GRADE_TYPE_NONE, GRADE_TYPE_TEXT))) {
|
||||
$itemcell->text = grade_edit_tree::get_weight_input($item);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue