ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilObjSCORMInitData Class Reference

Class ilObjSCORMInitData. More...

+ Collaboration diagram for ilObjSCORMInitData:

Static Public Member Functions

static encodeURIComponent ($str)
 
static getIliasScormVars ($slm_obj)
 
static getIliasScormData ($a_packageId)
 
static getIliasScormResources ($a_packageId)
 
static getIliasScormTree ($a_packageId)
 
static getStatus ($a_packageId, $a_user_id, $auto_last_visited, $scormType="1.2")
 
static get_max_attempts ($a_packageId)
 Get max. More...
 

Static Private Member Functions

static setHash ($a_packageId, $a_user_id)
 

Detailed Description

Class ilObjSCORMInitData.

Class for getting init Data fpr SCORM 1.2 RTE

Author
Uwe Kohnle kohnl.nosp@m.e@in.nosp@m.terne.nosp@m.tleh.nosp@m.rer-g.nosp@m.mbh..nosp@m.de
Version
Id
class.ilObjSCORMInitData.php

Definition at line 15 of file class.ilObjSCORMInitData.php.

Member Function Documentation

◆ encodeURIComponent()

static ilObjSCORMInitData::encodeURIComponent (   $str)
static

Definition at line 17 of file class.ilObjSCORMInitData.php.

18 {
19 $revert = array('%21' => '!', '%2A' => '*', '%27' => "'", '%28' => '(', '%29' => ')', '%7E' => '~');
20 return strtr(rawurlencode($str), $revert);
21 }

Referenced by getIliasScormVars().

+ Here is the caller graph for this function:

◆ get_max_attempts()

static ilObjSCORMInitData::get_max_attempts (   $a_packageId)
static

Get max.

number of attempts allowed for this package

Definition at line 385 of file class.ilObjSCORMInitData.php.

386 {
387 //erased in 5.1
388 return 0;
389 }

Referenced by ilSCORM13Player\get_max_attempts(), ilSCORMPresentationGUI\get_max_attempts(), and ilSCORMOfflineMode\tracking2sop().

+ Here is the caller graph for this function:

◆ getIliasScormData()

static ilObjSCORMInitData::getIliasScormData (   $a_packageId)
static

Definition at line 200 of file class.ilObjSCORMInitData.php.

201 {
202 global $DIC;
203 $ilias = $DIC['ilias'];
204 $ilUser = $DIC['ilUser'];
205 $ilDB = $DIC['ilDB'];
206 $b_readInteractions = 'false';
207 $a_out = array();
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'";
213 }
214 $val_set = $ilDB->queryF(
215 $tquery,
216 array('integer','integer'),
217 array($ilUser->getId(),$a_packageId)
218 );
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"]) );
222 }
223 }
224 return json_encode($a_out);
225 }
global $ilDB
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46

References $DIC, $ilDB, and $ilUser.

Referenced by ilSCORMPresentationGUI\apiInitData(), and ilSCORMOfflineMode\tracking2sop().

+ Here is the caller graph for this function:

◆ getIliasScormResources()

static ilObjSCORMInitData::getIliasScormResources (   $a_packageId)
static

Definition at line 227 of file class.ilObjSCORMInitData.php.

228 {
229 global $DIC;
230 $ilias = $DIC['ilias'];
231 $ilDB = $DIC['ilDB'];
232 // $s_out="";
233 $a_out = array();
234 $s_resourceIds = "";//necessary if resources exist having different href with same identifier
235 $val_set = $ilDB->queryF(
236 "
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",
241 array('integer'),
242 array($a_packageId)
243 );
244 while ($val_rec = $ilDB->fetchAssoc($val_set)) {
245 $s_resourceIds .= "," . $val_rec["obj_id"];
246 }
247 $s_resourceIds = substr($s_resourceIds, 1);
248
249 $tquery = "SELECT scorm_tree.lft, scorm_tree.child,
250 CASE WHEN sc_resource.scormtype = 'asset' THEN 1 ELSE 0 END AS asset,
251 sc_resource.href
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(
259 $tquery,
260 array('integer'),
261 array($a_packageId)
262 );
263 while ($val_rec = $ilDB->fetchAssoc($val_set)) {
264 // $s_out.='['.$val_rec["lft"].','.$val_rec["child"].','.$val_rec["asset"].',"'.self::encodeURIComponent($val_rec["href"]).'"],';
265 $a_out[] = array( (int) $val_rec["lft"], (int) $val_rec["child"], (int) $val_rec["asset"], self::encodeURIComponent($val_rec["href"]) );
266 }
267 // if(substr($s_out,(strlen($s_out)-1))==",") $s_out=substr($s_out,0,(strlen($s_out)-1));
268 // return "[".$s_out."]";
269 return json_encode($a_out);
270 }

