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
/**
18
 * Provides the information to backup question custom field.
19
 *
20
 * @package    qbank_customfields
21
 * @copyright  2021 Catalyst IT Australia Pty Ltd
22
 * @author     Matt Porritt <mattp@catalyst-au.net>
23
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25
class backup_qbank_customfields_plugin extends \backup_qbank_plugin {
26
 
27
    /**
28
     * Returns the comment information to attach to question element.
29
     *
30
     * @return backup_plugin_element The backup plugin element
31
     */
32
    protected function define_question_plugin_structure(): backup_plugin_element {
33
 
34
        // Define the virtual plugin element with the condition to fulfill.
35
        $plugin = $this->get_plugin_element();
36
 
37
        // Create one standard named plugin element (the visible container).
38
        $pluginwrapper = new backup_nested_element($this->get_recommended_name());
39
 
40
        // Connect the visible container ASAP.
41
        $plugin->add_child($pluginwrapper);
42
 
43
        $customfields = new backup_nested_element('customfields');
44
        $customfield = new backup_nested_element('customfield', ['id'],
45
            ['shortname', 'type', 'value', 'valueformat', 'valuetrust']);
46
 
47
        $pluginwrapper->add_child($customfields);
48
        $customfields->add_child($customfield);
49
 
50
        $customfield->set_source_sql("SELECT cfd.id, cff.shortname, cff.type,  cfd.value, cfd.valueformat, cfd.valuetrust
51
                                        FROM {customfield_data} cfd
52
                                        JOIN {customfield_field} cff ON cff.id = cfd.fieldid
53
                                        JOIN {customfield_category} cfc ON cfc.id = cff.categoryid
54
                                       WHERE cfc.component = 'qbank_customfields'
55
                                         AND cfc.area = 'question'
56
                                         AND cfd.instanceid = ?",
57
                [
58
                        backup::VAR_PARENTID
59
                ]);
60
 
61
        // Don't need to annotate ids nor files.
62
 
63
        return $plugin;
64
    }
65
}