Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is 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  /**
  18   * @package    mod_scorm
  19   * @subpackage backup-moodle2
  20   * @copyright  2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
  21   * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22   */
  23  
  24  defined('MOODLE_INTERNAL') || die();
  25  
  26  require_once($CFG->dirroot . '/mod/scorm/backup/moodle2/restore_scorm_stepslib.php'); // Because it exists (must)
  27  
  28  /**
  29   * scorm restore task that provides all the settings and steps to perform one
  30   * complete restore of the activity
  31   */
  32  class restore_scorm_activity_task extends restore_activity_task {
  33  
  34      /**
  35       * Define (add) particular settings this activity can have
  36       */
  37      protected function define_my_settings() {
  38          // No particular settings for this activity
  39      }
  40  
  41      /**
  42       * Define (add) particular steps this activity can have
  43       */
  44      protected function define_my_steps() {
  45          // scorm only has one structure step
  46          $this->add_step(new restore_scorm_activity_structure_step('scorm_structure', 'scorm.xml'));
  47      }
  48  
  49      /**
  50       * Define the contents in the activity that must be
  51       * processed by the link decoder
  52       */
  53      static public function define_decode_contents() {
  54          $contents = array();
  55  
  56          $contents[] = new restore_decode_content('scorm', array('intro'), 'scorm');
  57  
  58          return $contents;
  59      }
  60  
  61      /**
  62       * Define the decoding rules for links belonging
  63       * to the activity to be executed by the link decoder
  64       */
  65      static public function define_decode_rules() {
  66          $rules = array();
  67  
  68          $rules[] = new restore_decode_rule('SCORMVIEWBYID', '/mod/scorm/view.php?id=$1', 'course_module');
  69          $rules[] = new restore_decode_rule('SCORMINDEX', '/mod/scorm/index.php?id=$1', 'course');
  70  
  71          return $rules;
  72  
  73      }
  74  
  75      /**
  76       * Define the restore log rules that will be applied
  77       * by the {@link restore_logs_processor} when restoring
  78       * scorm logs. It must return one array
  79       * of {@link restore_log_rule} objects
  80       */
  81      static public function define_restore_log_rules() {
  82          $rules = array();
  83  
  84          $rules[] = new restore_log_rule('scorm', 'add', 'view.php?id={course_module}', '{scorm}');
  85          $rules[] = new restore_log_rule('scorm', 'update', 'view.php?id={course_module}', '{scorm}');
  86          $rules[] = new restore_log_rule('scorm', 'view', 'player.php?cm={course_module}&scoid={scorm_sco}', '{scorm}');
  87          $rules[] = new restore_log_rule('scorm', 'pre-view', 'view.php?id={course_module}', '{scorm}');
  88          $rules[] = new restore_log_rule('scorm', 'report', 'report.php?id={course_module}', '{scorm}');
  89          $rules[] = new restore_log_rule('scorm', 'launch', 'view.php?id={course_module}', '[result]');
  90          $rules[] = new restore_log_rule('scorm', 'delete attempts', 'report.php?id={course_module}', '[oldattempts]');
  91  
  92          return $rules;
  93      }
  94  
  95      /**
  96       * Define the restore log rules that will be applied
  97       * by the {@link restore_logs_processor} when restoring
  98       * course logs. It must return one array
  99       * of {@link restore_log_rule} objects
 100       *
 101       * Note this rules are applied when restoring course logs
 102       * by the restore final task, but are defined here at
 103       * activity level. All them are rules not linked to any module instance (cmid = 0)
 104       */
 105      static public function define_restore_log_rules_for_course() {
 106          $rules = array();
 107  
 108          $rules[] = new restore_log_rule('scorm', 'view all', 'index.php?id={course}', null);
 109  
 110          return $rules;
 111      }
 112  }