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';
237 $set = $ilDB->query(
"SELECT usr_id FROM ut_lp_marks WHERE ".
238 " obj_id = ".$ilDB->quote($a_obj_id,
"integer").
" AND ".
239 " status_dirty = ".$ilDB->quote(1,
"integer")
242 if ($rec = $ilDB->fetchAssoc($set))
249 if (!$dirty && is_array($a_users) && count($a_users) > 0)
251 $set = $ilDB->query(
"SELECT count(usr_id) cnt FROM ut_lp_marks WHERE ".
252 " obj_id = ".$ilDB->quote($a_obj_id,
"integer").
" AND ".
253 $ilDB->in(
"usr_id", $a_users,
false,
"integer"));
254 $r = $ilDB->fetchAssoc($set);
255 if ($r[
"cnt"] < count($a_users))
262 if ($dirty || $missing)
265 $trac_obj =
new $class($a_obj_id);
266 $trac_obj->refreshStatus($a_obj_id);
278 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
280 foreach ($not_attempted as $user_id)
286 foreach ($in_progress as $user_id)
292 foreach ($completed as $user_id)
298 foreach ($failed as $user_id)
311 static function writeStatus($a_obj_id, $a_user_id, $a_status, $a_percentage =
false, $a_force_per =
false)
315 $set = $ilDB->query(
"SELECT usr_id FROM ut_lp_marks WHERE ".
316 " obj_id = ".$ilDB->quote($a_obj_id,
"integer").
" AND ".
317 " usr_id = ".$ilDB->quote($a_user_id,
"integer")
320 $update_collections =
false;
321 if ($rec = $ilDB->fetchAssoc($set))
323 $ret = $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
324 " status = ".$ilDB->quote($a_status,
"integer").
",".
325 " status_changed = ".$ilDB->now().
",".
326 " status_dirty = ".$ilDB->quote(0,
"integer").
327 " WHERE usr_id = ".$ilDB->quote($a_user_id,
"integer").
328 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer").
329 " AND status <> ".$ilDB->quote($a_status,
"integer")
333 $update_collections =
true;
338 $ilDB->manipulate(
"INSERT INTO ut_lp_marks ".
339 "(status, status_changed, usr_id, obj_id, status_dirty) VALUES (".
340 $ilDB->quote($a_status,
"integer").
",".
342 $ilDB->quote($a_user_id,
"integer").
",".
343 $ilDB->quote($a_obj_id,
"integer").
",".
344 $ilDB->quote(0,
"integer").
346 $update_collections =
true;
350 $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
351 " status_dirty = ".$ilDB->quote(0,
"integer").
352 " WHERE usr_id = ".$ilDB->quote($a_user_id,
"integer").
353 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer")
357 if ($a_percentage !==
false || $a_force_per)
359 $a_percentage = max(0, (
int) $a_percentage);
360 $a_percentage = min(100, $a_percentage);
361 $ret = $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
362 " percentage = ".$ilDB->quote($a_percentage,
"integer").
363 " WHERE usr_id = ".$ilDB->quote($a_user_id,
"integer").
364 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer")
369 if ($update_collections)
371 $set = $ilDB->query(
"SELECT ut_lp_collections.obj_id obj_id FROM ".
372 "object_reference JOIN ut_lp_collections ON ".
373 "(object_reference.obj_id = ".$ilDB->quote($a_obj_id,
"integer").
374 " AND object_reference.ref_id = ut_lp_collections.item_id)");
375 while ($rec = $ilDB->fetchAssoc($set))
379 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
395 $set = $ilDB->query(
"SELECT usr_id FROM ut_lp_marks WHERE ".
396 " obj_id = ".$ilDB->quote($a_obj_id,
"integer").
" AND ".
397 " usr_id = ".$ilDB->quote($a_user_id,
"integer")
400 $update_collections =
false;
401 if ($rec = $ilDB->fetchAssoc($set))
403 $ret = $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
405 " status_changed = ".$ilDB->now().
",".
406 " status_dirty = ".$ilDB->quote(0,
"integer").
407 " WHERE usr_id = ".$ilDB->quote($a_user_id,
"integer").
408 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer").
413 $update_collections =
true;
418 $ilDB->manipulate(
"INSERT INTO ut_lp_marks ".
419 "(status, status_changed, usr_id, obj_id, status_dirty) VALUES (".
422 $ilDB->quote($a_user_id,
"integer").
",".
423 $ilDB->quote($a_obj_id,
"integer").
",".
424 $ilDB->quote(0,
"integer").
426 $update_collections =
true;
430 if ($update_collections)
432 $set = $ilDB->query(
"SELECT ut_lp_collections.obj_id obj_id FROM ".
433 "object_reference JOIN ut_lp_collections ON ".
434 "(object_reference.obj_id = ".$ilDB->quote($a_obj_id,
"integer").
435 " AND object_reference.ref_id = ut_lp_collections.item_id)");
436 while ($rec = $ilDB->fetchAssoc($set))
440 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
457 $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
458 " status_dirty = ".$ilDB->quote(1,
"integer")
473 $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
474 " status_dirty = ".$ilDB->quote(1,
"integer").
475 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer")