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';
244 $sql =
"SELECT usr_id FROM ut_lp_marks WHERE ".
245 " obj_id = ".$ilDB->quote($a_obj_id,
"integer").
" AND ".
246 " status_dirty = ".$ilDB->quote(1,
"integer");
247 if(is_array($a_users) && count($a_users) > 0)
249 $sql .=
" AND ".$ilDB->in(
"usr_id", $a_users,
false,
"integer");
251 $set = $ilDB->query($sql);
253 if ($rec = $ilDB->fetchAssoc($set))
260 if (!$dirty && is_array($a_users) && count($a_users) > 0)
262 $set = $ilDB->query(
"SELECT count(usr_id) cnt FROM ut_lp_marks WHERE ".
263 " obj_id = ".$ilDB->quote($a_obj_id,
"integer").
" AND ".
264 $ilDB->in(
"usr_id", $a_users,
false,
"integer"));
265 $r = $ilDB->fetchAssoc($set);
266 if ($r[
"cnt"] < count($a_users))
273 if ($dirty || $missing)
276 $trac_obj =
new $class($a_obj_id);
277 $trac_obj->refreshStatus($a_obj_id, $a_users);
289 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
291 foreach ($not_attempted as $user_id)
297 foreach ($in_progress as $user_id)
303 foreach ($completed as $user_id)
316 $missing_users = array_diff($a_users, $not_attempted+$in_progress+$completed+
$failed);
319 foreach ($missing_users as $user_id)
333 static function writeStatus($a_obj_id, $a_user_id, $a_status, $a_percentage =
false, $a_force_per =
false)
337 $set = $ilDB->query(
"SELECT usr_id FROM ut_lp_marks WHERE ".
338 " obj_id = ".$ilDB->quote($a_obj_id,
"integer").
" AND ".
339 " usr_id = ".$ilDB->quote($a_user_id,
"integer")
342 $update_collections =
false;
343 if ($rec = $ilDB->fetchAssoc($set))
345 $ret = $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
346 " status = ".$ilDB->quote($a_status,
"integer").
",".
347 " status_changed = ".$ilDB->now().
",".
348 " status_dirty = ".$ilDB->quote(0,
"integer").
349 " WHERE usr_id = ".$ilDB->quote($a_user_id,
"integer").
350 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer").
351 " AND status <> ".$ilDB->quote($a_status,
"integer")
355 $update_collections =
true;
360 $ilDB->manipulate(
"INSERT INTO ut_lp_marks ".
361 "(status, status_changed, usr_id, obj_id, status_dirty) VALUES (".
362 $ilDB->quote($a_status,
"integer").
",".
364 $ilDB->quote($a_user_id,
"integer").
",".
365 $ilDB->quote($a_obj_id,
"integer").
",".
366 $ilDB->quote(0,
"integer").
368 $update_collections =
true;
372 $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
373 " status_dirty = ".$ilDB->quote(0,
"integer").
374 " WHERE usr_id = ".$ilDB->quote($a_user_id,
"integer").
375 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer")
379 if ($a_percentage !==
false || $a_force_per)
381 $a_percentage = max(0, (
int) $a_percentage);
382 $a_percentage = min(100, $a_percentage);
383 $ret = $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
384 " percentage = ".$ilDB->quote($a_percentage,
"integer").
385 " WHERE usr_id = ".$ilDB->quote($a_user_id,
"integer").
386 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer")
391 if ($update_collections)
394 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
397 $set = $ilDB->query(
"SELECT ut_lp_collections.obj_id obj_id FROM ".
398 "object_reference JOIN ut_lp_collections ON ".
399 "(object_reference.obj_id = ".$ilDB->quote($a_obj_id,
"integer").
400 " AND object_reference.ref_id = ut_lp_collections.item_id)");
401 while ($rec = $ilDB->fetchAssoc($set))
423 $set = $ilDB->query(
"SELECT usr_id FROM ut_lp_marks WHERE ".
424 " obj_id = ".$ilDB->quote($a_obj_id,
"integer").
" AND ".
425 " usr_id = ".$ilDB->quote($a_user_id,
"integer")
428 $update_collections =
false;
429 if ($rec = $ilDB->fetchAssoc($set))
431 $ret = $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
433 " status_changed = ".$ilDB->now().
",".
434 " status_dirty = ".$ilDB->quote(0,
"integer").
435 " WHERE usr_id = ".$ilDB->quote($a_user_id,
"integer").
436 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer").
441 $update_collections =
true;
446 $ilDB->manipulate(
"INSERT INTO ut_lp_marks ".
447 "(status, status_changed, usr_id, obj_id, status_dirty) VALUES (".
450 $ilDB->quote($a_user_id,
"integer").
",".
451 $ilDB->quote($a_obj_id,
"integer").
",".
452 $ilDB->quote(0,
"integer").
454 $update_collections =
true;
458 if ($update_collections)
460 $set = $ilDB->query(
"SELECT ut_lp_collections.obj_id obj_id FROM ".
461 "object_reference JOIN ut_lp_collections ON ".
462 "(object_reference.obj_id = ".$ilDB->quote($a_obj_id,
"integer").
463 " AND object_reference.ref_id = ut_lp_collections.item_id)");
464 while ($rec = $ilDB->fetchAssoc($set))
468 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
485 $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
486 " status_dirty = ".$ilDB->quote(1,
"integer")
501 $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
502 " status_dirty = ".$ilDB->quote(1,
"integer").
503 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer")
517 $set = $ilDB->query(
"SELECT status FROM ut_lp_marks WHERE ".
518 " status_dirty = ".$ilDB->quote(0,
"integer").
519 " AND usr_id = ".$ilDB->quote($a_user_id,
"integer").
520 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer")
522 if ($rec = $ilDB->fetchAssoc($set))
524 return $rec[
"status"];
528 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
530 $set = $ilDB->query(
"SELECT status FROM ut_lp_marks WHERE ".
531 " status_dirty = ".$ilDB->quote(0,
"integer").
532 " AND usr_id = ".$ilDB->quote($a_user_id,
"integer").
533 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer")
535 if ($rec = $ilDB->fetchAssoc($set))
537 return $rec[
"status"];
552 $set = $ilDB->query(
"SELECT status_changed FROM ut_lp_marks WHERE ".
553 " status_dirty = ".$ilDB->quote(0,
"integer").
554 " AND usr_id = ".$ilDB->quote($a_user_id,
"integer").
555 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer")
557 if ($rec = $ilDB->fetchAssoc($set))
559 return $rec[
"status_changed"];
563 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
565 $set = $ilDB->query(
"SELECT status_changed FROM ut_lp_marks WHERE ".
566 " status_dirty = ".$ilDB->quote(0,
"integer").
567 " AND usr_id = ".$ilDB->quote($a_user_id,
"integer").
568 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer")
570 if ($rec = $ilDB->fetchAssoc($set))
572 return $rec[
"status_changed"];