Skip to content

Commit

Permalink
MDL-77902 gradebook: Ensure dyn search works with pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
Chocolate-lightning committed Apr 17, 2023
1 parent 0e08d0d commit fbc51cd
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
Expand Up @@ -101,7 +101,7 @@ protected static function execute(int $courseid): array {
$userpicture->size = 0; // Size f2.
$user->profileimageurlsmall = $userpicture->get_url($PAGE)->out(false);
return $user;
}, $report->load_users());
}, $report->load_users(true));
sort($users);

return [
Expand Down
6 changes: 4 additions & 2 deletions grade/report/grader/lib.php
Expand Up @@ -389,8 +389,10 @@ private function setup_sortitemid(string $sort = '') {

/**
* pulls out the userids of the users to be display, and sorts them
*
* @param bool $allusers If we are getting the users within the report, we want them all irrespective of paging.
*/
public function load_users() {
public function load_users(bool $allusers = false) {
global $CFG, $DB;

if (!empty($this->users)) {
Expand Down Expand Up @@ -465,7 +467,7 @@ public function load_users() {
$this->groupwheresql
ORDER BY $sort";
// We never work with unlimited result. Limit the number of records by MAX_STUDENTS_PER_PAGE if no other limit is specified.
$studentsperpage = $this->get_students_per_page() ?: static::MAX_STUDENTS_PER_PAGE;
$studentsperpage = ($this->get_students_per_page() && !$allusers) ? $this->get_students_per_page() : static::MAX_STUDENTS_PER_PAGE;
$this->users = $DB->get_records_sql($sql, $params, $studentsperpage * $this->page, $studentsperpage);

if (empty($this->users)) {
Expand Down
Expand Up @@ -307,3 +307,19 @@ Feature: Within the grader report, test that we can search for users
# Begin the search checking if we are adhering the filters.
When I set the field "Search users" to "Turtle"
Then "Turtle Manatee" "list_item" should not exist in the ".user-search" "css_element"

Scenario: As a teacher I can dynamically find users whilst ignoring pagination
Given "42" "users" exist with the following data:
| username | students[count] |
| firstname | Student |
| lastname | s[count] |
| email | students[count]@example.com |
And "42" "course enrolments" exist with the following data:
| user | students[count] |
| course | C1 |
| role |student |
And I reload the page
And the field "perpage" matches value "20"
When I set the field "Search users" to "42"
And I wait until "View all results for \"42\"" "link" exists
Then "Student s42" "list_item" should exist in the ".user-search" "css_element"

0 comments on commit fbc51cd

Please sign in to comment.