ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilObjSCORMTracking Class Reference

Class ilObjSCORMTracking. More...

+ Collaboration diagram for ilObjSCORMTracking:

Public Member Functions

 extractData ()
 
 store ($obj_id=0, $sahs_id=0, $extractData=1)
 

Static Public Member Functions

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

Detailed Description

Member Function Documentation

◆ _countCompleted()

static ilObjSCORMTracking::_countCompleted (   $a_scos,
  $a_obj_id,
  $a_user_id 
)
static

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

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

Referenced by ilLPStatusSCORM\determinePercentage().

522  {
523  global $ilDB;
524 
525  if (is_array($a_scos)) {
526  $in = $ilDB->in('sco_id', $a_scos, false, 'integer');
527 
528  $res = $ilDB->queryF(
529  'SELECT sco_id, rvalue FROM scorm_tracking
530  WHERE ' . $in . '
531  AND obj_id = %s
532  AND lvalue = %s
533  AND user_id = %s',
534  array('integer','text', 'integer'),
535  array($a_obj_id,'cmi.core.lesson_status', $a_user_id)
536  );
537 
538  $cnt = 0;
539  while ($rec = $ilDB->fetchAssoc($res)) {
540  if ($rec["rvalue"] == "completed" || $rec["rvalue"] == "passed") {
541  $cnt++;
542  }
543  }
544  }
545  return $cnt;
546  }
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
global $ilDB
+ Here is the caller graph for this function:

◆ _getCollectionStatus()

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

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

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

Referenced by ilLPStatusSCORM\determineStatus().

476  {
477  global $ilDB;
478 
479 
480  $status = "not_attempted";
481 
482  if (is_array($a_scos)) {
483  $in = $ilDB->in('sco_id', $a_scos, false, 'integer');
484 
485  $res = $ilDB->queryF(
486  'SELECT sco_id, rvalue FROM scorm_tracking
487  WHERE ' . $in . '
488  AND obj_id = %s
489  AND lvalue = %s
490  AND user_id = %s',
491  array('integer','text', 'integer'),
492  array($a_obj_id,'cmi.core.lesson_status', $a_user_id)
493  );
494 
495  $cnt = 0;
496  $completed = true;
497  $failed = false;
498  while ($rec = $ilDB->fetchAssoc($res)) {
499  if ($rec["rvalue"] == "failed") {
500  $failed = true;
501  }
502  if ($rec["rvalue"] != "completed" && $rec["rvalue"] != "passed") {
503  $completed = false;
504  }
505  $cnt++;
506  }
507  if ($cnt > 0) {
508  $status = "in_progress";
509  }
510  if ($completed && $cnt == count($a_scos)) {
511  $status = "completed";
512  }
513  if ($failed) {
514  $status = "failed";
515  }
516  }
517  return $status;
518  }
foreach($_POST as $key=> $value) $res
$failed
Definition: Utf8Test.php:85
Create styles array
The data for the language used.
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
global $ilDB
+ Here is the caller graph for this function:

◆ _getCompleted()

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

like necessary because of Oracle

Parameters
object$scorm_item_id
object$a_obj_id
Returns

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

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

442  {
443  global $ilDB;
444 
445  if (is_array($scorm_item_id)) {
446  $in = $ilDB->in('sco_id', $scorm_item_id, false, 'integer');
447 
448  $res = $ilDB->queryF(
449  'SELECT DISTINCT(user_id) FROM scorm_tracking
450  WHERE ' . $in . '
451  AND obj_id = %s
452  AND lvalue = %s
453  AND (' . $ilDB->like('rvalue', 'clob', 'completed') . ' OR ' . $ilDB->like('rvalue', 'clob', 'passed') . ')',
454  array('integer','text'),
455  array($a_obj_id,'cmi.core.lesson_status')
456  );
457  } else {
458  $res = $ilDB->queryF(
459  'SELECT DISTINCT(user_id) FROM scorm_tracking
460  WHERE sco_id = %s
461  AND obj_id = %s
462  AND lvalue = %s
463  AND (' . $ilDB->like('rvalue', 'clob', 'completed') . ' OR ' . $ilDB->like('rvalue', 'clob', 'passed') . ')',
464  array('integer','integer','text'),
465  array($scorm_item_id,$a_obj_id,'cmi.core.lesson_status')
466  );
467  }
468 
469  while ($row = $ilDB->fetchObject($res)) {
470  $user_ids[] = $row->user_id;
471  }
472  return $user_ids ? $user_ids : array();
473  }
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
global $ilDB

