ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 18 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 309 of file class.ilObjSCORMInitData.php.

310 {
311 //erased in 5.1
312 return 0;
313 }

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

+ Here is the caller graph for this function:

◆ getIliasScormData()

static ilObjSCORMInitData::getIliasScormData (   $a_packageId)
static

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

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

References $ilDB, and $ilUser.

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

+ Here is the caller graph for this function:

◆ getIliasScormResources()

static ilObjSCORMInitData::getIliasScormResources (   $a_packageId)
static

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

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

References $ilDB.

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

+ Here is the caller graph for this function:

◆ getIliasScormTree()

static ilObjSCORMInitData::getIliasScormTree (   $a_packageId)
static

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

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

References $ilDB.

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

+ Here is the caller graph for this function:

◆ getIliasScormVars()

static ilObjSCORMInitData::getIliasScormVars (   $slm_obj)
static

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

23 {
24 global $ilias, $ilLog, $ilUser, $lng, $ilDB, $ilSetting;
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 require_once('./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
46 $session_timeout = (int)ilWACSignedPath::getCookieMaxLifetimeInSeconds();
47 $max_idle = (int)ilSession::getIdleValue();
48 if ($session_timeout > $max_idle) $session_timeout = $max_idle;
49 $min_idle = (int)$ilSetting->get('session_min_idle', ilSessionControl::DEFAULT_MIN_IDLE) * 60;
50 if ($session_timeout > $min_idle) $session_timeout = $min_idle;
51 $session_timeout -= 10; //buffer
52 }
53 $b_autoReview='false';
54 if ($slm_obj->getAutoReview()) $b_autoReview='true';
55 $b_debug='false';
56 if ($slm_obj->getDebug()) $b_debug='true';
57 $b_autoContinue='false';
58 if ($slm_obj->getAutoContinue()) $b_autoContinue='true';
59 $b_checkSetValues='false';
60 if ($slm_obj->getCheck_values()) $b_checkSetValues='true';
61 $b_autoLastVisited='false';
62 if ($slm_obj->getAuto_last_visited()) {
63 $b_autoLastVisited='true';
64 if ($launchId == '0') $launchId=$slm_obj->getLastVisited($ilUser->getID());
65 }
66
67 $b_sessionDeactivated='false';
68 if ($slm_obj->getSessionDeactivated()) $b_sessionDeactivated='true';
69
70 //manifestData //extra to IliasScormManifestData
71 // $s_man = "";
72 $a_man = array();
73 $val_set = $ilDB->queryF('
74 SELECT sc_item.obj_id,prereq_type,prerequisites,maxtimeallowed,timelimitaction,datafromlms,masteryscore
75 FROM sc_item, scorm_object
76 WHERE scorm_object.obj_id=sc_item.obj_id
77 AND scorm_object.c_type = %s
78 AND scorm_object.slm_id = %s',
79 array('text','integer'),
80 array('sit',$slm_obj->getId())
81 );
82 while($val_rec = $ilDB->fetchAssoc($val_set)) {
83 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) {
84 $tmp_man=array((int)$val_rec["obj_id"],null,null,null,null,null,null);
85 if($val_rec["prereq_type"]!=null) $tmp_man[1]=self::encodeURIComponent($val_rec["prereq_type"]);
86 if($val_rec["prerequisites"]!=null) $tmp_man[2]=self::encodeURIComponent($val_rec["prerequisites"]);
87 if($val_rec["maxtimeallowed"]!=null) $tmp_man[3]=self::encodeURIComponent($val_rec["maxtimeallowed"]);
88 if($val_rec["timelimitaction"]!=null) $tmp_man[4]=self::encodeURIComponent($val_rec["timelimitaction"]);
89 if($val_rec["datafromlms"]!=null) $tmp_man[5]=self::encodeURIComponent($val_rec["datafromlms"]);
90 if($val_rec["masteryscore"]!=null) $tmp_man[6]=self::encodeURIComponent($val_rec["masteryscore"]);
91 $a_man[]=$tmp_man;
92 }
93 }
94
95 $s_out='{'
96 .'"refId":'.$_GET["ref_id"].','
97 .'"objId":'.$slm_obj->getId().','
98 .'"clientId":"'.CLIENT_ID.'",'
99 .'"launchId":'.$launchId.','
100 .'"launchNr":0,'
101 .'"pingSession":'. $session_timeout.','
102 .'"studentId":'.$ilias->account->getId().','
103 .'"studentName":"'.self::encodeURIComponent($ilias->account->getLastname().', '.$ilias->account->getFirstname()).'",'
104 .'"studentLogin":"'.self::encodeURIComponent($ilias->account->getLogin()).'",'
105 .'"studentOu":"'.self::encodeURIComponent($ilias->account->getDepartment()).'",'
106 .'"credit":"'.str_replace("_", "-", $slm_obj->getCreditMode()).'",'
107 .'"lesson_mode":"'.$slm_obj->getDefaultLessonMode().'",'
108 .'"b_autoReview":'.$b_autoReview.','
109 .'"b_messageLog":'.$b_messageLog.','
110 .'"b_checkSetValues":'.$b_checkSetValues.','
111 .'"b_storeObjectives":'.$b_storeObjectives.','
112 .'"b_storeInteractions":'.$b_storeInteractions.','
113 .'"b_readInteractions":'.$b_readInteractions.','
114 .'"c_storeSessionTime":"'.$c_storeSessionTime.'",'
115 .'"b_autoContinue":'.$b_autoContinue.','
116 .'"b_autoLastVisited":'.$b_autoLastVisited.','
117 .'"b_sessionDeactivated":'.$b_sessionDeactivated.','
118 .'"i_lessonScoreMax":'.$i_lessonScoreMax.','
119 .'"i_lessonMasteryScore":"'.$i_lessonMasteryScore.'",'
120 .'"b_debug":'.$b_debug.','
121 .'"a_itemParameter":'.json_encode($a_man).','
122 .'"status":'.json_encode(self::getStatus($slm_obj->getId(), $ilUser->getID(), $slm_obj->getAuto_last_visited())).','
123 .'"dataDirectory":"'.self::encodeURIComponent($slm_obj->getDataDirectory("output").'/').'",'
124 .'"img":{'
125 .'"asset":"'.self::encodeURIComponent(ilUtil::getImagePath('scorm/asset.svg')).'",'
126 .'"browsed":"'.self::encodeURIComponent(ilUtil::getImagePath('scorm/browsed.svg')).'",'
127 .'"completed":"'.self::encodeURIComponent(ilUtil::getImagePath('scorm/completed.svg')).'",'
128 .'"failed":"'.self::encodeURIComponent(ilUtil::getImagePath('scorm/failed.svg')).'",'
129 .'"incomplete":"'.self::encodeURIComponent(ilUtil::getImagePath('scorm/incomplete.svg')).'",'
130 .'"not_attempted":"'.self::encodeURIComponent(ilUtil::getImagePath('scorm/not_attempted.svg')).'",'
131 .'"passed":"'.self::encodeURIComponent(ilUtil::getImagePath('scorm/passed.svg')).'",'
132 .'"running":"'.self::encodeURIComponent(ilUtil::getImagePath('scorm/running.svg')).'"'
133 .'},'
134 .'"statusTxt":{'
135 .'"wait":"'.self::encodeURIComponent($lng->txt("please_wait")).'",'
136 .'"status":"'.self::encodeURIComponent($lng->txt("cont_status")).'",'
137 .'"browsed":"'.self::encodeURIComponent($lng->txt("cont_sc_stat_browsed")).'",'
138 .'"completed":"'.self::encodeURIComponent($lng->txt("cont_sc_stat_completed")).'",'
139 .'"failed":"'.self::encodeURIComponent($lng->txt("cont_sc_stat_failed")).'",'
140 .'"incomplete":"'.self::encodeURIComponent($lng->txt("cont_sc_stat_incomplete")).'",'
141 .'"not_attempted":"'.self::encodeURIComponent($lng->txt("cont_sc_stat_not_attempted")).'",'
142 .'"passed":"'.self::encodeURIComponent($lng->txt("cont_sc_stat_passed")).'",'
143 .'"running":"'.self::encodeURIComponent($lng->txt("cont_sc_stat_running")).'"'
144 .'}'
145 .'}';
146 return $s_out;
147 }
$_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 $lng
Definition: privfeed.php:17
global $ilSetting
Definition: privfeed.php:17

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

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

+ 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 227 of file class.ilObjSCORMInitData.php.

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

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

References $ilDB, $res, and date.

Referenced by getStatus().

+ Here is the caller graph for this function:

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