ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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.

References array.

18  {
19  $revert = array('%21'=>'!', '%2A'=>'*', '%27'=>"'", '%28'=>'(', '%29'=>')', '%7E'=>'~');
20  return strtr(rawurlencode($str), $revert);
21  }
Create styles array
The data for the language used.

◆ get_max_attempts()

static ilObjSCORMInitData::get_max_attempts (   $a_packageId)
static

Get max.

number of attempts allowed for this package

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

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

371  {
372  //erased in 5.1
373  return 0;
374  }
+ Here is the caller graph for this function:

◆ getIliasScormData()

static ilObjSCORMInitData::getIliasScormData (   $a_packageId)
static

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

References $ilDB, $ilUser, and array.

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

195  {
196  global $ilias, $ilUser, $ilDB;
197  $b_readInteractions='false';
198  $a_out=array();
199  $tquery = 'SELECT sco_id,lvalue,rvalue FROM scorm_tracking '
200  . 'WHERE user_id = %s AND obj_id = %s '
201  . "AND sco_id > 0 AND lvalue != 'cmi.core.entry' AND lvalue != 'cmi.core.session_time'";
202  if ($b_readInteractions == 'false') {
203  $tquery.=" AND SUBSTR(lvalue, 1, 16) != 'cmi.interactions'";
204  }
205  $val_set = $ilDB->queryF(
206  $tquery,
207  array('integer','integer'),
208  array($ilUser->getId(),$a_packageId)
209  );
210  while ($val_rec = $ilDB->fetchAssoc($val_set)) {
211  if (!strpos($val_rec["lvalue"], "._count")) {
212  $a_out[]=array( (int) $val_rec["sco_id"], $val_rec["lvalue"], self::encodeURIComponent($val_rec["rvalue"]) );
213  }
214  }
215  return json_encode($a_out);
216  }
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ getIliasScormResources()

static ilObjSCORMInitData::getIliasScormResources (   $a_packageId)
static

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

References $ilDB, and array.

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

