ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 _hasMaxAttempts ($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 377 of file class.ilSCORM2004Tracking.php.

379 {
380 global $ilDB;
381
382 if (is_array($a_scos))
383 {
384 $in = $ilDB->in('cp_node.cp_node_id', $a_scos, false, 'integer');
385
386 $res = $ilDB->queryF(
387 'SELECT cp_node.cp_node_id id,
388 cmi_node.completion_status completion,
389 cmi_node.success_status success
390 FROM cp_node, cmi_node
391 WHERE '.$in.'
392 AND cp_node.cp_node_id = cmi_node.cp_node_id
393 AND cp_node.slm_id = %s
394 AND cmi_node.user_id = %s',
395 array('integer', 'integer'),
396 array($a_obj_id, $a_user_id)
397 );
398
399
400 $cnt = 0;
401 while ($rec = $ilDB->fetchAssoc($res))
402 {
403 // #8171: alex, added (!$a_omit_failed || $rec["success"] != "failed")
404 // since completed/failed combination should not be included in
405 // percentage calculation at ilLPStatusSCOM::determinePercentage
406 if (($rec["completion"] == "completed" || $rec["success"] == "passed")
407 && (!$a_omit_failed || $rec["success"] != "failed"))
408 {
409 $cnt++;
410 }
411 }
412
413 }
414 return $cnt;
415 }
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 // check max attempts
340 if ($status == "in_progress" && self::_hasMaxAttempts($a_obj_id, $a_user_id))
341 {
342 $status = "failed";
343 }
344 }
345 return $status;
346 }
$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 }

References $ilDB, $in, $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, $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:

◆ _hasMaxAttempts()

static ilSCORM2004Tracking::_hasMaxAttempts (   $a_obj_id,
  $a_user_id 
)
static

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

349 {
350 global $ilDB;
351 // see ilSCORM13Player
352 $res = $ilDB->queryF(
353 'SELECT max_attempt FROM sahs_lm WHERE id = %s',
354 array('integer'),
355 array($a_obj_id)
356 );
357 $row = $ilDB->fetchAssoc($res);
358 $max_attempts = $row['max_attempt'];
359
360 if ($max_attempts)
361 {
362 $val_set = $ilDB->queryF('SELECT package_attempts FROM sahs_user WHERE obj_id = %s AND user_id = %s',
363 array('integer','integer'), array($a_obj_id,$a_user_id));
364 $val_rec = $ilDB->fetchAssoc($val_set);
365 $attempts = $val_rec["package_attempts"];
366 if ($attempts == null) $attempts = 0;
367
368 if ($attempts >= $max_attempts)
369 {
370 return true;
371 }
372 }
373
374 return false;
375 }

References $ilDB, $res, and $row.

Referenced by ilLPStatusSCORM\_getFailed().

+ Here is the caller graph for this function:

◆ _isCompleted()

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

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

458 {
459 if ($a_status == "completed" || $a_satisfied == "satisfied")
460 {
461 return true;
462 }
463
464 return false;
465 }

◆ _isFailed()

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

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

484 {
485 if ($a_status == "completed" && $a_satisfied == "notSatisfied")
486 {
487 return true;
488 }
489
490 return false;
491 }

◆ _isInProgress()

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

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

471 {
472 if ($a_status != "completed")
473 {
474 return true;
475 }
476
477 return false;
478 }

◆ _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 423 of file class.ilSCORM2004Tracking.php.

424 {
425 global $ilDB;
426
427 //get condition to select time
428 $val_set = $ilDB->queryF(
429 'SELECT time_from_lms FROM sahs_lm WHERE id = %s',
430 array('integer'),array($a_obj_id));
431 $val_rec = $ilDB->fetchAssoc($val_set);
432 $time_from_lms=(ilUtil::yn2tf($val_rec["time_from_lms"]));
433
434 // get attempts and time
435 $val_set = $ilDB->queryF('
436 SELECT package_attempts, sco_total_time_sec, total_time_sec
437 FROM sahs_user WHERE obj_id = %s AND user_id = %s',
438 array('integer','integer'), array($a_obj_id,$a_user_id));
439 $val_rec = $ilDB->fetchAssoc($val_set);
440 if ($time_from_lms == false) $time = $val_rec["sco_total_time_sec"];
441 else $time = $val_rec["total_time_sec"];
442 $attempts = $val_rec["package_attempts"];
443 if ($attempts == null) $attempts = ""; //??
444
445 if ($attempts != "" && $time == null) { //use old way
446 $time = self::getSumTotalTimeSecondsFromScos($a_obj_id, $a_user_id,true);
447 }
448
449 include_once("./Services/Tracking/classes/class.ilChangeEvent.php");
450 ilChangeEvent::_recordReadEvent($a_type, $a_ref_id,
451 $a_obj_id, $a_user_id, false, $attempts, $time);
452 }
_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 496 of file class.ilSCORM2004Tracking.php.

497 {
498 global $ilDB, $ilLog;
499 $scos = array();
500 $val_set = $ilDB->queryF(
501 'SELECT cp_node_id FROM cp_node
502 WHERE nodename = %s
503 AND cp_node.slm_id = %s',
504 array('text', 'integer'),
505 array('item', $a_obj_id)
506 );
507 while($val_rec = $ilDB->fetchAssoc($val_set))
508 {
509 array_push($scos,$val_rec['cp_node_id']);
510 }
511 $time = 0;
512 foreach ($scos as $sco)
513 {
514 include_once("./Modules/Scorm2004/classes/class.ilObjSCORM2004LearningModule.php");
515 $data_set = $ilDB->queryF('
516 SELECT total_time
517 FROM cmi_node
518 WHERE cp_node_id = %s
519 AND user_id = %s',
520 array('integer','integer'),
521 array($sco, $a_user_id)
522 );
523
524 while($data_rec = $ilDB->fetchAssoc($data_set))
525 {
526 $sec = ilObjSCORM2004LearningModule::_ISODurationToCentisec($data_rec["total_time"]) / 100;
527 }
528 $time += (int) $sec;
529 $sec = 0;
530//$ilLog->write("++".$time);
531 }
532 if ($a_write && $time>0) {
533 $ilDB->queryF('UPDATE sahs_user SET sco_total_time_sec=%s WHERE obj_id = %s AND user_id = %s',
534 array('integer', 'integer', 'integer'),
535 array($time, $a_obj_id, $a_user_id));
536 }
537 return $time;
538 }
_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: