ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 }

Referenced by getIliasScormVars().

+ Here is the caller graph for this function:

◆ get_max_attempts()

ilObjSCORMInitData::get_max_attempts (   $a_packageId)

Get max.

number of attempts allowed for this package

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

296 {
297 global $ilDB;
298
299 $res = $ilDB->queryF(
300 'SELECT max_attempt FROM sahs_lm WHERE id = %s',
301 array('integer'),
302 array($a_packageId)
303 );
304 $row = $ilDB->fetchAssoc($res);
305
306 return $row['max_attempt'];
307 }
global $ilDB

References $ilDB, $res, and $row.

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

+ Here is the caller graph for this function:

◆ getIliasScormData()

ilObjSCORMInitData::getIliasScormData (   $a_packageId)

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

138 {
139 global $ilias, $ilUser, $ilDB;
140 $b_readInteractions='false';
141 $a_out=array();
142 $tquery = 'SELECT sco_id,lvalue,rvalue FROM scorm_tracking '
143 .'WHERE user_id = %s AND obj_id = %s '
144 ."AND sco_id > 0 AND lvalue != 'cmi.core.entry' AND lvalue != 'cmi.core.session_time'";
145 if ($b_readInteractions == 'false') $tquery.=" AND SUBSTR(lvalue, 1, 16) != 'cmi.interactions'";
146 $val_set = $ilDB->queryF($tquery,
147 array('integer','integer'),
148 array($ilUser->getId(),$a_packageId)
149 );
150 while($val_rec = $ilDB->fetchAssoc($val_set)) {
151 if (!strpos($val_rec["lvalue"],"._count"))
152 $a_out[]=array( (int)$val_rec["sco_id"], $val_rec["lvalue"], self::encodeURIComponent($val_rec["rvalue"]) );
153 }
154 return json_encode($a_out);
155 }
global $ilUser
Definition: imgupload.php:15

References $ilDB, and $ilUser.

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

+ Here is the caller graph for this function:

◆ getIliasScormResources()

ilObjSCORMInitData::getIliasScormResources (   $a_packageId)

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

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

References $ilDB.

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

+ Here is the caller graph for this function:

◆ getIliasScormTree()

ilObjSCORMInitData::getIliasScormTree (   $a_packageId)

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

197 {
198 global $ilias, $ilDB;
199 $a_out=array();
200 $tquery="SELECT scorm_tree.child, scorm_tree.depth-3 depth, scorm_object.title, scorm_object.c_type
201 FROM scorm_tree, scorm_object
202 WHERE scorm_object.obj_id=scorm_tree.child
203 AND scorm_tree.slm_id=%s
204 AND (scorm_object.c_type='sor' OR scorm_object.c_type='sit')
205 ORDER BY scorm_tree.lft";
206 $val_set = $ilDB->queryF($tquery,
207 array('integer'),
208 array($a_packageId)
209 );
210 while($val_rec = $ilDB->fetchAssoc($val_set)) {
211 $a_out[]=array((int)$val_rec["child"],(int)$val_rec["depth"],self::encodeURIComponent($val_rec["title"]),$val_rec["c_type"]);
212 }
213 return json_encode($a_out);
214 }

References $ilDB.

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

+ Here is the caller graph for this function:

◆ getIliasScormVars()

ilObjSCORMInitData::getIliasScormVars (   $slm_obj)

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

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

References $_GET, $ilDB, $ilLog, $ilUser, $lng, encodeURIComponent(), 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()

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

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

216 {
217 global $ilDB;
218 include_once './Services/Tracking/classes/class.ilLPStatus.php';
219 $oldStatus = ilLPStatus::_lookupStatus($a_packageId, $a_user_id);
220 $status['saved_global_status']=(int) $oldStatus;
221 include_once './Services/Object/classes/class.ilObjectLP.php';
222 $olp = ilObjectLP::getInstance($a_packageId);
223 $status['lp_mode'] = $olp->getCurrentMode();
224 $collection = $olp->getCollectionInstance();
225 if($collection)
226 {
227 $status['scos'] = $collection->getItems();
228 }
229 else $status['scos'] = array();
230 $status['hash'] = ilObjSCORMInitData::setHash($a_packageId,$a_user_id);
231 $status['p'] = $a_user_id;
232
233 $status['last_visited'] = null;
234 $status['total_time_sec'] = 0;
235 $val_set = $ilDB->queryF(
236 'SELECT last_visited, sco_total_time_sec, total_time_sec FROM sahs_user WHERE obj_id = %s AND user_id = %s',
237 array('integer','integer'),
238 array($a_packageId,$a_user_id));
239 $val_rec = $ilDB->fetchAssoc($val_set);
240 if($auto_last_visited) $status['last_visited'] = $val_rec["last_visited"];
241 if ($val_rec["total_time_sec"]==null) {
242 if ($val_rec["sco_total_time_sec"]==null) {
243 //fall back for old ILIAS-Versions
244 if ($scormType == "2004") {
245 include_once './Modules/Scorm2004/classes/class.ilSCORM2004Tracking.php';
246 $status['total_time_sec'] = (int) ilSCORM2004Tracking::getSumTotalTimeSecondsFromScos($a_packageId, $a_user_id, true);
247 }
248 } else {
249 $status['total_time_sec'] = (int) $val_rec["sco_total_time_sec"];
250 }
251 } else {
252 $status['total_time_sec'] = (int) $val_rec["total_time_sec"];
253 }
254 return $status;
255 }
static _lookupStatus($a_obj_id, $a_user_id, $a_create=true)
Lookup status.
setHash($a_packageId, $a_user_id)
static getInstance($a_obj_id)
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()

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

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

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

References $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: