ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilScorm2004DataSet.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
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  {
67  $ilDB = $this->db;
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  // * Determine the dependent sets of data
96  // * @return mixed[]
97  // */
98  // protected function getDependencies(
99  // string $a_entity,
100  // string $a_version,
101  // ?array $a_rec = null,
102  // ?array $a_ids = null
103  // ) : array {
104  // switch ($a_entity) {
105  // case "sahs":
106  // return array();
107  //
108  // }
109  // return [];
110  // }
111 
112  // /**
113  // * Get xml record
114  // * @param string $a_entity
115  // * @param string $a_version
116  // * @param array $a_set
117  // * @return array
118  // * @throws ilFileUtilsException
119  // */
120  // public function getXmlRecord(string $a_entity, string $a_version, array $a_set) : array
121  // {
122  // if ($a_entity == "sahs") {
123  // // build traditional author export file
124  // $lm = new ilObjSCORM2004LearningModule($a_set["Id"], false);
125  // $export = new ilScorm2004Export($lm, 'SCORM 2004 3rd');
126  // $zip = $export->buildExportFile();
127  //
128  // // move it to temp dir
129  // $tmpdir = ilFileUtils::ilTempnam();
130  // ilFileUtils::makeDir($tmpdir);
131  // $exp_temp = $tmpdir . DIRECTORY_SEPARATOR . basename($zip);
132  // ilFileUtils::rename($zip, $exp_temp);
133  //
134  // $this->temp_dir[$a_set["Id"]] = $tmpdir;
135  //
136  // // include temp dir
137  // $a_set["Dir"] = $tmpdir;
138  // $a_set["File"] = basename($zip);
139  // }
140  //
141  // return $a_set;
142  // }
143 
144  public function afterXmlRecordWriting(string $a_entity, string $a_version, array $a_set): void
145  {
146  if ($a_entity === "sahs") {
147  // delete our temp dir
148  if (isset($this->temp_dir[$a_set["Id"]]) && is_dir($this->temp_dir[$a_set["Id"]])) {
149  ilFileUtils::delDir($this->temp_dir[$a_set["Id"]]);
150  }
151  }
152  }
153 
154 
155  // /**
156  // * Import record
157  // * @param string $a_entity
158  // * @param array $a_types
159  // * @param array $a_rec
160  // * @param ilImportMapping $a_mapping
161  // * @param string $a_schema_version
162  // */
163  // public function importRecord(
164  // string $a_entity,
165  // array $a_types,
166  // array $a_rec,
167  // ilImportMapping $a_mapping,
168  // string $a_schema_version
169  // ) : void {
170  // switch ($a_entity) {
171  // case "sahs":
172  // $new_obj_id = $a_mapping->getMapping("components/ILIAS/Container", "objs", $a_rec["Id"]);
173  // $lm = new ilObjSCORM2004LearningModule($new_obj_id, false);
174  //
176  // $lm->setImportSequencing(false);
177  // $lm->setSequencingExpertMode(false);
178  // $lm->setSubType("scorm2004");
179  //
180  // $dir = str_replace("..", "", $a_rec["Dir"]);
181  // if ($dir != "" && $this->getImportDirectory() != "") {
182  // $source_dir = $this->getImportDirectory() . "/" . $dir;
183  // $file_path = $lm->getDataDirectory() . "/" . $a_rec["File"];
184  // ilFileUtils::rename($source_dir . "/" . $a_rec["File"], $file_path);
185  //
186  // ilFileUtils::unzip($file_path);
187  // ilFileUtils::renameExecutables($lm->getDataDirectory());
188  // $title = $lm->readObject();
189  // if ($title != "") {
190  // ilObject::_writeTitle($lm->getId(), $title);
191  // }
192  //
193  // $lm->setLearningProgressSettingsAtUpload();
194  // $lm->update();
195  // }
196  // break;
197  //
198  // }
199  // }
200 }
Class ilScorm2004DataSet.
readData(string $a_entity, string $a_version, array $a_ids)
getTypes(string $a_entity, string $a_version)
ilDBInterface $db
static _lookupTitle(int $obj_id)
static delDir(string $a_dir, bool $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static _lookupDescription(int $obj_id)
afterXmlRecordWriting(string $a_entity, string $a_version, array $a_set)
Determine the dependent sets of data.
getSupportedVersions()
Note: this is currently used for SCORM authoring lms Get supported versions.
getXmlNamespace(string $a_entity, string $a_schema_version)
static _lookupType(int $id, bool $reference=false)