From 45722f41884d32f717eb8ac4c54a00ac7421faef Mon Sep 17 00:00:00 2001 From: Tim Hunt Date: Wed, 23 Oct 2019 22:27:05 +0100 Subject: [PATCH] MDL-67002 quiz reports: fix sorting on Oracle in the responses report --- mod/quiz/report/attemptsreport_table.php | 5 ++++ .../report/responses/last_responses_table.php | 27 +++---------------- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/mod/quiz/report/attemptsreport_table.php b/mod/quiz/report/attemptsreport_table.php index c0b798acb78..e4ae349f5e0 100644 --- a/mod/quiz/report/attemptsreport_table.php +++ b/mod/quiz/report/attemptsreport_table.php @@ -385,8 +385,13 @@ abstract class quiz_attempts_report_table extends table_sql { /** * Get any fields that might be needed when sorting on date for a particular slot. + * + * Note: these values are only used for sorting. The values displayed are taken + * from $this->lateststeps loaded in load_extra_data(). + * * @param int $slot the slot for the column we want. * @param string $alias the table alias for latest state information relating to that slot. + * @return string definitions of extra fields to add to the SELECT list of the query. */ protected function get_required_latest_state_fields($slot, $alias) { return ''; diff --git a/mod/quiz/report/responses/last_responses_table.php b/mod/quiz/report/responses/last_responses_table.php index 8ce209b1b71..831add7c1a5 100644 --- a/mod/quiz/report/responses/last_responses_table.php +++ b/mod/quiz/report/responses/last_responses_table.php @@ -114,14 +114,7 @@ class quiz_last_responses_table extends quiz_attempts_report_table { if (!isset($this->lateststeps[$attempt->usageid][$slot])) { return '-'; } - $stepdata = $this->lateststeps[$attempt->usageid][$slot]; - - if (property_exists($stepdata, $field . 'full')) { - $value = $stepdata->{$field . 'full'}; - } else { - $value = $stepdata->$field; - } - return $value; + return $this->lateststeps[$attempt->usageid][$slot]->$field; } public function other_cols($colname, $attempt) { @@ -158,20 +151,8 @@ class quiz_last_responses_table extends quiz_attempts_report_table { */ protected function get_required_latest_state_fields($slot, $alias) { global $DB; - $sortableresponse = $DB->sql_order_by_text("{$alias}.questionsummary"); - if ($sortableresponse === "{$alias}.questionsummary") { - // Can just order by text columns. No complexity needed. - return "{$alias}.questionsummary AS question{$slot}, - {$alias}.rightanswer AS right{$slot}, - {$alias}.responsesummary AS response{$slot}"; - } else { - // Work-around required. - return $DB->sql_order_by_text("{$alias}.questionsummary") . " AS question{$slot}, - {$alias}.questionsummary AS question{$slot}full, - " . $DB->sql_order_by_text("{$alias}.rightanswer") . " AS right{$slot}, - {$alias}.rightanswer AS right{$slot}full, - " . $DB->sql_order_by_text("{$alias}.responsesummary") . " AS response{$slot}, - {$alias}.responsesummary AS response{$slot}full"; - } + return $DB->sql_order_by_text("{$alias}.questionsummary") . " AS question{$slot}, + " . $DB->sql_order_by_text("{$alias}.rightanswer") . " AS right{$slot}, + " . $DB->sql_order_by_text("{$alias}.responsesummary") . " AS response{$slot}"; } }