diff --git a/grade/report/grader/classes/output/action_bar.php b/grade/report/grader/classes/output/action_bar.php
index 4ec80726ca4..8dd1f184e3f 100644
--- a/grade/report/grader/classes/output/action_bar.php
+++ b/grade/report/grader/classes/output/action_bar.php
@@ -60,7 +60,7 @@ class action_bar extends \core_grades\output\action_bar {
* @throws \moodle_exception
*/
public function export_for_template(\renderer_base $output): array {
- global $PAGE, $OUTPUT;
+ global $PAGE, $OUTPUT, $SESSION, $USER;
// If in the course context, we should display the general navigation selector in gradebook.
$courseid = $this->context->instanceid;
// Get the data used to output the general navigation selector.
@@ -125,6 +125,25 @@ class action_bar extends \core_grades\output\action_bar {
'classes' => 'd-none',
'content' => $collapse->export_for_template($output)
];
+
+ if ($course->groupmode == VISIBLEGROUPS || has_capability('moodle/site:accessallgroups', $this->context)) {
+ $allowedgroups = groups_get_all_groups($course->id, 0, $course->defaultgroupingid);
+ } else {
+ $allowedgroups = groups_get_all_groups($course->id, $USER->id, $course->defaultgroupingid);
+ }
+
+ if (!empty($SESSION->gradereport["filterfirstname-{$this->context->id}"]) ||
+ !empty($SESSION->gradereport["filterlastname-{$this->context->id}"]) ||
+ groups_get_course_group($course, true, $allowedgroups) ||
+ $this->usersearch) {
+ $reset = new moodle_url('/grade/report/grader/index.php', [
+ 'id' => $courseid,
+ 'group' => 0,
+ 'sifirst' => '',
+ 'silast' => ''
+ ]);
+ $data['pagereset'] = $reset->out(false);
+ }
}
return $data;
diff --git a/grade/report/grader/lang/en/gradereport_grader.php b/grade/report/grader/lang/en/gradereport_grader.php
index 565fb590978..68cb635d876 100644
--- a/grade/report/grader/lang/en/gradereport_grader.php
+++ b/grade/report/grader/lang/en/gradereport_grader.php
@@ -24,6 +24,8 @@
*/
$string['aria:dropdowncolumns'] = 'Collapsed columns found';
+$string['clearall'] = 'Clear all';
+$string['clearsearch'] = 'Clear searched users';
$string['collapsedcolumns'] = 'Collapsed columns {$a}';
$string['eventgradereportviewed'] = 'Grader report viewed';
$string['grader:manage'] = 'Manage the grader report';
diff --git a/grade/report/grader/templates/action_bar.mustache b/grade/report/grader/templates/action_bar.mustache
index e7117419589..594e7d582f9 100644
--- a/grade/report/grader/templates/action_bar.mustache
+++ b/grade/report/grader/templates/action_bar.mustache
@@ -61,7 +61,8 @@
]
},
"groupselector": "
",
- "collapsedcolumns": ""
+ "collapsedcolumns": "",
+ "pagereset": "http://moodle.local/grade/report/grader/index.php?id=2&userid=2&reset=1"
}
}}
@@ -90,6 +91,12 @@
{{/initialselector}}
+ {{#pagereset}}
+
+
+ {{/pagereset}}
{{#collapsedcolumns}}
{{#content}}
diff --git a/grade/report/grader/tests/behat/tertiary_navigation_searching.feature b/grade/report/grader/tests/behat/tertiary_navigation_searching.feature
index ddab19aac64..70308f55910 100644
--- a/grade/report/grader/tests/behat/tertiary_navigation_searching.feature
+++ b/grade/report/grader/tests/behat/tertiary_navigation_searching.feature
@@ -16,7 +16,6 @@ Feature: Within the grader report, test that we can search for users
| student3 | User | Example | student3@example.com | s3 | 3243249087 | 0875421745 | ABC2 | ABCD | Olney | GB |
| student4 | User | Test | student4@example.com | s4 | 0987532523 | 2149871323 | ABC3 | ABCD | Tokyo | JP |
| student5 | Turtle | Manatee | student5@example.com | s5 | 1239087780 | 9873623589 | ABC3 | ABCD | Perth | AU |
- # Note: Add groups etc so we can test that the search ignores those filters as well if we go down the filter dataset path.
And the following "course enrolments" exist:
| user | course | role |
| teacher1 | C1 | editingteacher |
@@ -25,6 +24,12 @@ Feature: Within the grader report, test that we can search for users
| student3 | C1 | student |
| student4 | C1 | student |
| student5 | C1 | student |
+ And the following "groups" exist:
+ | name | course | idnumber |
+ | Default group | C1 | dg |
+ And the following "group members" exist:
+ | user | group |
+ | student5 | dg |
And the following "activities" exist:
| activity | course | idnumber | name |
| assign | C1 | a1 | Test assignment one |
@@ -315,6 +320,28 @@ Feature: Within the grader report, test that we can search for users
When I set the field "Search users" to "Turtle"
Then I confirm "Turtle Manatee" in "user" search within the gradebook widget does not exist
+ Scenario: A teacher can reset the search and filters all at once
+ Given I set the field "Search users" to "Turtle"
+ And I click on "Turtle Manatee" "option_role"
+ And I wait until the page is ready
+ And the following should exist in the "user-grades" table:
+ | -1- |
+ | Turtle Manatee |
+ And I press "Filter by name"
+ And I select "T" in the "First name" "core_grades > initials bar"
+ And I select "M" in the "Last name" "core_grades > initials bar"
+ And the following should exist in the "user-grades" table:
+ | -1- |
+ | Turtle Manatee |
+ And I click on "Default group" in the "group" search widget
+ And the following should exist in the "user-grades" table:
+ | -1- |
+ | Turtle Manatee |
+ And I wait until the page is ready
+ When I click on "Clear all" "link" in the ".tertiary-navigation" "css_element"
+ And I wait until the page is ready
+ Then the field "Search users" matches value ""
+
Scenario: As a teacher I can dynamically find users whilst ignoring pagination
Given "42" "users" exist with the following data:
| username | students[count] |