/**
  * output table of content
  */
 function explorer($a_target = "sahs_content")
 {
     $this->tpl = new ilTemplate("tpl.sahs_exp_main.html", true, true, "Modules/ScormAicc");
     require_once "./Modules/ScormAicc/classes/HACP/class.ilHACPExplorer.php";
     $exp = new ilHACPExplorer($this->ctrl->getLinkTarget($this, "view"), $this->slm);
     $exp->setTargetGet("obj_id");
     $exp->setFrameTarget($a_target);
     //$exp->setFiltered(true);
     if ($_GET["scexpand"] == "") {
         $mtree = new ilSCORMTree($this->slm->getId());
         $expanded = $mtree->readRootId();
     } else {
         $expanded = $_GET["scexpand"];
     }
     $exp->setExpand($expanded);
     $exp->forceExpandAll(true, false);
     // build html-output
     //666$exp->setOutput(0);
     $exp->setOutput(0);
     $output = $exp->getOutput();
     $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
     $this->tpl->addBlockFile("CONTENT", "content", "tpl.explorer.html");
     $this->tpl->setVariable("TXT_EXPLORER_HEADER", $this->lng->txt("cont_content"));
     $this->tpl->setVariable("EXP_REFRESH", $this->lng->txt("refresh"));
     $this->tpl->setVariable("EXPLORER", $output);
     $this->tpl->setVariable("ACTION", $this->ctrl->getLinkTarget($this, $_GET["cmd"]) . "&frame=" . $_GET["frame"] . "&ref_id=" . $this->slm->getRefId() . "&scexpand=" . $_GET["scexpand"]);
     $this->tpl->parseCurrentBlock();
     $this->tpl->show();
 }
 /**
  * get all tracking items of scorm object
  * @access static
  */
 function _getTrackingItems($a_obj_id)
 {
     include_once "./Modules/ScormAicc/classes/SCORM/class.ilSCORMTree.php";
     $tree = new ilSCORMTree($a_obj_id);
     $root_id = $tree->readRootId();
     $items = array();
     $childs = $tree->getSubTree($tree->getNodeData($root_id));
     foreach ($childs as $child) {
         if ($child["c_type"] == "sit") {
             include_once "./Modules/ScormAicc/classes/SCORM/class.ilSCORMItem.php";
             $sc_item =& new ilSCORMItem($child["obj_id"]);
             if ($sc_item->getIdentifierRef() != "") {
                 $items[count($items)] =& $sc_item;
             }
         }
     }
     return $items;
 }
    /**
     * delete SCORM learning module and all related data
     *
     * this method has been tested on may 9th 2004
     * meta data, scorm lm data, scorm tree, scorm objects (organization(s),
     * manifest, resources and items), tracking data and data directory
     * have been deleted correctly as desired
     *
     * @access	public
     * @return	boolean	true if all object data were removed; false if only a references were removed
     */
    function delete()
    {
        global $ilDB, $ilLog;
        // always call parent delete function first!!
        if (!parent::delete()) {
            return false;
        }
        // delete meta data of scorm content object
        /*
        		$nested = new ilNestedSetXML();
        		$nested->init($this->getId(), $this->getType());
        		$nested->deleteAllDBData();
        */
        $this->deleteMetaData();
        // delete data directory
        ilUtil::delDir($this->getDataDirectory());
        // delete scorm learning module record
        $ilDB->manipulateF('DELETE FROM sahs_lm WHERE id = %s', array('integer'), array($this->getId()));
        $ilLog->write("SAHS Delete(SAHSLM), Subtype: " . $this->getSubType());
        if ($this->getSubType() == "scorm") {
            // remove all scorm objects and scorm tree
            include_once "./Modules/ScormAicc/classes/SCORM/class.ilSCORMTree.php";
            include_once "./Modules/ScormAicc/classes/SCORM/class.ilSCORMObject.php";
            $sc_tree = new ilSCORMTree($this->getId());
            $r_id = $sc_tree->readRootId();
            if ($r_id > 0) {
                $items = $sc_tree->getSubTree($sc_tree->getNodeData($r_id));
                foreach ($items as $item) {
                    $sc_object =& ilSCORMObject::_getInstance($item["obj_id"], $this->getId());
                    if (is_object($sc_object)) {
                        $sc_object->delete();
                    }
                }
                $sc_tree->removeTree($sc_tree->getTreeId());
            }
        }
        if ($this->getSubType() != "scorm") {
            // delete aicc data
            $res = $ilDB->queryF('
				SELECT aicc_object.obj_id FROM aicc_object, aicc_units
				WHERE aicc_object.obj_id = aicc_units.obj_id
				AND aicc_object.slm_id = %s', array('integer'), array($this->getId()));
            while ($row = $ilDB->fetchAssoc($res)) {
                $obj_id = $row['obj_id'];
                $ilDB->manipulateF('
					DELETE FROM aicc_units WHERE obj_id = %s', array('integer'), array($obj_id));
            }
            $res = $ilDB->queryF('
				SELECT aicc_object.obj_id FROM aicc_object, aicc_course
				WHERE aicc_object.obj_id = aicc_course.obj_id
				AND aicc_object.slm_id = %s', array('integer'), array($this->getId()));
            while ($row = $ilDB->fetchAssoc($res)) {
                $obj_id = $row['obj_id'];
                $ilDB->manipulateF('
					DELETE FROM aicc_course WHERE obj_id = %s', array('integer'), array($obj_id));
            }
            $ilDB->manipulateF('
				DELETE FROM aicc_object WHERE slm_id = %s', array('integer'), array($this->getId()));
        }
        $q_log = "DELETE FROM scorm_tracking WHERE obj_id = " . $ilDB->quote($this->getId());
        $ilLog->write("SAHS Delete(SAHSLM): " . $q_log);
        $ilDB->manipulateF('DELETE FROM scorm_tracking WHERE obj_id = %s', array('integer'), array($this->getId()));
        $q_log = "DELETE FROM sahs_user WHERE obj_id = " . $ilDB->quote($this->getId());
        $ilLog->write("SAHS Delete(SAHSLM): " . $q_log);
        $ilDB->manipulateF('DELETE FROM sahs_user WHERE obj_id = %s', array('integer'), array($this->getId()));
        // always call parent delete function at the end!!
        return true;
    }
 function finishSahs()
 {
     global $lng;
     $this->tpl = new ilTemplate("tpl.sahs_finish_cbt.html", true, true, "Modules/ScormAicc");
     $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
     // block not in template
     // $this->tpl->setCurrentBlock("switch_icon");
     $this->tpl->setVariable("SCO_ID", $_GET["sahs_id"]);
     $this->tpl->setVariable("SCO_ICO", ilUtil::getImagePath("scorm/" . str_replace(" ", "_", $_GET["status"]) . '.png'));
     $this->tpl->setVariable("SCO_ALT", $lng->txt("cont_status") . ": " . $lng->txt("cont_sc_stat_" . str_replace(" ", "_", $_GET["status"])) . ", " . $lng->txt("cont_total_time") . ": " . $_GET["totime"]);
     // BEGIN Partial fix for SCO sequencing:
     //       With this partial fix, ILIAS can now proceed to the next
     //          SCO, if it is a sibling of the current SCO.
     //       This fix doesn't fix the case, if the next SCO has a
     //          different parent item.
     //$this->tpl->setVariable("SCO_LAUNCH_ID", $_GET["launch"]);
     $launch_id = $_GET['launch'];
     if ($launch_id == 'null' || $launch_id == null) {
         require_once "./Modules/ScormAicc/classes/SCORM/class.ilSCORMTree.php";
         $mtree = new ilSCORMTree($this->slm->getId());
         $node_data = $mtree->fetchSuccessorNode($_GET['sahs_id']);
         if ($node_data && $node_data[type] == 'sit') {
             $launch_id = $node_data['child'];
         }
     }
     // END Partial fix for SCO sequencing
     $this->tpl->setVariable("SCO_LAUNCH_ID", $launch_id);
     // $this->tpl->parseCurrentBlock();
     $this->tpl->show();
 }
 /**
  * Constructor
  *
  * @param	int		$a_id		tree id (= AICC Learning Module Object ID)
  * @access	public
  */
 function ilAICCTree($a_id = 0)
 {
     parent::ilTree($a_id);
     $this->setTableNames('scorm_tree', 'aicc_object');
     $this->setTreeTablePK('slm_id');
 }