Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 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  
   3  // This file is part of Moodle - http://moodle.org/
   4  //
   5  // Moodle is free software: you can redistribute it and/or modify
   6  // it under the terms of the GNU General Public License as published by
   7  // the Free Software Foundation, either version 3 of the License, or
   8  // (at your option) any later version.
   9  //
  10  // Moodle is distributed in the hope that it will be useful,
  11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13  // GNU General Public License for more details.
  14  //
  15  // You should have received a copy of the GNU General Public License
  16  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  17  
  18  /**
  19   * @package   mod_workshop
  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/workshop/backup/moodle2/restore_workshop_stepslib.php'); // Because it exists (must)
  27  
  28  /**
  29   * workshop restore task that provides all the settings and steps to perform one
  30   * complete restore of the activity
  31   */
  32  class restore_workshop_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          // Choice only has one structure step
  46          $this->add_step(new restore_workshop_activity_structure_step('workshop_structure', 'workshop.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('workshop',
  57                            array('intro', 'instructauthors', 'instructreviewers', 'conclusion'), 'workshop');
  58          $contents[] = new restore_decode_content('workshop_submissions',
  59                            array('content', 'feedbackauthor'), 'workshop_submission');
  60          $contents[] = new restore_decode_content('workshop_assessments',
  61                            array('feedbackauthor', 'feedbackreviewer'), 'workshop_assessment');
  62  
  63          return $contents;
  64      }
  65  
  66      /**
  67       * Define the decoding rules for links belonging
  68       * to the activity to be executed by the link decoder
  69       */
  70      static public function define_decode_rules() {
  71          $rules = array();
  72  
  73          $rules[] = new restore_decode_rule('WORKSHOPVIEWBYID', '/mod/workshop/view.php?id=$1', 'course_module');
  74          $rules[] = new restore_decode_rule('WORKSHOPINDEX', '/mod/workshop/index.php?id=$1', 'course');
  75  
  76          return $rules;
  77  
  78      }
  79  
  80      /**
  81       * Define the restore log rules that will be applied
  82       * by the {@link restore_logs_processor} when restoring
  83       * workshop logs. It must return one array
  84       * of {@link restore_log_rule} objects
  85       */
  86      static public function define_restore_log_rules() {
  87          $rules = array();
  88  
  89          $rules[] = new restore_log_rule('workshop', 'add', 'view.php?id={course_module}', '{workshop}');
  90          $rules[] = new restore_log_rule('workshop', 'update', 'view.php?id={course_module}', '{workshop}');
  91          $rules[] = new restore_log_rule('workshop', 'view', 'view.php?id={course_module}', '{workshop}');
  92  
  93          $rules[] = new restore_log_rule('workshop', 'add assessment',
  94                         'assessment.php?asid={workshop_assessment}', '{workshop_submission}');
  95          $rules[] = new restore_log_rule('workshop', 'update assessment',
  96                         'assessment.php?asid={workshop_assessment}', '{workshop_submission}');
  97  
  98          $rules[] = new restore_log_rule('workshop', 'add reference assessment',
  99                         'exassessment.php?asid={workshop_referenceassessment}', '{workshop_examplesubmission}');
 100          $rules[] = new restore_log_rule('workshop', 'update reference assessment',
 101                         'exassessment.php?asid={workshop_referenceassessment}', '{workshop_examplesubmission}');
 102  
 103          $rules[] = new restore_log_rule('workshop', 'add example assessment',
 104                         'exassessment.php?asid={workshop_exampleassessment}', '{workshop_examplesubmission}');
 105          $rules[] = new restore_log_rule('workshop', 'update example assessment',
 106                         'exassessment.php?asid={workshop_exampleassessment}', '{workshop_examplesubmission}');
 107  
 108          $rules[] = new restore_log_rule('workshop', 'view submission',
 109                         'submission.php?cmid={course_module}&id={workshop_submission}', '{workshop_submission}');
 110          $rules[] = new restore_log_rule('workshop', 'add submission',
 111                         'submission.php?cmid={course_module}&id={workshop_submission}', '{workshop_submission}');
 112          $rules[] = new restore_log_rule('workshop', 'update submission',
 113                         'submission.php?cmid={course_module}&id={workshop_submission}', '{workshop_submission}');
 114  
 115          $rules[] = new restore_log_rule('workshop', 'view example',
 116                         'exsubmission.php?cmid={course_module}&id={workshop_examplesubmission}', '{workshop_examplesubmission}');
 117          $rules[] = new restore_log_rule('workshop', 'add example',
 118                         'exsubmission.php?cmid={course_module}&id={workshop_examplesubmission}', '{workshop_examplesubmission}');
 119          $rules[] = new restore_log_rule('workshop', 'update example',
 120                         'exsubmission.php?cmid={course_module}&id={workshop_examplesubmission}', '{workshop_examplesubmission}');
 121  
 122          $rules[] = new restore_log_rule('workshop', 'update aggregate grades', 'view.php?id={course_module}', '{workshop}');
 123          $rules[] = new restore_log_rule('workshop', 'update switch phase', 'view.php?id={course_module}', '[phase]');
 124          $rules[] = new restore_log_rule('workshop', 'update clear aggregated grades', 'view.php?id={course_module}', '{workshop}');
 125          $rules[] = new restore_log_rule('workshop', 'update clear assessments', 'view.php?id={course_module}', '{workshop}');
 126  
 127          return $rules;
 128      }
 129  
 130      /**
 131       * Define the restore log rules that will be applied
 132       * by the {@link restore_logs_processor} when restoring
 133       * course logs. It must return one array
 134       * of {@link restore_log_rule} objects
 135       *
 136       * Note this rules are applied when restoring course logs
 137       * by the restore final task, but are defined here at
 138       * activity level. All them are rules not linked to any module instance (cmid = 0)
 139       */
 140      static public function define_restore_log_rules_for_course() {
 141          $rules = array();
 142  
 143          $rules[] = new restore_log_rule('workshop', 'view all', 'index.php?id={course}', null);
 144  
 145          return $rules;
 146      }
 147  }