@@ -105,6 +105,13 @@ class grade_report_grader extends grade_report {
105
105
/** @var int Maximum number of students that can be shown on one page */
106
106
public const MAX_STUDENTS_PER_PAGE = 5000 ;
107
107
108
+ /**
109
+ * @var int The maximum number of grades that can be shown on one page.
110
+ *
111
+ * More than this causes issues for the browser due to the size of the page.
112
+ */
113
+ public const MAX_GRADES_PER_PAGE = 200000 ;
114
+
108
115
/** @var int[] List of available options on the pagination dropdown */
109
116
public const PAGINATION_OPTIONS = [20 , 100 ];
110
117
@@ -466,9 +473,10 @@ public function load_users(bool $allusers = false) {
466
473
$ this ->userwheresql
467
474
$ this ->groupwheresql
468
475
ORDER BY $ sort " ;
469
- // We never work with unlimited result. Limit the number of records by MAX_STUDENTS_PER_PAGE if no other limit is specified.
476
+ // We never work with unlimited result. Limit the number of records by $this->get_max_students_per_page() if no other limit
477
+ // is specified.
470
478
$ studentsperpage = ($ this ->get_students_per_page () && !$ allusers ) ?
471
- $ this ->get_students_per_page () : static :: MAX_STUDENTS_PER_PAGE ;
479
+ $ this ->get_students_per_page () : $ this -> get_max_students_per_page () ;
472
480
$ this ->users = $ DB ->get_records_sql ($ sql , $ params , $ studentsperpage * $ this ->page , $ studentsperpage );
473
481
474
482
if (empty ($ this ->users )) {
@@ -526,6 +534,18 @@ protected function get_allgradeitems() {
526
534
return $ this ->allgradeitems ;
527
535
}
528
536
537
+ /**
538
+ * Return the maximum number of students we can display per page.
539
+ *
540
+ * This is based on the number of grade items on the course, to limit the overall number of grades displayed on a single page.
541
+ * Trying to display too many grades causes browser issues.
542
+ *
543
+ * @return int
544
+ */
545
+ public function get_max_students_per_page (): int {
546
+ return round (static ::MAX_GRADES_PER_PAGE / count ($ this ->get_allgradeitems ()));
547
+ }
548
+
529
549
/**
530
550
* we supply the userids in this query, and get all the grades
531
551
* pulls out all the grades, this does not need to worry about paging
0 commit comments