1f942f76569236bb6b29c2b8ba193ff35e5cffdd
[moodle.git] / mod / workshop / backup / moodle2 / restore_workshop_activity_task.class.php
1 <?php
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/>.
18 /**
19  * @package    mod
20  * @subpackage workshop
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
23  */
25 defined('MOODLE_INTERNAL') || die();
27 require_once($CFG->dirroot . '/mod/workshop/backup/moodle2/restore_workshop_stepslib.php'); // Because it exists (must)
29 /**
30  * workshop restore task that provides all the settings and steps to perform one
31  * complete restore of the activity
32  */
33 class restore_workshop_activity_task extends restore_activity_task {
35     /**
36      * Define (add) particular settings this activity can have
37      */
38     protected function define_my_settings() {
39         // No particular settings for this activity
40     }
42     /**
43      * Define (add) particular steps this activity can have
44      */
45     protected function define_my_steps() {
46         // Choice only has one structure step
47         $this->add_step(new restore_workshop_activity_structure_step('workshop_structure', 'workshop.xml'));
48     }
50     /**
51      * Define the contents in the activity that must be
52      * processed by the link decoder
53      */
54     static public function define_decode_contents() {
55         $contents = array();
57         $contents[] = new restore_decode_content('workshop',
58                           array('intro', 'instructauthors', 'instructreviewers'), 'workshop');
59         $contents[] = new restore_decode_content('workshop_submissions',
60                           array('content', 'feedbackauthor'), 'workshop_submission');
61         $contents[] = new restore_decode_content('workshop_assessments',
62                           array('feedbackauthor', 'feedbackreviewer'), 'workshop_assessment');
64         return $contents;
65     }
67     /**
68      * Define the decoding rules for links belonging
69      * to the activity to be executed by the link decoder
70      */
71     static public function define_decode_rules() {
72         $rules = array();
74         $rules[] = new restore_decode_rule('WORKSHOPVIEWBYID', '/mod/workshop/view.php?id=$1', 'course_module');
75         $rules[] = new restore_decode_rule('WORKSHOPINDEX', '/mod/workshop/index.php?id=$1', 'course');
77         return $rules;
79     }
81     /**
82      * Define the restore log rules that will be applied
83      * by the {@link restore_logs_processor} when restoring
84      * workshop logs. It must return one array
85      * of {@link restore_log_rule} objects
86      */
87     static public function define_restore_log_rules() {
88         $rules = array();
90         $rules[] = new restore_log_rule('workshop', 'add', 'view.php?id={course_module}', '{workshop}');
91         $rules[] = new restore_log_rule('workshop', 'update', 'view.php?id={course_module}', '{workshop}');
92         $rules[] = new restore_log_rule('workshop', 'view', 'view.php?id={course_module}', '{workshop}');
94         $rules[] = new restore_log_rule('workshop', 'add assessment',
95                        'assessment.php?asid={workshop_assessment}', '{workshop_submission}');
96         $rules[] = new restore_log_rule('workshop', 'update assessment',
97                        'assessment.php?asid={workshop_assessment}', '{workshop_submission}');
99         $rules[] = new restore_log_rule('workshop', 'add reference assessment',
100                        'exassessment.php?asid={workshop_referenceassessment}', '{workshop_examplesubmission}');
101         $rules[] = new restore_log_rule('workshop', 'update reference assessment',
102                        'exassessment.php?asid={workshop_referenceassessment}', '{workshop_examplesubmission}');
104         $rules[] = new restore_log_rule('workshop', 'add example assessment',
105                        'exassessment.php?asid={workshop_exampleassessment}', '{workshop_examplesubmission}');
106         $rules[] = new restore_log_rule('workshop', 'update example assessment',
107                        'exassessment.php?asid={workshop_exampleassessment}', '{workshop_examplesubmission}');
109         $rules[] = new restore_log_rule('workshop', 'view submission',
110                        'submission.php?cmid={course_module}&id={workshop_submission}', '{workshop_submission}');
111         $rules[] = new restore_log_rule('workshop', 'add submission',
112                        'submission.php?cmid={course_module}&id={workshop_submission}', '{workshop_submission}');
113         $rules[] = new restore_log_rule('workshop', 'update submission',
114                        'submission.php?cmid={course_module}&id={workshop_submission}', '{workshop_submission}');
116         $rules[] = new restore_log_rule('workshop', 'view example',
117                        'exsubmission.php?cmid={course_module}&id={workshop_examplesubmission}', '{workshop_examplesubmission}');
118         $rules[] = new restore_log_rule('workshop', 'add example',
119                        'exsubmission.php?cmid={course_module}&id={workshop_examplesubmission}', '{workshop_examplesubmission}');
120         $rules[] = new restore_log_rule('workshop', 'update example',
121                        'exsubmission.php?cmid={course_module}&id={workshop_examplesubmission}', '{workshop_examplesubmission}');
123         $rules[] = new restore_log_rule('workshop', 'update aggregate grades', 'view.php?id={course_module}', '{workshop}');
124         $rules[] = new restore_log_rule('workshop', 'update switch phase', 'view.php?id={course_module}', '[phase]');
125         $rules[] = new restore_log_rule('workshop', 'update clear aggregated grades', 'view.php?id={course_module}', '{workshop}');
126         $rules[] = new restore_log_rule('workshop', 'update clear assessments', 'view.php?id={course_module}', '{workshop}');
128         return $rules;
129     }
131     /**
132      * Define the restore log rules that will be applied
133      * by the {@link restore_logs_processor} when restoring
134      * course logs. It must return one array
135      * of {@link restore_log_rule} objects
136      *
137      * Note this rules are applied when restoring course logs
138      * by the restore final task, but are defined here at
139      * activity level. All them are rules not linked to any module instance (cmid = 0)
140      */
141     static public function define_restore_log_rules_for_course() {
142         $rules = array();
144         $rules[] = new restore_log_rule('workshop', 'view all', 'index.php?id={course}', null);
146         return $rules;
147     }