/** * execute command */ function &executeCommand() { global $ilCtrl, $tpl; $next_class = $ilCtrl->getNextClass($this); $cmd = $ilCtrl->getCmd(); switch ($next_class) { case "ilscorm2004pagegui": $tpl->getStandardTemplate(); $this->setContentStyle(); $this->setLocator(); // Determine whether the view of a learning resource should // be shown in the frameset of ilias, or in a separate window. //$showViewInFrameset = $this->ilias->ini->readVariable("layout","view_target") == "frame"; $showViewInFrameset = true; $ilCtrl->setReturn($this, "edit"); include_once "./Modules/Scorm2004/classes/class.ilSCORM2004PageGUI.php"; $page_gui =& new ilSCORM2004PageGUI($this->slm_object->getType(), $this->node_object->getId(), 0, $this->getParentGUI()->object->getId(), $this->slm_object->getAssignedGlossary()); $page_gui->setEditPreview(true); $page_gui->setPresentationTitle($this->node_object->getTitle()); include_once "./Services/Style/classes/class.ilObjStyleSheet.php"; $page_gui->setStyleId(ilObjStyleSheet::getEffectiveContentStyleId($this->slm_object->getStyleSheetId(), "sahs")); if ($this->node_object->tree->getParentId($this->node_object->getId()) > 0) { $sco = new ilSCORM2004Sco($this->node_object->getSLMObject(), $this->node_object->tree->getParentId($this->node_object->getId())); if (count($sco->getGlossaryTermIds()) > 1) { include_once "./Modules/Scorm2004/classes/class.ilSCORM2004ScoGUI.php"; $page_gui->setGlossaryOverviewInfo(ilSCORM2004ScoGUI::getGlossaryOverviewId(), $sco); } } $ilCtrl->setParameterByClass("ilobjscorm2004learningmodulegui", "active_node", $_GET["obj_id"]); $page_gui->setExplorerUpdater("tree", "tree_div", $ilCtrl->getLinkTargetByClass("ilobjscorm2004learningmodulegui", "showTree", "", true)); $ilCtrl->setParameterByClass("ilobjscorm2004learningmodulegui", "active_node", ""); // set page view link $view_frame = ilFrameTargetInfo::_getFrame("MainContent"); $page_gui->setLinkParams("ref_id=" . $this->slm_object->getRefId()); $tpl->setTitleIcon(ilUtil::getImagePath("icon_pg_b.png")); $page_gui->activateMetaDataEditor($this->slm_object->getID(), $this->node_object->getId(), $this->node_object->getType(), $this->node_object, 'MDUpdateListener'); $ret = $ilCtrl->forwardCommand($page_gui); $this->setTabs(); $tpl->setContent($ret); break; default: $ret =& $this->{$cmd}(); break; } return $ret; }
/** * 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")); }
/** * Copy sco */ function copy($a_target_slm) { $sco = new ilSCORM2004Sco($a_target_slm); $sco->setTitle($this->getTitle()); if ($this->getSLMId() != $a_target_slm->getId()) { $sco->setImportId("il__sco_" . $this->getId()); } $sco->setSLMId($a_target_slm->getId()); $sco->setType($this->getType()); $sco->setDescription($this->getDescription()); $sco->create(true); $a_copied_nodes[$this->getId()] = $sco->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(), $sco->getId(), $this->getType()); return $sco; }
/** * Insert (multiple) scos at node */ function insertSco($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.ilSCORM2004Sco.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; } $sco_ids = array(); for ($i = 1; $i <= $num; $i++) { $sco = new ilSCORM2004Sco($this->object); $sco->setTitle($lng->txt("sahs_new_sco")); $sco->setSLMId($this->object->getId()); $sco->create(); ilSCORM2004Node::putInTree($sco, $parent_id, $target); $sco_ids[] = $sco->getId(); } $sco_ids = array_reverse($sco_ids); $sco_ids = implode($sco_ids, ":"); if ($a_redirect) { $ilCtrl->setParameter($this, "highlight", $sco_ids); $ilCtrl->redirect($this, "showOrganization", "node_" . $node_id); } return array("node_id" => $node_id, "items" => $sco_ids); }
function exportHTMLScoObjects($a_inst, $a_target_dir, &$expLog, $a_one_file = "") { global $ilBench; $tree = new ilTree($this->getId()); $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node'); $tree->setTreeTablePK("slm_id"); // copy all necessary files now if ($a_one_file != "") { $this->prepareHTMLExporter($a_target_dir); // put header into file $sco_tpl = new ilTemplate("tpl.sco.html", true, true, "Modules/Scorm2004"); include_once "./Services/COPage/classes/class.ilCOPageHTMLExport.php"; $sco_tpl = ilCOPageHTMLExport::getPreparedMainTemplate($sco_tpl); $sco_tpl->setCurrentBlock("js_file"); $sco_tpl->setVariable("JS_FILE", "./js/pure.js"); $sco_tpl->parseCurrentBlock(); $sco_tpl->setCurrentBlock("js_file"); $sco_tpl->setVariable("JS_FILE", "./js/question_handling.js"); $sco_tpl->parseCurrentBlock(); $sco_tpl->setCurrentBlock("head"); $sco_tpl->parseCurrentBlock(); fputs($a_one_file, $sco_tpl->get("head")); // toc include_once "./Modules/Scorm2004/classes/class.ilContObjectManifestBuilder.php"; $manifestBuilder = new ilContObjectManifestBuilder($this); $manifestBuilder->buildManifest('12'); $xsl = file_get_contents("./Modules/Scorm2004/templates/xsl/module.xsl"); $xml = simplexml_load_string($manifestBuilder->writer->xmlDumpMem()); $args = array('/_xml' => $xml->organizations->organization->asXml(), '/_xsl' => $xsl); $xh = xslt_create(); $params = array("one_page" => "y"); $output = xslt_process($xh, "arg:/_xml", "arg:/_xsl", NULL, $args, $params); xslt_free($xh); fputs($a_one_file, $output); } foreach ($tree->getSubTree($tree->getNodeData($tree->getRootId()), true, 'sco') as $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']); if ($a_one_file == "") { $node->exportHTML($a_inst, $sco_folder, $expLog, $a_one_file); } else { $node->exportHTMLPageObjects($a_inst, $a_target_dir, $expLog, 'full', "sco", $a_one_file, $sco_tpl); } if ($this->getAssignedGlossary() != 0) { include_once "./Modules/Glossary/classes/class.ilObjGlossary.php"; $glos = new ilObjGlossary($this->getAssignedGlossary(), false); //$glos->exportHTML($sco_folder."/glossary", $expLog); } } // copy all necessary files now if ($a_one_file != "") { // put tail into file fputs($a_one_file, $sco_tpl->get("tail")); } }
/** * 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; }
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); } }