diff --git a/mod/quiz/lib.php b/mod/quiz/lib.php index 8edeffc9520..87f6565e856 100644 --- a/mod/quiz/lib.php +++ b/mod/quiz/lib.php @@ -300,7 +300,7 @@ function quiz_get_answers($question) { } -function quiz_get_attempt_responses($attempt) { +function quiz_get_attempt_responses($attempt, $quiz) { // Given an attempt object, this function gets all the // stored responses and returns them in a format suitable // for regrading using quiz_grade_attempt_results() @@ -310,7 +310,8 @@ function quiz_get_attempt_responses($attempt) { FROM {$CFG->prefix}quiz_responses r, {$CFG->prefix}quiz_questions q WHERE r.attempt = '$attempt->id' - AND q.id = r.question")) { + AND q.id = r.question + AND q.id IN ($quiz->questions)")) { notify("Could not find any responses for that attempt!"); return false; } diff --git a/mod/quiz/report.php b/mod/quiz/report.php index 13729e320f5..24e38f1cc25 100644 --- a/mod/quiz/report.php +++ b/mod/quiz/report.php @@ -94,7 +94,7 @@ } } - if (! $questions = quiz_get_attempt_responses($attempt)) { + if (! $questions = quiz_get_attempt_responses($attempt, $quiz)) { error("Could not reconstruct quiz results for attempt $attempt->id!"); } @@ -147,13 +147,15 @@ $count->changed = 0; foreach ($attempts as $attempt) { + set_time_limit(120); + if (!$attempt->timefinish) { // Skip incomplete attempts continue; } $count->attempt++; - if (! $questions = quiz_get_attempt_responses($attempt)) { + if (! $questions = quiz_get_attempt_responses($attempt, $quiz)) { error("Could not reconstruct quiz results for attempt $attempt->id!"); }