42 $this->obj_id = $a_obj_id;
93 include_once
'Services/MetaData/classes/class.ilMDEducational.php';
201 function _updateStatus($a_obj_id, $a_usr_id, $a_obj = null, $a_percentage =
false, $a_force_raise =
false)
204 $log->debug(
"obj_id: ".$a_obj_id.
", user id: ".$a_usr_id.
", object: ".
209 $changed = self::writeStatus($a_obj_id, $a_usr_id, $status, $percentage);
214 if(!
$changed && (
bool)$a_force_raise)
216 self::raiseEvent($a_obj_id, $a_usr_id, $status, $percentage);
259 $sql =
"SELECT usr_id FROM ut_lp_marks WHERE ".
260 " obj_id = ".$ilDB->quote($a_obj_id,
"integer").
" AND ".
261 " status_dirty = ".$ilDB->quote(1,
"integer");
262 if(is_array($a_users) && count($a_users) > 0)
264 $sql .=
" AND ".$ilDB->in(
"usr_id", $a_users,
false,
"integer");
266 $set = $ilDB->query($sql);
268 if ($rec = $ilDB->fetchAssoc($set))
275 if (!$dirty && is_array($a_users) && count($a_users) > 0)
277 $set = $ilDB->query(
"SELECT count(usr_id) cnt FROM ut_lp_marks WHERE ".
278 " obj_id = ".$ilDB->quote($a_obj_id,
"integer").
" AND ".
279 $ilDB->in(
"usr_id", $a_users,
false,
"integer"));
280 $r = $ilDB->fetchAssoc($set);
281 if (
$r[
"cnt"] < count($a_users))
288 if ($dirty || $missing)
290 require_once
"Services/Tracking/classes/class.ilLPStatusFactory.php";
292 $trac_obj->refreshStatus($a_obj_id, $a_users);
296 static protected function raiseEvent($a_obj_id, $a_usr_id, $a_status, $a_percentage)
298 global $ilAppEventHandler;
301 $log->debug(
"obj_id: ".$a_obj_id.
", user id: ".$a_usr_id.
", status: ".
302 $a_status.
", percentage: ".$a_percentage);
304 $ilAppEventHandler->raise(
"Services/Tracking",
"updateStatus",
array(
305 "obj_id" => $a_obj_id,
306 "usr_id" => $a_usr_id,
307 "status" => $a_status,
308 "percentage" => $a_percentage
320 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
322 foreach ($not_attempted as $user_id)
325 if(self::writeStatus($a_obj_id, $user_id, self::LP_STATUS_NOT_ATTEMPTED_NUM, $percentage,
true))
331 foreach ($in_progress as $user_id)
334 if(self::writeStatus($a_obj_id, $user_id, self::LP_STATUS_IN_PROGRESS_NUM, $percentage,
true))
340 foreach ($completed as $user_id)
343 if(self::writeStatus($a_obj_id, $user_id, self::LP_STATUS_COMPLETED_NUM, $percentage,
true))
352 if(self::writeStatus($a_obj_id, $user_id, self::LP_STATUS_FAILED_NUM, $percentage,
true))
359 $missing_users = array_diff($a_users, $not_attempted+$in_progress+$completed+
$failed);
362 foreach ($missing_users as $user_id)
376 static function writeStatus($a_obj_id, $a_user_id, $a_status, $a_percentage =
false, $a_force_per =
false)
381 $log->debug(
"obj_id: ".$a_obj_id.
", user id: ".$a_user_id.
", status: ".
382 $a_status.
", percentage: ".$a_percentage.
", force: ".$a_force_per);
384 $update_collections =
false;
387 $set = $ilDB->query(
"SELECT usr_id,status,status_dirty FROM ut_lp_marks WHERE ".
388 " obj_id = ".$ilDB->quote($a_obj_id,
"integer").
" AND ".
389 " usr_id = ".$ilDB->quote($a_user_id,
"integer")
391 $rec = $ilDB->fetchAssoc($set);
397 if ($rec[
"status"] != $a_status)
399 $ret = $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
400 " status = ".$ilDB->quote($a_status,
"integer").
",".
401 " status_changed = ".$ilDB->now().
",".
402 " status_dirty = ".$ilDB->quote(0,
"integer").
403 " WHERE usr_id = ".$ilDB->quote($a_user_id,
"integer").
404 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer")
408 $update_collections =
true;
412 else if ($rec[
"status_dirty"])
414 $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
415 " status_dirty = ".$ilDB->quote(0,
"integer").
416 " WHERE usr_id = ".$ilDB->quote($a_user_id,
"integer").
417 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer")
436 $ilDB->replace(
"ut_lp_marks",
438 "obj_id" =>
array(
"integer", $a_obj_id),
439 "usr_id" =>
array(
"integer", $a_user_id)
442 "status" =>
array(
"integer", $a_status),
443 "status_changed" =>
array(
"timestamp",
date(
"Y-m-d H:i:s")),
444 "status_dirty" =>
array(
"integer", 0)
448 $update_collections =
true;
452 if ($a_percentage !==
false || $a_force_per)
454 $a_percentage = max(0, (
int) $a_percentage);
455 $a_percentage = min(100, $a_percentage);
456 $ret = $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
457 " percentage = ".$ilDB->quote($a_percentage,
"integer").
458 " WHERE usr_id = ".$ilDB->quote($a_user_id,
"integer").
459 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer")
464 if ($update_collections)
467 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
470 $set = $ilDB->query(
"SELECT ut_lp_collections.obj_id obj_id FROM ".
471 "object_reference JOIN ut_lp_collections ON ".
472 "(object_reference.obj_id = ".$ilDB->quote($a_obj_id,
"integer").
473 " AND object_reference.ref_id = ut_lp_collections.item_id)");
474 while ($rec = $ilDB->fetchAssoc($set))
485 self::raiseEvent($a_obj_id, $a_user_id, $a_status, $a_percentage);
488 return $update_collections;
502 $needs_update =
false;
504 $set = $ilDB->query(
"SELECT usr_id, status FROM ut_lp_marks WHERE ".
505 " obj_id = ".$ilDB->quote($a_obj_id,
"integer").
" AND ".
506 " usr_id = ".$ilDB->quote($a_user_id,
"integer")
508 if ($rec = $ilDB->fetchAssoc($set))
511 if($rec[
"status"] == self::LP_STATUS_NOT_ATTEMPTED_NUM)
513 $needs_update =
true;
519 $needs_update =
true;
524 require_once
"Services/Tracking/classes/class.ilLPStatusWrapper.php";
539 $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
540 " status_dirty = ".$ilDB->quote(1,
"integer")
555 $ilDB->manipulate(
"UPDATE ut_lp_marks SET ".
556 " status_dirty = ".$ilDB->quote(1,
"integer").
557 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer")
568 public static function _lookupStatus($a_obj_id, $a_user_id, $a_create =
true)
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"];
581 else if((
bool)$a_create)
583 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
585 $set = $ilDB->query(
"SELECT status FROM ut_lp_marks WHERE ".
586 " status_dirty = ".$ilDB->quote(0,
"integer").
587 " AND usr_id = ".$ilDB->quote($a_user_id,
"integer").
588 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer")
590 if ($rec = $ilDB->fetchAssoc($set))
592 return $rec[
"status"];
607 $set = $ilDB->query(
"SELECT percentage 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[
"percentage"];
627 return (self::_lookupStatus($a_obj_id, $a_user_id) == self::LP_STATUS_COMPLETED_NUM);
640 $set = $ilDB->query(
"SELECT status_changed FROM ut_lp_marks WHERE ".
641 " status_dirty = ".$ilDB->quote(0,
"integer").
642 " AND usr_id = ".$ilDB->quote($a_user_id,
"integer").
643 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer")
645 if ($rec = $ilDB->fetchAssoc($set))
647 return $rec[
"status_changed"];
651 include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
653 $set = $ilDB->query(
"SELECT status_changed FROM ut_lp_marks WHERE ".
654 " status_dirty = ".$ilDB->quote(0,
"integer").
655 " AND usr_id = ".$ilDB->quote($a_user_id,
"integer").
656 " AND obj_id = ".$ilDB->quote($a_obj_id,
"integer")
658 if ($rec = $ilDB->fetchAssoc($set))
660 return $rec[
"status_changed"];
677 $sql =
"SELECT usr_id, status, status_dirty FROM ut_lp_marks".
678 " WHERE obj_id = ".$ilDB->quote($a_obj_id,
"integer").
679 " AND status = ".$ilDB->quote($a_status,
"integer");
682 $sql .=
" AND ".$ilDB->in(
"usr_id", $a_user_ids,
"",
"integer");
685 $set = $ilDB->query($sql);
687 while($rec = $ilDB->fetchAssoc($set))
689 if(
$res[
"status_dirty"])
692 if(self::_lookupStatus($a_obj_id, $rec[
"usr_id"]) != $a_status)
697 $res[] = $rec[
"usr_id"];
712 return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_COMPLETED_NUM, $a_user_ids);
724 return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_FAILED_NUM, $a_user_ids);
736 return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_IN_PROGRESS_NUM, $a_user_ids);
754 $lp_invalid =
array();
756 include_once
"Services/Object/classes/class.ilObjectLP.php";
758 foreach($memberships as $obj_id => $status)
766 return array_diff($a_obj_ids, $lp_invalid);
780 include_once
"Services/Tracking/classes/collection/class.ilLPCollection.php";
783 include_once
"Services/Tracking/classes/class.ilLPObjSettings.php";
787 foreach($existing as $obj_id => $obj_mode)
793 if(in_array($obj_mode, $coll_modes))
801 include_once
"Services/Object/classes/class.ilObjectLP.php";
802 if(
sizeof($existing) !=
sizeof($a_obj_ids))
804 foreach(array_diff($a_obj_ids, $existing) as $obj_id)
807 $mode = $olp->getCurrentMode();
817 if(in_array($mode, $coll_modes))
826 return array_values(
$valid);
843 $sql =
"SELECT status, status_dirty, obj_id FROM ut_lp_marks".
844 " WHERE ".$ilDB->in(
"obj_id", $a_obj_ids,
"",
"integer").
845 " AND usr_id = ".$ilDB->quote($a_user_id,
"integer");
846 $set = $ilDB->query($sql);
847 while(
$row = $ilDB->fetchAssoc($set))
849 if(!
$row[
"status_dirty"])
851 $res[
$row[
"obj_id"]] = $row[
"status"];
855 $res[
$row[
"obj_id"]] = self::_lookupStatus($row[
"obj_id"], $a_user_id);
860 foreach($a_obj_ids as $obj_id)
862 if(!isset(
$res[$obj_id]))
864 $res[
$obj_id] = self::_lookupStatus($obj_id, $a_user_id);
865 if(
$res[$obj_id] === null)
879 $user_id = $ilUser->getId();
883 include_once(
"Services/Tracking/classes/class.ilObjUserTracking.php");
884 if($ilUser->getId() != ANONYMOUS_USER_ID &&
892 $a_obj_ids = self::validateLPForObjects($user_id, $a_obj_ids, (
int)
$_GET[
"ref_id"]);
895 $coll_obj_ids =
array();
896 $a_obj_ids = self::checkLPModesForObjects($a_obj_ids, $coll_obj_ids);
901 $res = self::getLPStatusForObjects($user_id, $a_obj_ids);
907 $lng->loadLanguageModule(
"trac");
908 include_once(
"./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
909 foreach(
$res as $obj_id => $status)
917 self::$list_gui_cache =
$res;
922 return self::$list_gui_cache[$a_obj_id];
const LP_STATUS_COMPLETED_NUM
static _getInProgress($a_obj_id)
Static function to read users who have the status 'in_progress'.
static _lookupFailedForObject($a_obj_id, $a_user_ids=null)
Get failed users for object.
refreshStatus($a_obj_id, $a_users=null)
Refresh status.
determineStatus($a_obj_id, $a_usr_id, $a_obj=null)
Determine status.
static _getCompleted($a_obj_id)
Static function to read the users who have the status 'completed'.
static _getTypicalLearningTimeSeconds($a_rbac_id, $a_obj_id=0)
static _getImagePathForStatus($a_status)
Get image path for status.
static raiseEvent($a_obj_id, $a_usr_id, $a_status, $a_percentage)
static preloadListGUIData($a_obj_ids)
static checkStatusForObject($a_obj_id, $a_users=false)
This function checks whether the status for a given number of users is dirty and must be recalculated...
static _hasLearningProgressLearner()
const LP_STATUS_PARTICIPATED
const LP_STATUS_NOT_ATTEMPTED
static _getStatusText($a_status, $a_lng=null)
Get status alt text.
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
static _lookupPercentage($a_obj_id, $a_user_id)
Lookup percentage.
static validateLPForObjects($a_user_id, $a_obj_ids, $a_parent_ref_id)
Process given objects for lp-relevance.
const LP_STATUS_IN_PROGRESS_NUM
static getListGUIStatus($a_obj_id)
static _getNotAttempted($a_obj_id)
static _getTypicalLearningTime($a_obj_id)
const LP_STATUS_IN_PROGRESS
static _getNotAttempted($a_obj_id)
Static function to read the number of user who have the status 'not_attempted'.
static _getFailed($a_obj_id)
Static function to read the users who have the status 'completed'.
static _getCompleted($a_obj_id)
static _enabledLearningProgress()
check wether learing progress is enabled or not
const LP_STATUS_NOT_PARTICIPATED
static _getStatusInfo($a_obj_id)
static _hasUserCompleted($a_obj_id, $a_user_id)
Lookup user object completion.
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
static _getCountInProgress($a_obj_id)
static _getCountNotAttempted($a_obj_id)
static _lookupStatusForObject($a_obj_id, $a_status, $a_user_ids=null)
Get users with given status for object.
static _getInstance($a_obj_id, $a_mode=NULL)
static _lookupStatusChanged($a_obj_id, $a_user_id)
Lookup status changed.
static checkLPModesForObjects($a_obj_ids, array &$a_coll_obj_ids)
Process lp modes for given objects.
_updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
New status handling (st: status, nr: accesses, p: percentage, t: time spent, m: mark) ...
static _lookupDBModeForObjects(array $a_obj_ids)
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
static _getInProgress($a_obj_id)
static _removeStatusCache($a_obj_id, $a_usr_id)
static _hasLearningProgressListGUI()
const LP_STATUS_NOT_ATTEMPTED_NUM
static _lookupInProgressForObject($a_obj_id, $a_user_ids=null)
Get in progress users for object.
const LP_STATUS_REGISTERED
static writeStatus($a_obj_id, $a_user_id, $a_status, $a_percentage=false, $a_force_per=false)
Write status for user and object.
static setDirty($a_obj_id)
Sets status of an object to dirty.
const LP_MODE_DEACTIVATED
static img($a_src, $a_alt="", $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
static getLPStatusForObjects($a_user_id, $a_obj_ids)
Get LP status for given objects (and user)
static setInProgressIfNotAttempted($a_obj_id, $a_user_id)
This function shoudl be clalled for normal "read events".
static _getCountCompleted($a_obj_id)
Abstract class ilLPStatus for all learning progress modes E.g ilLPStatusManual, ilLPStatusObjectives ...
static _getFailed($a_obj_id)
static _lookupCompletedForObject($a_obj_id, $a_user_ids=null)
Get completed users for object.
static getLogger($a_component_id)
Get component logger.
determinePercentage($a_obj_id, $a_usr_id, $a_obj=null)
Determine percentage.
static setAllDirty()
Sets all status to dirty.
static getLPMemberships($a_usr_id, array $a_obj_ids, $a_parent_ref_id=null, $a_mapped_ref_ids=false)
Get all objects where given user is member (from LP POV)
const LP_STATUS_COMPLETED
static getInstance($a_obj_id)
static getCollectionModes()
const LP_STATUS_NOT_REGISTERED
static _lookupStatus($a_obj_id, $a_user_id, $a_create=true)
Lookup status.
const LP_STATUS_FAILED_NUM