19declare(strict_types=1);
35 $revert = array(
'%21' =>
'!',
'%2A' =>
'*',
'%27' =>
"'",
'%28' =>
'(',
'%29' =>
')',
'%7E' =>
'~');
36 return strtr(rawurlencode($str), $revert);
43 $ilUser =
$DIC->user();
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 $session_timeout -= 10;
91 $b_autoReview =
'false';
93 $b_autoReview =
'true';
95 $b_autoSuspend =
'false';
97 $b_autoSuspend =
'true';
103 $b_autoContinue =
'false';
105 $b_autoContinue =
'true';
107 $b_checkSetValues =
'false';
109 $b_checkSetValues =
'true';
111 $b_autoLastVisited =
'false';
113 $b_autoLastVisited =
'true';
114 if ($launchId ==
'0') {
119 $b_sessionDeactivated =
'false';
121 $b_sessionDeactivated =
'true';
127 $val_set =
$ilDB->queryF(
129 SELECT sc_item.obj_id,prereq_type,prerequisites,maxtimeallowed,timelimitaction,datafromlms,masteryscore
130 FROM sc_item, scorm_object
131 WHERE scorm_object.obj_id=sc_item.obj_id
132 AND scorm_object.c_type = %s
133 AND scorm_object.slm_id = %s',
134 array(
'text',
'integer'),
135 array(
'sit',$slm_obj->
getId())
137 while ($val_rec =
$ilDB->fetchAssoc($val_set)) {
138 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) {
139 $tmp_man = array((
int) $val_rec[
"obj_id"],
null,
null,
null,
null,
null,
null);
140 if ($val_rec[
"prereq_type"] !=
null) {
143 if ($val_rec[
"prerequisites"] !=
null) {
146 if ($val_rec[
"maxtimeallowed"] !=
null) {
149 if ($val_rec[
"timelimitaction"] !=
null) {
152 if ($val_rec[
"datafromlms"] !=
null) {
155 if ($val_rec[
"masteryscore"] !=
null) {
163 .
'"refId":' .
$DIC->http()->wrapper()->query()->retrieve(
'ref_id',
$DIC->refinery()->kindlyTo()->string()) .
','
164 .
'"objId":' . $slm_obj->
getId() .
','
166 .
'"launchId":' . $launchId .
','
168 .
'"pingSession":' . $session_timeout .
','
173 .
'"credit":"' . str_replace(
"_",
"-", $slm_obj->
getCreditMode()) .
'",'
175 .
'"b_autoReview":' . $b_autoReview .
','
176 .
'"b_autoSuspend":' . $b_autoSuspend .
','
177 .
'"b_messageLog":' . $b_messageLog .
','
178 .
'"b_checkSetValues":' . $b_checkSetValues .
','
179 .
'"b_storeObjectives":' . $b_storeObjectives .
','
180 .
'"b_storeInteractions":' . $b_storeInteractions .
','
181 .
'"b_readInteractions":' . $b_readInteractions .
','
182 .
'"c_storeSessionTime":"' . $c_storeSessionTime .
'",'
183 .
'"b_autoContinue":' . $b_autoContinue .
','
184 .
'"b_autoLastVisited":' . $b_autoLastVisited .
','
185 .
'"b_sessionDeactivated":' . $b_sessionDeactivated .
','
186 .
'"i_lessonScoreMax":' . $i_lessonScoreMax .
','
187 .
'"i_lessonMasteryScore":"' . $i_lessonMasteryScore .
'",'
188 .
'"b_debug":' . $b_debug .
','
189 .
'"a_itemParameter":' . json_encode($a_man) .
','
190 .
'"status":' . json_encode(self::getStatus($slm_obj->
getId(), $ilUser->getID(), $slm_obj->
getAuto_last_visited())) .
','
220 $ilUser =
$DIC->user();
222 $b_readInteractions =
'false';
224 $tquery =
'SELECT sco_id,lvalue,rvalue FROM scorm_tracking '
225 .
'WHERE user_id = %s AND obj_id = %s '
226 .
"AND sco_id > 0 AND lvalue != 'cmi.core.entry' AND lvalue != 'cmi.core.session_time'";
227 if ($b_readInteractions ===
'false') {
228 $tquery .=
" AND SUBSTR(lvalue, 1, 16) != 'cmi.interactions'";
230 $val_set =
$ilDB->queryF(
232 array(
'integer',
'integer'),
233 array($ilUser->getId(),$a_packageId)
235 while ($val_rec =
$ilDB->fetchAssoc($val_set)) {
236 if (!strpos($val_rec[
"lvalue"],
"._count")) {
237 $a_out[] = array( (
int) $val_rec[
"sco_id"], $val_rec[
"lvalue"], self::encodeURIComponent($val_rec[
"rvalue"] ??
'') );
240 return json_encode($a_out);
250 $val_set =
$ilDB->queryF(
252 SELECT sc_resource.obj_id
253 FROM scorm_tree, sc_resource
254 WHERE scorm_tree.slm_id=%s
255 AND sc_resource.obj_id=scorm_tree.child",
259 while ($val_rec =
$ilDB->fetchAssoc($val_set)) {
260 $s_resourceIds .=
"," . $val_rec[
"obj_id"];
262 $s_resourceIds = substr($s_resourceIds, 1);
264 $tquery =
"SELECT scorm_tree.lft, scorm_tree.child,
265 CASE WHEN sc_resource.scormtype = 'asset' THEN 1 ELSE 0 END AS asset,
267 FROM scorm_tree, sc_resource, sc_item
268 WHERE scorm_tree.slm_id=%s
269 AND sc_item.obj_id=scorm_tree.child
270 AND sc_resource.import_id=sc_item.identifierref
271 AND sc_resource.obj_id in (" . $s_resourceIds .
")
272 ORDER BY scorm_tree.lft";
273 $val_set =
$ilDB->queryF(
278 while ($val_rec =
$ilDB->fetchAssoc($val_set)) {
280 $a_out[] = array( (
int) $val_rec[
"lft"], (
int) $val_rec[
"child"], (
int) $val_rec[
"asset"], self::encodeURIComponent($val_rec[
"href"]) );
284 return json_encode($a_out);
292 $tquery =
"SELECT scorm_tree.child, scorm_tree.depth-3 depth, scorm_object.title, scorm_object.c_type
293 FROM scorm_tree, scorm_object
294 WHERE scorm_object.obj_id=scorm_tree.child
295 AND scorm_tree.slm_id=%s
296 AND (scorm_object.c_type='sor' OR scorm_object.c_type='sit')
297 ORDER BY scorm_tree.lft";
298 $val_set =
$ilDB->queryF(
303 while ($val_rec =
$ilDB->fetchAssoc($val_set)) {
304 $a_out[] = array((
int) $val_rec[
"child"],(
int) $val_rec[
"depth"],self::encodeURIComponent($val_rec[
"title"] ??
''),$val_rec[
"c_type"]);
306 return json_encode($a_out);
312 public static function getStatus(
int $a_packageId,
int $a_user_id,
bool $auto_last_visited,
string $scormType =
"1.2"): array
317 $status[
'saved_global_status'] = (
int) $oldStatus;
319 $status[
'lp_mode'] = $olp->getCurrentMode();
320 $collection = $olp->getCollectionInstance();
322 $status[
'scos'] = $collection->getItems();
324 $status[
'scos'] = array();
327 $status[
'p'] = $a_user_id;
329 $status[
'last_visited'] =
null;
330 $status[
'total_time_sec'] = 0;
331 $val_set =
$ilDB->queryF(
332 'SELECT last_visited, sco_total_time_sec, total_time_sec FROM sahs_user WHERE obj_id = %s AND user_id = %s',
333 array(
'integer',
'integer'),
334 array($a_packageId,$a_user_id)
336 $val_rec =
$ilDB->fetchAssoc($val_set);
337 if ($auto_last_visited) {
338 $status[
'last_visited'] = $val_rec[
"last_visited"];
340 if ($val_rec[
"total_time_sec"] ==
null) {
341 if ($val_rec[
"sco_total_time_sec"] ==
null) {
343 if ($scormType ==
"2004") {
347 $status[
'total_time_sec'] = (
int) $val_rec[
"sco_total_time_sec"];
350 $status[
'total_time_sec'] = (
int) $val_rec[
"total_time_sec"];
359 private static function setHash(
int $a_packageId,
int $a_user_id):
int
363 $hash = random_int(1_000_000_000, 2_147_483_647);
364 $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")));
367 'SELECT count(*) cnt FROM sahs_user WHERE obj_id = %s AND user_id = %s',
368 array(
'integer',
'integer'),
369 array($a_packageId,$a_user_id)
372 if ($val_rec[
"cnt"] == 0) {
374 'INSERT INTO sahs_user (obj_id, user_id, hash, hash_end) VALUES(%s, %s, %s, %s)',
375 array(
'integer',
'integer',
'text',
'timestamp'),
376 array($a_packageId, $a_user_id,
"" . $hash, $endDate)
380 'UPDATE sahs_user SET hash = %s, hash_end = %s WHERE obj_id = %s AND user_id = %s',
381 array(
'text',
'timestamp',
'integer',
'integer'),
382 array(
"" . $hash, $endDate, $a_packageId, $a_user_id)
static _lookupStatus(int $a_obj_id, int $a_user_id, bool $a_create=true)
Lookup status.
static getLogger(string $a_component_id)
Get component logger.
getDefaultLessonMode()
get default lesson mode
getApiStudentId()
Get cmi.core.student_id / cmi.learner_id for API.
getApiStudentName()
Get cmi.core.student_name / cmi.learner_name for API note: 'lastname, firstname' is required for SCOR...
getDataDirectory(?string $mode="filesystem")
get data directory of lm
getCreditMode()
get credit mode
getAutoReview()
get auto review as true/false for SCORM 1.2
getSessionDeactivated()
sessionDisabled for SCORM 2004
Class ilObjSCORMInitData.
static getIliasScormResources(int $a_packageId)
static getIliasScormTree(int $a_packageId)
static setHash(int $a_packageId, int $a_user_id)
hash for storing data without session
static getIliasScormVars(ilObjSCORMLearningModule $slm_obj)
static getIliasScormData(int $a_packageId)
static encodeURIComponent(string $str)
static getStatus(int $a_packageId, int $a_user_id, bool $auto_last_visited, string $scormType="1.2")
Class ilObjSCORMLearningModule.
getLastVisited(int $user_id)
static getInstance(int $obj_id)
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
const int DEFAULT_MIN_IDLE
default value for settings that have not been defined in setup or administration yet
static getIdleValue()
Returns the idle time in seconds.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
static getCookieMaxLifetimeInSeconds()