Esempio n. 1
0
 /**
  * Create asset
  */
 function create($a_upload = false, $a_template = false)
 {
     include_once "./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Item.php";
     include_once "./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Objective.php";
     parent::create($a_upload);
     if (!$a_template) {
         $seq_item = new ilSCORM2004Item($this->getId());
         $seq_item->insert();
     }
 }
 /**
 * Constructor
 * @access	public
 */
 function ilSCORM2004Sequencing($a_treeid = null, $a_rootlevel = false)
 {
     parent::ilSCORM2004Item($a_treeid, $a_rootlevel);
     if ($a_treeid != null) {
         $xpath_obj = new DOMXPath($this->dom);
         $obj_node_list = $xpath_obj->query('//controlMode');
         $this->setNode($obj_node_list->item(0));
         if ($obj_node_list->length != 1) {
             $obj_con = $this->dom->createElement("controlMode");
             $root = $this->dom->getElementsByTagName("sequencing")->item(0);
             $root->appendChild($obj_con);
             $this->node = $this->dom->getElementsByTagName("controlMode")->item(0);
             $this->setFlow(true);
             $this->setChoice(true);
             $this->setForwardOnly(false);
         }
     }
 }
 public function deleteSeqInfo()
 {
     include_once "./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Item.php";
     $seq_item = new ilSCORM2004Item($this->getId());
     $seq_item->delete();
 }
 /**
  * write item hierarchy (Recursive Style)
  *
  */
 function writeItemHierarchyRec($tree, $a_parent_node)
 {
     foreach ($tree->getFilteredChilds(array('page'), $a_parent_node) as $obj) {
         if ($obj['type'] == '') {
             continue;
         }
         $attrs = array();
         $attrs["identifier"] = "il_" . IL_INST_ID . "_" . $obj['type'] . "_" . $obj['obj_id'];
         if ($obj['type'] == 'sco' || $obj['type'] == 'ass') {
             $attrs["identifierref"] = $attrs["identifier"] . "_ref";
         }
         $this->writer->xmlStartTag("item", $attrs);
         $attrs = array();
         $this->writer->xmlElement("title", $attrs, $obj['title']);
         if ($tree->getFilteredChilds(array('page'), $obj['obj_id'])) {
             $this->writeItemHierarchyRec($tree, $obj['obj_id']);
         }
         if ($this->version == "2004") {
             if ($obj['type'] == 'sco' || $obj['type'] == 'ass') {
                 $this->writer->xmlStartTag("metadata");
                 $this->writer->xmlElement("adlcp:location", null, $obj['obj_id'] . "/indexMD.xml");
                 $this->writer->xmlEndTag("metadata");
             }
             require_once "./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Item.php";
             $seq_item = new ilSCORM2004Item($obj['obj_id']);
             $this->writer->xmlData($this->writer->xmlFormatData($seq_item->exportAsXML()), false, false);
         }
         $this->writer->xmlEndTag("item");
     }
 }
 /**
  * Save sequencing
  */
 function saveSequencing()
 {
     global $tpl, $lng, $ilCtrl;
     include_once "./Modules/Scorm2004/classes/seq_editor/class.ilSCORM2004Item.php";
     include_once "./Modules/Scorm2004/classes/class.ilSCORM2004Sco.php";
     $t = $this->object->getTree();
     $root_node = $t->getNodeData($t->getRootId());
     $nodes = $this->object->getTree()->getSubtree($root_node);
     foreach ($nodes as $node) {
         if (in_array($node["type"], array("", "chap", "sco"))) {
             if ($node["type"] == "") {
                 $item = new ilSCORM2004Item($this->object->getId(), true);
             } else {
                 $item = new ilSCORM2004Item($node["child"]);
             }
             $xml = '<?xml version="1.0"?>' . ilUtil::stripSlashes($_POST["seq"][$node["child"]], false);
             $ob_texts = array();
             if ($node["type"] == "sco") {
                 $sco = new ilSCORM2004Sco($this->object, $node["child"]);
                 $objectives = $sco->getObjectives();
                 foreach ($objectives as $o) {
                     $ob_texts[$o->getId()] = $o->getObjectiveId();
                 }
             }
             $item->setSeqXml($xml);
             $item->initDom();
             $item->update();
             if ($node["type"] == "sco") {
                 foreach ($ob_texts as $id => $t) {
                     $objective = new ilScorm2004Objective($node["child"], $id);
                     $objective->setObjectiveId($t);
                     $objective->updateObjective();
                 }
             }
         }
     }
     ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
     $ilCtrl->redirect($this, "showSequencing");
 }
 public function updateObjective()
 {
     parent::update();
 }
 /**
  * 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;
 }