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

Class ilSCORM2004Tracking. More...

+ Collaboration diagram for ilSCORM2004Tracking:

Public Member Functions

 ilObjSCORM2004Tracking ()
 Constructor @access public. More...
 
 _getInProgress ($scorm_item_id, $a_obj_id)
 
 _getCompleted ($scorm_item_id, $a_obj_id)
 
 _getFailed ($scorm_item_id, $a_obj_id)
 
 _getCountCompletedPerUser ($a_scorm_item_ids, $a_obj_id, $a_omit_failed=false)
 Get progress of selected scos. More...
 
 _getProgressInfo ($a_obj_id)
 Get overall scorm status. More...
 
 _getProgressInfoOfUser ($a_obj_id, $a_user_id)
 Get overall scorm status. More...
 
 _getTrackedUsers ($a_obj_id)
 Get all tracked users. More...
 
 _getItemProgressInfo ($a_scorm_item_ids, $a_obj_id, $a_omit_failed=false)
 
 _syncReadEvent ($a_obj_id, $a_user_id, $a_type, $a_ref_id, $time_from_lms=null)
 Synch read event table. More...
 
 getSumTotalTimeSecondsFromScos ($a_obj_id, $a_user_id, $a_write=false)
 should be avoided; store value to increase performance for further requests More...
 

Static Public Member Functions

static _getCollectionStatus ($a_scos, $a_obj_id, $a_user_id)
 
static _countCompleted ($a_scos, $a_obj_id, $a_user_id, $a_omit_failed=false)
 
static _isCompleted ($a_status, $a_satisfied)
 
static _isInProgress ($a_status, $a_satisfied)
 
static _isFailed ($a_status, $a_satisfied)
 

Detailed Description

Member Function Documentation

◆ _countCompleted()

static ilSCORM2004Tracking::_countCompleted (   $a_scos,
  $a_obj_id,
  $a_user_id,
  $a_omit_failed = false 
)
static

Definition at line 343 of file class.ilSCORM2004Tracking.php.

345 {
346 global $ilDB;
347
348 if (is_array($a_scos))
349 {
350 $in = $ilDB->in('cp_node.cp_node_id', $a_scos, false, 'integer');
351
352 $res = $ilDB->queryF(
353 'SELECT cp_node.cp_node_id id,
354 cmi_node.completion_status completion,
355 cmi_node.success_status success
356 FROM cp_node, cmi_node
357 WHERE '.$in.'
358 AND cp_node.cp_node_id = cmi_node.cp_node_id
359 AND cp_node.slm_id = %s
360 AND cmi_node.user_id = %s',
361 array('integer', 'integer'),
362 array($a_obj_id, $a_user_id)
363 );
364
365
366 $cnt = 0;
367 while ($rec = $ilDB->fetchAssoc($res))
368 {
369 // #8171: alex, added (!$a_omit_failed || $rec["success"] != "failed")
370 // since completed/failed combination should not be included in
371 // percentage calculation at ilLPStatusSCOM::determinePercentage
372 if (($rec["completion"] == "completed" || $rec["success"] == "passed")
373 && (!$a_omit_failed || $rec["success"] != "failed"))
374 {
375 $cnt++;
376 }
377 }
378
379 }
380 return $cnt;
381 }
global $ilDB

References $ilDB, $in, and $res.

Referenced by ilLPStatusSCORM\determinePercentage().

+ Here is the caller graph for this function:

◆ _getCollectionStatus()

static ilSCORM2004Tracking::_getCollectionStatus (   $a_scos,
  $a_obj_id,
  $a_user_id 
)
static

Definition at line 300 of file class.ilSCORM2004Tracking.php.

