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 |
* Backup instructions for the seb (Safe Exam Browser) quiz access subplugin.
|
|
|
19 |
*
|
|
|
20 |
* @package quizaccess_seb
|
|
|
21 |
* @category backup
|
|
|
22 |
* @author Andrew Madden <andrewmadden@catalyst-au.net>
|
|
|
23 |
* @copyright 2020 Catalyst IT
|
|
|
24 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
25 |
*/
|
|
|
26 |
|
|
|
27 |
defined('MOODLE_INTERNAL') || die();
|
|
|
28 |
|
|
|
29 |
require_once($CFG->dirroot . '/mod/quiz/backup/moodle2/backup_mod_quiz_access_subplugin.class.php');
|
|
|
30 |
|
|
|
31 |
/**
|
|
|
32 |
* Backup instructions for the seb (Safe Exam Browser) quiz access subplugin.
|
|
|
33 |
*
|
|
|
34 |
* @copyright 2020 Catalyst IT
|
|
|
35 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
36 |
*/
|
|
|
37 |
class backup_quizaccess_seb_subplugin extends backup_mod_quiz_access_subplugin {
|
|
|
38 |
|
|
|
39 |
/**
|
|
|
40 |
* Stores the data related to the Safe Exam Browser quiz settings and management for a particular quiz.
|
|
|
41 |
*
|
|
|
42 |
* @return backup_subplugin_element
|
|
|
43 |
*/
|
|
|
44 |
protected function define_quiz_subplugin_structure() {
|
|
|
45 |
parent::define_quiz_subplugin_structure();
|
|
|
46 |
$quizid = backup::VAR_ACTIVITYID;
|
|
|
47 |
|
|
|
48 |
$subplugin = $this->get_subplugin_element();
|
|
|
49 |
$subpluginwrapper = new backup_nested_element($this->get_recommended_name());
|
|
|
50 |
|
|
|
51 |
$template = new \quizaccess_seb\template();
|
|
|
52 |
$blanktemplatearray = (array) $template->to_record();
|
|
|
53 |
unset($blanktemplatearray['usermodified']);
|
|
|
54 |
unset($blanktemplatearray['timemodified']);
|
|
|
55 |
|
|
|
56 |
$templatekeys = array_keys($blanktemplatearray);
|
|
|
57 |
|
|
|
58 |
$subplugintemplatesettings = new backup_nested_element('quizaccess_seb_template', null, $templatekeys);
|
|
|
59 |
|
|
|
60 |
// Get quiz settings keys to save.
|
|
|
61 |
$settings = new \quizaccess_seb\seb_quiz_settings();
|
|
|
62 |
$blanksettingsarray = (array) $settings->to_record();
|
|
|
63 |
unset($blanksettingsarray['id']); // We don't need to save reference to settings record in current instance.
|
|
|
64 |
// We don't need to save the data about who last modified the settings as they will be overwritten on restore. Also
|
|
|
65 |
// means we don't have to think about user data for the backup.
|
|
|
66 |
unset($blanksettingsarray['usermodified']);
|
|
|
67 |
unset($blanksettingsarray['timemodified']);
|
|
|
68 |
|
|
|
69 |
$settingskeys = array_keys($blanksettingsarray);
|
|
|
70 |
|
|
|
71 |
// Save the settings.
|
|
|
72 |
$subpluginquizsettings = new backup_nested_element('quizaccess_seb_quizsettings', null, $settingskeys);
|
|
|
73 |
|
|
|
74 |
// Connect XML elements into the tree.
|
|
|
75 |
$subplugin->add_child($subpluginwrapper);
|
|
|
76 |
$subpluginwrapper->add_child($subpluginquizsettings);
|
|
|
77 |
$subpluginquizsettings->add_child($subplugintemplatesettings);
|
|
|
78 |
|
|
|
79 |
// Set source to populate the settings data by referencing the ID of quiz being backed up.
|
|
|
80 |
$subpluginquizsettings->set_source_table(quizaccess_seb\seb_quiz_settings::TABLE, ['quizid' => $quizid]);
|
|
|
81 |
|
|
|
82 |
$subpluginquizsettings->annotate_files('quizaccess_seb', 'filemanager_sebconfigfile', null);
|
|
|
83 |
|
|
|
84 |
$params = ['id' => '../templateid'];
|
|
|
85 |
$subplugintemplatesettings->set_source_table(\quizaccess_seb\template::TABLE, $params);
|
|
|
86 |
|
|
|
87 |
return $subplugin;
|
|
|
88 |
}
|
|
|
89 |
}
|