19 $revert = array(
'%21'=>
'!',
'%2A'=>
'*',
'%27'=>
"'",
'%28'=>
'(',
'%29'=>
')',
'%7E'=>
'~');
20 return strtr(rawurlencode($str), $revert);
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';
34 if ($slm_obj->getTime_from_lms()) $c_storeSessionTime=
'i';
35 $i_lessonScoreMax=
'-1';
36 $i_lessonMasteryScore=$slm_obj->getMasteryScore();
39 $b_messageLog=
'false';
40 if ($ilLog->current_log_level == 30) $b_messageLog=
'true';
42 if (
$_GET[
"autolaunch"] !=
"") $launchId=
$_GET[
"autolaunch"];
44 if ($slm_obj->getSession()) {
46 require_once(
'./Services/WebAccessChecker/classes/class.ilWACSignedPath.php');
49 $b_autoReview=
'false';
50 if ($slm_obj->getAutoReview()) $b_autoReview=
'true';
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());
63 $b_sessionDeactivated=
'false';
64 if ($slm_obj->getSessionDeactivated()) $b_sessionDeactivated=
'true';
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())
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"]);
92 .
'"refId":'.
$_GET[
"ref_id"].
',' 93 .
'"objId":'.$slm_obj->getId().
',' 94 .
'"clientId":"'.CLIENT_ID.
'",' 95 .
'"launchId":'.$launchId.
',' 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").
'/').
'",' 126 .
'"not_attempted":"'.self::encodeURIComponent(
ilUtil::getImagePath(
'scorm/not_attempted.svg')).
'",' 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")).
'"' 147 $b_readInteractions=
'false';
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)
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"]) );
161 return json_encode($a_out);
165 global $ilias,
$ilDB;
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",
177 while($val_rec = $ilDB->fetchAssoc($val_set)) {
178 $s_resourceIds .=
",".$val_rec[
"obj_id"];
180 $s_resourceIds = substr($s_resourceIds,1);
182 $tquery=
"SELECT scorm_tree.lft, scorm_tree.child, 183 CASE WHEN sc_resource.scormtype = 'asset' THEN 1 ELSE 0 END AS asset, 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,
195 while($val_rec = $ilDB->fetchAssoc($val_set)) {
197 $a_out[]=array( (
int)$val_rec[
"lft"], (
int)$val_rec[
"child"], (
int)$val_rec[
"asset"], self::encodeURIComponent($val_rec[
"href"]) );
201 return json_encode($a_out);
205 global $ilias,
$ilDB;
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,
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"]);
220 return json_encode($a_out);
223 function getStatus($a_packageId,$a_user_id,$auto_last_visited,$scormType=
"1.2") {
225 include_once
'./Services/Tracking/classes/class.ilLPStatus.php';
227 $status[
'saved_global_status']=(int) $oldStatus;
228 include_once
'./Services/Object/classes/class.ilObjectLP.php';
230 $status[
'lp_mode'] = $olp->getCurrentMode();
231 $collection = $olp->getCollectionInstance();
234 $status[
'scos'] = $collection->getItems();
236 else $status[
'scos'] = array();
238 $status[
'p'] = $a_user_id;
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) {
251 if ($scormType ==
"2004") {
252 include_once
'./Modules/Scorm2004/classes/class.ilSCORM2004Tracking.php';
256 $status[
'total_time_sec'] = (int) $val_rec[
"sco_total_time_sec"];
259 $status[
'total_time_sec'] = (int) $val_rec[
"total_time_sec"];
267 private function setHash($a_packageId,$a_user_id) {
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')));
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)
276 $val_rec = $ilDB->fetchAssoc(
$res);
277 if ($val_rec[
"cnt"] == 0) {
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)
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)
getStatus($a_packageId, $a_user_id, $auto_last_visited, $scormType="1.2")
getIliasScormData($a_packageId)
static getCookieMaxLifetimeInSeconds()
getIliasScormVars($slm_obj)
setHash($a_packageId, $a_user_id)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
getIliasScormResources($a_packageId)
get_max_attempts($a_packageId)
Get max.
getSumTotalTimeSecondsFromScos($a_obj_id, $a_user_id, $a_write=false)
should be avoided; store value to increase performance for further requests
getIliasScormTree($a_packageId)
static getInstance($a_obj_id)
Class ilObjSCORMInitData.
static _lookupStatus($a_obj_id, $a_user_id, $a_create=true)
Lookup status.