301 {
302 global $ilDB;
303
304 $status = "not_attempted";
305
306 if (is_array($a_scos))
307 {
308 $in = $ilDB->in('cp_node.cp_node_id', $a_scos, false, 'integer');
309
310 $res = $ilDB->queryF(
311 'SELECT cp_node.cp_node_id id,
312 cmi_node.completion_status completion,
313 cmi_node.success_status success
314 FROM cp_node, cmi_node
315 WHERE '.$in.'
316 AND cp_node.cp_node_id = cmi_node.cp_node_id
317 AND cp_node.slm_id = %s
318 AND cmi_node.user_id = %s',
319 array('integer', 'integer'),
320 array($a_obj_id, $a_user_id)
321 );
322
323 $started = false;
324 $cntcompleted = 0;
325 $failed = false;
326 while ($rec = $ilDB->fetchAssoc($res))
327 {
328 if ($rec["completion"] == "completed" || $rec["success"] == "passed")
329 {
330 $cntcompleted++;
331 }
332 if ($rec["success"] == "failed") $failed = true;
333 $started = true;
334 }
335 if ($started == true) $status = "in_progress";
336 if ($failed == true) $status = "failed";
337 else if ($cntcompleted == count($a_scos)) $status = "completed";
338
339 }
340 return $status;
341 }
$failed
Definition: Utf8Test.php:86

References $failed, $ilDB, $in, and $res.

Referenced by ilLPStatusSCORM\determineStatus().

+ Here is the caller graph for this function:

◆ _getCompleted()

ilSCORM2004Tracking::_getCompleted (   $scorm_item_id,
  $a_obj_id 
)

Definition at line 58 of file class.ilSCORM2004Tracking.php.

59 {
60 global $ilDB;
61
62die("Not Implemented: ilSCORM2004Tracking_getCompleted");
63/*
64 if(is_array($scorm_item_id))
65 {
66 $where = "WHERE sco_id IN(".implode(",",ilUtil::quoteArray($scorm_item_id)).") ";
67 }
68 else
69 {
70 $where = "sco_id = ".$ilDB->quote($scorm_item_id)." ";
71 }
72
73 $query = "SELECT DISTINCT(user_id) FROM scorm_tracking ".
74 $where.
75 "AND obj_id = ".$ilDB->quote($a_obj_id)." ".
76 "AND lvalue = 'cmi.core.lesson_status' ".
77 "AND ( rvalue = 'completed' ".
78 "OR rvalue = 'passed')";
79 $res = $ilDB->query($query);
80 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
81 {
82 $user_ids[] = $row->user_id;
83 }
84 return $user_ids ? $user_ids : array();
85*/
86 }

References $ilDB.

◆ _getCountCompletedPerUser()

ilSCORM2004Tracking::_getCountCompletedPerUser (   $a_scorm_item_ids,
  $a_obj_id,
  $a_omit_failed = false 
)

Get progress of selected scos.

Parameters
object$a_scorm_item_ids
object$a_obj_id
bool$a_omit_faileddo not include success==failed
Returns

Definition at line 124 of file class.ilSCORM2004Tracking.php.

125 {
126 global $ilDB;
127
128 $in = $ilDB->in('cp_node.cp_node_id', $a_scorm_item_ids, false, 'integer');
129
130 // #8171: success_status vs. completion status
131 $omit_failed = '';
132 if($a_omit_failed)
133 {
134 $omit_failed = ' AND success_status <> '.$ilDB->quote('failed', 'text');
135 }
136
137 $res = $ilDB->queryF('
138 SELECT cmi_node.user_id user_id, COUNT(user_id) completed FROM cp_node, cmi_node
139 WHERE '.$in.$omit_failed.'
140 AND cp_node.cp_node_id = cmi_node.cp_node_id
141 AND cp_node.slm_id = %s
142 AND completion_status = %s
143 GROUP BY cmi_node.user_id',
144 array('integer', 'text'),
145 array($a_obj_id, 'completed')
146 );
147 while($row = $ilDB->fetchObject($res))
148 {
149 $users[$row->user_id] = $row->completed;
150 }
151
152 return $users ? $users : array();
153 }

References $ilDB, $in, $res, and $row.

Referenced by ilLPStatusSCORM\_getStatusInfo().

+ Here is the caller graph for this function:

◆ _getFailed()

ilSCORM2004Tracking::_getFailed (   $scorm_item_id,
  $a_obj_id 
)

Definition at line 88 of file class.ilSCORM2004Tracking.php.

89 {
90 global $ilDB;
91
92die("Not Implemented: ilSCORM2004Tracking_getFailed");
93/*
94 if(is_array($scorm_item_id))
95 {
96 $where = "WHERE sco_id IN('".implode("','",$scorm_item_id)."') ";
97 }
98 else
99 {
100 $where = "sco_id = '".$scorm_item_id."' ";
101 }
102
103 $query = "SELECT DISTINCT(user_id) FROM scorm_tracking ".
104 $where.
105 "AND obj_id = '".$a_obj_id."' ".
106 "AND lvalue = 'cmi.core.lesson_status' ".
107 "AND rvalue = 'failed'";
108 $res = $ilDB->query($query);
109 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
110 {
111 $user_ids[] = $row->user_id;
112 }
113 return $user_ids ? $user_ids : array();
114*/
115 }

