]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-15729 "detailled responses report not showing responses"
authorjamiesensei <jamiesensei>
Mon, 21 Jul 2008 10:27:47 +0000 (10:27 +0000)
committerjamiesensei <jamiesensei>
Mon, 21 Jul 2008 10:27:47 +0000 (10:27 +0000)
mod/quiz/report/responses/report.php
mod/quiz/report/responses/responses_table.php

index ea8b062355b5933f30bdcbfc8585b02fa1b65909..a2bd6f974a967da3e1d4b949a8c96013814e2391 100644 (file)
@@ -177,7 +177,7 @@ class quiz_responses_report extends quiz_default_report {
     
     
             // Construct the SQL
-            $fields = $DB->sql_concat('u.id', '\'#\'', 'COALESCE(qa.attempt, \'0\')').' AS uniqueid, ';
+            $fields = $DB->sql_concat('u.id', '\'#\'', 'COALESCE(qa.attempt, \'0\')').' AS concattedid, ';
             if ($qmsubselect) {
                 $fields .=
                     "(CASE " .
@@ -186,7 +186,7 @@ class quiz_responses_report extends quiz_default_report {
                     "END) AS gradedattempt, ";
             }
             
-            $fields .='qa.uniqueid AS attemptuniqueid, qa.id AS attempt, u.id AS userid, u.idnumber, u.firstname,'.
+            $fields .='qa.uniqueid, qa.id AS attempt, u.id AS userid, u.idnumber, u.firstname,'.
                 ' u.lastname, u.institution, u.department, u.email, u.picture, u.imagealt, '.
                 'qa.sumgrades, qa.timefinish, qa.timestart, qa.timefinish - qa.timestart AS duration, ' .
                 'qa.layout ';
@@ -303,7 +303,7 @@ class quiz_responses_report extends quiz_default_report {
     
             $table->define_columns($columns);
             $table->define_headers($headers);
-            $table->sortable(true, 'uniqueid');
+            $table->sortable(true, 'concattedid');
         
             // Set up the table
             $table->define_baseurl($reporturl->out(false, $displayoptions));
index f2576ce755487e8eb63146d6fadd8ec2fe489d3d..ec0ba60db03cf129618b638e4d99641ea665a712 100644 (file)
@@ -20,21 +20,10 @@ class quiz_report_responses_table extends table_sql {
         $this->displayoptions = $displayoptions;
     }
     function build_table(){
-        global $CFG, $DB;
         if ($this->rawdata) {
             // Define some things we need later to process raw data from db.
             $this->strtimeformat = get_string('strftimedatetime');
             parent::build_table();
-            //end of adding data from attempts data to table / download
-            //now add averages at bottom of table :
-            $params = array($this->quiz->id);
-
-            $this->add_separator();
-            if ($this->is_downloading()){
-                $namekey = 'lastname';
-            } else {
-                $namekey = 'fullname';
-            }
         }
     }
 
@@ -149,26 +138,17 @@ class quiz_report_responses_table extends table_sql {
         }
     }
     function other_cols($colname, $attempt){
-        static $gradedstatesbyattempt = null, $states =array();
-        if ($gradedstatesbyattempt === null){
-            //get all the attempt ids we want to display on this page
-            //or to export for download.
-            $attemptids = array();
-            foreach ($this->rawdata as $attempt){
-                if ($attempt->attemptuniqueid > 0){  
-                    $attemptids[] = $attempt->attemptuniqueid;
-                    $states[$attempt->attemptuniqueid] = get_question_states($this->questions, $this->quiz, $attempt);
-                }
-            }
-            $gradedstatesbyattempt = quiz_get_newgraded_states($attemptids, true, 'qs.id, qs.grade, qs.event, qs.question, qs.attempt');
-        }
+        static $states =array();
         if (preg_match('/^qsanswer([0-9]+)$/', $colname, $matches)){
+            if ($attempt->uniqueid > 0 && !isset($states[$attempt->uniqueid])){
+                $states[$attempt->uniqueid] = get_question_states($this->questions, $this->quiz, $attempt);
+            }
+            $statesforattempt = $states[$attempt->uniqueid];
             $questionid = $matches[1];
             $question = $this->questions[$questionid];
-            $stateforqinattempt = $gradedstatesbyattempt[$attempt->attemptuniqueid][$questionid];
-            $responses =  get_question_actual_response($question, $states[$attempt->attemptuniqueid][$questionid]);
+            $responses =  get_question_actual_response($question, $statesforattempt[$questionid]);
             $response = (!empty($responses)? implode(', ',$responses) : '-');
-            $grade = $stateforqinattempt->grade;
+            $grade = $statesforattempt[$questionid]->last_graded->grade;
             if (!$this->is_downloading()) {
                 $format_options = new stdClass;
                 $format_options->para = false;
@@ -183,7 +163,7 @@ class quiz_report_responses_table extends table_sql {
                 }          
                 return '<span class="'.$qclass.'">'.format_text($response, FORMAT_MOODLE, $format_options).'</span>';
             } else {
-                return format_text($response, FORMAT_MOODLE, $format_options);
+                return $response;
             }
         } else {
             return NULL;