◆ _getCountCompletedPerUser()

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

Get users who have status completed or passed.

Parameters
object$a_scorm_item_ids
object$a_obj_id
Returns

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

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

Referenced by ilLPStatusSCORM\_getStatusInfo().

645  {
646  global $ilDB;
647 
648  $in = $ilDB->in('sco_id', $a_scorm_item_ids, false, 'integer');
649 
650  // Why does this query use a like search against "passed" and "failed"
651  //because it's clob and we support Oracle
652  $res = $ilDB->queryF(
653  '
654  SELECT user_id, COUNT(user_id) completed FROM scorm_tracking
655  WHERE ' . $in . '
656  AND obj_id = %s
657  AND lvalue = %s
658  AND (' . $ilDB->like('rvalue', 'clob', 'completed') . ' OR ' . $ilDB->like('rvalue', 'clob', 'passed') . ')
659  GROUP BY user_id',
660  array('integer', 'text'),
661  array($a_obj_id, 'cmi.core.lesson_status')
662  );
663  while ($row = $ilDB->fetchObject($res)) {
664  $users[$row->user_id] = $row->completed;
665  }
666  return $users ? $users : array();
667  }
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
$users
Definition: authpage.php:44
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
global $ilDB
+ Here is the caller graph for this function:

◆ _getFailed()

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

like necessary because of Oracle

Parameters
object$scorm_item_id
object$a_obj_id
Returns

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

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

603  {
604  global $ilDB;
605 
606  if (is_array($scorm_item_id)) {
607  $in = $ilDB->in('sco_id', $scorm_item_id, false, 'integer');
608 
609  $res = $ilDB->queryF(
610  '
611  SELECT DISTINCT(user_id) FROM scorm_tracking
612  WHERE ' . $in . '
613  AND obj_id = %s
614  AND lvalue = %s
615  AND ' . $ilDB->like('rvalue', 'clob', 'failed') . ' ',
616  array('integer','text'),
617  array($a_obj_id,'cmi.core.lesson_status')
618  );
619  } else {
620  $res = $ilDB->queryF(
621  '
622  SELECT DISTINCT(user_id) FROM scorm_tracking
623  WHERE sco_id = %s
624  AND obj_id = %s
625  AND lvalue = %s
626  AND ' . $ilDB->like('rvalue', 'clob', 'failed') . ' ',
627  array('integer','integer','text'),
628  array($scorm_item_id,$a_obj_id,'cmi.core.lesson_status')
629  );
630  }
631 
632  while ($row = $ilDB->fetchObject($res)) {
633  $user_ids[] = $row->user_id;
634  }
635  return $user_ids ? $user_ids : array();
636  }
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
global $ilDB

◆ _getInProgress()

static ilObjSCORMTracking::_getInProgress (   $scorm_item_id,
  $a_obj_id,
  $a_blocked_user_ids = null 
)
static
Parameters
object$scorm_item_id
object$a_obj_id
array$a_blocked_user_ids
Returns

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

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

Referenced by _getProgressInfo().

