ILIAS  release_8 Revision v8.24
ilScormAiccImporter Class Reference
+ Inheritance diagram for ilScormAiccImporter:
+ Collaboration diagram for ilScormAiccImporter:

Public Member Functions

 __construct ()
 
 getResult ()
 
 init ()
 
 importXmlRepresentation (string $a_entity, string $a_id, string $a_xml, ?ilImportMapping $a_mapping)
 
 writeData (string $a_entity, string $a_version, int $a_id)
 
- Public Member Functions inherited from ilXmlImporter
 __construct ()
 
 setImport (ilImport $a_val)
 
 getImport ()
 
 init ()
 
 setInstallId (string $a_val)
 
 getInstallId ()
 
 setInstallUrl (string $a_val)
 
 getInstallUrl ()
 
 setSchemaVersion (string $a_val)
 
 getSchemaVersion ()
 
 setImportDirectory (string $a_val)
 
 getImportDirectory ()
 
 setSkipEntities (array $a_val)
 
 getSkipEntities ()
 
 exportedFromSameInstallation ()
 
 importXmlRepresentation (string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping)
 
 finalProcessing (ilImportMapping $a_mapping)
 
 afterContainerImportProcessing (ilImportMapping $mapping)
 

Private Member Functions

 initResult ()
 
 publishResult (\ILIAS\Data\Result $result)
 

Private Attributes

ilScormAiccDataSet $dataset
 
ILIAS Data Result $result
 
DataTypeFactory $df
 
array $module_properties = []
 

Additional Inherited Members

- Protected Attributes inherited from ilXmlImporter
array $skip_entities = array()
 
ilImport $imp
 
string $install_id
 
string $install_url
 
string $schema_version
 
string $import_directory
 

Detailed Description

Definition at line 23 of file class.ilScormAiccImporter.php.

Constructor & Destructor Documentation

◆ __construct()

ilScormAiccImporter::__construct ( )

Reimplemented from ilXmlImporter.

Definition at line 33 of file class.ilScormAiccImporter.php.

