MDL-49202 core_grades: perform same action on categories in form

When you click on 'Edit' then 'Hide' on a grade item like a course category
that contains many grade items, the course and the grade items are set to
hidden. However, if you use the 'hidden' option on the 'Edit settings'
page it only hides that item and none of the items (assignment etc)
under that course category. We want them to be consistent.
This commit is contained in:
Mark Nelson 2021-08-17 20:13:34 +08:00
parent 9396dacf81
commit e6ea2e72f4

View file

@ -683,11 +683,15 @@ class grade_edit_tree {
$gradeitem->grademin, $gradeitem->grademax, 'gradebook');
}
// Update hiding flag.
if ($hiddenuntil) {
$gradeitem->set_hidden($hiddenuntil, false);
} else {
$gradeitem->set_hidden($hidden, false);
// Only update the category's 'hidden' status if it has changed. Leaving a category as 'unhidden' (checkbox left
// unmarked) and submitting the form without this conditional check will result in displaying any grade items that
// are in the category, including those that were previously 'hidden'.
if (($gradecategory->get_hidden() != $hiddenuntil) || ($gradecategory->get_hidden() != $hidden)) {
if ($hiddenuntil) {
$gradecategory->set_hidden($hiddenuntil, true);
} else {
$gradecategory->set_hidden($hidden, true);
}
}
$gradeitem->set_locktime($locktime); // Locktime first - it might be removed when unlocking.