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
24 defined('MOODLE_INTERNAL') || die();
27 * Provides the information to backup numerical questions
29 class backup_qtype_numerical_plugin extends backup_qtype_plugin {
32 * Returns the qtype information to attach to question element
34 protected function define_question_plugin_structure() {
36 // Define the virtual plugin element with the condition to fulfill
37 $plugin = $this->get_plugin_element(null, '../../qtype', 'numerical');
39 // Create one standard named plugin element (the visible container)
40 $pluginwrapper = new backup_nested_element($this->get_recommended_name());
42 // connect the visible container ASAP
43 $plugin->add_child($pluginwrapper);
45 // This qtype uses standard question_answers, add them here
46 // to the tree before any other information that will use them
47 $this->add_question_question_answers($pluginwrapper);
49 // This qtype uses standard numerical units, add them here
50 $this->add_question_numerical_units($pluginwrapper);
52 // This qtype uses standard numerical options, add them here
53 $this->add_question_numerical_options($pluginwrapper);
55 // Now create the qtype own structures
56 $numericalrecords = new backup_nested_element('numerical_records');
57 $numericalrecord = new backup_nested_element('numerical_record', array('id'), array(
58 'answer', 'tolerance'));
60 // Now the own qtype tree
61 $pluginwrapper->add_child($numericalrecords);
62 $numericalrecords->add_child($numericalrecord);
64 // set source to populate the data
65 $numericalrecord->set_source_table('question_numerical', array('question' => backup::VAR_PARENTID));
67 // don't need to annotate ids nor files