ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilLPStatusCollectionManual Class Reference
+ Inheritance diagram for ilLPStatusCollectionManual:
+ Collaboration diagram for ilLPStatusCollectionManual:

Public Member Functions

 determineStatus (int $a_obj_id, int $a_usr_id, ?object $a_obj=null)
 
- Public Member Functions inherited from ilLPStatus
 __construct (int $a_obj_id)
 
 _updateStatus (int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
 New status handling (st: status, nr: accesses, p: percentage, t: time spent, m: mark) Learning progress: More...
 
 determinePercentage (int $a_obj_id, int $a_usr_id, ?object $a_obj=null)
 
 determineStatus (int $a_obj_id, int $a_usr_id, ?object $a_obj=null)
 
 refreshStatus (int $a_obj_id, ?array $a_users=null)
 Refresh status. More...
 

Static Public Member Functions

static _getInProgress (int $a_obj_id)
 
static _getCompleted (int $a_obj_id)
 
static _getStatusInfo (int $a_obj_id)
 
static _getObjectStatus ( $a_obj_id, $a_user_id=null)
 
static _setObjectStatus (int $a_obj_id, int $a_user_id, ?array $a_completed=null)
 
- Static Public Member Functions inherited from ilLPStatus
static _getCountNotAttempted (int $a_obj_id)
 
static _getNotAttempted (int $a_obj_id)
 
static _getCountInProgress (int $a_obj_id)
 
static _getInProgress (int $a_obj_id)
 
static _getCountCompleted (int $a_obj_id)
 
static _getCompleted (int $a_obj_id)
 
static _getFailed (int $a_obj_id)
 
static _getCountFailed (int $a_obj_id)
 
static _getStatusInfo (int $a_obj_id)
 
static _getTypicalLearningTime (string $type, int $obj_id, int $sub_id=0)
 
static checkStatusForObject (int $a_obj_id, ?array $a_users=null)
 This function checks whether the status for a given number of users is dirty and must be recalculated. More...
 
static writeStatus (int $a_obj_id, int $a_user_id, int $a_status, int $a_percentage=0, bool $a_force_per=false, ?int &$a_old_status=self::LP_STATUS_NOT_ATTEMPTED_NUM)
 Write status for user and object. More...
 
static setInProgressIfNotAttempted (int $a_obj_id, int $a_user_id)
 This function shoudl be clalled for normal "read events". More...
 
static setAllDirty ()
 Sets all status to dirty. More...
 
static setDirty (int $a_obj_id)
 Sets status of an object to dirty. More...
 
static _lookupStatus (int $a_obj_id, int $a_user_id, bool $a_create=true)
 Lookup status. More...
 
static _lookupPercentage (int $a_obj_id, int $a_user_id)
 Lookup percentage. More...
 
static _hasUserCompleted (int $a_obj_id, int $a_user_id)
 Lookup user object completion. More...
 
static _lookupStatusChanged (int $a_obj_id, int $a_user_id)
 Lookup status changed. More...
 
static _lookupCompletedForObject (int $a_obj_id, ?array $a_user_ids=null)
 Get completed users for object. More...
 
static _lookupFailedForObject (int $a_obj_id, ?array $a_user_ids=null)
 Get failed users for object. More...
 
static _lookupInProgressForObject (int $a_obj_id, ?array $a_user_ids=null)
 Get in progress users for object. More...
 
static preloadListGUIData (array $a_obj_ids)
 
static getListGUIStatus (int $a_obj_id, bool $a_image_only=true)
 
static hasListGUIStatus (int $a_obj_id)
 

Additional Inherited Members

- Data Fields inherited from ilLPStatus
const LP_STATUS_NOT_ATTEMPTED = 'trac_no_attempted'
 
const LP_STATUS_IN_PROGRESS = 'trac_in_progress'
 
const LP_STATUS_COMPLETED = 'trac_completed'
 
const LP_STATUS_FAILED = 'trac_failed'
 
const LP_STATUS_NOT_ATTEMPTED_NUM = 0
 
const LP_STATUS_IN_PROGRESS_NUM = 1
 
const LP_STATUS_COMPLETED_NUM = 2
 
const LP_STATUS_FAILED_NUM = 3
 
const LP_STATUS_REGISTERED = 'trac_registered'
 
const LP_STATUS_NOT_REGISTERED = 'trac_not_registered'
 
const LP_STATUS_PARTICIPATED = 'trac_participated'
 
const LP_STATUS_NOT_PARTICIPATED = 'trac_not_participated'
 
- Static Public Attributes inherited from ilLPStatus
static $list_gui_cache
 
- Static Protected Member Functions inherited from ilLPStatus
static raiseEvent (int $a_obj_id, int $a_usr_id, int $a_status, int $a_old_status, int $a_percentage)
 
static _lookupStatusForObject (int $a_obj_id, int $a_status, ?array $a_user_ids=null)
 Get users with given status for object. More...
 
static validateLPForObjects (int $a_user_id, array $a_obj_ids, int $a_parent_ref_id)
 Process given objects for lp-relevance. More...
 
static checkLPModesForObjects (array $a_obj_ids, array &$a_coll_obj_ids)
 Process lp modes for given objects. More...
 
static getLPStatusForObjects (int $a_user_id, array $a_obj_ids)
 Get LP status for given objects (and user) More...
 
- Protected Attributes inherited from ilLPStatus
int $obj_id
 
ilDBInterface $db
 
ilObjectDataCache $ilObjDataCache
 

Detailed Description

Definition at line 24 of file class.ilLPStatusCollectionManual.php.

Member Function Documentation

◆ _getCompleted()

static ilLPStatusCollectionManual::_getCompleted ( int  $a_obj_id)
static
Parameters
int$a_obj_id
Returns
int[]

Reimplemented from ilLPStatus.

Definition at line 42 of file class.ilLPStatusCollectionManual.php.

42 : array
43 {
44 $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
45
46 $counter = 0;
47 $users = array();
48 foreach ($status_info['items'] as $item_id) {
49 $tmp_users = $status_info['completed'][$item_id];
50
51 if (!$counter++) {
52 $users = $tmp_users;
53 } else {
54 $users = array_intersect($users, $tmp_users);
55 }
56 }
57 return array_unique($users);
58 }
static _getStatusInfo(int $a_obj_id)
Reads informations about the object e.g test results, tlt, number of visits.
$counter

References $counter, and ilLPStatusWrapper\_getStatusInfo().

+ Here is the call graph for this function:

◆ _getInProgress()

static ilLPStatusCollectionManual::_getInProgress ( int  $a_obj_id)
static

Reimplemented from ilLPStatus.

Definition at line 26 of file class.ilLPStatusCollectionManual.php.

26 : array
27 {
28 $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
29
30 // find any completed item
31 $users = array();
32 if (isset($status_info['completed'])) {
33 foreach ($status_info['completed'] as $in_progress) {
34 $users = array_merge($users, $in_progress);
35 }
36 $users = array_unique($users);
37 }
38 // remove all users which have completed ALL items
39 return array_diff($users, ilLPStatusWrapper::_getCompleted($a_obj_id));
40 }
static _getCompleted(int $a_obj_id)
Static function to read the users who have the status 'completed'.

References ilLPStatusWrapper\_getCompleted(), and ilLPStatusWrapper\_getStatusInfo().

+ Here is the call graph for this function:

◆ _getObjectStatus()

static ilLPStatusCollectionManual::_getObjectStatus (   $a_obj_id,
  $a_user_id = null 
)
static

Definition at line 134 of file class.ilLPStatusCollectionManual.php.

137 : array {
138 global $DIC;
139
140 $ilDB = $DIC['ilDB'];
141
142 $res = array();
143
144 $sql = "SELECT subitem_id, completed, usr_id, last_change" .
145 " FROM ut_lp_coll_manual" .
146 " WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer");
147 if ($a_user_id) {
148 $sql .= " AND usr_id = " . $ilDB->quote($a_user_id, "integer");
149 }
150 $set = $ilDB->query($sql);
151 while ($row = $ilDB->fetchAssoc($set)) {
152 if (!$a_user_id) {
153 $res[(int) $row["subitem_id"]][(int) $row["usr_id"]] = (int) $row["completed"];
154 } else {
155 $res[(int) $row["subitem_id"]] = array((int) $row["completed"],
156 $row["last_change"]
157 );
158 }
159 }
160 return $res;
161 }
$res
Definition: ltiservices.php:69
global $DIC
Definition: shib_login.php:26

