Skip to content

Commit

Permalink
MDL-64891 gradebook: Disable grade display type dependent on grade type
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tobiasreischmann committed Feb 18, 2019
1 parent 1249995 commit 6555342
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions grade/edit/tree/category_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,17 @@ 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);
$mform->addElement('select', 'grade_item_decimals', get_string('decimalpoints', 'grades'), $options);
$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);
Expand Down
2 changes: 2 additions & 0 deletions grade/edit/tree/item_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {
Expand Down

0 comments on commit 6555342

Please sign in to comment.