diff --git a/mod/quiz/report/overview/report.php b/mod/quiz/report/overview/report.php index c7e268149d4..0b82f201bb0 100644 --- a/mod/quiz/report/overview/report.php +++ b/mod/quiz/report/overview/report.php @@ -374,6 +374,7 @@ class quiz_overview_report extends quiz_attempt_report { */ protected function regrade_attempt($attempt, $dryrun = false, $slots = null) { global $DB; + set_time_limit(30); $transaction = $DB->start_delegated_transaction(); @@ -406,6 +407,11 @@ class quiz_overview_report extends quiz_attempt_report { } $transaction->allow_commit(); + + // Really, PHP should not need this hint, but without this, we just run out of memory. + $quba = null; + $transaction = null; + gc_collect_cycles(); } /** @@ -445,7 +451,6 @@ class quiz_overview_report extends quiz_attempt_report { $this->clear_regrade_table($quiz, $groupstudents); foreach ($attempts as $attempt) { - set_time_limit(30); $this->regrade_attempt($attempt, $dryrun); } @@ -494,7 +499,6 @@ class quiz_overview_report extends quiz_attempt_report { $this->clear_regrade_table($quiz, $groupstudents); foreach ($attempts as $attempt) { - set_time_limit(30); $this->regrade_attempt($attempt, false, $attemptquestions[$attempt->uniqueid]); }