ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilCmiXapiImporter Class Reference
+ Inheritance diagram for ilCmiXapiImporter:
+ Collaboration diagram for ilCmiXapiImporter:

Public Member Functions

 __construct ()
 ilCmiXapiImporter constructor. More...
 
 importXmlRepresentation (string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping)
 Init the object creation from import. More...
 
 init ()
 
 __destruct ()
 if single import then deleteImportDirectiry More...
 
- Public Member Functions inherited from ilXmlImporter
 __construct ()
 
 setImport (ilImport $a_val)
 
 getImport ()
 
 init ()
 
 setInstallId (string $a_val)
 
 getInstallId ()
 
 setInstallUrl (string $a_val)
 
 getInstallUrl ()
 
 setSchemaVersion (string $a_val)
 
 getSchemaVersion ()
 
 setImportDirectory (string $a_val)
 
 getImportDirectory ()
 
 setSkipEntities (array $a_val)
 
 getSkipEntities ()
 
 exportedFromSameInstallation ()
 
 importXmlRepresentation (string $a_entity, string $a_id, string $a_xml, ilImportMapping $a_mapping)
 
 finalProcessing (ilImportMapping $a_mapping)
 
 afterContainerImportProcessing (ilImportMapping $mapping)
 

Data Fields

array $manifest = []
 

Private Member Functions

 prepareSingleObject ()
 Builds the CmiXapi Object. More...
 
 prepareContainerObject ()
 Builds the CmiXapi Object. More...
 
 prepareLocalSourceStorage ()
 Creates a folder in the data directory of the document root. More...
 
 parseXmlFileProperties ()
 Parse xml file and set properties. More...
 
 updateNewObj ()
 Finalize the new CmiXapi Object. More...
 
 deleteImportDirectiry ()
 Delete the import directory. More...
 
 getImportDirectorySingle ()
 Gets the relative path to the Filesystem::temp Folder. More...
 
 getImportDirectoryContainer ()
 Gets the relative path to the Filesystem::temp Folder. More...
 

Private Attributes

array $_moduleProperties = []
 
ilCmiXapiDataSet $_dataset
 
ilObject $_cmixObj
 
string $_newId = null
 
string $_import_objId
 
ilImportMapping $_mapping
 
string $_relWebDir = 'lm_data/lm_'
 
string $_relImportDir = ''
 
bool $_isSingleImport = false
 
ILIAS DI Container $dic
 
ILIAS Filesystem Filesystem $filesystemWeb
 
ILIAS Filesystem Filesystem $filesystemTemp
 

Additional Inherited Members

- Protected Attributes inherited from ilXmlImporter
array $skip_entities = array()
 
ilImport $imp
 
string $install_id
 
string $install_url
 
string $schema_version
 
string $import_directory
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilCmiXapiImporter::__construct ( )

ilCmiXapiImporter constructor.

Definition at line 60 of file class.ilCmiXapiImporter.php.

References $DIC, and ILIAS\GlobalScreen\Provider\__construct().

61  {
63  global $DIC;
64  $this->dic = $DIC;
65  $this->filesystemWeb = $DIC->filesystem()->web();
66  $this->filesystemTemp = $DIC->filesystem()->temp();
67  $this->_dataset = new ilCmiXapiDataSet();
68  $this->_dataset->_cmixSettingsProperties['Title'] = '';
69  $this->_dataset->_cmixSettingsProperties['Description'] = '';
70  //todo: at the moment restricted to one module in xml file, extend?
71  }
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

◆ __destruct()

ilCmiXapiImporter::__destruct ( )

if single import then deleteImportDirectiry

Definition at line 289 of file class.ilCmiXapiImporter.php.

References deleteImportDirectiry().

290  {
291  if ($this->_isSingleImport) {
292  $this->deleteImportDirectiry();
293  }
294  }
deleteImportDirectiry()
Delete the import directory.
+ Here is the call graph for this function:

Member Function Documentation