References $ilDB.

◆ _getInProgress()

ilSCORM2004Tracking::_getInProgress (   $scorm_item_id,
  $a_obj_id 
)

Definition at line 22 of file class.ilSCORM2004Tracking.php.

23 {
24
25die("Not Implemented: ilSCORM2004Tracking_getInProgress");
26/*
27 global $ilDB;
28
29 if(is_array($scorm_item_id))
30 {
31 $where = "WHERE sco_id IN(";
32 $where .= implode(",",ilUtil::quoteArray($scorm_item_id));
33 $where .= ") ";
34 $where .= ("AND obj_id = ".$ilDB->quote($a_obj_id)." ");
35
36 }
37 else
38 {
39 $where = "WHERE sco_id = ".$ilDB->quote($scorm_item_id)." ";
40 $where .= ("AND obj_id = ".$ilDB->quote($a_obj_id)." ");
41 }
42
43
44 $query = "SELECT user_id,sco_id FROM scorm_tracking ".
45 $where.
46 "GROUP BY user_id, sco_id";
47
48
49 $res = $ilDB->query($query);
50 while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
51 {
52 $in_progress[$row->sco_id][] = $row->user_id;
53 }
54 return is_array($in_progress) ? $in_progress : array();
55*/
56 }

◆ _getItemProgressInfo()

ilSCORM2004Tracking::_getItemProgressInfo (   $a_scorm_item_ids,
  $a_obj_id,
  $a_omit_failed = false 
)

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

258 {
259 global $ilDB;
260
261 $in = $ilDB->in('cp_node.cp_node_id', $a_scorm_item_ids, false, 'integer');
262
263 $res = $ilDB->queryF(
264 'SELECT cp_node.cp_node_id id,
265 cmi_node.user_id user_id,
266 cmi_node.completion_status completion,
267 cmi_node.success_status success
268 FROM cp_node, cmi_node
269 WHERE '.$in.'
270 AND cp_node.cp_node_id = cmi_node.cp_node_id
271 AND cp_node.slm_id = %s',
272 array('integer'),
273 array($a_obj_id)
274 );
275
276 $info['completed'] = array();
277 $info['failed'] = array();
278 $info['in_progress'] = array();
279
280 while($row = $ilDB->fetchAssoc($res))
281 {
282 // if any data available, set in progress.
283 $info['in_progress'][$row["id"]][] = $row["user_id"];
284 if ($row["completion"] == "completed" || $row["success"] == "passed")
285 {
286 // #8171: success_status vs. completion status
287 if(!$a_omit_failed || $row["success"] != "failed")
288 {
289 $info['completed'][$row["id"]][] = $row["user_id"];
290 }
291 }
292 if ($row["success"] == "failed")
293 {
294 $info['failed'][$row["id"]][] = $row["user_id"];
295 }
296 }
297 return $info;
298 }
$info
Definition: example_052.php:80

References $ilDB, $in, $info, $res, and $row.

Referenced by ilLPStatusSCORM\_getStatusInfo().

+ Here is the caller graph for this function:

◆ _getProgressInfo()

ilSCORM2004Tracking::_getProgressInfo (   $a_obj_id)

Get overall scorm status.

Parameters
object$a_obj_id
Returns

Definition at line 161 of file class.ilSCORM2004Tracking.php.

162 {
163 global $ilDB;
164
165 $res = $ilDB->queryF('
166 SELECT user_id, status, satisfied FROM cmi_gobjective
167 WHERE objective_id = %s
168 AND scope_id = %s',
169 array('text', 'integer'),
170 array('-course_overall_status-', $a_obj_id)
171 );
172
173 $info['completed'] = array();
174 $info['failed'] = array();
175 $info['in_progress'] = array();
176
177 while($row = $ilDB->fetchAssoc($res))
178 {
179 if (self::_isCompleted($row["status"], $row["satisfied"]))
180 {
181 $info['completed'][] = $row["user_id"];
182 }
183 if (self::_isInProgress($row["status"], $row["satisfied"]))
184 {
185 $info['in_progress'][] = $row["user_id"];
186 }
187 if (self::_isFailed($row["status"], $row["satisfied"]))
188 {
189 $info['failed'][] = $row["user_id"];
190 }
191 }
192
193 return $info;
194 }

