/** * imports question(s) into the questionpool */ function uploadQplObject($questions_only = false) { $this->ctrl->setParameter($this, 'new_type', $_REQUEST['new_type']); if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK) { ilUtil::sendFailure($this->lng->txt("error_upload"), true); if (!$questions_only) { $this->ctrl->redirect($this, 'create'); } return false; } // create import directory include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php"; $basedir = ilObjQuestionPool::_createImportDirectory(); // copy uploaded file to import directory $file = pathinfo($_FILES["xmldoc"]["name"]); $full_path = $basedir . "/" . $_FILES["xmldoc"]["name"]; $GLOBALS['ilLog']->write(__METHOD__ . ": full path " . $full_path); include_once "./Services/Utilities/classes/class.ilUtil.php"; ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path); $GLOBALS['ilLog']->write(__METHOD__ . ": full path " . $full_path); if (strcmp($_FILES["xmldoc"]["type"], "text/xml") == 0) { $qti_file = $full_path; ilObjTest::_setImportDirectory($basedir); } else { // unzip file ilUtil::unzip($full_path); // determine filenames of xml files $subdir = basename($file["basename"], "." . $file["extension"]); ilObjQuestionPool::_setImportDirectory($basedir); $xml_file = ilObjQuestionPool::_getImportDirectory() . '/' . $subdir . '/' . $subdir . ".xml"; $qti_file = ilObjQuestionPool::_getImportDirectory() . '/' . $subdir . '/' . str_replace("qpl", "qti", $subdir) . ".xml"; } // start verification of QTI files include_once "./Services/QTI/classes/class.ilQTIParser.php"; $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, ""); $result = $qtiParser->startParsing(); $founditems =& $qtiParser->getFoundItems(); if (count($founditems) == 0) { // nothing found // delete import directory ilUtil::delDir($basedir); ilUtil::sendFailure($this->lng->txt("qpl_import_no_items"), true); if (!$questions_only) { $this->ctrl->redirect($this, 'create'); } return false; } $complete = 0; $incomplete = 0; foreach ($founditems as $item) { if (strlen($item["type"])) { $complete++; } else { $incomplete++; } } if ($complete == 0) { // delete import directory ilUtil::delDir($basedir); ilUtil::sendFailure($this->lng->txt("qpl_import_non_ilias_files"), true); if (!$questions_only) { $this->ctrl->redirect($this, 'create'); } return false; } $_SESSION["qpl_import_xml_file"] = $xml_file; $_SESSION["qpl_import_qti_file"] = $qti_file; $_SESSION["qpl_import_subdir"] = $subdir; // display of found questions $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.qpl_import_verification.html", "Modules/TestQuestionPool"); $row_class = array("tblrow1", "tblrow2"); $counter = 0; foreach ($founditems as $item) { $this->tpl->setCurrentBlock("verification_row"); $this->tpl->setVariable("ROW_CLASS", $row_class[$counter++ % 2]); $this->tpl->setVariable("QUESTION_TITLE", $item["title"]); $this->tpl->setVariable("QUESTION_IDENT", $item["ident"]); include_once "./Services/QTI/classes/class.ilQTIItem.php"; switch ($item["type"]) { case CLOZE_TEST_IDENTIFIER: $type = $this->lng->txt("assClozeTest"); break; case IMAGEMAP_QUESTION_IDENTIFIER: $type = $this->lng->txt("assImagemapQuestion"); break; case JAVAAPPLET_QUESTION_IDENTIFIER: $type = $this->lng->txt("assJavaApplet"); break; case MATCHING_QUESTION_IDENTIFIER: $type = $this->lng->txt("assMatchingQuestion"); break; case MULTIPLE_CHOICE_QUESTION_IDENTIFIER: $type = $this->lng->txt("assMultipleChoice"); break; case KPRIM_CHOICE_QUESTION_IDENTIFIER: $type = $this->lng->txt("assKprimChoice"); break; case SINGLE_CHOICE_QUESTION_IDENTIFIER: $type = $this->lng->txt("assSingleChoice"); break; case ORDERING_QUESTION_IDENTIFIER: $type = $this->lng->txt("assOrderingQuestion"); break; case TEXT_QUESTION_IDENTIFIER: $type = $this->lng->txt("assTextQuestion"); break; case NUMERIC_QUESTION_IDENTIFIER: $type = $this->lng->txt("assNumeric"); break; case TEXTSUBSET_QUESTION_IDENTIFIER: $type = $this->lng->txt("assTextSubset"); break; default: $type = $this->lng->txt($item["type"]); break; } if (strcmp($type, "-" . $item["type"] . "-") == 0) { global $ilPluginAdmin; $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_MODULE, "TestQuestionPool", "qst"); foreach ($pl_names as $pl_name) { $pl = ilPlugin::getPluginObject(IL_COMP_MODULE, "TestQuestionPool", "qst", $pl_name); if (strcmp($pl->getQuestionType(), $item["type"]) == 0) { $type = $pl->getQuestionTypeTranslation(); } } } $this->tpl->setVariable("QUESTION_TYPE", $type); $this->tpl->parseCurrentBlock(); } $this->tpl->setCurrentBlock("import_qpl"); if (is_file($xml_file)) { // read file into a string $fh = @fopen($xml_file, "r") or die(""); $xml = @fread($fh, filesize($xml_file)); @fclose($fh); if (preg_match("/<ContentObject.*?MetaData.*?General.*?Title[^>]*?>([^<]*?)</", $xml, $matches)) { $this->tpl->setVariable("VALUE_NEW_QUESTIONPOOL", $matches[1]); } } $this->tpl->setVariable("TEXT_CREATE_NEW_QUESTIONPOOL", $this->lng->txt("qpl_import_create_new_qpl")); $this->tpl->parseCurrentBlock(); $this->tpl->setCurrentBlock("adm_content"); $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt("question_type")); $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("question_title")); $this->tpl->setVariable("FOUND_QUESTIONS_INTRODUCTION", $this->lng->txt("qpl_import_verify_found_questions")); if ($questions_only) { $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_questions_into_qpl")); $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this)); } else { $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_qpl")); $this->ctrl->setParameter($this, "new_type", $this->type); $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this)); //$this->tpl->setVariable("FORMACTION", $this->getFormAction("save","adm_object.php?cmd=gateway&ref_id=".$_GET["ref_id"]."&new_type=".$this->type)); } $this->tpl->setVariable("ARROW", ilUtil::getImagePath("arrow_downright.svg")); $this->tpl->setVariable("VALUE_IMPORT", $this->lng->txt("import")); $this->tpl->setVariable("VALUE_CANCEL", $this->lng->txt("cancel")); $value_questions_only = 0; if ($questions_only) { $value_questions_only = 1; } $this->tpl->setVariable("VALUE_QUESTIONS_ONLY", $value_questions_only); $this->tpl->parseCurrentBlock(); return true; }
/** * Import lm from directory * * @param * @return */ function importFromDirectory($a_directory, $a_validate = true) { global $lng; // determine filename of xml file $subdir = basename($a_directory); $xml_file = $a_directory . "/" . $subdir . ".xml"; // check directory exists within zip file if (!is_dir($a_directory)) { return sprintf($lng->txt("cont_no_subdir_in_zip"), $subdir); } // check whether xml file exists within zip file if (!is_file($xml_file)) { return sprintf($lng->txt("cont_zip_file_invalid"), $subdir . "/" . $subdir . ".xml"); } // import questions $qti_file = $a_directory . "/qti.xml"; $qtis = array(); if (is_file($qti_file)) { include_once "./Services/QTI/classes/class.ilQTIParser.php"; include_once "./Modules/Test/classes/class.ilObjTest.php"; $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, ""); $result = $qtiParser->startParsing(); $founditems =& $qtiParser->getFoundItems(); $testObj = new ilObjTest(0, true); if (count($founditems) > 0) { $qtiParser = new ilQTIParser($qti_file, IL_MO_PARSE_QTI, 0, ""); $qtiParser->setTestObject($testObj); $result = $qtiParser->startParsing(); $qtis = array_merge($qtis, $qtiParser->getImportMapping()); } } include_once "./Modules/LearningModule/classes/class.ilContObjParser.php"; $contParser = new ilContObjParser($this, $xml_file, $subdir, $qmapping); $contParser->setQuestionMapping($qtis); $contParser->startParsing(); ilObject::_writeImportId($this->getId(), $this->getImportId()); $this->MDUpdateListener('General'); // import style $style_file = $a_directory . "/style.xml"; $style_zip_file = $a_directory . "/style.zip"; if (is_file($style_zip_file)) { require_once "./Services/Style/classes/class.ilObjStyleSheet.php"; $style = new ilObjStyleSheet(); $style->import($style_zip_file); $this->writeStyleSheetId($style->getId()); } else { if (is_file($style_file)) { require_once "./Services/Style/classes/class.ilObjStyleSheet.php"; $style = new ilObjStyleSheet(); $style->import($style_file); $this->writeStyleSheetId($style->getId()); } } // // validate if ($a_validate) { $mess = $this->validatePages(); } if ($mess == "") { // handle internal links to this learning module include_once "./Modules/LearningModule/classes/class.ilLMPage.php"; ilLMPage::_handleImportRepositoryLinks($this->getImportId(), $this->getType(), $this->getRefId()); } return $mess; }
/** * imports test and question(s) */ function uploadTstObject() { if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK) { ilUtil::sendFailure($this->lng->txt("error_upload")); $this->createObject(); return; } include_once "./Modules/Test/classes/class.ilObjTest.php"; // create import directory $basedir = ilObjTest::_createImportDirectory(); // copy uploaded file to import directory $file = pathinfo($_FILES["xmldoc"]["name"]); $full_path = $basedir . "/" . $_FILES["xmldoc"]["name"]; ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path); // unzip file ilUtil::unzip($full_path); // determine filenames of xml files $subdir = basename($file["basename"], "." . $file["extension"]); ilObjTest::_setImportDirectory($basedir); $xml_file = ilObjTest::_getImportDirectory() . '/' . $subdir . '/' . $subdir . ".xml"; $qti_file = ilObjTest::_getImportDirectory() . '/' . $subdir . '/' . preg_replace("/test|tst/", "qti", $subdir) . ".xml"; $results_file = ilObjTest::_getImportDirectory() . '/' . $subdir . '/' . preg_replace("/test|tst/", "results", $subdir) . ".xml"; if (!is_file($qti_file)) { ilUtil::delDir($basedir); ilUtil::sendFailure($this->lng->txt("tst_import_non_ilias_zip")); $this->createObject(); return; } // start verification of QTI files include_once "./Services/QTI/classes/class.ilQTIParser.php"; $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, ""); $result = $qtiParser->startParsing(); $founditems =& $qtiParser->getFoundItems(); if (count($founditems) == 0) { // nothing found // delete import directory ilUtil::delDir($basedir); ilUtil::sendInfo($this->lng->txt("tst_import_no_items")); $this->createObject(); return; } $complete = 0; $incomplete = 0; foreach ($founditems as $item) { if (strlen($item["type"])) { $complete++; } else { $incomplete++; } } if ($complete == 0) { // delete import directory ilUtil::delDir($basedir); ilUtil::sendInfo($this->lng->txt("qpl_import_non_ilias_files")); $this->createObject(); return; } $_SESSION["tst_import_results_file"] = $results_file; $_SESSION["tst_import_xml_file"] = $xml_file; $_SESSION["tst_import_qti_file"] = $qti_file; $_SESSION["tst_import_subdir"] = $subdir; // display of found questions $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.tst_import_verification.html", "Modules/Test"); $row_class = array("tblrow1", "tblrow2"); $counter = 0; foreach ($founditems as $item) { $this->tpl->setCurrentBlock("verification_row"); $this->tpl->setVariable("ROW_CLASS", $row_class[$counter++ % 2]); $this->tpl->setVariable("QUESTION_TITLE", $item["title"]); $this->tpl->setVariable("QUESTION_IDENT", $item["ident"]); include_once "./Services/QTI/classes/class.ilQTIItem.php"; switch ($item["type"]) { case "MULTIPLE CHOICE QUESTION": case QT_MULTIPLE_CHOICE_MR: //$this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("qt_multiple_choice")); $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assMultipleChoice")); break; case "SINGLE CHOICE QUESTION": case QT_MULTIPLE_CHOICE_SR: $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assSingleChoice")); break; case KPRIM_CHOICE_QUESTION_IDENTIFIER: case QT_KPRIM_CHOICE: $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assKprimChoice")); break; case "NUMERIC QUESTION": case QT_NUMERIC: $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assNumeric")); break; case "TEXTSUBSET QUESTION": case QT_TEXTSUBSET: $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextSubset")); break; case "CLOZE QUESTION": case QT_CLOZE: $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assClozeTest")); break; case "IMAGE MAP QUESTION": case QT_IMAGEMAP: $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assImagemapQuestion")); break; case "JAVA APPLET QUESTION": case QT_JAVAAPPLET: $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assJavaApplet")); break; case "MATCHING QUESTION": case QT_MATCHING: $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assMatchingQuestion")); break; case "ORDERING QUESTION": case QT_ORDERING: $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assOrderingQuestion")); break; case "TEXT QUESTION": case QT_TEXT: $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextQuestion")); break; } $this->tpl->parseCurrentBlock(); } // on import creation screen the pool was chosen (-1 for no pool) // BUT when no pool is available the input on creation screen is missing, so the field value -1 for no pool is not submitted. $QplOrTstID = isset($_POST["qpl"]) && (int) $_POST["qpl"] != 0 ? $_POST["qpl"] : -1; $this->tpl->setCurrentBlock("adm_content"); $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt("question_type")); $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("question_title")); $this->tpl->setVariable("FOUND_QUESTIONS_INTRODUCTION", $this->lng->txt("tst_import_verify_found_questions")); $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_tst")); $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this)); $this->tpl->setVariable("ARROW", ilUtil::getImagePath("arrow_downright.svg")); $this->tpl->setVariable("QUESTIONPOOL_ID", $QplOrTstID); $this->tpl->setVariable("VALUE_IMPORT", $this->lng->txt("import")); $this->tpl->setVariable("VALUE_CANCEL", $this->lng->txt("cancel")); $this->tpl->parseCurrentBlock(); }
public function dbImportSco($slm, $sco, $asset = false) { $qtis = array(); $d = ilUtil::getDir($this->packageFolder); foreach ($d as $f) { //continue; if ($f[type] == 'file' && substr($f[entry], 0, 4) == 'qti_') { include_once "./Services/QTI/classes/class.ilQTIParser.php"; include_once "./Modules/Test/classes/class.ilObjTest.php"; $qtiParser = new ilQTIParser($this->packageFolder . "/" . $f[entry], IL_MO_VERIFY_QTI, 0, ""); $result = $qtiParser->startParsing(); $founditems =& $qtiParser->getFoundItems(); // die(print_r($founditems)); foreach ($founditems as $qp) { $newObj = new ilObjTest(0, true); // This creates a lot of invalid repository objects for each question // question are not repository objects (see e.g. table object_data), alex 29 Sep 2009 // $newObj->setType ( $qp ['type'] ); // $newObj->setTitle ( $qp ['title'] ); // $newObj->create ( true ); // $newObj->createReference (); // $newObj->putInTree ($_GET ["ref_id"]); // $newObj->setPermissions ( $sco->getId ()); // $newObj->notify ("new", $_GET["ref_id"], $sco->getId (), $_GET["ref_id"], $newObj->getRefId () ); // $newObj->mark_schema->flush (); $qtiParser = new ilQTIParser($this->packageFolder . "/" . $f[entry], IL_MO_PARSE_QTI, 0, ""); $qtiParser->setTestObject($newObj); $result = $qtiParser->startParsing(); // $newObj->saveToDb (); $qtis = array_merge($qtis, $qtiParser->getImportMapping()); } } } //exit; include_once 'Modules/Scorm2004/classes/class.ilSCORM2004Page.php'; $doc = new SimpleXMLElement($this->imsmanifest->saveXml()); $l = $doc->xpath("/ContentObject/MetaData"); if ($l[0]) { include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php'; $mdxml =& new ilMDXMLCopier($l[0]->asXML(), $slm->getId(), $sco->getId(), $sco->getType()); $mdxml->startParsing(); $mdxml->getMDObject()->update(); } $l = $doc->xpath("/ContentObject/PageObject"); foreach ($l as $page_xml) { $tnode = $page_xml->xpath('MetaData/General/Title'); $page = new ilSCORM2004PageNode($slm); $page->setTitle($tnode[0]); $page->setSLMId($slm->getId()); $page->create(true); ilSCORM2004Node::putInTree($page, $sco->getId(), $target); $pmd = $page_xml->xpath("MetaData"); if ($pmd[0]) { include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php'; $mdxml =& new ilMDXMLCopier($pmd[0]->asXML(), $slm->getId(), $page->getId(), $page->getType()); $mdxml->startParsing(); $mdxml->getMDObject()->update(); } $tnode = $page_xml->xpath("//MediaObject/MediaAlias | //InteractiveImage/MediaAlias"); foreach ($tnode as $ttnode) { include_once './Services/MediaObjects/classes/class.ilObjMediaObject.php'; $OriginId = $ttnode[OriginId]; $medianodes = $doc->xpath("//MediaObject[MetaData/General/Identifier/@Entry='" . $OriginId . "']"); $medianode = $medianodes[0]; if ($medianode) { $media_object = new ilObjMediaObject(); $media_object->setTitle($medianode->MetaData->General->Title); $media_object->setDescription($medianode->MetaData->General->Description); $media_object->create(false); $mmd = $medianode->xpath("MetaData"); if ($mmd[0]) { include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php'; $mdxml =& new ilMDXMLCopier($mmd[0]->asXML(), 0, $media_object->getId(), $media_object->getType()); $mdxml->startParsing(); $mdxml->getMDObject()->update(); } // determine and create mob directory, move uploaded file to directory $media_object->createDirectory(); $mob_dir = ilObjMediaObject::_getDirectory($media_object->getId()); foreach ($medianode->MediaItem as $xMediaItem) { $media_item =& new ilMediaItem(); $media_object->addMediaItem($media_item); $media_item->setPurpose($xMediaItem[Purpose]); $media_item->setFormat($xMediaItem->Format); $media_item->setLocation($xMediaItem->Location); $media_item->setLocationType($xMediaItem->Location[Type]); $media_item->setWidth($xMediaItem->Layout[Width]); $media_item->setHeight($xMediaItem->Layout[Height]); $media_item->setHAlign($xMediaItem->Layout[HorizontalAlign]); $media_item->setCaption($xMediaItem->Caption); $media_item->setTextRepresentation($xMediaItem->TextRepresentation); $nr = 0; // add map areas (external links only) foreach ($xMediaItem->MapArea as $n => $v) { if ($v->ExtLink[Href] != "") { include_once "./Services/MediaObjects/classes/class.ilMapArea.php"; $ma = new ilMapArea(); $map_area = new ilMapArea(); $map_area->setShape($v[Shape]); $map_area->setCoords($v[Coords]); $map_area->setLinkType(IL_EXT_LINK); $map_area->setTitle($v->ExtLink); $map_area->setHref($v->ExtLink[Href]); $media_item->addMapArea($map_area); } } if ($media_item->getLocationType() == "LocalFile") { // $tmp_name = $this->packageFolder."/objects/".$OriginId."/".$xMediaItem->Location; // copy($tmp_name, $mob_dir."/".$xMediaItem->Location); } } // copy whole directory ilUtil::rCopy($this->packageFolder . "/objects/" . $OriginId, $mob_dir); // alex: fixed media import: these lines have been // behind the next curly bracket which makes it fail // when no medianode is given. (id=0 -> fatal error) ilUtil::renameExecutables($mob_dir); $media_object->update(true); $ttnode[OriginId] = "il__mob_" . $media_object->getId(); } } include_once "./Modules/File/classes/class.ilObjFile.php"; include_once "./Services/Utilities/classes/class.ilFileUtils.php"; include_once "./Services/MediaObjects/classes/class.ilObjMediaObject.php"; $intlinks = $page_xml->xpath("//IntLink"); foreach ($intlinks as $intlink) { if ($intlink[Type] != "File") { continue; } $path = $this->packageFolder . "/objects/" . str_replace('dfile', 'file', $intlink[Target]); if (!is_dir($path)) { continue; } $ffiles = array(); ilFileUtils::recursive_dirscan($path, $ffiles); $filename = $ffiles[file][0]; $fileObj = new ilObjFile(); $fileObj->setType("file"); $fileObj->setTitle(ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename))); $fileObj->setFileName(ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename))); // better use this, mime_content_type is deprecated $fileObj->setFileType(ilObjMediaObject::getMimeType($path . "/" . $filename)); $fileObj->setFileSize(filesize($path . "/" . $filename)); $fileObj->create(); $fileObj->createReference(); //$fileObj->putInTree($_GET["ref_id"]); //$fileObj->setPermissions($slm->getId ()); $fileObj->createDirectory(); $fileObj->storeUnzipedFile($path . "/" . $filename, ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename))); $intlink[Target] = "il__dfile_" . $fileObj->getId(); } $fileitems = $page_xml->xpath("//FileItem/Identifier"); foreach ($fileitems as $fileitem) { $path = $this->packageFolder . "/objects/" . $fileitem[Entry]; if (!is_dir($path)) { continue; } $ffiles = array(); ilFileUtils::recursive_dirscan($path, $ffiles); $filename = $ffiles[file][0]; $fileObj = new ilObjFile(); $fileObj->setType("file"); $fileObj->setTitle(ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename))); $fileObj->setFileName(ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename))); // better use this, mime_content_type is deprecated $fileObj->setFileType(ilObjMediaObject::getMimeType($path . "/" . $filename)); $fileObj->setFileSize(filesize($path . "/" . $filename)); $fileObj->create(); $fileObj->createReference(); //$fileObj->putInTree($_GET["ref_id"]); //$fileObj->setPermissions($slm->getId ()); $fileObj->createDirectory(); $fileObj->storeUnzipedFile($path . "/" . $filename, ilFileUtils::utf8_encode(ilUtil::stripSlashes($filename))); $fileitem[Entry] = "il__file_" . $fileObj->getId(); } $pagex = new ilSCORM2004Page($page->getId()); $ddoc = new DOMDocument(); $ddoc->async = false; $ddoc->preserveWhiteSpace = false; $ddoc->formatOutput = false; $ddoc->loadXML($page_xml->asXML()); $xpath = new DOMXPath($ddoc); $tnode = $xpath->query('PageContent'); $t = "<PageObject>"; foreach ($tnode as $ttnode) { $t .= $ddoc->saveXML($ttnode); } $t .= "</PageObject>"; foreach ($qtis as $old => $q) { $t = str_replace($old, 'il__qst_' . $q['pool'], $t); } $pagex->setXMLContent($t); $pagex->updateFromXML(); } }