From 312dce0ebc6a2e1ab988729227f2043fbb7e1226 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Sun, 31 May 2015 13:34:06 +0100 Subject: [PATCH] MDL-50341 quiz statistics: non-attempted questions broke first-try stats For behaviours that allow multiple tries, and when the teacher had chosen to generate statistics for the first tries only, and when a student had not attempted one question, then an error occurred. It should have been classified as no response. --- question/behaviour/behaviourbase.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/question/behaviour/behaviourbase.php b/question/behaviour/behaviourbase.php index e89ae69d710..8daaab0a200 100644 --- a/question/behaviour/behaviourbase.php +++ b/question/behaviour/behaviourbase.php @@ -308,7 +308,12 @@ abstract class question_behaviour { } else { $stepswithsubmit = $this->qa->get_steps_with_submitted_response_iterator(); if ($whichtries == question_attempt::FIRST_TRY) { - return $this->question->classify_response($stepswithsubmit[1]->get_qt_data()); + $firsttry = $stepswithsubmit[1]; + if ($firsttry) { + return $this->question->classify_response($firsttry->get_qt_data()); + } else { + return $this->question->classify_response(array()); + } } else { $classifiedresponses = array(); foreach ($stepswithsubmit as $submittedresponseno => $step) {