ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
ilSCORMPackageParser Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilSCORMPackageParser:
+ Collaboration diagram for ilSCORMPackageParser:

Public Member Functions

 __construct (object $a_slm_object, string $a_xml_file)
 Constructor. More...
 
 setHandlers ($a_xml_parser)
 set event handler should be overwritten by inherited class More...
 
 startParsing ()
 
 getPackageTitle ()
 
 beginElement (string $a_name)
 update parsing status for a element begin More...
 
 endElement (string $a_name)
 update parsing status for an element ending More...
 
 getCurrentElement ()
 returns current element More...
 
 getAncestorElement (int $nr=1)
 
 buildTag (string $type, string $name, ?array $attr=null)
 generate a tag with given name and attributes More...
 
 getCurrentParent ()
 
 handlerBeginTag ($a_xml_parser, string $a_name, array $a_attribs)
 handler for begin of element More...
 
 handlerEndTag ($a_xml_parser, string $a_name)
 handler for end of element More...
 
 handlerCharacterData ($a_xml_parser, ?string $a_data)
 handler for character data More...
 
- Public Member Functions inherited from ilSaxParser
 __construct (?string $path_to_file='', ?bool $throw_exception=false)
 
 setXMLContent (string $a_xml_content)
 
 getXMLContent ()
 
 getInputType ()
 
 startParsing ()
 stores xml data in array More...
 
 createParser ()
 
 setHandlers ($a_xml_parser)
 
 parse ($a_xml_parser, $a_fp=null)
 

Data Fields

array $current_element
 
object $slm_object
 
array $parent_stack
 
bool $tree_created
 
object $scorm_tree
 
object $current_organization
 
object $current_resource
 
array $item_stack
 
string $package_title = ""
 
- Data Fields inherited from ilSaxParser
string $xml_file
 
bool $throw_exception = false
 

Private Attributes

ilSCORMTree $sc_tree
 

Additional Inherited Members

- Protected Member Functions inherited from ilSaxParser
 openXMLFile ()
 
 handleError (string $message)
 
 setThrowException (bool $throw_exception)
 
- Protected Attributes inherited from ilSaxParser
ilLanguage $lng = null
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning SCORM Package Parser

Author
Version
$Id$

Definition at line 28 of file class.ilSCORMPackageParser.php.

Constructor & Destructor Documentation

◆ __construct()

ilSCORMPackageParser::__construct ( object  $a_slm_object,
string  $a_xml_file 
)

Constructor.

Parameters
object$a_lm_objectmust be of type ilObjLearningModule
string$a_xml_filexml file

Definition at line 47 of file class.ilSCORMPackageParser.php.