References $DIC, and $ilDB.

Referenced by ilSCORMPresentationGUI\apiInitData(), and ilSCORMOfflineMode\tracking2sop().

+ Here is the caller graph for this function:

◆ getIliasScormTree()

static ilObjSCORMInitData::getIliasScormTree (   $a_packageId)
static

Definition at line 272 of file class.ilObjSCORMInitData.php.

273 {
274 global $DIC;
275 $ilias = $DIC['ilias'];
276 $ilDB = $DIC['ilDB'];
277 $a_out = array();
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(
285 $tquery,
286 array('integer'),
287 array($a_packageId)
288 );
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"]);
291 }
292 return json_encode($a_out);
293 }

References $DIC, and $ilDB.

Referenced by ilSCORMPresentationGUI\apiInitData(), and ilSCORMOfflineMode\tracking2sop().

+ Here is the caller graph for this function:

◆ getIliasScormVars()

static ilObjSCORMInitData::getIliasScormVars (   $slm_obj)
static

Definition at line 23 of file class.ilObjSCORMInitData.php.

24 {
25 global $DIC;
26 $ilias = $DIC['ilias'];
27 $ilLog = $DIC['ilLog'];
28 $ilUser = $DIC['ilUser'];
29 $lng = $DIC['lng'];
30 $ilDB = $DIC['ilDB'];
31 $ilSetting = $DIC['ilSetting'];
32 // $slm_obj = new ilObjSCORMLearningModule($_GET["ref_id"]);
33
34 //variables to set in administration interface
35 $b_storeObjectives = 'false';
36 if ($slm_obj->getObjectives()) {
37 $b_storeObjectives = 'true';
38 }
39 $b_storeInteractions = 'false';
40 if ($slm_obj->getInteractions()) {
41 $b_storeInteractions = 'true';
42 }
43 $b_readInteractions = 'false';
44 $c_storeSessionTime = 's';//n=no, s=sco, i=ilias
45 if ($slm_obj->getTime_from_lms()) {
46 $c_storeSessionTime = 'i';
47 }
48 $i_lessonScoreMax = '-1';
49 $i_lessonMasteryScore = $slm_obj->getMasteryScore();
50
51 //other variables
52 $b_messageLog = 'false';
53 if ($ilLog->current_log_level == 30) {
54 $b_messageLog = 'true';
55 }
56 $launchId = '0';
57 if ($_GET["autolaunch"] != "") {
58 $launchId = $_GET["autolaunch"];
59 }
60 $session_timeout = 0; //unlimited sessions
61 if ($slm_obj->getSession()) {
62 require_once('./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
63 $session_timeout = (int) ilWACSignedPath::getCookieMaxLifetimeInSeconds();
64 $max_idle = (int) ilSession::getIdleValue();
65 if ($session_timeout > $max_idle) {
66 $session_timeout = $max_idle;
67 }
68 $min_idle = (int) $ilSetting->get('session_min_idle', ilSessionControl::DEFAULT_MIN_IDLE) * 60;
69 if ($session_timeout > $min_idle) {
70 $session_timeout = $min_idle;
71 }
72 $session_timeout -= 10; //buffer
73 }
74 $b_autoReview = 'false';
75 if ($slm_obj->getAutoReview()) {
76 $b_autoReview = 'true';
77 }
78 $b_autoSuspend = 'false';
79 if ($slm_obj->getAutoSuspend()) {
80 $b_autoSuspend = 'true';
81 }
82 $b_debug = 'false';
83 if ($slm_obj->getDebug()) {
84 $b_debug = 'true';
85 }
86 $b_autoContinue = 'false';
87 if ($slm_obj->getAutoContinue()) {
88 $b_autoContinue = 'true';
89 }
90 $b_checkSetValues = 'false';
91 if ($slm_obj->getCheck_values()) {
92 $b_checkSetValues = 'true';
93 }
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());
99 }
100 }
101
102 $b_sessionDeactivated = 'false';
103 if ($slm_obj->getSessionDeactivated()) {
104 $b_sessionDeactivated = 'true';
105 }
106
107 //manifestData //extra to IliasScormManifestData
108 // $s_man = "";
109 $a_man = array();
110 $val_set = $ilDB->queryF(
111 '
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())
119 );
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) {
124 $tmp_man[1] = self::encodeURIComponent($val_rec["prereq_type"]);
125 }
126 if ($val_rec["prerequisites"] != null) {
127 $tmp_man[2] = self::encodeURIComponent($val_rec["prerequisites"]);
128 }
129 if ($val_rec["maxtimeallowed"] != null) {
130 $tmp_man[3] = self::encodeURIComponent($val_rec["maxtimeallowed"]);
131 }
132 if ($val_rec["timelimitaction"] != null) {
133 $tmp_man[4] = self::encodeURIComponent($val_rec["timelimitaction"]);
134 }
135 if ($val_rec["datafromlms"] != null) {
136 $tmp_man[5] = self::encodeURIComponent($val_rec["datafromlms"]);
137 }
138 if ($val_rec["masteryscore"] != null) {
139 $tmp_man[6] = self::encodeURIComponent($val_rec["masteryscore"]);
140 }
141 $a_man[] = $tmp_man;
142 }
143 }
144
145 $s_out = '{'
146 . '"refId":' . $_GET["ref_id"] . ','
147 . '"objId":' . $slm_obj->getId() . ','
148 . '"clientId":"' . CLIENT_ID . '",'
149 . '"launchId":' . $launchId . ','
150 . '"launchNr":0,'
151 . '"pingSession":' . $session_timeout . ','
152 . '"studentId":"' . $slm_obj->getApiStudentId() . '",'
153 . '"studentName":"' . self::encodeURIComponent($slm_obj->getApiStudentName()) . '",'
154 . '"studentLogin":"' . self::encodeURIComponent($ilias->account->getLogin()) . '",'
155 . '"studentOu":"' . self::encodeURIComponent($ilias->account->getDepartment()) . '",'
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())) . ','
174 . '"dataDirectory":"' . self::encodeURIComponent($slm_obj->getDataDirectory("output") . '/') . '",'
175 . '"img":{'
176 . '"asset":"' . self::encodeURIComponent(ilUtil::getImagePath('scorm/asset.svg')) . '",'
177 . '"browsed":"' . self::encodeURIComponent(ilUtil::getImagePath('scorm/browsed.svg')) . '",'
178 . '"completed":"' . self::encodeURIComponent(ilUtil::getImagePath('scorm/completed.svg')) . '",'
179 . '"failed":"' . self::encodeURIComponent(ilUtil::getImagePath('scorm/failed.svg')) . '",'
180 . '"incomplete":"' . self::encodeURIComponent(ilUtil::getImagePath('scorm/incomplete.svg')) . '",'
181 . '"not_attempted":"' . self::encodeURIComponent(ilUtil::getImagePath('scorm/not_attempted.svg')) . '",'
182 . '"passed":"' . self::encodeURIComponent(ilUtil::getImagePath('scorm/passed.svg')) . '",'
183 . '"running":"' . self::encodeURIComponent(ilUtil::getImagePath('scorm/running.svg')) . '"'
184 . '},'
185 . '"statusTxt":{'
186 . '"wait":"' . self::encodeURIComponent($lng->txt("please_wait")) . '",'
187 . '"status":"' . self::encodeURIComponent($lng->txt("cont_status")) . '",'
188 . '"browsed":"' . self::encodeURIComponent($lng->txt("cont_sc_stat_browsed")) . '",'
189 . '"completed":"' . self::encodeURIComponent($lng->txt("cont_sc_stat_completed")) . '",'
190 . '"failed":"' . self::encodeURIComponent($lng->txt("cont_sc_stat_failed")) . '",'
191 . '"incomplete":"' . self::encodeURIComponent($lng->txt("cont_sc_stat_incomplete")) . '",'
192 . '"not_attempted":"' . self::encodeURIComponent($lng->txt("cont_sc_stat_not_attempted")) . '",'
193 . '"passed":"' . self::encodeURIComponent($lng->txt("cont_sc_stat_passed")) . '",'
194 . '"running":"' . self::encodeURIComponent($lng->txt("cont_sc_stat_running")) . '"'
195 . '}'
196 . '}';
197 return $s_out;
198 }
$_GET["client_id"]
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()
global $ilSetting
Definition: privfeed.php:17
$lng

