ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilObjSCORMTracking Class Reference

Class ilObjSCORMTracking. More...

+ Collaboration diagram for ilObjSCORMTracking:

Static Public Member Functions

static storeJsApi ()
 
static storeJsApiCmi (int $user_id, int $obj_id, object $data)
 
static syncGlobalStatus (int $userId, int $packageId, int $refId, object $data, ?int $new_global_status)
 
static _insertTrackData (int $a_sahs_id, string $a_lval, string $a_rval, int $a_obj_id)
 
static _getCompleted (object $scorm_item_id, int $a_obj_id)
 like necessary because of Oracle More...
 
static _getCollectionStatus (?array $a_scos, int $a_obj_id, int $a_user_id)
 
static _countCompleted (?array $a_scos, int $a_obj_id, int $a_user_id)
 
static lookupLastAccessTimes (int $a_obj_id)
 Lookup last acccess time for all users of a scorm module. More...
 
static _getTrackedUsers (int $a_obj_id)
 Get all tracked users. More...
 
static _getFailed (object $scorm_item_id, int $a_obj_id)
 like necessary because of Oracle More...
 
static _getCountCompletedPerUser (array $a_scorm_item_ids, int $a_obj_id)
 Get users who have status completed or passed. More...
 
static _getProgressInfo (array $sco_item_ids, int $a_obj_id)
 Get info about. More...
 
static _getInProgress (array|int $scorm_item_id, int $a_obj_id, ?array $a_blocked_user_ids=null)
 
static scorm12PlayerUnload ()
 
static checkIfAllowed (int $packageId, int $userId, int $hash)
 
static _syncReadEvent (int $a_obj_id, int $a_user_id, string $a_type, int $a_ref_id)
 

Detailed Description

Member Function Documentation

◆ _countCompleted()

static ilObjSCORMTracking::_countCompleted ( ?array  $a_scos,
int  $a_obj_id,
int  $a_user_id 
)
static

Definition at line 344 of file class.ilObjSCORMTracking.php.

References $DIC, $ilDB, and $res.

Referenced by ilLPStatusSCORM\determinePercentage().

