ILIAS  release_8 Revision v8.24
class.ilScorm2004DataSet.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
26{
27 protected array $temp_dir = array();
28
34 public function getSupportedVersions(): array
35 {
36 return array("5.1.0");
37 }
38
39 public function getXmlNamespace(string $a_entity, string $a_schema_version): string
40 {
41 return "http://www.ilias.de/xml/Modules/Scorm2004/" . $a_entity;
42 }
43
47 protected function getTypes(string $a_entity, string $a_version): array
48 {
49 if ($a_entity === "sahs") {
50 switch ($a_version) {
51 case "5.1.0":
52 return array(
53 "Id" => "integer",
54 "Title" => "text",
55 "Description" => "text",
56 "Editable" => "integer",
57 "Dir" => "directory",
58 "File" => "text"
59 );
60 }
61 }
62 return [];
63 }
64
65 public function readData(string $a_entity, string $a_version, array $a_ids): void
66 {
68
69 if (!is_array($a_ids)) {
70 $a_ids = array($a_ids);
71 }
72
73 // sahs
74 if ($a_entity === "sahs") {
75 $this->data = array();
76
77 switch ($a_version) {
78 case "5.1.0":
79 foreach ($a_ids as $sahs_id) {
80 if (ilObject::_lookupType((int) $sahs_id) === "sahs") {
81 $this->data[] = array("Id" => $sahs_id,
82 "Title" => ilObject::_lookupTitle((int) $sahs_id),
83 "Description" => ilObject::_lookupDescription((int) $sahs_id),
84 "Editable" => 1
85 );
86 }
87 }
88 break;
89
90 }
91 }
92 }
93
94
95// /**
96// * Determine the dependent sets of data
97// * @return mixed[]
98// */
99// protected function getDependencies(
100// string $a_entity,
101// string $a_version,
102// ?array $a_rec = null,
103// ?array $a_ids = null
104// ) : array {
105// switch ($a_entity) {
106// case "sahs":
107// return array();
108//
109// }
110// return [];
111// }
112
113// /**
114// * Get xml record
115// * @param string $a_entity
116// * @param string $a_version
117// * @param array $a_set
118// * @return array
119// * @throws ilFileUtilsException
120// */
121// public function getXmlRecord(string $a_entity, string $a_version, array $a_set) : array
122// {
123// if ($a_entity == "sahs") {
124// // build traditional author export file
125// $lm = new ilObjSCORM2004LearningModule($a_set["Id"], false);
126// $export = new ilScorm2004Export($lm, 'SCORM 2004 3rd');
127// $zip = $export->buildExportFile();
128//
129// // move it to temp dir
130// $tmpdir = ilFileUtils::ilTempnam();
131// ilFileUtils::makeDir($tmpdir);
132// $exp_temp = $tmpdir . DIRECTORY_SEPARATOR . basename($zip);
133// ilFileUtils::rename($zip, $exp_temp);
134//
135// $this->temp_dir[$a_set["Id"]] = $tmpdir;
136//
137// // include temp dir
138// $a_set["Dir"] = $tmpdir;
139// $a_set["File"] = basename($zip);
140// }
141//
142// return $a_set;
143// }
144
145 public function afterXmlRecordWriting(string $a_entity, string $a_version, array $a_set): void
146 {
147 if ($a_entity === "sahs") {
148 // delete our temp dir
149 if (isset($this->temp_dir[$a_set["Id"]]) && is_dir($this->temp_dir[$a_set["Id"]])) {
150 ilFileUtils::delDir($this->temp_dir[$a_set["Id"]]);
151 }
152 }
153 }
154
155
156// /**
157// * Import record
158// * @param string $a_entity
159// * @param array $a_types
160// * @param array $a_rec
161// * @param ilImportMapping $a_mapping
162// * @param string $a_schema_version
163// */
164// public function importRecord(
165// string $a_entity,
166// array $a_types,
167// array $a_rec,
168// ilImportMapping $a_mapping,
169// string $a_schema_version
170// ) : void {
171// switch ($a_entity) {
172// case "sahs":
173// $new_obj_id = $a_mapping->getMapping("Services/Container", "objs", $a_rec["Id"]);
174// $lm = new ilObjSCORM2004LearningModule($new_obj_id, false);
175//
177// $lm->setImportSequencing(false);
178// $lm->setSequencingExpertMode(false);
179// $lm->setSubType("scorm2004");
180//
181// $dir = str_replace("..", "", $a_rec["Dir"]);
182// if ($dir != "" && $this->getImportDirectory() != "") {
183// $source_dir = $this->getImportDirectory() . "/" . $dir;
184// $file_path = $lm->getDataDirectory() . "/" . $a_rec["File"];
185// ilFileUtils::rename($source_dir . "/" . $a_rec["File"], $file_path);
186//
187// ilFileUtils::unzip($file_path);
188// ilFileUtils::renameExecutables($lm->getDataDirectory());
189// $title = $lm->readObject();
190// if ($title != "") {
191// ilObject::_writeTitle($lm->getId(), $title);
192// }
193//
194// $lm->setLearningProgressSettingsAtUpload();
195// $lm->update();
196// }
197// break;
198//
199// }
200// }
201}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilDBInterface $db
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static _lookupType(int $id, bool $reference=false)
static _lookupTitle(int $obj_id)
static _lookupDescription(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
readData(string $a_entity, string $a_version, array $a_ids)
Read data from DB.
afterXmlRecordWriting(string $a_entity, string $a_version, array $a_set)
getSupportedVersions()
Note: this is currently used for SCORM authoring lms Get supported versions.
getXmlNamespace(string $a_entity, string $a_schema_version)
getTypes(string $a_entity, string $a_version)