ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilObjSCORMTracking.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2011 ILIAS open source, Extended GPL, see docs/LICENSE */
4
13{
14 public function extractData()
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 }
40
41 public function store($obj_id=0, $sahs_id=0, $extractData=1)
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 }
143
144 public static function storeJsApi($obj_id=0)
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 }
173
174 public static function storeJsApiCmi($user_id, $obj_id, $data)
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 }
264
265 //erase later see ilSCORM2004StoreData
266 public static function syncGlobalStatus($userId, $packageId, $data, $new_global_status)
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 }
314
315
322 public static function _syncReadEvent($a_obj_id, $a_user_id, $a_type, $a_ref_id)
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 }
370
371 public static function _insertTrackData($a_sahs_id, $a_lval, $a_rval, $a_obj_id)
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 }
389
390
397 public static function _getInProgress($scorm_item_id, $a_obj_id, $a_blocked_user_ids = null)
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 }
434
441 public static function _getCompleted($scorm_item_id, $a_obj_id)
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 }
474
475 public static function _getCollectionStatus($a_scos, $a_obj_id, $a_user_id)
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 }
519
520
521 public static function _countCompleted($a_scos, $a_obj_id, $a_user_id)
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 }
547 //not correct because of assets!
554 public static function lookupLastAccessTimes($a_obj_id)
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 }
570
571
577 public static function _getTrackedUsers($a_obj_id)
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 }
595
602 public static function _getFailed($scorm_item_id, $a_obj_id)
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 }
637
644 public static function _getCountCompletedPerUser($a_scorm_item_ids, $a_obj_id)
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 }
668
675 public static function _getProgressInfo($sco_item_ids, $a_obj_id)
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 }
713
714 public static function scorm12PlayerUnload()
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 }
742
743 public static function checkIfAllowed($packageId, $userId, $hash)
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 }
758} // END class.ilObjSCORMTracking
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
$failed
Definition: Utf8Test.php:85
if(php_sapi_name() !='cli') $in
Definition: Utf8Test.php:37
if(! $in) print
$users
Definition: authpage.php:44
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
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 _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
static writeStatus($a_obj_id, $a_user_id, $a_status, $a_percentage=false, $a_force_per=false)
Write status for user and object.
Class ilObjSCORMTracking.
static _getTrackedUsers($a_obj_id)
Get all tracked users.
static _getProgressInfo($sco_item_ids, $a_obj_id)
Get info about.
static syncGlobalStatus($userId, $packageId, $data, $new_global_status)
static _getCompleted($scorm_item_id, $a_obj_id)
like necessary because of Oracle
static _countCompleted($a_scos, $a_obj_id, $a_user_id)
static _getInProgress($scorm_item_id, $a_obj_id, $a_blocked_user_ids=null)
static _getCollectionStatus($a_scos, $a_obj_id, $a_user_id)
static _syncReadEvent($a_obj_id, $a_user_id, $a_type, $a_ref_id)
Synch read event table.
static _getFailed($scorm_item_id, $a_obj_id)
like necessary because of Oracle
static lookupLastAccessTimes($a_obj_id)
Lookup last acccess time for all users of a scorm module @global ilDB $ilDB.
static storeJsApiCmi($user_id, $obj_id, $data)
static _getCountCompletedPerUser($a_scorm_item_ids, $a_obj_id)
Get users who have status completed or passed.
static _insertTrackData($a_sahs_id, $a_lval, $a_rval, $a_obj_id)
static checkIfAllowed($packageId, $userId, $hash)
store($obj_id=0, $sahs_id=0, $extractData=1)
static _lookupObjId($a_id)
static now()
Return current timestamp in Y-m-d H:i:s format.
$key
Definition: croninfo.php:18
$i
Definition: disco.tpl.php:19
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
$time
Definition: cron.php:21
$info
Definition: index.php:5
update($pash, $contents, Config $config)
$query
$insert
foreach($_POST as $key=> $value) $res
$packageId
global $ilDB
$ilUser
Definition: imgupload.php:18
$a_type
Definition: workflow.php:92