Ejemplo n.º 1
0
 /**
  * update Properties
  */
 function updateProperties()
 {
     global $tpl, $lng;
     $empty = false;
     foreach ($_POST as $key => $value) {
         if (preg_match('/(obj_)(.+)/', $key, $match)) {
             $objective = new ilScorm2004Objective($this->node_object->getId(), $match[2]);
             //				if (!$value)
             //				{
             //					$empty=true;
             //				} else {
             $objective->setObjectiveID(ilUtil::stripSlashes($value));
             $objective->updateObjective();
             //				}
         }
     }
     $this->node_object->setHideObjectivePage(ilUtil::stripSlashes($_POST["hide_objectives_page"]));
     $this->node_object->update();
     include_once "./Services/MetaData/classes/class.ilMD.php";
     $meta = new ilMD($this->node_object->getSLMId(), $this->node_object->getId(), $this->node_object->getType());
     $gen = $meta->getGeneral();
     $desc_ids = $gen->getDescriptionIds();
     $des = $gen->getDescription($desc_ids[0]);
     $des->setDescription(ilUtil::stripSlashes($_POST["desc"]));
     $des->update();
     $gen->update();
     if (!$empty) {
         ilUtil::sendInfo($lng->txt("saved_successfully"), true);
     } else {
         ilUtil::sendFailure($lng->txt("sahs_empty_objectives_are_not_allowed"), true);
     }
     $this->showProperties();
 }
 /**
  * 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");
 }
 /**
  * Imports an extracted SCORM 2004 module from ilias-data dir into database
  *
  * @access       public
  * @return       string title of package
  */
 public function il_importSco($packageId, $sco_id, $packageFolder)
 {
     global $ilDB, $ilLog;
     $this->packageFolder = $packageFolder;
     $this->packageId = $packageId;
     $this->imsmanifestFile = $this->packageFolder . '/' . 'index.xml';
     $this->imsmanifest = new DOMDocument();
     $this->imsmanifest->async = false;
     if (!@$this->imsmanifest->load($this->imsmanifestFile)) {
         $this->diagnostic[] = 'XML not wellformed';
         return false;
     }
     $slm = new ilObjSCORM2004LearningModule($packageId, false);
     $sco = new ilSCORM2004Sco($slm, $sco_id);
     $this->dbImportSco($slm, $sco);
     // import sco.xml
     $sco_xml_file = $this->packageFolder . '/sco.xml';
     if (is_file($sco_xml_file)) {
         $scodoc = new DOMDocument();
         $scodoc->async = false;
         if (!@$scodoc->load($sco_xml_file)) {
             $this->diagnostic[] = 'XML of sco.xml not wellformed';
             return false;
         }
         //$doc = new SimpleXMLElement($scodoc->saveXml());
         //$l = $doc->xpath("/sco/objective");
         $xpath = new DOMXPath($scodoc);
         $nodes = $xpath->query("/sco/objective");
         foreach ($nodes as $node) {
             $t_node = $node->firstChild;
             if (is_object($t_node)) {
                 $objective_text = $t_node->textContent;
                 if (trim($objective_text) != "") {
                     $objs = $sco->getObjectives();
                     foreach ($objs as $o) {
                         $mappings = $o->getMappings();
                         if ($mappings == null) {
                             $ob = new ilScorm2004Objective($sco->getId(), $o->getId());
                             $ob->setObjectiveID($objective_text);
                             $ob->updateObjective();
                         }
                     }
                 }
             }
         }
     }
     return "";
 }