From 0a0632cee65582daaafed4664749a3a0ee8f3c4d Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Fri, 22 Apr 2016 10:49:00 +0800 Subject: [PATCH] MDL-53638 mod_feedback: corrections during rebase: 1. make query in upgrade cross-DB 2. rebase on top of MDL-51603 --- mod/feedback/classes/responses_table.php | 19 ++++--------------- mod/feedback/db/upgradelib.php | 5 +++-- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/mod/feedback/classes/responses_table.php b/mod/feedback/classes/responses_table.php index 64070e02293..8dd9afef11e 100644 --- a/mod/feedback/classes/responses_table.php +++ b/mod/feedback/classes/responses_table.php @@ -416,22 +416,11 @@ class mod_feedback_responses_table extends table_sql { * Returns html code for displaying "Download" button if applicable. */ public function download_buttons() { - if ($this->is_downloadable() && !$this->is_downloading()) { + global $OUTPUT; - $elementid = $this->uniqueid . '_download'; - $html = '
'; - $html .= '
'; - if ($courseid = $this->feedbackstructure->get_courseid()) { - $html .= ''; - } - $html .= html_writer::tag('label', get_string('downloadresponseas', 'feedback'), - ['for' => $elementid]); - $html .= html_writer::select($this->get_download_menu(), - $this->downloadparamname, $this->defaultdownloadformat, false, ['id' => $elementid]); - $html .= html_writer::empty_tag('input', ['type' => 'submit', 'value' => get_string('download')]); - $html .= '
'; - - return $html; + if ($this->is_downloadable() && !$this->is_downloading()) { + return $OUTPUT->download_dataformat_selector(get_string('downloadas', 'table'), + $this->baseurl->out_omit_querystring(), $this->downloadparamname, $this->baseurl->params()); } else { return ''; } diff --git a/mod/feedback/db/upgradelib.php b/mod/feedback/db/upgradelib.php index fdad98cbba5..bff41339dbb 100644 --- a/mod/feedback/db/upgradelib.php +++ b/mod/feedback/db/upgradelib.php @@ -56,8 +56,9 @@ function mod_feedback_upgrade_courseid($tmp = false) { } // Part 2. Update courseid in the completed table. - $sql = "UPDATE {feedback_completed$suffix} c " + $sql = "UPDATE {feedback_completed$suffix} " . "SET courseid = (SELECT COALESCE(MIN(v.course_id), 0) " - . "FROM {feedback_value$suffix} v WHERE v.completed = c.id)"; + . "FROM {feedback_value$suffix} v " + . "WHERE v.completed = {feedback_completed$suffix}.id)"; $DB->execute($sql); } -- 2.43.0