48 {
49 parent::__construct($a_xml_file);
50 // $this->cnt = array();
51 $this->current_element = array();
52 $this->slm_object = $a_slm_object;
53 $this->tree_created = false;
54 $this->parent_stack = array();
55 $this->item_stack = array();
56 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ beginElement()

ilSCORMPackageParser::beginElement ( string  $a_name)

update parsing status for a element begin

Definition at line 88 of file class.ilSCORMPackageParser.php.

88 : void
89 {
90 // if (!isset($this->status["$a_name"])) {
91 // $this->cnt[$a_name] == 1;
92 // } else {
93 // $this->cnt[$a_name]++;
94 // }
95 $this->current_element[count($this->current_element)] = $a_name;
96 }

Referenced by handlerBeginTag().

+ Here is the caller graph for this function:

◆ buildTag()

ilSCORMPackageParser::buildTag ( string  $type,
string  $name,
?array  $attr = null 
)

generate a tag with given name and attributes

Definition at line 135 of file class.ilSCORMPackageParser.php.

135 : string
136 {
137 $tag = "<";
138
139 if ($type === "end") {
140 $tag .= "/";
141 }
142
143 $tag .= $name;
144
145 if (is_array($attr)) {
146 foreach ($attr as $k => $v) {
147 $tag .= " " . $k . "=\"$v\"";
148 }
149 }
150
151 $tag .= ">";
152
153 return $tag;
154 }
if($format !==null) $name
Definition: metadata.php:247
$type

References $name, and $type.

◆ endElement()

ilSCORMPackageParser::endElement ( string  $a_name)

update parsing status for an element ending

Definition at line 101 of file class.ilSCORMPackageParser.php.

101 : void
102 {
103 // $this->cnt[$a_name]--;
104 unset($this->current_element[count($this->current_element) - 1]);
105 }

Referenced by handlerEndTag().

+ Here is the caller graph for this function:

◆ getAncestorElement()

ilSCORMPackageParser::getAncestorElement ( int  $nr = 1)

Definition at line 115 of file class.ilSCORMPackageParser.php.

115 : ?string
116 {
117 return ($this->current_element[count($this->current_element) - 1 - $nr]);
118 }

Referenced by handlerCharacterData().

+ Here is the caller graph for this function:

◆ getCurrentElement()

ilSCORMPackageParser::getCurrentElement ( )

returns current element

Definition at line 110 of file class.ilSCORMPackageParser.php.

110 : ?string
111 {
112 return ($this->current_element[count($this->current_element) - 1]);
113 }

Referenced by handlerCharacterData().

+ Here is the caller graph for this function:

◆ getCurrentParent()

ilSCORMPackageParser::getCurrentParent ( )

Definition at line 156 of file class.ilSCORMPackageParser.php.

156 : int
157 {
158 return $this->parent_stack[count($this->parent_stack) - 1];
159 }

◆ getPackageTitle()

ilSCORMPackageParser::getPackageTitle ( )

Definition at line 80 of file class.ilSCORMPackageParser.php.

80 : string
81 {
82 return ilUtil::stripSlashes($this->package_title);
83 }
static stripSlashes(string $a_str, bool $a_strip_html=true, string $a_allow="")

References ilUtil\stripSlashes().

+ Here is the call graph for this function:

◆ handlerBeginTag()

ilSCORMPackageParser::handlerBeginTag (   $a_xml_parser,
string  $a_name,
array  $a_attribs 
)

handler for begin of element

Parameters
resource | XMLParser$a_xml_parser
string$a_name
array$a_attribs
Returns
void

Definition at line 168 of file class.ilSCORMPackageParser.php.

168 : void
169 {
170 //echo "<br>handlerBeginTag:".$a_name;
171 switch ($a_name) {
172 case "manifest":
173 $mVersion = "";
174 if (isset($a_attribs["version"])) {
175 $mVersion = $a_attribs["version"];
176 }
177 $manifest = new ilSCORMManifest();
178 $manifest->setSLMId($this->slm_object->getId());
179 $manifest->setImportId($a_attribs["identifier"]);
180 $manifest->setVersion($mVersion);
181 if (isset($a_attribs["xml:base"])) {
182 $manifest->setXmlBase($a_attribs["xml:base"]);
183 }
184 $manifest->create();
185 if (!$this->tree_created) {
186 $this->sc_tree = new ilSCORMTree($this->slm_object->getId());
187 $this->sc_tree->addTree($this->slm_object->getId(), $manifest->getId());
188 } else {
189 $this->sc_tree->insertNode($manifest->getId(), $this->getCurrentParent());
190 }
191 $this->parent_stack[] = $manifest->getId();
192 break;
193
194 case "organizations":
195 $organizations = new ilSCORMOrganizations();
196 $organizations->setSLMId($this->slm_object->getId());
197 if (isset($a_attribs["default"])) {
198 $organizations->setDefaultOrganization($a_attribs["default"]);
199 } else {
200 $organizations->setDefaultOrganization("");
201 }
202 $organizations->create();
203 $this->sc_tree->insertNode($organizations->getId(), $this->getCurrentParent());
204 $this->parent_stack[] = $organizations->getId();
205 break;
206
207 case "organization":
208 $organization = new ilSCORMOrganization();
209 $organization->setSLMId($this->slm_object->getId());
210 $organization->setImportId($a_attribs["identifier"]);
211 if (isset($a_attribs["structure"])) {
212 $organization->setStructure($a_attribs["structure"]);
213 }
214 $organization->create();
215 $this->current_organization = &$organization;
216 $this->sc_tree->insertNode($organization->getId(), $this->getCurrentParent());
217 $this->parent_stack[] = $organization->getId();
218 break;
219
220 case "item":
221 $item = new ilSCORMItem();
222 $item->setSLMId($this->slm_object->getId());
223 $item->setImportId($a_attribs["identifier"]);
224 $item->setIdentifierRef($a_attribs["identifierref"]);
225 if (isset($a_attribs["isvisible"])) {
226 if (strtolower((string) $a_attribs["isvisible"]) !== "false") {
227 $item->setVisible(true);
228 } else {
229 $item->setVisible(false);
230 }
231 }
232 if (isset($a_attribs["parameters"])) {
233 $item->setParameters($a_attribs["parameters"]);
234 }
235 $item->create();
236 $this->sc_tree->insertNode($item->getId(), $this->getCurrentParent());
237 $this->parent_stack[] = $item->getId();
238 $this->item_stack[count($this->item_stack)] = &$item;
239 break;
240
241 case "adlcp:prerequisites":
242 $this->item_stack[count($this->item_stack) - 1]->setPrereqType($a_attribs["type"]);
243 break;
244
245 case "resources":
247 $resources->setSLMId($this->slm_object->getId());
248 if (isset($a_attribs["xml:base"])) {
249 $resources->setXmlBase($a_attribs["xml:base"]);
250 }
251 $resources->create();
252 $this->sc_tree->insertNode($resources->getId(), $this->getCurrentParent());
253 $this->parent_stack[] = $resources->getId();
254 break;
255
256 case "resource":
257 $resource = new ilSCORMResource();
258 $resource->setSLMId($this->slm_object->getId());
259 $resource->setImportId($a_attribs["identifier"]);
260 $resource->setResourceType($a_attribs["type"]);
261 if (isset($a_attribs["adlcp:scormtype"])) {
262 $resource->setScormType($a_attribs["adlcp:scormtype"]);
263 }
264 if (isset($a_attribs["xml:base"])) {
265 $resource->setXmlBase($a_attribs["xml:base"]);
266 }
267 if (isset($a_attribs["href"])) {
268 $resource->setHRef($a_attribs["href"]);
269 }
270 $resource->create();
271 $this->current_resource = &$resource;
272 $this->sc_tree->insertNode($resource->getId(), $this->getCurrentParent());
273 $this->parent_stack[] = $resource->getId();
274 break;
275
276 case "file":
277 $file = new ilSCORMResourceFile();
278 $file->setHRef($a_attribs["href"]);
279 $this->current_resource->addFile($file);
280 break;
281
282 case "dependency":
283 $dependency = new ilSCORMResourceDependency();
284 $dependency->setIdentifierRef($a_attribs["identifierref"]);
285 $this->current_resource->addDependency($dependency);
286 break;
287
288 }
289 $this->beginElement($a_name);
290 }
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...
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...
beginElement(string $a_name)
update parsing status for a element begin
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...
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$resources
Definition: ltiservices.php:68

References $resources, and beginElement().

+ Here is the call graph for this function:

◆ handlerCharacterData()

ilSCORMPackageParser::handlerCharacterData (   $a_xml_parser,
?string  $a_data 
)

handler for character data

Parameters
resource | XMLParser$a_xml_parser
string | null$a_data
Returns
void

Definition at line 335 of file class.ilSCORMPackageParser.php.

335 : void
336 {
337 //echo "<br>handlerCharacterData:".$this->getCurrentElement().":".$a_data;
338 // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
339 $a_data = preg_replace("/\n/", "", $a_data);
340 $a_data = preg_replace("/\t+/", "", $a_data);
341 if (!empty($a_data)) {
342 switch ($this->getCurrentElement()) {
343 case "title":
344 switch ($this->getAncestorElement(1)) {
345 case "organization":
346 $this->current_organization->setTitle(
347 ilUtil::stripSlashes($this->current_organization->getTitle() . $a_data)
348 );
349 $this->package_title = ilUtil::stripSlashes($this->current_organization->getTitle());
350 break;
351
352 case "item":
353 $this->item_stack[count($this->item_stack) - 1]->setTitle(
354 ilUtil::stripSlashes($this->item_stack[count($this->item_stack) - 1]->getTitle() . $a_data)
355 );
356 break;
357 }
358 break;
359
360 case "adlcp:prerequisites":
361 $this->item_stack[count($this->item_stack) - 1]->setPrerequisites($a_data);
362 break;
363
364 case "adlcp:maxtimeallowed":
365 $this->item_stack[count($this->item_stack) - 1]->setMaxTimeAllowed($a_data);
366 break;
367
368 case "adlcp:timelimitaction":
369 $this->item_stack[count($this->item_stack) - 1]->setTimeLimitAction($a_data);
370 break;
371
372 case "adlcp:datafromlms":
373 $this->item_stack[count($this->item_stack) - 1]->setDataFromLms($a_data);
374 break;
375
376 case "adlcp:masteryscore":
377 $this->item_stack[count($this->item_stack) - 1]->setMasteryScore($a_data);
378 break;
379
380 }
381 }
382 }
getCurrentElement()
returns current element

References getAncestorElement(), getCurrentElement(), and ilUtil\stripSlashes().

+ Here is the call graph for this function:

◆ handlerEndTag()

ilSCORMPackageParser::handlerEndTag (   $a_xml_parser,
string  $a_name 
)

handler for end of element

Parameters
resource | XMLParser$a_xml_parser
string$a_name
Returns
void

Definition at line 298 of file class.ilSCORMPackageParser.php.

298 : void
299 {
300 //echo "<br>handlerEndTag:".$a_name;
301
302 switch ($a_name) {
303 case "manifest":
304 case "organizations":
305 case "resources":
306 array_pop($this->parent_stack);
307 break;
308
309 case "organization":
310 $this->current_organization->update();
311 array_pop($this->parent_stack);
312 break;
313
314 case "item":
315 $this->item_stack[count($this->item_stack) - 1]->update();
316 unset($this->item_stack[count($this->item_stack) - 1]);
317 array_pop($this->parent_stack);
318 break;
319
320 case "resource":
321 $this->current_resource->update();
322 array_pop($this->parent_stack);
323 break;
324
325 }
326 $this->endElement($a_name);
327 }
endElement(string $a_name)
update parsing status for an element ending

References endElement().

+ Here is the call graph for this function:

◆ setHandlers()

ilSCORMPackageParser::setHandlers (   $a_xml_parser)

set event handler should be overwritten by inherited class

Parameters
resource | XMLParser$a_xml_parser
Returns
void

Reimplemented from ilSaxParser.

Definition at line 65 of file class.ilSCORMPackageParser.php.

65 : void
66 {
67 xml_set_object($a_xml_parser, $this);
68 xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
69 xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
70 }

◆ startParsing()

ilSCORMPackageParser::startParsing ( )
Exceptions
ilSaxParserException

Reimplemented from ilSaxParser.

Definition at line 75 of file class.ilSCORMPackageParser.php.

75 : void
76 {
77 parent::startParsing();
78 }

Field Documentation

◆ $current_element

array ilSCORMPackageParser::$current_element

Definition at line 32 of file class.ilSCORMPackageParser.php.

◆ $current_organization

object ilSCORMPackageParser::$current_organization

Definition at line 37 of file class.ilSCORMPackageParser.php.

◆ $current_resource

object ilSCORMPackageParser::$current_resource

Definition at line 38 of file class.ilSCORMPackageParser.php.

◆ $item_stack

array ilSCORMPackageParser::$item_stack

Definition at line 39 of file class.ilSCORMPackageParser.php.

◆ $package_title

string ilSCORMPackageParser::$package_title = ""

Definition at line 40 of file class.ilSCORMPackageParser.php.

◆ $parent_stack

array ilSCORMPackageParser::$parent_stack

Definition at line 34 of file class.ilSCORMPackageParser.php.

◆ $sc_tree

ilSCORMTree ilSCORMPackageParser::$sc_tree
private

Definition at line 30 of file class.ilSCORMPackageParser.php.

◆ $scorm_tree

object ilSCORMPackageParser::$scorm_tree

Definition at line 36 of file class.ilSCORMPackageParser.php.

◆ $slm_object

object ilSCORMPackageParser::$slm_object

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

◆ $tree_created

bool ilSCORMPackageParser::$tree_created

Definition at line 35 of file class.ilSCORMPackageParser.php.


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