ILIAS  Release_4_0_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)
 _insertTrackData ($a_sahs_id, $a_lval, $a_rval, $a_obj_id)
 _getFailed ($scorm_item_id, $a_obj_id)
 Redesign required.

Static Public Member Functions

static _getInProgress ($scorm_item_id, $a_obj_id)
 Redesign required.
static _getCompleted ($scorm_item_id, $a_obj_id)
 Redesign required.
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::_getCompleted (   $scorm_item_id,
  $a_obj_id 
)
static

Redesign required.

Todo:
avoid like search against clob field rvalue
Deprecated:
Parameters
object$scorm_item_id
object$a_obj_id
Returns

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

References $ilDB, $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', '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();
}
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 327 of file class.ilObjSCORMTracking.php.

References $ilDB, $in, $query, $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"
/*
$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')
);
*/
// 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 
)

Redesign required.

Todo:
avoid like search against clob field rvalue
Deprecated:
Parameters
object$scorm_item_id
object$a_obj_id
Returns

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

References $ilDB, $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 
)
static

Redesign required.

Todo:
avoid like search against clob field rvalue
Deprecated:
Parameters
object$scorm_item_id
object$a_obj_id
Returns

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

References $ilDB, $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))
{
$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 371 of file class.ilObjSCORMTracking.php.

References $ilDB, $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();
while($row = $ilDB->fetchObject($res))
{
switch($row->rvalue)
{
case 'completed':
case 'passed':
$info['completed'][$row->sco_id][] = $row->user_id;
break;
case 'failed':
$info['failed'][$row->sco_id][] = $row->user_id;
break;
}
}
$info['in_progress'] = ilObjSCORMTracking::_getInProgress($sco_item_ids,$a_obj_id);
return $info;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

References $ilDB, 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())
));
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilObjSCORMTracking::extractData ( )

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

References $_GET, $_POST, and $key.

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

{
global $ilias;
}
ilObjSCORMTracking::store (   $obj_id = 0,
  $sahs_id = 0,
  $extractData = 1 
)

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

References $_GET, $_POST, $f, $ilDB, ilObject\_lookupObjId(), extractData(), and ilUtil\now().

Referenced by ilObjHACPTracking\putparam().

{
global $ilDB, $ilUser;
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);
}

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