Esempio n. 1
0
 /**
  * Create sco
  */
 function create($a_upload = false, $a_template = false)
 {
     global $ilDB;
     parent::create($a_upload, $a_template);
     if (!$a_template) {
         $obj = new ilSCORM2004Objective($this->getId());
         //			$obj->setObjectiveID("Objective SCO ".$this->getId());
         $obj->setId("local_obj_" . $this->getID() . "_0");
         $obj->update();
     }
     $ilDB->manipulate("INSERT INTO sahs_sc13_sco " . "(id, hide_obj_page) VALUES (" . $ilDB->quote($this->getId(), "integer") . "," . $ilDB->quote($this->getHideObjectivePage(), "integer") . ")");
 }
Esempio n. 2
0
 /**
  * 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;
 }
 /**
  * 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);
     }
 }