moodle-mod_htmlcert/backup/moodle2/backup_customcert_stepslib.php

84 lines
3.4 KiB
PHP
Raw Normal View History

<?php
2021-11-24 07:29:43 +00:00
// This file is part of the htmlcert module for Moodle - http://moodle.org/
//
// 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.
*
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>
* @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
*/
2021-11-24 07:29:43 +00:00
class backup_htmlcert_activity_structure_step extends backup_activity_structure_step {
/**
* 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(
'templateid', 'name', 'intro', 'introformat', 'requiredtime', 'verifyany', 'emailstudents',
'emailteachers', 'emailothers', 'protection', 'timecreated', 'timemodified'));
// The template.
$template = new backup_nested_element('template', array('id'), array(
'name', 'contextid', 'timecreated', 'timemodified'));
// 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'));
// Build the tree.
2021-11-24 07:29:43 +00:00
$htmlcert->add_child($issues);
$issues->add_child($issue);
2021-11-24 07:29:43 +00:00
$htmlcert->add_child($template);
// Define sources.
2021-11-24 07:29:43 +00:00
$htmlcert->set_source_table('htmlcert', array('id' => backup::VAR_ACTIVITYID));
// Define template source.
2021-11-24 07:29:43 +00:00
$template->set_source_table('htmlcert_templates', array('contextid' => backup::VAR_CONTEXTID));
// 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));
}
// Annotate the user id's where required.
$issue->annotate_ids('user', 'userid');
// 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);
2021-11-24 07:29:43 +00:00
// Return the root element (htmlcert), wrapped into standard activity structure.
return $this->prepare_activity_structure($htmlcert);
}
}