19 declare(strict_types=1);
45 $this->module_properties = [];
62 public function init(): void
81 $xml_directory = $a_xml;
86 ->ok(
'Parsing started')
95 $a_mapping !==
null &&
96 ($new_id = $a_mapping->
getMapping(
'Services/Container',
'objs', $a_id))) {
101 return $this->df->ok($xml_directory);
105 if (!is_dir($xml_directory)) {
106 return $this->df->
error(
107 sprintf(
'Directory lost while importing: %s', $xml_directory)
114 $manifest_file = $xml_directory .
'/manifest.xml';
115 if (!file_exists($manifest_file)) {
116 return $this->df->
error(
118 'No manifest file found in import directory "%s": %s',
125 return $this->df->ok($manifest_file);
128 $manifest_file_content = file_get_contents($manifest_file);
129 if (!is_string($manifest_file_content) || $manifest_file_content ===
'') {
130 return $this->df->error(
132 'Could not read content from manifest file: %s',
138 return $this->df->ok($manifest_file_content);
140 ->then(
function (
string $manifest_file_content) use ($xml_directory): ?
\ILIAS\Data\Result {
141 $properties_file = $xml_directory .
'/properties.xml';
142 $properties_file_content = file_get_contents($properties_file);
143 if (!is_string($properties_file_content) || $properties_file_content ===
'') {
144 return $this->df->error(
146 'Could not read file: %s',
152 return $this->df->ok($properties_file_content);
160 foreach ($this->dataset->properties as $key => $value) {
161 $this->module_properties[$key] = $properties_xml_doc->{$key};
164 $this->module_properties[
'Title'] = $properties_xml_doc->Title;
165 $this->module_properties[
'Description'] = $properties_xml_doc->Description;
167 foreach ($this->module_properties as $key => $property_node) {
168 $property_value = $property_node->__toString();
169 $filteredValue = preg_replace(
'%\s%',
'', $property_value);
173 return $this->df->ok($this->module_properties);
175 return $this->df->error($exception);
178 )->then(
function (array $module_properties) use (
186 $a_mapping !==
null &&
187 ($new_id = $a_mapping->getMapping(
188 'Services/Container',
192 $this->dataset->writeData(
195 $new_object->getId(),
199 $new_object->createReference();
201 $scormFile =
'content.zip';
202 $scormFilePath = $xml_directory .
'/' . $scormFile;
203 $targetPath = $new_object->getDataDirectory() .
'/' . $scormFile;
204 $file_path = $targetPath;
207 $DIC->legacyArchives()->unzip($file_path);
211 $new_ref_id = $new_object->getRefId();
212 $subType = $module_properties[
'SubType'];
213 if ($subType ===
'scorm') {
219 $title = $new_object->readObject();
220 $new_object->setLearningProgressSettingsAtUpload();
228 public function writeData(
string $a_entity,
string $a_version,
int $a_id): void
230 $this->dataset->writeData($a_entity, $a_version, $a_id, $this->module_properties);
Interface Observer Contains several chained tasks and infos about them.
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
publishResult(\ILIAS\Data\Result $result)
importXmlRepresentation(string $a_entity, string $a_id, string $a_xml, ?ilImportMapping $a_mapping)
A result encapsulates a value or an error and simplifies the handling of those.
ILIAS Data Result $result
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static renameExecutables(string $a_dir)
ilScormAiccDataSet $dataset
getMapping(string $a_comp, string $a_entity, string $a_old_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
writeData(string $a_entity, string $a_version, int $a_id)
error()
Get the encapsulated error.
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
__construct(Container $dic, ilPlugin $plugin)
Class ilObjSCORM2004LearningModule.
static rename(string $a_source, string $a_target)
Class ilObjSCORMLearningModule.