398  {
399  global $ilDB;
400 
401  if (is_array($scorm_item_id)) {
402  $in = $ilDB->in('sco_id', $scorm_item_id, false, 'integer');
403 
404  $res = $ilDB->queryF(
405  'SELECT user_id,sco_id FROM scorm_tracking
406  WHERE ' . $in . '
407  AND obj_id = %s
408  GROUP BY user_id, sco_id',
409  array('integer'),
410  array($a_obj_id)
411  );
412  } else {
413  $res = $ilDB->queryF(
414  'SELECT user_id,sco_id FROM scorm_tracking
415  WHERE sco_id = %s
416  AND obj_id = %s',
417  array('integer','integer'),
418  array($scorm_item_id,$a_obj_id)
419  );
420  }
421 
422  $in_progress = array();
423 
424  while ($row = $ilDB->fetchObject($res)) {
425  // #15061 - see _getProgressInfo()
426  if (!($a_blocked_user_ids &&
427  is_array($a_blocked_user_ids[$row->sco_id]) &&
428  in_array($row->user_id, $a_blocked_user_ids[$row->sco_id]))) {
429  $in_progress[$row->sco_id][] = $row->user_id;
430  }
431  }
432  return $in_progress;
433  }
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
global $ilDB
+ Here is the caller graph for this function:

◆ _getProgressInfo()

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

Get info about.

Parameters
object$sco_item_ids
object$a_obj_id
Returns

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

References $ilDB, $in, $info, $res, $row, _getInProgress(), and array.

Referenced by ilLPStatusSCORM\_getStatusInfo().

676  {
677  global $ilDB;
678 
679  $in = $ilDB->in('sco_id', $sco_item_ids, false, 'integer');
680 
681  $res = $ilDB->queryF(
682  '
683  SELECT * FROM scorm_tracking
684  WHERE ' . $in . '
685  AND obj_id = %s
686  AND lvalue = %s ',
687  array('integer','text'),
688  array($a_obj_id,'cmi.core.lesson_status')
689  );
690 
691  $info['completed'] = array();
692  $info['failed'] = array();
693 
694  $user_ids = array();
695  while ($row = $ilDB->fetchObject($res)) {
696  switch ($row->rvalue) {
697  case 'completed':
698  case 'passed':
699  $info['completed'][$row->sco_id][] = $row->user_id;
700  $user_ids[$row->sco_id][] = $row->user_id;
701  break;
702 
703  case 'failed':
704  $info['failed'][$row->sco_id][] = $row->user_id;
705  $user_ids[$row->sco_id][] = $row->user_id;
706  break;
707  }
708  }
709  $info['in_progress'] = ilObjSCORMTracking::_getInProgress($sco_item_ids, $a_obj_id, $user_ids);
710 
711  return $info;
712  }
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
static _getInProgress($scorm_item_id, $a_obj_id, $a_blocked_user_ids=null)
global $ilDB
$info
Definition: index.php:5
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _getTrackedUsers()

static ilObjSCORMTracking::_getTrackedUsers (   $a_obj_id)
static

Get all tracked users.

Parameters
object$a_obj_id
Returns

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

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

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

578  {
579  global $ilDB, $ilLog;
580 
581  $res = $ilDB->queryF(
582  'SELECT DISTINCT user_id FROM scorm_tracking
583  WHERE obj_id = %s
584  AND lvalue = %s',
585  array('integer','text'),
586  array($a_obj_id,'cmi.core.lesson_status')
587  );
588 
589  $users = array();
590  while ($row = $ilDB->fetchAssoc($res)) {
591  $users[] = $row["user_id"];
592  }
593  return $users;
594  }
foreach($_POST as $key=> $value) $res
Create styles array
The data for the language used.
$users
Definition: authpage.php:44
global $ilDB
+ Here is the caller graph for this function:

◆ _insertTrackData()

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

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

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

Referenced by ilSCORMItem\insertTrackData().

372  {
373  global $ilDB, $ilUser;
374 
375  $ilDB->insert('scorm_tracking', array(
376  'obj_id' => array('integer', $a_obj_id),
377  'user_id' => array('integer', $ilUser->getId()),
378  'sco_id' => array('integer', $a_sahs_id),
379  'lvalue' => array('text', $a_lval),
380  'rvalue' => array('clob', $a_rval),
381  'c_timestamp' => array('timestamp', ilUtil::now())
382  ));
383 
384  if ($a_lval == "cmi.core.lesson_status") {
385  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
386  ilLPStatusWrapper::_updateStatus($a_obj_id, $ilUser->getId());
387  }
388  }
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
static now()
Return current timestamp in Y-m-d H:i:s format.
$ilUser
Definition: imgupload.php:18
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _syncReadEvent()

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

Synch read event table.

Parameters

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

References $a_type, $ilDB, $ilLog, $time, ilChangeEvent\_recordReadEvent(), and array.

Referenced by scorm12PlayerUnload(), and store().

323  {
324  global $ilDB, $ilLog;
325  $val_set = $ilDB->queryF(
326  'SELECT package_attempts, total_time_sec, sco_total_time_sec, time_from_lms FROM sahs_user, sahs_lm '
327  . 'WHERE sahs_user.obj_id = %s AND sahs_user.user_id = %s AND sahs_user.obj_id = sahs_lm.id',
328  array('integer','integer'),
329  array($a_obj_id,$a_user_id)
330  );
331 
332  $val_rec = $ilDB->fetchAssoc($val_set);
333 
334  if ($val_rec["package_attempts"] == null) {
335  $val_rec["package_attempts"]="";
336  }
337  $attempts = $val_rec["package_attempts"];
338 
339  $time = 0;
340  // if ($val_rec["time_from_lms"] == "y") {
341  // $time = (int)$val_rec["total_time_sec"];
342  // } else {
343  $time = (int) $val_rec["sco_total_time_sec"];
344  // }
345 
346  // get learning time for old ILIAS-Versions
347  if ($time == 0) {
348  $sco_set = $ilDB->queryF(
349  '
350  SELECT sco_id, rvalue FROM scorm_tracking
351  WHERE obj_id = %s
352  AND user_id = %s
353  AND lvalue = %s
354  AND sco_id <> %s',
355  array('integer','integer','text','integer'),
356  array($a_obj_id,$a_user_id, 'cmi.core.total_time',0)
357  );
358 
359  while ($sco_rec = $ilDB->fetchAssoc($sco_set)) {
360  $tarr = explode(":", $sco_rec["rvalue"]);
361  $sec = (int) $tarr[2] + (int) $tarr[1] * 60 +
362  (int) substr($tarr[0], strlen($tarr[0]) - 3) * 60 * 60;
363  $time += $sec;
364  }
365  }
366 
367  include_once("./Services/Tracking/classes/class.ilChangeEvent.php");
368  ilChangeEvent::_recordReadEvent($a_type, $a_ref_id, $a_obj_id, $a_user_id, false, $attempts, $time);
369  }
static _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.
$time
Definition: cron.php:21
$a_type
Definition: workflow.php:92
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkIfAllowed()

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

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

References $ilDB, $packageId, $res, array, and date.

744  {
745  global $ilDB;
746  $res = $ilDB->queryF(
747  'select hash from sahs_user where obj_id=%s AND user_id=%s AND hash_end>%s',
748  array('integer','integer','timestamp'),
749  array($packageId,$userId,date('Y-m-d H:i:s'))
750  );
751  $rowtmp=$ilDB->fetchAssoc($res);
752  if ($rowtmp['hash']==$hash) {
753  return;
754  } else {
755  die("not allowed");
756  }
757  }
foreach($_POST as $key=> $value) $res
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Create styles array
The data for the language used.
global $ilDB
$packageId

◆ extractData()

ilObjSCORMTracking::extractData ( )

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

References $_GET, $_POST, $key, array, and League\Flysystem\Adapter\Polyfill\update().

Referenced by store().

15  {
16  $this->insert = array();
17  if (is_array($_GET["iL"])) {
18  foreach ($_GET["iL"] as $key => $value) {
19  $this->insert[] = array("left" => $value, "right" => $_GET["iR"][$key]);
20  }
21  }
22  if (is_array($_POST["iL"])) {
23  foreach ($_POST["iL"] as $key => $value) {
24  $this->insert[] = array("left" => $value, "right" => $_POST["iR"][$key]);
25  }
26  }
27 
28  $this->update = array();
29  if (is_array($_GET["uL"])) {
30  foreach ($_GET["uL"] as $key => $value) {
31  $this->update[] = array("left" => $value, "right" => $_GET["uR"][$key]);
32  }
33  }
34  if (is_array($_POST["uL"])) {
35  foreach ($_POST["uL"] as $key => $value) {
36  $this->update[] = array("left" => $value, "right" => $_POST["uR"][$key]);
37  }
38  }
39  }
$_GET["client_id"]
Create styles array
The data for the language used.
update($pash, $contents, Config $config)
$key
Definition: croninfo.php:18
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ lookupLastAccessTimes()

static ilObjSCORMTracking::lookupLastAccessTimes (   $a_obj_id)
static

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

Parameters
int$a_obj_id
Returns
array

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

References $ilDB, $query, $res, $row, $users, array, and ilDBConstants\FETCHMODE_OBJECT.

555  {
556  global $ilDB;
557 
558  $query = 'SELECT user_id, MAX(c_timestamp) tst ' .
559  'FROM scorm_tracking ' .
560  'WHERE obj_id = ' . $ilDB->quote($a_obj_id, 'integer') . ' ' .
561  'GROUP BY user_id';
562  $res = $ilDB->query($query);
563 
564  $users = array();
565  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
566  $users[$row->user_id] = $row->tst;
567  }
568  return $users;
569  }
foreach($_POST as $key=> $value) $res
$query
Create styles array
The data for the language used.
$users
Definition: authpage.php:44
global $ilDB

◆ scorm12PlayerUnload()

static ilObjSCORMTracking::scorm12PlayerUnload ( )
static

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

References $_GET, $_POST, $GLOBALS, $ilDB, $ilUser, _syncReadEvent(), array, date, and header.

715  {
716  global $ilUser, $ilDB;
717 
718  //$user_id = $ilUser->getID();
719  $user_id = (int) $_GET["p"];
720  $ref_id = (int) $_GET["ref_id"];
721  // $obj_id = ilObject::_lookupObjId($ref_id);
722  $obj_id = (int) $_GET["package_id"];
723  if ($obj_id <= 1) {
724  $GLOBALS['ilLog']->write(__METHOD__ . ' no valid obj_id');
725  } else {
726  $last_visited=$_POST['last_visited'];
727  $endDate = date('Y-m-d H:i:s', mktime(date('H'), date('i')+5, date('s'), date('m'), date('d'), date('Y')));
728  $ilDB->manipulateF(
729  'UPDATE sahs_user
730  SET last_visited = %s, hash_end =%s, last_access = %s
731  WHERE obj_id = %s AND user_id = %s',
732  array('text', 'timestamp', 'timestamp', 'integer', 'integer'),
733  array($last_visited, $endDate, date('Y-m-d H:i:s'), $obj_id, $user_id)
734  );
735  // update time and numbers of attempts in change event
736  //NOTE: here it is correct (not count of commit with changed values); be careful to performance issues
737  ilObjSCORMTracking::_syncReadEvent($obj_id, $user_id, "sahs", $ref_id);
738  }
739  header('Content-Type: text/plain; charset=UTF-8');
740  print("");
741  }
$_GET["client_id"]
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$ilUser
Definition: imgupload.php:18
Add a drawing to the header
Definition: 04printing.php:69
static _syncReadEvent($a_obj_id, $a_user_id, $a_type, $a_ref_id)
Synch read event table.
Create styles array
The data for the language used.
global $ilDB
$_POST["username"]
+ Here is the call graph for this function:

◆ store()

ilObjSCORMTracking::store (   $obj_id = 0,
  $sahs_id = 0,
  $extractData = 1 
)

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

References $_GET, $_POST, $ilDB, $ilUser, $insert, ilObject\_lookupObjId(), _syncReadEvent(), ilLPStatusWrapper\_updateStatus(), array, extractData(), ilUtil\now(), and League\Flysystem\Adapter\Polyfill\update().

42  {
43  global $ilDB, $ilUser;
44 
45  $ref_id = $_GET["ref_id"];
46  if (empty($obj_id)) {
47  $obj_id = ilObject::_lookupObjId($_GET["ref_id"]);
48  }
49 
50  // writing to scorm test log
51  $f = fopen("./Modules/ScormAicc/log/scorm.log", "a");
52  fwrite($f, "\nCALLING SCORM store()\n");
53  fwrite($f, 'POST: ' . print_r($_POST, true));
54 
55 
56  if (empty($sahs_id)) {
57  $sahs_id = ($_GET["sahs_id"] != "") ? $_GET["sahs_id"] : $_POST["sahs_id"];
58  }
59 
60  if ($extractData==1) {
61  $this->extractData();
62  }
63 
64  if (is_object($ilUser)) {
65  $user_id = $ilUser->getId();
66  }
67 
68 
69 
70  if ($obj_id <= 1) {
71  fwrite($f, "Error: No obj_id given.\n");
72  } else {
73  foreach ($this->insert as $insert) {
74  $set = $ilDB->queryF(
75  '
76  SELECT * FROM scorm_tracking
77  WHERE user_id = %s
78  AND sco_id = %s
79  AND lvalue = %s
80  AND obj_id = %s',
81  array('integer','integer','text','integer'),
82  array($user_id,$sahs_id,$insert["left"],$obj_id)
83  );
84  if ($rec = $ilDB->fetchAssoc($set)) {
85  fwrite($f, "Error Insert, left value already exists. L:" . $insert["left"] . ",R:" .
86  $insert["right"] . ",sahs_id:" . $sahs_id . ",user_id:" . $user_id . "\n");
87  } else {
88  $ilDB->insert('scorm_tracking', array(
89  'obj_id' => array('integer', $obj_id),
90  'user_id' => array('integer', $user_id),
91  'sco_id' => array('integer', $sahs_id),
92  'lvalue' => array('text', $insert["left"]),
93  'rvalue' => array('clob', $insert["right"]),
94  'c_timestamp' => array('timestamp', ilUtil::now())
95  ));
96 
97  fwrite($f, "Insert - L:" . $insert["left"] . ",R:" .
98  $insert["right"] . ",sahs_id:" . $sahs_id . ",user_id:" . $user_id . "\n");
99  }
100  }
101  foreach ($this->update as $update) {
102  $set = $ilDB->queryF(
103  '
104  SELECT * FROM scorm_tracking
105  WHERE user_id = %s
106  AND sco_id = %s
107  AND lvalue = %s
108  AND obj_id = %s',
109  array('integer','integer','text','integer'),
110  array($user_id,$sahs_id,$update["left"],$obj_id)
111  );
112 
113  if ($rec = $ilDB->fetchAssoc($set)) {
114  $ilDB->update(
115  'scorm_tracking',
116  array(
117  'rvalue' => array('clob', $update["right"]),
118  'c_timestamp' => array('timestamp', ilUtil::now())
119  ),
120  array(
121  'user_id' => array('integer', $user_id),
122  'sco_id' => array('integer', $sahs_id),
123  'lvalue' => array('text', $update["left"]),
124  'obj_id' => array('integer', $obj_id)
125  )
126  );
127  } else {
128  fwrite($f, "ERROR Update, left value does not exist. L:" . $update["left"] . ",R:" .
129  $update["right"] . ",sahs_id:" . $sahs_id . ",user_id:" . $user_id . "\n");
130  }
131  }
132  }
133  fclose($f);
134 
135  // update status
136  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
137  ilLPStatusWrapper::_updateStatus($obj_id, $user_id);
138 
139  // update time and numbers of attempts in change event
140  //NOTE: is possibly not correct (it is count of commit with changed values); be careful to performance issues
141  ilObjSCORMTracking::_syncReadEvent($obj_id, $user_id, "sahs", $ref_id);
142  }
$_GET["client_id"]
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
static now()
Return current timestamp in Y-m-d H:i:s format.
static _lookupObjId($a_id)
$ilUser
Definition: imgupload.php:18
static _syncReadEvent($a_obj_id, $a_user_id, $a_type, $a_ref_id)
Synch read event table.
Create styles array
The data for the language used.
update($pash, $contents, Config $config)
global $ilDB
$_POST["username"]
$insert
+ Here is the call graph for this function:

◆ storeJsApi()

static ilObjSCORMTracking::storeJsApi (   $obj_id = 0)
static

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

References $_GET, $data, $in, and header.

145  {
146  // global $ilLog, $ilUser;
147 
148  // if (is_object($ilUser)) {
149  // $user_id = $ilUser->getId();
150  // }
151  // if (empty($obj_id)) $obj_id = ilObject::_lookupObjId($_GET["ref_id"]);
152  $obj_id = (int) $_GET["package_id"];
153  $in = file_get_contents("php://input");
154  // $ilLog->write($in);
155  $data = json_decode($in);
156  $user_id = (int) $data->p;
157 
158  header('Content-Type: text/plain; charset=UTF-8');
159 
160  $rval=self::storeJsApiCmi($user_id, $obj_id, $data);
161  if ($rval!=true) {
162  print("storeJsApiCmi failed");
163  } else {
164  $rval=self::syncGlobalStatus($user_id, $obj_id, $data, $data->now_global_status);
165  if ($rval!=true) {
166  print("syncGlobalStatus failed");
167  }
168  }
169  if ($rval==true) {
170  print("ok");
171  }
172  }
$_GET["client_id"]
Add a drawing to the header
Definition: 04printing.php:69
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37

◆ storeJsApiCmi()

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

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

References $_POST, $data, $i, $ilDB, $ilLog, array, and ilUtil\now().

Referenced by ilSCORMOfflineMode\sop2il().

175  {
176  global $ilLog, $ilDB;
177 
178  $b_updateStatus=false;
179 
180  $b_messageLog=false;
181  if ($ilLog->current_log_level == 30) {
182  $b_messageLog=true;
183  }
184 
185  if ($b_messageLog) {
186  $ilLog->write("ScormAicc: CALLING SCORM storeJsApi() " . $_POST);
187  }
188 
189 
190  $aa_data = array();
191  // if (is_array($_POST["S"])) {
192  // foreach($_POST["S"] as $key => $value) {
193  // $aa_data[] = array("sco_id" => $value, "left" => $_POST["L"][$key], "right" => $_POST["R"][$key]);
194  // }
195  // }
196  for ($i=0;$i<count($data->cmi);$i++) {
197  $aa_data[] = array("sco_id" => (int) $data->cmi[$i][0], "left" => $data->cmi[$i][1], "right" => $data->cmi[$i][2]);
198  // $aa_data[] = array("sco_id" => (int) $data->cmi[$i][0], "left" => $data->cmi[$i][1], "right" => rawurldecode($data->cmi[$i][2]));
199  }
200 
201  if ($obj_id <= 1) {
202  $ilLog->write("ScormAicc: storeJsApi: Error: No valid obj_id given.");
203  } else {
204  foreach ($aa_data as $a_data) {
205  $set = $ilDB->queryF(
206  '
207  SELECT rvalue FROM scorm_tracking
208  WHERE user_id = %s
209  AND sco_id = %s
210  AND lvalue = %s
211  AND obj_id = %s',
212  array('integer','integer','text','integer'),
213  array($user_id,$a_data["sco_id"],$a_data["left"],$obj_id)
214  );
215  if ($rec = $ilDB->fetchAssoc($set)) {
216  if ($a_data["left"] == 'cmi.core.lesson_status' && $a_data["right"] != $rec["rvalue"]) {
217  $b_updateStatus = true;
218  }
219  $ilDB->update(
220  'scorm_tracking',
221  array(
222  'rvalue' => array('clob', $a_data["right"]),
223  'c_timestamp' => array('timestamp', ilUtil::now())
224  ),
225  array(
226  'user_id' => array('integer', $user_id),
227  'sco_id' => array('integer', $a_data["sco_id"]),
228  'lvalue' => array('text', $a_data["left"]),
229  'obj_id' => array('integer', $obj_id)
230  )
231  );
232  if ($b_messageLog) {
233  $ilLog->write("ScormAicc: storeJsApi Updated - L:" . $a_data["left"] . ",R:" .
234  $a_data["right"] . " for obj_id:" . $obj_id . ",sco_id:" . $a_data["sco_id"] . ",user_id:" . $user_id);
235  }
236  } else {
237  if ($a_data["left"] == 'cmi.core.lesson_status') {
238  $b_updateStatus = true;
239  }
240  $ilDB->insert('scorm_tracking', array(
241  'obj_id' => array('integer', $obj_id),
242  'user_id' => array('integer', $user_id),
243  'sco_id' => array('integer', $a_data["sco_id"]),
244  'lvalue' => array('text', $a_data["left"]),
245  'rvalue' => array('clob', $a_data["right"]),
246  'c_timestamp' => array('timestamp', ilUtil::now())
247  ));
248  if ($b_messageLog) {
249  $ilLog->write("ScormAicc: storeJsApi Inserted - L:" . $a_data["left"] . ",R:" .
250  $a_data["right"] . " for obj_id:" . $obj_id . ",sco_id:" . $a_data["sco_id"] . ",user_id:" . $user_id);
251  }
252  }
253  }
254  }
255 
256  // update status
257  // if ($b_updateStatus == true) {
258  // include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
259  // ilLPStatusWrapper::_updateStatus($obj_id, $user_id);
260  // }
261 
262  return true;
263  }
static now()
Return current timestamp in Y-m-d H:i:s format.
Create styles array
The data for the language used.
global $ilDB
$i
Definition: disco.tpl.php:19
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ syncGlobalStatus()

