ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilObjSCORMInitData Class Reference

Class ilObjSCORMInitData. More...

+ Collaboration diagram for ilObjSCORMInitData:

Public Member Functions

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

Private Member Functions

 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()

ilObjSCORMInitData::encodeURIComponent (   $str)

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

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

◆ get_max_attempts()

ilObjSCORMInitData::get_max_attempts (   $a_packageId)

Get max.

number of attempts allowed for this package

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

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

306  {
307  //erased in 5.1
308  return 0;
309  }
+ Here is the caller graph for this function:

◆ getIliasScormData()

ilObjSCORMInitData::getIliasScormData (   $a_packageId)

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

References $ilDB, and $ilUser.

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

145  {
146  global $ilias, $ilUser, $ilDB;
147  $b_readInteractions='false';
148  $a_out=array();
149  $tquery = 'SELECT sco_id,lvalue,rvalue FROM scorm_tracking '
150  .'WHERE user_id = %s AND obj_id = %s '
151  ."AND sco_id > 0 AND lvalue != 'cmi.core.entry' AND lvalue != 'cmi.core.session_time'";
152  if ($b_readInteractions == 'false') $tquery.=" AND SUBSTR(lvalue, 1, 16) != 'cmi.interactions'";
153  $val_set = $ilDB->queryF($tquery,
154  array('integer','integer'),
155  array($ilUser->getId(),$a_packageId)
156  );
157  while($val_rec = $ilDB->fetchAssoc($val_set)) {
158  if (!strpos($val_rec["lvalue"],"._count"))
159  $a_out[]=array( (int)$val_rec["sco_id"], $val_rec["lvalue"], self::encodeURIComponent($val_rec["rvalue"]) );
160  }
161  return json_encode($a_out);
162  }
global $ilUser
Definition: imgupload.php:15
global $ilDB
+ Here is the caller graph for this function:

◆ getIliasScormResources()

ilObjSCORMInitData::getIliasScormResources (   $a_packageId)

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

References $ilDB.

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

164  {
165  global $ilias, $ilDB;
166 // $s_out="";
167  $a_out=array();
168  $s_resourceIds="";//necessary if resources exist having different href with same identifier
169  $val_set = $ilDB->queryF("
170  SELECT sc_resource.obj_id
171  FROM scorm_tree, sc_resource
172  WHERE scorm_tree.slm_id=%s
173  AND sc_resource.obj_id=scorm_tree.child",
174  array('integer'),
175  array($a_packageId)
176  );
177  while($val_rec = $ilDB->fetchAssoc($val_set)) {
178  $s_resourceIds .= ",".$val_rec["obj_id"];
179  }
180  $s_resourceIds = substr($s_resourceIds,1);
181 
182  $tquery="SELECT scorm_tree.lft, scorm_tree.child,
183  CASE WHEN sc_resource.scormtype = 'asset' THEN 1 ELSE 0 END AS asset,
184  sc_resource.href
185  FROM scorm_tree, sc_resource, sc_item
186  WHERE scorm_tree.slm_id=%s
187  AND sc_item.obj_id=scorm_tree.child
188  AND sc_resource.import_id=sc_item.identifierref
189  AND sc_resource.obj_id in (".$s_resourceIds.")
190  ORDER BY scorm_tree.lft";
191  $val_set = $ilDB->queryF($tquery,
192  array('integer'),
193  array($a_packageId)
194  );
195  while($val_rec = $ilDB->fetchAssoc($val_set)) {
196 // $s_out.='['.$val_rec["lft"].','.$val_rec["child"].','.$val_rec["asset"].',"'.self::encodeURIComponent($val_rec["href"]).'"],';
197  $a_out[]=array( (int)$val_rec["lft"], (int)$val_rec["child"], (int)$val_rec["asset"], self::encodeURIComponent($val_rec["href"]) );
198  }
199 // if(substr($s_out,(strlen($s_out)-1))==",") $s_out=substr($s_out,0,(strlen($s_out)-1));
200 // return "[".$s_out."]";
201  return json_encode($a_out);
202  }
global $ilDB
+ Here is the caller graph for this function:

◆ getIliasScormTree()

ilObjSCORMInitData::getIliasScormTree (   $a_packageId)

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

References $ilDB.

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

204  {
205  global $ilias, $ilDB;
206  $a_out=array();
207  $tquery="SELECT scorm_tree.child, scorm_tree.depth-3 depth, scorm_object.title, scorm_object.c_type
208  FROM scorm_tree, scorm_object
209  WHERE scorm_object.obj_id=scorm_tree.child
210  AND scorm_tree.slm_id=%s
211  AND (scorm_object.c_type='sor' OR scorm_object.c_type='sit')
212  ORDER BY scorm_tree.lft";
213  $val_set = $ilDB->queryF($tquery,
214  array('integer'),
215  array($a_packageId)
216  );
217  while($val_rec = $ilDB->fetchAssoc($val_set)) {
218  $a_out[]=array((int)$val_rec["child"],(int)$val_rec["depth"],self::encodeURIComponent($val_rec["title"]),$val_rec["c_type"]);
219  }
220  return json_encode($a_out);
221  }
global $ilDB
+ Here is the caller graph for this function:

◆ getIliasScormVars()

ilObjSCORMInitData::getIliasScormVars (   $slm_obj)

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

References $_GET, $ilDB, $ilLog, $ilUser, $lng, ilWACSignedPath\getCookieMaxLifetimeInSeconds(), and ilUtil\getImagePath().

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

23  {
24  global $ilias, $ilLog, $ilUser, $lng, $ilDB;
25 // $slm_obj =& new ilObjSCORMLearningModule($_GET["ref_id"]);
26 
27  //variables to set in administration interface
28  $b_storeObjectives='false';
29  if ($slm_obj->getObjectives()) $b_storeObjectives='true';
30  $b_storeInteractions='false';
31  if ($slm_obj->getInteractions()) $b_storeInteractions='true';
32  $b_readInteractions='false';
33  $c_storeSessionTime='s';//n=no, s=sco, i=ilias
34  if ($slm_obj->getTime_from_lms()) $c_storeSessionTime='i';
35  $i_lessonScoreMax='-1';
36  $i_lessonMasteryScore=$slm_obj->getMasteryScore();
37 
38  //other variables
39  $b_messageLog='false';
40  if ($ilLog->current_log_level == 30) $b_messageLog='true';
41  $launchId='0';
42  if ($_GET["autolaunch"] != "") $launchId=$_GET["autolaunch"];
43  $session_timeout = 0; //unlimited sessions
44  if ($slm_obj->getSession()) {
45  // $session_timeout = (int)($ilias->ini->readVariable("session","expire"))/2;
46  require_once('./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
47  $session_timeout = (int)ilWACSignedPath::getCookieMaxLifetimeInSeconds()-1;
48  }
49  $b_autoReview='false';
50  if ($slm_obj->getAutoReview()) $b_autoReview='true';
51  $b_debug='false';
52  if ($slm_obj->getDebug()) $b_debug='true';
53  $b_autoContinue='false';
54  if ($slm_obj->getAutoContinue()) $b_autoContinue='true';
55  $b_checkSetValues='false';
56  if ($slm_obj->getCheck_values()) $b_checkSetValues='true';
57  $b_autoLastVisited='false';
58  if ($slm_obj->getAuto_last_visited()) {
59  $b_autoLastVisited='true';
60  if ($launchId == '0') $launchId=$slm_obj->getLastVisited($ilUser->getID());
61  }
62 
63  $b_sessionDeactivated='false';
64  if ($slm_obj->getSessionDeactivated()) $b_sessionDeactivated='true';
65 
66  //manifestData //extra to IliasScormManifestData
67  // $s_man = "";
68  $a_man = array();
69  $val_set = $ilDB->queryF('
70  SELECT sc_item.obj_id,prereq_type,prerequisites,maxtimeallowed,timelimitaction,datafromlms,masteryscore
71  FROM sc_item, scorm_object
72  WHERE scorm_object.obj_id=sc_item.obj_id
73  AND scorm_object.c_type = %s
74  AND scorm_object.slm_id = %s',
75  array('text','integer'),
76  array('sit',$slm_obj->getId())
77  );
78  while($val_rec = $ilDB->fetchAssoc($val_set)) {
79  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) {
80  $tmp_man=array((int)$val_rec["obj_id"],null,null,null,null,null,null);
81  if($val_rec["prereq_type"]!=null) $tmp_man[1]=self::encodeURIComponent($val_rec["prereq_type"]);
82  if($val_rec["prerequisites"]!=null) $tmp_man[2]=self::encodeURIComponent($val_rec["prerequisites"]);
83  if($val_rec["maxtimeallowed"]!=null) $tmp_man[3]=self::encodeURIComponent($val_rec["maxtimeallowed"]);
84  if($val_rec["timelimitaction"]!=null) $tmp_man[4]=self::encodeURIComponent($val_rec["timelimitaction"]);
85  if($val_rec["datafromlms"]!=null) $tmp_man[5]=self::encodeURIComponent($val_rec["datafromlms"]);
86  if($val_rec["masteryscore"]!=null) $tmp_man[6]=self::encodeURIComponent($val_rec["masteryscore"]);
87  $a_man[]=$tmp_man;
88  }
89  }
90 
91  $s_out='{'
92  .'"refId":'.$_GET["ref_id"].','
93  .'"objId":'.$slm_obj->getId().','
94  .'"clientId":"'.CLIENT_ID.'",'
95  .'"launchId":'.$launchId.','
96  .'"launchNr":0,'
97  .'"pingSession":'. $session_timeout.','
98  .'"studentId":'.$ilias->account->getId().','
99  .'"studentName":"'.self::encodeURIComponent($ilias->account->getLastname().', '.$ilias->account->getFirstname()).'",'
100  .'"studentLogin":"'.self::encodeURIComponent($ilias->account->getLogin()).'",'
101  .'"studentOu":"'.self::encodeURIComponent($ilias->account->getDepartment()).'",'
102  .'"credit":"'.str_replace("_", "-", $slm_obj->getCreditMode()).'",'
103  .'"lesson_mode":"'.$slm_obj->getDefaultLessonMode().'",'
104  .'"b_autoReview":'.$b_autoReview.','
105  .'"b_messageLog":'.$b_messageLog.','
106  .'"b_checkSetValues":'.$b_checkSetValues.','
107  .'"b_storeObjectives":'.$b_storeObjectives.','
108  .'"b_storeInteractions":'.$b_storeInteractions.','
109  .'"b_readInteractions":'.$b_readInteractions.','
110  .'"c_storeSessionTime":"'.$c_storeSessionTime.'",'
111  .'"b_autoContinue":'.$b_autoContinue.','
112  .'"b_autoLastVisited":'.$b_autoLastVisited.','
113  .'"b_sessionDeactivated":'.$b_sessionDeactivated.','
114  .'"i_lessonScoreMax":'.$i_lessonScoreMax.','
115  .'"i_lessonMasteryScore":"'.$i_lessonMasteryScore.'",'
116  .'"b_debug":'.$b_debug.','
117  .'"a_itemParameter":'.json_encode($a_man).','
118  .'"status":'.json_encode(self::getStatus($slm_obj->getId(), $ilUser->getID(), $slm_obj->getAuto_last_visited())).','
119  .'"dataDirectory":"'.self::encodeURIComponent($slm_obj->getDataDirectory("output").'/').'",'
120  .'"img":{'
121  .'"asset":"'.self::encodeURIComponent(ilUtil::getImagePath('scorm/asset.svg')).'",'
122  .'"browsed":"'.self::encodeURIComponent(ilUtil::getImagePath('scorm/browsed.svg')).'",'
123  .'"completed":"'.self::encodeURIComponent(ilUtil::getImagePath('scorm/completed.svg')).'",'
124  .'"failed":"'.self::encodeURIComponent(ilUtil::getImagePath('scorm/failed.svg')).'",'
125  .'"incomplete":"'.self::encodeURIComponent(ilUtil::getImagePath('scorm/incomplete.svg')).'",'
126  .'"not_attempted":"'.self::encodeURIComponent(ilUtil::getImagePath('scorm/not_attempted.svg')).'",'
127  .'"passed":"'.self::encodeURIComponent(ilUtil::getImagePath('scorm/passed.svg')).'",'
128  .'"running":"'.self::encodeURIComponent(ilUtil::getImagePath('scorm/running.svg')).'"'
129  .'},'
130  .'"statusTxt":{'
131  .'"wait":"'.self::encodeURIComponent($lng->txt("please_wait")).'",'
132  .'"status":"'.self::encodeURIComponent($lng->txt("cont_status")).'",'
133  .'"browsed":"'.self::encodeURIComponent($lng->txt("cont_sc_stat_browsed")).'",'
134  .'"completed":"'.self::encodeURIComponent($lng->txt("cont_sc_stat_completed")).'",'
135  .'"failed":"'.self::encodeURIComponent($lng->txt("cont_sc_stat_failed")).'",'
136  .'"incomplete":"'.self::encodeURIComponent($lng->txt("cont_sc_stat_incomplete")).'",'
137  .'"not_attempted":"'.self::encodeURIComponent($lng->txt("cont_sc_stat_not_attempted")).'",'
138  .'"passed":"'.self::encodeURIComponent($lng->txt("cont_sc_stat_passed")).'",'
139  .'"running":"'.self::encodeURIComponent($lng->txt("cont_sc_stat_running")).'"'
140  .'}'
141  .'}';
142  return $s_out;
143  }
static getCookieMaxLifetimeInSeconds()
$_GET["client_id"]
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
global $ilUser
Definition: imgupload.php:15
global $lng
Definition: privfeed.php:40
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getStatus()

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

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

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

Referenced by ilSCORM13Player\getConfigForPlayer().

223  {
224  global $ilDB;
225  include_once './Services/Tracking/classes/class.ilLPStatus.php';
226  $oldStatus = ilLPStatus::_lookupStatus($a_packageId, $a_user_id);
227  $status['saved_global_status']=(int) $oldStatus;
228  include_once './Services/Object/classes/class.ilObjectLP.php';
229  $olp = ilObjectLP::getInstance($a_packageId);
230  $status['lp_mode'] = $olp->getCurrentMode();
231  $collection = $olp->getCollectionInstance();
232  if($collection)
233  {
234  $status['scos'] = $collection->getItems();
235  }
236  else $status['scos'] = array();
237  $status['hash'] = ilObjSCORMInitData::setHash($a_packageId,$a_user_id);
238  $status['p'] = $a_user_id;
239 
240  $status['last_visited'] = null;
241  $status['total_time_sec'] = 0;
242  $val_set = $ilDB->queryF(
243  'SELECT last_visited, sco_total_time_sec, total_time_sec FROM sahs_user WHERE obj_id = %s AND user_id = %s',
244  array('integer','integer'),
245  array($a_packageId,$a_user_id));
246  $val_rec = $ilDB->fetchAssoc($val_set);
247  if($auto_last_visited) $status['last_visited'] = $val_rec["last_visited"];
248  if ($val_rec["total_time_sec"]==null) {
249  if ($val_rec["sco_total_time_sec"]==null) {
250  //fall back for old ILIAS-Versions
251  if ($scormType == "2004") {
252  include_once './Modules/Scorm2004/classes/class.ilSCORM2004Tracking.php';
253  $status['total_time_sec'] = (int) ilSCORM2004Tracking::getSumTotalTimeSecondsFromScos($a_packageId, $a_user_id, true);
254  }
255  } else {
256  $status['total_time_sec'] = (int) $val_rec["sco_total_time_sec"];
257  }
258  } else {
259  $status['total_time_sec'] = (int) $val_rec["total_time_sec"];
260  }
261 
262 
263 
264  return $status;
265  }
setHash($a_packageId, $a_user_id)
getSumTotalTimeSecondsFromScos($a_obj_id, $a_user_id, $a_write=false)
should be avoided; store value to increase performance for further requests
global $ilDB
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()

ilObjSCORMInitData::setHash (   $a_packageId,
  $a_user_id 
)
private

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

References $ilDB, and $res.

Referenced by getStatus().

267  {
268  global $ilDB;
269  $hash = mt_rand(1000000000,9999999999);
270  $endDate = date('Y-m-d H:i:s', mktime(date('H'), date('i'), date('s'), date('m'), date('d')+1, date('Y')));
271 
272  $res = $ilDB->queryF('SELECT count(*) cnt FROM sahs_user WHERE obj_id = %s AND user_id = %s',
273  array('integer', 'integer'),
274  array($a_packageId,$a_user_id)
275  );
276  $val_rec = $ilDB->fetchAssoc($res);
277  if ($val_rec["cnt"] == 0) { //offline_mode could be inserted
278  $ilDB->manipulateF('INSERT INTO sahs_user (obj_id, user_id, hash, hash_end) VALUES(%s, %s, %s, %s)',
279  array('integer', 'integer', 'text', 'timestamp'),
280  array($a_packageId, $a_user_id, "".$hash, $endDate)
281  );
282  }
283  else
284  {
285  $ilDB->manipulateF('UPDATE sahs_user SET hash = %s, hash_end = %s WHERE obj_id = %s AND user_id = %s',
286  array('text', 'timestamp', 'integer', 'integer'),
287  array("".$hash, $endDate, $a_packageId, $a_user_id)
288  );
289  }
290  //clean table
291  // if (fmod($hash,100) == 0) //note: do not use % for large numbers; here php-min-Version: 4.2.0
292  // {
293  // $endDate = date('Y-m-d H:i:s', mktime(date('H'), date('i'), date('s'), date('m'), date('d')-2, date('Y')));
294  // $ilDB->manipulateF('DELETE FROM cmi_custom WHERE lvalue = %s AND c_timestamp < %s',
295  // array('text', 'timestamp'),
296  // array('hash', $endDate)
297  // );
298  // }
299  return $hash;
300  }
global $ilDB
+ Here is the caller graph for this function:

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