From b208ea26d168744cfc8367604000ffbc9ef7bb97 Mon Sep 17 00:00:00 2001 From: Shamim Rezaie Date: Wed, 26 Jul 2023 22:45:10 +1000 Subject: [PATCH] MDL-78082 core_grades: Hide lock/unlock options for grade categories Problem: The grade_categories table lacks a 'locked' field, making it technically impossible to lock grade categories. In Moodle 4.1, the "category total" column could be locked (from the edit category form), but locking grade categories directly was not supported. Solution: In response to the issue, the lock/unlock feature for grade categories has been removed. Since the grade_categories table does not have the necessary 'locked' field, attempting to implement category locking would be infeasible. As a result, the feature has been removed from the interface to avoid confusion. Explanation: By removing the lock/unlock feature for grade categories, we ensure that users no longer encounter non-functional options and prevent any potential misunderstandings about the locking behaviour. Additionally, this change aligns the user interface with the underlying database schema and eliminates any misleading functionality. --- grade/lib.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/grade/lib.php b/grade/lib.php index 8c4d100084c..f3b637d71fa 100644 --- a/grade/lib.php +++ b/grade/lib.php @@ -2379,7 +2379,10 @@ class grade_structure { ['id' => $this->courseid, 'sesskey' => sesskey(), 'eid' => $element['eid']]); $url = $gpr->add_url_params($url); - if (($element['type'] == 'grade') && ($element['object']->grade_item->is_locked())) { + if ($element['type'] == 'category') { + // Grade categories themselves cannot be locked. + return null; + } else if (($element['type'] == 'grade') && ($element['object']->grade_item->is_locked())) { // Don't allow an unlocking action for a grade whose grade item is locked: just print a state icon. $strparamobj = new stdClass(); $strparamobj->itemname = $element['object']->grade_item->get_name(true, true); @@ -2520,6 +2523,7 @@ class grade_structure { if (isset($element['type']) && ($element['type'] == 'category')) { $context['classes'] = 'category_grade_icons'; + $context['locked'] = false; } return $OUTPUT->render_from_template('core_grades/status_icons', $context); @@ -2651,7 +2655,6 @@ class grade_structure { } $context->editurl = $this->get_edit_link($element, $gpr); $context->hideurl = $this->get_hiding_link($element, $gpr); - $context->lockurl = $this->get_locking_link($element, $gpr); } }