From 45cf6fd910a99ba1f50dfaa1a1e09d0793a7d2ad Mon Sep 17 00:00:00 2001 From: jamiesensei Date: Wed, 29 Oct 2008 10:00:44 +0000 Subject: [PATCH] MDL-14209 "quiz stats report:Seperation of functionality and unit tests for calculations" Seperating out call for processing actual student responses from calculation of other grade stats as I want to unit test the grade stats calculations. --- mod/quiz/report/statistics/qstats.php | 13 ++++++++++++- mod/quiz/report/statistics/report.php | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/mod/quiz/report/statistics/qstats.php b/mod/quiz/report/statistics/qstats.php index 4f00b88223..7e6253cded 100644 --- a/mod/quiz/report/statistics/qstats.php +++ b/mod/quiz/report/statistics/qstats.php @@ -94,7 +94,6 @@ class qstats{ } else { $question =& $this->questions[$stats->questionid]; } - $this->_process_actual_responses($question, $state); } @@ -269,6 +268,18 @@ class qstats{ $this->questions[$qid]->_stats->effectiveweight = null; } } + } + + function process_responses(){ + foreach ($this->states as $state){ + if ($this->questions[$state->question]->qtype == 'random'){ + if ($realstate = question_get_real_state($state)){ + $this->_process_actual_responses($this->subquestions[$realstate->question], $realstate); + } + } else { + $this->_process_actual_responses($this->questions[$state->question], $state); + } + } $this->responses = quiz_report_unindex($this->responses); } /** diff --git a/mod/quiz/report/statistics/report.php b/mod/quiz/report/statistics/report.php index c5413f2b87..5e2322223e 100644 --- a/mod/quiz/report/statistics/report.php +++ b/mod/quiz/report/statistics/report.php @@ -565,6 +565,7 @@ class quiz_statistics_report extends quiz_default_report { $qstats = new qstats($questions, $s, $sumgradesavg); $qstats->get_records($quizid, $currentgroup, $groupstudents, $useallattempts); $qstats->process_states(); + $qstats->process_responses(); } else { $qstats = false; } -- 2.39.5