From 452351550bc335c4f05cbb2a7459ae7c37fe62ea Mon Sep 17 00:00:00 2001 From: jamiesensei Date: Fri, 19 Sep 2008 10:12:54 +0000 Subject: [PATCH] MDL-16567 "Quiz statistics report does not work when the quiz contains descriptions" slightly more elegant and efficient solution to issue. --- mod/quiz/report/statistics/qstats.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/mod/quiz/report/statistics/qstats.php b/mod/quiz/report/statistics/qstats.php index 07a00c5495..53f9ff3d19 100644 --- a/mod/quiz/report/statistics/qstats.php +++ b/mod/quiz/report/statistics/qstats.php @@ -38,6 +38,7 @@ class qstats{ } function get_records($quizid, $currentgroup, $groupstudents, $allattempts){ global $DB; + list($qsql, $qparams) = $DB->get_in_or_equal(array_keys($this->questions), SQL_PARAMS_NAMED, 'q0000'); list($fromqa, $whereqa, $qaparams) = quiz_report_attempts_sql($quizid, $currentgroup, $groupstudents, $allattempts); $sql = 'SELECT qs.id, ' . 'qs.question, ' . @@ -49,18 +50,13 @@ class qstats{ '{question_states} qs, '. $fromqa.' '. 'WHERE ' .$whereqa. + 'AND qs.question '.$qsql.' '. 'AND qns.attemptid = qa.uniqueid '. 'AND qns.newgraded = qs.id'; - $this->states = $DB->get_records_sql($sql, $qaparams); + $this->states = $DB->get_records_sql($sql, $qaparams + $qparams); if ($this->states === false){ print_error('errorstatisticsquestions', 'quiz_statistics'); } - // Nasty hack fix for MDL-16567 - TODO a proper fix. - foreach ($this->states as $id => $state) { - if (!isset($this->questions[$state->question])) { - unset($this->states[$id]); - } - } } function _initial_states_walker($state, &$stats, $positionstat = true){ -- 2.39.5