Skip to content

Commit

Permalink
MDL-36020 overview/report: fix quiz regrade session lock
Browse files Browse the repository at this point in the history
  • Loading branch information
troylee authored and danpoltawski committed May 20, 2013
1 parent 166e25f commit 4126c81
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion mod/quiz/report/overview/report.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -291,6 +291,14 @@ protected function process_actions($quiz, $cm, $currentgroup, $groupstudents, $a
} }
} }


/**
* Unlock the session and allow the regrading process to run in the background.
*/
protected function unlock_session() {
session_get_instance()->write_close();
ignore_user_abort(true);
}

/** /**
* Regrade a particular quiz attempt. Either for real ($dryrun = false), or * Regrade a particular quiz attempt. Either for real ($dryrun = false), or
* as a pretend regrade to see which fractions would change. The outcome is * as a pretend regrade to see which fractions would change. The outcome is
Expand All @@ -306,7 +314,8 @@ protected function process_actions($quiz, $cm, $currentgroup, $groupstudents, $a
*/ */
protected function regrade_attempt($attempt, $dryrun = false, $slots = null) { protected function regrade_attempt($attempt, $dryrun = false, $slots = null) {
global $DB; global $DB;
set_time_limit(30); // Need more time for a quiz with many questions.
set_time_limit(300);


$transaction = $DB->start_delegated_transaction(); $transaction = $DB->start_delegated_transaction();


Expand Down Expand Up @@ -359,6 +368,7 @@ protected function regrade_attempt($attempt, $dryrun = false, $slots = null) {
protected function regrade_attempts($quiz, $dryrun = false, protected function regrade_attempts($quiz, $dryrun = false,
$groupstudents = array(), $attemptids = array()) { $groupstudents = array(), $attemptids = array()) {
global $DB; global $DB;
$this->unlock_session();


$where = "quiz = ? AND preview = 0"; $where = "quiz = ? AND preview = 0";
$params = array($quiz->id); $params = array($quiz->id);
Expand Down Expand Up @@ -400,6 +410,7 @@ protected function regrade_attempts($quiz, $dryrun = false,
*/ */
protected function regrade_attempts_needing_it($quiz, $groupstudents) { protected function regrade_attempts_needing_it($quiz, $groupstudents) {
global $DB; global $DB;
$this->unlock_session();


$where = "quiza.quiz = ? AND quiza.preview = 0 AND qqr.regraded = 0"; $where = "quiza.quiz = ? AND quiza.preview = 0 AND qqr.regraded = 0";
$params = array($quiz->id); $params = array($quiz->id);
Expand Down

0 comments on commit 4126c81

Please sign in to comment.