References $_GET, $DIC, $ilDB, $ilLog, $ilSetting, $ilUser, $lng, ilSessionControl\DEFAULT_MIN_IDLE, encodeURIComponent(), ilWACSignedPath\getCookieMaxLifetimeInSeconds(), ilSession\getIdleValue(), and ilUtil\getImagePath().

Referenced by ilSCORMPresentationGUI\apiInitData(), and ilSCORMOfflineMode\tracking2sop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStatus()

static ilObjSCORMInitData::getStatus (   $a_packageId,
  $a_user_id,
  $auto_last_visited,
  $scormType = "1.2" 
)
static

Definition at line 295 of file class.ilObjSCORMInitData.php.

296 {
297 global $DIC;
298 $ilDB = $DIC['ilDB'];
299 include_once './Services/Tracking/classes/class.ilLPStatus.php';
300 $oldStatus = ilLPStatus::_lookupStatus($a_packageId, $a_user_id);
301 $status['saved_global_status'] = (int) $oldStatus;
302 include_once './Services/Object/classes/class.ilObjectLP.php';
303 $olp = ilObjectLP::getInstance($a_packageId);
304 $status['lp_mode'] = $olp->getCurrentMode();
305 $collection = $olp->getCollectionInstance();
306 if ($collection) {
307 $status['scos'] = $collection->getItems();
308 } else {
309 $status['scos'] = array();
310 }
311 $status['hash'] = ilObjSCORMInitData::setHash($a_packageId, $a_user_id);
312 $status['p'] = $a_user_id;
313
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)
320 );
321 $val_rec = $ilDB->fetchAssoc($val_set);
322 if ($auto_last_visited) {
323 $status['last_visited'] = $val_rec["last_visited"];
324 }
325 if ($val_rec["total_time_sec"] == null) {
326 if ($val_rec["sco_total_time_sec"] == null) {
327 //fall back for old ILIAS-Versions
328 if ($scormType == "2004") {
329 include_once './Modules/Scorm2004/classes/class.ilSCORM2004Tracking.php';
330 $status['total_time_sec'] = (int) ilSCORM2004Tracking::getSumTotalTimeSecondsFromScos($a_packageId, $a_user_id, true);
331 }
332 } else {
333 $status['total_time_sec'] = (int) $val_rec["sco_total_time_sec"];
334 }
335 } else {
336 $status['total_time_sec'] = (int) $val_rec["total_time_sec"];
337 }
338
339
340
341 return $status;
342 }
static _lookupStatus($a_obj_id, $a_user_id, $a_create=true)
Lookup status.
static setHash($a_packageId, $a_user_id)
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

