44        $this->obj_id = $a_obj_id;
 
   95        include_once 
'Services/MetaData/classes/class.ilMDEducational.php';
 
  203    public function _updateStatus($a_obj_id, $a_usr_id, $a_obj = 
null, $a_percentage = 
false, $a_force_raise = 
false)
 
  207            "obj_id: %s, user id: %s, object: %s",
 
  210            (is_object($a_obj) ? get_class($a_obj) : 
'null')
 
  220        if (!
$changed && (
bool) $a_force_raise) { 
 
  266        $sql = 
"SELECT usr_id FROM ut_lp_marks WHERE " .
 
  267            " obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer") . 
" AND " .
 
  268            " status_dirty = " . 
$ilDB->quote(1, 
"integer");
 
  269        if (is_array($a_users) && count($a_users) > 0) {
 
  270            $sql .= 
" AND " . 
$ilDB->in(
"usr_id", $a_users, 
false, 
"integer");
 
  272        $set = 
$ilDB->query($sql);
 
  274        if ($rec = 
$ilDB->fetchAssoc($set)) {
 
  280        if (!$dirty && is_array($a_users) && count($a_users) > 0) {
 
  281            $set = 
$ilDB->query(
"SELECT count(usr_id) cnt FROM ut_lp_marks WHERE " .
 
  282                " obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer") . 
" AND " .
 
  283                $ilDB->in(
"usr_id", $a_users, 
false, 
"integer"));
 
  285            if (
$r[
"cnt"] < count($a_users)) {
 
  291        if ($dirty || $missing) {
 
  292            require_once 
"Services/Tracking/classes/class.ilLPStatusFactory.php"; 
 
  294            $trac_obj->refreshStatus($a_obj_id, $a_users);
 
  298    protected static function raiseEvent($a_obj_id, $a_usr_id, $a_status, $a_percentage)
 
  302        $ilAppEventHandler = 
$DIC[
'ilAppEventHandler'];
 
  305        $log->debug(
"obj_id: " . $a_obj_id . 
", user id: " . $a_usr_id . 
", status: " .
 
  306            $a_status . 
", percentage: " . $a_percentage);
 
  308        $ilAppEventHandler->raise(
"Services/Tracking", 
"updateStatus", array(
 
  309            "obj_id" => $a_obj_id,
 
  310            "usr_id" => $a_usr_id,
 
  311            "status" => $a_status,
 
  312            "percentage" => $a_percentage
 
  324        include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
 
  326        foreach ($not_attempted as $user_id) {
 
  328            if (self::writeStatus($a_obj_id, $user_id, self::LP_STATUS_NOT_ATTEMPTED_NUM, $percentage, 
true)) {
 
  333        foreach ($in_progress as $user_id) {
 
  335            if (self::writeStatus($a_obj_id, $user_id, self::LP_STATUS_IN_PROGRESS_NUM, $percentage, 
true)) {
 
  340        foreach ($completed as $user_id) {
 
  342            if (self::writeStatus($a_obj_id, $user_id, self::LP_STATUS_COMPLETED_NUM, $percentage, 
true)) {
 
  347        foreach (
$failed as $user_id) {
 
  349            if (self::writeStatus($a_obj_id, $user_id, self::LP_STATUS_FAILED_NUM, $percentage, 
true)) {
 
  354            $missing_users = array_diff($a_users, $not_attempted + $in_progress + $completed + 
$failed);
 
  355            if ($missing_users) {
 
  356                foreach ($missing_users as $user_id) {
 
  369    public static function writeStatus($a_obj_id, $a_user_id, $a_status, $a_percentage = 
false, $a_force_per = 
false)
 
  376        $log->debug(
"obj_id: " . $a_obj_id . 
", user id: " . $a_user_id . 
", status: " .
 
  377            $a_status . 
", percentage: " . $a_percentage . 
", force: " . $a_force_per);
 
  379        $update_collections = 
false;
 
  383            "SELECT usr_id,status,status_dirty FROM ut_lp_marks WHERE " .
 
  384            " obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer") . 
" AND " .
 
  385            " usr_id = " . 
$ilDB->quote($a_user_id, 
"integer")
 
  387        $rec = 
$ilDB->fetchAssoc($set);
 
  392            if ($rec[
"status"] != $a_status) {
 
  394                    "UPDATE ut_lp_marks SET " .
 
  395                    " status = " . 
$ilDB->quote($a_status, 
"integer") . 
"," .
 
  396                    " status_changed = " . 
$ilDB->now() . 
"," .
 
  397                    " status_dirty = " . 
$ilDB->quote(0, 
"integer") .
 
  398                    " WHERE usr_id = " . 
$ilDB->quote($a_user_id, 
"integer") .
 
  399                    " AND obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer")
 
  402                    $update_collections = 
true;
 
  406            elseif ($rec[
"status_dirty"]) {
 
  408                    "UPDATE ut_lp_marks SET " .
 
  409                    " status_dirty = " . 
$ilDB->quote(0, 
"integer") .
 
  410                    " WHERE usr_id = " . 
$ilDB->quote($a_user_id, 
"integer") .
 
  411                    " AND obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer")
 
  432                    "obj_id" => array(
"integer", $a_obj_id),
 
  433                    "usr_id" => array(
"integer", $a_user_id)
 
  436                    "status" => array(
"integer", $a_status),
 
  437                    "status_changed" => array(
"timestamp", date(
"Y-m-d H:i:s")), 
 
  438                    "status_dirty" => array(
"integer", 0)
 
  442            $update_collections = 
true;
 
  446        if ($a_percentage !== 
false || $a_force_per) {
 
  447            $a_percentage = max(0, (
int) $a_percentage);
 
  448            $a_percentage = min(100, $a_percentage);
 
  450                "UPDATE ut_lp_marks SET " .
 
  451                " percentage = " . 
$ilDB->quote($a_percentage, 
"integer") .
 
  452                " WHERE usr_id = " . 
$ilDB->quote($a_user_id, 
"integer") .
 
  453                " AND obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer")
 
  458        if ($update_collections) {
 
  460            include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
 
  463            $set = 
$ilDB->query(
"SELECT ut_lp_collections.obj_id obj_id FROM " .
 
  464                "object_reference JOIN ut_lp_collections ON " .
 
  465                "(object_reference.obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer") .
 
  466                " AND object_reference.ref_id = ut_lp_collections.item_id)");
 
  467            while ($rec = 
$ilDB->fetchAssoc($set)) {
 
  479        return $update_collections;
 
  495        $needs_update = 
false;
 
  498            "SELECT usr_id, status FROM ut_lp_marks WHERE " .
 
  499            " obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer") . 
" AND " .
 
  500            " usr_id = " . 
$ilDB->quote($a_user_id, 
"integer")
 
  502        if ($rec = 
$ilDB->fetchAssoc($set)) {
 
  504            if ($rec[
"status"] == self::LP_STATUS_NOT_ATTEMPTED_NUM) {
 
  505                $needs_update = 
true;
 
  509            $needs_update = 
true;
 
  513            require_once 
"Services/Tracking/classes/class.ilLPStatusWrapper.php";
 
  531            "UPDATE ut_lp_marks SET " .
 
  532            " status_dirty = " . 
$ilDB->quote(1, 
"integer")
 
  549            "UPDATE ut_lp_marks SET " .
 
  550            " status_dirty = " . 
$ilDB->quote(1, 
"integer") .
 
  551            " WHERE obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer")
 
  562    public static function _lookupStatus($a_obj_id, $a_user_id, $a_create = 
true)
 
  569            "SELECT status FROM ut_lp_marks WHERE " .
 
  570            " status_dirty = " . 
$ilDB->quote(0, 
"integer") .
 
  571            " AND usr_id = " . 
$ilDB->quote($a_user_id, 
"integer") .
 
  572            " AND obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer")
 
  574        if ($rec = 
$ilDB->fetchAssoc($set)) {
 
  575            return $rec[
"status"];
 
  576        } elseif ((
bool) $a_create) {
 
  577            include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
 
  580                "SELECT status FROM ut_lp_marks WHERE " .
 
  581                " status_dirty = " . 
$ilDB->quote(0, 
"integer") .
 
  582                " AND usr_id = " . 
$ilDB->quote($a_user_id, 
"integer") .
 
  583                " AND obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer")
 
  585            if ($rec = 
$ilDB->fetchAssoc($set)) {
 
  586                return $rec[
"status"];
 
  604            "SELECT percentage FROM ut_lp_marks WHERE " .
 
  605            " status_dirty = " . 
$ilDB->quote(0, 
"integer") .
 
  606            " AND usr_id = " . 
$ilDB->quote($a_user_id, 
"integer") .
 
  607            " AND obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer")
 
  609        if ($rec = 
$ilDB->fetchAssoc($set)) {
 
  610            return $rec[
"percentage"];
 
  623        return (self::_lookupStatus($a_obj_id, $a_user_id) == self::LP_STATUS_COMPLETED_NUM);
 
  639            "SELECT status_changed FROM ut_lp_marks WHERE " .
 
  640            " status_dirty = " . 
$ilDB->quote(0, 
"integer") .
 
  641            " AND usr_id = " . 
$ilDB->quote($a_user_id, 
"integer") .
 
  642            " AND obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer")
 
  644        if ($rec = 
$ilDB->fetchAssoc($set)) {
 
  645            return $rec[
"status_changed"];
 
  647            include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
 
  650                "SELECT status_changed FROM ut_lp_marks WHERE " .
 
  651                " status_dirty = " . 
$ilDB->quote(0, 
"integer") .
 
  652                " AND usr_id = " . 
$ilDB->quote($a_user_id, 
"integer") .
 
  653                " AND obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer")
 
  655            if ($rec = 
$ilDB->fetchAssoc($set)) {
 
  656                return $rec[
"status_changed"];
 
  675        $sql = 
"SELECT usr_id, status, status_dirty FROM ut_lp_marks" .
 
  676            " WHERE obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer") .
 
  677            " AND status = " . 
$ilDB->quote($a_status, 
"integer");
 
  679            $sql .= 
" AND " . 
$ilDB->in(
"usr_id", $a_user_ids, 
"", 
"integer");
 
  682        $set = 
$ilDB->query($sql);
 
  684        while ($rec = 
$ilDB->fetchAssoc($set)) {
 
  685            if (
$res[
"status_dirty"]) {
 
  687                if (self::_lookupStatus($a_obj_id, $rec[
"usr_id"]) != $a_status) {
 
  691            $res[] = $rec[
"usr_id"];
 
  748        $lp_invalid = array();
 
  750        include_once 
"Services/Object/classes/class.ilObjectLP.php";
 
  752        foreach ($memberships as 
$obj_id => $status) {
 
  758        return array_diff($a_obj_ids, $lp_invalid);
 
  772        include_once 
"Services/Tracking/classes/collection/class.ilLPCollection.php";
 
  775        include_once 
"Services/Tracking/classes/class.ilLPObjSettings.php";
 
  779        foreach ($existing as 
$obj_id => $obj_mode) {
 
  783                if (in_array($obj_mode, $coll_modes)) {
 
  790        include_once 
"Services/Object/classes/class.ilObjectLP.php";
 
  791        if (
sizeof($existing) != 
sizeof($a_obj_ids)) {
 
  792            foreach (array_diff($a_obj_ids, $existing) as 
$obj_id) {
 
  794                $mode = $olp->getCurrentMode();
 
  801                    if (in_array($mode, $coll_modes)) {
 
  809        return array_values(
$valid);
 
  828        $sql = 
"SELECT status, status_dirty, obj_id FROM ut_lp_marks" .
 
  829            " WHERE " . 
$ilDB->in(
"obj_id", $a_obj_ids, 
"", 
"integer") .
 
  830            " AND usr_id = " . 
$ilDB->quote($a_user_id, 
"integer");
 
  831        $set = 
$ilDB->query($sql);
 
  833            if (!
$row[
"status_dirty"]) {
 
  841        foreach ($a_obj_ids as 
$obj_id) {
 
  864        include_once(
"Services/Tracking/classes/class.ilObjUserTracking.php");
 
  865        if (
$ilUser->getId() != ANONYMOUS_USER_ID &&
 
  875            $coll_obj_ids = array();
 
  887            $lng->loadLanguageModule(
"trac");
 
  888            include_once(
"./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
 
  899        self::$list_gui_cache = 
$res;
 
  906            if (isset(self::$list_gui_cache[$a_obj_id][
"image"])) {
 
  907                $image = self::$list_gui_cache[$a_obj_id][
"image"];
 
  912        return self::$list_gui_cache[$a_obj_id];
 
An exception for terminatinating execution or to throw for unit testing.
static getCollectionModes()
const LP_MODE_DEACTIVATED
static _lookupDBModeForObjects(array $a_obj_ids)
static _getInstance($a_obj_id, $a_mode=null)
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
static _getNotAttempted($a_obj_id)
Static function to read the number of user who have the status 'not_attempted'.
static _removeStatusCache($a_obj_id, $a_usr_id)
static _getCompleted($a_obj_id)
Static function to read the users who have the status 'completed'.
static _getInProgress($a_obj_id)
Static function to read users who have the status 'in_progress'.
static _getFailed($a_obj_id)
Static function to read the users who have the status 'completed'.
Abstract class ilLPStatus for all learning progress modes E.g ilLPStatusManual, ilLPStatusObjectives ...
const LP_STATUS_COMPLETED_NUM
_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 _lookupStatusForObject($a_obj_id, $a_status, $a_user_ids=null)
Get users with given status for object.
const LP_STATUS_NOT_PARTICIPATED
static _getStatusInfo($a_obj_id)
static preloadListGUIData($a_obj_ids)
determineStatus($a_obj_id, $a_usr_id, $a_obj=null)
Determine status.
static _getInProgress($a_obj_id)
static _getCountInProgress($a_obj_id)
static _getTypicalLearningTime($a_obj_id)
static _lookupStatus($a_obj_id, $a_user_id, $a_create=true)
Lookup status.
determinePercentage($a_obj_id, $a_usr_id, $a_obj=null)
Determine percentage.
const LP_STATUS_COMPLETED
static _lookupInProgressForObject($a_obj_id, $a_user_ids=null)
Get in progress users for object.
static setInProgressIfNotAttempted($a_obj_id, $a_user_id)
This function shoudl be clalled for normal "read events".
static _lookupFailedForObject($a_obj_id, $a_user_ids=null)
Get failed users for object.
const LP_STATUS_NOT_REGISTERED
const LP_STATUS_PARTICIPATED
const LP_STATUS_IN_PROGRESS_NUM
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 _getCompleted($a_obj_id)
static _getCountNotAttempted($a_obj_id)
static _hasUserCompleted($a_obj_id, $a_user_id)
Lookup user object completion.
const LP_STATUS_NOT_ATTEMPTED_NUM
const LP_STATUS_REGISTERED
static checkLPModesForObjects($a_obj_ids, array &$a_coll_obj_ids)
Process lp modes for given objects.
refreshStatus($a_obj_id, $a_users=null)
Refresh status.
static _getNotAttempted($a_obj_id)
static setAllDirty()
Sets all status to dirty.
static _getCountCompleted($a_obj_id)
static getLPStatusForObjects($a_user_id, $a_obj_ids)
Get LP status for given objects (and user)
static _lookupStatusChanged($a_obj_id, $a_user_id)
Lookup status changed.
static _lookupCompletedForObject($a_obj_id, $a_user_ids=null)
Get completed users for object.
static setDirty($a_obj_id)
Sets status of an object to dirty.
const LP_STATUS_FAILED_NUM
static validateLPForObjects($a_user_id, $a_obj_ids, $a_parent_ref_id)
Process given objects for lp-relevance.
static _lookupPercentage($a_obj_id, $a_user_id)
Lookup percentage.
static raiseEvent($a_obj_id, $a_usr_id, $a_status, $a_percentage)
static getListGUIStatus($a_obj_id, $a_image_only=true)
static _getFailed($a_obj_id)
const LP_STATUS_NOT_ATTEMPTED
const LP_STATUS_IN_PROGRESS
static writeStatus($a_obj_id, $a_user_id, $a_status, $a_percentage=false, $a_force_per=false)
Write status for user and object.
static _getStatusText($a_status, $a_lng=null)
Get status alt text.
static _getImagePathForStatus($a_status)
Get image path for status.
static getLogger($a_component_id)
Get component logger.
static _getTypicalLearningTimeSeconds($a_rbac_id, $a_obj_id=0)
static _hasLearningProgressListGUI()
static _hasLearningProgressLearner()
static _enabledLearningProgress()
check wether learing progress is enabled or not
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)
static getInstance($a_obj_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
static img($a_src, $a_alt=null, $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
foreach($_POST as $key=> $value) $res