MDL-53638 mod_feedback: corrections during rebase:
authorMarina Glancy <marina@moodle.com>
Fri, 22 Apr 2016 02:49:00 +0000 (10:49 +0800)
committerMarina Glancy <marina@moodle.com>
Wed, 27 Apr 2016 08:04:44 +0000 (16:04 +0800)
1. make query in upgrade cross-DB
2. rebase on top of MDL-51603

mod/feedback/classes/responses_table.php
mod/feedback/db/upgradelib.php

index 64070e0..8dd9afe 100644 (file)
@@ -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 = '<div class="mdl-align">';
-            $html .= '<form action="'. $this->baseurl .'" method="post" class="form-inline">';
-            if ($courseid = $this->feedbackstructure->get_courseid()) {
-                $html .= '<input type="hidden" name="courseid" value="' . s($courseid) . '">';
-            }
-            $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 .= '</form></div>';
-
-            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 '';
         }
index fdad98c..bff4133 100644 (file)
@@ -56,8 +56,9 @@ function mod_feedback_upgrade_courseid($tmp = false) {
     }
 
     // Part 2. Update courseid in the completed table.
-    $sql = "UPDATE {feedback_completed$suffix} "
+    $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);
 }