From bfcdb5100fc0077e87b3d0ac40bbf46065d4c009 Mon Sep 17 00:00:00 2001 From: dragos5436 Date: Tue, 21 Jan 2025 12:32:33 +0000 Subject: [PATCH] MDL-83297 gradereport_grader: Make maxgradesperpage configurable After deploying to our production environment, we noticed that for large gradebooks, having a max of 200,000 grades per page was still too high and resulted in the gradebook page crashing or failing to load entirely. This commit will make this value configurable (e.g. ->maxgradesperpage = 70000) rather than a constant so that other institutions can tune it. Co-authored-by: Leon Stringer --- config-dist.php | 10 ++++++++-- grade/report/grader/lib.php | 10 +++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/config-dist.php b/config-dist.php index c0fb1163afb..833bc4bf68f 100644 --- a/config-dist.php +++ b/config-dist.php @@ -789,8 +789,14 @@ $CFG->admin = 'admin'; // polling should be done and latest update retrieved. // If no value is set, then it will default to 5 seconds. // -// $CFG->progresspollinterval = 5; - +// $CFG->progresspollinterval = 5; +// +// Set limit for grade items that can be shown on a single page of the grader +// report. Browsers struggle when the number of grade items is very large and +// one tries to view all students. +// +// $CFG->maxgradesperpage = 200000; +// //========================================================================= // 7. SETTINGS FOR DEVELOPMENT SERVERS - not intended for production use!!! //========================================================================= diff --git a/grade/report/grader/lib.php b/grade/report/grader/lib.php index c0b1a5b7bd5..291453128a4 100644 --- a/grade/report/grader/lib.php +++ b/grade/report/grader/lib.php @@ -547,7 +547,15 @@ class grade_report_grader extends grade_report { * @return int */ public function get_max_students_per_page(): int { - return round(static::MAX_GRADES_PER_PAGE / count($this->get_allgradeitems())); + global $CFG; + + if (isset($CFG->maxgradesperpage) && clean_param($CFG->maxgradesperpage, PARAM_INT) > 0) { + $maxgradesperpage = $CFG->maxgradesperpage; + } else { + $maxgradesperpage = self::MAX_GRADES_PER_PAGE; + } + + return round($maxgradesperpage / count($this->get_allgradeitems())); } /**