Skip to content

Commit

Permalink
MDL-78100 gradereport_grader: Clear all button to reset filters
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocolate-lightning committed Aug 17, 2023
1 parent 478abd6 commit 9f5e343
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 3 deletions.
21 changes: 20 additions & 1 deletion grade/report/grader/classes/output/action_bar.php
Expand Up @@ -60,7 +60,7 @@ public function get_template(): string {
* @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.
Expand Down Expand Up @@ -125,6 +125,25 @@ public function export_for_template(\renderer_base $output): array {
'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;
Expand Down
2 changes: 2 additions & 0 deletions grade/report/grader/lang/en/gradereport_grader.php
Expand Up @@ -24,6 +24,8 @@
*/

$string['aria:dropdowncolumns'] = 'Collapsed columns found';
$string['clearall'] = 'Clear all';
$string['clearsearch'] = 'Clear searched users';
$string['collapsedcolumns'] = 'Collapsed columns <span class="badge badge-pill badge-primary ml-1" data-collapse="count">{$a}</span>';
$string['eventgradereportviewed'] = 'Grader report viewed';
$string['grader:manage'] = 'Manage the grader report';
Expand Down
9 changes: 8 additions & 1 deletion grade/report/grader/templates/action_bar.mustache
Expand Up @@ -61,7 +61,8 @@
]
},
"groupselector": "<div class='group-selector'></div>",
"collapsedcolumns": "<div class='collapse-columns'></div>"
"collapsedcolumns": "<div class='collapse-columns'></div>",
"pagereset": "http://moodle.local/grade/report/grader/index.php?id=2&userid=2&reset=1"
}
}}
<div class="container-fluid tertiary-navigation full-width-bottom-border">
Expand Down Expand Up @@ -90,6 +91,12 @@
</div>
<div class="navitem-divider"></div>
{{/initialselector}}
{{#pagereset}}
<div class="navitem align-self-center">
<a href="{{{.}}}" class="btn btn-link">{{#str}}clearall, gradereport_grader{{/str}}</a>
</div>
<div class="navitem-divider"></div>
{{/pagereset}}
{{#collapsedcolumns}}
<div class="navitem flex-column align-self-center ml-auto {{#classes}}{{.}}{{/classes}}" aria-live="polite">
{{#content}}
Expand Down
Expand Up @@ -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 |
Expand All @@ -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 |
Expand Down Expand Up @@ -317,6 +322,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] |
Expand Down

0 comments on commit 9f5e343

Please sign in to comment.