References $ilDB, $info, $res, and $row.

Referenced by ilLPStatusSCORMPackage\_getStatusInfo().

+ Here is the caller graph for this function:

◆ _getProgressInfoOfUser()

ilSCORM2004Tracking::_getProgressInfoOfUser (   $a_obj_id,
  $a_user_id 
)

Get overall scorm status.

Parameters
object$a_obj_id
Returns

Definition at line 201 of file class.ilSCORM2004Tracking.php.

202 {
203 global $ilDB, $ilLog;
204
205 $res = $ilDB->queryF('
206 SELECT status, satisfied FROM cmi_gobjective
207 WHERE objective_id = %s
208 AND scope_id = %s AND user_id = %s',
209 array('text', 'integer', 'integer'),
210 array('-course_overall_status-', $a_obj_id, $a_user_id)
211 );
212
213 $status = "not_attempted";
214 if ($row = $ilDB->fetchAssoc($res))
215 {
216 if (self::_isInProgress($row["status"], $row["satisfied"]))
217 {
218 $status = "in_progress";
219 }
220 if (self::_isCompleted($row["status"], $row["satisfied"]))
221 {
222 $status = "completed";
223 }
224 if (self::_isFailed($row["status"], $row["satisfied"]))
225 {
226 $status = "failed";
227 }
228 }
229 return $status;
230 }

References $ilDB, $ilLog, $res, and $row.

Referenced by ilLPStatusSCORMPackage\determineStatus().

+ Here is the caller graph for this function:

◆ _getTrackedUsers()

ilSCORM2004Tracking::_getTrackedUsers (   $a_obj_id)

Get all tracked users.

Parameters
object$a_obj_id
Returns

Definition at line 237 of file class.ilSCORM2004Tracking.php.

238 {
239 global $ilDB, $ilLog;
240
241 $res = $ilDB->queryF('
242 SELECT DISTINCT user_id FROM cmi_gobjective
243 WHERE objective_id = %s
244 AND scope_id = %s',
245 array('text', 'integer'),
246 array('-course_overall_status-', $a_obj_id)
247 );
248
249 $users = array();
250 while ($row = $ilDB->fetchAssoc($res))
251 {
252 $users[] = $row["user_id"];
253 }
254 return $users;
255 }

References $ilDB, $ilLog, $res, and $row.

Referenced by ilLPStatusSCORM\refreshStatus(), and ilLPStatusSCORMPackage\refreshStatus().

+ Here is the caller graph for this function:

◆ _isCompleted()

static ilSCORM2004Tracking::_isCompleted (   $a_status,
  $a_satisfied 
)
static

Definition at line 423 of file class.ilSCORM2004Tracking.php.

424 {
425 if ($a_status == "completed" || $a_satisfied == "satisfied")
426 {
427 return true;
428 }
429
430 return false;
431 }

◆ _isFailed()

static ilSCORM2004Tracking::_isFailed (   $a_status,
  $a_satisfied 
)
static

Definition at line 449 of file class.ilSCORM2004Tracking.php.

450 {
451 if ($a_status == "completed" && $a_satisfied == "notSatisfied")
452 {
453 return true;
454 }
455
456 return false;
457 }

◆ _isInProgress()

static ilSCORM2004Tracking::_isInProgress (   $a_status,
  $a_satisfied 
)
static

Definition at line 436 of file class.ilSCORM2004Tracking.php.

437 {
438 if ($a_status != "completed")
439 {
440 return true;
441 }
442
443 return false;
444 }

◆ _syncReadEvent()

ilSCORM2004Tracking::_syncReadEvent (   $a_obj_id,
  $a_user_id,
  $a_type,
  $a_ref_id,
  $time_from_lms = null 
)

Synch read event table.

Parameters

return

Definition at line 389 of file class.ilSCORM2004Tracking.php.

