From: jamiesensei Date: Mon, 21 Jul 2008 10:27:47 +0000 (+0000) Subject: MDL-15729 "detailled responses report not showing responses" X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=3e71541fde61ec786845376814bf38281066bca6;p=moodle.git MDL-15729 "detailled responses report not showing responses" --- diff --git a/mod/quiz/report/responses/report.php b/mod/quiz/report/responses/report.php index ea8b062355..a2bd6f974a 100644 --- a/mod/quiz/report/responses/report.php +++ b/mod/quiz/report/responses/report.php @@ -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)); diff --git a/mod/quiz/report/responses/responses_table.php b/mod/quiz/report/responses/responses_table.php index f2576ce755..ec0ba60db0 100644 --- a/mod/quiz/report/responses/responses_table.php +++ b/mod/quiz/report/responses/responses_table.php @@ -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 ''.format_text($response, FORMAT_MOODLE, $format_options).''; } else { - return format_text($response, FORMAT_MOODLE, $format_options); + return $response; } } else { return NULL;