3 declare(strict_types=1);
    35         $revert = array(
'%21' => 
'!', 
'%2A' => 
'*', 
'%27' => 
"'", 
'%28' => 
'(', 
'%29' => 
')', 
'%7E' => 
'~');
    36         return strtr(rawurlencode($str), $revert);
    43         $ilUser = $DIC->user();
    44         $lng = $DIC->language();
    45         $ilDB = $DIC->database();
    50         $b_storeObjectives = 
'false';
    52             $b_storeObjectives = 
'true';
    54         $b_storeInteractions = 
'false';
    56             $b_storeInteractions = 
'true';
    58         $b_readInteractions = 
'false';
    59         $c_storeSessionTime = 
's';
    61             $c_storeSessionTime = 
'i';
    63         $i_lessonScoreMax = 
'-1';
    67         $b_messageLog = 
'false';
    72         if ($DIC->http()->wrapper()->query()->has(
'autolaunch')) {
    73             $autoLaunch = $DIC->http()->wrapper()->query()->retrieve(
'autolaunch', $DIC->refinery()->kindlyTo()->string());
    74             if ($autoLaunch != 
"") {
    75                 $launchId = $autoLaunch;
    82             if ($session_timeout > $max_idle) {
    83                 $session_timeout = $max_idle;
    86             if ($session_timeout > $min_idle) {
    87                 $session_timeout = $min_idle;
    89             if ($session_timeout > 10) { 
    90                 $session_timeout -= 10;
    93         $b_autoReview = 
'false';
    95             $b_autoReview = 
'true';
    97         $b_autoSuspend = 
'false';
    99             $b_autoSuspend = 
'true';
   105         $b_autoContinue = 
'false';
   107             $b_autoContinue = 
'true';
   109         $b_checkSetValues = 
'false';
   111             $b_checkSetValues = 
'true';
   113         $b_autoLastVisited = 
'false';
   115             $b_autoLastVisited = 
'true';
   116             if ($launchId == 
'0') {
   121         $b_sessionDeactivated = 
'false';
   123             $b_sessionDeactivated = 
'true';
   129         $val_set = 
$ilDB->queryF(
   131                         SELECT sc_item.obj_id,prereq_type,prerequisites,maxtimeallowed,timelimitaction,datafromlms,masteryscore    132                         FROM sc_item, scorm_object    133                         WHERE scorm_object.obj_id=sc_item.obj_id   134                         AND scorm_object.c_type = %s   135                         AND scorm_object.slm_id = %s',
   136             array(
'text',
'integer'),
   137             array(
'sit',$slm_obj->
getId())
   139         while ($val_rec = 
$ilDB->fetchAssoc($val_set)) {
   140             if ($val_rec[
"prereq_type"] != null || $val_rec[
"prerequisites"] != null || $val_rec[
"maxtimeallowed"] != null || $val_rec[
"timelimitaction"] != null || $val_rec[
"datafromlms"] != null || $val_rec[
"masteryscore"] != null) {
   141                 $tmp_man = array((
int) $val_rec[
"obj_id"],null,null,null,null,null,null);
   142                 if ($val_rec[
"prereq_type"] != null) {
   143                     $tmp_man[1] = self::encodeURIComponent($val_rec[
"prereq_type"]);
   145                 if ($val_rec[
"prerequisites"] != null) {
   146                     $tmp_man[2] = self::encodeURIComponent($val_rec[
"prerequisites"]);
   148                 if ($val_rec[
"maxtimeallowed"] != null) {
   149                     $tmp_man[3] = self::encodeURIComponent($val_rec[
"maxtimeallowed"]);
   151                 if ($val_rec[
"timelimitaction"] != null) {
   152                     $tmp_man[4] = self::encodeURIComponent($val_rec[
"timelimitaction"]);
   154                 if ($val_rec[
"datafromlms"] != null) {
   155                     $tmp_man[5] = self::encodeURIComponent($val_rec[
"datafromlms"]);
   157                 if ($val_rec[
"masteryscore"] != null) {
   158                     $tmp_man[6] = self::encodeURIComponent($val_rec[
"masteryscore"]);
   165             . 
'"refId":' . $DIC->http()->wrapper()->query()->retrieve(
'ref_id', $DIC->refinery()->kindlyTo()->string()) . 
','   166             . 
'"objId":' . $slm_obj->
getId() . 
','   168             . 
'"launchId":' . $launchId . 
','   170             . 
'"pingSession":' . $session_timeout . 
','   172             . 
'"studentName":"' . self::encodeURIComponent($slm_obj->
getApiStudentName()) . 
'",'   173             . 
'"studentLogin":"' . self::encodeURIComponent($ilUser->getLogin()) . 
'",'   174             . 
'"studentOu":"' . self::encodeURIComponent($ilUser->getDepartment()) . 
'",'   175             . 
'"credit":"' . str_replace(
"_", 
"-", $slm_obj->
getCreditMode()) . 
'",'   177             . 
'"b_autoReview":' . $b_autoReview . 
','   178             . 
'"b_autoSuspend":' . $b_autoSuspend . 
','   179             . 
'"b_messageLog":' . $b_messageLog . 
','   180             . 
'"b_checkSetValues":' . $b_checkSetValues . 
','   181             . 
'"b_storeObjectives":' . $b_storeObjectives . 
','   182             . 
'"b_storeInteractions":' . $b_storeInteractions . 
','   183             . 
'"b_readInteractions":' . $b_readInteractions . 
','   184             . 
'"c_storeSessionTime":"' . $c_storeSessionTime . 
'",'   185             . 
'"b_autoContinue":' . $b_autoContinue . 
','   186             . 
'"b_autoLastVisited":' . $b_autoLastVisited . 
','   187             . 
'"b_sessionDeactivated":' . $b_sessionDeactivated . 
','   188             . 
'"i_lessonScoreMax":' . $i_lessonScoreMax . 
','   189             . 
'"i_lessonMasteryScore":"' . $i_lessonMasteryScore . 
'",'   190             . 
'"b_debug":' . $b_debug . 
','   191             . 
'"a_itemParameter":' . json_encode($a_man) . 
','   192             . 
'"status":' . json_encode(self::getStatus($slm_obj->
getId(), $ilUser->getID(), $slm_obj->
getAuto_last_visited())) . 
','   193             . 
'"dataDirectory":"' . self::encodeURIComponent($slm_obj->
getDataDirectory(
"output") . 
'/') . 
'",'   197                 . 
'"completed":"' . self::encodeURIComponent(
ilUtil::getImagePath(
'scorm/completed.svg')) . 
'",'   199                 . 
'"incomplete":"' . self::encodeURIComponent(
ilUtil::getImagePath(
'scorm/incomplete.svg')) . 
'",'   200                 . 
'"not_attempted":"' . self::encodeURIComponent(
ilUtil::getImagePath(
'scorm/not_attempted.svg')) . 
'",'   205                 . 
'"wait":"' . self::encodeURIComponent(
$lng->txt(
"please_wait")) . 
'",'   206                 . 
'"status":"' . self::encodeURIComponent(
$lng->txt(
"cont_status")) . 
'",'   207                 . 
'"browsed":"' . self::encodeURIComponent(
$lng->txt(
"cont_sc_stat_browsed")) . 
'",'   208                 . 
'"completed":"' . self::encodeURIComponent(
$lng->txt(
"cont_sc_stat_completed")) . 
'",'   209                 . 
'"failed":"' . self::encodeURIComponent(
$lng->txt(
"cont_sc_stat_failed")) . 
'",'   210                 . 
'"incomplete":"' . self::encodeURIComponent(
$lng->txt(
"cont_sc_stat_incomplete")) . 
'",'   211                 . 
'"not_attempted":"' . self::encodeURIComponent(
$lng->txt(
"cont_sc_stat_not_attempted")) . 
'",'   212                 . 
'"passed":"' . self::encodeURIComponent(
$lng->txt(
"cont_sc_stat_passed")) . 
'",'   213                 . 
'"running":"' . self::encodeURIComponent(
$lng->txt(
"cont_sc_stat_running")) . 
'"'   222         $ilUser = $DIC->user();
   223         $ilDB = $DIC->database();
   224         $b_readInteractions = 
'false';
   226         $tquery = 
'SELECT sco_id,lvalue,rvalue FROM scorm_tracking '   227                 . 
'WHERE user_id = %s AND obj_id = %s '   228                 . 
"AND sco_id > 0 AND lvalue != 'cmi.core.entry' AND lvalue != 'cmi.core.session_time'";
   229         if ($b_readInteractions === 
'false') {
   230             $tquery .= 
" AND SUBSTR(lvalue, 1, 16) != 'cmi.interactions'";
   232         $val_set = 
$ilDB->queryF(
   234             array(
'integer',
'integer'),
   235             array($ilUser->getId(),$a_packageId)
   237         while ($val_rec = 
$ilDB->fetchAssoc($val_set)) {
   238             if (!strpos($val_rec[
"lvalue"], 
"._count")) {
   239                 $a_out[] = array( (
int) $val_rec[
"sco_id"], $val_rec[
"lvalue"], self::encodeURIComponent($val_rec[
"rvalue"]) );
   242         return json_encode($a_out);
   248         $ilDB = $DIC->database();
   252         $val_set = 
$ilDB->queryF(
   254                         SELECT sc_resource.obj_id   255                         FROM scorm_tree, sc_resource   256                         WHERE scorm_tree.slm_id=%s    257                         AND sc_resource.obj_id=scorm_tree.child",
   261         while ($val_rec = 
$ilDB->fetchAssoc($val_set)) {
   262             $s_resourceIds .= 
"," . $val_rec[
"obj_id"];
   264         $s_resourceIds = substr($s_resourceIds, 1);
   266         $tquery = 
"SELECT scorm_tree.lft, scorm_tree.child,    267                         CASE WHEN sc_resource.scormtype = 'asset' THEN 1 ELSE 0 END AS asset,   269                         FROM scorm_tree, sc_resource, sc_item   270                         WHERE scorm_tree.slm_id=%s    271                         AND sc_item.obj_id=scorm_tree.child    272                         AND sc_resource.import_id=sc_item.identifierref    273                         AND sc_resource.obj_id in (" . $s_resourceIds . 
")    274                         ORDER BY scorm_tree.lft";
   275         $val_set = 
$ilDB->queryF(
   280         while ($val_rec = 
$ilDB->fetchAssoc($val_set)) {
   282             $a_out[] = array( (
int) $val_rec[
"lft"], (
int) $val_rec[
"child"], (
int) $val_rec[
"asset"], self::encodeURIComponent($val_rec[
"href"]) );
   286         return json_encode($a_out);
   292         $ilDB = $DIC->database();
   294         $tquery = 
"SELECT scorm_tree.child, scorm_tree.depth-3 depth, scorm_object.title, scorm_object.c_type   295                         FROM scorm_tree, scorm_object   296                         WHERE scorm_object.obj_id=scorm_tree.child   297                         AND scorm_tree.slm_id=%s   298                         AND (scorm_object.c_type='sor' OR scorm_object.c_type='sit')   299                         ORDER BY scorm_tree.lft";
   300         $val_set = 
$ilDB->queryF(
   305         while ($val_rec = 
$ilDB->fetchAssoc($val_set)) {
   306             $a_out[] = array((
int) $val_rec[
"child"],(
int) $val_rec[
"depth"],self::encodeURIComponent($val_rec[
"title"]),$val_rec[
"c_type"]);
   308         return json_encode($a_out);
   314     public static function getStatus(
int $a_packageId, 
int $a_user_id, 
bool $auto_last_visited, 
string $scormType = 
"1.2"): array
   317         $ilDB = $DIC->database();
   319         $status[
'saved_global_status'] = (
int) $oldStatus;
   321         $status[
'lp_mode'] = $olp->getCurrentMode();
   322         $collection = $olp->getCollectionInstance();
   324             $status[
'scos'] = $collection->getItems();
   326             $status[
'scos'] = array();
   329         $status[
'p'] = $a_user_id;
   331         $status[
'last_visited'] = null;
   332         $status[
'total_time_sec'] = 0;
   333         $val_set = 
$ilDB->queryF(
   334             'SELECT last_visited, sco_total_time_sec, total_time_sec FROM sahs_user WHERE obj_id = %s AND user_id = %s',
   335             array(
'integer',
'integer'),
   336             array($a_packageId,$a_user_id)
   338         $val_rec = 
$ilDB->fetchAssoc($val_set);
   339         if ($auto_last_visited) {
   340             $status[
'last_visited'] = $val_rec[
"last_visited"];
   342         if ($val_rec[
"total_time_sec"] == null) {
   343             if ($val_rec[
"sco_total_time_sec"] == null) {
   345                 if ($scormType == 
"2004") {
   349                 $status[
'total_time_sec'] = (
int) $val_rec[
"sco_total_time_sec"];
   352             $status[
'total_time_sec'] = (
int) $val_rec[
"total_time_sec"];
   361     private static function setHash(
int $a_packageId, 
int $a_user_id): 
int   364         $ilDB = $DIC->database();
   365         $hash = random_int(1_000_000_000, 2_147_483_647);
   366         $endDate = date(
'Y-m-d H:i:s', mktime((
int) date(
"H"), (
int) date(
"i"), (
int) date(
"s"), (
int) date(
"m"), (
int) date(
"d") + 1, (
int) date(
"Y")));
   369             'SELECT count(*) cnt FROM sahs_user WHERE obj_id = %s AND user_id = %s',
   370             array(
'integer', 
'integer'),
   371             array($a_packageId,$a_user_id)
   374         if ($val_rec[
"cnt"] == 0) {
   376                 'INSERT INTO sahs_user (obj_id, user_id, hash, hash_end) VALUES(%s, %s, %s, %s)',
   377                 array(
'integer', 
'integer', 
'text', 
'timestamp'),
   378                 array($a_packageId, $a_user_id, 
"" . $hash, $endDate)
   382                 'UPDATE sahs_user SET hash = %s, hash_end = %s WHERE obj_id = %s AND user_id = %s',
   383                 array(
'text', 
'timestamp', 
'integer', 
'integer'),
   384                 array(
"" . $hash, $endDate, $a_packageId, $a_user_id)
 
static getIliasScormData(int $a_packageId)
 
static getCookieMaxLifetimeInSeconds()
 
static getLogger(string $a_component_id)
Get component logger. 
 
getSessionDeactivated()
sessionDisabled for SCORM 2004 
 
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory) 
 
static getIliasScormVars(ilObjSCORMLearningModule $slm_obj)
 
getAutoReview()
get auto review as true/false for SCORM 1.2 
 
static setHash(int $a_packageId, int $a_user_id)
hash for storing data without session 
 
getApiStudentId()
Get cmi.core.student_id / cmi.learner_id for API. 
 
getLastVisited(int $user_id)
 
static getStatus(int $a_packageId, int $a_user_id, bool $auto_last_visited, string $scormType="1.2")
 
static _lookupStatus(int $a_obj_id, int $a_user_id, bool $a_create=true)
Lookup status. 
 
getApiStudentName()
Get cmi.core.student_name / cmi.learner_name for API note: 'lastname, firstname' is required for SCOR...
 
static getIliasScormResources(int $a_packageId)
 
getDataDirectory(?string $mode="filesystem")
get data directory of lm 
 
getCreditMode()
get credit mode 
 
static getIliasScormTree(int $a_packageId)
 
static getSumTotalTimeSecondsFromScos(int $a_obj_id, int $a_user_id, bool $a_write=false)
should be avoided; store value to increase performance for further requests 
 
static getIdleValue(bool $fixedMode=false)
Returns the idle time in seconds. 
 
getDefaultLessonMode()
get default lesson mode 
 
static getInstance(int $obj_id)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static encodeURIComponent(string $str)