Referenced by _getStatusInfo().

+ Here is the caller graph for this function:

◆ _getStatusInfo()

static ilLPStatusCollectionManual::_getStatusInfo ( int  $a_obj_id)
static

Reimplemented from ilLPStatus.

Definition at line 60 of file class.ilLPStatusCollectionManual.php.

60 : array
61 {
62 $status_info = array();
63
64 $olp = ilObjectLP::getInstance($a_obj_id);
65 $collection = $olp->getCollectionInstance();
66 if ($collection) {
67 // @todo check if obj_id can be removed
68 $status_info["items"] = $collection->getItems($a_obj_id);
69
70 foreach ($status_info["items"] as $item_id) {
71 $status_info["completed"][$item_id] = array();
72 }
73
74 $ref_ids = ilObject::_getAllReferences($a_obj_id);
75 $ref_id = end($ref_ids);
76 $possible_items = $collection->getPossibleItems($ref_id);
77 $chapter_ids = array_intersect(
78 array_keys($possible_items),
79 $status_info["items"]
80 );
81
82 // fix order (adapt from possible items)
83 $status_info["items"] = $chapter_ids;
84
85 if ($chapter_ids) {
86 $status = self::_getObjectStatus($a_obj_id);
87
88 foreach ($chapter_ids as $item_id) {
89 $status_info["item_titles"][$item_id] = $possible_items[$item_id]["title"];
90
91 if (isset($status[$item_id])) {
92 foreach ($status[$item_id] as $user_id => $user_status) {
93 if ($user_status) {
94 $status_info["completed"][$item_id][] = $user_id;
95 }
96 }
97 }
98 }
99 }
100 }
101 return $status_info;
102 }
static _getObjectStatus( $a_obj_id, $a_user_id=null)
static getInstance(int $obj_id)
static _getAllReferences(int $id)
get all reference ids for object ID
$ref_id
Definition: ltiauth.php:66

