MDL-64891 gradebook: Disable grade display type dependent on grade type

If the grade types text or none are selected for an item or a category,
none of the 'grade display type' options  will change the displayed
grade within the reports. Thus, we can disable the settings for grade
display type as well as the one for decimal places in this case.
This commit is contained in:
Tobias Reischmann 2019-02-18 16:40:38 +01:00
parent 124999563a
commit 6555342863
No known key found for this signature in database
GPG Key ID: 14715C065F634E33
2 changed files with 6 additions and 0 deletions

View File

@ -211,6 +211,8 @@ class edit_category_form extends moodleform {
}
$mform->addElement('select', 'grade_item_display', get_string('gradedisplaytype', 'grades'), $options);
$mform->addHelpButton('grade_item_display', 'gradedisplaytype', 'grades');
$mform->disabledIf('grade_item_display', 'grade_item_gradetype', 'in',
array(GRADE_TYPE_TEXT, GRADE_TYPE_NONE));
$default_gradedecimals = grade_get_setting($COURSE->id, 'decimalpoints', $CFG->grade_decimalpoints);
$options = array(-1=>get_string('defaultprev', 'grades', $default_gradedecimals), 0=>0, 1=>1, 2=>2, 3=>3, 4=>4, 5=>5);
@ -218,6 +220,8 @@ class edit_category_form extends moodleform {
$mform->addHelpButton('grade_item_decimals', 'decimalpoints', 'grades');
$mform->setDefault('grade_item_decimals', -1);
$mform->disabledIf('grade_item_decimals', 'grade_item_display', 'eq', GRADE_DISPLAY_TYPE_LETTER);
$mform->disabledIf('grade_item_decimals', 'grade_item_gradetype', 'in',
array(GRADE_TYPE_TEXT, GRADE_TYPE_NONE));
if ($default_gradedisplaytype == GRADE_DISPLAY_TYPE_LETTER) {
$mform->disabledIf('grade_item_decimals', 'grade_item_display', "eq", GRADE_DISPLAY_TYPE_DEFAULT);

View File

@ -166,6 +166,7 @@ class edit_item_form extends moodleform {
}
$mform->addElement('select', 'display', get_string('gradedisplaytype', 'grades'), $options);
$mform->addHelpButton('display', 'gradedisplaytype', 'grades');
$mform->disabledIf('display', 'gradetype', 'eq', GRADE_TYPE_TEXT);
$default_gradedecimals = grade_get_setting($COURSE->id, 'decimalpoints', $CFG->grade_decimalpoints);
$options = array(-1=>get_string('defaultprev', 'grades', $default_gradedecimals), 0=>0, 1=>1, 2=>2, 3=>3, 4=>4, 5=>5);
@ -176,6 +177,7 @@ class edit_item_form extends moodleform {
if ($default_gradedisplaytype == GRADE_DISPLAY_TYPE_LETTER) {
$mform->disabledIf('decimals', 'display', "eq", GRADE_DISPLAY_TYPE_DEFAULT);
}
$mform->disabledIf('decimals', 'gradetype', 'eq', GRADE_TYPE_TEXT);
/// hiding
if ($item->cancontrolvisibility) {