Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.
   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   * @package    mod_scorm
  18   * @author     Ankit Kumar Agarwal
  19   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  20   */
  21  
  22  namespace mod_scorm;
  23  
  24  /*******************************************************************/
  25  // Default class for Scorm plugins
  26  //
  27  // Doesn't do anything on it's own -- it needs to be extended.
  28  // This class displays scorm reports. Because it is called from
  29  // within /mod/scorm/report.php you can assume that the page header
  30  // and footer are taken care of.
  31  //
  32  // This file can refer to itself as report.php to pass variables
  33  // to itself - all these will also be globally available.
  34  /*******************************************************************/
  35  
  36  defined('MOODLE_INTERNAL') || die();
  37  
  38  class report {
  39      /**
  40       * displays the full report
  41       * @param stdClass $scorm full SCORM object
  42       * @param stdClass $cm - full course_module object
  43       * @param stdClass $course - full course object
  44       * @param string $download - type of download being requested
  45       */
  46      public function display($scorm, $cm, $course, $download) {
  47          // This function just displays the report.
  48          return true;
  49      }
  50      /**
  51       * allows the plugin to control who can see this plugin.
  52       * @return boolean
  53       */
  54      public function canview($contextmodule) {
  55          return true;
  56      }
  57  
  58      /**
  59       * Generates a checkbox that can be added to header tables to select/deselect all quiz attempts.
  60       *
  61       * @return string
  62       */
  63      protected function generate_master_checkbox(): string {
  64          global $OUTPUT;
  65  
  66          // Build the select/deselect all control.
  67          $selectalltext = get_string('selectall', 'scorm');
  68          $deselectalltext = get_string('selectnone', 'scorm');
  69          $mastercheckbox = new \core\output\checkbox_toggleall('scorm-attempts', true, [
  70              'name' => 'scorm-selectall-attempts',
  71              'value' => 1,
  72              'label' => $selectalltext,
  73              'labelclasses' => 'accesshide',
  74              'selectall' => $selectalltext,
  75              'deselectall' => $deselectalltext,
  76          ]);
  77  
  78          return $OUTPUT->render($mastercheckbox);
  79      }
  80  
  81      /**
  82       * Generates a checkbox for a row in the attempts table.
  83       *
  84       * @param string $name The checkbox's name attribute.
  85       * @param string $value The checkbox's value.
  86       * @return string
  87       */
  88      protected function generate_row_checkbox(string $name, string $value): string {
  89          global $OUTPUT;
  90  
  91          $checkbox = new \core\output\checkbox_toggleall('scorm-attempts', false, [
  92              'name' => $name,
  93              'value' => $value,
  94          ]);
  95          return $OUTPUT->render($checkbox);
  96      }
  97  
  98      /**
  99       * Generates an action button that deletes the selected attempts.
 100       */
 101      protected function generate_delete_selected_button(): string {
 102          $deleteselectedparams = array(
 103              'type' => 'submit',
 104              'value' => get_string('deleteselected', 'scorm'),
 105              'class' => 'btn btn-secondary',
 106              'data-action' => 'toggle',
 107              'data-togglegroup' => 'scorm-attempts',
 108              'data-toggle' => 'action',
 109              'disabled' => true
 110          );
 111          return \html_writer::empty_tag('input', $deleteselectedparams);
 112      }
 113  }