42        $this->obj_id = $a_obj_id;
 
   93        include_once 
'Services/MetaData/classes/class.ilMDEducational.php';
 
  201    public function _updateStatus($a_obj_id, $a_usr_id, $a_obj = 
null, $a_percentage = 
false, $a_force_raise = 
false)
 
  205            "obj_id: %s, user id: %s, object: %s",
 
  208            (is_object($a_obj) ? get_class($a_obj) : 
'null')
 
  218        if (!
$changed && (
bool) $a_force_raise) { 
 
  262        $sql = 
"SELECT usr_id FROM ut_lp_marks WHERE " .
 
  263            " obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer") . 
" AND " .
 
  264            " status_dirty = " . 
$ilDB->quote(1, 
"integer");
 
  265        if (is_array($a_users) && count($a_users) > 0) {
 
  266            $sql .= 
" AND " . 
$ilDB->in(
"usr_id", $a_users, 
false, 
"integer");
 
  268        $set = 
$ilDB->query($sql);
 
  270        if ($rec = 
$ilDB->fetchAssoc($set)) {
 
  276        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"));
 
  281            if (
$r[
"cnt"] < count($a_users)) {
 
  287        if ($dirty || $missing) {
 
  288            require_once 
"Services/Tracking/classes/class.ilLPStatusFactory.php"; 
 
  290            $trac_obj->refreshStatus($a_obj_id, $a_users);
 
  294    protected static function raiseEvent($a_obj_id, $a_usr_id, $a_status, $a_percentage)
 
  296        global $ilAppEventHandler;
 
  299        $log->debug(
"obj_id: " . $a_obj_id . 
", user id: " . $a_usr_id . 
", status: " .
 
  300            $a_status . 
", percentage: " . $a_percentage);
 
  302        $ilAppEventHandler->raise(
"Services/Tracking", 
"updateStatus", array(
 
  303            "obj_id" => $a_obj_id,
 
  304            "usr_id" => $a_usr_id,
 
  305            "status" => $a_status,
 
  306            "percentage" => $a_percentage
 
  318        include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
 
  320        foreach ($not_attempted as $user_id) {
 
  322            if (self::writeStatus($a_obj_id, $user_id, self::LP_STATUS_NOT_ATTEMPTED_NUM, $percentage, 
true)) {
 
  327        foreach ($in_progress as $user_id) {
 
  329            if (self::writeStatus($a_obj_id, $user_id, self::LP_STATUS_IN_PROGRESS_NUM, $percentage, 
true)) {
 
  334        foreach ($completed as $user_id) {
 
  336            if (self::writeStatus($a_obj_id, $user_id, self::LP_STATUS_COMPLETED_NUM, $percentage, 
true)) {
 
  341        foreach (
$failed as $user_id) {
 
  343            if (self::writeStatus($a_obj_id, $user_id, self::LP_STATUS_FAILED_NUM, $percentage, 
true)) {
 
  348            $missing_users = array_diff($a_users, $not_attempted+$in_progress+$completed+
$failed);
 
  349            if ($missing_users) {
 
  350                foreach ($missing_users as $user_id) {
 
  363    public static function writeStatus($a_obj_id, $a_user_id, $a_status, $a_percentage = 
false, $a_force_per = 
false)
 
  368        $log->debug(
"obj_id: " . $a_obj_id . 
", user id: " . $a_user_id . 
", status: " .
 
  369            $a_status . 
", percentage: " . $a_percentage . 
", force: " . $a_force_per);
 
  371        $update_collections = 
false;
 
  375            "SELECT usr_id,status,status_dirty FROM ut_lp_marks WHERE " .
 
  376            " obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer") . 
" AND " .
 
  377            " usr_id = " . 
$ilDB->quote($a_user_id, 
"integer")
 
  379        $rec = 
$ilDB->fetchAssoc($set);
 
  384            if ($rec[
"status"] != $a_status) {
 
  386                    "UPDATE ut_lp_marks SET " .
 
  387                    " status = " . 
$ilDB->quote($a_status, 
"integer") . 
"," .
 
  388                    " status_changed = " . 
$ilDB->now() . 
"," .
 
  389                    " status_dirty = " . 
$ilDB->quote(0, 
"integer") .
 
  390                    " WHERE usr_id = " . 
$ilDB->quote($a_user_id, 
"integer") .
 
  391                    " AND obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer")
 
  394                    $update_collections = 
true;
 
  398            elseif ($rec[
"status_dirty"]) {
 
  400                    "UPDATE ut_lp_marks SET " .
 
  401                    " status_dirty = " . 
$ilDB->quote(0, 
"integer") .
 
  402                    " WHERE usr_id = " . 
$ilDB->quote($a_user_id, 
"integer") .
 
  403                    " AND obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer")
 
  424                    "obj_id" => array(
"integer", $a_obj_id),
 
  425                    "usr_id" => array(
"integer", $a_user_id)
 
  428                    "status" => array(
"integer", $a_status),
 
  429                    "status_changed" => array(
"timestamp", 
date(
"Y-m-d H:i:s")), 
 
  430                    "status_dirty" => array(
"integer", 0)
 
  434            $update_collections = 
true;
 
  438        if ($a_percentage !== 
false || $a_force_per) {
 
  439            $a_percentage = max(0, (
int) $a_percentage);
 
  440            $a_percentage = min(100, $a_percentage);
 
  442                "UPDATE ut_lp_marks SET " .
 
  443                " percentage = " . 
$ilDB->quote($a_percentage, 
"integer") .
 
  444                " WHERE usr_id = " . 
$ilDB->quote($a_user_id, 
"integer") .
 
  445                " AND obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer")
 
  450        if ($update_collections) {
 
  452            include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
 
  455            $set = 
$ilDB->query(
"SELECT ut_lp_collections.obj_id obj_id FROM " .
 
  456                "object_reference JOIN ut_lp_collections ON " .
 
  457                "(object_reference.obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer") .
 
  458                " AND object_reference.ref_id = ut_lp_collections.item_id)");
 
  459            while ($rec = 
$ilDB->fetchAssoc($set)) {
 
  471        return $update_collections;
 
  485        $needs_update = 
false;
 
  488            "SELECT usr_id, status FROM ut_lp_marks WHERE " .
 
  489            " obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer") . 
" AND " .
 
  490            " usr_id = " . 
$ilDB->quote($a_user_id, 
"integer")
 
  492        if ($rec = 
$ilDB->fetchAssoc($set)) {
 
  494            if ($rec[
"status"] == self::LP_STATUS_NOT_ATTEMPTED_NUM) {
 
  495                $needs_update = 
true;
 
  499            $needs_update = 
true;
 
  503            require_once 
"Services/Tracking/classes/class.ilLPStatusWrapper.php";
 
  519            "UPDATE ut_lp_marks SET " .
 
  520            " status_dirty = " . 
$ilDB->quote(1, 
"integer")
 
  535            "UPDATE ut_lp_marks SET " .
 
  536            " status_dirty = " . 
$ilDB->quote(1, 
"integer") .
 
  537            " WHERE obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer")
 
  548    public static function _lookupStatus($a_obj_id, $a_user_id, $a_create = 
true)
 
  553            "SELECT status FROM ut_lp_marks WHERE " .
 
  554            " status_dirty = " . 
$ilDB->quote(0, 
"integer") .
 
  555            " AND usr_id = " . 
$ilDB->quote($a_user_id, 
"integer") .
 
  556            " AND obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer")
 
  558        if ($rec = 
$ilDB->fetchAssoc($set)) {
 
  559            return $rec[
"status"];
 
  560        } elseif ((
bool) $a_create) {
 
  561            include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
 
  564                "SELECT status FROM ut_lp_marks WHERE " .
 
  565                " status_dirty = " . 
$ilDB->quote(0, 
"integer") .
 
  566                " AND usr_id = " . 
$ilDB->quote($a_user_id, 
"integer") .
 
  567                " AND obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer")
 
  569            if ($rec = 
$ilDB->fetchAssoc($set)) {
 
  570                return $rec[
"status"];
 
  586            "SELECT percentage FROM ut_lp_marks WHERE " .
 
  587            " status_dirty = " . 
$ilDB->quote(0, 
"integer") .
 
  588            " AND usr_id = " . 
$ilDB->quote($a_user_id, 
"integer") .
 
  589            " AND obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer")
 
  591        if ($rec = 
$ilDB->fetchAssoc($set)) {
 
  592            return $rec[
"percentage"];
 
  605        return (self::_lookupStatus($a_obj_id, $a_user_id) == self::LP_STATUS_COMPLETED_NUM);
 
  619            "SELECT status_changed FROM ut_lp_marks WHERE " .
 
  620            " status_dirty = " . 
$ilDB->quote(0, 
"integer") .
 
  621            " AND usr_id = " . 
$ilDB->quote($a_user_id, 
"integer") .
 
  622            " AND obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer")
 
  624        if ($rec = 
$ilDB->fetchAssoc($set)) {
 
  625            return $rec[
"status_changed"];
 
  627            include_once(
"./Services/Tracking/classes/class.ilLPStatusWrapper.php");
 
  630                "SELECT status_changed FROM ut_lp_marks WHERE " .
 
  631                " status_dirty = " . 
$ilDB->quote(0, 
"integer") .
 
  632                " AND usr_id = " . 
$ilDB->quote($a_user_id, 
"integer") .
 
  633                " AND obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer")
 
  635            if ($rec = 
$ilDB->fetchAssoc($set)) {
 
  636                return $rec[
"status_changed"];
 
  653        $sql = 
"SELECT usr_id, status, status_dirty FROM ut_lp_marks" .
 
  654            " WHERE obj_id = " . 
$ilDB->quote($a_obj_id, 
"integer") .
 
  655            " AND status = " . 
$ilDB->quote($a_status, 
"integer");
 
  657            $sql .= 
" AND " . 
$ilDB->in(
"usr_id", $a_user_ids, 
"", 
"integer");
 
  660        $set = 
$ilDB->query($sql);
 
  662        while ($rec = 
$ilDB->fetchAssoc($set)) {
 
  663            if (
$res[
"status_dirty"]) {
 
  665                if (self::_lookupStatus($a_obj_id, $rec[
"usr_id"]) != $a_status) {
 
  669            $res[] = $rec[
"usr_id"];
 
  726        $lp_invalid = array();
 
  728        include_once 
"Services/Object/classes/class.ilObjectLP.php";
 
  730        foreach ($memberships as 
$obj_id => $status) {
 
  736        return array_diff($a_obj_ids, $lp_invalid);
 
  750        include_once 
"Services/Tracking/classes/collection/class.ilLPCollection.php";
 
  753        include_once 
"Services/Tracking/classes/class.ilLPObjSettings.php";
 
  757        foreach ($existing as 
$obj_id => $obj_mode) {
 
  761                if (in_array($obj_mode, $coll_modes)) {
 
  768        include_once 
"Services/Object/classes/class.ilObjectLP.php";
 
  769        if (
sizeof($existing) != 
sizeof($a_obj_ids)) {
 
  770            foreach (array_diff($a_obj_ids, $existing) as 
$obj_id) {
 
  772                $mode = $olp->getCurrentMode();
 
  779                    if (in_array($mode, $coll_modes)) {
 
  787        return array_values(
$valid);
 
  804        $sql = 
"SELECT status, status_dirty, obj_id FROM ut_lp_marks" .
 
  805            " WHERE " . 
$ilDB->in(
"obj_id", $a_obj_ids, 
"", 
"integer") .
 
  806            " AND usr_id = " . 
$ilDB->quote($a_user_id, 
"integer");
 
  807        $set = 
$ilDB->query($sql);
 
  809            if (!
$row[
"status_dirty"]) {
 
  817        foreach ($a_obj_ids as 
$obj_id) {
 
  837        include_once(
"Services/Tracking/classes/class.ilObjUserTracking.php");
 
  838        if (
$ilUser->getId() != ANONYMOUS_USER_ID &&
 
  848            $coll_obj_ids = array();
 
  860            $lng->loadLanguageModule(
"trac");
 
  861            include_once(
"./Services/Tracking/classes/class.ilLearningProgressBaseGUI.php");
 
  869        self::$list_gui_cache = 
$res;
 
  876            if (isset(self::$list_gui_cache[$a_obj_id][
"image"])) {
 
  877                $image = self::$list_gui_cache[$a_obj_id][
"image"];
 
  882        return self::$list_gui_cache[$a_obj_id];
 
sprintf('%.4f', $callTime)
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
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 getListGUIStatus($a_obj_id, $a_image_only=false)
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 _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="", $a_width="", $a_height="", $a_border=0, $a_id="", $a_class="")
Build img tag.
foreach($_POST as $key=> $value) $res