ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilScormAiccImporter.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2016 ILIAS open source, Extended GPL, see docs/LICENSE */
3 include_once("./Services/Export/classes/class.ilXmlImporter.php");
5 {
6  public function __construct()
7  {
8  require_once "./Modules/ScormAicc/classes/class.ilScormAiccDataSet.php";
9  $this->dataset = new ilScormAiccDataSet ();
10  //todo: at the moment restricted to one module in xml file, extend?
11  $this->moduleProperties = [];
12  $this->manifest = [];
13  }
14 
15  public function init()
16  {
17  }
18 
25  function importXmlRepresentation($a_entity, $a_id, $a_import_dirname, $a_mapping)
26  {
27  global $ilLog;
28  $result = false;
29  if (file_exists($a_import_dirname))
30  {
31  $manifestFile = $a_import_dirname . "/manifest.xml";
32  if (file_exists($manifestFile))
33  {
34  $manifest = file_get_contents ($manifestFile);
35  $manifestRoot = simplexml_load_string($manifest);
36  $this->manifest["scormFile"] = $manifestRoot->scormFile;
37  $this->manifest["properties"] = $manifestRoot->properties;
38  if(isset ($manifest))
39  {
40  $propertiesFile = $a_import_dirname . "/" . $this->manifest["properties"][0];
41  $xml = file_get_contents ($propertiesFile);
42  if(isset ($xml))
43  {
44  $xmlRoot = simplexml_load_string($xml);
45  //todo: extend for import of multiple modules in one file ??
46  foreach ($this->dataset->properties as $key => $value)
47  {
48  $this->moduleProperties[$key] = $xmlRoot->$key;
49  }
50  $this->moduleProperties["Title"] = $xmlRoot->Title;
51  $this->moduleProperties["Description"] = $xmlRoot->Description;
52  $result = true;
53  }
54  else
55  {
56  $ilLog->write("error parsing xml file for scorm import");
57  //error xml parsing
58  }
59  }
60  else
61  {
62  $ilLog->write("error reading manifest file");
63  }
64  }
65  else
66  {
67  $ilLog->write("error no manifest file found");
68  }
69  }
70  else
71  {
72  $ilLog->write("error file lost while importing");
73  //error non existing file
74  }
75  return $result;
76  }
77 
78  public function writeData($a_entity, $version, $a_id)
79  {
80  $this->dataset->writeData($a_entity, $a_version, $a_id, $this->moduleProperties);
81  }
82 }
83 ?>
$result
writeData($a_entity, $version, $a_id)
importXmlRepresentation($a_entity, $a_id, $a_import_dirname, $a_mapping)
Import XML.
Xml importer class.