. /** * Define all the backup steps that will be used by the backup_htmlcert_activity_task. * * @package mod_htmlcert * @copyright 2013 Mark Nelson , 2021 Klaus-Uwe Mitterer * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.'); /** * Define the complete htmlcert structure for backup, with file and id annotations. * * @package mod_htmlcert * @copyright 2013 Mark Nelson , 2021 Klaus-Uwe Mitterer * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ 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. $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( 'htmlcertid', 'userid', 'timecreated', 'emailed', 'code')); // Build the tree. $htmlcert->add_child($issues); $issues->add_child($issue); $htmlcert->add_child($template); // Define sources. $htmlcert->set_source_table('htmlcert', array('id' => backup::VAR_ACTIVITYID)); // Define template source. $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')) { $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. $htmlcert->annotate_files('mod_htmlcert', 'intro', null); $htmlcert->annotate_files('mod_htmlcert', 'image', null, context_course::instance($this->get_courseid())->id); // Return the root element (htmlcert), wrapped into standard activity structure. return $this->prepare_activity_structure($htmlcert); } }