28 const CMI5_XSD =
'cmi5_v1_CourseStructure.xsd';
69 if (!
$DIC->filesystem()->web()->has($this->getWebDataDirRelativeObjectDirectory())) {
101 $fileInfo = pathinfo($serverFile);
103 switch ($fileInfo[
'extension']) {
134 $fileData[
'tmp_name']
152 if (
$DIC->upload()->hasUploads()) {
153 if (!
$DIC->upload()->hasBeenProcessed()) {
154 $DIC->upload()->process();
161 if (isset(
$results[$uploadFilePath])) {
164 if (
$result->getStatus() == FileUploadProcessingStatus::OK) {
169 'upload processing failed with message ' .
170 '"' .
$result->getStatus()->getMessage() .
'"'
210 $dom =
new DOMDocument();
211 $dom->load($xmlFilePath);
213 switch (basename($xmlFilePath)) {
241 $dom =
new DOMDocument();
242 $dom->load($xmlFilePath);
243 switch (basename($xmlFileName)) {
266 if (!$dom->schemaValidate($xsdFilePath)) {
274 $zar =
new ZipArchive();
275 $zar->open($uploadFilePath);
276 $zar->extractTo($targetPath);
291 return implode(DIRECTORY_SEPARATOR, $dirs);
299 return self::RELATIVE_CONTENT_DIRECTORY_NAMEBASE . $this->
object->getId();
308 return pathinfo($uploadResult->getName(), PATHINFO_EXTENSION);
326 foreach (self::$CONTENT_XML_FILENAMES as $xmlFileName) {
329 if (
$DIC->filesystem()->web()->has($xmlFilePath)) {
343 return ILIAS_ABSOLUTE_PATH . DIRECTORY_SEPARATOR . self::RELATIVE_XSD_DIRECTORY . DIRECTORY_SEPARATOR . $xsdFileName;
349 $xPath =
new DOMXPath($dom);
351 $courseNode = $xPath->query(
"//*[local-name()='course']")->item(0);
353 $title = $xPath->query(
"//*[local-name()='title']/*[local-name()='langstring']", $courseNode)->item(0)->nodeValue;
354 $this->
object->setTitle(trim($title));
356 $description = $xPath->query(
"//*[local-name()='description']/*[local-name()='langstring']", $courseNode)->item(0)->nodeValue;
357 $this->
object->setDescription(trim($description));
359 $publisherId = trim($courseNode->getAttribute(
'id'));
360 $this->
object->setPublisherId($publisherId);
363 $this->
object->setActivityId($activityId);
365 foreach ($xPath->query(
"//*[local-name()='au']") as $assignedUnitNode) {
366 $relativeLaunchUrl = $xPath->query(
"//*[local-name()='url']", $assignedUnitNode)->item(0)->nodeValue;
367 $launchParameters = $xPath->query(
"//*[local-name()='launchParameters']", $assignedUnitNode)->item(0)->nodeValue;
368 $moveOn = trim($assignedUnitNode->getAttribute(
'moveOn'));
369 $entitlementKey = $xPath->query(
"//*[local-name()='entitlementKey']", $assignedUnitNode)->item(0)->nodeValue;
370 $masteryScore = trim($assignedUnitNode->getAttribute(
'masteryScore'));
372 if (!empty($relativeLaunchUrl)) {
373 $this->
object->setLaunchUrl(trim($relativeLaunchUrl));
375 if (!empty($launchParameters)) {
376 $this->
object->setLaunchParameters(trim($launchParameters));
378 if (!empty($moveOn)) {
382 $this->
object->setMoveOn($moveOn);
384 if (!empty($entitlementKey)) {
385 $this->
object->setEntitlementKey($entitlementKey);
387 if (!empty($masteryScore)) {
388 $this->
object->setMasteryScore($masteryScore);
396 $xml_str = $dom->saveXML();
397 $this->
object->setXmlManifest($xml_str);
398 $this->
object->update();
399 $this->
object->save();
418 $lpSettings->setMode($mode);
419 $lpSettings->update();
424 $xPath =
new DOMXPath($dom);
426 foreach ($xPath->query(
"//*[local-name()='activity']") as $activityNode) {
427 $title = $xPath->query(
"//*[local-name()='name']", $activityNode)->item(0)->nodeValue;
428 $this->
object->setTitle(trim($title));
430 $description = $xPath->query(
"//*[local-name()='description']", $activityNode)->item(0)->nodeValue;
431 $this->
object->setDescription(trim($description));
433 $activityId = $activityNode->getAttribute(
'id');
434 $this->
object->setActivityId(trim($activityId));
436 $relativeLaunchUrl = $xPath->query(
"//*[local-name()='launch']", $activityNode)->item(0)->nodeValue;
437 $this->
object->setLaunchUrl(trim($relativeLaunchUrl));
442 $xml_str = $dom->saveXML();
443 $this->
object->setXmlManifest($xml_str);
444 $this->
object->update();
445 $this->
object->save();
451 $objId = $this->
object->getId();
An exception for terminatinating execution or to throw for unit testing.
sanitizeObjectDirectory()
getUpload($uploadFilePath)
validateXmlFile(DOMDocument $dom, $xsdFilePath)
__construct(ilObjCmiXapi $object)
ilCmiXapiContentUploadImporter constructor.
importServerFile($serverFile)
fetchFileExtension(FileUploadResult $uploadResult)
const IMP_FILE_EXTENSION_ZIP
const IMP_FILE_EXTENSION_XML
getXsdFilePath($xsdFileName)
getAbsoluteObjectDirectory()
const RELATIVE_CONTENT_DIRECTORY_NAMEBASE
initObjectFromTincanXml($dom)
handleXmlFile($xmlFilePath)
const RELATIVE_XSD_DIRECTORY
handleFile(string $serverFile)
initObjectFromCmi5Xml($dom)
importFormUpload(ilFileInputGUI $uploadInput)
static $CONTENT_XML_FILENAMES
getWebDataDirRelativeObjectDirectory()
ensureCreatedObjectDirectory()
handleZipContentUpload($uploadFilePath)
handleUpload(FileUploadResult $uploadResult)
generateActivityId($publisherId)
static $CONTENT_XSD_FILENAMES
handleXmlFileFromUpload($xmlFileName, $xmlFilePath)
const MOVEON_COMPLETED_OR_PASSED
const MOVEON_COMPLETED_AND_PASSED
const LP_MODE_CMIX_COMPLETED_OR_PASSED
const LP_MODE_CMIX_PASSED
const LP_MODE_DEACTIVATED
const LP_MODE_CMIX_COMPLETED
static getWebspaceDir($mode="filesystem")
get webspace directory
static renameExecutables($a_dir)
Rename uploaded executables for security reasons.