219  {
220  global $ilias, $ilDB;
221  // $s_out="";
222  $a_out=array();
223  $s_resourceIds="";//necessary if resources exist having different href with same identifier
224  $val_set = $ilDB->queryF(
225  "
226  SELECT sc_resource.obj_id
227  FROM scorm_tree, sc_resource
228  WHERE scorm_tree.slm_id=%s
229  AND sc_resource.obj_id=scorm_tree.child",
230  array('integer'),
231  array($a_packageId)
232  );
233  while ($val_rec = $ilDB->fetchAssoc($val_set)) {
234  $s_resourceIds .= "," . $val_rec["obj_id"];
235  }
236  $s_resourceIds = substr($s_resourceIds, 1);
237 
238  $tquery="SELECT scorm_tree.lft, scorm_tree.child,
239  CASE WHEN sc_resource.scormtype = 'asset' THEN 1 ELSE 0 END AS asset,
240  sc_resource.href
241  FROM scorm_tree, sc_resource, sc_item
242  WHERE scorm_tree.slm_id=%s
243  AND sc_item.obj_id=scorm_tree.child
244  AND sc_resource.import_id=sc_item.identifierref
245  AND sc_resource.obj_id in (" . $s_resourceIds . ")
246  ORDER BY scorm_tree.lft";
247  $val_set = $ilDB->queryF(
248  $tquery,
249  array('integer'),
250  array($a_packageId)
251  );
252  while ($val_rec = $ilDB->fetchAssoc($val_set)) {
253  // $s_out.='['.$val_rec["lft"].','.$val_rec["child"].','.$val_rec["asset"].',"'.self::encodeURIComponent($val_rec["href"]).'"],';
254  $a_out[]=array( (int) $val_rec["lft"], (int) $val_rec["child"], (int) $val_rec["asset"], self::encodeURIComponent($val_rec["href"]) );
255  }
256  // if(substr($s_out,(strlen($s_out)-1))==",") $s_out=substr($s_out,0,(strlen($s_out)-1));
257  // return "[".$s_out."]";
258  return json_encode($a_out);
259  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ getIliasScormTree()

static ilObjSCORMInitData::getIliasScormTree (   $a_packageId)
static

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

References $ilDB, and array.

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

262  {
263  global $ilias, $ilDB;
264  $a_out=array();
265  $tquery="SELECT scorm_tree.child, scorm_tree.depth-3 depth, scorm_object.title, scorm_object.c_type
266  FROM scorm_tree, scorm_object
267  WHERE scorm_object.obj_id=scorm_tree.child
268  AND scorm_tree.slm_id=%s
269  AND (scorm_object.c_type='sor' OR scorm_object.c_type='sit')
270  ORDER BY scorm_tree.lft";
271  $val_set = $ilDB->queryF(
272  $tquery,
273  array('integer'),
274  array($a_packageId)
275  );
276  while ($val_rec = $ilDB->fetchAssoc($val_set)) {
277  $a_out[]=array((int) $val_rec["child"],(int) $val_rec["depth"],self::encodeURIComponent($val_rec["title"]),$val_rec["c_type"]);
278  }
279  return json_encode($a_out);
280  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ getIliasScormVars()

static ilObjSCORMInitData::getIliasScormVars (   $slm_obj)
static

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

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

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

24  {
25  global $ilias, $ilLog, $ilUser, $lng, $ilDB, $ilSetting;
26  // $slm_obj = new ilObjSCORMLearningModule($_GET["ref_id"]);
27 
28  //variables to set in administration interface
29  $b_storeObjectives='false';
30  if ($slm_obj->getObjectives()) {
31  $b_storeObjectives='true';
32  }
33  $b_storeInteractions='false';
34  if ($slm_obj->getInteractions()) {
35  $b_storeInteractions='true';
36  }
37  $b_readInteractions='false';
38  $c_storeSessionTime='s';//n=no, s=sco, i=ilias
39  if ($slm_obj->getTime_from_lms()) {
40  $c_storeSessionTime='i';
41  }
42  $i_lessonScoreMax='-1';
43  $i_lessonMasteryScore=$slm_obj->getMasteryScore();
44 
45  //other variables
46  $b_messageLog='false';
47  if ($ilLog->current_log_level == 30) {
48  $b_messageLog='true';
49  }
50  $launchId='0';
51  if ($_GET["autolaunch"] != "") {
52  $launchId=$_GET["autolaunch"];
53  }
54  $session_timeout = 0; //unlimited sessions
55  if ($slm_obj->getSession()) {
56  require_once('./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
57  $session_timeout = (int) ilWACSignedPath::getCookieMaxLifetimeInSeconds();
58  $max_idle = (int) ilSession::getIdleValue();
59  if ($session_timeout > $max_idle) {
60  $session_timeout = $max_idle;
61  }
62  $min_idle = (int) $ilSetting->get('session_min_idle', ilSessionControl::DEFAULT_MIN_IDLE) * 60;
63  if ($session_timeout > $min_idle) {
64  $session_timeout = $min_idle;
65  }
66  $session_timeout -= 10; //buffer
67  }
68  $b_autoReview='false';
69  if ($slm_obj->getAutoReview()) {
70  $b_autoReview='true';
71  }
72  $b_autoSuspend='false';
73  if ($slm_obj->getAutoSuspend()) {
74  $b_autoSuspend='true';
75  }
76  $b_debug='false';
77  if ($slm_obj->getDebug()) {
78  $b_debug='true';
79  }
80  $b_autoContinue='false';
81  if ($slm_obj->getAutoContinue()) {
82  $b_autoContinue='true';
83  }
84  $b_checkSetValues='false';
85  if ($slm_obj->getCheck_values()) {
86  $b_checkSetValues='true';
87  }
88  $b_autoLastVisited='false';
89  if ($slm_obj->getAuto_last_visited()) {
90  $b_autoLastVisited='true';
91  if ($launchId == '0') {
92  $launchId=$slm_obj->getLastVisited($ilUser->getID());
93  }
94  }
95 
96  $b_sessionDeactivated='false';
97  if ($slm_obj->getSessionDeactivated()) {
98  $b_sessionDeactivated='true';
99  }
100 
101  //manifestData //extra to IliasScormManifestData
102  // $s_man = "";
103  $a_man = array();
104  $val_set = $ilDB->queryF(
105  '
106  SELECT sc_item.obj_id,prereq_type,prerequisites,maxtimeallowed,timelimitaction,datafromlms,masteryscore
107  FROM sc_item, scorm_object
108  WHERE scorm_object.obj_id=sc_item.obj_id
109  AND scorm_object.c_type = %s
110  AND scorm_object.slm_id = %s',
111  array('text','integer'),
112  array('sit',$slm_obj->getId())
113  );
114  while ($val_rec = $ilDB->fetchAssoc($val_set)) {
115  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) {
116  $tmp_man=array((int) $val_rec["obj_id"],null,null,null,null,null,null);
117  if ($val_rec["prereq_type"]!=null) {
118  $tmp_man[1]=self::encodeURIComponent($val_rec["prereq_type"]);
119  }
120  if ($val_rec["prerequisites"]!=null) {
121  $tmp_man[2]=self::encodeURIComponent($val_rec["prerequisites"]);
122  }
123  if ($val_rec["maxtimeallowed"]!=null) {
124  $tmp_man[3]=self::encodeURIComponent($val_rec["maxtimeallowed"]);
125  }
126  if ($val_rec["timelimitaction"]!=null) {
127  $tmp_man[4]=self::encodeURIComponent($val_rec["timelimitaction"]);
128  }
129  if ($val_rec["datafromlms"]!=null) {
130  $tmp_man[5]=self::encodeURIComponent($val_rec["datafromlms"]);
131  }
132  if ($val_rec["masteryscore"]!=null) {
133  $tmp_man[6]=self::encodeURIComponent($val_rec["masteryscore"]);
134  }
135  $a_man[]=$tmp_man;
136  }
137  }
138 
139  $s_out='{'
140  . '"refId":' . $_GET["ref_id"] . ','
141  . '"objId":' . $slm_obj->getId() . ','
142  . '"clientId":"' . CLIENT_ID . '",'
143  . '"launchId":' . $launchId . ','
144  . '"launchNr":0,'
145  . '"pingSession":' . $session_timeout . ','
146  . '"studentId":"' . $slm_obj->getApiStudentId() . '",'
147  . '"studentName":"' . self::encodeURIComponent($slm_obj->getApiStudentName()) . '",'
148  . '"studentLogin":"' . self::encodeURIComponent($ilias->account->getLogin()) . '",'
149  . '"studentOu":"' . self::encodeURIComponent($ilias->account->getDepartment()) . '",'
150  . '"credit":"' . str_replace("_", "-", $slm_obj->getCreditMode()) . '",'
151  . '"lesson_mode":"' . $slm_obj->getDefaultLessonMode() . '",'
152  . '"b_autoReview":' . $b_autoReview . ','
153  . '"b_autoSuspend":' . $b_autoSuspend . ','
154  . '"b_messageLog":' . $b_messageLog . ','
155  . '"b_checkSetValues":' . $b_checkSetValues . ','
156  . '"b_storeObjectives":' . $b_storeObjectives . ','
157  . '"b_storeInteractions":' . $b_storeInteractions . ','
158  . '"b_readInteractions":' . $b_readInteractions . ','
159  . '"c_storeSessionTime":"' . $c_storeSessionTime . '",'
160  . '"b_autoContinue":' . $b_autoContinue . ','
161  . '"b_autoLastVisited":' . $b_autoLastVisited . ','
162  . '"b_sessionDeactivated":' . $b_sessionDeactivated . ','
163  . '"i_lessonScoreMax":' . $i_lessonScoreMax . ','
164  . '"i_lessonMasteryScore":"' . $i_lessonMasteryScore . '",'
165  . '"b_debug":' . $b_debug . ','
166  . '"a_itemParameter":' . json_encode($a_man) . ','
167  . '"status":' . json_encode(self::getStatus($slm_obj->getId(), $ilUser->getID(), $slm_obj->getAuto_last_visited())) . ','
168  . '"dataDirectory":"' . self::encodeURIComponent($slm_obj->getDataDirectory("output") . '/') . '",'
169  . '"img":{'
170  . '"asset":"' . self::encodeURIComponent(ilUtil::getImagePath('scorm/asset.svg')) . '",'
171  . '"browsed":"' . self::encodeURIComponent(ilUtil::getImagePath('scorm/browsed.svg')) . '",'
172  . '"completed":"' . self::encodeURIComponent(ilUtil::getImagePath('scorm/completed.svg')) . '",'
173  . '"failed":"' . self::encodeURIComponent(ilUtil::getImagePath('scorm/failed.svg')) . '",'
174  . '"incomplete":"' . self::encodeURIComponent(ilUtil::getImagePath('scorm/incomplete.svg')) . '",'
175  . '"not_attempted":"' . self::encodeURIComponent(ilUtil::getImagePath('scorm/not_attempted.svg')) . '",'
176  . '"passed":"' . self::encodeURIComponent(ilUtil::getImagePath('scorm/passed.svg')) . '",'
177  . '"running":"' . self::encodeURIComponent(ilUtil::getImagePath('scorm/running.svg')) . '"'
178  . '},'
179  . '"statusTxt":{'
180  . '"wait":"' . self::encodeURIComponent($lng->txt("please_wait")) . '",'
181  . '"status":"' . self::encodeURIComponent($lng->txt("cont_status")) . '",'
182  . '"browsed":"' . self::encodeURIComponent($lng->txt("cont_sc_stat_browsed")) . '",'
183  . '"completed":"' . self::encodeURIComponent($lng->txt("cont_sc_stat_completed")) . '",'
184  . '"failed":"' . self::encodeURIComponent($lng->txt("cont_sc_stat_failed")) . '",'
185  . '"incomplete":"' . self::encodeURIComponent($lng->txt("cont_sc_stat_incomplete")) . '",'
186  . '"not_attempted":"' . self::encodeURIComponent($lng->txt("cont_sc_stat_not_attempted")) . '",'
187  . '"passed":"' . self::encodeURIComponent($lng->txt("cont_sc_stat_passed")) . '",'
188  . '"running":"' . self::encodeURIComponent($lng->txt("cont_sc_stat_running")) . '"'
189  . '}'
190  . '}';
191  return $s_out;
192  }
static getCookieMaxLifetimeInSeconds()
$_GET["client_id"]
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
$ilUser
Definition: imgupload.php:18
static getIdleValue($fixedMode=false)
Returns the idle time in seconds.
Create styles array
The data for the language used.
global $ilSetting
Definition: privfeed.php:17
global $lng
Definition: privfeed.php:17
global $ilDB
+ 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 282 of file class.ilObjSCORMInitData.php.

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

Referenced by ilSCORM13Player\getConfigForPlayer().

283  {
284  global $ilDB;
285  include_once './Services/Tracking/classes/class.ilLPStatus.php';
286  $oldStatus = ilLPStatus::_lookupStatus($a_packageId, $a_user_id);
287  $status['saved_global_status']=(int) $oldStatus;
288  include_once './Services/Object/classes/class.ilObjectLP.php';
289  $olp = ilObjectLP::getInstance($a_packageId);
290  $status['lp_mode'] = $olp->getCurrentMode();
291  $collection = $olp->getCollectionInstance();
292  if ($collection) {
293  $status['scos'] = $collection->getItems();
294  } else {
295  $status['scos'] = array();
296  }
297  $status['hash'] = ilObjSCORMInitData::setHash($a_packageId, $a_user_id);
298  $status['p'] = $a_user_id;
299 
300  $status['last_visited'] = null;
301  $status['total_time_sec'] = 0;
302  $val_set = $ilDB->queryF(
303  'SELECT last_visited, sco_total_time_sec, total_time_sec FROM sahs_user WHERE obj_id = %s AND user_id = %s',
304  array('integer','integer'),
305  array($a_packageId,$a_user_id)
306  );
307  $val_rec = $ilDB->fetchAssoc($val_set);
308  if ($auto_last_visited) {
309  $status['last_visited'] = $val_rec["last_visited"];
310  }
311  if ($val_rec["total_time_sec"]==null) {
312  if ($val_rec["sco_total_time_sec"]==null) {
313  //fall back for old ILIAS-Versions
314  if ($scormType == "2004") {
315  include_once './Modules/Scorm2004/classes/class.ilSCORM2004Tracking.php';
316  $status['total_time_sec'] = (int) ilSCORM2004Tracking::getSumTotalTimeSecondsFromScos($a_packageId, $a_user_id, true);
317  }
318  } else {
319  $status['total_time_sec'] = (int) $val_rec["sco_total_time_sec"];
320  }
321  } else {
322  $status['total_time_sec'] = (int) $val_rec["total_time_sec"];
323  }
324 
325 
326 
327  return $status;
328  }
static setHash($a_packageId, $a_user_id)
Create styles array
The data for the language used.
global $ilDB
static getSumTotalTimeSecondsFromScos($a_obj_id, $a_user_id, $a_write=false)
should be avoided; store value to increase performance for further requests
static getInstance($a_obj_id)
static _lookupStatus($a_obj_id, $a_user_id, $a_create=true)
Lookup status.
+ 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 330 of file class.ilObjSCORMInitData.php.

References $ilDB, $res, array, and date.

Referenced by getStatus().

331  {
332  global $ilDB;
333  $hash = mt_rand(1000000000, 2147483647);
334  $endDate = date('Y-m-d H:i:s', mktime(date('H'), date('i'), date('s'), date('m'), date('d')+1, date('Y')));
335 
336  $res = $ilDB->queryF(
337  'SELECT count(*) cnt FROM sahs_user WHERE obj_id = %s AND user_id = %s',
338  array('integer', 'integer'),
339  array($a_packageId,$a_user_id)
340  );
341  $val_rec = $ilDB->fetchAssoc($res);
342  if ($val_rec["cnt"] == 0) { //offline_mode could be inserted
343  $ilDB->manipulateF(
344  'INSERT INTO sahs_user (obj_id, user_id, hash, hash_end) VALUES(%s, %s, %s, %s)',
345  array('integer', 'integer', 'text', 'timestamp'),
346  array($a_packageId, $a_user_id, "" . $hash, $endDate)
347  );
348  } else {
349  $ilDB->manipulateF(
350  'UPDATE sahs_user SET hash = %s, hash_end = %s WHERE obj_id = %s AND user_id = %s',
351  array('text', 'timestamp', 'integer', 'integer'),
352  array("" . $hash, $endDate, $a_packageId, $a_user_id)
353  );
354  }
355  //clean table
356  // if (fmod($hash,100) == 0) //note: do not use % for large numbers; here php-min-Version: 4.2.0
357  // {
358  // $endDate = date('Y-m-d H:i:s', mktime(date('H'), date('i'), date('s'), date('m'), date('d')-2, date('Y')));
359  // $ilDB->manipulateF('DELETE FROM cmi_custom WHERE lvalue = %s AND c_timestamp < %s',
360  // array('text', 'timestamp'),
361  // array('hash', $endDate)
362  // );
363  // }
364  return $hash;
365  }
foreach($_POST as $key=> $value) $res
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

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