From e5b0920e487eee897b4de77cf9fb965571e69e01 Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Thu, 4 Aug 2011 18:13:29 +0100 Subject: [PATCH] MDL-28612 Quiz statistics report does not always show the 'Actual response' column when it should --- mod/quiz/report/statistics/responseanalysis.php | 12 +++++++++--- question/type/questionbase.php | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/mod/quiz/report/statistics/responseanalysis.php b/mod/quiz/report/statistics/responseanalysis.php index 3aa9022fbb2..1c030f429c4 100644 --- a/mod/quiz/report/statistics/responseanalysis.php +++ b/mod/quiz/report/statistics/responseanalysis.php @@ -98,12 +98,18 @@ class quiz_statistics_response_analyser { /** * @return bool whether this analysis has a response class more than one - * different acutal response. + * different acutal response, or if the actual response is different from + * the model response. */ public function has_actual_responses() { foreach ($this->responseclasses as $subpartid => $partclasses) { - foreach ($partclasses as $responseclassid => $notused) { - if (count($this->responses[$subpartid][$responseclassid]) > 1) { + foreach ($partclasses as $responseclassid => $modelresponse) { + $numresponses = count($this->responses[$subpartid][$responseclassid]); + if ($numresponses > 1) { + return true; + } + $actualresponse = key($this->responses[$subpartid][$responseclassid]); + if ($numresponses == 1 && $actualresponse != $modelresponse->responseclass) { return true; } } diff --git a/question/type/questionbase.php b/question/type/questionbase.php index f45bf40d076..edd9266468f 100644 --- a/question/type/questionbase.php +++ b/question/type/questionbase.php @@ -454,7 +454,7 @@ class question_classified_response { } public static function no_response() { - return new question_classified_response(null, null, null); + return new question_classified_response(null, get_string('noresponse', 'question'), null); } }