ILIAS  release_7 Revision v7.30-3-g800a261c036
ilScormAiccImporter Class Reference
+ Inheritance diagram for ilScormAiccImporter:
+ Collaboration diagram for ilScormAiccImporter:

Public Member Functions

 __construct ()
 Constructor. More...
 
 init ()
 Init. More...
 
 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 ( )

Constructor.

Parameters

return

Reimplemented from ilXmlImporter.

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 157 of file class.ilScormAiccImporter.php.

158 {
159 // if editable...
160 if (is_int(strpos($a_xml, "<Editable>1</Editable>"))) {
161 // ...use ilScorm2004DataSet for import
162 include_once("./Modules/Scorm2004/classes/class.ilScorm2004DataSet.php");
163 $dataset = new ilScorm2004DataSet();
164 $dataset->setDSPrefix("ds");
165 $dataset->setImportDirectory($this->getImportDirectory());
166
167 include_once("./Services/DataSet/classes/class.ilDataSetImportParser.php");
168 $parser = new ilDataSetImportParser(
169 $a_entity,
170 $this->getSchemaVersion(),
171 $a_xml,
172 $dataset,
173 $a_mapping
174 );
175 return true;
176 }
177 return false;
178 }
Manifest parser for ILIAS standard export files.
getSchemaVersion()
Get schema version.
getImportDirectory()
Get import directory.

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

Referenced by importXmlRepresentation().

+ 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

return

Reimplemented from ilXmlImporter.

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

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,"xml","sahs");
39 // $tempFile = dirname($exportDir) . '/export/' . basename($this->getImportDirectory()) . '.zip';
40
41 // $timeStamp = time();
42 // $lmDir = ilUtil::getWebspaceDir("filesystem") . "/lm_data/";
43 // $lmTempDir = $lmDir . $timeStamp;
44 // $importDir = $this->getImportDirectory();
45 // $a_import_dirname = $lmTempDir . '/' . basename($importDir);
46 // if (!file_exists($tempFile)) {
47 // $tempFile = $importDir . '/content.zip';
48 // $a_import_dirname = $importDir;
49 // }
50 // if (!file_exists($lmTempDir)) {
51 // mkdir($lmTempDir, 0755, true);
52 // }
53 // $zar = new ZipArchive();
54 // $zar->open($tempFile);
55 // $zar->extractTo($lmTempDir);
56 // $zar->close();
57 $a_import_dirname = $this->getImportDirectory();
58 }
59
60 // $ilLog->write($a_import_dirname);
61 $result = false;
62 if (file_exists($a_import_dirname)) {
63 $manifestFile = $a_import_dirname . "/manifest.xml";
64 if (file_exists($manifestFile)) {
65 $manifest = file_get_contents($manifestFile);
66 if (isset($manifest)) {
67 $propertiesFile = $a_import_dirname . "/properties.xml";
68 $xml = file_get_contents($propertiesFile);
69
70 if (isset($xml)) {
71 $use_internal_errors = libxml_use_internal_errors(true);
72 $xmlRoot = simplexml_load_string(trim($xml));
73 libxml_use_internal_errors($use_internal_errors);
74 if (!$xmlRoot instanceof SimpleXMLElement) {
75 $ilLog->write('XML for SCORM Import is: ' . $xml . $xmlRoot);
76 return false;
77 }
78
79 foreach ($this->dataset->properties as $key => $value) {
80 $this->moduleProperties[$key] = $xmlRoot->$key;
81 }
82 $this->moduleProperties["Title"] = $xmlRoot->Title;
83 $this->moduleProperties["Description"] = $xmlRoot->Description;
84
85 foreach ($this->moduleProperties as $key => $xmlRoot) {
86 $xmlRootValue = $xmlRoot->__toString();
87 $filteredValue = preg_replace('%\s%', '', $xmlRootValue);
88 $this->moduleProperties[$key] = ilUtil::stripSlashes($filteredValue);
89 }
90
91 if ($a_id != null && $new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_id)) {
92 $this->dataset->writeData("sahs", "5.1.0", $newObj->getId(), $this->moduleProperties);
93
94 $newObj->createReference();
95
96 $scormFile = "content.zip";
97 $scormFilePath = $a_import_dirname . "/" . $scormFile;
98 $targetPath = $newObj->getDataDirectory() . "/" . $scormFile;
99 $file_path = $targetPath;
100
101 ilFileUtils::rename($scormFilePath, $targetPath);
102 ilUtil::unzip($file_path);
103 unlink($file_path);
104 // ilUtil::delDir($lmTempDir, false);
105 // $ilLog->write($scormFilePath.'----'. $targetPath);
106 ilUtil::renameExecutables($newObj->getDataDirectory());
107
108 $newId = $newObj->getRefId();
109 // $newObj->putInTree($newId);
110 // $newObj->setPermissions($newId);
111 $subType = $this->moduleProperties["SubType"];
112 if ($subType == "scorm") {
113 include_once("./Modules/ScormAicc/classes/class.ilObjSCORMLearningModule.php");
114 $newObj = new ilObjSCORMLearningModule($newId);
115 } else {
116 include_once("./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php");
117 $newObj = new ilObjSCORM2004LearningModule($newId);
118 }
119 $title = $newObj->readObject();
120 //auto set learning progress settings
121 $newObj->setLearningProgressSettingsAtUpload();
122 }
123
124
125 $result = true;
126 } else {
127 $ilLog->write("error parsing xml file for scorm import");
128 //error xml parsing
129 }
130 } else {
131 $ilLog->write("error reading manifest file");
132 }
133 } else {
134 $ilLog->write("error no manifest file found");
135 }
136 } else {
137 $ilLog->write("error file lost while importing");
138 //error non existing file
139 }
140 return $result;
141 }
$result
static rename($a_source, $a_target)
Rename a file.
Class ilObjSCORM2004LearningModule.
Class ilObjSCORMLearningModule.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
handleEditableLmXml($a_entity, $a_id, $a_xml, $a_mapping)
Handle editable (authoring) scorm lms.
static unzip(string $path_to_zip_file, bool $overwrite_existing=false, bool $unpack_flat=false)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.
global $DIC
Definition: goto.php:24
$xml
Definition: metadata.php:332

References $DIC, $result, $xml, ilXmlImporter\getImportDirectory(), ilObjectFactory\getInstanceByObjId(), handleEditableLmXml(), ilFileUtils\rename(), ilUtil\renameExecutables(), ilUtil\stripSlashes(), and ilUtil\unzip().

+ Here is the call graph for this function:

◆ init()

ilScormAiccImporter::init ( )

Init.

Reimplemented from ilXmlImporter.

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

16 {
17 }

◆ writeData()

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

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

144 {
145 $this->dataset->writeData($a_entity, $a_version, $a_id, $this->moduleProperties);
146 }

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