2013-07-23 05:21:54 +00:00
|
|
|
<?php
|
2021-11-24 07:29:43 +00:00
|
|
|
// This file is part of the htmlcert module for Moodle - http://moodle.org/
|
2013-07-23 05:21:54 +00:00
|
|
|
//
|
|
|
|
// Moodle is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// Moodle is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
/**
|
2021-11-24 07:29:43 +00:00
|
|
|
* Define all the backup steps that will be used by the backup_htmlcert_activity_task.
|
2013-07-23 05:21:54 +00:00
|
|
|
*
|
2021-11-24 07:29:43 +00:00
|
|
|
* @package mod_htmlcert
|
|
|
|
* @copyright 2013 Mark Nelson <markn@moodle.com>, 2021 Klaus-Uwe Mitterer <kumitterer@kumi.systems>
|
2013-07-23 05:21:54 +00:00
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
|
*/
|
|
|
|
|
|
|
|
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
|
|
|
|
|
|
|
|
/**
|
2021-11-24 07:29:43 +00:00
|
|
|
* Define the complete htmlcert structure for backup, with file and id annotations.
|
2017-02-16 12:12:19 +00:00
|
|
|
*
|
2021-11-24 07:29:43 +00:00
|
|
|
* @package mod_htmlcert
|
|
|
|
* @copyright 2013 Mark Nelson <markn@moodle.com>, 2021 Klaus-Uwe Mitterer <kumitterer@kumi.systems>
|
2017-02-16 12:12:19 +00:00
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
2013-07-23 05:21:54 +00:00
|
|
|
*/
|
2021-11-24 07:29:43 +00:00
|
|
|
class backup_htmlcert_activity_structure_step extends backup_activity_structure_step {
|
2013-07-23 05:21:54 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Define the structure of the backup file.
|
|
|
|
*
|
|
|
|
* @return backup_nested_element
|
|
|
|
*/
|
|
|
|
protected function define_structure() {
|
|
|
|
|
|
|
|
// The instance.
|
2021-11-24 07:29:43 +00:00
|
|
|
$htmlcert = new backup_nested_element('htmlcert', array('id'), array(
|
2018-02-22 11:07:13 +00:00
|
|
|
'templateid', 'name', 'intro', 'introformat', 'requiredtime', 'verifyany', 'emailstudents',
|
2017-02-02 09:17:41 +00:00
|
|
|
'emailteachers', 'emailothers', 'protection', 'timecreated', 'timemodified'));
|
2013-07-23 05:21:54 +00:00
|
|
|
|
2016-04-05 07:52:43 +00:00
|
|
|
// The template.
|
|
|
|
$template = new backup_nested_element('template', array('id'), array(
|
|
|
|
'name', 'contextid', 'timecreated', 'timemodified'));
|
2013-07-23 05:21:54 +00:00
|
|
|
|
2016-04-05 07:52:43 +00:00
|
|
|
// The issues.
|
|
|
|
$issues = new backup_nested_element('issues');
|
|
|
|
$issue = new backup_nested_element('issue', array('id'), array(
|
2021-11-24 07:29:43 +00:00
|
|
|
'htmlcertid', 'userid', 'timecreated', 'emailed', 'code'));
|
2016-04-05 07:52:43 +00:00
|
|
|
|
2013-07-23 05:21:54 +00:00
|
|
|
// Build the tree.
|
2021-11-24 07:29:43 +00:00
|
|
|
$htmlcert->add_child($issues);
|
2013-07-23 05:21:54 +00:00
|
|
|
$issues->add_child($issue);
|
2021-11-24 07:29:43 +00:00
|
|
|
$htmlcert->add_child($template);
|
2013-07-23 05:21:54 +00:00
|
|
|
|
|
|
|
// Define sources.
|
2021-11-24 07:29:43 +00:00
|
|
|
$htmlcert->set_source_table('htmlcert', array('id' => backup::VAR_ACTIVITYID));
|
2013-07-23 05:21:54 +00:00
|
|
|
|
2016-04-05 07:52:43 +00:00
|
|
|
// Define template source.
|
2021-11-24 07:29:43 +00:00
|
|
|
$template->set_source_table('htmlcert_templates', array('contextid' => backup::VAR_CONTEXTID));
|
2013-07-23 05:21:54 +00:00
|
|
|
|
|
|
|
// If we are including user info then save the issues.
|
|
|
|
if ($this->get_setting_value('userinfo')) {
|
2021-11-24 07:29:43 +00:00
|
|
|
$issue->set_source_table('htmlcert_issues', array('htmlcertid' => backup::VAR_ACTIVITYID));
|
2013-07-23 05:21:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Annotate the user id's where required.
|
|
|
|
$issue->annotate_ids('user', 'userid');
|
|
|
|
|
2017-04-27 13:54:10 +00:00
|
|
|
// Define file annotations.
|
2021-11-24 07:29:43 +00:00
|
|
|
$htmlcert->annotate_files('mod_htmlcert', 'intro', null);
|
|
|
|
$htmlcert->annotate_files('mod_htmlcert', 'image', null, context_course::instance($this->get_courseid())->id);
|
2017-04-27 13:54:10 +00:00
|
|
|
|
2021-11-24 07:29:43 +00:00
|
|
|
// Return the root element (htmlcert), wrapped into standard activity structure.
|
|
|
|
return $this->prepare_activity_structure($htmlcert);
|
2013-07-23 05:21:54 +00:00
|
|
|
}
|
|
|
|
}
|