Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/scorm/backup/moodle2/restore_scorm_stepslib.php
Go to the documentation of this file.
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 restore_scorm_activity_structure_step extends restore_activity_structure_step {
00032 
00033     protected function define_structure() {
00034 
00035         $paths = array();
00036         $userinfo = $this->get_setting_value('userinfo');
00037 
00038         $paths[] = new restore_path_element('scorm', '/activity/scorm');
00039         $paths[] = new restore_path_element('scorm_sco', '/activity/scorm/scoes/sco');
00040         $paths[] = new restore_path_element('scorm_sco_data', '/activity/scorm/scoes/sco/sco_datas/sco_data');
00041         $paths[] = new restore_path_element('scorm_seq_objective', '/activity/scorm/scoes/sco/seq_objectives/seq_objective');
00042         $paths[] = new restore_path_element('scorm_seq_rolluprule', '/activity/scorm/scoes/sco/seq_rolluprules/seq_rolluprule');
00043         $paths[] = new restore_path_element('scorm_seq_rolluprulecond', '/activity/scorm/scoes/sco/seq_rollupruleconds/seq_rolluprulecond');
00044         $paths[] = new restore_path_element('scorm_seq_rulecond', '/activity/scorm/scoes/sco/seq_ruleconds/seq_rulecond');
00045         $paths[] = new restore_path_element('scorm_seq_rulecond_data', '/activity/scorm/scoes/sco/seq_rulecond_datas/seq_rulecond_data');
00046 
00047         $paths[] = new restore_path_element('scorm_seq_mapinfo', '/activity/scorm/scoes/sco/seq_objectives/seq_objective/seq_mapinfos/seq_mapinfo');
00048         if ($userinfo) {
00049             $paths[] = new restore_path_element('scorm_sco_track', '/activity/scorm/scoes/sco/sco_tracks/sco_track');
00050         }
00051 
00052         // Return the paths wrapped into standard activity structure
00053         return $this->prepare_activity_structure($paths);
00054     }
00055 
00056     protected function process_scorm($data) {
00057         global $DB;
00058 
00059         $data = (object)$data;
00060         $oldid = $data->id;
00061 
00062         $data->course = $this->get_courseid();
00063 
00064         $data->timeopen = $this->apply_date_offset($data->timeopen);
00065         $data->timeclose = $this->apply_date_offset($data->timeclose);
00066         $data->timemodified = $this->apply_date_offset($data->timemodified);
00067 
00068         // insert the scorm record
00069         $newitemid = $DB->insert_record('scorm', $data);
00070         // immediately after inserting "activity" record, call this
00071         $this->apply_activity_instance($newitemid);
00072     }
00073 
00074     protected function process_scorm_sco($data) {
00075         global $DB;
00076 
00077         $data = (object)$data;
00078 
00079         $oldid = $data->id;
00080         $data->scorm = $this->get_new_parentid('scorm');
00081 
00082         $newitemid = $DB->insert_record('scorm_scoes', $data);
00083         $this->set_mapping('scorm_sco', $oldid, $newitemid);
00084     }
00085 
00086     protected function process_scorm_sco_data($data) {
00087         global $DB;
00088 
00089         $data = (object)$data;
00090         $oldid = $data->id;
00091         $data->scoid = $this->get_new_parentid('scorm_sco');
00092 
00093         $newitemid = $DB->insert_record('scorm_scoes_data', $data);
00094         // No need to save this mapping as far as nothing depend on it
00095         // (child paths, file areas nor links decoder)
00096     }
00097 
00098     protected function process_scorm_seq_objective($data) {
00099         global $DB;
00100 
00101         $data = (object)$data;
00102         $oldid = $data->id;
00103         $data->scoid = $this->get_new_parentid('scorm_sco');
00104 
00105         $newitemid = $DB->insert_record('scorm_seq_objective', $data);
00106         $this->set_mapping('scorm_seq_objective', $oldid, $newitemid);
00107     }
00108 
00109     protected function process_scorm_seq_rolluprule($data) {
00110         global $DB;
00111 
00112         $data = (object)$data;
00113         $oldid = $data->id;
00114         $data->scoid = $this->get_new_parentid('scorm_sco');
00115 
00116         $newitemid = $DB->insert_record('scorm_seq_rolluprule', $data);
00117         $this->set_mapping('scorm_seq_rolluprule', $oldid, $newitemid);
00118     }
00119 
00120     protected function process_scorm_seq_rolluprulecond($data) {
00121         global $DB;
00122 
00123         $data = (object)$data;
00124         $oldid = $data->id;
00125         $data->scoid = $this->get_new_parentid('scorm_sco');
00126         $data->ruleconditions = $this->get_new_parentid('scorm_seq_rolluprule');
00127 
00128         $newitemid = $DB->insert_record('scorm_seq_rolluprulecond', $data);
00129         // No need to save this mapping as far as nothing depend on it
00130         // (child paths, file areas nor links decoder)
00131     }
00132 
00133     protected function process_scorm_seq_rulecond($data) {
00134         global $DB;
00135 
00136         $data = (object)$data;
00137         $oldid = $data->id;
00138         $data->scoid = $this->get_new_parentid('scorm_sco');
00139 
00140         $newitemid = $DB->insert_record('scorm_seq_ruleconds', $data);
00141         $this->set_mapping('scorm_seq_ruleconds', $oldid, $newitemid);
00142     }
00143 
00144     protected function process_scorm_seq_rulecond_data($data) {
00145         global $DB;
00146 
00147         $data = (object)$data;
00148         $oldid = $data->id;
00149         $data->scoid = $this->get_new_parentid('scorm_sco');
00150         $data->ruleconditions = $this->get_new_parentid('scorm_seq_ruleconds');
00151 
00152         $newitemid = $DB->insert_record('scorm_seq_rulecond', $data);
00153         // No need to save this mapping as far as nothing depend on it
00154         // (child paths, file areas nor links decoder)
00155     }
00156 
00157 
00158 
00159     protected function process_scorm_seq_mapinfo($data) {
00160         global $DB;
00161 
00162         $data = (object)$data;
00163         $oldid = $data->id;
00164         $data->scoid = $this->get_new_parentid('scorm_sco');
00165         $data->objectiveid = $this->get_new_parentid('scorm_seq_objective');
00166         $newitemid = $DB->insert_record('scorm_scoes_data', $data);
00167         // No need to save this mapping as far as nothing depend on it
00168         // (child paths, file areas nor links decoder)
00169     }
00170 
00171     protected function process_scorm_sco_track($data) {
00172         global $DB;
00173 
00174         $data = (object)$data;
00175         $oldid = $data->id;
00176         $data->scormid = $this->get_new_parentid('scorm');
00177         $data->scoid = $this->get_new_parentid('scorm_sco');
00178         $data->userid = $this->get_mappingid('user', $data->userid);
00179         $data->timemodified = $this->apply_date_offset($data->timemodified);
00180 
00181         $newitemid = $DB->insert_record('scorm_scoes_track', $data);
00182         // No need to save this mapping as far as nothing depend on it
00183         // (child paths, file areas nor links decoder)
00184     }
00185 
00186     protected function after_execute() {
00187         // Add scorm related files, no need to match by itemname (just internally handled context)
00188         $this->add_related_files('mod_scorm', 'intro', null);
00189         $this->add_related_files('mod_scorm', 'content', null);
00190         $this->add_related_files('mod_scorm', 'package', null);
00191     }
00192 }
 All Data Structures Namespaces Files Functions Variables Enumerations