/** * Delete Nested Page Objects */ private function delete_rec($a_delete_meta_data = true) { $childs = $this->tree->getChilds($this->getId()); foreach ($childs as $child) { $obj =& ilSCORM2004NodeFactory::getInstance($this->slm_object, $child["obj_id"], false); if (is_object($obj)) { if ($obj->getType() == "page") { $obj->delete($a_delete_meta_data); } } unset($obj); } parent::delete($a_delete_meta_data); }
/** * Paste item (tree) from clipboard or other learning module to target scorm learning module * * @param object $a_target_slm target scorm 2004 learning module object * @param int $a_item_id id of item that should be pasted * @param int $a_parent_id parent id in target tree, * @param int $a_target predecessor target node, no ID means: last child * @param string $a_insert_time cliboard insert time (not needed, if $a_from_cliboard is false) * @param array $a_copied_nodes array of IDs od copied nodes, key is ID of source node, value is ID of copied node * @param bool $a_as_copy if true, items are copied otherwise they are moved * @param bool $a_from_clipboard if true, child node information is read from clipboard, otherwise from source tree */ static function pasteTree($a_target_slm, $a_item_id, $a_parent_id, $a_target, $a_insert_time, &$a_copied_nodes, $a_as_copy = false, $a_from_clipboard = true) { global $ilUser, $ilias, $ilLog; // source lm id, item type and lm object $item_slm_id = ilSCORM2004Node::_lookupSLMID($a_item_id); $item_type = ilSCORM2004Node::_lookupType($a_item_id); //$slm_obj = $ilias->obj_factory->getInstanceByObjId($item_slm_id); include_once "./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php"; $slm_obj = new ilObjSCORM2004LearningModule($item_slm_id, false); if ($item_type == "chap") { include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Chapter.php"; $item = new ilSCORM2004Chapter($slm_obj, $a_item_id); } else { if ($item_type == "page") { include_once "./Modules/Scorm2004/classes/class.ilSCORM2004PageNode.php"; $item = new ilSCORM2004PageNode($slm_obj, $a_item_id); } else { if ($item_type == "sco") { include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php"; $item = new ilSCORM2004Sco($slm_obj, $a_item_id); } else { if ($item_type == "ass") { include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Asset.php"; $item = new ilSCORM2004Asset($slm_obj, $a_item_id); } } } } $ilLog->write("Getting from clipboard type " . $item_type . ", " . "Item ID: " . $a_item_id . ", of original SLM: " . $item_slm_id); if ($item_slm_id != $a_target_slm->getId() && !$a_as_copy) { // @todo: check whether st is NOT in tree // "move" metadata to new lm include_once "Services/MetaData/classes/class.ilMD.php"; $md = new ilMD($item_slm_id, $item->getId(), $item->getType()); $new_md = $md->cloneMD($a_target_slm->getId(), $item->getId(), $item->getType()); // update lm object $item->setSLMId($a_target_slm->getId()); $item->setSLMObject($a_target_slm); $item->update(); // delete old meta data set $md->deleteAll(); if ($item_type == "page") { $page = $item->getPageObject(); $page->buildDom($a_from_clipboard); $page->setParentId($a_target_slm->getId()); $page->update(); } } if ($a_as_copy) { $target_item = $item->copy($a_target_slm); $a_copied_nodes[$item->getId()] = $target_item->getId(); } else { $target_item = $item; } $ilLog->write("Putting into tree type " . $target_item->getType() . "Item ID: " . $target_item->getId() . ", Parent: " . $a_parent_id . ", " . "Target: " . $a_target . ", Item LM:" . $target_item->getContentObject()->getId()); ilSCORM2004Node::putInTree($target_item, $a_parent_id, $a_target); if ($a_from_clipboard) { $childs = $ilUser->getClipboardChilds($item->getId(), $a_insert_time); } else { // get childs of source tree $source_tree = $slm_obj->getTree(); $childs = $source_tree->getChilds($a_item_id); } foreach ($childs as $child) { $child_id = $a_from_clipboard ? $child["id"] : $child["child"]; ilSCORM2004Node::pasteTree($a_target_slm, $child_id, $target_item->getId(), IL_LAST_NODE, $a_insert_time, $a_copied_nodes, $a_as_copy); } return $target_item->getId(); }
/** * Delete Scorm Page * * @param boolean Delete also metadata. */ function delete($a_delete_meta_data = true) { parent::delete($a_delete_meta_data); $this->page_object->delete(); }
/** * Get's the repository object ID of a parent object, if possible * * see ilWebAccessChecker */ function getParentObjectIdForUsage($a_usage, $a_include_all_access_obj_ids = false) { if (is_int(strpos($a_usage["type"], ":"))) { $us_arr = explode(":", $a_usage["type"]); $type = $us_arr[1]; $cont_type = $us_arr[0]; } else { $type = $a_usage["type"]; } $id = $a_usage["id"]; $obj_id = false; switch ($type) { // RTE / tiny mce case "html": switch ($cont_type) { case "qpl": // Question Pool *Question* Text (Test) include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; $qinfo = assQuestion::_getQuestionInfo($id); if ($qinfo["original_id"] > 0) { include_once "./Modules/Test/classes/class.ilObjTest.php"; $obj_id = ilObjTest::_lookupTestObjIdForQuestionId($id); // usage in test } else { $obj_id = $qinfo["obj_fi"]; // usage in pool } break; case "spl": // Question Pool *Question* Text (Survey) include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php"; $quest = SurveyQuestion::_instanciateQuestion($id); if ($quest) { $parent_id = $quest->getObjId(); // pool question copy - find survey, do not use pool itself if ($quest->getOriginalId() && ilObject::_lookupType($parent_id) == "spl") { $obj_id = SurveyQuestion::_lookupSurveyObjId($id); } else { $obj_id = $parent_id; } unset($quest); } break; case "exca": // Exercise assignment $returned_pk = $a_usage['id']; // we are just checking against exercise object include_once 'Modules/Exercise/classes/class.ilObjExercise.php'; $obj_id = ilObjExercise::lookupExerciseIdForReturnedId($returned_pk); break; case "frm": // Forum $post_pk = $a_usage['id']; include_once 'Modules/Forum/classes/class.ilForumPost.php'; include_once 'Modules/Forum/classes/class.ilForum.php'; $oPost = new ilForumPost($post_pk); $frm_pk = $oPost->getForumId(); $obj_id = ilForum::_lookupObjIdForForumId($frm_pk); break; // temporary items (per user) // temporary items (per user) case "frm~": case "exca~": $obj_id = $a_usage['id']; break; // "old" category pages // "old" category pages case "cat": // InfoScreen Text // InfoScreen Text case "tst": case "svy": // data collection // data collection case "dcl": $obj_id = $id; break; } break; // page editor // page editor case "pg": switch ($cont_type) { // question feedback // parent obj id is q id case "qfbg": include_once './Services/COPage/classes/class.ilPageObject.php'; $id = ilPageObject::lookupParentId($id, 'qfbg'); // note: no break here, we only altered the $id to the question id // note: no break here, we only altered the $id to the question id case "qpl": // Question Pool Question Pages include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; $qinfo = assQuestion::_getQuestionInfo($id); if ($qinfo["original_id"] > 0) { include_once "./Modules/Test/classes/class.ilObjTest.php"; $obj_id = ilObjTest::_lookupTestObjIdForQuestionId($id); // usage in test } else { $obj_id = $qinfo["obj_fi"]; // usage in pool } if ($obj_id == 0) { include_once "./Services/COPage/classes/class.ilPCQuestion.php"; $pinfo = ilPCQuestion::_getPageForQuestionId($id, "lm"); if ($pinfo && $pinfo["parent_type"] == "lm") { include_once "./Modules/LearningModule/classes/class.ilLMObject.php"; $obj_id = ilLMObject::_lookupContObjID($pinfo["page_id"]); } $pinfo = ilPCQuestion::_getPageForQuestionId($id, "sahs"); if ($pinfo && $pinfo["parent_type"] == "sahs") { include_once "./Modules/SCORM2004/classes/class.ilSCORM2004Node.php"; $obj_id = ilSCORM2004Node::_lookupSLMID($pinfo["page_id"]); } } break; case "lm": case "dbk": // learning modules include_once "./Modules/LearningModule/classes/class.ilLMObject.php"; $obj_id = ilLMObject::_lookupContObjID($id); break; case "gdf": // glossary definition include_once "./Modules/Glossary/classes/class.ilGlossaryDefinition.php"; include_once "./Modules/Glossary/classes/class.ilGlossaryTerm.php"; $term_id = ilGlossaryDefinition::_lookupTermId($id); $obj_id = ilGlossaryTerm::_lookGlossaryID($term_id); break; case "wpg": // wiki page include_once 'Modules/Wiki/classes/class.ilWikiPage.php'; $obj_id = ilWikiPage::lookupObjIdByPage($id); break; case "sahs": // sahs page // can this implementation be used for other content types, too? include_once './Services/COPage/classes/class.ilPageObject.php'; $obj_id = ilPageObject::lookupParentId($id, 'sahs'); break; case "prtf": // portfolio include_once "Modules/Portfolio/classes/class.ilPortfolioPage.php"; $obj_id = ilPortfolioPage::findPortfolioForPage($id); break; case "prtt": // portfolio template include_once "Modules/Portfolio/classes/class.ilPortfolioTemplatePage.php"; $obj_id = ilPortfolioTemplatePage::findPortfolioForPage($id); break; case "blp": // blog include_once './Services/COPage/classes/class.ilPageObject.php'; $obj_id = ilPageObject::lookupParentId($id, 'blp'); break; case "impr": // imprint page - always id 1 // fallthrough // imprint page - always id 1 // fallthrough case "crs": case "grp": case "cat": case "fold": case "root": case "cont": case "cstr": // repository pages $obj_id = $id; break; } break; // Media Pool // Media Pool case "mep": $obj_id = $id; break; // News Context Object (e.g. MediaCast) // News Context Object (e.g. MediaCast) case "news": include_once "./Services/News/classes/class.ilNewsItem.php"; $obj_id = ilNewsItem::_lookupContextObjId($id); break; } return $obj_id; }
/** * Insert chapter from clipboard */ function insertChapterClip() { global $ilCtrl, $ilUser; include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Node.php"; ilSCORM2004Node::insertChapterClip($this->object); $ilCtrl->redirect($this, "showOrganization", "node_" . ilSCORM2004OrganizationHFormGUI::getPostNodeId()); }
/** * Copy authored content (everything done with the editor * * @param * @return */ function copyAuthoredContent($a_new_obj) { global $ilias; // set/copy stylesheet include_once "./Services/Style/classes/class.ilObjStyleSheet.php"; $style_id = $this->getStyleSheetId(); if ($style_id > 0 && !ilObjStyleSheet::_lookupStandard($style_id)) { $style_obj = $ilias->obj_factory->getInstanceByObjId($style_id); $new_id = $style_obj->ilClone(); $a_new_obj->setStyleSheetId($new_id); $a_new_obj->update(); } $a_new_obj->createScorm2004Tree(); $source_tree = $this->getTree(); $target_tree_root_id = $a_new_obj->getTree()->readRootId(); $childs = $source_tree->getChilds($source_tree->readRootId()); $a_copied_nodes = array(); include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Node.php"; foreach ($childs as $c) { ilSCORM2004Node::pasteTree($a_new_obj, $c["child"], $target_tree_root_id, IL_LAST_NODE, "", $a_copied_nodes, true, false); } }
/** * Insert assets from clipboard */ function insertAssetClip() { global $ilCtrl, $ilUser; ilSCORM2004Node::insertAssetClip($this->slm_object); $ilCtrl->redirect($this, "showOrganization", "node_" . ilSCORM2004OrganizationHFormGUI::getPostNodeId()); }
/** * function import Template * * @return success of import * @author Hendrik Holtmann */ public function importTemplate($a_target, $a_object, $a_parent, $node) { global $ilDB; switch ($node->getAttribute('type')) { case "lesson": if ($this->parentchapter == true) { $chap = new ilSCORM2004SeqChapter($a_object); } else { $chap = new ilSCORM2004Chapter($a_object); } $chap->setTitle($node->getElementsByTagName("title")->item(0)->nodeValue); $chap->setSLMId($a_object->getId()); $chap->create(); $this->sahs_sc13_treeId = $chap->getId(); ilSCORM2004Node::putInTree($chap, $a_parent, $a_target); $a_parent = $this->sahs_sc13_treeId; if ($this->parentchapter == true) { $ilDB->manipulate("INSERT INTO sahs_sc13_seq_assign (identifier, sahs_sc13_tree_node_id) VALUES " . "(" . $ilDB->quote($this->getIdentifier(), "text") . "," . $ilDB->quote($this->sahs_sc13_treeId, "integer") . ")"); $this->parentchapter = false; } $new_id = $chap->getId(); break; case "sco": $sco = new ilSCORM2004Sco($a_object); $sco->setTitle($node->getElementsByTagName("title")->item(0)->nodeValue); $sco->setSLMId($a_object->getId()); $sco->create(false, true); $this->sahs_sc13_treeId = $sco->getId(); ilSCORM2004Node::putInTree($sco, $a_parent, $target); $new_id = $sco->getId(); break; } $seq_node = $node->getElementsByTagName("sequencing")->item(0); $obj_node = $seq_node->getElementsByTagName("objectives")->item(0); //addtitle if ($obj_node) { foreach ($obj_node->childNodes as $objchild) { if ($objchild->nodeName === "objective" || $objchild->nodeName === "primaryObjective") { $title = $objchild->getAttribute('objectiveID'); $objchild->setAttribute("title", $title); $i++; } } } $seq_item = new ilSCORM2004Item(); $seq_item->setTreeNodeId($this->sahs_sc13_treeId); $seq_item->setImportid($this->importId); $seq_item->setNocopy($seq_node->getAttribute('nocopy')); $seq_item->setNodelete($seq_node->getAttribute('nodelete')); $seq_item->setNomove($seq_node->getAttribute('nomove')); $seq_doc = new DOMDocument(); $toadd = $seq_doc->importNode($seq_node, true); $seq_doc->appendChild($toadd); //generate Unique ObjectiveIDs for context //@targetObjectiveID $xpath_obj = new DOMXPath($seq_doc); $found_nodes = $xpath_obj->query('//@objectiveID | //@referencedObjective | //@targetObjectiveID'); for ($i = 0; $i < $found_nodes->length; $i++) { $element = null; $val = $found_nodes->item($i)->value; $uid = $this->sahs_sc13_treeId; if ($found_nodes->item($i)->name == "targetObjectiveID") { $uid = $this->importId; } $val = strtolower(preg_replace('/ +/', '_', $val) . "_" . $uid); $element = $found_nodes->item($i)->ownerElement; $element->setAttribute($found_nodes->item($i)->name, $val); } $seq_item->setDom($seq_doc); $seq_item->insert(); foreach ($node->childNodes as $child) { if ($child->nodeName === "item") { $this->importTemplate($a_target, $a_object, $a_parent, $child); } } return $new_id; }
/** * Standard Version of Fill Row. Most likely to * be overwritten by derived class. */ protected function fillRow($a_set) { global $lng, $ilCtrl; $lng->loadLanguageModule("assessment"); include_once "./Modules/Scorm2004/classes/class.ilSCORM2004NodeFactory.php"; $node_object = ilSCORM2004NodeFactory::getInstance($this->slm_object, $a_set["child"], false); $tr_data = $node_object->getObjectives(); // learning objectives foreach ($tr_data as $data) { $this->tpl->setCurrentBlock("objective"); $this->tpl->setVariable("TXT_LEARNING_OBJECTIVE", ilSCORM2004Sco::convertLists($data->getObjectiveID())); $this->tpl->setVariable("IMG_LOBJ", ilUtil::getImagePath("icon_lobj.svg")); $this->tpl->parseCurrentBlock(); } // pages include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Page.php"; include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php"; $childs = $this->tree->getChilds($a_set["child"]); foreach ($childs as $child) { // get question ids include_once "./Services/COPage/classes/class.ilPCQuestion.php"; $qids = ilPCQuestion::_getQuestionIdsForPage("sahs", $child["child"]); if (count($qids) > 0) { // output questions foreach ($qids as $qid) { $this->tpl->setCurrentBlock("question"); //$qtitle = assQuestion::_getTitle($qid); $qtype = assQuestion::_getQuestionType($qid); //$qtext = assQuestion::_getQuestionText($qid); $qtext = assQuestion::_getQuestionTitle($qid); $this->tpl->setVariable("TXT_QUESTION", $qtext); $this->tpl->setVariable("TXT_QTYPE", $lng->txt($qtype)); $this->tpl->setVariable("IMG_QST", ilUtil::getImagePath("icon_tst.svg")); $this->tpl->parseCurrentBlock(); } // output page title $page_title = ilSCORM2004Node::_lookupTitle($child["child"]); $this->tpl->setCurrentBlock("page"); $this->tpl->setVariable("TXT_PAGE_TITLE", $page_title); $this->tpl->setVariable("IMG_PAGE", ilUtil::getImagePath("icon_pg.svg")); $ilCtrl->setParameterByClass("ilscorm2004pagenodegui", "obj_id", $child["child"]); $this->tpl->setVariable("HREF_EDIT_PAGE", $ilCtrl->getLinkTargetByClass("ilscorm2004pagenodegui", "edit")); $this->tpl->parseCurrentBlock(); } } // sco title $this->tpl->setVariable("TXT_SCO_TITLE", $a_set["title"]); $this->tpl->setVariable("IMG_SCO", ilUtil::getImagePath("icon_sco.svg")); $ilCtrl->setParameterByClass("ilscorm2004scogui", "obj_id", $a_set["child"]); $this->tpl->setVariable("HREF_EDIT_SCO", $ilCtrl->getLinkTargetByClass("ilscorm2004scogui", "showProperties")); }
/** * show related objects as links */ function showTargets(&$tpl, $a_rep_obj_id, $a_note_id, $a_obj_type, $a_obj_id) { global $tree, $ilAccess, $objDefinition, $ilUser; if ($this->targets_enabled) { if ($a_rep_obj_id > 0) { // get all visible references of target object // repository $ref_ids = ilObject::_getAllReferences($a_rep_obj_id); if ($ref_ids) { $vis_ref_ids = array(); foreach ($ref_ids as $ref_id) { if ($ilAccess->checkAccess("visible", "", $ref_id)) { $vis_ref_ids[] = $ref_id; } } // output links to targets if (count($vis_ref_ids) > 0) { foreach ($vis_ref_ids as $vis_ref_id) { $type = ilObject::_lookupType($vis_ref_id, true); $sub_link = $sub_title = ""; if ($type == "sahs") { $link = "goto.php?target=sahs_" . $vis_ref_id; $title = ilObject::_lookupTitle($a_rep_obj_id); if ($a_obj_type == "sco" || $a_obj_type == "seqc" || $a_obj_type == "chap" || $a_obj_type == "pg") { $sub_link = "goto.php?target=sahs_" . $vis_ref_id . "_" . $a_obj_id; include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Node.php"; $sub_title = ilSCORM2004Node::_lookupTitle($a_obj_id); $sub_icon = ilUtil::getImagePath("icon_" . $a_obj_type . ".svg"); } } else { if ($type == "poll") { include_once "Services/Link/classes/class.ilLink.php"; $title = ilObject::_lookupTitle($a_rep_obj_id); $link = ilLink::_getLink($vis_ref_id, "poll"); } else { if ($a_obj_type != "pg") { if (!is_object($this->item_list_gui[$type])) { $class = $objDefinition->getClassName($type); $location = $objDefinition->getLocation($type); $full_class = "ilObj" . $class . "ListGUI"; include_once $location . "/class." . $full_class . ".php"; $this->item_list_gui[$type] = new $full_class(); } // for references, get original title // (link will lead to orignal, which basically is wrong though) if ($a_obj_type == "crsr" || $a_obj_type == "catr") { include_once "Services/ContainerReference/classes/class.ilContainerReference.php"; $tgt_obj_id = ilContainerReference::_lookupTargetId($a_rep_obj_id); $title = ilObject::_lookupTitle($tgt_obj_id); } else { $title = ilObject::_lookupTitle($a_rep_obj_id); } $this->item_list_gui[$type]->initItem($vis_ref_id, $a_rep_obj_id, $title); $link = $this->item_list_gui[$type]->getCommandLink("infoScreen"); // workaround, because # anchor can't be passed through frameset $link = ilUtil::appendUrlParameterString($link, "anchor=note_" . $a_note_id); $link = $this->item_list_gui[$type]->appendRepositoryFrameParameter($link) . "#note_" . $a_note_id; } else { $title = ilObject::_lookupTitle($a_rep_obj_id); $link = "goto.php?target=pg_" . $a_obj_id . "_" . $vis_ref_id; } } } $par_id = $tree->getParentId($vis_ref_id); // sub object link if ($sub_link != "") { if ($this->export_html || $this->print) { $tpl->setCurrentBlock("exp_target_sub_object"); } else { $tpl->setCurrentBlock("target_sub_object"); $tpl->setVariable("LINK_SUB_TARGET", $sub_link); } $tpl->setVariable("TXT_SUB_TARGET", $sub_title); $tpl->setVariable("IMG_SUB_TARGET", $sub_icon); $tpl->parseCurrentBlock(); } // container and object link if ($this->export_html || $this->print) { $tpl->setCurrentBlock("exp_target_object"); } else { $tpl->setCurrentBlock("target_object"); $tpl->setVariable("LINK_TARGET", $link); } $tpl->setVariable("TXT_CONTAINER", ilObject::_lookupTitle(ilObject::_lookupObjId($par_id))); $tpl->setVariable("IMG_CONTAINER", ilObject::_getIcon(ilObject::_lookupObjId($par_id), "tiny")); $tpl->setVariable("TXT_TARGET", $title); $tpl->setVariable("IMG_TARGET", ilObject::_getIcon($a_rep_obj_id, "tiny")); $tpl->parseCurrentBlock(); } $tpl->touchBlock("target_objects"); } } else { // we only need 1 instance if (!$this->wsp_tree) { include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php"; include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php"; $this->wsp_tree = new ilWorkspaceTree($ilUser->getId()); $this->wsp_access_handler = new ilWorkspaceAccessHandler($this->wsp_tree); } $node_id = $this->wsp_tree->lookupNodeId($a_rep_obj_id); if ($this->wsp_access_handler->checkAccess("visible", "", $node_id)) { $path = $this->wsp_tree->getPathFull($node_id); if ($path) { $item = array_pop($path); $parent = array_pop($path); if (!$parent["title"]) { $parent["title"] = $this->lng->txt("wsp_personal_workspace"); } // sub-objects $additional = null; if ($a_obj_id) { $sub_title = $this->getSubObjectTitle($a_rep_obj_id, $a_obj_id); if ($sub_title) { $item["title"] .= " (" . $sub_title . ")"; $additional = "_" . $a_obj_id; } } $link = ilWorkspaceAccessHandler::getGotoLink($node_id, $a_rep_obj_id, $additional); } else { $owner = ilObject::_lookupOwner($a_rep_obj_id); $parent["title"] = $this->lng->txt("wsp_tab_shared") . " (" . ilObject::_lookupOwnerName($owner) . ")"; $item["title"] = ilObject::_lookupTitle($a_rep_obj_id); $link = "ilias.php?baseClass=ilPersonalDesktopGUI&cmd=jumpToWorkspace&dsh=" . $owner; } // container and object link if ($this->export_html || $this->print) { $tpl->setCurrentBlock("exp_target_object"); } else { $tpl->setCurrentBlock("target_object"); $tpl->setVariable("LINK_TARGET", $link); } // :TODO: no images in template ? $tpl->setVariable("TXT_CONTAINER", $parent["title"]); $tpl->setVariable("IMG_CONTAINER", ilObject::_getIcon($parent["obj_id"], "tiny")); $tpl->setVariable("TXT_TARGET", $item["title"]); $tpl->setVariable("IMG_TARGET", ilObject::_getIcon($a_rep_obj_id, "tiny")); $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(); } }