diff --git a/grade/report/grader/classes/external/get_users_in_report.php b/grade/report/grader/classes/external/get_users_in_report.php index 4114ebe7bdd..e8cd67479c7 100644 --- a/grade/report/grader/classes/external/get_users_in_report.php +++ b/grade/report/grader/classes/external/get_users_in_report.php @@ -101,7 +101,7 @@ class get_users_in_report extends external_api { $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 [ diff --git a/grade/report/grader/lib.php b/grade/report/grader/lib.php index c56d33611af..4dae0ae552f 100644 --- a/grade/report/grader/lib.php +++ b/grade/report/grader/lib.php @@ -389,8 +389,10 @@ class grade_report_grader extends grade_report { /** * 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)) { @@ -465,7 +467,7 @@ class grade_report_grader extends grade_report { $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)) { diff --git a/grade/report/grader/tests/behat/tertiary_navigation_searching.feature b/grade/report/grader/tests/behat/tertiary_navigation_searching.feature index f9529e59cd8..b8a4d1e0e13 100644 --- a/grade/report/grader/tests/behat/tertiary_navigation_searching.feature +++ b/grade/report/grader/tests/behat/tertiary_navigation_searching.feature @@ -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"