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 the customcert module for 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
 * Define all the backup steps that will be used by the backup_customcert_activity_task.
19
 *
20
 * @package    mod_customcert
21
 * @copyright  2013 Mark Nelson <markn@moodle.com>
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
/**
26
 * Define the complete customcert structure for backup, with file and id annotations.
27
 *
28
 * @package    mod_customcert
29
 * @copyright  2013 Mark Nelson <markn@moodle.com>
30
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
31
 */
32
class backup_customcert_activity_structure_step extends backup_activity_structure_step {
33
 
34
    /**
35
     * Define the structure of the backup file.
36
     *
37
     * @return backup_nested_element
38
     */
39
    protected function define_structure() {
40
 
41
        // The instance.
42
        $customcert = new backup_nested_element('customcert', ['id'], [
43
            'templateid', 'name', 'intro', 'introformat', 'requiredtime', 'verifyany', 'emailstudents',
44
            'emailteachers', 'emailothers', 'protection', 'timecreated', 'timemodified']);
45
 
46
        // The template.
47
        $template = new backup_nested_element('template', ['id'], [
48
            'name', 'contextid', 'timecreated', 'timemodified']);
49
 
50
        // The pages.
51
        $pages = new backup_nested_element('pages');
52
        $page = new backup_nested_element('page', ['id'], [
53
            'templateid', 'width', 'height', 'leftmargin', 'rightmargin',
54
            'sequence', 'timecreated', 'timemodified']);
55
 
56
        // The elements.
57
        $element = new backup_nested_element('element', ['id'], [
58
            'pageid', 'name', 'element', 'data', 'font', 'fontsize',
59
            'colour', 'posx', 'posy', 'width', 'refpoint', 'sequence',
60
            'alignment', 'timecreated', 'timemodified']);
61
 
62
        // The issues.
63
        $issues = new backup_nested_element('issues');
64
        $issue = new backup_nested_element('issue', ['id'], [
65
            'customcertid', 'userid', 'timecreated', 'emailed', 'code']);
66
 
67
        // Build the tree.
68
        $customcert->add_child($issues);
69
        $issues->add_child($issue);
70
        $customcert->add_child($template);
71
        $template->add_child($pages);
72
        $pages->add_child($page);
73
        $page->add_child($element);
74
 
75
        // Define sources.
76
        $customcert->set_source_table('customcert', ['id' => backup::VAR_ACTIVITYID]);
77
 
78
        // Define template source.
79
        $template->set_source_table('customcert_templates', ['contextid' => backup::VAR_CONTEXTID]);
80
 
81
        // Define page source.
82
        $page->set_source_table('customcert_pages', ['templateid' => backup::VAR_PARENTID]);
83
 
84
        // Define element source, each element belongs to a page.
85
        $element->set_source_table('customcert_elements', ['pageid' => backup::VAR_PARENTID]);
86
 
87
        // If we are including user info then save the issues.
88
        if ($this->get_setting_value('userinfo')) {
89
            $issue->set_source_table('customcert_issues', ['customcertid' => backup::VAR_ACTIVITYID]);
90
        }
91
 
92
        // Annotate the user id's where required.
93
        $issue->annotate_ids('user', 'userid');
94
 
95
        // Define file annotations.
96
        $customcert->annotate_files('mod_customcert', 'intro', null);
97
        $customcert->annotate_files('mod_customcert', 'image', null, context_course::instance($this->get_courseid())->id);
98
 
99
        // Return the root element (customcert), wrapped into standard activity structure.
100
        return $this->prepare_activity_structure($customcert);
101
    }
102
}