4 define(
'LP_STATUS_NOT_ATTEMPTED',
'trac_no_attempted');
5 define(
'LP_STATUS_IN_PROGRESS',
'trac_in_progress');
6 define(
'LP_STATUS_COMPLETED',
'trac_completed');
7 define(
'LP_STATUS_FAILED',
'trac_failed');
9 define(
'LP_STATUS_NOT_ATTEMPTED_NUM', 0);
10 define(
'LP_STATUS_IN_PROGRESS_NUM', 1);
11 define(
'LP_STATUS_COMPLETED_NUM', 2);
12 define(
'LP_STATUS_FAILED_NUM', 3);
15 define(
'LP_STATUS_REGISTERED',
'trac_registered');
16 define(
'LP_STATUS_NOT_REGISTERED',
'trac_not_registered');
17 define(
'LP_STATUS_PARTICIPATED',
'trac_participated');
18 define(
'LP_STATUS_NOT_PARTICIPATED',
'trac_not_participated');
41 $this->obj_id = $a_obj_id;
86 include_once
'Services/MetaData/classes/class.ilMDEducational.php';
195 function _updateStatus($a_obj_id, $a_usr_id, $a_obj = null, $a_percentage =
false, $a_no_raise =
false)
249 $sql =
"SELECT usr_id FROM ut_lp_marks WHERE ".
250 " obj_id = ".$ilDB->quote($a_obj_id,
"integer").
" AND ".
251 " status_dirty = ".$ilDB->quote(1,
"integer");
252 if(is_array($a_users) && count($a_users) > 0)
254 $sql .=
" AND ".$ilDB->in(
"usr_id", $a_users,
false,
"integer");
256 $set = $ilDB->query($sql);
258 if ($rec = $ilDB->fetchAssoc($set))
265 if (!$dirty && is_array($a_users) && count($a_users) > 0)
267 $set = $ilDB->query(
"SELECT count(usr_id) cnt FROM ut_lp_marks WHERE ".
268 " obj_id = ".$ilDB->quote($a_obj_id,
"integer").
" AND ".
269 $ilDB->in(
"usr_id", $a_users,
false,
"integer"));
270 $r = $ilDB->fetchAssoc($set);
271 if ($r[
"cnt"] < count($a_users))
278 if ($dirty || $missing)
280 require_once
"Services/Tracking/classes/class.ilLPStatusFactory.php";
282 $trac_obj =
new $class($a_obj_id);
283 $trac_obj->refreshStatus($a_obj_id, $a_users);
287 protected function raiseEvent($a_obj_id, $a_usr_id, $a_status, $a_percentage)
289 global $ilAppEventHandler;
291 $ilAppEventHandler->raise(
"Services/Tracking",
"updateStatus", array(
292 "obj_id" => $a_obj_id,
293 "usr_id" => $a_usr_id,
294 "status" => $a_status,
295 "percentage" => $a_percentage
307 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
309 foreach ($not_attempted as $user_id)
318 foreach ($in_progress as $user_id)
327 foreach ($completed as $user_id)
346 $missing_users = array_diff($a_users, $not_attempted+$in_progress+$completed+
$failed);
349 foreach ($missing_users as $user_id)
363 static function writeStatus($a_obj_id, $a_user_id, $a_status, $a_percentage =
false, $a_force_per =
false)
367 $update_collections =
false;
370 $set = $ilDB->query(
"SELECT usr_id,status,status_dirty FROM ut_lp_marks WHERE ".
371 " obj_id = ".$ilDB->quote($a_obj_id,
"integer").
" AND ".
372 " usr_id = ".$ilDB->quote($a_user_id,
"integer")
374 $rec = $ilDB->fetchAssoc($set);
380 if ($rec[
"status"] != $a_status)
382 $ret = $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
383 " status = ".$ilDB->quote($a_status,
"integer").
",".
384 " status_changed = ".$ilDB->now().
",".
385 " status_dirty = ".$ilDB->quote(0,
"integer").
386 " WHERE usr_id = ".$ilDB->quote($a_user_id,
"integer").
387 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer")
391 $update_collections =
true;
395 else if ($rec[
"status_dirty"])
397 $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
398 " status_dirty = ".$ilDB->quote(0,
"integer").
399 " WHERE usr_id = ".$ilDB->quote($a_user_id,
"integer").
400 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer")
407 $ilDB->manipulate(
"INSERT INTO ut_lp_marks ".
408 "(status, status_changed, usr_id, obj_id, status_dirty) VALUES (".
409 $ilDB->quote($a_status,
"integer").
",".
411 $ilDB->quote($a_user_id,
"integer").
",".
412 $ilDB->quote($a_obj_id,
"integer").
",".
413 $ilDB->quote(0,
"integer").
415 $update_collections =
true;
419 if ($a_percentage !==
false || $a_force_per)
421 $a_percentage = max(0, (
int) $a_percentage);
422 $a_percentage = min(100, $a_percentage);
423 $ret = $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
424 " percentage = ".$ilDB->quote($a_percentage,
"integer").
425 " WHERE usr_id = ".$ilDB->quote($a_user_id,
"integer").
426 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer")
431 if ($update_collections)
434 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
437 $set = $ilDB->query(
"SELECT ut_lp_collections.obj_id obj_id FROM ".
438 "object_reference JOIN ut_lp_collections ON ".
439 "(object_reference.obj_id = ".$ilDB->quote($a_obj_id,
"integer").
440 " AND object_reference.ref_id = ut_lp_collections.item_id)");
441 while ($rec = $ilDB->fetchAssoc($set))
453 return $update_collections;
465 $set = $ilDB->query(
"SELECT usr_id FROM ut_lp_marks WHERE ".
466 " obj_id = ".$ilDB->quote($a_obj_id,
"integer").
" AND ".
467 " usr_id = ".$ilDB->quote($a_user_id,
"integer")
470 $update_collections =
false;
471 if ($rec = $ilDB->fetchAssoc($set))
473 $ret = $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
475 " status_changed = ".$ilDB->now().
",".
476 " status_dirty = ".$ilDB->quote(0,
"integer").
477 " WHERE usr_id = ".$ilDB->quote($a_user_id,
"integer").
478 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer").
483 $update_collections =
true;
488 $ilDB->manipulate(
"INSERT INTO ut_lp_marks ".
489 "(status, status_changed, usr_id, obj_id, status_dirty) VALUES (".
492 $ilDB->quote($a_user_id,
"integer").
",".
493 $ilDB->quote($a_obj_id,
"integer").
",".
494 $ilDB->quote(0,
"integer").
496 $update_collections =
true;
500 if ($update_collections)
502 $set = $ilDB->query(
"SELECT ut_lp_collections.obj_id obj_id FROM ".
503 "object_reference JOIN ut_lp_collections ON ".
504 "(object_reference.obj_id = ".$ilDB->quote($a_obj_id,
"integer").
505 " AND object_reference.ref_id = ut_lp_collections.item_id)");
506 while ($rec = $ilDB->fetchAssoc($set))
510 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
527 $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
528 " status_dirty = ".$ilDB->quote(1,
"integer")
543 $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
544 " status_dirty = ".$ilDB->quote(1,
"integer").
545 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer")
559 $set = $ilDB->query(
"SELECT status FROM ut_lp_marks WHERE ".
560 " status_dirty = ".$ilDB->quote(0,
"integer").
561 " AND usr_id = ".$ilDB->quote($a_user_id,
"integer").
562 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer")
564 if ($rec = $ilDB->fetchAssoc($set))
566 return $rec[
"status"];
570 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
572 $set = $ilDB->query(
"SELECT status FROM ut_lp_marks WHERE ".
573 " status_dirty = ".$ilDB->quote(0,
"integer").
574 " AND usr_id = ".$ilDB->quote($a_user_id,
"integer").
575 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer")
577 if ($rec = $ilDB->fetchAssoc($set))
579 return $rec[
"status"];
594 $set = $ilDB->query(
"SELECT status_changed FROM ut_lp_marks WHERE ".
595 " status_dirty = ".$ilDB->quote(0,
"integer").
596 " AND usr_id = ".$ilDB->quote($a_user_id,
"integer").
597 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer")
599 if ($rec = $ilDB->fetchAssoc($set))
601 return $rec[
"status_changed"];
605 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
607 $set = $ilDB->query(
"SELECT status_changed FROM ut_lp_marks WHERE ".
608 " status_dirty = ".$ilDB->quote(0,
"integer").
609 " AND usr_id = ".$ilDB->quote($a_user_id,
"integer").
610 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer")
612 if ($rec = $ilDB->fetchAssoc($set))
614 return $rec[
"status_changed"];
631 $sql =
"SELECT usr_id, status, status_dirty FROM ut_lp_marks".
632 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer").
633 " AND status = ".$ilDB->quote($a_status,
"integer");
636 $sql .=
" AND ".$ilDB->in(
"usr_id", $a_user_ids,
"",
"integer");
639 $set = $ilDB->query($sql);
641 while($rec = $ilDB->fetchAssoc($set))
643 if(
$res[
"status_dirty"])
646 if(self::_lookupStatus($a_obj_id, $rec[
"usr_id"]) != $a_status)
651 $res[] = $rec[
"usr_id"];