◆ deleteImportDirectiry()

ilCmiXapiImporter::deleteImportDirectiry ( )
private

Delete the import directory.

Exceptions

Definition at line 250 of file class.ilCmiXapiImporter.php.

Referenced by __destruct().

250  : self
251  {
252  $this->filesystemTemp->delete($this->_relImportDir);
253  return $this;
254  }
+ Here is the caller graph for this function:

◆ getImportDirectoryContainer()

ilCmiXapiImporter::getImportDirectoryContainer ( )
private

Gets the relative path to the Filesystem::temp Folder.

Returns
$this

Definition at line 272 of file class.ilCmiXapiImporter.php.

References ilXmlImporter\getImportDirectory().

Referenced by importXmlRepresentation().

272  : self
273  {
274  $importTempDir = $this->getImportDirectory();
275  $dirArr = array_reverse(explode('/', $importTempDir));
276  $this->_relImportDir = $dirArr[3] . '/' . $dirArr[2] . '/' . $dirArr[1] . '/' . $dirArr[0];
277 
278  return $this;
279  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getImportDirectorySingle()

ilCmiXapiImporter::getImportDirectorySingle ( )
private

Gets the relative path to the Filesystem::temp Folder.

Returns
$this

Definition at line 260 of file class.ilCmiXapiImporter.php.

References ilXmlImporter\getImportDirectory().

Referenced by importXmlRepresentation().

260  : self
261  {
262  $importTempDir = $this->getImportDirectory();
263  $dirArr = array_reverse(explode('/', $importTempDir));
264  $this->_relImportDir = $dirArr[1] . '/' . $dirArr[0];
265  return $this;
266  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ importXmlRepresentation()

ilCmiXapiImporter::importXmlRepresentation ( string  $a_entity,
string  $a_id,
string  $a_xml,
ilImportMapping  $a_mapping 
)

Init the object creation from import.

Exceptions

Definition at line 78 of file class.ilCmiXapiImporter.php.

References getImportDirectoryContainer(), getImportDirectorySingle(), ilImportMapping\getMapping(), parseXmlFileProperties(), prepareContainerObject(), prepareLocalSourceStorage(), prepareSingleObject(), and updateNewObj().

78  : void
79  {
80  $this->_import_objId = $a_id;
81  $this->_mapping = $a_mapping;
82 
83  if ($this->_newId = $a_mapping->getMapping('Services/Container', 'objs', (string) $this->_import_objId)) {
84  // container content
85  $this->prepareContainerObject();
87  } else {
88  // single object
89  $this->prepareSingleObject();
90  $this->getImportDirectorySingle();
91  $this->_isSingleImport = true;
92  }
94  $this->parseXmlFileProperties();
95  $this->updateNewObj();
96  }
getImportDirectoryContainer()
Gets the relative path to the Filesystem::temp Folder.
prepareSingleObject()
Builds the CmiXapi Object.
prepareLocalSourceStorage()
Creates a folder in the data directory of the document root.
getMapping(string $a_comp, string $a_entity, string $a_old_id)
getImportDirectorySingle()
Gets the relative path to the Filesystem::temp Folder.
parseXmlFileProperties()
Parse xml file and set properties.
updateNewObj()
Finalize the new CmiXapi Object.
prepareContainerObject()
Builds the CmiXapi Object.
+ Here is the call graph for this function:

◆ init()

ilCmiXapiImporter::init ( )

Definition at line 282 of file class.ilCmiXapiImporter.php.

282  : void
283  {
284  }

◆ parseXmlFileProperties()

ilCmiXapiImporter::parseXmlFileProperties ( )
private

Parse xml file and set properties.

Returns
$this
Exceptions

Definition at line 166 of file class.ilCmiXapiImporter.php.

References ILIAS\LTI\ToolProvider\$key, and $xml.

Referenced by importXmlRepresentation().

166  : self
167  {
168  $xmlRoot = null;
169  $xml = $this->filesystemTemp->readStream($this->_relImportDir . '/properties.xml');
170  if ($xml != false) {
171  $use_internal_errors = libxml_use_internal_errors(true);
172  $xmlRoot = simplexml_load_string((string) $xml);
173  libxml_use_internal_errors($use_internal_errors);
174  }
175  foreach ($this->_dataset->_cmixSettingsProperties as $key => $property) {
176  $this->_moduleProperties[$key] = trim($xmlRoot->$key->__toString());
177  }
178  return $this;
179  }
string $key
Consumer key/client ID value.
Definition: System.php:193
$xml
Definition: metadata.php:351
+ Here is the caller graph for this function:

◆ prepareContainerObject()

ilCmiXapiImporter::prepareContainerObject ( )
private

Builds the CmiXapi Object.

Definition at line 124 of file class.ilCmiXapiImporter.php.

References ilObjectFactory\getInstanceByObjId().

Referenced by importXmlRepresentation().

124  : void
125  {
126  $this->_newId = $this->_mapping->getMapping('Services/Container', 'objs', (string) $this->_import_objId);
127  if (!is_null($this->_newId) && $this->_newId != "") {
128  // container content
129  $this->_cmixObj = ilObjectFactory::getInstanceByObjId((int) $this->_newId, false);
130  //$_SESSION['tst_import_subdir'] = $this->getImportPackageName();
131  $this->_cmixObj->save(); // this generates test id first time
132  //var_dump([$this->getImportDirectory(), $this->_import_dirname]); exit;
133  $this->_mapping->addMapping("Modules/CmiXapi", "cmix", (string) $this->_import_objId, $this->_newId);
134  }
135  $this->_cmixObj->save();
136  $this->_cmixObj->update();
137  }
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prepareLocalSourceStorage()

ilCmiXapiImporter::prepareLocalSourceStorage ( )
private

Creates a folder in the data directory of the document root.

Exceptions

Definition at line 144 of file class.ilCmiXapiImporter.php.

References ilFileUtils\getWebspaceDir(), and ilFileUtils\unzip().

Referenced by importXmlRepresentation().

144  : self
145  {
146  if (true === $this->filesystemTemp->has($this->_relImportDir . '/content.zip')) {
147  // $this->_hasContent = true;
148  $this->_relWebDir = $this->_relWebDir . $this->_cmixObj->getId();
149  if (false === $this->filesystemWeb->has($this->_relWebDir)) {
150  $this->filesystemWeb->createDir($this->_relWebDir);
151  $this->filesystemWeb->put($this->_relWebDir . '/content.zip', $this->filesystemTemp->read($this->_relImportDir . '/content.zip'));
152  $webDataDir = ilFileUtils::getWebspaceDir();
153  ilFileUtils::unzip($webDataDir . "/" . $this->_relWebDir . "/content.zip");
154  $this->filesystemWeb->delete($this->_relWebDir . '/content.zip');
155  }
156  }
157  return $this;
158  }
static getWebspaceDir(string $mode="filesystem")
get webspace directory
static unzip(string $path_to_zip_file, bool $overwrite_existing=false, bool $unpack_flat=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ prepareSingleObject()

ilCmiXapiImporter::prepareSingleObject ( )
private

Builds the CmiXapi Object.

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

Referenced by importXmlRepresentation().

101  : self
102  {
103  // create new cmix object
104  $this->_cmixObj = new ilObjCmiXapi();
105  // set type of questionpool object
106  $this->_cmixObj->setType('cmix');
107  // set title of questionpool object to "dummy"
108  $this->_cmixObj->setTitle("dummy");
109  // set description of questionpool object
110  $this->_cmixObj->setDescription("test import");
111  // create the questionpool class in the ILIAS database (object_data table)
112  $this->_cmixObj->create(true);
113  $this->_newId = (string) $this->_cmixObj->getId();
114  $this->_mapping->addMapping('Modules/CmiXapi', 'cmix', (string) $this->_import_objId, (string) $this->_newId);
115  //$this->getImport();
116  $this->_cmixObj->update();
117 
118  return $this;
119  }
+ Here is the caller graph for this function:

◆ updateNewObj()

ilCmiXapiImporter::updateNewObj ( )
private

Finalize the new CmiXapi Object.

Returns
void

Definition at line 185 of file class.ilCmiXapiImporter.php.

Referenced by importXmlRepresentation().

185  : void
186  {
187  $this->_cmixObj->setTitle($this->_moduleProperties['Title'] . " " . $this->dic->language()->txt("copy_of_suffix"));
188  $this->_cmixObj->setDescription($this->_moduleProperties['Description']);
189  $this->_cmixObj->update();
190 
191  if ($this->_moduleProperties['LrsTypeId']) {
192  $this->_cmixObj->setLrsTypeId((int) $this->_moduleProperties['LrsTypeId']);
193  $this->_cmixObj->setLrsType(new ilCmiXapiLrsType((int) $this->_moduleProperties['LrsTypeId']));
194  }
195  $this->_cmixObj->setContentType((string) $this->_moduleProperties['ContentType']);
196  $this->_cmixObj->setSourceType((string) $this->_moduleProperties['SourceType']);
197  $this->_cmixObj->setActivityId((string) $this->_moduleProperties['ActivityId']);
198  $this->_cmixObj->setInstructions((string) $this->_moduleProperties['Instructions']);
199  // $this->_cmixObj->setOfflineStatus($this->_moduleProperties['OfflineStatus']);
200  $this->_cmixObj->setLaunchUrl((string) $this->_moduleProperties['LaunchUrl']);
201  $this->_cmixObj->setAuthFetchUrlEnabled((bool) $this->_moduleProperties['AuthFetchUrl']);
202  $this->_cmixObj->setLaunchMethod((string) $this->_moduleProperties['LaunchMethod']);
203  $this->_cmixObj->setLaunchMode((string) $this->_moduleProperties['LaunchMode']);
204  $this->_cmixObj->setMasteryScore((float) $this->_moduleProperties['MasteryScore']);
205  $this->_cmixObj->setKeepLpStatusEnabled((bool) $this->_moduleProperties['KeepLp']);
206  $this->_cmixObj->setPrivacyIdent((int) $this->_moduleProperties['PrivacyIdent']);
207  $this->_cmixObj->setPrivacyName((int) $this->_moduleProperties['PrivacyName']);
208  $this->_cmixObj->setUserPrivacyComment((string) $this->_moduleProperties['UsrPrivacyComment']);
209  $this->_cmixObj->setStatementsReportEnabled((bool) $this->_moduleProperties['ShowStatements']);
210  $this->_cmixObj->setXmlManifest((string) $this->_moduleProperties['XmlManifest']);
211  $this->_cmixObj->setVersion((int) $this->_moduleProperties['Version']);
212  $this->_cmixObj->setHighscoreEnabled((bool) $this->_moduleProperties['HighscoreEnabled']);
213  $this->_cmixObj->setHighscoreAchievedTS((bool) $this->_moduleProperties['HighscoreAchievedTs']);
214  $this->_cmixObj->setHighscorePercentage((bool) $this->_moduleProperties['HighscorePercentage']);
215  $this->_cmixObj->setHighscoreWtime((bool) $this->_moduleProperties['HighscoreWtime']);
216  $this->_cmixObj->setHighscoreOwnTable((bool) $this->_moduleProperties['HighscoreOwnTable']);
217  $this->_cmixObj->setHighscoreTopTable((bool) $this->_moduleProperties['HighscoreTopTable']);
218  $this->_cmixObj->setHighscoreTopNum((int) $this->_moduleProperties['HighscoreTopNum']);
219  $this->_cmixObj->setBypassProxyEnabled((bool) $this->_moduleProperties['BypassProxy']);
220  $this->_cmixObj->setOnlyMoveon((bool) $this->_moduleProperties['OnlyMoveon']);
221  $this->_cmixObj->setAchieved((bool) $this->_moduleProperties['Achieved']);
222  $this->_cmixObj->setAnswered((bool) $this->_moduleProperties['Answered']);
223  $this->_cmixObj->setCompleted((bool) $this->_moduleProperties['Completed']);
224  $this->_cmixObj->setFailed((bool) $this->_moduleProperties['Failed']);
225  $this->_cmixObj->setInitialized((bool) $this->_moduleProperties['Initialized']);
226  $this->_cmixObj->setPassed((bool) $this->_moduleProperties['Passed']);
227  $this->_cmixObj->setProgressed((bool) $this->_moduleProperties['Progressed']);
228  $this->_cmixObj->setSatisfied((bool) $this->_moduleProperties['Satisfied']);
229  $this->_cmixObj->setTerminated((bool) $this->_moduleProperties['Terminated']);
230  $this->_cmixObj->setHideData((bool) $this->_moduleProperties['HideData']);
231  $this->_cmixObj->setTimestamp((bool) $this->_moduleProperties['Timestamp']);
232  $this->_cmixObj->setDuration((bool) $this->_moduleProperties['Duration']);
233  $this->_cmixObj->setNoSubstatements((bool) $this->_moduleProperties['NoSubstatements']);
234  $this->_cmixObj->setPublisherId((string) $this->_moduleProperties['PublisherId']);
235  // $this->_cmixObj->setAnonymousHomepage($this->_moduleProperties['AnonymousHomepage']);
236  $this->_cmixObj->setMoveOn((string) $this->_moduleProperties['MoveOn']);
237  $this->_cmixObj->setLaunchParameters((string) $this->_moduleProperties['LaunchParameters']);
238  $this->_cmixObj->setEntitlementKey((string) $this->_moduleProperties['EntitlementKey']);
239  $this->_cmixObj->setSwitchToReviewEnabled((bool) $this->_moduleProperties['SwitchToReview']);
240  $this->_cmixObj->save();
241  $this->_cmixObj->updateMetaData();
242 
243  }
+ Here is the caller graph for this function:

Field Documentation

◆ $_cmixObj

ilObject ilCmiXapiImporter::$_cmixObj
private

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

◆ $_dataset

ilCmiXapiDataSet ilCmiXapiImporter::$_dataset
private

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

◆ $_import_objId

string ilCmiXapiImporter::$_import_objId
private

Definition at line 42 of file class.ilCmiXapiImporter.php.

◆ $_isSingleImport

bool ilCmiXapiImporter::$_isSingleImport = false
private

Definition at line 50 of file class.ilCmiXapiImporter.php.

◆ $_mapping

ilImportMapping ilCmiXapiImporter::$_mapping
private

Definition at line 44 of file class.ilCmiXapiImporter.php.

◆ $_moduleProperties

array ilCmiXapiImporter::$_moduleProperties = []
private

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

◆ $_newId

string ilCmiXapiImporter::$_newId = null
private

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

◆ $_relImportDir

string ilCmiXapiImporter::$_relImportDir = ''
private

Definition at line 48 of file class.ilCmiXapiImporter.php.

◆ $_relWebDir

string ilCmiXapiImporter::$_relWebDir = 'lm_data/lm_'
private

Definition at line 46 of file class.ilCmiXapiImporter.php.

◆ $dic

ILIAS DI Container ilCmiXapiImporter::$dic
private

Definition at line 52 of file class.ilCmiXapiImporter.php.

◆ $filesystemTemp

ILIAS Filesystem Filesystem ilCmiXapiImporter::$filesystemTemp
private

Definition at line 56 of file class.ilCmiXapiImporter.php.

◆ $filesystemWeb

ILIAS Filesystem Filesystem ilCmiXapiImporter::$filesystemWeb
private

Definition at line 54 of file class.ilCmiXapiImporter.php.

◆ $manifest

array ilCmiXapiImporter::$manifest = []

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


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