ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilObjSCORMTracking Class Reference

Class ilObjSCORMTracking. More...

+ Inheritance diagram for ilObjSCORMTracking:
+ Collaboration diagram for ilObjSCORMTracking:

Public Member Functions

 ilObjSCORMTracking ()
 Constructor public.
 extractData ()
 store ($obj_id=0, $sahs_id=0, $extractData=1)
 storeJsApi ($obj_id=0)
 storeJsApiCmi ($user_id, $obj_id, $data)
 syncGlobalStatus ($userId, $packageId, $data, $new_global_status)
 _syncReadEvent ($a_obj_id, $a_user_id, $a_type, $a_ref_id)
 Synch read event table.
 _insertTrackData ($a_sahs_id, $a_lval, $a_rval, $a_obj_id)
 _getTrackedUsers ($a_obj_id)
 Get all tracked users.
 _getFailed ($scorm_item_id, $a_obj_id)
 like necessary because of Oracle
 scorm12PlayerUnload ()

Static Public Member Functions

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
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)
static lookupLastAccessTimes ($a_obj_id)
 Lookup last acccess time for all users of a scorm module ilDB $ilDB.
static _getCountCompletedPerUser ($a_scorm_item_ids, $a_obj_id)
 Get users who have status completed or passed.
static _getProgressInfo ($sco_item_ids, $a_obj_id)
 Get info about.

Detailed Description

Member Function Documentation

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

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

References $in, and $res.

Referenced by ilLPStatusSCORM\determinePercentage().

{
global $ilDB;
if (is_array($a_scos))
{
$in = $ilDB->in('sco_id', $a_scos, false, 'integer');
$res = $ilDB->queryF('SELECT sco_id, rvalue FROM scorm_tracking
WHERE '.$in.'
AND obj_id = %s
AND lvalue = %s
AND user_id = %s',
array('integer','text', 'integer'),
array($a_obj_id,'cmi.core.lesson_status', $a_user_id));
$cnt = 0;
while ($rec = $ilDB->fetchAssoc($res))
{
if ($rec["rvalue"] == "completed" || $rec["rvalue"] == "passed")
{
$cnt++;
}
}
}
return $cnt;
}

+ Here is the caller graph for this function:

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

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

References $failed, $in, and $res.

Referenced by ilLPStatusSCORM\determineStatus().

{
global $ilDB;
$status = "not_attempted";
if (is_array($a_scos))
{
$in = $ilDB->in('sco_id', $a_scos, false, 'integer');
$res = $ilDB->queryF('SELECT sco_id, rvalue FROM scorm_tracking
WHERE '.$in.'
AND obj_id = %s
AND lvalue = %s
AND user_id = %s',
array('integer','text', 'integer'),
array($a_obj_id,'cmi.core.lesson_status', $a_user_id));
$cnt = 0;
$completed = true;
$failed = false;
while ($rec = $ilDB->fetchAssoc($res))
{
if ($rec["rvalue"] == "failed")
{
$failed = true;
}
if ($rec["rvalue"] != "completed" && $rec["rvalue"] != "passed")
{
$completed = false;
}
$cnt++;
}
if ($cnt > 0)
{
$status = "in_progress";
}
if ($completed && $cnt == count($a_scos))
{
$status = "completed";
}
if ($failed)
{
$status = "failed";
}
// check max attempts
if ($status == "in_progress" && self::_hasMaxAttempts($a_obj_id, $a_user_id))
{
$status = "failed";
}
}
return $status;
}

+ Here is the caller graph for this function:

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 438 of file class.ilObjSCORMTracking.php.

References $in, $res, and $row.

Referenced by ilObjSCORMLearningModule\exportSelected().