References $ref_id, $user_id, ilObject\_getAllReferences(), _getObjectStatus(), and ilObjectLP\getInstance().

+ Here is the call graph for this function:

◆ _setObjectStatus()

static ilLPStatusCollectionManual::_setObjectStatus ( int  $a_obj_id,
int  $a_user_id,
?array  $a_completed = null 
)
static

Definition at line 163 of file class.ilLPStatusCollectionManual.php.

167 : void {
168 global $DIC;
169
170 $ilDB = $DIC['ilDB'];
171
172 $now = time();
173
174 if (!$a_completed) {
175 $a_completed = array();
176 }
177
178 $olp = ilObjectLP::getInstance($a_obj_id);
179 $collection = $olp->getCollectionInstance();
180 if ($collection) {
181 $existing = self::_getObjectStatus($a_obj_id, $a_user_id);
182
183 foreach ($collection->getItems() as $item_id) {
184 if (isset($existing[$item_id])) {
185 // value changed
186 if ((!$existing[$item_id][0] && in_array(
187 $item_id,
188 $a_completed
189 )) ||
190 ($existing[$item_id][0] && !in_array(
191 $item_id,
192 $a_completed
193 ))) {
194 $ilDB->manipulate(
195 "UPDATE ut_lp_coll_manual SET " .
196 " completed = " . $ilDB->quote(
197 in_array($item_id, $a_completed),
198 "integer"
199 ) .
200 " , last_change = " . $ilDB->quote(
201 $now,
202 "integer"
203 ) .
204 " WHERE obj_id = " . $ilDB->quote(
205 $a_obj_id,
206 "integer"
207 ) .
208 " AND usr_id = " . $ilDB->quote(
209 $a_user_id,
210 "integer"
211 ) .
212 " AND subitem_id = " . $ilDB->quote(
213 $item_id,
214 "integer"
215 )
216 );
217 }
218 } elseif (in_array($item_id, $a_completed)) {
219 $ilDB->manipulate(
220 "INSERT INTO ut_lp_coll_manual" .
221 "(obj_id,usr_id,subitem_id,completed,last_change)" .
222 " VALUES (" . $ilDB->quote($a_obj_id, "integer") .
223 " , " . $ilDB->quote($a_user_id, "integer") .
224 " , " . $ilDB->quote($item_id, "integer") .
225 " , " . $ilDB->quote(1, "integer") .
226 " , " . $ilDB->quote($now, "integer") . ")"
227 );
228 }
229 }
230 }
231
232 ilLPStatusWrapper::_updateStatus($a_obj_id, $a_user_id);
233 }
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)

◆ determineStatus()

ilLPStatusCollectionManual::determineStatus ( int  $a_obj_id,
int  $a_usr_id,
?object  $a_obj = null 
)

Reimplemented from ilLPStatus.

Definition at line 104 of file class.ilLPStatusCollectionManual.php.

108 : int {
109 $info = self::_getStatusInfo($a_obj_id);
110
111 if (isset($info["completed"])) {
112 $completed = true;
113 $in_progress = false;
114 foreach ($info["completed"] as $user_ids) {
115 // has completed at least 1 item
116 if (in_array($a_usr_id, $user_ids)) {
117 $in_progress = true;
118 } // must have completed all items to complete collection
119 else {
120 $completed = false;
121 }
122 }
123 if ($completed) {
125 }
126 if ($in_progress) {
128 }
129 }
130
132 }
const LP_STATUS_COMPLETED_NUM
const LP_STATUS_IN_PROGRESS_NUM
const LP_STATUS_NOT_ATTEMPTED_NUM
$info
Definition: entry_point.php:21

References $info, ilLPStatus\LP_STATUS_COMPLETED_NUM, and ilLPStatus\LP_STATUS_IN_PROGRESS_NUM.


The documentation for this class was generated from the following file: