19 $revert = array(
'%21' =>
'!',
'%2A' =>
'*',
'%27' =>
"'",
'%28' =>
'(',
'%29' =>
')',
'%7E' =>
'~');
20 return strtr(rawurlencode($str), $revert);
26 $ilias =
$DIC[
'ilias'];
27 $ilLog =
$DIC[
'ilLog'];
35 $b_storeObjectives =
'false';
36 if ($slm_obj->getObjectives()) {
37 $b_storeObjectives =
'true';
39 $b_storeInteractions =
'false';
40 if ($slm_obj->getInteractions()) {
41 $b_storeInteractions =
'true';
43 $b_readInteractions =
'false';
44 $c_storeSessionTime =
's';
45 if ($slm_obj->getTime_from_lms()) {
46 $c_storeSessionTime =
'i';
48 $i_lessonScoreMax =
'-1';
49 $i_lessonMasteryScore = $slm_obj->getMasteryScore();
52 $b_messageLog =
'false';
53 if ($ilLog->current_log_level == 30) {
54 $b_messageLog =
'true';
57 if (
$_GET[
"autolaunch"] !=
"") {
58 $launchId =
$_GET[
"autolaunch"];
61 if ($slm_obj->getSession()) {
62 require_once(
'./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
65 if ($session_timeout > $max_idle) {
66 $session_timeout = $max_idle;
69 if ($session_timeout > $min_idle) {
70 $session_timeout = $min_idle;
72 $session_timeout -= 10;
74 $b_autoReview =
'false';
75 if ($slm_obj->getAutoReview()) {
76 $b_autoReview =
'true';
78 $b_autoSuspend =
'false';
79 if ($slm_obj->getAutoSuspend()) {
80 $b_autoSuspend =
'true';
83 if ($slm_obj->getDebug()) {
86 $b_autoContinue =
'false';
87 if ($slm_obj->getAutoContinue()) {
88 $b_autoContinue =
'true';
90 $b_checkSetValues =
'false';
91 if ($slm_obj->getCheck_values()) {
92 $b_checkSetValues =
'true';
94 $b_autoLastVisited =
'false';
95 if ($slm_obj->getAuto_last_visited()) {
96 $b_autoLastVisited =
'true';
97 if ($launchId ==
'0') {
98 $launchId = $slm_obj->getLastVisited(
$ilUser->getID());
102 $b_sessionDeactivated =
'false';
103 if ($slm_obj->getSessionDeactivated()) {
104 $b_sessionDeactivated =
'true';
110 $val_set =
$ilDB->queryF(
112 SELECT sc_item.obj_id,prereq_type,prerequisites,maxtimeallowed,timelimitaction,datafromlms,masteryscore
113 FROM sc_item, scorm_object
114 WHERE scorm_object.obj_id=sc_item.obj_id
115 AND scorm_object.c_type = %s
116 AND scorm_object.slm_id = %s',
117 array(
'text',
'integer'),
118 array(
'sit',$slm_obj->getId())
120 while ($val_rec =
$ilDB->fetchAssoc($val_set)) {
121 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) {
122 $tmp_man = array((
int) $val_rec[
"obj_id"],
null,
null,
null,
null,
null,
null);
123 if ($val_rec[
"prereq_type"] !=
null) {
126 if ($val_rec[
"prerequisites"] !=
null) {
129 if ($val_rec[
"maxtimeallowed"] !=
null) {
132 if ($val_rec[
"timelimitaction"] !=
null) {
135 if ($val_rec[
"datafromlms"] !=
null) {
138 if ($val_rec[
"masteryscore"] !=
null) {
146 .
'"refId":' .
$_GET[
"ref_id"] .
','
147 .
'"objId":' . $slm_obj->getId() .
','
149 .
'"launchId":' . $launchId .
','
151 .
'"pingSession":' . $session_timeout .
','
152 .
'"studentId":"' . $slm_obj->getApiStudentId() .
'",'
156 .
'"credit":"' . str_replace(
"_",
"-", $slm_obj->getCreditMode()) .
'",'
157 .
'"lesson_mode":"' . $slm_obj->getDefaultLessonMode() .
'",'
158 .
'"b_autoReview":' . $b_autoReview .
','
159 .
'"b_autoSuspend":' . $b_autoSuspend .
','
160 .
'"b_messageLog":' . $b_messageLog .
','
161 .
'"b_checkSetValues":' . $b_checkSetValues .
','
162 .
'"b_storeObjectives":' . $b_storeObjectives .
','
163 .
'"b_storeInteractions":' . $b_storeInteractions .
','
164 .
'"b_readInteractions":' . $b_readInteractions .
','
165 .
'"c_storeSessionTime":"' . $c_storeSessionTime .
'",'
166 .
'"b_autoContinue":' . $b_autoContinue .
','
167 .
'"b_autoLastVisited":' . $b_autoLastVisited .
','
168 .
'"b_sessionDeactivated":' . $b_sessionDeactivated .
','
169 .
'"i_lessonScoreMax":' . $i_lessonScoreMax .
','
170 .
'"i_lessonMasteryScore":"' . $i_lessonMasteryScore .
'",'
171 .
'"b_debug":' . $b_debug .
','
172 .
'"a_itemParameter":' . json_encode($a_man) .
','
173 .
'"status":' . json_encode(self::getStatus($slm_obj->getId(),
$ilUser->getID(), $slm_obj->getAuto_last_visited())) .
','
203 $ilias =
$DIC[
'ilias'];
206 $b_readInteractions =
'false';
208 $tquery =
'SELECT sco_id,lvalue,rvalue FROM scorm_tracking '
209 .
'WHERE user_id = %s AND obj_id = %s '
210 .
"AND sco_id > 0 AND lvalue != 'cmi.core.entry' AND lvalue != 'cmi.core.session_time'";
211 if ($b_readInteractions ==
'false') {
212 $tquery .=
" AND SUBSTR(lvalue, 1, 16) != 'cmi.interactions'";
214 $val_set =
$ilDB->queryF(
216 array(
'integer',
'integer'),
217 array(
$ilUser->getId(),$a_packageId)
219 while ($val_rec =
$ilDB->fetchAssoc($val_set)) {
220 if (!strpos($val_rec[
"lvalue"],
"._count")) {
221 $a_out[] = array( (
int) $val_rec[
"sco_id"], $val_rec[
"lvalue"], self::encodeURIComponent($val_rec[
"rvalue"]) );
224 return json_encode($a_out);
230 $ilias =
$DIC[
'ilias'];
235 $val_set =
$ilDB->queryF(
237 SELECT sc_resource.obj_id
238 FROM scorm_tree, sc_resource
239 WHERE scorm_tree.slm_id=%s
240 AND sc_resource.obj_id=scorm_tree.child",
244 while ($val_rec =
$ilDB->fetchAssoc($val_set)) {
245 $s_resourceIds .=
"," . $val_rec[
"obj_id"];
247 $s_resourceIds = substr($s_resourceIds, 1);
249 $tquery =
"SELECT scorm_tree.lft, scorm_tree.child,
250 CASE WHEN sc_resource.scormtype = 'asset' THEN 1 ELSE 0 END AS asset,
252 FROM scorm_tree, sc_resource, sc_item
253 WHERE scorm_tree.slm_id=%s
254 AND sc_item.obj_id=scorm_tree.child
255 AND sc_resource.import_id=sc_item.identifierref
256 AND sc_resource.obj_id in (" . $s_resourceIds .
")
257 ORDER BY scorm_tree.lft";
258 $val_set =
$ilDB->queryF(
263 while ($val_rec =
$ilDB->fetchAssoc($val_set)) {
265 $a_out[] = array( (
int) $val_rec[
"lft"], (
int) $val_rec[
"child"], (
int) $val_rec[
"asset"], self::encodeURIComponent($val_rec[
"href"]) );
269 return json_encode($a_out);
275 $ilias =
$DIC[
'ilias'];
278 $tquery =
"SELECT scorm_tree.child, scorm_tree.depth-3 depth, scorm_object.title, scorm_object.c_type
279 FROM scorm_tree, scorm_object
280 WHERE scorm_object.obj_id=scorm_tree.child
281 AND scorm_tree.slm_id=%s
282 AND (scorm_object.c_type='sor' OR scorm_object.c_type='sit')
283 ORDER BY scorm_tree.lft";
284 $val_set =
$ilDB->queryF(
289 while ($val_rec =
$ilDB->fetchAssoc($val_set)) {
290 $a_out[] = array((
int) $val_rec[
"child"],(
int) $val_rec[
"depth"],self::encodeURIComponent($val_rec[
"title"]),$val_rec[
"c_type"]);
292 return json_encode($a_out);
295 public static function getStatus($a_packageId, $a_user_id, $auto_last_visited, $scormType =
"1.2")
299 include_once
'./Services/Tracking/classes/class.ilLPStatus.php';
301 $status[
'saved_global_status'] = (int) $oldStatus;
302 include_once
'./Services/Object/classes/class.ilObjectLP.php';
304 $status[
'lp_mode'] = $olp->getCurrentMode();
305 $collection = $olp->getCollectionInstance();
307 $status[
'scos'] = $collection->getItems();
309 $status[
'scos'] = array();
312 $status[
'p'] = $a_user_id;
314 $status[
'last_visited'] =
null;
315 $status[
'total_time_sec'] = 0;
316 $val_set =
$ilDB->queryF(
317 'SELECT last_visited, sco_total_time_sec, total_time_sec FROM sahs_user WHERE obj_id = %s AND user_id = %s',
318 array(
'integer',
'integer'),
319 array($a_packageId,$a_user_id)
321 $val_rec =
$ilDB->fetchAssoc($val_set);
322 if ($auto_last_visited) {
323 $status[
'last_visited'] = $val_rec[
"last_visited"];
325 if ($val_rec[
"total_time_sec"] ==
null) {
326 if ($val_rec[
"sco_total_time_sec"] ==
null) {
328 if ($scormType ==
"2004") {
329 include_once
'./Modules/Scorm2004/classes/class.ilSCORM2004Tracking.php';
333 $status[
'total_time_sec'] = (int) $val_rec[
"sco_total_time_sec"];
336 $status[
'total_time_sec'] = (int) $val_rec[
"total_time_sec"];
344 private static function setHash($a_packageId, $a_user_id)
348 $hash = mt_rand(1000000000, 2147483647);
349 $endDate = date(
'Y-m-d H:i:s', mktime(date(
'H'), date(
'i'), date(
's'), date(
'm'), date(
'd') + 1, date(
'Y')));
352 'SELECT count(*) cnt FROM sahs_user WHERE obj_id = %s AND user_id = %s',
353 array(
'integer',
'integer'),
354 array($a_packageId,$a_user_id)
357 if ($val_rec[
"cnt"] == 0) {
359 'INSERT INTO sahs_user (obj_id, user_id, hash, hash_end) VALUES(%s, %s, %s, %s)',
360 array(
'integer',
'integer',
'text',
'timestamp'),
361 array($a_packageId, $a_user_id,
"" . $hash, $endDate)
365 'UPDATE sahs_user SET hash = %s, hash_end = %s WHERE obj_id = %s AND user_id = %s',
366 array(
'text',
'timestamp',
'integer',
'integer'),
367 array(
"" . $hash, $endDate, $a_packageId, $a_user_id)
An exception for terminatinating execution or to throw for unit testing.
static _lookupStatus($a_obj_id, $a_user_id, $a_create=true)
Lookup status.
Class ilObjSCORMInitData.
static encodeURIComponent($str)
static getIliasScormData($a_packageId)
static getIliasScormVars($slm_obj)
static get_max_attempts($a_packageId)
Get max.
static getStatus($a_packageId, $a_user_id, $auto_last_visited, $scormType="1.2")
static getIliasScormResources($a_packageId)
static setHash($a_packageId, $a_user_id)
static getIliasScormTree($a_packageId)
static getInstance($a_obj_id)
static getSumTotalTimeSecondsFromScos($a_obj_id, $a_user_id, $a_write=false)
should be avoided; store value to increase performance for further requests
static getIdleValue($fixedMode=false)
Returns the idle time in seconds.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static getCookieMaxLifetimeInSeconds()
foreach($_POST as $key=> $value) $res