{
global $ilDB;
if(is_array($scorm_item_id))
{
$in = $ilDB->in('sco_id', $scorm_item_id, false, 'integer');
$res = $ilDB->queryF('SELECT DISTINCT(user_id) FROM scorm_tracking
WHERE '.$in.'
AND obj_id = %s
AND lvalue = %s
AND ('.$ilDB->like('rvalue', 'clob', 'completed').' OR '.$ilDB->like('rvalue', 'clob', 'passed').')',
array('integer','text'),
array($a_obj_id,'cmi.core.lesson_status'));
}
else
{
$res = $ilDB->queryF('SELECT DISTINCT(user_id) FROM scorm_tracking
WHERE sco_id = %s
AND obj_id = %s
AND lvalue = %s
AND ('.$ilDB->like('rvalue', 'clob', 'completed').' OR '.$ilDB->like('rvalue', 'clob', 'passed').')',
array('integer','integer','text'),
array($scorm_item_id,$a_obj_id,'cmi.core.lesson_status'));
}
while($row = $ilDB->fetchObject($res))
{
$user_ids[] = $row->user_id;
}
return $user_ids ? $user_ids : array();
}

+ Here is the caller graph for this function:

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 692 of file class.ilObjSCORMTracking.php.

References $in, $res, and $row.

Referenced by ilLPStatusSCORM\_getStatusInfo().

{
global $ilDB;
$in = $ilDB->in('sco_id', $a_scorm_item_ids, false, 'integer');
// Why does this query use a like search against "passed" and "failed"
//because it's clob and we support Oracle
$res = $ilDB->queryF('
SELECT user_id, COUNT(user_id) completed FROM scorm_tracking
WHERE '.$in.'
AND obj_id = %s
AND lvalue = %s
AND ('.$ilDB->like('rvalue', 'clob', 'completed').' OR '.$ilDB->like('rvalue', 'clob', 'passed').')
GROUP BY user_id',
array('integer', 'text'),
array($a_obj_id, 'cmi.core.lesson_status')
);
while($row = $ilDB->fetchObject($res))
{
$users[$row->user_id] = $row->completed;
}
/*
// Avoid searches against field rvalue.
// This gives the possibility to reuse the obj_id,sco_id,lvalue index.
$query = "SELECT user_id,rvalue FROM scorm_tracking ".
"WHERE ".$in." ".
"AND obj_id = ".$ilDB->quote($a_obj_id,'integer')." ".
"AND lvalue = ".$ilDB->quote('cmi.core.lesson_status','text');
$res = $ilDB->query($query);
while($row = $ilDB->fetchObject($res))
{
if($row->rvalue == 'passed' or $row->rvalue == 'completed')
{
++$users[$row->user_id];
}
}*/
return $users ? $users : array();
}

+ Here is the caller graph for this function:

ilObjSCORMTracking::_getFailed (   $scorm_item_id,
  $a_obj_id 
)

like necessary because of Oracle

Parameters
object$scorm_item_id
object$a_obj_id
Returns

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

References $in, $res, and $row.

{
global $ilDB;
if(is_array($scorm_item_id))
{
$in = $ilDB->in('sco_id', $scorm_item_id, false, 'integer');
$res = $ilDB->queryF('
SELECT DISTINCT(user_id) FROM scorm_tracking
WHERE '.$in.'
AND obj_id = %s
AND lvalue = %s
AND '.$ilDB->like('rvalue', 'clob', 'failed').' ',
array('integer','text'),
array($a_obj_id,'cmi.core.lesson_status'));
}
else
{
$res = $ilDB->queryF('
SELECT DISTINCT(user_id) FROM scorm_tracking
WHERE sco_id = %s
AND obj_id = %s
AND lvalue = %s
AND '.$ilDB->like('rvalue', 'clob', 'failed').' ',
array('integer','integer','text'),
array($scorm_item_id,$a_obj_id,'cmi.core.lesson_status'));
}
while($row = $ilDB->fetchObject($res))
{
$user_ids[] = $row->user_id;
}
return $user_ids ? $user_ids : array();
}
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 $in, $res, and $row.

Referenced by _getProgressInfo().

