19 declare(strict_types=1);
31 public static function _getInProgress(
int $scorm_item_id,
int $a_obj_id): void
33 throw new Exception(
"Not Implemented: ilSCORM2004Tracking_getInProgress");
39 public static function _getCompleted(
int $scorm_item_id,
int $a_obj_id): void
41 throw new Exception(
"Not Implemented: ilSCORM2004Tracking_getCompleted");
47 public static function _getFailed(
int $scorm_item_id,
int $a_obj_id): void
49 throw new Exception(
"Not Implemented: ilSCORM2004Tracking_getFailed");
61 $ilDB = $DIC->database();
64 $in =
$ilDB->in(
'cp_node.cp_node_id', $a_scorm_item_ids,
false,
'integer');
69 $omit_failed =
' AND success_status <> ' .
$ilDB->quote(
'failed',
'text');
74 SELECT cmi_node.user_id user_id, COUNT(user_id) completed FROM cp_node, cmi_node 75 WHERE ' . $in . $omit_failed .
' 76 AND cp_node.cp_node_id = cmi_node.cp_node_id 77 AND cp_node.slm_id = %s 78 AND completion_status = %s 79 GROUP BY cmi_node.user_id',
80 array(
'integer',
'text'),
81 array($a_obj_id,
'completed')
84 $users[$row->user_id] = $row->completed;
98 $ilDB = $DIC->database();
102 SELECT user_id, status, satisfied FROM cmi_gobjective 103 WHERE objective_id = %s 105 array(
'text',
'integer'),
106 array(
'-course_overall_status-', $a_obj_id)
109 $info[
'completed'] = array();
110 $info[
'failed'] = array();
111 $info[
'in_progress'] = array();
114 if (self::_isCompleted($row[
"status"], $row[
"satisfied"])) {
115 $info[
'completed'][] = (
int) $row[
"user_id"];
117 if (self::_isInProgress($row[
"status"], $row[
"satisfied"])) {
118 $info[
'in_progress'][] = (
int) $row[
"user_id"];
120 if (self::_isFailed($row[
"status"], $row[
"satisfied"])) {
121 $info[
'failed'][] = (
int) $row[
"user_id"];
135 $ilDB = $DIC->database();
139 SELECT status, satisfied FROM cmi_gobjective 140 WHERE objective_id = %s 141 AND scope_id = %s AND user_id = %s',
142 array(
'text',
'integer',
'integer'),
143 array(
'-course_overall_status-', $a_obj_id, $a_user_id)
146 $status =
"not_attempted";
148 if (self::_isInProgress($row[
"status"], $row[
"satisfied"])) {
149 $status =
"in_progress";
151 if (self::_isCompleted($row[
"status"], $row[
"satisfied"])) {
152 $status =
"completed";
154 if (self::_isFailed($row[
"status"], $row[
"satisfied"])) {
169 $ilDB = $DIC->database();
173 SELECT DISTINCT user_id FROM cmi_gobjective 174 WHERE objective_id = %s 176 array(
'text',
'integer'),
177 array(
'-course_overall_status-', $a_obj_id)
182 $users[] = (
int) $row[
"user_id"];
190 public static function _getItemProgressInfo(array $a_scorm_item_ids,
int $a_obj_id,
bool $a_omit_failed): array
194 $ilDB = $DIC->database();
196 $in =
$ilDB->in(
'cp_node.cp_node_id', $a_scorm_item_ids,
false,
'integer');
199 'SELECT cp_node.cp_node_id id, 200 cmi_node.user_id user_id, 201 cmi_node.completion_status completion, 202 cmi_node.success_status success 203 FROM cp_node, cmi_node 205 AND cp_node.cp_node_id = cmi_node.cp_node_id 206 AND cp_node.slm_id = %s',
211 $info[
'completed'] = array();
212 $info[
'failed'] = array();
213 $info[
'in_progress'] = array();
217 $info[
'in_progress'][$row[
"id"]][] = $row[
"user_id"];
218 if ($row[
"completion"] ===
"completed" || $row[
"success"] ===
"passed") {
220 if (!$a_omit_failed || $row[
"success"] !==
"failed") {
221 $info[
'completed'][$row[
"id"]][] = $row[
"user_id"];
224 if ($row[
"success"] ===
"failed") {
225 $info[
'failed'][$row[
"id"]][] = $row[
"user_id"];
235 $ilDB = $DIC->database();
237 $status =
"not_attempted";
239 if (is_array($a_scos)) {
240 $in =
$ilDB->in(
'cp_node.cp_node_id', $a_scos,
false,
'integer');
243 'SELECT cp_node.cp_node_id id, 244 cmi_node.completion_status completion, 245 cmi_node.success_status success 246 FROM cp_node, cmi_node 248 AND cp_node.cp_node_id = cmi_node.cp_node_id 249 AND cp_node.slm_id = %s 250 AND cmi_node.user_id = %s',
251 array(
'integer',
'integer'),
252 array($a_obj_id, $a_user_id)
259 if ($rec[
"completion"] ===
"completed" || $rec[
"success"] ===
"passed") {
262 if ($rec[
"success"] ===
"failed") {
267 if ($started ==
true) {
268 $status =
"in_progress";
270 if ($failed ==
true) {
272 } elseif ($cntcompleted == count($a_scos)) {
273 $status =
"completed";
287 $ilDB = $DIC->database();
290 if (is_array($a_scos)) {
291 $in =
$ilDB->in(
'cp_node.cp_node_id', $a_scos,
false,
'integer');
294 'SELECT cp_node.cp_node_id id, 295 cmi_node.completion_status completion, 296 cmi_node.success_status success 297 FROM cp_node, cmi_node 299 AND cp_node.cp_node_id = cmi_node.cp_node_id 300 AND cp_node.slm_id = %s 301 AND cmi_node.user_id = %s',
302 array(
'integer',
'integer'),
303 array($a_obj_id, $a_user_id)
311 if (($rec[
"completion"] ===
"completed" || $rec[
"success"] ===
"passed")
312 && (!$a_omit_failed || $rec[
"success"] !==
"failed")) {
327 $ilDB = $DIC->database();
330 $val_set =
$ilDB->queryF(
331 'SELECT time_from_lms FROM sahs_lm WHERE id = %s',
335 $val_rec =
$ilDB->fetchAssoc($val_set);
339 $val_set =
$ilDB->queryF(
341 SELECT package_attempts, sco_total_time_sec, total_time_sec 342 FROM sahs_user WHERE obj_id = %s AND user_id = %s',
343 array(
'integer',
'integer'),
344 array($a_obj_id,$a_user_id)
346 $val_rec =
$ilDB->fetchAssoc($val_set);
348 $time = $val_rec[
"sco_total_time_sec"];
350 $time = $val_rec[
"total_time_sec"];
352 $attempts = $val_rec[
"package_attempts"];
353 if ($attempts ==
null) {
357 if ($attempts !=
"" && $time ==
null) {
358 $time = self::getSumTotalTimeSecondsFromScos($a_obj_id, $a_user_id,
true);
385 public static function _isCompleted(
string $a_status,
string $a_satisfied): bool
387 return $a_status ===
"completed" || $a_satisfied ===
"satisfied";
390 public static function _isInProgress(
string $a_status,
string $a_satisfied): bool
392 return $a_status !==
"completed";
395 public static function _isFailed(
string $a_status,
string $a_satisfied): bool
397 return $a_status ===
"completed" && $a_satisfied ===
"notSatisfied";
407 $ilDB = $DIC->database();
409 $val_set =
$ilDB->queryF(
410 'SELECT cp_node_id FROM cp_node 412 AND cp_node.slm_id = %s',
413 array(
'text',
'integer'),
414 array(
'item', $a_obj_id)
416 while ($val_rec =
$ilDB->fetchAssoc($val_set)) {
417 $scos[] = $val_rec[
'cp_node_id'];
420 foreach ($scos as $sco) {
422 $data_set =
$ilDB->queryF(
426 WHERE cp_node_id = %s 428 array(
'integer',
'integer'),
429 array($sco, $a_user_id)
432 while ($data_rec =
$ilDB->fetchAssoc($data_set)) {
438 if ($a_write && $time > 0) {
440 'UPDATE sahs_user SET sco_total_time_sec=%s WHERE obj_id = %s AND user_id = %s',
441 array(
'integer',
'integer',
'integer'),
442 array($time, $a_obj_id, $a_user_id)
static _isCompleted(string $a_status, string $a_satisfied)
static _getProgressInfoOfUser(int $a_obj_id, int $a_user_id)
Get overall scorm status.
static _getProgressInfo(int $a_obj_id)
Get overall scorm status.
static _getCountCompletedPerUser(array $a_scorm_item_ids, int $a_obj_id, bool $a_omit_failed=false)
Get progress of selected scos.
static _getItemProgressInfo(array $a_scorm_item_ids, int $a_obj_id, bool $a_omit_failed)
static _getTrackedUsers(int $a_obj_id)
Get all tracked users.
static _ISODurationToCentisec(string $str)
convert ISO 8601 Timeperiods to centiseconds
static _getCollectionStatus(array $a_scos, int $a_obj_id, int $a_user_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _getCompleted(int $scorm_item_id, int $a_obj_id)
static _recordReadEvent(string $a_type, int $a_ref_id, int $obj_id, int $usr_id, bool $isCatchupWriteEvents=true, $a_ext_rc=null, $a_ext_time=null)
static _isFailed(string $a_status, string $a_satisfied)
static _getFailed(int $scorm_item_id, int $a_obj_id)
Class ilSCORM2004Tracking.
static _syncReadEvent(int $a_obj_id, int $a_user_id, string $a_type, int $a_ref_id, ?bool $time_from_lms=null)
Synch read event table.
static getSumTotalTimeSecondsFromScos(int $a_obj_id, int $a_user_id, bool $a_write=false)
should be avoided; store value to increase performance for further requests
static yn2tf(string $a_yn)
static _isInProgress(string $a_status, string $a_satisfied)
static _countCompleted(array $a_scos, int $a_obj_id, int $a_user_id, bool $a_omit_failed)
static _getInProgress(int $scorm_item_id, int $a_obj_id)