Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

   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 renderers for the bulk activity completion stuff.
  19   *
  20   * @package core_course
  21   * @copyright 2017 Adrian Greeve
  22   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  23   */
  24  
  25  defined('MOODLE_INTERNAL') || die;
  26  
  27  require_once($CFG->dirroot.'/course/renderer.php');
  28  
  29  /**
  30   * Main renderer for the bulk activity completion stuff.
  31   *
  32   * @package core_course
  33   * @copyright 2017 Adrian Greeve
  34   * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  35   */
  36  class core_course_bulk_activity_completion_renderer extends plugin_renderer_base {
  37  
  38      /**
  39       * Render the navigation tabs for the completion page.
  40       *
  41       * @param int|stdClass $courseorid the course object or id.
  42       * @param String $page the tab to focus.
  43       * @return string html
  44       */
  45      public function navigation($courseorid, $page) {
  46          $tabs = core_completion\manager::get_available_completion_tabs($courseorid);
  47          if (count($tabs) > 1) {
  48              return $this->tabtree($tabs, $page);
  49          } else {
  50              return '';
  51          }
  52      }
  53  
  54      /**
  55       * Render the bulk completion tab.
  56       *
  57       * @param Array|stdClass $data the context data to pass to the template.
  58       * @return bool|string
  59       */
  60      public function bulkcompletion($data) {
  61          return parent::render_from_template('core_course/bulkactivitycompletion', $data);
  62      }
  63  
  64      /**
  65       * Render the default completion tab.
  66       *
  67       * @param Array|stdClass $data the context data to pass to the template.
  68       * @return bool|string
  69       */
  70      public function defaultcompletion($data) {
  71          return parent::render_from_template('core_course/defaultactivitycompletion', $data);
  72      }
  73  
  74      /**
  75       * Renders the form for bulk editing activities completion
  76       *
  77       * @param moodleform $form
  78       * @param array $activities
  79       * @return string
  80       */
  81      public function edit_bulk_completion($form, $activities) {
  82          ob_start();
  83          $form->display();
  84          $formhtml = ob_get_contents();
  85          ob_end_clean();
  86  
  87          $data = (object)[
  88              'form' => $formhtml,
  89              'activities' => array_values($activities),
  90              'activitiescount' => count($activities),
  91          ];
  92          return parent::render_from_template('core_course/editbulkactivitycompletion', $data);
  93      }
  94  
  95      /**
  96       * Renders the form for editing default completion
  97       *
  98       * @param moodleform $form
  99       * @param array $modules
 100       * @return string
 101       */
 102      public function edit_default_completion($form, $modules) {
 103          ob_start();
 104          $form->display();
 105          $formhtml = ob_get_contents();
 106          ob_end_clean();
 107  
 108          $data = (object)[
 109              'form' => $formhtml,
 110              'modules' => array_values($modules),
 111              'modulescount' => count($modules),
 112          ];
 113          return parent::render_from_template('core_course/editdefaultcompletion', $data);
 114      }
 115  }