{
global $ilDB;
if(is_array($scorm_item_id))
{
$in = $ilDB->in('sco_id', $scorm_item_id, false, 'integer');
$res = $ilDB->queryF('SELECT user_id,sco_id FROM scorm_tracking
WHERE '.$in.'
AND obj_id = %s
GROUP BY user_id, sco_id',
array('integer'),array($a_obj_id));
}
else
{
$res = $ilDB->queryF('SELECT user_id,sco_id FROM scorm_tracking
WHERE sco_id = %s
AND obj_id = %s',
array('integer','integer'),array($scorm_item_id,$a_obj_id)
);
}
while($row = $ilDB->fetchObject($res))
{
// see _getProgressInfo()
if(!($a_blocked_user_ids && in_array($row->user_id, $a_blocked_user_ids)))
{
$in_progress[$row->sco_id][] = $row->user_id;
}
}
return is_array($in_progress) ? $in_progress : array();
}

+ Here is the caller graph for this function:

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 739 of file class.ilObjSCORMTracking.php.

References $in, $res, $row, and _getInProgress().

Referenced by ilLPStatusSCORM\_getStatusInfo().

{
global $ilDB;
$in = $ilDB->in('sco_id', $sco_item_ids, false, 'integer');
$res = $ilDB->queryF('
SELECT * FROM scorm_tracking
WHERE '.$in.'
AND obj_id = %s
AND lvalue = %s ',
array('integer','text'),
array($a_obj_id,'cmi.core.lesson_status'));
$info['completed'] = array();
$info['failed'] = array();
$user_ids = array();
while($row = $ilDB->fetchObject($res))
{
switch($row->rvalue)
{
case 'completed':
case 'passed':
$info['completed'][$row->sco_id][] = $row->user_id;
$user_ids[] = $row->user_id;
break;
case 'failed':
$info['failed'][$row->sco_id][] = $row->user_id;
$user_ids[] = $row->user_id;
break;
}
}
$info['in_progress'] = ilObjSCORMTracking::_getInProgress($sco_item_ids,$a_obj_id,$user_ids);
return $info;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSCORMTracking::_getTrackedUsers (   $a_obj_id)

Get all tracked users.

Parameters
object$a_obj_id
Returns

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

References $ilLog, $res, and $row.

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

{
global $ilDB, $ilLog;
$res = $ilDB->queryF('SELECT DISTINCT user_id FROM scorm_tracking
WHERE obj_id = %s
AND lvalue = %s',
array('integer','text'),
array($a_obj_id,'cmi.core.lesson_status'));
$users = array();
while ($row = $ilDB->fetchAssoc($res))
{
$users[] = $row["user_id"];
}
return $users;
}

+ Here is the caller graph for this function:

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

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

Referenced by ilLPStatusSCORM\_getFailed().

{
global $ilDB;
// see ilSCORMPresentationGUI
$val_set = $ilDB->queryF('SELECT * FROM sahs_lm WHERE id = %s',
array('integer'), array($a_obj_id));
$val_rec = $ilDB->fetchAssoc($val_set);
$max_attempts = $val_rec["max_attempt"];
if ($max_attempts)
{
$val_set = $ilDB->queryF('
SELECT * FROM scorm_tracking
WHERE user_id = %s
AND sco_id = %s
AND lvalue= %s
AND obj_id = %s',
array('integer','integer','text','integer'),
array($a_user_id,0,'package_attempts',$a_obj_id)
);
$val_rec = $ilDB->fetchAssoc($val_set);
$val_rec["rvalue"] = str_replace("\r\n", "\n", $val_rec["rvalue"]);
if ($val_rec["rvalue"] == null)
{
$val_rec["rvalue"] = 0;
}
$act_attempts = $val_rec["rvalue"];
if ($act_attempts >= $max_attempts)
{
return true;
}
}
return false;
}

+ Here is the caller graph for this function:

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

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

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

Referenced by ilSCORMItem\insertTrackData(), ilAICCUnit\insertTrackData(), and ilAICCCourse\insertTrackData().

{
global $ilDB, $ilUser;
$ilDB->insert('scorm_tracking', array(
'obj_id' => array('integer', $a_obj_id),
'user_id' => array('integer', $ilUser->getId()),
'sco_id' => array('integer', $a_sahs_id),
'lvalue' => array('text', $a_lval),
'rvalue' => array('clob', $a_rval),
'c_timestamp' => array('timestamp', ilUtil::now())
));
if ($a_lval == "cmi.core.lesson_status")
{
include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
ilLPStatusWrapper::_updateStatus($a_obj_id, $ilUser->getId());
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Synch read event table.

Parameters
@return

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

References $ilLog, and ilChangeEvent\_recordReadEvent().

Referenced by scorm12PlayerUnload(), and store().

{
global $ilDB, $ilLog;
//TODO: use sahs_user in future!! Especially for learningTime!
// get attempts
$val_set = $ilDB->queryF('SELECT package_attempts FROM sahs_user WHERE obj_id = %s AND user_id = %s',
array('integer','integer'),
array($a_obj_id,$a_user_id));
$val_rec = $ilDB->fetchAssoc($val_set);
if ($val_rec["package_attempts"] == null) {
$val_rec["package_attempts"]="";
}
$attempts = $val_rec["package_attempts"];
// get learning time
$sco_set = $ilDB->queryF('
SELECT sco_id, rvalue FROM scorm_tracking
WHERE obj_id = %s
AND user_id = %s
AND lvalue = %s
AND sco_id <> %s',
array('integer','integer','text','integer'),
array($a_obj_id,$a_user_id, 'cmi.core.total_time',0));
$time = 0;
while($sco_rec = $ilDB->fetchAssoc($sco_set))
{
$tarr = explode(":", $sco_rec["rvalue"]);
$sec = (int) $tarr[2] + (int) $tarr[1] * 60 +
(int) substr($tarr[0], strlen($tarr[0]) - 3) * 60 * 60;
$time += $sec;
}
include_once("./Services/Tracking/classes/class.ilChangeEvent.php");
ilChangeEvent::_recordReadEvent($a_type, $a_ref_id, $a_obj_id, $a_user_id, false, $attempts, $time);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSCORMTracking::extractData ( )

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

References $_GET, and $_POST.

Referenced by store().

{
$this->insert = array();
if (is_array($_GET["iL"]))
{
foreach($_GET["iL"] as $key => $value)
{
$this->insert[] = array("left" => $value, "right" => $_GET["iR"][$key]);
}
}
if (is_array($_POST["iL"]))
{
foreach($_POST["iL"] as $key => $value)
{
$this->insert[] = array("left" => $value, "right" => $_POST["iR"][$key]);
}
}
$this->update = array();
if (is_array($_GET["uL"]))
{
foreach($_GET["uL"] as $key => $value)
{
$this->update[] = array("left" => $value, "right" => $_GET["uR"][$key]);
}
}
if (is_array($_POST["uL"]))
{
foreach($_POST["uL"] as $key => $value)
{
$this->update[] = array("left" => $value, "right" => $_POST["uR"][$key]);
}
}
}

+ Here is the caller graph for this function:

ilObjSCORMTracking::ilObjSCORMTracking ( )

Constructor public.

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

{
global $ilias;
}
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 601 of file class.ilObjSCORMTracking.php.

References $query, $res, $row, and DB_FETCHMODE_OBJECT.

Referenced by ilObjSCORMLearningModule\exportSelected().

{
global $ilDB;
$query = 'SELECT user_id, MAX(c_timestamp) tst '.
'FROM scorm_tracking '.
'WHERE obj_id = '.$ilDB->quote($a_obj_id,'integer').' '.
'GROUP BY user_id';
$res = $ilDB->query($query);
$users = array();
while($row = $res->fetchRow(DB_FETCHMODE_OBJECT))
{
$users[$row->user_id] = $row->tst;
}
return $users;
}

+ Here is the caller graph for this function:

ilObjSCORMTracking::scorm12PlayerUnload ( )

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

References $_GET, $_POST, $GLOBALS, $ilUser, $ref_id, ilObject\_lookupObjId(), and _syncReadEvent().

{
global $ilUser, $ilDB;
$user_id = $ilUser->getID();
$ref_id = $_GET["ref_id"];
if ($obj_id <= 1){
$GLOBALS['ilLog']->write(__METHOD__.' no valid obj_id');
} else {
$last_visited=$_POST['last_visited'];
$ilDB->manipulateF('UPDATE sahs_user
SET last_visited = %s, last_access = %s
WHERE obj_id = %s AND user_id = %s',
array('text', 'timestamp', 'integer', 'integer'),
array($last_visited, date('Y-m-d H:i:s'), $obj_id, $user_id)
);
// $data=$_POST['last_visited'];
// $GLOBALS['ilLog']->write(__METHOD__.' last_visited: '.$data);
// if($data) {
// $set = $ilDB->queryF('
// SELECT rvalue FROM scorm_tracking
// WHERE user_id = %s
// AND sco_id = %s
// AND lvalue = %s
// AND obj_id = %s',
// array('integer','integer','text','integer'),
// array($user_id,0,'last_visited',$obj_id));
// if ($rec = $ilDB->fetchAssoc($set)) {
// $ilDB->update('scorm_tracking',
// array(
// 'rvalue' => array('clob', $data),
// 'c_timestamp' => array('timestamp', ilUtil::now())
// ),
// array(
// 'user_id' => array('integer', $user_id),
// 'sco_id' => array('integer', 0),
// 'lvalue' => array('text', 'last_visited'),
// 'obj_id' => array('integer', $obj_id)
// )
// );
// }
// else {
// $ilDB->insert('scorm_tracking', array(
// 'obj_id' => array('integer', $obj_id),
// 'user_id' => array('integer', $user_id),
// 'sco_id' => array('integer', 0),
// 'lvalue' => array('text', 'last_visited'),
// 'rvalue' => array('clob', $data),
// 'c_timestamp' => array('timestamp', ilUtil::now())
// ));
// }
// }
// update time and numbers of attempts in change event
//NOTE: here it is correct (not count of commit with changed values); be careful to performance issues
ilObjSCORMTracking::_syncReadEvent($obj_id, $user_id, "sahs", $ref_id);
}
header('Content-Type: text/plain; charset=UTF-8');
print("");
}

+ Here is the call graph for this function:

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

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

References $_GET, $_POST, $ilUser, $ref_id, ilObject\_lookupObjId(), _syncReadEvent(), ilLPStatusWrapper\_updateStatus(), extractData(), and ilUtil\now().

Referenced by ilObjHACPTracking\putparam().

{
global $ilDB, $ilUser;
$ref_id = $_GET["ref_id"];
if (empty($obj_id))
{
$obj_id = ilObject::_lookupObjId($_GET["ref_id"]);
}
// writing to scorm test log
$f = fopen("./Modules/ScormAicc/log/scorm.log", "a");
fwrite($f, "\nCALLING SCORM store()\n");
fwrite($f,'POST: '.print_r($_POST,true));
if (empty($sahs_id))
$sahs_id = ($_GET["sahs_id"] != "") ? $_GET["sahs_id"] : $_POST["sahs_id"];
if ($extractData==1)
$this->extractData();
if (is_object($ilUser))
{
$user_id = $ilUser->getId();
}
if ($obj_id <= 1)
{
fwrite($f, "Error: No obj_id given.\n");
}
else
{
foreach($this->insert as $insert)
{
$set = $ilDB->queryF('
SELECT * FROM scorm_tracking
WHERE user_id = %s
AND sco_id = %s
AND lvalue = %s
AND obj_id = %s',
array('integer','integer','text','integer'),
array($user_id,$sahs_id,$insert["left"],$obj_id));
if ($rec = $ilDB->fetchAssoc($set))
{
fwrite($f, "Error Insert, left value already exists. L:".$insert["left"].",R:".
$insert["right"].",sahs_id:".$sahs_id.",user_id:".$user_id."\n");
}
else
{
$ilDB->insert('scorm_tracking', array(
'obj_id' => array('integer', $obj_id),
'user_id' => array('integer', $user_id),
'sco_id' => array('integer', $sahs_id),
'lvalue' => array('text', $insert["left"]),
'rvalue' => array('clob', $insert["right"]),
'c_timestamp' => array('timestamp', ilUtil::now())
));
fwrite($f, "Insert - L:".$insert["left"].",R:".
$insert["right"].",sahs_id:".$sahs_id.",user_id:".$user_id."\n");
}
}
foreach($this->update as $update)
{
$set = $ilDB->queryF('
SELECT * FROM scorm_tracking
WHERE user_id = %s
AND sco_id = %s
AND lvalue = %s
AND obj_id = %s',
array('integer','integer','text','integer'),
array($user_id,$sahs_id,$update["left"],$obj_id));
if ($rec = $ilDB->fetchAssoc($set))
{
$ilDB->update('scorm_tracking',
array(
'rvalue' => array('clob', $update["right"]),
'c_timestamp' => array('timestamp', ilUtil::now())
),
array(
'user_id' => array('integer', $user_id),
'sco_id' => array('integer', $sahs_id),
'lvalue' => array('text', $update["left"]),
'obj_id' => array('integer', $obj_id)
)
);
}
else
{
fwrite($f, "ERROR Update, left value does not exist. L:".$update["left"].",R:".
$update["right"].",sahs_id:".$sahs_id.",user_id:".$user_id."\n");
}
}
}
fclose($f);
// update status
include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
// update time and numbers of attempts in change event
//NOTE: is possibly not correct (it is count of commit with changed values); be careful to performance issues
ilObjSCORMTracking::_syncReadEvent($obj_id, $user_id, "sahs", $ref_id);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSCORMTracking::storeJsApi (   $obj_id = 0)

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

References $_GET, $ilLog, $ilUser, $in, ilObject\_lookupObjId(), storeJsApiCmi(), and syncGlobalStatus().

{
global $ilLog, $ilUser;
if (is_object($ilUser)) {
$user_id = $ilUser->getId();
}
if (empty($obj_id)) $obj_id = ilObject::_lookupObjId($_GET["ref_id"]);
$in = file_get_contents("php://input");
$ilLog->write($in);
$data = json_decode($in);
header('Content-Type: text/plain; charset=UTF-8');
$rval=self::storeJsApiCmi($user_id,$obj_id,$data);
if($rval!=true) {
print("storeJsApiCmi failed");
} else {
$rval=self::syncGlobalStatus($user_id, $obj_id, $data, $data->now_global_status);
if($rval!=true) print("syncGlobalStatus failed");
}
if($rval==true) print("ok");
}

+ Here is the call graph for this function:

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

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

References $_POST, $ilLog, and ilUtil\now().

Referenced by ilSCORMOfflineMode\sop2il(), and storeJsApi().

{
global $ilLog, $ilDB;
$b_updateStatus=false;
$b_messageLog=false;
if ($ilLog->current_log_level == 30)
$b_messageLog=true;
if ($b_messageLog)
$ilLog->write("ScormAicc: CALLING SCORM storeJsApi() ".$_POST);
$aa_data = array();
// if (is_array($_POST["S"])) {
// foreach($_POST["S"] as $key => $value) {
// $aa_data[] = array("sco_id" => $value, "left" => $_POST["L"][$key], "right" => $_POST["R"][$key]);
// }
// }
for ($i=0;$i<count($data->cmi);$i++) {
$aa_data[] = array("sco_id" => (int) $data->cmi[$i][0], "left" => $data->cmi[$i][1], "right" => $data->cmi[$i][2]);
// $aa_data[] = array("sco_id" => (int) $data->cmi[$i][0], "left" => $data->cmi[$i][1], "right" => rawurldecode($data->cmi[$i][2]));
}
if ($obj_id <= 1) {
$ilLog->write("ScormAicc: storeJsApi: Error: No valid obj_id given.");
}
else {
foreach($aa_data as $a_data) {
$set = $ilDB->queryF('
SELECT rvalue FROM scorm_tracking
WHERE user_id = %s
AND sco_id = %s
AND lvalue = %s
AND obj_id = %s',
array('integer','integer','text','integer'),
array($user_id,$a_data["sco_id"],$a_data["left"],$obj_id));
if ($rec = $ilDB->fetchAssoc($set)) {
if ($a_data["left"] == 'cmi.core.lesson_status' && $a_data["right"] != $rec["rvalue"]) {
$b_updateStatus = true;
}
$ilDB->update('scorm_tracking',
array(
'rvalue' => array('clob', $a_data["right"]),
'c_timestamp' => array('timestamp', ilUtil::now())
),
array(
'user_id' => array('integer', $user_id),
'sco_id' => array('integer', $a_data["sco_id"]),
'lvalue' => array('text', $a_data["left"]),
'obj_id' => array('integer', $obj_id)
)
);
if ($b_messageLog) {
$ilLog->write("ScormAicc: storeJsApi Updated - L:".$a_data["left"].",R:".
$a_data["right"]." for obj_id:".$obj_id.",sco_id:".$a_data["sco_id"].",user_id:".$user_id);
}
}
else {
if ($a_data["left"] == 'cmi.core.lesson_status') {
$b_updateStatus = true;
}
$ilDB->insert('scorm_tracking', array(
'obj_id' => array('integer', $obj_id),
'user_id' => array('integer', $user_id),
'sco_id' => array('integer', $a_data["sco_id"]),
'lvalue' => array('text', $a_data["left"]),
'rvalue' => array('clob', $a_data["right"]),
'c_timestamp' => array('timestamp', ilUtil::now())
));
if ($b_messageLog) {
$ilLog->write("ScormAicc: storeJsApi Inserted - L:".$a_data["left"].",R:".
$a_data["right"]." for obj_id:".$obj_id.",sco_id:".$$a_data["sco_id"].",user_id:".$user_id);
}
}
}
}
// update status
// if ($b_updateStatus == true) {
// include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
// ilLPStatusWrapper::_updateStatus($obj_id, $user_id);
// }
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

References $_GET, $ilLog, ilChangeEvent\_recordReadEvent(), and ilLPStatus\writeStatus().

Referenced by ilSCORMOfflineMode\sop2il(), and storeJsApi().

{
global $ilDB, $ilLog;
$saved_global_status=$data->saved_global_status;
$ilLog->write("saved_global_status=".$saved_global_status);
//last_visited!
// get attempts
if (!$data->packageAttempts) {
$val_set = $ilDB->queryF('SELECT package_attempts FROM sahs_user WHERE obj_id = %s AND user_id = %s',
array('integer','integer'), array($packageId,$userId));
$val_rec = $ilDB->fetchAssoc($val_set);
$attempts = $val_rec["package_attempts"];
} else {
$attempts=$data->packageAttempts;
}
if ($attempts == null) $attempts = 1;
//update percentage_completed, sco_total_time_sec,status in sahs_user
$totalTime=(int)$data->totalTimeCentisec;
$totalTime=round($totalTime/100);
$ilDB->queryF('UPDATE sahs_user SET sco_total_time_sec=%s, status=%s, percentage_completed=%s, package_attempts=%s WHERE obj_id = %s AND user_id = %s',
array('integer', 'integer', 'integer', 'integer', 'integer', 'integer'),
array($totalTime, $new_global_status, $data->percentageCompleted, $attempts, $packageId, $userId));
// self::ensureObjectDataCacheExistence();
global $ilObjDataCache;
include_once("./Services/Tracking/classes/class.ilChangeEvent.php");
ilChangeEvent::_recordReadEvent("sahs", (int)$_GET['ref_id'],$packageId, $userId, false, $attempts, $totalTime);
//end sync access number and time in read event table
// update learning progress
if ($new_global_status != null) {//could only happen when synchronising from SCORM Offline Player
include_once("./Services/Tracking/classes/class.ilObjUserTracking.php");
include_once("./Services/Tracking/classes/class.ilLPStatus.php");
ilLPStatus::writeStatus($packageId, $userId,$new_global_status,$data->percentageCompleted);
// here put code for soap to MaxCMS e.g. when if($saved_global_status != $new_global_status)
}
return true;
}

+ 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: