/**
  * 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"));
 }
 /**
  * Delete Nested Page Objects
  */
 private function delete_rec($a_delete_meta_data = true)
 {
     $childs = $this->tree->getChilds($this->getId());
     foreach ($childs as $child) {
         $obj =& ilSCORM2004NodeFactory::getInstance($this->slm_object, $child["obj_id"], false);
         if (is_object($obj)) {
             if ($obj->getType() == "page") {
                 $obj->delete($a_delete_meta_data);
             }
         }
         unset($obj);
     }
     parent::delete($a_delete_meta_data);
 }
 /**
  * Delete all nodes of Scorm Learning Module
  *
  * @param	object		Scorm 2004 Learning Module Object
  */
 function _deleteAllSLMNodes($a_slm_object)
 {
     global $ilDB;
     $query = "SELECT * FROM sahs_sc13_tree_node " . "WHERE slm_id = " . $ilDB->quote($a_slm_object->getId(), "integer") . " ";
     $obj_set = $ilDB->query($query);
     require_once "./Modules/Scorm2004/classes/class.ilSCORM2004NodeFactory.php";
     while ($obj_rec = $ilDB->fetchAssoc($obj_set)) {
         $node_obj = ilSCORM2004NodeFactory::getInstance($a_slm_object, $obj_rec["obj_id"], false);
         if (is_object($node_obj)) {
             $node_obj->delete();
         }
     }
     return true;
 }
 /**
  * Delete chapters/scos/pages
  */
 function confirmedDelete($a_redirect = true)
 {
     global $ilCtrl;
     $tree = new ilTree($this->object->getId());
     $tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
     $tree->setTreeTablePK("slm_id");
     // delete all selected objects
     include_once "./Modules/Scorm2004/classes/class.ilSCORM2004NodeFactory.php";
     foreach ($_POST["id"] as $id) {
         if ($id != IL_FIRST_NODE) {
             $obj = ilSCORM2004NodeFactory::getInstance($this->object, $id, false);
             $node_data = $tree->getNodeData($id);
             if (is_object($obj)) {
                 $obj->setSLMId($this->object->getId());
                 /*include_once("./Services/History/classes/class.ilHistory.php");
                 	 ilHistory::_createEntry($this->object->getId(), "delete_".$obj->getType(),
                 		array(ilLMObject::_lookupTitle($id), $id),
                 		$this->object->getType());*/
                 $obj->delete();
             }
             if ($tree->isInTree($id)) {
                 $tree->deleteTree($node_data);
             }
         }
     }
     // check the tree
     //		$this->object->checkTree();
     // feedback
     ilUtil::sendInfo($this->lng->txt("info_deleted"), true);
     if ($a_redirect) {
         $ilCtrl->redirect($this, "showOrganization");
     }
 }
 /**
  * Execute Drag Drop Action
  *
  * @param	string	$source_id		Source element ID
  * @param	string	$target_id		Target element ID
  * @param	string	$first_child	Insert as first child of target
  * @param	string	$movecopy		Position ("move" | "copy")
  */
 function executeDragDrop($source_id, $target_id, $first_child, $as_subitem = false, $movecopy = "move")
 {
     $this->slm_tree = new ilTree($this->getId());
     $this->slm_tree->setTableNames('sahs_sc13_tree', 'sahs_sc13_tree_node');
     $this->slm_tree->setTreeTablePK("slm_id");
     require_once "./Modules/Scorm2004/classes/class.ilSCORM2004NodeFactory.php";
     $source_obj = ilSCORM2004NodeFactory::getInstance($this, $source_id, true);
     //$source_obj->setLMId($this->getId());
     if (!$first_child) {
         $target_obj = ilSCORM2004NodeFactory::getInstance($this, $target_id, true);
         //$target_obj->setLMId($this->getId());
         $target_parent = $this->slm_tree->getParentId($target_id);
     }
     //echo "-".$source_obj->getType()."-";
     // handle pages
     if ($source_obj->getType() == "page") {
         if ($this->slm_tree->isInTree($source_obj->getId())) {
             $node_data = $this->slm_tree->getNodeData($source_obj->getId());
             // cut on move
             if ($movecopy == "move") {
                 $parent_id = $this->slm_tree->getParentId($source_obj->getId());
                 $this->slm_tree->deleteTree($node_data);
                 // write history entry
                 /*					require_once("./Services/History/classes/class.ilHistory.php");
                 					ilHistory::_createEntry($source_obj->getId(), "cut",
                 						array(ilLMObject::_lookupTitle($parent_id), $parent_id),
                 						$this->getType().":pg");
                 					ilHistory::_createEntry($parent_id, "cut_page",
                 						array(ilLMObject::_lookupTitle($source_obj->getId()), $source_obj->getId()),
                 						$this->getType().":st");
                 */
             }
             /*				else			// this is not implemented here
             				{
             					// copy page
             					$new_page =& $source_obj->copy();
             					$source_id = $new_page->getId();
             					$source_obj =& $new_page;
             				}
             */
             // paste page
             if (!$this->slm_tree->isInTree($source_obj->getId())) {
                 if ($first_child) {
                     $target_pos = IL_FIRST_NODE;
                     $parent = $target_id;
                 } else {
                     if ($as_subitem) {
                         $parent = $target_id;
                         $target_pos = IL_FIRST_NODE;
                         $pg_childs = $this->slm_tree->getChildsByType($parent, "page");
                         if (count($pg_childs) != 0) {
                             $target_pos = $pg_childs[count($pg_childs) - 1]["obj_id"];
                         }
                     } else {
                         $target_pos = $target_id;
                         $parent = $target_parent;
                     }
                 }
                 // insert page into tree
                 $this->slm_tree->insertNode($source_obj->getId(), $parent, $target_pos);
                 // write history entry
                 /*					if ($movecopy == "move")
                 					{
                 						// write history comments
                 						include_once("./Services/History/classes/class.ilHistory.php");
                 						ilHistory::_createEntry($source_obj->getId(), "paste",
                 							array(ilLMObject::_lookupTitle($parent), $parent),
                 							$this->getType().":pg");
                 						ilHistory::_createEntry($parent, "paste_page",
                 							array(ilLMObject::_lookupTitle($source_obj->getId()), $source_obj->getId()),
                 							$this->getType().":st");
                 					}
                 */
             }
         }
     }
     // handle scos
     if ($source_obj->getType() == "sco" || $source_obj->getType() == "ass") {
         //echo "2";
         $source_node = $this->slm_tree->getNodeData($source_id);
         $subnodes = $this->slm_tree->getSubtree($source_node);
         // check, if target is within subtree
         foreach ($subnodes as $subnode) {
             if ($subnode["obj_id"] == $target_id) {
                 return;
             }
         }
         $target_pos = $target_id;
         if ($first_child) {
             $target_pos = IL_FIRST_NODE;
             $target_parent = $target_id;
             $pg_childs = $this->slm_tree->getChildsByType($target_parent, "page");
             if (count($pg_childs) != 0) {
                 $target_pos = $pg_childs[count($pg_childs) - 1]["obj_id"];
             }
         } else {
             if ($as_subitem) {
                 $target_parent = $target_id;
                 $target_pos = IL_FIRST_NODE;
                 $childs = $this->slm_tree->getChilds($target_parent);
                 if (count($childs) != 0) {
                     $target_pos = $childs[count($childs) - 1]["obj_id"];
                 }
             }
         }
         // delete source tree
         if ($movecopy == "move") {
             $this->slm_tree->deleteTree($source_node);
         }
         /*			else
         			{
         				// copy chapter (incl. subcontents)
         				$new_chapter =& $source_obj->copy($this->slm_tree, $target_parent, $target_pos);
         			}
         */
         if (!$this->slm_tree->isInTree($source_id)) {
             $this->slm_tree->insertNode($source_id, $target_parent, $target_pos);
             // insert moved tree
             if ($movecopy == "move") {
                 foreach ($subnodes as $node) {
                     if ($node["obj_id"] != $source_id) {
                         $this->slm_tree->insertNode($node["obj_id"], $node["parent"]);
                     }
                 }
             }
         }
         // check the tree
         //			$this->checkTree();
     }
     // handle chapters
     if ($source_obj->getType() == "chap") {
         //echo "2";
         $source_node = $this->slm_tree->getNodeData($source_id);
         $subnodes = $this->slm_tree->getSubtree($source_node);
         // check, if target is within subtree
         foreach ($subnodes as $subnode) {
             if ($subnode["obj_id"] == $target_id) {
                 return;
             }
         }
         $target_pos = $target_id;
         if ($first_child) {
             $target_pos = IL_FIRST_NODE;
             $target_parent = $target_id;
             //$sco_childs = $this->slm_tree->getChildsByType($target_parent, "sco");
             //if (count($sco_childs) != 0)
             //{
             //	$target_pos = $sco_childs[count($sco_childs) - 1]["obj_id"];
             //}
         } else {
             if ($as_subitem) {
                 $target_parent = $target_id;
                 $target_pos = IL_FIRST_NODE;
                 $childs = $this->slm_tree->getChilds($target_parent);
                 if (count($childs) != 0) {
                     $target_pos = $childs[count($childs) - 1]["obj_id"];
                 }
             }
         }
         // delete source tree
         if ($movecopy == "move") {
             $this->slm_tree->deleteTree($source_node);
         }
         /*			else
         			{
         				// copy chapter (incl. subcontents)
         				$new_chapter =& $source_obj->copy($this->slm_tree, $target_parent, $target_pos);
         			}
         */
         if (!$this->slm_tree->isInTree($source_id)) {
             $this->slm_tree->insertNode($source_id, $target_parent, $target_pos);
             // insert moved tree
             if ($movecopy == "move") {
                 foreach ($subnodes as $node) {
                     if ($node["obj_id"] != $source_id) {
                         $this->slm_tree->insertNode($node["obj_id"], $node["parent"]);
                     }
                 }
             }
         }
         // check the tree
         //			$this->checkTree();
     }
     //		$this->checkTree();
 }
 /**
  * Get node object (chapter/sco/page)
  */
 function getNodeObject($a_node_id)
 {
     include_once "./Modules/Scorm2004/classes/class.ilSCORM2004NodeFactory.php";
     $this->node_object = ilSCORM2004NodeFactory::getInstance($this->slm_object, $a_node_id, false);
 }