16 $this->insert =
array();
17 if (is_array(
$_GET[
"iL"])) {
19 $this->insert[] =
array(
"left" => $value,
"right" =>
$_GET[
"iR"][
$key]);
22 if (is_array(
$_POST[
"iL"])) {
24 $this->insert[] =
array(
"left" => $value,
"right" =>
$_POST[
"iR"][
$key]);
29 if (is_array(
$_GET[
"uL"])) {
34 if (is_array(
$_POST[
"uL"])) {
41 public function store($obj_id=0, $sahs_id=0, $extractData=1)
45 $ref_id =
$_GET[
"ref_id"];
51 $f = fopen(
"./Modules/ScormAicc/log/scorm.log",
"a");
52 fwrite($f,
"\nCALLING SCORM store()\n");
53 fwrite($f,
'POST: ' . print_r(
$_POST,
true));
56 if (empty($sahs_id)) {
60 if ($extractData==1) {
64 if (is_object($ilUser)) {
65 $user_id = $ilUser->getId();
71 fwrite($f,
"Error: No obj_id given.\n");
73 foreach ($this->insert as
$insert) {
76 SELECT * FROM scorm_tracking 81 array(
'integer',
'integer',
'text',
'integer'),
82 array($user_id,$sahs_id,$insert[
"left"],$obj_id)
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");
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"]),
97 fwrite($f,
"Insert - L:" . $insert[
"left"] .
",R:" .
98 $insert[
"right"] .
",sahs_id:" . $sahs_id .
",user_id:" . $user_id .
"\n");
101 foreach ($this->
update as $update) {
102 $set = $ilDB->queryF(
104 SELECT * FROM scorm_tracking 109 array(
'integer',
'integer',
'text',
'integer'),
110 array($user_id,$sahs_id,$update[
"left"],$obj_id)
113 if ($rec = $ilDB->fetchAssoc($set)) {
117 'rvalue' =>
array(
'clob', $update[
"right"]),
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)
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");
136 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
152 $obj_id = (int)
$_GET[
"package_id"];
153 $in = file_get_contents(
"php://input");
156 $user_id = (int)
$data->p;
158 header(
'Content-Type: text/plain; charset=UTF-8');
160 $rval=self::storeJsApiCmi($user_id, $obj_id,
$data);
162 print(
"storeJsApiCmi failed");
164 $rval=self::syncGlobalStatus($user_id, $obj_id,
$data,
$data->now_global_status);
166 print(
"syncGlobalStatus failed");
178 $b_updateStatus=
false;
181 if ($ilLog->current_log_level == 30) {
186 $ilLog->write(
"ScormAicc: CALLING SCORM storeJsApi() " .
$_POST);
197 $aa_data[] =
array(
"sco_id" => (
int)
$data->cmi[
$i][0],
"left" =>
$data->cmi[$i][1],
"right" =>
$data->cmi[$i][2]);
202 $ilLog->write(
"ScormAicc: storeJsApi: Error: No valid obj_id given.");
204 foreach ($aa_data as $a_data) {
205 $set = $ilDB->queryF(
207 SELECT rvalue FROM scorm_tracking 212 array(
'integer',
'integer',
'text',
'integer'),
213 array($user_id,$a_data[
"sco_id"],$a_data[
"left"],$obj_id)
215 if ($rec = $ilDB->fetchAssoc($set)) {
216 if ($a_data[
"left"] ==
'cmi.core.lesson_status' && $a_data[
"right"] != $rec[
"rvalue"]) {
217 $b_updateStatus =
true;
222 'rvalue' =>
array(
'clob', $a_data[
"right"]),
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)
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);
237 if ($a_data[
"left"] ==
'cmi.core.lesson_status') {
238 $b_updateStatus =
true;
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"]),
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);
269 $saved_global_status=
$data->saved_global_status;
270 $ilLog->write(
"saved_global_status=" . $saved_global_status);
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'),
279 $val_rec = $ilDB->fetchAssoc($val_set);
280 $attempts = $val_rec[
"package_attempts"];
282 $attempts=
$data->packageAttempts;
284 if ($attempts == null) {
289 $totalTime=(int)
$data->totalTimeCentisec;
290 $totalTime=round($totalTime/100);
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'),
298 global $ilObjDataCache;
299 include_once(
"./Services/Tracking/classes/class.ilChangeEvent.php");
305 if ($new_global_status != null) {
306 include_once(
"./Services/Tracking/classes/class.ilObjUserTracking.php");
307 include_once(
"./Services/Tracking/classes/class.ilLPStatus.php");
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)
332 $val_rec = $ilDB->fetchAssoc($val_set);
334 if ($val_rec[
"package_attempts"] == null) {
335 $val_rec[
"package_attempts"]=
"";
337 $attempts = $val_rec[
"package_attempts"];
343 $time = (int) $val_rec[
"sco_total_time_sec"];
348 $sco_set = $ilDB->queryF(
350 SELECT sco_id, rvalue FROM scorm_tracking 355 array(
'integer',
'integer',
'text',
'integer'),
356 array($a_obj_id,$a_user_id,
'cmi.core.total_time',0)
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;
367 include_once(
"./Services/Tracking/classes/class.ilChangeEvent.php");
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),
384 if ($a_lval ==
"cmi.core.lesson_status") {
385 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
397 public static function _getInProgress($scorm_item_id, $a_obj_id, $a_blocked_user_ids = null)
401 if (is_array($scorm_item_id)) {
402 $in = $ilDB->in(
'sco_id', $scorm_item_id,
false,
'integer');
404 $res = $ilDB->queryF(
405 'SELECT user_id,sco_id FROM scorm_tracking 408 GROUP BY user_id, sco_id',
413 $res = $ilDB->queryF(
414 'SELECT user_id,sco_id FROM scorm_tracking 417 array(
'integer',
'integer'),
418 array($scorm_item_id,$a_obj_id)
422 $in_progress =
array();
424 while (
$row = $ilDB->fetchObject(
$res)) {
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;
445 if (is_array($scorm_item_id)) {
446 $in = $ilDB->in(
'sco_id', $scorm_item_id,
false,
'integer');
448 $res = $ilDB->queryF(
449 'SELECT DISTINCT(user_id) FROM scorm_tracking 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')
458 $res = $ilDB->queryF(
459 'SELECT DISTINCT(user_id) FROM scorm_tracking 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')
469 while (
$row = $ilDB->fetchObject(
$res)) {
470 $user_ids[] =
$row->user_id;
472 return $user_ids ? $user_ids :
array();
480 $status =
"not_attempted";
482 if (is_array($a_scos)) {
483 $in = $ilDB->in(
'sco_id', $a_scos,
false,
'integer');
485 $res = $ilDB->queryF(
486 'SELECT sco_id, rvalue FROM scorm_tracking 491 array(
'integer',
'text',
'integer'),
492 array($a_obj_id,
'cmi.core.lesson_status', $a_user_id)
498 while ($rec = $ilDB->fetchAssoc(
$res)) {
499 if ($rec[
"rvalue"] ==
"failed") {
502 if ($rec[
"rvalue"] !=
"completed" && $rec[
"rvalue"] !=
"passed") {
508 $status =
"in_progress";
510 if ($completed && $cnt == count($a_scos)) {
511 $status =
"completed";
525 if (is_array($a_scos)) {
526 $in = $ilDB->in(
'sco_id', $a_scos,
false,
'integer');
528 $res = $ilDB->queryF(
529 'SELECT sco_id, rvalue FROM scorm_tracking 534 array(
'integer',
'text',
'integer'),
535 array($a_obj_id,
'cmi.core.lesson_status', $a_user_id)
539 while ($rec = $ilDB->fetchAssoc(
$res)) {
540 if ($rec[
"rvalue"] ==
"completed" || $rec[
"rvalue"] ==
"passed") {
558 $query =
'SELECT user_id, MAX(c_timestamp) tst ' .
559 'FROM scorm_tracking ' .
560 'WHERE obj_id = ' . $ilDB->quote($a_obj_id,
'integer') .
' ' .
581 $res = $ilDB->queryF(
582 'SELECT DISTINCT user_id FROM scorm_tracking 585 array(
'integer',
'text'),
586 array($a_obj_id,
'cmi.core.lesson_status')
590 while (
$row = $ilDB->fetchAssoc(
$res)) {
606 if (is_array($scorm_item_id)) {
607 $in = $ilDB->in(
'sco_id', $scorm_item_id,
false,
'integer');
609 $res = $ilDB->queryF(
611 SELECT DISTINCT(user_id) FROM scorm_tracking 615 AND ' . $ilDB->like(
'rvalue',
'clob',
'failed') .
' ',
616 array(
'integer',
'text'),
617 array($a_obj_id,
'cmi.core.lesson_status')
620 $res = $ilDB->queryF(
622 SELECT DISTINCT(user_id) FROM scorm_tracking 626 AND ' . $ilDB->like(
'rvalue',
'clob',
'failed') .
' ',
627 array(
'integer',
'integer',
'text'),
628 array($scorm_item_id,$a_obj_id,
'cmi.core.lesson_status')
632 while (
$row = $ilDB->fetchObject(
$res)) {
633 $user_ids[] =
$row->user_id;
635 return $user_ids ? $user_ids :
array();
648 $in = $ilDB->in(
'sco_id', $a_scorm_item_ids,
false,
'integer');
652 $res = $ilDB->queryF(
654 SELECT user_id, COUNT(user_id) completed FROM scorm_tracking 658 AND (' . $ilDB->like(
'rvalue',
'clob',
'completed') .
' OR ' . $ilDB->like(
'rvalue',
'clob',
'passed') .
') 660 array(
'integer',
'text'),
661 array($a_obj_id,
'cmi.core.lesson_status')
663 while (
$row = $ilDB->fetchObject(
$res)) {
679 $in = $ilDB->in(
'sco_id', $sco_item_ids,
false,
'integer');
681 $res = $ilDB->queryF(
683 SELECT * FROM scorm_tracking 687 array(
'integer',
'text'),
688 array($a_obj_id,
'cmi.core.lesson_status')
695 while (
$row = $ilDB->fetchObject(
$res)) {
696 switch (
$row->rvalue) {
700 $user_ids[
$row->sco_id][] =
$row->user_id;
705 $user_ids[
$row->sco_id][] =
$row->user_id;
719 $user_id = (int)
$_GET[
"p"];
720 $ref_id = (int)
$_GET[
"ref_id"];
722 $obj_id = (int)
$_GET[
"package_id"];
724 $GLOBALS[
'ilLog']->write(__METHOD__ .
' no valid obj_id');
726 $last_visited=
$_POST[
'last_visited'];
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)
739 header(
'Content-Type: text/plain; charset=UTF-8');
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'),
751 $rowtmp=$ilDB->fetchAssoc(
$res);
752 if ($rowtmp[
'hash']==$hash) {
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.
static storeJsApiCmi($user_id, $obj_id, $data)
static _getCompleted($scorm_item_id, $a_obj_id)
like necessary because of Oracle
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Class ilObjSCORMTracking.
static storeJsApi($obj_id=0)
static _getTrackedUsers($a_obj_id)
Get all tracked users.
static now()
Return current timestamp in Y-m-d H:i:s format.
static _countCompleted($a_scos, $a_obj_id, $a_user_id)
static _getCountCompletedPerUser($a_scorm_item_ids, $a_obj_id)
Get users who have status completed or passed.
foreach($_POST as $key=> $value) $res
static _lookupObjId($a_id)
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
static _getFailed($scorm_item_id, $a_obj_id)
like necessary because of Oracle
Add a drawing to the header
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.
static _insertTrackData($a_sahs_id, $a_lval, $a_rval, $a_obj_id)
if(php_sapi_name() !='cli') $in
update($pash, $contents, Config $config)
static lookupLastAccessTimes($a_obj_id)
Lookup last acccess time for all users of a scorm module ilDB $ilDB.
static writeStatus($a_obj_id, $a_user_id, $a_status, $a_percentage=false, $a_force_per=false)
Write status for user and object.
static _getInProgress($scorm_item_id, $a_obj_id, $a_blocked_user_ids=null)
static _getCollectionStatus($a_scos, $a_obj_id, $a_user_id)
static _getProgressInfo($sco_item_ids, $a_obj_id)
Get info about.
static scorm12PlayerUnload()
static syncGlobalStatus($userId, $packageId, $data, $new_global_status)
static checkIfAllowed($packageId, $userId, $hash)
store($obj_id=0, $sahs_id=0, $extractData=1)