|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 // This file is part of Moodle - http://moodle.org/ 00003 // 00004 // Moodle is free software: you can redistribute it and/or modify 00005 // it under the terms of the GNU General Public License as published by 00006 // the Free Software Foundation, either version 3 of the License, or 00007 // (at your option) any later version. 00008 // 00009 // Moodle is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 // GNU General Public License for more details. 00013 // 00014 // You should have received a copy of the GNU General Public License 00015 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 00016 00031 class backup_scorm_activity_structure_step extends backup_activity_structure_step { 00032 00033 protected function define_structure() { 00034 00035 // To know if we are including userinfo 00036 $userinfo = $this->get_setting_value('userinfo'); 00037 00038 // Define each element separated 00039 $scorm = new backup_nested_element('scorm', array('id'), array( 00040 'name', 'scormtype', 'reference', 'intro', 00041 'introformat', 'version', 'maxgrade', 'grademethod', 00042 'whatgrade', 'maxattempt', 'forcecompleted', 'forcenewattempt', 00043 'lastattemptlock', 'displayattemptstatus', 'displaycoursestructure', 'updatefreq', 00044 'sha1hash', 'md5hash', 'revision', 'launch', 00045 'skipview', 'hidebrowse', 'hidetoc', 'hidenav', 00046 'auto', 'popup', 'options', 'width', 00047 'height', 'timeopen', 'timeclose', 'timemodified')); 00048 00049 $scoes = new backup_nested_element('scoes'); 00050 00051 $sco = new backup_nested_element('sco', array('id'), array( 00052 'manifest', 'organization', 'parent', 'identifier', 00053 'launch', 'scormtype', 'title')); 00054 00055 $scodatas = new backup_nested_element('sco_datas'); 00056 00057 $scodata = new backup_nested_element('sco_data', array('id'), array( 00058 'name', 'value')); 00059 00060 $seqruleconds = new backup_nested_element('seq_ruleconds'); 00061 00062 $seqrulecond = new backup_nested_element('seq_rulecond', array('id'), array( 00063 'conditioncombination', 'ruletype', 'action')); 00064 00065 $seqrulecondsdatas = new backup_nested_element('seq_rulecond_datas'); 00066 00067 $seqrulecondsdata = new backup_nested_element('seq_rulecond_data', array('id'), array( 00068 'refrencedobjective', 'measurethreshold', 'operator', 'cond')); 00069 00070 $seqrolluprules = new backup_nested_element('seq_rolluprules'); 00071 00072 $seqrolluprule = new backup_nested_element('seq_rolluprule', array('id'), array( 00073 'childactivityset', 'minimumcount', 'minimumpercent', 'conditioncombination', 00074 'action')); 00075 00076 $seqrollupruleconds = new backup_nested_element('seq_rollupruleconds'); 00077 00078 $seqrolluprulecond = new backup_nested_element('seq_rolluprulecond', array('id'), array( 00079 'cond', 'operator')); 00080 00081 $seqobjectives = new backup_nested_element('seq_objectives'); 00082 00083 $seqobjective = new backup_nested_element('seq_objective', array('id'), array( 00084 'primaryobj', 'objectiveid', 'satisfiedbymeasure', 'minnormalizedmeasure')); 00085 00086 $seqmapinfos = new backup_nested_element('seq_mapinfos'); 00087 00088 $seqmapinfo = new backup_nested_element('seq_mapinfo', array('id'), array( 00089 'targetobjectiveid', 'readsatisfiedstatus', 'readnormalizedmeasure', 'writesatisfiedstatus', 00090 'writenormalizedmeasure')); 00091 00092 $scotracks = new backup_nested_element('sco_tracks'); 00093 00094 $scotrack = new backup_nested_element('sco_track', array('id'), array( 00095 'userid', 'attempt', 'element', 'value', 00096 'timemodified')); 00097 00098 // Build the tree 00099 $scorm->add_child($scoes); 00100 $scoes->add_child($sco); 00101 00102 $sco->add_child($scodatas); 00103 $scodatas->add_child($scodata); 00104 00105 $sco->add_child($seqruleconds); 00106 $seqruleconds->add_child($seqrulecond); 00107 00108 $seqrulecond->add_child($seqrulecondsdatas); 00109 $seqrulecondsdatas->add_child($seqrulecondsdata); 00110 00111 $sco->add_child($seqrolluprules); 00112 $seqrolluprules->add_child($seqrolluprule); 00113 00114 $seqrolluprule->add_child($seqrollupruleconds); 00115 $seqrollupruleconds->add_child($seqrolluprulecond); 00116 00117 $sco->add_child($seqobjectives); 00118 $seqobjectives->add_child($seqobjective); 00119 00120 $seqobjective->add_child($seqmapinfos); 00121 $seqmapinfos->add_child($seqmapinfo); 00122 00123 $sco->add_child($scotracks); 00124 $scotracks->add_child($scotrack); 00125 00126 // Define sources 00127 $scorm->set_source_table('scorm', array('id' => backup::VAR_ACTIVITYID)); 00128 00129 $sco->set_source_table('scorm_scoes', array('scorm' => backup::VAR_PARENTID)); 00130 00131 $scodata->set_source_table('scorm_scoes_data', array('scoid' => backup::VAR_PARENTID)); 00132 00133 $seqrulecond->set_source_table('scorm_seq_ruleconds', array('scoid' => backup::VAR_PARENTID)); 00134 00135 $seqrulecondsdata->set_source_table('scorm_seq_rulecond', array('ruleconditionsid' => backup::VAR_PARENTID)); 00136 00137 $seqrolluprule->set_source_table('scorm_seq_rolluprule', array('scoid' => backup::VAR_PARENTID)); 00138 00139 $seqrolluprulecond->set_source_table('scorm_seq_rolluprulecond', array('rollupruleid' => backup::VAR_PARENTID)); 00140 00141 $seqobjective->set_source_table('scorm_seq_objective', array('scoid' => backup::VAR_PARENTID)); 00142 00143 $seqmapinfo->set_source_table('scorm_seq_mapinfo', array('objectiveid' => backup::VAR_PARENTID)); 00144 00145 // All the rest of elements only happen if we are including user info 00146 if ($userinfo) { 00147 $scotrack->set_source_table('scorm_scoes_track', array('scoid' => backup::VAR_PARENTID)); 00148 } 00149 00150 // Define id annotations 00151 $scotrack->annotate_ids('user', 'userid'); 00152 00153 // Define file annotations 00154 $scorm->annotate_files('mod_scorm', 'intro', null); // This file area hasn't itemid 00155 $scorm->annotate_files('mod_scorm', 'content', null); // This file area hasn't itemid 00156 $scorm->annotate_files('mod_scorm', 'package', null); // This file area hasn't itemid 00157 00158 // Return the root element (scorm), wrapped into standard activity structure 00159 return $this->prepare_activity_structure($scorm); 00160 } 00161 }