ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilScorm2004DataSet.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2016 ILIAS open source, Extended GPL, see docs/LICENSE */
3include_once("./Services/DataSet/classes/class.ilDataSet.php");
4
6{
7 protected $temp_dir = array();
8
16 public function getSupportedVersions()
17 {
18 return array("5.1.0");
19 }
20
27 public function getXmlNamespace($a_entity, $a_schema_version)
28 {
29 return "http://www.ilias.de/xml/Modules/Scorm2004/" . $a_entity;
30 }
31
38 protected function getTypes($a_entity, $a_version)
39 {
40 if ($a_entity == "sahs") {
41 switch ($a_version) {
42 case "5.1.0":
43 return array(
44 "Id" => "integer",
45 "Title" => "text",
46 "Description" => "text",
47 "Editable" => "integer",
48 "Dir" => "directory",
49 "File" => "text"
50 );
51 }
52 }
53 }
54
61 public function readData($a_entity, $a_version, $a_ids, $a_field = "")
62 {
64
65 if (!is_array($a_ids)) {
66 $a_ids = array($a_ids);
67 }
68
69 // sahs
70 if ($a_entity == "sahs") {
71 $this->data = array();
72
73 switch ($a_version) {
74 case "5.1.0":
75 foreach ($a_ids as $sahs_id) {
76 if (ilObject::_lookupType($sahs_id) == "sahs") {
77 $this->data[] = array("Id" => $sahs_id,
78 "Title" => ilObject::_lookupTitle($sahs_id),
79 "Description" => ilObject::_lookupDescription($sahs_id),
80 "Editable" => 1
81 );
82 }
83 }
84 break;
85
86 }
87 }
88 }
89
90
94 protected function getDependencies($a_entity, $a_version, $a_rec, $a_ids)
95 {
96 switch ($a_entity) {
97 case "sahs":
98 return array();
99
100 }
101 return false;
102 }
103
110 public function getXmlRecord($a_entity, $a_version, $a_set)
111 {
112 if ($a_entity == "sahs") {
113 // build traditional author export file
114 include_once './Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php';
115 $lm = new ilObjSCORM2004LearningModule($a_set["Id"], false);
116 $export = new ilScorm2004Export($lm, 'SCORM 2004 3rd');
117 $zip = $export->buildExportFile();
118
119 // move it to temp dir
120 $tmpdir = ilUtil::ilTempnam();
121 ilUtil::makeDir($tmpdir);
122 $exp_temp = $tmpdir . DIRECTORY_SEPARATOR . basename($zip);
123 ilFileUtils::rename($zip, $exp_temp);
124
125 $this->temp_dir[$a_set["Id"]] = $tmpdir;
126
127 // include temp dir
128 $a_set["Dir"] = $tmpdir;
129 $a_set["File"] = basename($zip);
130 }
131
132 return $a_set;
133 }
134
135
142 public function afterXmlRecordWriting($a_entity, $a_schema_version, $d)
143 {
144 if ($a_entity == "sahs") {
145 // delete our temp dir
146 if (isset($this->temp_dir[$d["Id"]]) && is_dir($this->temp_dir[$d["Id"]])) {
147 ilUtil::delDir($this->temp_dir[$d["Id"]]);
148 }
149 }
150 }
151
152
161 public function importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
162 {
163 switch ($a_entity) {
164 case "sahs":
165 $new_obj_id = $a_mapping->getMapping("Services/Container", "objs", $a_rec["Id"]);
166 include_once("./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php");
167 $lm = new ilObjSCORM2004LearningModule($new_obj_id, false);
168
169 $lm->setEditable($a_rec["Editable"]);
170 $lm->setImportSequencing(false);
171 $lm->setSequencingExpertMode(false);
172 $lm->setSubType("scorm2004");
173
174 $dir = str_replace("..", "", $a_rec["Dir"]);
175 if ($dir != "" && $this->getImportDirectory() != "") {
176 $source_dir = $this->getImportDirectory() . "/" . $dir;
177 $file_path = $lm->getDataDirectory() . "/" . $a_rec["File"];
178 ilFileUtils::rename($source_dir . "/" . $a_rec["File"], $file_path);
179
180 ilUtil::unzip($file_path);
181 ilUtil::renameExecutables($lm->getDataDirectory());
182 $title = $lm->readObject();
183 if ($title != "") {
184 ilObject::_writeTitle($lm->getId(), $title);
185 }
186
187 $lm->setLearningProgressSettingsAtUpload();
188 $lm->update();
189 }
190 break;
191
192 }
193 }
194}
An exception for terminatinating execution or to throw for unit testing.
A dataset contains in data in a common structure that can be shared and transformed for different pur...
getImportDirectory()
Get import directory.
static rename($a_source, $a_target)
Rename a file.
Class ilObjSCORM2004LearningModule.
static _lookupTitle($a_id)
lookup object title
static _lookupDescription($a_id)
lookup object description
static _writeTitle($a_obj_id, $a_title)
write title to db (static)
static _lookupType($a_id, $a_reference=false)
lookup object type
getTypes($a_entity, $a_version)
Get field types for entity.
getXmlRecord($a_entity, $a_version, $a_set)
Get xml record.
getXmlNamespace($a_entity, $a_schema_version)
Get xml namespace.
getSupportedVersions()
Note: this is currently used for SCORM authoring lms.
importRecord($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
Import record.
readData($a_entity, $a_version, $a_ids, $a_field="")
Read data.
afterXmlRecordWriting($a_entity, $a_schema_version, $d)
getDependencies($a_entity, $a_version, $a_rec, $a_ids)
Determine the dependent sets of data.
Export class for SCORM 2004 object.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static unzip(string $path_to_zip_file, bool $overwrite_existing=false, bool $unpack_flat=false)
static ilTempnam($a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
static makeDir($a_dir)
creates a new directory and inherits all filesystem permissions of the parent directory You may pass ...
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
global $ilDB