[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/mod/feedback/classes/ -> responses_anon_table.php (source)

   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18   * Contains class mod_feedback_responses_anon_table
  19   *
  20   * @package   mod_feedback
  21   * @copyright 2016 Marina Glancy
  22   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  defined('MOODLE_INTERNAL') || die();
  26  
  27  /**
  28   * Class mod_feedback_responses_anon_table
  29   *
  30   * @package   mod_feedback
  31   * @copyright 2016 Marina Glancy
  32   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  33   */
  34  class mod_feedback_responses_anon_table extends mod_feedback_responses_table {
  35  
  36      /** @var string */
  37      protected $showallparamname = 'ashowall';
  38  
  39      /** @var string */
  40      protected $downloadparamname = 'adownload';
  41  
  42      /**
  43       * Initialises table
  44       */
  45      public function init() {
  46  
  47          $cm = $this->feedbackstructure->get_cm();
  48          $this->uniqueid = 'feedback-showentry-anon-list-' . $cm->instance;
  49  
  50          // There potentially can be both tables with anonymouns and non-anonymous responses on
  51          // the same page (for example when feedback anonymity was changed after some people
  52          // already responded). In this case we need to distinguish tables' pagination parameters.
  53          $this->request[TABLE_VAR_PAGE] = 'apage';
  54  
  55          $tablecolumns = ['random_response'];
  56          $tableheaders = [get_string('response_nr', 'feedback')];
  57  
  58          if ($this->feedbackstructure->get_feedback()->course == SITEID && !$this->feedbackstructure->get_courseid()) {
  59              $tablecolumns[] = 'courseid';
  60              $tableheaders[] = get_string('course');
  61          }
  62  
  63          $this->define_columns($tablecolumns);
  64          $this->define_headers($tableheaders);
  65  
  66          $this->sortable(true, 'random_response');
  67          $this->collapsible(true);
  68          $this->set_attribute('id', 'showentryanontable');
  69  
  70          $params = ['instance' => $cm->instance,
  71              'anon' => FEEDBACK_ANONYMOUS_YES,
  72              'courseid' => $this->feedbackstructure->get_courseid()];
  73  
  74          $fields = 'c.id, c.random_response, c.courseid';
  75          $from = '{feedback_completed} c';
  76          $where = 'c.anonymous_response = :anon AND c.feedback = :instance';
  77          if ($this->feedbackstructure->get_courseid()) {
  78              $where .= ' AND c.courseid = :courseid';
  79          }
  80  
  81          $group = groups_get_activity_group($this->feedbackstructure->get_cm(), true);
  82          if ($group) {
  83              $where .= ' AND c.userid IN (SELECT g.userid FROM {groups_members} g WHERE g.groupid = :group)';
  84              $params['group'] = $group;
  85          }
  86  
  87          $this->set_sql($fields, $from, $where, $params);
  88          $this->set_count_sql("SELECT COUNT(c.id) FROM $from WHERE $where", $params);
  89      }
  90  
  91      /**
  92       * Returns a link for viewing a single response
  93       * @param stdClass $row
  94       * @return \moodle_url
  95       */
  96      protected function get_link_single_entry($row) {
  97          return new moodle_url($this->baseurl, ['showcompleted' => $row->id]);
  98      }
  99  
 100      /**
 101       * Prepares column reponse for display
 102       * @param stdClass $row
 103       * @return string
 104       */
 105      public function col_random_response($row) {
 106          if ($this->is_downloading()) {
 107              return $row->random_response;
 108          } else {
 109              return html_writer::link($this->get_link_single_entry($row),
 110                      get_string('response_nr', 'feedback').': '. $row->random_response);
 111          }
 112      }
 113  }


Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1