ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilScormAiccImporter Class Reference
+ Inheritance diagram for ilScormAiccImporter:
+ Collaboration diagram for ilScormAiccImporter:

Public Member Functions

 __construct ()
 
 init ()
 
 importXmlRepresentation ($a_entity, $a_id, $a_import_dirname, $a_mapping)
 Import XML. More...
 
 writeData ($a_entity, $a_version, $a_id)
 
 handleEditableLmXml ($a_entity, $a_id, $a_xml, $a_mapping)
 Handle editable (authoring) scorm lms. More...
 
- Public Member Functions inherited from ilXmlImporter
 __construct ()
 Constructor. More...
 
 setImport ($a_val)
 Set import. More...
 
 getImport ()
 Get import. More...
 
 init ()
 Init. More...
 
 setInstallId ($a_val)
 Set installation id. More...
 
 getInstallId ()
 Get installation id. More...
 
 setInstallUrl ($a_val)
 Set installation url. More...
 
 getInstallUrl ()
 Get installation url. More...
 
 setSchemaVersion ($a_val)
 Set schema version. More...
 
 getSchemaVersion ()
 Get schema version. More...
 
 setImportDirectory ($a_val)
 Set import directory. More...
 
 getImportDirectory ()
 Get import directory. More...
 
 setSkipEntities ($a_val)
 Set skip entities. More...
 
 getSkipEntities ()
 Get skip entities. More...
 
 exportedFromSameInstallation ()
 Is exporting and importing installation identical? More...
 
 importXmlRepresentation ($a_entity, $a_id, $a_xml, $a_mapping)
 Import xml representation. More...
 
 finalProcessing ($a_mapping)
 Final processing. More...
 
 afterContainerImportProcessing (ilImportMapping $mapping)
 Called after all container objects have been implemented. More...
 

Additional Inherited Members

- Protected Attributes inherited from ilXmlImporter
 $skip_entities = array()
 
 $imp
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilScormAiccImporter::__construct ( )

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

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  }

Member Function Documentation

◆ handleEditableLmXml()

ilScormAiccImporter::handleEditableLmXml (   $a_entity,
  $a_id,
  $a_xml,
  $a_mapping 
)

Handle editable (authoring) scorm lms.

Parameters
string$a_entityentity
string$a_idid
string$a_xmlxml
ilImportMapping$a_mappingimport mapping object
Returns
bool success

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

References $dataset, $parser, ilXmlImporter\getImportDirectory(), and ilXmlImporter\getSchemaVersion().

Referenced by importXmlRepresentation().

136  {
137  // if editable...
138  if (is_int(strpos($a_xml, "<Editable>1</Editable>"))) {
139  // ...use ilScorm2004DataSet for import
140  include_once("./Modules/Scorm2004/classes/class.ilScorm2004DataSet.php");
142  $dataset->setDSPrefix("ds");
143  $dataset->setImportDirectory($this->getImportDirectory());
144 
145  include_once("./Services/DataSet/classes/class.ilDataSetImportParser.php");
147  $a_entity,
148  $this->getSchemaVersion(),
149  $a_xml,
150  $dataset,
151  $a_mapping
152  );
153  return true;
154  }
155  return false;
156  }
getSchemaVersion()
Get schema version.
getImportDirectory()
Get import directory.
$dataset
Definition: showstats.php:45
Manifest parser for ILIAS standard export files.
$parser
Definition: BPMN2Parser.php:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importXmlRepresentation()

ilScormAiccImporter::importXmlRepresentation (   $a_entity,
  $a_id,
  $a_import_dirname,
  $a_mapping 
)

Import XML.

Parameters

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

References $ilLog, $key, $result, $title, $xml, ilExport\_getExportDirectory(), ilUtil\delDir(), ilXmlImporter\getImportDirectory(), ilObjectFactory\getInstanceByObjId(), ilUtil\getWebspaceDir(), handleEditableLmXml(), ilFileUtils\rename(), ilUtil\renameExecutables(), time, and ilUtil\unzip().

