3 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
20 * @subpackage backup-moodle2
21 * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') || die();
27 require_once($CFG->dirroot . '/mod/survey/backup/moodle2/restore_survey_stepslib.php'); // Because it exists (must)
30 * survey restore task that provides all the settings and steps to perform one
31 * complete restore of the activity
33 class restore_survey_activity_task extends restore_activity_task {
36 * Define (add) particular settings this activity can have
38 protected function define_my_settings() {
39 // No particular settings for this activity
43 * Define (add) particular steps this activity can have
45 protected function define_my_steps() {
46 // survey only has one structure step
47 $this->add_step(new restore_survey_activity_structure_step('survey_structure', 'survey.xml'));
51 * Define the contents in the activity that must be
52 * processed by the link decoder
54 static public function define_decode_contents() {
57 $contents[] = new restore_decode_content('survey', array('intro'), 'survey');
63 * Define the decoding rules for links belonging
64 * to the activity to be executed by the link decoder
66 static public function define_decode_rules() {
69 $rules[] = new restore_decode_rule('SURVEYVIEWBYID', '/mod/survey/view.php?id=$1', 'course_module');
70 $rules[] = new restore_decode_rule('SURVEYINDEX', '/mod/survey/index.php?id=$1', 'course');
77 * Define the restore log rules that will be applied
78 * by the {@link restore_logs_processor} when restoring
79 * survey logs. It must return one array
80 * of {@link restore_log_rule} objects
82 static public function define_restore_log_rules() {
85 $rules[] = new restore_log_rule('survey', 'add', 'view.php?id={course_module}', '{survey}');
86 $rules[] = new restore_log_rule('survey', 'update', 'view.php?id={course_module}', '{survey}');
87 $rules[] = new restore_log_rule('survey', 'view', 'view.php?id={course_module}', '{survey}');
88 $rules[] = new restore_log_rule('survey', 'download', 'download.php?id={course_module}&type=[type]&group=[group]', '{survey}');
89 $rules[] = new restore_log_rule('survey', 'view report', 'report.php?id={course_module}', '{survey}');
90 $rules[] = new restore_log_rule('survey', 'submit', 'view.php?id={course_module}', '{survey}');
91 $rules[] = new restore_log_rule('survey', 'view graph', 'view.php?id={course_module}', '{survey}');
92 $rules[] = new restore_log_rule('survey', 'view form', 'view.php?id={course_module}', '{survey}');
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
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)
107 static public function define_restore_log_rules_for_course() {
110 $rules[] = new restore_log_rule('survey', 'view all', 'index.php?id={course}', null);