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 $sql =
"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");
240 if(is_array($a_users) && count($a_users) > 0)
242 $sql .=
" AND ".$ilDB->in(
"usr_id", $a_users,
false,
"integer");
244 $set = $ilDB->query($sql);
246 if ($rec = $ilDB->fetchAssoc($set))
253 if (!$dirty && is_array($a_users) && count($a_users) > 0)
255 $set = $ilDB->query(
"SELECT count(usr_id) cnt FROM ut_lp_marks WHERE ".
256 " obj_id = ".$ilDB->quote($a_obj_id,
"integer").
" AND ".
257 $ilDB->in(
"usr_id", $a_users,
false,
"integer"));
258 $r = $ilDB->fetchAssoc($set);
259 if ($r[
"cnt"] < count($a_users))
266 if ($dirty || $missing)
269 $trac_obj =
new $class($a_obj_id);
270 $trac_obj->refreshStatus($a_obj_id, $a_users);
282 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
284 foreach ($not_attempted as $user_id)
290 foreach ($in_progress as $user_id)
296 foreach ($completed as $user_id)
309 $missing_users = array_diff($a_users, $not_attempted+$in_progress+$completed+
$failed);
312 foreach ($missing_users as $user_id)
326 static function writeStatus($a_obj_id, $a_user_id, $a_status, $a_percentage =
false, $a_force_per =
false)
330 $set = $ilDB->query(
"SELECT usr_id FROM ut_lp_marks WHERE ".
331 " obj_id = ".$ilDB->quote($a_obj_id,
"integer").
" AND ".
332 " usr_id = ".$ilDB->quote($a_user_id,
"integer")
335 $update_collections =
false;
336 if ($rec = $ilDB->fetchAssoc($set))
338 $ret = $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
339 " status = ".$ilDB->quote($a_status,
"integer").
",".
340 " status_changed = ".$ilDB->now().
",".
341 " status_dirty = ".$ilDB->quote(0,
"integer").
342 " WHERE usr_id = ".$ilDB->quote($a_user_id,
"integer").
343 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer").
344 " AND status <> ".$ilDB->quote($a_status,
"integer")
348 $update_collections =
true;
353 $ilDB->manipulate(
"INSERT INTO ut_lp_marks ".
354 "(status, status_changed, usr_id, obj_id, status_dirty) VALUES (".
355 $ilDB->quote($a_status,
"integer").
",".
357 $ilDB->quote($a_user_id,
"integer").
",".
358 $ilDB->quote($a_obj_id,
"integer").
",".
359 $ilDB->quote(0,
"integer").
361 $update_collections =
true;
365 $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
366 " status_dirty = ".$ilDB->quote(0,
"integer").
367 " WHERE usr_id = ".$ilDB->quote($a_user_id,
"integer").
368 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer")
372 if ($a_percentage !==
false || $a_force_per)
374 $a_percentage = max(0, (
int) $a_percentage);
375 $a_percentage = min(100, $a_percentage);
376 $ret = $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
377 " percentage = ".$ilDB->quote($a_percentage,
"integer").
378 " WHERE usr_id = ".$ilDB->quote($a_user_id,
"integer").
379 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer")
384 if ($update_collections)
387 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
390 $set = $ilDB->query(
"SELECT ut_lp_collections.obj_id obj_id FROM ".
391 "object_reference JOIN ut_lp_collections ON ".
392 "(object_reference.obj_id = ".$ilDB->quote($a_obj_id,
"integer").
393 " AND object_reference.ref_id = ut_lp_collections.item_id)");
394 while ($rec = $ilDB->fetchAssoc($set))
416 $set = $ilDB->query(
"SELECT usr_id FROM ut_lp_marks WHERE ".
417 " obj_id = ".$ilDB->quote($a_obj_id,
"integer").
" AND ".
418 " usr_id = ".$ilDB->quote($a_user_id,
"integer")
421 $update_collections =
false;
422 if ($rec = $ilDB->fetchAssoc($set))
424 $ret = $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
426 " status_changed = ".$ilDB->now().
",".
427 " status_dirty = ".$ilDB->quote(0,
"integer").
428 " WHERE usr_id = ".$ilDB->quote($a_user_id,
"integer").
429 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer").
434 $update_collections =
true;
439 $ilDB->manipulate(
"INSERT INTO ut_lp_marks ".
440 "(status, status_changed, usr_id, obj_id, status_dirty) VALUES (".
443 $ilDB->quote($a_user_id,
"integer").
",".
444 $ilDB->quote($a_obj_id,
"integer").
",".
445 $ilDB->quote(0,
"integer").
447 $update_collections =
true;
451 if ($update_collections)
453 $set = $ilDB->query(
"SELECT ut_lp_collections.obj_id obj_id FROM ".
454 "object_reference JOIN ut_lp_collections ON ".
455 "(object_reference.obj_id = ".$ilDB->quote($a_obj_id,
"integer").
456 " AND object_reference.ref_id = ut_lp_collections.item_id)");
457 while ($rec = $ilDB->fetchAssoc($set))
461 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
478 $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
479 " status_dirty = ".$ilDB->quote(1,
"integer")
494 $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
495 " status_dirty = ".$ilDB->quote(1,
"integer").
496 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer")