mirrored from git://git.moodle.org/moodle.git
/
backup_scorm_stepslib.php
156 lines (117 loc) · 6.77 KB
/
backup_scorm_stepslib.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
// This file is part of 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/>.
/**
* @package moodlecore
* @subpackage backup-moodle2
* @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/**
* Define all the backup steps that will be used by the backup_scorm_activity_task
*/
/**
* Define the complete scorm structure for backup, with file and id annotations
*/
class backup_scorm_activity_structure_step extends backup_activity_structure_step {
protected function define_structure() {
// To know if we are including userinfo
$userinfo = $this->get_setting_value('userinfo');
// Define each element separated
$scorm = new backup_nested_element('scorm', array('id'), array(
'name', 'scormtype', 'reference', 'intro',
'introformat', 'version', 'maxgrade', 'grademethod',
'whatgrade', 'maxattempt', 'forcecompleted', 'forcenewattempt',
'lastattemptlock', 'displayattemptstatus', 'displaycoursestructure', 'updatefreq',
'sha1hash', 'md5hash', 'revision', 'launch',
'skipview', 'hidebrowse', 'hidetoc', 'hidenav',
'auto', 'popup', 'options', 'width',
'height', 'timeopen', 'timeclose', 'timemodified',
'completionstatusrequired', 'completionscorerequired'));
$scoes = new backup_nested_element('scoes');
$sco = new backup_nested_element('sco', array('id'), array(
'manifest', 'organization', 'parent', 'identifier',
'launch', 'scormtype', 'title'));
$scodatas = new backup_nested_element('sco_datas');
$scodata = new backup_nested_element('sco_data', array('id'), array(
'name', 'value'));
$seqruleconds = new backup_nested_element('seq_ruleconds');
$seqrulecond = new backup_nested_element('seq_rulecond', array('id'), array(
'conditioncombination', 'ruletype', 'action'));
$seqrulecondsdatas = new backup_nested_element('seq_rulecond_datas');
$seqrulecondsdata = new backup_nested_element('seq_rulecond_data', array('id'), array(
'refrencedobjective', 'measurethreshold', 'operator', 'cond'));
$seqrolluprules = new backup_nested_element('seq_rolluprules');
$seqrolluprule = new backup_nested_element('seq_rolluprule', array('id'), array(
'childactivityset', 'minimumcount', 'minimumpercent', 'conditioncombination',
'action'));
$seqrollupruleconds = new backup_nested_element('seq_rollupruleconds');
$seqrolluprulecond = new backup_nested_element('seq_rolluprulecond', array('id'), array(
'cond', 'operator'));
$seqobjectives = new backup_nested_element('seq_objectives');
$seqobjective = new backup_nested_element('seq_objective', array('id'), array(
'primaryobj', 'objectiveid', 'satisfiedbymeasure', 'minnormalizedmeasure'));
$seqmapinfos = new backup_nested_element('seq_mapinfos');
$seqmapinfo = new backup_nested_element('seq_mapinfo', array('id'), array(
'targetobjectiveid', 'readsatisfiedstatus', 'readnormalizedmeasure', 'writesatisfiedstatus',
'writenormalizedmeasure'));
$scotracks = new backup_nested_element('sco_tracks');
$scotrack = new backup_nested_element('sco_track', array('id'), array(
'userid', 'attempt', 'element', 'value',
'timemodified'));
// Build the tree
$scorm->add_child($scoes);
$scoes->add_child($sco);
$sco->add_child($scodatas);
$scodatas->add_child($scodata);
$sco->add_child($seqruleconds);
$seqruleconds->add_child($seqrulecond);
$seqrulecond->add_child($seqrulecondsdatas);
$seqrulecondsdatas->add_child($seqrulecondsdata);
$sco->add_child($seqrolluprules);
$seqrolluprules->add_child($seqrolluprule);
$seqrolluprule->add_child($seqrollupruleconds);
$seqrollupruleconds->add_child($seqrolluprulecond);
$sco->add_child($seqobjectives);
$seqobjectives->add_child($seqobjective);
$seqobjective->add_child($seqmapinfos);
$seqmapinfos->add_child($seqmapinfo);
$sco->add_child($scotracks);
$scotracks->add_child($scotrack);
// Define sources
$scorm->set_source_table('scorm', array('id' => backup::VAR_ACTIVITYID));
// Order is important for several SCORM calls (especially scorm_scoes) in the following calls to set_source_table
$sco->set_source_table('scorm_scoes', array('scorm' => backup::VAR_PARENTID), 'id ASC');
$scodata->set_source_table('scorm_scoes_data', array('scoid' => backup::VAR_PARENTID), 'id ASC');
$seqrulecond->set_source_table('scorm_seq_ruleconds', array('scoid' => backup::VAR_PARENTID), 'id ASC');
$seqrulecondsdata->set_source_table('scorm_seq_rulecond', array('ruleconditionsid' => backup::VAR_PARENTID), 'id ASC');
$seqrolluprule->set_source_table('scorm_seq_rolluprule', array('scoid' => backup::VAR_PARENTID), 'id ASC');
$seqrolluprulecond->set_source_table('scorm_seq_rolluprulecond', array('rollupruleid' => backup::VAR_PARENTID), 'id ASC');
$seqobjective->set_source_table('scorm_seq_objective', array('scoid' => backup::VAR_PARENTID), 'id ASC');
$seqmapinfo->set_source_table('scorm_seq_mapinfo', array('objectiveid' => backup::VAR_PARENTID), 'id ASC');
// All the rest of elements only happen if we are including user info
if ($userinfo) {
$scotrack->set_source_table('scorm_scoes_track', array('scoid' => backup::VAR_PARENTID), 'id ASC');
}
// Define id annotations
$scotrack->annotate_ids('user', 'userid');
// Define file annotations
$scorm->annotate_files('mod_scorm', 'intro', null); // This file area hasn't itemid
$scorm->annotate_files('mod_scorm', 'content', null); // This file area hasn't itemid
$scorm->annotate_files('mod_scorm', 'package', null); // This file area hasn't itemid
// Return the root element (scorm), wrapped into standard activity structure
return $this->prepare_activity_structure($scorm);
}
}