390 {
391 global $ilDB;
392
393 //get condition to select time
394 $val_set = $ilDB->queryF(
395 'SELECT time_from_lms FROM sahs_lm WHERE id = %s',
396 array('integer'),array($a_obj_id));
397 $val_rec = $ilDB->fetchAssoc($val_set);
398 $time_from_lms=(ilUtil::yn2tf($val_rec["time_from_lms"]));
399
400 // get attempts and time
401 $val_set = $ilDB->queryF('
402 SELECT package_attempts, sco_total_time_sec, total_time_sec
403 FROM sahs_user WHERE obj_id = %s AND user_id = %s',
404 array('integer','integer'), array($a_obj_id,$a_user_id));
405 $val_rec = $ilDB->fetchAssoc($val_set);
406 if ($time_from_lms == false) $time = $val_rec["sco_total_time_sec"];
407 else $time = $val_rec["total_time_sec"];
408 $attempts = $val_rec["package_attempts"];
409 if ($attempts == null) $attempts = ""; //??
410
411 if ($attempts != "" && $time == null) { //use old way
412 $time = self::getSumTotalTimeSecondsFromScos($a_obj_id, $a_user_id,true);
413 }
414
415 include_once("./Services/Tracking/classes/class.ilChangeEvent.php");
416 ilChangeEvent::_recordReadEvent($a_type, $a_ref_id,
417 $a_obj_id, $a_user_id, false, $attempts, $time);
418 }
_recordReadEvent($a_type, $a_ref_id, $obj_id, $usr_id, $isCatchupWriteEvents=true, $a_ext_rc=false, $a_ext_time=false)
Records a read event and catches up with write events.
getSumTotalTimeSecondsFromScos($a_obj_id, $a_user_id, $a_write=false)
should be avoided; store value to increase performance for further requests
static yn2tf($a_yn)
convert "y"/"n" to true/false

References $ilDB, ilChangeEvent\_recordReadEvent(), getSumTotalTimeSecondsFromScos(), and ilUtil\yn2tf().

Referenced by ilSCORM2004StoreData\scormPlayerUnload(), and ilSCORM2004StoreData\syncGlobalStatus().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSumTotalTimeSecondsFromScos()

ilSCORM2004Tracking::getSumTotalTimeSecondsFromScos (   $a_obj_id,
  $a_user_id,
  $a_write = false 
)

should be avoided; store value to increase performance for further requests

Definition at line 462 of file class.ilSCORM2004Tracking.php.

463 {
464 global $ilDB, $ilLog;
465 $scos = array();
466 $val_set = $ilDB->queryF(
467 'SELECT cp_node_id FROM cp_node
468 WHERE nodename = %s
469 AND cp_node.slm_id = %s',
470 array('text', 'integer'),
471 array('item', $a_obj_id)
472 );
473 while($val_rec = $ilDB->fetchAssoc($val_set))
474 {
475 array_push($scos,$val_rec['cp_node_id']);
476 }
477 $time = 0;
478 foreach ($scos as $sco)
479 {
480 include_once("./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php");
481 $data_set = $ilDB->queryF('
482 SELECT total_time
483 FROM cmi_node
484 WHERE cp_node_id = %s
485 AND user_id = %s',
486 array('integer','integer'),
487 array($sco, $a_user_id)
488 );
489
490 while($data_rec = $ilDB->fetchAssoc($data_set))
491 {
492 $sec = ilObjSCORM2004LearningModule::_ISODurationToCentisec($data_rec["total_time"]) / 100;
493 }
494 $time += (int) $sec;
495 $sec = 0;
496//$ilLog->write("++".$time);
497 }
498 if ($a_write && $time>0) {
499 $ilDB->queryF('UPDATE sahs_user SET sco_total_time_sec=%s WHERE obj_id = %s AND user_id = %s',
500 array('integer', 'integer', 'integer'),
501 array($time, $a_obj_id, $a_user_id));
502 }
503 return $time;
504 }
_ISODurationToCentisec($str)
convert ISO 8601 Timeperiods to centiseconds ta

References $ilDB, $ilLog, and ilObjSCORM2004LearningModule\_ISODurationToCentisec().

Referenced by _syncReadEvent(), and ilObjSCORMInitData\getStatus().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ilObjSCORM2004Tracking()

ilSCORM2004Tracking::ilObjSCORM2004Tracking ( )

Constructor @access public.

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

19 {
20 }

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