Merge branch 'MDL-87031_501' of https://github.com/santoshndev/moodle into MOODLE_501_STABLE

This commit is contained in:
Huong Nguyen
2025-11-25 10:35:19 +07:00
6 changed files with 51 additions and 3 deletions
+2 -1
View File
@@ -31,6 +31,7 @@ require_once($CFG->dirroot.'/grade/report/lib.php');
$courseid = required_param('id', PARAM_INT);
$groupid = optional_param('group', null, PARAM_INT);
$reset = optional_param('reset', 0, PARAM_BOOL);
// Making this work with profile reports.
$userid = optional_param('userid', null, PARAM_INT);
@@ -105,7 +106,7 @@ switch ($itemtype) {
}
// If the item id (user id) cannot be defined or the user id is not part of the list of gradable users,
// display the user select zero state.
if (is_null($itemid) || !array_key_exists($itemid, grade_report::get_gradable_users($courseid, $currentgroup))) {
if (is_null($itemid) || !array_key_exists($itemid, grade_report::get_gradable_users($courseid, $currentgroup)) || $reset) {
$itemtype = 'user_select';
unset($SESSION->gradereport_singleview["useritem-{$context->id}"]);
}
+5 -1
View File
@@ -46,7 +46,11 @@ class gradereport_singleview_renderer extends plugin_renderer_base {
*/
public function users_selector(object $course, ?int $userid = null, ?int $groupid = null): string {
$courserenderer = $this->page->get_renderer('core', 'course');
$resetlink = new moodle_url('/grade/report/singleview/index.php', ['id' => $course->id, 'group' => $groupid ?? 0]);
$resetlink = new moodle_url('/grade/report/singleview/index.php', [
'id' => $course->id,
'group' => $groupid ?? 0,
'reset' => 1,
]);
$usersearch = '';
if ($userid) {
@@ -220,3 +220,22 @@ Feature: Within the singleview report, a teacher can search for users.
And the focused element is "Clear search input" "button" in the ".user-search" "css_element"
And I press the enter key
And I confirm "Turtle Manatee" does not exist in the "Search users" search combo box
Scenario: A teacher can clear the search and reload the page to show no student details
# A teacher searches for and selects a specific user.
Given I set the field "Search users" to "Turtle"
And I wait until "Turtle Manatee" "option_role" exists
When I click on "Turtle Manatee" "list_item"
# After selection, page reloads and displays only that user.
And I wait until the page is ready
Then "Turtle Manatee" "heading" should exist
# Search input retains the selected user for context.
And the field "Search users" matches value "Turtle Manatee"
# Teacher clicks the Clear link to reset the search and reload the page.
When I click on "Clear" "link"
# Page reloads with search field cleared and no student details displayed (empty state).
And I wait until the page is ready
Then the field "Search users" matches value ""
# All student headings should disappear (no students shown on empty state).
And "Turtle Manatee" "heading" should not exist
@@ -97,7 +97,7 @@ class action_bar extends \core_grades\output\action_bar {
$data['groupselector'] = $groupselector->export_for_template($output);
}
$resetlink = new moodle_url('/grade/report/user/index.php', ['id' => $courseid, 'group' => 0]);
$resetlink = new moodle_url('/grade/report/user/index.php', ['id' => $courseid, 'group' => 0, 'reset' => 1]);
$baseurl = new moodle_url('/grade/report/user/index.php', ['id' => $courseid]);
$PAGE->requires->js_call_amd('gradereport_user/user', 'init', [$baseurl->out(false)]);
+5
View File
@@ -31,6 +31,7 @@ $courseid = required_param('id', PARAM_INT);
// 0 - view all reports. null - view own report. non-zero and non-null - view other user report.
$userid = optional_param('userid', null, PARAM_INT);
$userview = optional_param('userview', 0, PARAM_INT);
$reset = optional_param('reset', 0, PARAM_BOOL);
$PAGE->set_url(new moodle_url('/grade/report/user/index.php', ['id' => $courseid]));
@@ -130,6 +131,10 @@ if (has_capability('moodle/grade:viewall', $context)) {
$userid = $USER->id;
}
// If the reset parameter is set, clear any stored (last viewed) user in a session variable.
if ($reset) {
unset($SESSION->gradereport_user["useritem-{$context->id}"]);
}
// If there is a stored (last viewed) user in a session variable, bypass the user select zero state and display the
// report for that user.
$lastvieweduserid = $SESSION->gradereport_user["useritem-{$context->id}"] ?? null;
@@ -261,3 +261,22 @@ Feature: Within the User report, a teacher can search for users.
And "User Test" "heading" should not exist
And "Teacher 1" "heading" should not exist
And "Turtle Manatee" "heading" should not exist
Scenario: A teacher can clear the search and reload the page to show no student details
# A teacher searches for and selects a specific user.
Given I set the field "Search users" to "Dummy"
And I wait until "Dummy User" "option_role" exists
When I click on "Dummy User" "list_item"
# After selection, page reloads and displays only that user.
And I wait until the page is ready
Then "Dummy User" "heading" should exist
# Search input retains the selected user for context.
And the field "Search users" matches value "Dummy User"
# Teacher clicks the Clear link to reset the search and reload the page.
When I click on "Clear" "link"
# Page reloads with search field cleared and no student details displayed (empty state).
And I wait until the page is ready
Then the field "Search users" matches value ""
# All student headings should disappear (no students shown on empty state).
And "Dummy User" "heading" should not exist