References $DIC, $ilDB, ilLPStatus\_lookupStatus(), ilObjectLP\getInstance(), ilSCORM2004Tracking\getSumTotalTimeSecondsFromScos(), and setHash().

Referenced by ilSCORM13Player\getConfigForPlayer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setHash()

static ilObjSCORMInitData::setHash (   $a_packageId,
  $a_user_id 
)
staticprivate

Definition at line 344 of file class.ilObjSCORMInitData.php.

345 {
346 global $DIC;
347 $ilDB = $DIC['ilDB'];
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')));
350
351 $res = $ilDB->queryF(
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)
355 );
356 $val_rec = $ilDB->fetchAssoc($res);
357 if ($val_rec["cnt"] == 0) { //offline_mode could be inserted
358 $ilDB->manipulateF(
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)
362 );
363 } else {
364 $ilDB->manipulateF(
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)
368 );
369 }
370 //clean table
371 // if (fmod($hash,100) == 0) //note: do not use % for large numbers; here php-min-Version: 4.2.0
372 // {
373 // $endDate = date('Y-m-d H:i:s', mktime(date('H'), date('i'), date('s'), date('m'), date('d')-2, date('Y')));
374 // $ilDB->manipulateF('DELETE FROM cmi_custom WHERE lvalue = %s AND c_timestamp < %s',
375 // array('text', 'timestamp'),
376 // array('hash', $endDate)
377 // );
378 // }
379 return $hash;
380 }
foreach($_POST as $key=> $value) $res

References $DIC, $ilDB, and $res.

Referenced by getStatus().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: