]> git.mjollnir.org Git - moodle.git/commitdiff
Fix for bug 5379: Item analysis report should not have a hard coded list of question...
authortjhunt <tjhunt>
Wed, 31 May 2006 15:58:39 +0000 (15:58 +0000)
committertjhunt <tjhunt>
Wed, 31 May 2006 15:58:39 +0000 (15:58 +0000)
Please test this if you have a moodle install with some unusual question types. Thanks.

Merged from 1.6stable.

mod/quiz/report/analysis/report.php
question/type/questiontype.php

index af63a30a69ed402ba8ef5fcabd0cff979d3f1d5e..e82d5e679b564321aa46526f094ec5e1ddf4b91b 100644 (file)
@@ -111,7 +111,6 @@ class quiz_report extends quiz_default_report {
         $questionarray = array_unique(explode(",",$questionlist));
         $questionlist = implode(",", $questionarray);
         unset($questionarray);
-        $accepted_qtypes = array(SHORTANSWER, TRUEFALSE, MULTICHOICE, MATCH, NUMERICAL, CALCULATED);        
 
         foreach ($attempts as $attempt) {
             switch ($attemptselection) {
@@ -157,10 +156,10 @@ class quiz_report extends quiz_default_report {
                     continue;
                 }
                 $qtype = ($quizquestions[$i]->qtype=='random') ? $states[$i]->options->question->qtype : $quizquestions[$i]->qtype;
-                if (!in_array ($qtype, $accepted_qtypes)){
+                $q = get_question_responses($quizquestions[$i], $states[$i]);
+                if (empty($q)){
                     continue;
                 }                
-                $q = get_question_responses($quizquestions[$i], $states[$i]);
                 $qid = $q->id;
                 if (!isset($questions[$qid])) {
                     $questions[$qid]['id'] = $qid;
index 5c0d15d6c7c3f24fbcab3cf41115129e9f2ebb9e..df5cdbdd7e92ff331e556b47184314c3a192c348 100644 (file)
@@ -353,20 +353,21 @@ class default_questiontype {
     */
     // ULPGC ecastro
     function get_all_responses(&$question, &$state) {
-        unset($answers);
-        if (is_array($question->options->answers)) {
+        if (isset($question->options->answers) && is_array($question->options->answers)) {
+            $answers = array();
             foreach ($question->options->answers as $aid=>$answer) {
-                unset ($r);
+                $r = new stdClass;
                 $r->answer = $answer->answer;
                 $r->credit = $answer->fraction;
                 $answers[$aid] = $r;
             }
+            $result = new stdClass;
+            $result->id = $question->id;
+            $result->responses = $answers;
+            return $result;
         } else {
-            $answers[]="error"; // just for debugging, eliminate
+            return null;
         }
-        $result->id = $question->id;
-        $result->responses = $answers;
-        return $result;
     }
 
     /**