/** * Copy sco */ function copy($a_target_slm) { $ass = new ilSCORM2004Asset($a_target_slm); $ass->setTitle($this->getTitle()); if ($this->getSLMId() != $a_target_slm->getId()) { $ass->setImportId("il__ass_" . $this->getId()); } $ass->setSLMId($a_target_slm->getId()); $ass->setType($this->getType()); $ass->setDescription($this->getDescription()); $ass->create(true); $a_copied_nodes[$this->getId()] = $ass->getId(); // copy meta data include_once "Services/MetaData/classes/class.ilMD.php"; $md = new ilMD($this->getSLMId(), $this->getId(), $this->getType()); $new_md = $md->cloneMD($a_target_slm->getId(), $ass->getId(), $this->getType()); return $ass; }
/** * 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(); }
/** * Insert (multiple) assets at node */ function insertAsset($a_redirect = true) { global $ilCtrl, $lng; include_once "./Modules/Scorm2004/classes/class.ilSCORM2004OrganizationHFormGUI.php"; $slm_tree =& new ilTree($this->object->getId()); $slm_tree->setTreeTablePK("slm_id"); $slm_tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node'); $num = ilSCORM2004OrganizationHFormGUI::getPostMulti(); $node_id = ilSCORM2004OrganizationHFormGUI::getPostNodeId(); include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Asset.php"; include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Node.php"; if (!ilSCORM2004OrganizationHFormGUI::getPostFirstChild()) { $parent_id = $slm_tree->getParentId($node_id); $target = $node_id; } else { $parent_id = $node_id; $target = IL_FIRST_NODE; } $ass_ids = array(); for ($i = 1; $i <= $num; $i++) { $ass = new ilSCORM2004Asset($this->object); $ass->setTitle($lng->txt("sahs_new_asset")); $ass->setSLMId($this->object->getId()); $ass->create(); ilSCORM2004Node::putInTree($ass, $parent_id, $target); $ass_ids[] = $ass->getId(); } $ass_ids = array_reverse($ass_ids); $ass_ids = implode($ass_ids, ":"); if ($a_redirect) { $ilCtrl->setParameter($this, "highlight", $ass_ids); $ilCtrl->redirect($this, "showOrganization", "node_" . $node_id); } return array("node_id" => $node_id, "items" => $ass_ids); }
function dbImportLM($node, $parent_id = "", $a_import_sequencing = false) { switch ($node->getName()) { case "manifest": $this->slm_tree =& new ilTree($this->slm->getId()); $this->slm_tree->setTreeTablePK("slm_id"); $this->slm_tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node'); $this->slm_tree->addTree($this->slm->getId(), 1); //add seqinfo for rootNode include_once "./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Sequencing.php"; $seq_info = new ilSCORM2004Sequencing($this->slm->getId(), true); // get original sequencing information $r = $this->mani_xpath->query("/d:manifest/d:organizations/d:organization/imsss:sequencing"); $this->imsmanifest->formatOutput = false; if ($r) { $this->setSequencingInfo($r->item(0), $seq_info, $a_import_sequencing); if ($a_import_sequencing) { $seq_info->initDom(); } } $seq_info->insert(); if (file_exists($this->packageFolder . '/' . 'index.xml')) { $doc = simplexml_load_file($this->packageFolder . '/' . 'index.xml'); $l = $doc->xpath("/ContentObject/MetaData"); if ($l[0]) { include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php'; $mdxml =& new ilMDXMLCopier($l[0]->asXML(), $this->slm->getId(), $this->slm->getId(), $this->slm->getType()); $mdxml->startParsing(); $mdxml->getMDObject()->update(); } } break; case "organization": $this->slm->title = $node->title; break; case "item": $a = $node->attributes(); if (preg_match("/il_\\d+_chap_\\d+/", $a['identifier'])) { $chap =& new ilSCORM2004Chapter($this->slm); $chap->setTitle($node->title); $chap->setSLMId($this->slm->getId()); $chap->create(true); // save sequencing information $r = $this->mani_xpath->query("//d:item[@identifier='" . $a['identifier'] . "']/imsss:sequencing"); if ($r) { $seq_info = new ilSCORM2004Sequencing($chap->getId()); $this->setSequencingInfo($r->item(0), $seq_info, $a_import_sequencing); $seq_info->initDom(); $seq_info->insert(); } ilSCORM2004Node::putInTree($chap, $parent_id, ""); $parent_id = $chap->getId(); $doc = simplexml_load_file($this->packageFolder . '/' . 'index.xml'); $l = $doc->xpath("/ContentObject/StructureObject/MetaData[General/Identifier/@Entry='" . $a['identifier'] . "']"); if ($l[0]) { include_once 'Services/MetaData/classes/class.ilMDXMLCopier.php'; $mdxml =& new ilMDXMLCopier($l[0]->asXML(), $this->slm->getId(), $chap->getId(), $chap->getType()); $mdxml->startParsing(); $mdxml->getMDObject()->update(); } } if (preg_match("/il_\\d+_sco_(\\d+)/", $a['identifier'], $match)) { $sco = new ilSCORM2004Sco($this->slm); $sco->setTitle($node->title); $sco->setSLMId($this->slm->getId()); $sco->create(true); // save sequencing information $r = $this->mani_xpath->query("//d:item[@identifier='" . $a['identifier'] . "']/imsss:sequencing"); if ($r) { $seq_info = new ilSCORM2004Sequencing($sco->getId()); $this->setSequencingInfo($r->item(0), $seq_info, $a_import_sequencing, "local_obj_" . $sco->getID() . "_0"); $seq_info->initDom(); $seq_info->insert(); } ilSCORM2004Node::putInTree($sco, $parent_id, ""); $newPack = new ilSCORM13Package(); $newPack->il_importSco($this->slm->getId(), $sco->getId(), $this->packageFolder . "/" . $match[1]); $parent_id = $sco->getId(); } if (preg_match("/il_\\d+_ass_(\\d+)/", $a['identifier'], $match)) { $ass = new ilSCORM2004Asset($this->slm); $ass->setTitle($node->title); $ass->setSLMId($this->slm->getId()); $ass->create(true); // save sequencing information $r = $this->mani_xpath->query("//d:item[@identifier='" . $a['identifier'] . "']/imsss:sequencing"); if ($r) { $seq_info = new ilSCORM2004Sequencing($ass->getId()); $this->setSequencingInfo($r->item(0), $seq_info, $a_import_sequencing, "local_obj_" . $ass->getID() . "_0"); $seq_info->initDom(); $seq_info->insert(); } ilSCORM2004Node::putInTree($ass, $parent_id, ""); $newPack = new ilSCORM13Package(); $newPack->il_importAss($this->slm->getId(), $ass->getId(), $this->packageFolder . "/" . $match[1]); $parent_id = $ass->getId(); } break; } foreach ($node->children() as $child) { $this->dbImportLM($child, $parent_id, $a_import_sequencing); } }