Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.
   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  namespace qbank_columnsortorder\output;
  18  
  19  use moodle_url;
  20  use plugin_renderer_base;
  21  use qbank_columnsortorder\column_manager;
  22  
  23  /**
  24   * Class renderer.
  25   * @package    qbank_columnsortorder
  26   * @copyright  2021 Catalyst IT Australia Pty Ltd
  27   * @author     Ghaly Marc-Alexandre <marc-alexandreghaly@catalyst-ca.net>
  28   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  29   */
  30  class renderer extends plugin_renderer_base {
  31      /**
  32       * Render list of question bank plugin columns.
  33       *
  34       * @return string The rendered HTML.
  35       */
  36      public function render_column_sort_ui() {
  37          $columnsortorder = new column_manager();
  38          $enabledcolumns = $columnsortorder->get_columns();
  39          $disabledcolumns = $columnsortorder->get_disabled_columns();
  40          $params = [];
  41          foreach ($enabledcolumns as $columnname) {
  42              $name = $columnname->name;
  43              $colname = get_string('qbankcolumnname', 'qbank_columnsortorder', $columnname->colname);
  44              if ($columnname->class === 'qbank_customfields\custom_field_column') {
  45                  $columnname->class .= "\\$columnname->colname";
  46              }
  47              $params['names'][] = ['name' => $name, 'colname' => $colname, 'class' => $columnname->class];
  48          }
  49          $params['disabled'] = $disabledcolumns;
  50          $params['columnsdisabled'] = (!empty($params['disabled'])) ? true : false;
  51          $urltoredirect = new moodle_url('/admin/settings.php', ['section' => 'manageqbanks']);
  52  
  53          $params['urltomanageqbanks'] = get_string('qbankgotomanageqbanks', 'qbank_columnsortorder', $urltoredirect->out());
  54  
  55          return $this->render_from_template('qbank_columnsortorder/columnsortorder', $params);
  56      }
  57  }