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   * @package    mod_feedback
  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/feedback/backup/moodle2/restore_feedback_stepslib.php'); // Because it exists (must)
  27  
  28  /**
  29   * feedback restore task that provides all the settings and steps to perform one
  30   * complete restore of the activity
  31   */
  32  class restore_feedback_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          // feedback only has one structure step
  46          $this->add_step(new restore_feedback_activity_structure_step('feedback_structure', 'feedback.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('feedback', array('intro', 'site_after_submit', 'page_after_submit'), 'feedback');
  57          $contents[] = new restore_decode_content('feedback_item', array('presentation'), 'feedback_item');
  58          $contents[] = new restore_decode_content('feedback_value', array('value'), 'feedback_value');
  59  
  60          return $contents;
  61      }
  62  
  63      /**
  64       * Define the decoding rules for links belonging
  65       * to the activity to be executed by the link decoder
  66       */
  67      static public function define_decode_rules() {
  68          $rules = array();
  69  
  70          $rules[] = new restore_decode_rule('FEEDBACKINDEX', '/mod/feedback/index.php?id=$1', 'course');
  71          $rules[] = new restore_decode_rule('FEEDBACKVIEWBYID', '/mod/feedback/view.php?id=$1', 'course_module');
  72          $rules[] = new restore_decode_rule('FEEDBACKANALYSISBYID', '/mod/feedback/analysis.php?id=$1', 'course_module');
  73          $rules[] = new restore_decode_rule('FEEDBACKSHOWENTRIESBYID', '/mod/feedback/show_entries.php?id=$1', 'course_module');
  74  
  75          return $rules;
  76  
  77      }
  78  
  79      /**
  80       * Define the restore log rules that will be applied
  81       * by the {@link restore_logs_processor} when restoring
  82       * feedback logs. It must return one array
  83       * of {@link restore_log_rule} objects
  84       */
  85      static public function define_restore_log_rules() {
  86          $rules = array();
  87  
  88          $rules[] = new restore_log_rule('feedback', 'add', 'view.php?id={course_module}', '{feedback}');
  89          $rules[] = new restore_log_rule('feedback', 'update', 'view.php?id={course_module}', '{feedback}');
  90          $rules[] = new restore_log_rule('feedback', 'view', 'view.php?id={course_module}', '{feedback}');
  91          $rules[] = new restore_log_rule('feedback', 'submit', 'view.php?id={course_module}', '{feedback}');
  92          $rules[] = new restore_log_rule('feedback', 'startcomplete', 'view.php?id={course_module}', '{feedback}');
  93  
  94          return $rules;
  95      }
  96  
  97      /**
  98       * Define the restore log rules that will be applied
  99       * by the {@link restore_logs_processor} when restoring
 100       * course logs. It must return one array
 101       * of {@link restore_log_rule} objects
 102       *
 103       * Note this rules are applied when restoring course logs
 104       * by the restore final task, but are defined here at
 105       * activity level. All them are rules not linked to any module instance (cmid = 0)
 106       */
 107      static public function define_restore_log_rules_for_course() {
 108          $rules = array();
 109  
 110          $rules[] = new restore_log_rule('feedback', 'view all', 'index.php?id={course}', null);
 111  
 112          return $rules;
 113      }
 114  }