344  : int
345  {
346  global $DIC;
347  $ilDB = $DIC->database();
348  $cnt = 0;
349 
350  if (is_array($a_scos)) {
351  $in = $ilDB->in('sco_id', $a_scos, false, 'integer');
352 
353  $res = $ilDB->queryF(
354  'SELECT sco_id, rvalue FROM scorm_tracking
355  WHERE ' . $in . '
356  AND obj_id = %s
357  AND lvalue = %s
358  AND user_id = %s',
359  array('integer', 'text', 'integer'),
360  array($a_obj_id, 'cmi.core.lesson_status', $a_user_id)
361  );
362 
363  while ($rec = $ilDB->fetchAssoc($res)) {
364  if ($rec["rvalue"] === "completed" || $rec["rvalue"] === "passed") {
365  $cnt++;
366  }
367  }
368  }
369  return $cnt;
370  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:26
+ Here is the caller graph for this function:

◆ _getCollectionStatus()

static ilObjSCORMTracking::_getCollectionStatus ( ?array  $a_scos,
int  $a_obj_id,
int  $a_user_id 
)
static

Definition at line 299 of file class.ilObjSCORMTracking.php.

References $DIC, $ilDB, and $res.

Referenced by ilLPStatusSCORM\determineStatus().

299  : string
300  {
301  global $DIC;
302  $ilDB = $DIC->database();
303 
304  $status = "not_attempted";
305 
306  if (is_array($a_scos)) {
307  $in = $ilDB->in('sco_id', $a_scos, false, 'integer');
308 
309  $res = $ilDB->queryF(
310  'SELECT sco_id, rvalue FROM scorm_tracking
311  WHERE ' . $in . '
312  AND obj_id = %s
313  AND lvalue = %s
314  AND user_id = %s',
315  array('integer', 'text', 'integer'),
316  array($a_obj_id, 'cmi.core.lesson_status', $a_user_id)
317  );
318 
319  $cnt = 0;
320  $completed = true;
321  $failed = false;
322  while ($rec = $ilDB->fetchAssoc($res)) {
323  if ($rec["rvalue"] === "failed") {
324  $failed = true;
325  }
326  if ($rec["rvalue"] !== "completed" && $rec["rvalue"] !== "passed") {
327  $completed = false;
328  }
329  $cnt++;
330  }
331  if ($cnt > 0) {
332  $status = "in_progress";
333  }
334  if ($completed && $cnt == count($a_scos)) {
335  $status = "completed";
336  }
337  if ($failed) {
338  $status = "failed";
339  }
340  }
341  return $status;
342  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:26
+ Here is the caller graph for this function:

◆ _getCompleted()

static ilObjSCORMTracking::_getCompleted ( object  $scorm_item_id,
int  $a_obj_id 
)
static

like necessary because of Oracle

Definition at line 254 of file class.ilObjSCORMTracking.php.

References $DIC, $ilDB, and $res.

254  : array
255  {
256  global $DIC;
257  $ilDB = $DIC->database();
258 
259  $user_ids = [];
260 
261  if (is_array($scorm_item_id)) {
262  $in = $ilDB->in('sco_id', $scorm_item_id, false, 'integer');
263 
264  $res = $ilDB->queryF(
265  'SELECT DISTINCT(user_id) FROM scorm_tracking
266  WHERE ' . $in . '
267  AND obj_id = %s
268  AND lvalue = %s
269  AND (' . $ilDB->like('rvalue', 'clob', 'completed') . ' OR ' . $ilDB->like(
270  'rvalue',
271  'clob',
272  'passed'
273  ) . ')',
274  array('integer', 'text'),
275  array($a_obj_id, 'cmi.core.lesson_status')
276  );
277  } else {
278  $res = $ilDB->queryF(
279  'SELECT DISTINCT(user_id) FROM scorm_tracking
280  WHERE sco_id = %s
281  AND obj_id = %s
282  AND lvalue = %s
283  AND (' . $ilDB->like('rvalue', 'clob', 'completed') . ' OR ' . $ilDB->like(
284  'rvalue',
285  'clob',
286  'passed'
287  ) . ')',
288  array('integer', 'integer', 'text'),
289  array($scorm_item_id, $a_obj_id, 'cmi.core.lesson_status')
290  );
291  }
292 
293  while ($row = $ilDB->fetchObject($res)) {
294  $user_ids[] = $row->user_id;
295  }
296  return $user_ids;
297  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:26

◆ _getCountCompletedPerUser()

static ilObjSCORMTracking::_getCountCompletedPerUser ( array  $a_scorm_item_ids,
int  $a_obj_id 
)
static

Get users who have status completed or passed.

Returns
array<int|string, mixed>

Definition at line 463 of file class.ilObjSCORMTracking.php.

References $DIC, $ilDB, and $res.

Referenced by ilLPStatusSCORM\_getStatusInfo().

463  : array
464  {
465  global $DIC;
466  $ilDB = $DIC->database();
467  $users = [];
468 
469  $in = $ilDB->in('sco_id', $a_scorm_item_ids, false, 'integer');
470 
471  // Why does this query use a like search against "passed" and "failed"
472  //because it's clob and we support Oracle
473  $res = $ilDB->queryF(
474  '
475  SELECT user_id, COUNT(user_id) completed FROM scorm_tracking
476  WHERE ' . $in . '
477  AND obj_id = %s
478  AND lvalue = %s
479  AND (' . $ilDB->like('rvalue', 'clob', 'completed') . ' OR ' . $ilDB->like('rvalue', 'clob', 'passed') . ')
480  GROUP BY user_id',
481  array('integer', 'text'),
482  array($a_obj_id, 'cmi.core.lesson_status')
483  );
484  while ($row = $ilDB->fetchObject($res)) {
485  $users[$row->user_id] = $row->completed;
486  }
487  return $users;
488  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:26
+ Here is the caller graph for this function:

◆ _getFailed()

static ilObjSCORMTracking::_getFailed ( object  $scorm_item_id,
int  $a_obj_id 
)
static

like necessary because of Oracle

Definition at line 421 of file class.ilObjSCORMTracking.php.

References $DIC, $ilDB, and $res.

421  : array
422  {
423  global $DIC;
424  $ilDB = $DIC->database();
425  $user_ids = [];
426 
427  if (is_array($scorm_item_id)) {
428  $in = $ilDB->in('sco_id', $scorm_item_id, false, 'integer');
429 
430  $res = $ilDB->queryF(
431  '
432  SELECT DISTINCT(user_id) FROM scorm_tracking
433  WHERE ' . $in . '
434  AND obj_id = %s
435  AND lvalue = %s
436  AND ' . $ilDB->like('rvalue', 'clob', 'failed') . ' ',
437  array('integer', 'text'),
438  array($a_obj_id, 'cmi.core.lesson_status')
439  );
440  } else {
441  $res = $ilDB->queryF(
442  '
443  SELECT DISTINCT(user_id) FROM scorm_tracking
444  WHERE sco_id = %s
445  AND obj_id = %s
446  AND lvalue = %s
447  AND ' . $ilDB->like('rvalue', 'clob', 'failed') . ' ',
448  array('integer', 'integer', 'text'),
449  array($scorm_item_id, $a_obj_id, 'cmi.core.lesson_status')
450  );
451  }
452 
453  while ($row = $ilDB->fetchObject($res)) {
454  $user_ids[] = $row->user_id;
455  }
456  return $user_ids;
457  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:26

◆ _getInProgress()

static ilObjSCORMTracking::_getInProgress ( array|int  $scorm_item_id,
int  $a_obj_id,
?array  $a_blocked_user_ids = null 
)
static
Returns
array<int|string, mixed[]>

Definition at line 537 of file class.ilObjSCORMTracking.php.

References $DIC, $ilDB, and $res.

Referenced by _getProgressInfo().

537  : array
538  {
539  global $DIC;
540  $ilDB = $DIC->database();
541 
542  if (is_array($scorm_item_id)) {
543  $in = $ilDB->in('sco_id', $scorm_item_id, false, 'integer');
544 
545  $res = $ilDB->queryF(
546  'SELECT user_id,sco_id FROM scorm_tracking
547  WHERE ' . $in . '
548  AND obj_id = %s
549  GROUP BY user_id, sco_id',
550  array('integer'),
551  array($a_obj_id)
552  );
553  } else {
554  $res = $ilDB->queryF(
555  'SELECT user_id,sco_id FROM scorm_tracking
556  WHERE sco_id = %s
557  AND obj_id = %s',
558  array('integer', 'integer'),
559  array($scorm_item_id, $a_obj_id)
560  );
561  }
562 
563  $in_progress = array();
564 
565  while ($row = $ilDB->fetchObject($res)) {
566  // #15061 - see _getProgressInfo()
567  if (!($a_blocked_user_ids &&
568  isset($a_blocked_user_ids[$row->sco_id]) &&
569  is_array($a_blocked_user_ids[$row->sco_id]) &&
570  in_array($row->user_id, $a_blocked_user_ids[$row->sco_id]))) {
571  $in_progress[$row->sco_id][] = $row->user_id;
572  }
573  }
574  return $in_progress;
575  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:26
+ Here is the caller graph for this function:

◆ _getProgressInfo()

static ilObjSCORMTracking::_getProgressInfo ( array  $sco_item_ids,
int  $a_obj_id 
)
static

Get info about.

Returns
array<string, array>

Definition at line 494 of file class.ilObjSCORMTracking.php.

References $DIC, $ilDB, $info, $res, and _getInProgress().

Referenced by ilLPStatusSCORM\_getStatusInfo().

494  : array
495  {
496  global $DIC;
497  $ilDB = $DIC->database();
498 
499  $in = $ilDB->in('sco_id', $sco_item_ids, false, 'integer');
500 
501  $res = $ilDB->queryF(
502  '
503  SELECT * FROM scorm_tracking
504  WHERE ' . $in . '
505  AND obj_id = %s
506  AND lvalue = %s ',
507  array('integer', 'text'),
508  array($a_obj_id, 'cmi.core.lesson_status')
509  );
510 
511  $info['completed'] = array();
512  $info['failed'] = array();
513 
514  $user_ids = array();
515  while ($row = $ilDB->fetchObject($res)) {
516  switch ($row->rvalue) {
517  case 'completed':
518  case 'passed':
519  $info['completed'][$row->sco_id][] = $row->user_id;
520  $user_ids[$row->sco_id][] = $row->user_id;
521  break;
522 
523  case 'failed':
524  $info['failed'][$row->sco_id][] = $row->user_id;
525  $user_ids[$row->sco_id][] = $row->user_id;
526  break;
527  }
528  }
529  $info['in_progress'] = ilObjSCORMTracking::_getInProgress($sco_item_ids, $a_obj_id, $user_ids);
530 
531  return $info;
532  }
static _getInProgress(array|int $scorm_item_id, int $a_obj_id, ?array $a_blocked_user_ids=null)
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:26
$info
Definition: entry_point.php:21
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getTrackedUsers()

static ilObjSCORMTracking::_getTrackedUsers ( int  $a_obj_id)
static

Get all tracked users.

Definition at line 397 of file class.ilObjSCORMTracking.php.

References $DIC, $ilDB, and $res.

Referenced by ilTrQuery\getParticipantsForObject(), and ilLPStatusSCORM\refreshStatus().

397  : array
398  {
399  global $DIC;
400  $ilDB = $DIC->database();
401  // $ilLog = ilLoggerFactory::getLogger('sahs');
402 
403  $res = $ilDB->queryF(
404  'SELECT DISTINCT user_id FROM scorm_tracking
405  WHERE obj_id = %s
406  AND lvalue = %s',
407  array('integer', 'text'),
408  array($a_obj_id, 'cmi.core.lesson_status')
409  );
410 
411  $users = array();
412  while ($row = $ilDB->fetchAssoc($res)) {
413  $users[] = $row["user_id"];
414  }
415  return $users;
416  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:26
+ Here is the caller graph for this function:

◆ _insertTrackData()

static ilObjSCORMTracking::_insertTrackData ( int  $a_sahs_id,
string  $a_lval,
string  $a_rval,
int  $a_obj_id 
)
static

Definition at line 230 of file class.ilObjSCORMTracking.php.

References $DIC, $ilDB, ilLPStatusWrapper\_updateStatus(), and ilUtil\now().

Referenced by ilSCORMItem\insertTrackData().

230  : void
231  {
232  global $DIC;
233  $ilDB = $DIC->database();
234  $ilUser = $DIC->user();
235 
236  $ilDB->insert('scorm_tracking', array(
237  'obj_id' => array('integer', $a_obj_id),
238  'user_id' => array('integer', $ilUser->getId()),
239  'sco_id' => array('integer', $a_sahs_id),
240  'lvalue' => array('text', $a_lval),
241  'rvalue' => array('clob', $a_rval),
242  'c_timestamp' => array('timestamp', ilUtil::now())
243  ));
244 
245  if ($a_lval === "cmi.core.lesson_status") {
246  ilLPStatusWrapper::_updateStatus($a_obj_id, $ilUser->getId());
247  }
248  }
static now()
Return current timestamp in Y-m-d H:i:s format.
global $DIC
Definition: shib_login.php:26
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _syncReadEvent()

static ilObjSCORMTracking::_syncReadEvent ( int  $a_obj_id,
int  $a_user_id,
string  $a_type,
int  $a_ref_id 
)
static

Definition at line 627 of file class.ilObjSCORMTracking.php.

References $DIC, $ilDB, ilChangeEvent\_recordReadEvent(), ilLoggerFactory\getLogger(), ILIAS\Repository\int(), and null.

Referenced by scorm12PlayerUnload().

627  : void
628  {
629  global $DIC;
630  $ilDB = $DIC->database();
631  $ilLog = ilLoggerFactory::getLogger('sahs');
632  $val_set = $ilDB->queryF(
633  'SELECT package_attempts, total_time_sec, sco_total_time_sec, time_from_lms FROM sahs_user, sahs_lm '
634  . 'WHERE sahs_user.obj_id = %s AND sahs_user.user_id = %s AND sahs_user.obj_id = sahs_lm.id',
635  array('integer', 'integer'),
636  array($a_obj_id, $a_user_id)
637  );
638 
639  $val_rec = $ilDB->fetchAssoc($val_set);
640 
641  if ($val_rec["package_attempts"] == null) {
642  $val_rec["package_attempts"] = "";
643  }
644  $attempts = $val_rec["package_attempts"];
645 
646  $time = (int) $val_rec["sco_total_time_sec"];
647 
648  // get learning time for old ILIAS-Versions
649  if ($time == 0) {
650  $sco_set = $ilDB->queryF(
651  '
652  SELECT sco_id, rvalue FROM scorm_tracking
653  WHERE obj_id = %s
654  AND user_id = %s
655  AND lvalue = %s
656  AND sco_id <> %s',
657  array('integer', 'integer', 'text', 'integer'),
658  array($a_obj_id, $a_user_id, 'cmi.core.total_time', 0)
659  );
660 
661  while ($sco_rec = $ilDB->fetchAssoc($sco_set)) {
662  $tarr = explode(":", $sco_rec["rvalue"]);
663  $sec = (int) $tarr[2] + (int) $tarr[1] * 60 +
664  (int) substr($tarr[0], strlen($tarr[0]) - 3) * 60 * 60;
665  $time += $sec;
666  }
667  }
668  ilChangeEvent::_recordReadEvent($a_type, $a_ref_id, $a_obj_id, $a_user_id, false, $attempts, $time);
669  }
static getLogger(string $a_component_id)
Get component logger.
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _recordReadEvent(string $a_type, int $a_ref_id, int $obj_id, int $usr_id, bool $isCatchupWriteEvents=true, $a_ext_rc=null, $a_ext_time=null)
global $DIC
Definition: shib_login.php:26
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkIfAllowed()

static ilObjSCORMTracking::checkIfAllowed ( int  $packageId,
int  $userId,
int  $hash 
)
static

Definition at line 611 of file class.ilObjSCORMTracking.php.

References $DIC, $ilDB, and $res.

611  : void
612  {
613  global $DIC;
614  $ilDB = $DIC->database();
615  $res = $ilDB->queryF(
616  'select hash from sahs_user where obj_id=%s AND user_id=%s AND hash_end>%s',
617  array('integer', 'integer', 'timestamp'),
618  array($packageId, $userId, date('Y-m-d H:i:s'))
619  );
620  $rowtmp = $ilDB->fetchAssoc($res);
621  if (! ($rowtmp && $rowtmp['hash'] == $hash)) {
622  //output used by api
623  die("not allowed");
624  }
625  }
$res
Definition: ltiservices.php:66
$packageId
Definition: storeScorm.php:24
global $DIC
Definition: shib_login.php:26

◆ lookupLastAccessTimes()

static ilObjSCORMTracking::lookupLastAccessTimes ( int  $a_obj_id)
static

Lookup last acccess time for all users of a scorm module.

Returns
array<int|string, mixed>

Definition at line 376 of file class.ilObjSCORMTracking.php.

References $DIC, $ilDB, $res, and ilDBConstants\FETCHMODE_OBJECT.

376  : array
377  {
378  global $DIC;
379  $ilDB = $DIC->database();
380  $users = array();
381 
382  $query = 'SELECT user_id, MAX(c_timestamp) tst ' .
383  'FROM scorm_tracking ' .
384  'WHERE obj_id = ' . $ilDB->quote($a_obj_id, 'integer') . ' ' .
385  'GROUP BY user_id';
386  $res = $ilDB->query($query);
387 
388  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
389  $users[$row->user_id] = $row->tst;
390  }
391  return $users;
392  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:26

◆ scorm12PlayerUnload()

static ilObjSCORMTracking::scorm12PlayerUnload ( )
static

Definition at line 577 of file class.ilObjSCORMTracking.php.

References $DIC, $GLOBALS, $ilDB, $ref_id, $user_id, _syncReadEvent(), and ILIAS\UI\examples\Symbol\Glyph\Header\header().

577  : void
578  {
579  global $DIC;
580  $ilDB = $DIC->database();
581  $user_id = $DIC->http()->wrapper()->query()->retrieve('p', $DIC->refinery()->kindlyTo()->int());
582  $ref_id = $DIC->http()->wrapper()->query()->retrieve('ref_id', $DIC->refinery()->kindlyTo()->int());
583  $obj_id = $DIC->http()->wrapper()->query()->retrieve('package_id', $DIC->refinery()->kindlyTo()->int());
584  if ($obj_id <= 1) {
585  $GLOBALS['DIC']['ilLog']->write(__METHOD__ . ' no valid obj_id');
586  } else {
587  $last_visited = "";
588  if ($DIC->http()->wrapper()->query()->has('last_visited')) {
589  $last_visited = $DIC->http()->wrapper()->query()->retrieve('last_visited', $DIC->refinery()->kindlyTo()->string());
590  }
591 
592  $endDate = date(
593  'Y-m-d H:i:s',
594  mktime((int) date('H'), (int) date('i') + 5, (int) date('s'), (int) date('m'), (int) date('d'), (int) date('Y'))
595  );
596  $ilDB->manipulateF(
597  'UPDATE sahs_user
598  SET last_visited = %s, hash_end =%s, last_access = %s
599  WHERE obj_id = %s AND user_id = %s',
600  array('text', 'timestamp', 'timestamp', 'integer', 'integer'),
601  array($last_visited, $endDate, date('Y-m-d H:i:s'), $obj_id, $user_id)
602  );
603  // update time and numbers of attempts in change event
604  //NOTE: here it is correct (not count of commit with changed values); be careful to performance issues
606  }
607  header('Content-Type: text/plain; charset=UTF-8');
608  print("");
609  }
$ref_id
Definition: ltiauth.php:65
$GLOBALS["DIC"]
Definition: wac.php:53
global $DIC
Definition: shib_login.php:26
static _syncReadEvent(int $a_obj_id, int $a_user_id, string $a_type, int $a_ref_id)
header()
expected output: > ILIAS shows the rendered Component.
Definition: header.php:29
+ Here is the call graph for this function:

◆ storeJsApi()

static ilObjSCORMTracking::storeJsApi ( )
static

Definition at line 28 of file class.ilObjSCORMTracking.php.

References $data, $DIC, $refId, $user_id, ILIAS\UI\examples\Symbol\Glyph\Header\header(), and ILIAS\Repository\int().

28  : void
29  {
30  global $DIC;
31  $obj_id = $DIC->http()->wrapper()->query()->retrieve('package_id', $DIC->refinery()->kindlyTo()->int());
32  $refId = $DIC->http()->wrapper()->query()->retrieve('ref_id', $DIC->refinery()->kindlyTo()->int());
33  $in = file_get_contents("php://input");
34  $data = json_decode($in);
35  $user_id = (int) $data->p;
36 
37  header('Content-Type: text/plain; charset=UTF-8');
38 
39  $rval = self::storeJsApiCmi($user_id, $obj_id, $data);
40  if ($rval != true) {
41  print("storeJsApiCmi failed");
42  } else {
43  $rval = self::syncGlobalStatus($user_id, $obj_id, $refId, $data, $data->now_global_status);
44  if ($rval != true) {
45  print("syncGlobalStatus failed");
46  }
47  }
48  if ($rval == true) {
49  print("ok");
50  }
51  }
$refId
Definition: xapitoken.php:58
global $DIC
Definition: shib_login.php:26
header()
expected output: > ILIAS shows the rendered Component.
Definition: header.php:29
+ Here is the call graph for this function:

◆ storeJsApiCmi()

static ilObjSCORMTracking::storeJsApiCmi ( int  $user_id,
int  $obj_id,
object  $data 
)
static

Definition at line 53 of file class.ilObjSCORMTracking.php.

References $DIC, $ilDB, ilSCORMObject\_lookupPresentableItems(), ilLPStatusWrapper\_updateStatus(), ilLoggerFactory\getLogger(), ilLTIAppEventListener\handleOutcomeWithoutLP(), and ilUtil\now().

53  : bool
54  {
55  global $DIC;
56  $ilLog = ilLoggerFactory::getLogger('sahs');
57  $ilDB = $DIC->database();
58 
59  $b_updateStatus = false;
60  $i_score_max = 0;
61  $i_score_raw = 0;
62 
63  $aa_data = array();
64  // if (is_array($_POST["S"])) {
65  // foreach($_POST["S"] as $key => $value) {
66  // $aa_data[] = array("sco_id" => $value, "left" => $_POST["L"][$key], "right" => $_POST["R"][$key]);
67  // }
68  // }
69  foreach ($data->cmi as $value) {
70  $aa_data[] = array("sco_id" => (int) $value[0],
71  "left" => $value[1],
72  "right" => $value[2]
73  );
74  // $aa_data[] = array("sco_id" => (int) $data->cmi[$i][0], "left" => $data->cmi[$i][1], "right" => rawurldecode($data->cmi[$i][2]));
75  }
76 
77  if ($obj_id <= 1) {
78  $ilLog->write("ScormAicc: storeJsApi: Error: No valid obj_id given.");
79  } else {
80  foreach ($aa_data as $a_data) {
81  $set = $ilDB->queryF(
82  '
83  SELECT rvalue FROM scorm_tracking
84  WHERE user_id = %s
85  AND sco_id = %s
86  AND lvalue = %s
87  AND obj_id = %s',
88  array('integer', 'integer', 'text', 'integer'),
89  array($user_id, $a_data["sco_id"], $a_data["left"], $obj_id)
90  );
91  if ($rec = $ilDB->fetchAssoc($set)) {
92  if ($a_data["left"] === 'cmi.core.lesson_status' && $a_data["right"] != $rec["rvalue"]) {
93  $b_updateStatus = true;
94  }
95  $ilDB->update(
96  'scorm_tracking',
97  array(
98  'rvalue' => array('clob', $a_data["right"]),
99  'c_timestamp' => array('timestamp', ilUtil::now())
100  ),
101  array(
102  'user_id' => array('integer', $user_id),
103  'sco_id' => array('integer', $a_data["sco_id"]),
104  'lvalue' => array('text', $a_data["left"]),
105  'obj_id' => array('integer', $obj_id)
106  )
107  );
108  $ilLog->debug("ScormAicc: storeJsApi Updated - L:" . $a_data["left"] . ",R:" .
109  $a_data["right"] . " for obj_id:" . $obj_id . ",sco_id:" . $a_data["sco_id"] . ",user_id:" . $user_id);
110  } else {
111  if ($a_data["left"] === 'cmi.core.lesson_status') {
112  $b_updateStatus = true;
113  }
114  $ilDB->insert('scorm_tracking', array(
115  'obj_id' => array('integer', $obj_id),
116  'user_id' => array('integer', $user_id),
117  'sco_id' => array('integer', $a_data["sco_id"]),
118  'lvalue' => array('text', $a_data["left"]),
119  'rvalue' => array('clob', $a_data["right"]),
120  'c_timestamp' => array('timestamp', ilUtil::now())
121  ));
122  $ilLog->debug("ScormAicc: storeJsApi Inserted - L:" . $a_data["left"] . ",R:" .
123  $a_data["right"] . " for obj_id:" . $obj_id . ",sco_id:" . $a_data["sco_id"] . ",user_id:" . $user_id);
124  }
125  if ($a_data["left"] === 'cmi.core.score.max') {
126  $i_score_max = $a_data["right"];
127  }
128  if ($a_data["left"] === 'cmi.core.score.raw') {
129  $i_score_raw = $a_data["right"];
130  }
131  }
132  // mantis #30293
133  if ($i_score_max > 0 && $i_score_raw > 0) {
134  if (count(ilSCORMObject::_lookupPresentableItems($obj_id)) == 1) {
136  $obj_id,
137  $user_id,
138  ($i_score_raw / $i_score_max) * 100
139  );
140  }
141  }
142  }
143 
144  // update status
145  if ($b_updateStatus === true) {
147  }
148 
149  return true;
150  }
static getLogger(string $a_component_id)
Get component logger.
static _lookupPresentableItems(int $a_slm_id)
Count number of presentable SCOs/Assets of SCORM learning module.
static now()
Return current timestamp in Y-m-d H:i:s format.
global $DIC
Definition: shib_login.php:26
static handleOutcomeWithoutLP(int $a_obj_id, int $a_usr_id, ?float $a_percentage)
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
+ Here is the call graph for this function:

◆ syncGlobalStatus()

static ilObjSCORMTracking::syncGlobalStatus ( int  $userId,
int  $packageId,
int  $refId,
object  $data,
?int  $new_global_status 
)
static

Definition at line 152 of file class.ilObjSCORMTracking.php.

References $DIC, $ilDB, ilChangeEvent\_recordReadEvent(), ilLPStatusWrapper\_updateStatus(), ilLoggerFactory\getLogger(), ILIAS\Repository\int(), and null.

152  : bool
153  {
154  global $DIC;
155  $ilDB = $DIC->database();
156  $ilLog = ilLoggerFactory::getLogger('sahs');
157  $saved_global_status = $data->saved_global_status;
158  $ilLog->write("saved_global_status=" . $saved_global_status);
159 
160  // get attempts
161  if (!isset($data->packageAttempts)) {
162  $val_set = $ilDB->queryF(
163  'SELECT package_attempts FROM sahs_user WHERE obj_id = %s AND user_id = %s',
164  array('integer', 'integer'),
165  array($packageId, $userId)
166  );
167  $val_rec = $ilDB->fetchAssoc($val_set);
168  $attempts = $val_rec["package_attempts"];
169  } else {
170  $attempts = $data->packageAttempts;
171  }
172  if ($attempts == null) {
173  $attempts = 1;
174  }
175 
176  //update percentage_completed, sco_total_time_sec,status in sahs_user
177  $totalTime = (int) $data->totalTimeCentisec;
178  $totalTime = round($totalTime / 100);
179  $ilDB->queryF(
180  'UPDATE sahs_user SET last_visited=%s, last_access = %s, sco_total_time_sec=%s, status=%s, percentage_completed=%s, package_attempts=%s WHERE obj_id = %s AND user_id = %s',
181  array('text', 'timestamp', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer'),
182  array($data->last_visited,
183  date('Y-m-d H:i:s'),
184  $totalTime,
185  $new_global_status,
186  $data->percentageCompleted,
187  $attempts,
188  $packageId,
189  $userId
190  )
191  );
192 
193  // self::ensureObjectDataCacheExistence();
194  global $DIC;
195  $ilObjDataCache = $DIC['ilObjDataCache'];
196  //workaround if $row->read_count == null TODO ERASE
197  try {
199  "sahs",
200  $refId,
201  $packageId,
202  $userId,
203  false,
204  $attempts,
205  $totalTime
206  );
207  } catch (\Exception $exception) {
209  "sahs",
210  $refId,
211  $packageId,
212  $userId,
213  false,
214  null,
215  $totalTime
216  );
217  }
218 
219  //end sync access number and time in read event table
220 
221  // update learning progress
222  if ($new_global_status !== null) {
224 
225  // here put code for soap to MaxCMS e.g. when if($saved_global_status != $new_global_status)
226  }
227  return true;
228  }
static getLogger(string $a_component_id)
Get component logger.
$packageId
Definition: storeScorm.php:24
$refId
Definition: xapitoken.php:58
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _recordReadEvent(string $a_type, int $a_ref_id, int $obj_id, int $usr_id, bool $isCatchupWriteEvents=true, $a_ext_rc=null, $a_ext_time=null)
global $DIC
Definition: shib_login.php:26
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
+ Here is the call graph for this function:

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