2 // This file is part of Moodle - http://moodle.org/
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.
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.
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/>.
18 * Defines all the backup steps that will be used by {@link backup_attendance_activity_task}
20 * @package mod_attendance
21 * @copyright 2011 Artem Andreev <andreev.artem@gmail.com>
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 defined('MOODLE_INTERNAL') ||
die();
28 * Defines the complete attendance structure for backup, with file and id annotations
30 * @copyright 2011 Artem Andreev <andreev.artem@gmail.com>
31 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
33 class backup_attendance_activity_structure_step
extends backup_activity_structure_step
{
36 * Define the structure of the backup workflow.
38 * @return restore_path_element $structure
40 protected function define_structure() {
42 // Are we including userinfo?
43 $userinfo = $this->get_setting_value('userinfo');
45 // XML nodes declaration - non-user data.
46 $attendance = new backup_nested_element('attendance', array('id'), array(
47 'name', 'intro', 'introformat', 'grade', 'showextrauserdetails', 'showsessiondetails', 'sessiondetailspos', 'subnet'));
49 $statuses = new backup_nested_element('statuses');
50 $status = new backup_nested_element('status', array('id'), array(
51 'acronym', 'description', 'grade', 'studentavailability', 'setunmarked', 'visible', 'deleted', 'setnumber'));
53 $warnings = new backup_nested_element('warnings');
54 $warning = new backup_nested_element('warning', array('id'), array('warningpercent', 'warnafter',
55 'maxwarn', 'emailuser', 'emailsubject', 'emailcontent', 'emailcontentformat', 'thirdpartyemails'));
57 $sessions = new backup_nested_element('sessions');
58 $session = new backup_nested_element('session', array('id'), array(
59 'groupid', 'sessdate', 'duration', 'lasttaken', 'lasttakenby', 'timemodified',
60 'description', 'descriptionformat', 'studentscanmark', 'studentpassword', 'autoassignstatus',
61 'subnet', 'automark', 'automarkcompleted', 'statusset', 'absenteereport', 'preventsharedip',
62 'preventsharediptime', 'caleventid'));
64 // XML nodes declaration - user data.
65 $logs = new backup_nested_element('logs');
66 $log = new backup_nested_element('log', array('id'), array(
67 'sessionid', 'studentid', 'statusid', 'statusset', 'timetaken', 'takenby', 'remarks'));
69 // Build the tree in the order needed for restore.
70 $attendance->add_child($statuses);
71 $statuses->add_child($status);
73 $attendance->add_child($warnings);
74 $warnings->add_child($warning);
76 $attendance->add_child($sessions);
77 $sessions->add_child($session);
79 $session->add_child($logs);
80 $logs->add_child($log);
82 // Data sources - non-user data.
84 $attendance->set_source_table('attendance', array('id' => backup
::VAR_ACTIVITYID
));
86 $status->set_source_table('attendance_statuses', array('attendanceid' => backup
::VAR_PARENTID
));
88 $warning->set_source_table('attendance_warning',
89 array('idnumber' => backup
::VAR_PARENTID
));
91 $session->set_source_table('attendance_sessions', array('attendanceid' => backup
::VAR_PARENTID
));
93 // Data sources - user related data.
95 $log->set_source_table('attendance_log', array('sessionid' => backup
::VAR_PARENTID
));
99 $session->annotate_ids('user', 'lasttakenby');
100 $session->annotate_ids('group', 'groupid');
101 $log->annotate_ids('user', 'studentid');
102 $log->annotate_ids('user', 'takenby');
105 $session->annotate_files('mod_attendance', 'session', 'id');
107 // Return the root element (workshop), wrapped into standard activity structure.
108 return $this->prepare_activity_structure($attendance);