/** * 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(); }
/** * Delete */ function delete() { global $ilDB; parent::delete(); $ilDB->manipulate("DELETE FROM sahs_sc13_sco WHERE " . " id = " . $ilDB->quote($this->getId(), "integer")); }
/** * 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); }
/** * SCO preview */ function sco_preview() { global $tpl, $ilCtrl, $lng; // init main template $tpl = new ilTemplate("tpl.main.html", true, true); include_once "./Services/Style/classes/class.ilObjStyleSheet.php"; $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation()); $tpl->setBodyClass(""); $tpl->setCurrentBlock("ContentStyle"); $tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath($this->slm_object->getStyleSheetId())); $tpl->parseCurrentBlock(); // get javascript include_once "./Services/jQuery/classes/class.iljQueryUtil.php"; iljQueryUtil::initjQuery(); iljQueryUtil::initjQueryUI(); $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/pure.js"); $tpl->addJavaScript("./Modules/Scorm2004/scripts/pager.js"); $tpl->addOnLoadCode("pager.Init();"); $tree = new ilTree($this->slm_object->getId()); $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node'); $tree->setTreeTablePK("slm_id"); include_once "./Modules/Scorm2004/classes/class.ilSCORM2004PageGUI.php"; include_once "./Services/MetaData/classes/class.ilMD.php"; $meta = new ilMD($this->node_object->getSLMId(), $this->node_object->getId(), $this->node_object->getType()); $desc_ids = $meta->getGeneral()->getDescriptionIds(); $sco_description = $meta->getGeneral()->getDescription($desc_ids[0])->getDescription(); // get sco template $sco_tpl = new ilTemplate("tpl.sco.html", true, true, "Modules/Scorm2004"); // navigation $lk = ilObjSAHSLearningModule::getAffectiveLocalization($this->node_object->getSLMId()); ilSCORM2004Asset::renderNavigation($sco_tpl, "", $lk); // meta page (description and objectives) ilSCORM2004Asset::renderMetaPage($sco_tpl, $this->node_object, $this->node_object->getType()); // init export (this initialises glossary template) ilSCORM2004PageGUI::initExport(); $terms = $this->node_object->getGlossaryTermIds(); // render page foreach ($tree->getSubTree($tree->getNodeData($this->node_object->getId()), true, 'page') as $page) { $page_obj = new ilSCORM2004PageGUI($this->node_object->getType(), $page["obj_id"], 0, $this->slm_object->getId()); $page_obj->setPresentationTitle($page["title"]); $page_obj->setOutputMode(IL_PAGE_PREVIEW); $page_obj->setStyleId($this->slm_object->getStyleSheetId()); if (count($terms) > 1) { $page_obj->setGlossaryOverviewInfo(ilSCORM2004ScoGUI::getGlossaryOverviewId(), $this->node_object); } $sco_tpl->setCurrentBlock("page_preview"); $html = $ilCtrl->getHTML($page_obj); //$sco_tpl->setVariable("PAGE_PRV", $page_obj->showPage("export")); $sco_tpl->setVariable("PAGE_PRV", $html); $sco_tpl->parseCurrentBlock(); } $output = $sco_tpl->get(); // append glossary entries on the sco level $output .= ilSCORM2004PageGUI::getGlossaryHTML($this->node_object); //insert questions require_once './Modules/Scorm2004/classes/class.ilQuestionExporter.php'; $output = preg_replace_callback("/{{{{{(Question;)(il__qst_[0-9]+)}}}}}/", array(get_class($this), 'insertQuestion'), $output); // $output = preg_replace("/{/","",$output); // $output = preg_replace("/}/","",$output); $output = "<script>var ScormApi=null;" . ilQuestionExporter::questionsJS() . "</script>" . $output; $lk = ilObjSAHSLearningModule::getAffectiveLocalization($this->node_object->getSLMId()); // include_once("./Modules/Scorm2004/classes/class.ilSCORM2004PageGUI.php"); // ilSCORM2004PageGUI::addPreparationJavascript($tpl, $lk); $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/question_handling.js"); $tpl->addCss("./Modules/Scorm2004/templates/default/question_handling.css"); include_once "./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php"; ilOverlayGUI::initJavascript(); //inline JS $output .= '<script type="text/javascript" src="./Modules/Scorm2004/scripts/questions/question_handling.js"></script>'; $tpl->setVariable("CONTENT", $output); }
/** * export page objects to xml (see ilias_co.dtd) * * @param object $a_xml_writer ilXmlWriter object that receives the * xml data */ function exportXMLScoObjects($a_inst, $a_target_dir, $ver, &$expLog) { global $ilBench; $tree = new ilTree($this->getId()); $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node'); $tree->setTreeTablePK("slm_id"); foreach ($tree->getSubTree($tree->getNodeData($tree->getRootId()), true, array('sco', 'ass')) as $sco) { if ($sco['type'] == "sco") { include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php"; $sco_folder = $a_target_dir . "/" . $sco['obj_id']; ilUtil::makeDir($sco_folder); $node = new ilSCORM2004Sco($this, $sco['obj_id']); $node->exportScorm($a_inst, $sco_folder, $ver, $expLog); } if ($sco['type'] == "ass") { include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Asset.php"; $sco_folder = $a_target_dir . "/" . $sco['obj_id']; ilUtil::makeDir($sco_folder); $node = new ilSCORM2004Asset($this, $sco['obj_id']); $node->exportScorm($a_inst, $sco_folder, $ver, $expLog); } } }
/** * Constructor * * @param object SCORM LM object */ function __construct($a_slm_object) { parent::ilSCORM2004Node($a_slm_object); $this->setType("ass"); }
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); } }