From 655534286387e13b79d03a7134bdac10dede2f7b Mon Sep 17 00:00:00 2001 From: Tobias Reischmann Date: Mon, 18 Feb 2019 16:40:38 +0100 Subject: [PATCH] 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. --- grade/edit/tree/category_form.php | 4 ++++ grade/edit/tree/item_form.php | 2 ++ 2 files changed, 6 insertions(+) diff --git a/grade/edit/tree/category_form.php b/grade/edit/tree/category_form.php index 98a18a45d09..ef6ada4b10b 100644 --- a/grade/edit/tree/category_form.php +++ b/grade/edit/tree/category_form.php @@ -211,6 +211,8 @@ function definition() { } $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 @@ function definition() { $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); diff --git a/grade/edit/tree/item_form.php b/grade/edit/tree/item_form.php index 5dfb8e95136..f762cc7e9c8 100644 --- a/grade/edit/tree/item_form.php +++ b/grade/edit/tree/item_form.php @@ -166,6 +166,7 @@ function definition() { } $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 @@ function definition() { 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) {