ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 136 of file class.ilScormAiccImporter.php.

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

Referenced by importXmlRepresentation().

137  {
138  // if editable...
139  if (is_int(strpos($a_xml, "<Editable>1</Editable>"))) {
140  // ...use ilScorm2004DataSet for import
141  include_once("./Modules/Scorm2004/classes/class.ilScorm2004DataSet.php");
142  $dataset = new ilScorm2004DataSet();
143  $dataset->setDSPrefix("ds");
144  $dataset->setImportDirectory($this->getImportDirectory());
145 
146  include_once("./Services/DataSet/classes/class.ilDataSetImportParser.php");
148  $a_entity,
149  $this->getSchemaVersion(),
150  $a_xml,
151  $dataset,
152  $a_mapping
153  );
154  return true;
155  }
156  return false;
157  }
getSchemaVersion()
Get schema version.
getImportDirectory()
Get import directory.
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 $DIC, $ilLog, $key, $result, $title, $xml, ilExport\_getExportDirectory(), ilUtil\delDir(), ilXmlImporter\getImportDirectory(), ilObjectFactory\getInstanceByObjId(), ilUtil\getWebspaceDir(), handleEditableLmXml(), ilFileUtils\rename(), ilUtil\renameExecutables(), and ilUtil\unzip().

26  {
27  global $DIC;
28  $ilLog = $DIC['ilLog'];
29 
30  if ($this->handleEditableLmXml($a_entity, $a_id, $a_import_dirname, $a_mapping)) {
31  return true;
32  }
33  // case i container
34  if ($a_id != null && $new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) {
35  $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
36 
37  require_once("./Services/Export/classes/class.ilExport.php");
38  $exportDir = ilExport::_getExportDirectory($a_id);
39  $tempFile = dirname($exportDir) . '/export/' . basename($this->getImportDirectory()) . '.zip';
40  $timeStamp = time();
41  $lmDir = ilUtil::getWebspaceDir("filesystem") . "/lm_data/";
42  $lmTempDir = $lmDir . $timeStamp;
43  if (!file_exists($lmTempDir)) {
44  mkdir($lmTempDir, 0755, true);
45  }
46  $zar = new ZipArchive();
47  $zar->open($tempFile);
48  $zar->extractTo($lmTempDir);
49  $zar->close();
50  $a_import_dirname = $lmTempDir . '/' . basename($this->getImportDirectory());
51  }
52 
53 
54 
55  $result = false;
56  if (file_exists($a_import_dirname)) {
57  $manifestFile = $a_import_dirname . "/manifest.xml";
58  if (file_exists($manifestFile)) {
59  $manifest = file_get_contents($manifestFile);
60  if (isset($manifest)) {
61  $propertiesFile = $a_import_dirname . "/properties.xml";
62  $xml = file_get_contents($propertiesFile);
63  if (isset($xml)) {
64  $xmlRoot = simplexml_load_string($xml);
65  foreach ($this->dataset->properties as $key => $value) {
66  $this->moduleProperties[$key] = $xmlRoot->$key;
67  }
68  $this->moduleProperties["Title"] = $xmlRoot->Title;
69  $this->moduleProperties["Description"] = $xmlRoot->Description;
70 
71  if ($a_id != null && $new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) {
72  $this->dataset->writeData("sahs", "5.1.0", $newObj->getId(), $this->moduleProperties);
73 
74  $newObj->createReference();
75 
76  $scormFile = "content.zip";
77  $scormFilePath = $a_import_dirname . "/" . $scormFile;
78  $targetPath = $newObj->getDataDirectory() . "/" . $scormFile;
79  $file_path = $targetPath;
80 
81  ilFileUtils::rename($scormFilePath, $targetPath);
82  ilUtil::unzip($file_path);
83  unlink($file_path);
84  ilUtil::delDir($lmTempDir, false);
85  ilUtil::renameExecutables($newObj->getDataDirectory());
86 
87  $newId = $newObj->getRefId();
88  // $newObj->putInTree($newId);
89  // $newObj->setPermissions($newId);
90  $subType = $this->moduleProperties["SubType"][0];
91  if ($subType == "scorm") {
92  include_once("./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php");
93  $newObj = new ilObjSCORMLearningModule($newId);
94  } else {
95  include_once("./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php");
96  $newObj = new ilObjSCORM2004LearningModule($newId);
97  }
98  $title = $newObj->readObject();
99  //auto set learning progress settings
100  $newObj->setLearningProgressSettingsAtUpload();
101  }
102 
103 
104  $result = true;
105  } else {
106  $ilLog->write("error parsing xml file for scorm import");
107  //error xml parsing
108  }
109  } else {
110  $ilLog->write("error reading manifest file");
111  }
112  } else {
113  $ilLog->write("error no manifest file found");
114  }
115  } else {
116  $ilLog->write("error file lost while importing");
117  //error non existing file
118  }
119  return $result;
120  }
$result
global $DIC
Definition: saml.php:7
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.
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.
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 122 of file class.ilScormAiccImporter.php.

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

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