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.
   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   * Define all the backup steps that will be used by the backup_assign_activity_task
  19   *
  20   * @package   mod_assign
  21   * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
  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 . '/mod/assign/backup/moodle2/restore_assign_stepslib.php');
  28  
  29  /**
  30   * assign restore task that provides all the settings and steps to perform one complete restore of the activity
  31   *
  32   * @package   mod_assign
  33   * @copyright 2012 NetSpot {@link http://www.netspot.com.au}
  34   * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  35   */
  36  class restore_assign_activity_task extends restore_activity_task {
  37  
  38      /**
  39       * Define (add) particular settings this activity can have.
  40       */
  41      protected function define_my_settings() {
  42          // No particular settings for this activity.
  43      }
  44  
  45      /**
  46       * Define (add) particular steps this activity can have.
  47       */
  48      protected function define_my_steps() {
  49          // Assignment only has one structure step.
  50          $this->add_step(new restore_assign_activity_structure_step('assign_structure', 'assign.xml'));
  51      }
  52  
  53      /**
  54       * Define the contents in the activity that must be
  55       * processed by the link decoder.
  56       *
  57       * @return array
  58       */
  59      static public function define_decode_contents() {
  60          $contents = array();
  61  
  62          $contents[] = new restore_decode_content('assign', array('intro'), 'assign');
  63  
  64          return $contents;
  65      }
  66  
  67      /**
  68       * Define the decoding rules for links belonging
  69       * to the activity to be executed by the link decoder.
  70       *
  71       * @return array of restore_decode_rule
  72       */
  73      static public function define_decode_rules() {
  74          $rules = array();
  75  
  76          $rules[] = new restore_decode_rule('ASSIGNVIEWBYID',
  77                                             '/mod/assign/view.php?id=$1',
  78                                             'course_module');
  79          $rules[] = new restore_decode_rule('ASSIGNINDEX',
  80                                             '/mod/assign/index.php?id=$1',
  81                                             'course_module');
  82  
  83          return $rules;
  84  
  85      }
  86  
  87      /**
  88       * Define the restore log rules that will be applied
  89       * by the {@link restore_logs_processor} when restoring
  90       * assign logs. It must return one array
  91       * of {@link restore_log_rule} objects.
  92       *
  93       * @return array of restore_log_rule
  94       */
  95      static public function define_restore_log_rules() {
  96          $rules = array();
  97  
  98          $rules[] = new restore_log_rule('assign', 'add', 'view.php?id={course_module}', '{assign}');
  99          $rules[] = new restore_log_rule('assign', 'update', 'view.php?id={course_module}', '{assign}');
 100          $rules[] = new restore_log_rule('assign', 'view', 'view.php?id={course_module}', '{assign}');
 101  
 102          return $rules;
 103      }
 104  
 105      /**
 106       * Define the restore log rules that will be applied
 107       * by the {@link restore_logs_processor} when restoring
 108       * course logs. It must return one array
 109       * of {@link restore_log_rule} objects
 110       *
 111       * Note this rules are applied when restoring course logs
 112       * by the restore final task, but are defined here at
 113       * activity level. All them are rules not linked to any module instance (cmid = 0)
 114       *
 115       * @return array
 116       */
 117      static public function define_restore_log_rules_for_course() {
 118          $rules = array();
 119  
 120          return $rules;
 121      }
 122  
 123      /**
 124       * Given a comment area, return the itemname that contains the itemid mappings.
 125       *
 126       * @param string $commentarea
 127       * @return string
 128       */
 129      public function get_comment_mapping_itemname($commentarea) {
 130          switch ($commentarea) {
 131              case 'submission_comments':
 132                  $itemname = 'submission';
 133                  break;
 134              default:
 135                  $itemname = parent::get_comment_mapping_itemname($commentarea);
 136                  break;
 137          }
 138  
 139          return $itemname;
 140      }
 141  }