Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 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
defined('MOODLE_INTERNAL') || die();
18
 
19
// Because it exists (must).
20
require_once($CFG->dirroot . '/mod/questionnaire/backup/moodle2/restore_questionnaire_stepslib.php');
21
 
22
/**
23
 * Questionnaire restore task that provides all the settings and steps to perform one complete restore of the activity.
24
 * @package mod_questionnaire
25
 * @copyright  2016 Mike Churchward (mike.churchward@poetgroup.org)
26
 * @author     Mike Churchward
27
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
28
 */
29
class restore_questionnaire_activity_task extends restore_activity_task {
30
 
31
    /**
32
     * Define (add) particular settings this activity can have
33
     */
34
    protected function define_my_settings() {
35
        // No particular settings for this activity.
36
    }
37
 
38
    /**
39
     * Define (add) particular steps this activity can have
40
     */
41
    protected function define_my_steps() {
42
        // Choice only has one structure step.
43
        $this->add_step(new restore_questionnaire_activity_structure_step('questionnaire_structure', 'questionnaire.xml'));
44
    }
45
 
46
    /**
47
     * Define the contents in the activity that must be
48
     * processed by the link decoder
49
     */
50
    public static function define_decode_contents() {
51
        $contents = array();
52
 
53
        $contents[] = new restore_decode_content('questionnaire', array('intro'), 'questionnaire');
54
        $contents[] = new restore_decode_content('questionnaire_survey',
55
                        array('info', 'thank_head', 'thank_body', 'thanks_page', 'feedbacknotes'), 'questionnaire_survey');
56
        $contents[] = new restore_decode_content('questionnaire_question', array('content'), 'questionnaire_question');
57
        $contents[] = new restore_decode_content('questionnaire_fb_sections', array('sectionheading'), 'questionnaire_fb_sections');
58
        $contents[] = new restore_decode_content('questionnaire_feedback', array('feedbacktext'), 'questionnaire_feedback');
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
    public static function define_decode_rules() {
68
        $rules = array();
69
 
70
        $rules[] = new restore_decode_rule('QUESTIONNAIREVIEWBYID', '/mod/questionnaire/view.php?id=$1', 'course_module');
71
        $rules[] = new restore_decode_rule('QUESTIONNAIREINDEX', '/mod/questionnaire/index.php?id=$1', 'course');
72
 
73
        return $rules;
74
 
75
    }
76
 
77
    /**
78
     * Define the restore log rules that will be applied
79
     * by the restore_logs_processor when restoring
80
     * questionnaire logs. It must return one array
81
     * of restore_log_rule objects
82
     */
83
    public static function define_restore_log_rules() {
84
        $rules = array();
85
 
86
        $rules[] = new restore_log_rule('questionnaire', 'add', 'view.php?id={course_module}', '{questionnaire}');
87
        $rules[] = new restore_log_rule('questionnaire', 'update', 'view.php?id={course_module}', '{questionnaire}');
88
        $rules[] = new restore_log_rule('questionnaire', 'view', 'view.php?id={course_module}', '{questionnaire}');
89
        $rules[] = new restore_log_rule('questionnaire', 'choose', 'view.php?id={course_module}', '{questionnaire}');
90
        $rules[] = new restore_log_rule('questionnaire', 'choose again', 'view.php?id={course_module}', '{questionnaire}');
91
        $rules[] = new restore_log_rule('questionnaire', 'report', 'report.php?id={course_module}', '{questionnaire}');
92
 
93
        return $rules;
94
    }
95
 
96
    /**
97
     * Define the restore log rules that will be applied
98
     * by the restore_logs_processor when restoring
99
     * course logs. It must return one array
100
     * of restore_log_rule objects
101
     *
102
     * Note this rules are applied when restoring course logs
103
     * by the restore final task, but are defined here at
104
     * activity level. All them are rules not linked to any module instance (cmid = 0)
105
     */
106
    public static function define_restore_log_rules_for_course() {
107
        $rules = array();
108
 
109
        // Fix old wrong uses (missing extension).
110
        $rules[] = new restore_log_rule('questionnaire', 'view all', 'index?id={course}', null,
111
                                        null, null, 'index.php?id={course}');
112
        $rules[] = new restore_log_rule('questionnaire', 'view all', 'index.php?id={course}', null);
113
 
114
        return $rules;
115
    }
116
}