34 {
35 $this->dataset = new ilScormAiccDataSet();
36 $this->df = new DataTypeFactory();
37 $this->initResult();
38
40 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct(), and initResult().

+ Here is the call graph for this function:

Member Function Documentation

◆ getResult()

ilScormAiccImporter::getResult ( )
Returns
\ILIAS\Data\Result|\ILIAS\Data\Result\Ok<array<string, string|SimpleXMLElement>>

Definition at line 57 of file class.ilScormAiccImporter.php.

58 {
59 return $this->result;
60 }
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Result.php:15

References $result.

◆ importXmlRepresentation()

ilScormAiccImporter::importXmlRepresentation ( string  $a_entity,
string  $a_id,
string  $a_xml,
?ilImportMapping  $a_mapping 
)
Exceptions
ilDatabaseException
ilFileUtilsException
ilObjectNotFoundException

Definition at line 71 of file class.ilScormAiccImporter.php.

76 : void {
77 global $DIC;
78
79 $this->initResult();
80
81 $xml_directory = $a_xml;
82 $new_object = null;
83
84 $this->publishResult(
85 $this->df
86 ->ok('Parsing started')
87 ->then(
88 function (string $message) use (
89 &$new_object,
90 &$xml_directory,
91 $a_id,
92 $a_mapping
93 ): ?\ILIAS\Data\Result {
94 if ($a_id !== '' &&
95 $a_mapping !== null &&
96 ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id))) {
97 $new_object = ilObjectFactory::getInstanceByObjId((int) $new_id, false);
98 $xml_directory = $this->getImportDirectory();
99 }
100
101 return $this->df->ok($xml_directory);
102 }
103 )
104 ->then(function (string $xml_directory): ?\ILIAS\Data\Result {
105 if (!is_dir($xml_directory)) {
106 return $this->df->error(
107 sprintf('Directory lost while importing: %s', $xml_directory)
108 );
109 }
110
111 return null;
112 })
113 ->then(function (string $xml_directory): ?\ILIAS\Data\Result {
114 $manifest_file = $xml_directory . '/manifest.xml';
115 if (!file_exists($manifest_file)) {
116 return $this->df->error(
117 sprintf(
118 'No manifest file found in import directory "%s": %s',
119 $xml_directory,
120 $manifest_file
121 )
122 );
123 }
124
125 return $this->df->ok($manifest_file);
126 })
127 ->then(function (string $manifest_file): ?\ILIAS\Data\Result {
128 $manifest_file_content = file_get_contents($manifest_file);
129 if (!is_string($manifest_file_content) || $manifest_file_content === '') {
130 return $this->df->error(
131 sprintf(
132 'Could not read content from manifest file: %s',
133 $manifest_file
134 )
135 );
136 }
137
138 return $this->df->ok($manifest_file_content);
139 })
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(
145 sprintf(
146 'Could not read file: %s',
147 $properties_file
148 )
149 );
150 }
151
152 return $this->df->ok($properties_file_content);
153 })
154 ->then(function (string $properties_file_content): ?\ILIAS\Data\Result {
155 return (new ilScormImportParser($this->df))->parse($properties_file_content);
156 })
157 ->then(
158 function (SimpleXMLElement $properties_xml_doc): ?\ILIAS\Data\Result {
159 try {
160 foreach ($this->dataset->properties as $key => $value) {
161 $this->module_properties[$key] = $properties_xml_doc->{$key};
162 }
163
164 $this->module_properties['Title'] = $properties_xml_doc->Title;
165 $this->module_properties['Description'] = $properties_xml_doc->Description;
166
167 foreach ($this->module_properties as $key => $property_node) {
168 $property_value = $property_node->__toString();
169 $filteredValue = preg_replace('%\s%', '', $property_value);
170 $this->module_properties[$key] = ilUtil::stripSlashes($filteredValue);
171 }
172
173 return $this->df->ok($this->module_properties);
174 } catch (Exception $exception) {
175 return $this->df->error($exception);
176 }
177 }
178 )->then(function (array $module_properties) use (
179 $xml_directory,
180 $a_id,
181 $a_mapping,
182 $new_object
183 ): ?\ILIAS\Data\Result {
184 if ($a_id !== '' &&
185 $a_mapping !== null &&
186 ($new_id = $a_mapping->getMapping(
187 'Services/Container',
188 'objs',
189 $a_id
190 ))) {
191 $this->dataset->writeData(
192 'sahs',
193 '5.1.0',
194 $new_object->getId(),
195 $this->module_properties
196 );
197
198 $new_object->createReference();
199
200 $scormFile = 'content.zip';
201 $scormFilePath = $xml_directory . '/' . $scormFile;
202 $targetPath = $new_object->getDataDirectory() . '/' . $scormFile;
203 $file_path = $targetPath;
204
205 ilFileUtils::rename($scormFilePath, $targetPath);
206 ilFileUtils::unzip($file_path);
207 unlink($file_path);
208 ilFileUtils::renameExecutables($new_object->getDataDirectory());
209
210 $new_ref_id = $new_object->getRefId();
211 $subType = $module_properties['SubType'];
212 if ($subType === 'scorm') {
213 $new_object = new ilObjSCORMLearningModule($new_ref_id);
214 } else {
215 $new_object = new ilObjSCORM2004LearningModule($new_ref_id);
216 }
217
218 $title = $new_object->readObject();
219 $new_object->setLearningProgressSettingsAtUpload();
220 }
221
222 return null;
223 })
224 );
225 }
static unzip(string $path_to_zip_file, bool $overwrite_existing=false, bool $unpack_flat=false)
static rename(string $a_source, string $a_target)
static renameExecutables(string $a_dir)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
publishResult(\ILIAS\Data\Result $result)
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
try
Definition: cron.php:23
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
global $DIC
Definition: feed.php:28
string $key
Consumer key/client ID value.
Definition: System.php:193
Class ChatMainBarProvider \MainMenu\Provider.
$message
Definition: xapiexit.php:32

◆ init()

ilScormAiccImporter::init ( )

Reimplemented from ilXmlImporter.

Definition at line 62 of file class.ilScormAiccImporter.php.

62 : void
63 {
64 }

◆ initResult()

ilScormAiccImporter::initResult ( )
private

Definition at line 42 of file class.ilScormAiccImporter.php.

42 : void
43 {
44 $this->publishResult($this->df->error('No XML parsed, yet'));
45 $this->module_properties = [];
46 }

References publishResult().

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ publishResult()

ilScormAiccImporter::publishResult ( \ILIAS\Data\Result  $result)
private

Definition at line 48 of file class.ilScormAiccImporter.php.

49 {
50 $this->result = $result;
51 return $this->result;
52 }

References $result.

Referenced by initResult().

+ Here is the caller graph for this function:

◆ writeData()

ilScormAiccImporter::writeData ( string  $a_entity,
string  $a_version,
int  $a_id 
)

Definition at line 227 of file class.ilScormAiccImporter.php.

227 : void
228 {
229 $this->dataset->writeData($a_entity, $a_version, $a_id, $this->module_properties);
230 }

Field Documentation

◆ $dataset

ilScormAiccDataSet ilScormAiccImporter::$dataset
private

Definition at line 25 of file class.ilScormAiccImporter.php.

◆ $df

DataTypeFactory ilScormAiccImporter::$df
private

Definition at line 27 of file class.ilScormAiccImporter.php.

◆ $module_properties

array ilScormAiccImporter::$module_properties = []
private

Definition at line 31 of file class.ilScormAiccImporter.php.

◆ $result

ILIAS Data Result ilScormAiccImporter::$result
private

Definition at line 26 of file class.ilScormAiccImporter.php.

Referenced by getResult(), and publishResult().


The documentation for this class was generated from the following file: