Skip to content

Commit

Permalink
MDL-78082 core_grades: Hide lock/unlock options for grade categories
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rezaies committed Sep 6, 2023
1 parent 475f617 commit d2d8d16
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions grade/lib.php
Expand Up @@ -2352,7 +2352,10 @@ public function get_locking_link(array $element, object $gpr): ?string {
['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);
Expand Down Expand Up @@ -2480,7 +2483,7 @@ public function set_grade_status_icons(array $element): string {
'moodle', $attributes);
}

if ($element['object']->is_locked()) {
if (($element['type'] != 'category') && $element['object']->is_locked()) {
$statusicons .= $OUTPUT->pix_icon('i/lock', grade_helper::get_lang_string('locked', 'grades'),
'moodle', $attributes);
}
Expand Down Expand Up @@ -2640,7 +2643,6 @@ public function get_cell_action_menu(array $element, string $mode, grade_plugin_
}
$context->editurl = $this->get_edit_link($element, $gpr);
$context->hideurl = $this->get_hiding_link($element, $gpr);
$context->lockurl = $this->get_locking_link($element, $gpr);
}
}

Expand Down

0 comments on commit d2d8d16

Please sign in to comment.