static ilObjSCORMTracking::syncGlobalStatus (   $userId,
  $packageId,
  $data,
  $new_global_status 
)
static

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

References $_GET, $data, $ilDB, $ilLog, $packageId, ilChangeEvent\_recordReadEvent(), array, date, and ilLPStatus\writeStatus().

Referenced by ilSCORMOfflineMode\sop2il().

267  {
268  global $ilDB, $ilLog;
269  $saved_global_status=$data->saved_global_status;
270  $ilLog->write("saved_global_status=" . $saved_global_status);
271 
272  // get attempts
273  if (!$data->packageAttempts) {
274  $val_set = $ilDB->queryF(
275  'SELECT package_attempts FROM sahs_user WHERE obj_id = %s AND user_id = %s',
276  array('integer','integer'),
277  array($packageId,$userId)
278  );
279  $val_rec = $ilDB->fetchAssoc($val_set);
280  $attempts = $val_rec["package_attempts"];
281  } else {
282  $attempts=$data->packageAttempts;
283  }
284  if ($attempts == null) {
285  $attempts = 1;
286  }
287 
288  //update percentage_completed, sco_total_time_sec,status in sahs_user
289  $totalTime=(int) $data->totalTimeCentisec;
290  $totalTime=round($totalTime/100);
291  $ilDB->queryF(
292  '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',
293  array('text', 'timestamp', 'integer', 'integer', 'integer', 'integer', 'integer', 'integer'),
294  array($data->last_visited, date('Y-m-d H:i:s'), $totalTime, $new_global_status, $data->percentageCompleted, $attempts, $packageId, $userId)
295  );
296 
297  // self::ensureObjectDataCacheExistence();
298  global $ilObjDataCache;
299  include_once("./Services/Tracking/classes/class.ilChangeEvent.php");
300  ilChangeEvent::_recordReadEvent("sahs", (int) $_GET['ref_id'], $packageId, $userId, false, $attempts, $totalTime);
301 
302  //end sync access number and time in read event table
303 
304  // update learning progress
305  if ($new_global_status != null) {//could only happen when synchronising from SCORM Offline Player
306  include_once("./Services/Tracking/classes/class.ilObjUserTracking.php");
307  include_once("./Services/Tracking/classes/class.ilLPStatus.php");
308  ilLPStatus::writeStatus($packageId, $userId, $new_global_status, $data->percentageCompleted);
309 
310  // here put code for soap to MaxCMS e.g. when if($saved_global_status != $new_global_status)
311  }
312  return true;
313  }
static _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.
$_GET["client_id"]
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
Create styles array
The data for the language used.
static writeStatus($a_obj_id, $a_user_id, $a_status, $a_percentage=false, $a_force_per=false)
Write status for user and object.
global $ilDB
$packageId
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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