/**
     * This function is called by the API applet in the content frame
     * when a SCO is started.
     */
    function launchSahs()
    {
        global $ilUser, $ilDB;
        $sco_id = $_GET["sahs_id"] == "" ? $_POST["sahs_id"] : $_GET["sahs_id"];
        $ref_id = $_GET["ref_id"] == "" ? $_POST["ref_id"] : $_GET["ref_id"];
        $this->slm =& new ilObjSCORMLearningModule($ref_id, true);
        include_once "./Modules/ScormAicc/classes/SCORM/class.ilSCORMItem.php";
        include_once "./Modules/ScormAicc/classes/SCORM/class.ilSCORMResource.php";
        $item =& new ilSCORMItem($sco_id);
        $id_ref = $item->getIdentifierRef();
        $resource =& new ilSCORMResource();
        $resource->readByIdRef($id_ref, $item->getSLMId());
        //$slm_obj =& new ilObjSCORMLearningModule($_GET["ref_id"]);
        $href = $resource->getHref();
        $this->tpl = new ilTemplate("tpl.sahs_launch_cbt.html", true, true, "Modules/ScormAicc");
        $this->tpl->setVariable("HREF", $this->slm->getDataDirectory("output") . "/" . $href);
        // set item data
        $this->tpl->setVariable("LAUNCH_DATA", $item->getDataFromLms());
        $this->tpl->setVariable("MAST_SCORE", $item->getMasteryScore());
        $this->tpl->setVariable("MAX_TIME", $item->getMaxTimeAllowed());
        $this->tpl->setVariable("LIMIT_ACT", $item->getTimeLimitAction());
        // set alternative API name
        if ($this->slm->getAPIAdapterName() != "API") {
            $this->tpl->setCurrentBlock("alt_api_ref");
            $this->tpl->setVariable("API_NAME", $this->slm->getAPIAdapterName());
            $this->tpl->parseCurrentBlock();
        }
        $val_set = $ilDB->queryF('
			SELECT * FROM scorm_tracking 
			WHERE user_id = %s
			AND sco_id = %s
			AND obj_id = %s', array('integer', 'integer', 'integer'), array($ilUser->getId(), $sco_id, $this->slm->getId()));
        $re_value = array();
        while ($val_rec = $ilDB->fetchAssoc($val_set)) {
            $val_rec["rvalue"] = str_replace("\r\n", "\n", $val_rec["rvalue"]);
            $val_rec["rvalue"] = str_replace("\r", "\n", $val_rec["rvalue"]);
            $val_rec["rvalue"] = str_replace("\n", "\\n", $val_rec["rvalue"]);
            $re_value[$val_rec["lvalue"]] = $val_rec["rvalue"];
        }
        foreach ($re_value as $var => $value) {
            switch ($var) {
                case "cmi.core.lesson_location":
                case "cmi.core.lesson_status":
                case "cmi.core.entry":
                case "cmi.core.score.raw":
                case "cmi.core.score.max":
                case "cmi.core.score.min":
                case "cmi.core.total_time":
                case "cmi.core.exit":
                case "cmi.suspend_data":
                case "cmi.comments":
                case "cmi.student_preference.audio":
                case "cmi.student_preference.language":
                case "cmi.student_preference.speed":
                case "cmi.student_preference.text":
                    $this->setSingleVariable($var, $value);
                    break;
                case "cmi.objectives._count":
                    $this->setSingleVariable($var, $value);
                    $this->setArray("cmi.objectives", $value, "id", $re_value);
                    $this->setArray("cmi.objectives", $value, "score.raw", $re_value);
                    $this->setArray("cmi.objectives", $value, "score.max", $re_value);
                    $this->setArray("cmi.objectives", $value, "score.min", $re_value);
                    $this->setArray("cmi.objectives", $value, "status", $re_value);
                    break;
                case "cmi.interactions._count":
                    $this->setSingleVariable($var, $value);
                    $this->setArray("cmi.interactions", $value, "id", $re_value);
                    for ($i = 0; $i < $value; $i++) {
                        $var2 = "cmi.interactions." . $i . ".objectives._count";
                        if (isset($v_array[$var2])) {
                            $cnt = $v_array[$var2];
                            $this->setArray("cmi.interactions." . $i . ".objectives", $cnt, "id", $re_value);
                            /*
                            							$this->setArray("cmi.interactions.".$i.".objectives",
                            								$cnt, "score.raw", $re_value);
                            							$this->setArray("cmi.interactions.".$i.".objectives",
                            								$cnt, "score.max", $re_value);
                            							$this->setArray("cmi.interactions.".$i.".objectives",
                            								$cnt, "score.min", $re_value);
                            							$this->setArray("cmi.interactions.".$i.".objectives",
                            								$cnt, "status", $re_value);*/
                        }
                    }
                    $this->setArray("cmi.interactions", $value, "time", $re_value);
                    $this->setArray("cmi.interactions", $value, "type", $re_value);
                    for ($i = 0; $i < $value; $i++) {
                        $var2 = "cmi.interactions." . $i . ".correct_responses._count";
                        if (isset($v_array[$var2])) {
                            $cnt = $v_array[$var2];
                            $this->setArray("cmi.interactions." . $i . ".correct_responses", $cnt, "pattern", $re_value);
                            $this->setArray("cmi.interactions." . $i . ".correct_responses", $cnt, "weighting", $re_value);
                        }
                    }
                    $this->setArray("cmi.interactions", $value, "student_response", $re_value);
                    $this->setArray("cmi.interactions", $value, "result", $re_value);
                    $this->setArray("cmi.interactions", $value, "latency", $re_value);
                    break;
            }
        }
        global $lng;
        $this->tpl->setCurrentBlock("switch_icon");
        $this->tpl->setVariable("SCO_ID", $_GET["sahs_id"]);
        $this->tpl->setVariable("SCO_ICO", ilUtil::getImagePath("scorm/running.png"));
        $this->tpl->setVariable("SCO_ALT", $lng->txt("cont_status") . ": " . $lng->txt("cont_sc_stat_running"));
        $this->tpl->parseCurrentBlock();
        // set icon, if more than one SCO/Asset is presented
        $items = ilSCORMObject::_lookupPresentableItems($this->slm->getId());
        if (count($items) > 1 || strtolower(get_class($this->slm)) == "ilobjaicclearningmodule" || strtolower(get_class($this->slm)) == "ilobjhacplearningmodule") {
            $this->tpl->setVariable("SWITCH_ICON_CMD", "switch_icon();");
        }
        // lesson mode
        $lesson_mode = $this->slm->getDefaultLessonMode();
        if ($this->slm->getAutoReview()) {
            if ($re_value["cmi.core.lesson_status"] == "completed" || $re_value["cmi.core.lesson_status"] == "passed" || $re_value["cmi.core.lesson_status"] == "failed") {
                $lesson_mode = "review";
            }
        }
        $this->tpl->setVariable("LESSON_MODE", $lesson_mode);
        // credit mode
        if ($lesson_mode == "normal") {
            $this->tpl->setVariable("CREDIT_MODE", str_replace("_", "-", $this->slm->getCreditMode()));
        } else {
            $this->tpl->setVariable("CREDIT_MODE", "no-credit");
        }
        // init cmi.core.total_time, cmi.core.lesson_status and cmi.core.entry
        $sahs_obj_id = ilObject::_lookupObjId($_GET["ref_id"]);
        if (!isset($re_value["cmi.core.total_time"])) {
            $item->insertTrackData("cmi.core.total_time", "0000:00:00", $sahs_obj_id);
        }
        if (!isset($re_value["cmi.core.lesson_status"])) {
            $item->insertTrackData("cmi.core.lesson_status", "not attempted", $sahs_obj_id);
        }
        if (!isset($re_value["cmi.core.entry"])) {
            $item->insertTrackData("cmi.core.entry", "", $sahs_obj_id);
        }
        $this->tpl->show();
        //echo htmlentities($this->tpl->get()); exit;
    }