MDL-32214 quiz regrading: with many attempts, PHP runs out of memory
This commit is contained in:
@@ -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]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user