26  {
27  global $ilLog;
28 
29  if ($this->handleEditableLmXml($a_entity, $a_id, $a_import_dirname, $a_mapping)) {
30  return true;
31  }
32  // case i container
33  if ($a_id != null && $new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) {
34  $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
35 
36  require_once("./Services/Export/classes/class.ilExport.php");
37  $exportDir = ilExport::_getExportDirectory($a_id);
38  $tempFile = dirname($exportDir) . '/export/' . basename($this->getImportDirectory()) . '.zip';
39  $timeStamp = time();
40  $lmDir = ilUtil::getWebspaceDir("filesystem") . "/lm_data/";
41  $lmTempDir = $lmDir . $timeStamp;
42  if (!file_exists($lmTempDir)) {
43  mkdir($lmTempDir, 0755, true);
44  }
45  $zar = new ZipArchive();
46  $zar->open($tempFile);
47  $zar->extractTo($lmTempDir);
48  $zar->close();
49  $a_import_dirname = $lmTempDir . '/' . basename($this->getImportDirectory());
50  }
51 
52 
53 
54  $result = false;
55  if (file_exists($a_import_dirname)) {
56  $manifestFile = $a_import_dirname . "/manifest.xml";
57  if (file_exists($manifestFile)) {
58  $manifest = file_get_contents($manifestFile);
59  if (isset($manifest)) {
60  $propertiesFile = $a_import_dirname . "/properties.xml";
61  $xml = file_get_contents($propertiesFile);
62  if (isset($xml)) {
63  $xmlRoot = simplexml_load_string($xml);
64  foreach ($this->dataset->properties as $key => $value) {
65  $this->moduleProperties[$key] = $xmlRoot->$key;
66  }
67  $this->moduleProperties["Title"] = $xmlRoot->Title;
68  $this->moduleProperties["Description"] = $xmlRoot->Description;
69 
70  if ($a_id != null && $new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) {
71  $this->dataset->writeData("sahs", "5.1.0", $newObj->getId(), $this->moduleProperties);
72 
73  $newObj->createReference();
74 
75  $scormFile = "content.zip";
76  $scormFilePath = $a_import_dirname . "/" . $scormFile;
77  $targetPath = $newObj->getDataDirectory() . "/" . $scormFile;
78  $file_path = $targetPath;
79 
80  ilFileUtils::rename($scormFilePath, $targetPath);
81  ilUtil::unzip($file_path);
82  unlink($file_path);
83  ilUtil::delDir($lmTempDir, false);
84  ilUtil::renameExecutables($newObj->getDataDirectory());
85 
86  $newId = $newObj->getRefId();
87  // $newObj->putInTree($newId);
88  // $newObj->setPermissions($newId);
89  $subType = $this->moduleProperties["SubType"][0];
90  if ($subType == "scorm") {
91  include_once("./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php");
92  $newObj = new ilObjSCORMLearningModule($newId);
93  } else {
94  include_once("./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php");
95  $newObj = new ilObjSCORM2004LearningModule($newId);
96  }
97  $title = $newObj->readObject();
98  //auto set learning progress settings
99  $newObj->setLearningProgressSettingsAtUpload();
100  }
101 
102 
103  $result = true;
104  } else {
105  $ilLog->write("error parsing xml file for scorm import");
106  //error xml parsing
107  }
108  } else {
109  $ilLog->write("error reading manifest file");
110  }
111  } else {
112  $ilLog->write("error no manifest file found");
113  }
114  } else {
115  $ilLog->write("error file lost while importing");
116  //error non existing file
117  }
118  return $result;
119  }
$result
getImportDirectory()
Get import directory.
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
handleEditableLmXml($a_entity, $a_id, $a_xml, $a_mapping)
Handle editable (authoring) scorm lms.
static rename($a_source, $a_target)
Rename a file.
$xml
Definition: metadata.php:240
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
Class ilObjSCORM2004LearningModule.
static _getExportDirectory($a_obj_id, $a_type="xml", $a_obj_type="", $a_entity="")
Get export directory for an repository object.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static getWebspaceDir($mode="filesystem")
get webspace directory
$key
Definition: croninfo.php:18
Class ilObjSCORMLearningModule.
+ Here is the call graph for this function:

◆ init()

ilScormAiccImporter::init ( )

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

16  {
17  }

◆ writeData()

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

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

122  {
123  $this->dataset->writeData($a_entity, $a_version, $a_id, $this->moduleProperties);
124  }

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