ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilLPStatusCollection Class Reference
+ Inheritance diagram for ilLPStatusCollection:
+ Collaboration diagram for ilLPStatusCollection:

Public Member Functions

 __construct ($a_obj_id)
 
 determineStatus ($a_obj_id, $a_user_id, $a_obj=null)
 Determine status. More...
 
- Public Member Functions inherited from ilLPStatus
 __construct ($a_obj_id)
 
 _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) More...
 
 determinePercentage ($a_obj_id, $a_usr_id, $a_obj=null)
 Determine percentage. More...
 
 determineStatus ($a_obj_id, $a_usr_id, $a_obj=null)
 Determine status. More...
 
 refreshStatus ($a_obj_id, $a_users=null)
 Refresh status. More...
 

Static Public Member Functions

static _getNotAttempted ($a_obj_id)
 
static _getInProgress ($a_obj_id)
 
static _getCompleted ($a_obj_id)
 Get completed users New handling for optional grouped assignments. More...
 
static _getFailed ($a_obj_id)
 
static _getStatusInfo ($a_obj_id)
 
static _getTypicalLearningTime ($a_obj_id)
 
static determineGroupingStatus ($status, $gr_info, $user_id, $is_grouping)
 Determine grouping status @global $ilObjDataCache. More...
 
static _lookupCompletedForObject ($a_obj_id, $a_user_ids=null)
 Get completed users for object. More...
 
static _lookupFailedForObject ($a_obj_id, $a_user_ids=null)
 Get failed users for object. More...
 
static _lookupInProgressForObject ($a_obj_id, $a_user_ids=null)
 Get in progress users for object. More...
 
- Static Public Member Functions inherited from ilLPStatus
static _getCountNotAttempted ($a_obj_id)
 
static _getNotAttempted ($a_obj_id)
 
static _getCountInProgress ($a_obj_id)
 
static _getInProgress ($a_obj_id)
 
static _getCountCompleted ($a_obj_id)
 
static _getCompleted ($a_obj_id)
 
static _getFailed ($a_obj_id)
 
static _getCountFailed ()
 
static _getStatusInfo ($a_obj_id)
 
static _getTypicalLearningTime ($a_obj_id)
 
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. More...
 
static writeStatus ($a_obj_id, $a_user_id, $a_status, $a_percentage=false, $a_force_per=false)
 Write status for user and object. More...
 
static setInProgressIfNotAttempted ($a_obj_id, $a_user_id)
 This function shoudl be clalled for normal "read events". More...
 
static setAllDirty ()
 Sets all status to dirty. More...
 
static setDirty ($a_obj_id)
 Sets status of an object to dirty. More...
 
static _lookupStatus ($a_obj_id, $a_user_id, $a_create=true)
 Lookup status. More...
 
static _lookupPercentage ($a_obj_id, $a_user_id)
 Lookup percentage. More...
 
static _hasUserCompleted ($a_obj_id, $a_user_id)
 Lookup user object completion. More...
 
static _lookupStatusChanged ($a_obj_id, $a_user_id)
 Lookup status changed. More...
 
static _lookupCompletedForObject ($a_obj_id, $a_user_ids=null)
 Get completed users for object. More...
 
static _lookupFailedForObject ($a_obj_id, $a_user_ids=null)
 Get failed users for object. More...
 
static _lookupInProgressForObject ($a_obj_id, $a_user_ids=null)
 Get in progress users for object. More...
 
static preloadListGUIData ($a_obj_ids)
 
static getListGUIStatus ($a_obj_id, $a_image_only=false)
 

Static Protected Member Functions

static getMembers ($a_obj_id)
 Get members for object. More...
 
- Static Protected Member Functions inherited from ilLPStatus
static raiseEvent ($a_obj_id, $a_usr_id, $a_status, $a_percentage)
 
static _lookupStatusForObject ($a_obj_id, $a_status, $a_user_ids=null)
 Get users with given status for object. More...
 
static validateLPForObjects ($a_user_id, $a_obj_ids, $a_parent_ref_id)
 Process given objects for lp-relevance. More...
 
static checkLPModesForObjects ($a_obj_ids, array &$a_coll_obj_ids)
 Process lp modes for given objects. More...
 
static getLPStatusForObjects ($a_user_id, $a_obj_ids)
 Get LP status for given objects (and user) More...
 

Additional Inherited Members

- Data Fields inherited from ilLPStatus
 $obj_id = null
 
 $db = null
 
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
 

Detailed Description

Definition at line 36 of file class.ilLPStatusCollection.php.

Constructor & Destructor Documentation

◆ __construct()

ilLPStatusCollection::__construct (   $a_obj_id)

Reimplemented from ilLPStatus.

Definition at line 38 of file class.ilLPStatusCollection.php.

39 {
40 global $ilDB;
41
42 parent::__construct($a_obj_id);
43 $this->db = $ilDB;
44 }
global $ilDB

References $ilDB.

Member Function Documentation

◆ _getCompleted()

static ilLPStatusCollection::_getCompleted (   $a_obj_id)
static

Get completed users New handling for optional grouped assignments.

Parameters
int$a_obj_id
Returns
array users

Reimplemented from ilLPStatus.

Definition at line 99 of file class.ilLPStatusCollection.php.

100 {
101 global $ilObjDataCache;
102
103 include_once './Services/Object/classes/class.ilObjectLP.php';
104 $olp = ilObjectLP::getInstance($a_obj_id);
105 $collection = $olp->getCollectionInstance();
106 if ($collection) {
107 $grouped_items = $collection->getGroupedItemsForLPStatus();
108 }
109 if (!sizeof($grouped_items)) {
110 // #11513 - empty collections cannot be completed
111 return array();
112 } else {
113 // New handling for optional assignments
114 $counter = 0;
115 $users = array();
116 foreach ($grouped_items as $grouping_id => $grouping) {
117 $isGrouping = $grouping_id ? true : false;
118 $grouping_completed = array();
119 $grouping_completed_users_num = array();
120 foreach ((array) $grouping['items'] as $item) {
121 $item_id = $ilObjDataCache->lookupObjId($item);
122 $tmp_users = ilLPStatusWrapper::_getCompleted($item_id);
123 if ($isGrouping) {
124 // Iterated through all grouped items and count the number of fullfiled items
125 foreach ($tmp_users as $tmp_user_id) {
126 ++$grouping_completed_users_num[$tmp_user_id];
127 }
128 } else {
129 if (!$counter++) {
130 $users = $tmp_users;
131 } else {
132 $users = array_intersect($users, $tmp_users);
133 }
134 }
135 }
136 if ($isGrouping) {
137 // Iterate through all "grouping_completed_users_num"
138 // All users with completed items greater equal than "num_obligatory" are completed
139 foreach ($grouping_completed_users_num as $tmp_user_id => $grouping_num_completed) {
140 if ($grouping_num_completed >= $grouping['num_obligatory']) {
141 $grouping_completed[] = $tmp_user_id;
142 }
143 }
144
145 // build intersection of users
146 if (!$counter++) {
147 $users = $grouping_completed;
148 } else {
149 $users = array_intersect($users, $grouping_completed);
150 }
151 }
152 }
153 }
154
155 $users = array_diff($users, ilLPStatusWrapper::_getFailed($a_obj_id));
156
157 if ($users) {
158 // Exclude all non members
159 $users = array_intersect(self::getMembers($a_obj_id), (array) $users);
160 }
161
162 return (array) $users;
163 }
$users
Definition: authpage.php:44
static _getCompleted($a_obj_id)
Static function to read the users who have the status 'completed'.
static _getFailed($a_obj_id)
Static function to read the users who have the status 'completed'.
static getInstance($a_obj_id)
$counter

References $counter, $users, ilLPStatusWrapper\_getCompleted(), ilLPStatusWrapper\_getFailed(), and ilObjectLP\getInstance().

+ Here is the call graph for this function:

◆ _getFailed()

static ilLPStatusCollection::_getFailed (   $a_obj_id)
static

Reimplemented from ilLPStatus.

Definition at line 165 of file class.ilLPStatusCollection.php.

166 {
167 global $ilObjDataCache;
168
169 $users = array();
170
171 include_once './Services/Object/classes/class.ilObjectLP.php';
172 $olp = ilObjectLP::getInstance($a_obj_id);
173 $collection = $olp->getCollectionInstance();
174 if ($collection) {
175 foreach ($collection->getGroupedItemsForLPStatus() as $grouping_id => $grouping) {
176 $isGrouping = $grouping_id ? true : false;
177
178 $gr_failed = array();
179 $gr_failed_users_num = array();
180 $counter = 0;
181 foreach ((array) $grouping['items'] as $item) {
182 $item_id = $ilObjDataCache->lookupObjId($item);
183 $tmp_users = ilLPStatusWrapper::_getFailed($item_id);
184
185 if ($isGrouping) {
186 foreach ($tmp_users as $tmp_user_id) {
187 ++$gr_failed_users_num[$tmp_user_id];
188 }
189 } else {
190 // One item failed is sufficient for status failed.
191 $gr_failed = array_merge($gr_failed, $tmp_users);
192 }
193 $counter++;
194 }
195 if ($isGrouping) {
196 $allowed_failed = count($grouping['items']) - $grouping['num_obligatory'];
197 // Itereate over all failed users and check whether the allowd_failed value exceeded
198 foreach ($gr_failed_users_num as $tmp_user_id => $num_failed) {
199 if ($num_failed > $allowed_failed) {
200 $gr_failed[] = $tmp_user_id;
201 }
202 }
203 }
204 $users = array_unique(array_merge($users, $gr_failed));
205 }
206 }
207
208 if ($users) {
209 // Exclude all non members
210 $users = array_intersect(self::getMembers($a_obj_id), (array) $users);
211 }
212
213 return array_unique($users);
214 }

References $counter, $users, ilLPStatusWrapper\_getFailed(), and ilObjectLP\getInstance().

+ Here is the call graph for this function:

◆ _getInProgress()

static ilLPStatusCollection::_getInProgress (   $a_obj_id)
static

Reimplemented from ilLPStatus.

Definition at line 61 of file class.ilLPStatusCollection.php.

62 {
63 include_once './Services/Tracking/classes/class.ilChangeEvent.php';
65
66 include_once './Services/Object/classes/class.ilObjectLP.php';
67 $olp = ilObjectLP::getInstance($a_obj_id);
68 $collection = $olp->getCollectionInstance();
69 if ($collection) {
70 foreach ($collection->getItems() as $item_id) {
71 $item_id = ilObject::_lookupObjId($item_id);
72
73 // merge arrays of users with status 'in progress'
74 $users = array_unique(array_merge((array) $users, ilLPStatusWrapper::_getInProgress($item_id)));
75 $users = array_unique(array_merge((array) $users, ilLPStatusWrapper::_getCompleted($item_id)));
76 }
77 }
78
79 // Exclude all users with status completed.
80 $users = array_diff((array) $users, ilLPStatusWrapper::_getCompleted($a_obj_id));
81 // Exclude all users with status failed.
82 $users = array_diff((array) $users, ilLPStatusWrapper::_getFailed($a_obj_id));
83
84 if ($users) {
85 // Exclude all non members
86 $users = array_intersect(self::getMembers($a_obj_id), (array) $users);
87 }
88
89 return $users;
90 }
static lookupUsersInProgress($a_obj_id)
Lookup users in progress.
static _getInProgress($a_obj_id)
Static function to read users who have the status 'in_progress'.
static _lookupObjId($a_id)

References $users, ilLPStatusWrapper\_getCompleted(), ilLPStatusWrapper\_getFailed(), ilLPStatusWrapper\_getInProgress(), ilObject\_lookupObjId(), ilObjectLP\getInstance(), and ilChangeEvent\lookupUsersInProgress().

+ Here is the call graph for this function:

◆ _getNotAttempted()

static ilLPStatusCollection::_getNotAttempted (   $a_obj_id)
static

Reimplemented from ilLPStatus.

Definition at line 46 of file class.ilLPStatusCollection.php.

47 {
48 $users = array();
49
50 $members = self::getMembers($a_obj_id);
51 if ($members) {
52 // diff in progress and completed (use stored result in LPStatusWrapper)
53 $users = array_diff((array) $members, ilLPStatusWrapper::_getInProgress($a_obj_id));
54 $users = array_diff((array) $users, ilLPStatusWrapper::_getCompleted($a_obj_id));
55 $users = array_diff((array) $users, ilLPStatusWrapper::_getFailed($a_obj_id));
56 }
57
58 return $users;
59 }
static getMembers($a_obj_id)
Get members for object.

References $users, ilLPStatusWrapper\_getCompleted(), ilLPStatusWrapper\_getFailed(), ilLPStatusWrapper\_getInProgress(), and getMembers().

+ Here is the call graph for this function:

◆ _getStatusInfo()

static ilLPStatusCollection::_getStatusInfo (   $a_obj_id)
static

Reimplemented from ilLPStatus.

Definition at line 216 of file class.ilLPStatusCollection.php.

217 {
218 $status_info = array();
219
220 include_once './Services/Object/classes/class.ilObjectLP.php';
221 $olp = ilObjectLP::getInstance($a_obj_id);
222 $collection = $olp->getCollectionInstance();
223 if ($collection) {
224 $status_info['collections'] = $collection->getItems();
225 $status_info['num_collections'] = count($status_info['collections']);
226 }
227
228 return $status_info;
229 }

References ilObjectLP\getInstance().

+ Here is the call graph for this function:

◆ _getTypicalLearningTime()

static ilLPStatusCollection::_getTypicalLearningTime (   $a_obj_id)
static

Reimplemented from ilLPStatus.

Definition at line 231 of file class.ilLPStatusCollection.php.

232 {
233 global $ilObjDataCache;
234
235 if ($ilObjDataCache->lookupType($a_obj_id) == 'sahs') {
236 return parent::_getTypicalLearningTime($a_obj_id);
237 }
238
239 $tlt = 0;
240 $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
241 foreach ($status_info['collections'] as $item) {
242 $tlt += ilLPStatusWrapper::_getTypicalLearningTime($ilObjDataCache->lookupObjId($item));
243 }
244 return $tlt;
245 }
static _getStatusInfo($a_obj_id)
Reads informations about the object e.g test results, tlt, number of visits.
static _getTypicalLearningTime($a_obj_id)
Reads Typical learning time.

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

+ Here is the call graph for this function:

◆ _lookupCompletedForObject()

static ilLPStatusCollection::_lookupCompletedForObject (   $a_obj_id,
  $a_user_ids = null 
)
static

Get completed users for object.

Parameters
int$a_obj_id
array$a_user_ids
Returns
array

Reimplemented from ilLPStatus.

Definition at line 391 of file class.ilLPStatusCollection.php.

392 {
393 if (!$a_user_ids) {
394 $a_user_ids = self::getMembers($a_obj_id);
395 if (!$a_user_ids) {
396 return array();
397 }
398 }
399 return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_COMPLETED_NUM, $a_user_ids);
400 }
static _lookupStatusForObject($a_obj_id, $a_status, $a_user_ids=null)
Get users with given status for object.

References ilLPStatus\_lookupStatusForObject(), and getMembers().

+ Here is the call graph for this function:

◆ _lookupFailedForObject()

static ilLPStatusCollection::_lookupFailedForObject (   $a_obj_id,
  $a_user_ids = null 
)
static

Get failed users for object.

Parameters
int$a_obj_id
array$a_user_ids
Returns
array

Reimplemented from ilLPStatus.

Definition at line 409 of file class.ilLPStatusCollection.php.

410 {
411 if (!$a_user_ids) {
412 $a_user_ids = self::getMembers($a_obj_id);
413 if (!$a_user_ids) {
414 return array();
415 }
416 }
417 return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_FAILED_NUM, $a_user_ids);
418 }

References ilLPStatus\_lookupStatusForObject(), and getMembers().

+ Here is the call graph for this function:

◆ _lookupInProgressForObject()

static ilLPStatusCollection::_lookupInProgressForObject (   $a_obj_id,
  $a_user_ids = null 
)
static

Get in progress users for object.

Parameters
int$a_obj_id
array$a_user_ids
Returns
array

Reimplemented from ilLPStatus.

Definition at line 427 of file class.ilLPStatusCollection.php.

428 {
429 if (!$a_user_ids) {
430 $a_user_ids = self::getMembers($a_obj_id);
431 if (!$a_user_ids) {
432 return array();
433 }
434 }
435 return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_IN_PROGRESS_NUM, $a_user_ids);
436 }

References ilLPStatus\_lookupStatusForObject(), and getMembers().

+ Here is the call graph for this function:

◆ determineGroupingStatus()

static ilLPStatusCollection::determineGroupingStatus (   $status,
  $gr_info,
  $user_id,
  $is_grouping 
)
static

Determine grouping status @global $ilObjDataCache.

Parameters
array$status
array$items
int$user_id
boolean$is_grouping
Returns
boolean

Definition at line 311 of file class.ilLPStatusCollection.php.

312 {
313 global $ilObjDataCache;
314
315 $items = $gr_info['items'];
316 if ($is_grouping) {
317 $max_allowed_failed = count($items) - $gr_info['num_obligatory'];
318 $required_completed = $gr_info['num_obligatory'];
319 } else {
320 $max_allowed_failed = 0;
321 $required_completed = count($items);
322 }
323
324 // Required for grouping with a number of obligatory items
325 $num_failed = 0;
326 $num_completed = 0;
327
328 foreach ($items as $item_id) {
329 $item_id = $ilObjDataCache->lookupObjId($item_id);
330 $gr_status = ilLPStatusWrapper::_determineStatus($item_id, $user_id);
331
332 if ($gr_status == self::LP_STATUS_FAILED_NUM) {
333 if (++$num_failed > $max_allowed_failed) {
334 $status['failed'] = true;
335 $status['completed'] = false;
336 return $status;
337 }
338 }
339 if ($gr_status == self::LP_STATUS_COMPLETED_NUM) {
340 if (++$num_completed >= $required_completed) {
341 return $status;
342 }
343 }
344 }
345 // Not completed since returned above
346 $status['completed'] = false;
347 return $status;
348 }
static _determineStatus($a_obj_id, $a_usr_id)
Determine status.

References ilLPStatusWrapper\_determineStatus().

Referenced by determineStatus().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ determineStatus()

ilLPStatusCollection::determineStatus (   $a_obj_id,
  $a_user_id,
  $a_obj = null 
)

Determine status.

Parameters
integerobject id
integeruser id
objectobject (optional depends on object type)
Returns
integer status

Reimplemented from ilLPStatus.

Definition at line 255 of file class.ilLPStatusCollection.php.

256 {
257 global $ilObjDataCache;
258
259 $status['completed'] = true;
260 $status['failed'] = false;
261 $status['in_progress'] = false;
262
263 switch ($ilObjDataCache->lookupType($a_obj_id)) {
264 case "crs":
265 case "fold":
266 case "grp":
267 include_once "./Services/Tracking/classes/class.ilChangeEvent.php";
268 if (ilChangeEvent::hasAccessed($a_obj_id, $a_user_id)) {
269 $status['in_progress'] = true;
270 }
271
272 include_once './Services/Object/classes/class.ilObjectLP.php';
273 $olp = ilObjectLP::getInstance($a_obj_id);
274 $collection = $olp->getCollectionInstance();
275 if ($collection) {
276 $grouped_items = $collection->getGroupedItemsForLPStatus();
277 }
278 if (!sizeof($grouped_items)) {
279 // #11513 - empty collections cannot be completed
280 $status['completed'] = false;
281 } else {
282 foreach ($grouped_items as $grouping_id => $grouping) {
283 $isGrouping = $grouping_id ? true : false;
284 $status = self::determineGroupingStatus($status, $grouping, $a_user_id, $isGrouping);
285 }
286 }
287
288 if ($status['completed']) {
290 }
291 if ($status['failed']) {
293 }
294 if ($status['in_progress']) {
296 }
297 break;
298 }
300 }
static hasAccessed($a_obj_id, $a_usr_id)
Has accessed.
static determineGroupingStatus($status, $gr_info, $user_id, $is_grouping)
Determine grouping status @global $ilObjDataCache.
const LP_STATUS_COMPLETED_NUM
const LP_STATUS_IN_PROGRESS_NUM
const LP_STATUS_NOT_ATTEMPTED_NUM
const LP_STATUS_FAILED_NUM

References determineGroupingStatus(), ilObjectLP\getInstance(), ilChangeEvent\hasAccessed(), ilLPStatus\LP_STATUS_COMPLETED_NUM, ilLPStatus\LP_STATUS_FAILED_NUM, ilLPStatus\LP_STATUS_IN_PROGRESS_NUM, and ilLPStatus\LP_STATUS_NOT_ATTEMPTED_NUM.

+ Here is the call graph for this function:

◆ getMembers()

static ilLPStatusCollection::getMembers (   $a_obj_id)
staticprotected

Get members for object.

Parameters
int$a_obj_id
Returns
array

Definition at line 355 of file class.ilLPStatusCollection.php.

356 {
357 global $ilObjDataCache, $tree;
358
359 switch ($ilObjDataCache->lookupType($a_obj_id)) {
360 case 'crs':
361 include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
362 $member_obj = ilCourseParticipants::_getInstanceByObjId($a_obj_id);
363 return $member_obj->getMembers();
364
365 case 'grp':
366 include_once 'Modules/Group/classes/class.ilGroupParticipants.php';
367 $member_obj = ilGroupParticipants::_getInstanceByObjId($a_obj_id);
368 return $member_obj->getMembers();
369
370 case 'fold':
371 $folder_ref_ids = ilObject::_getAllReferences($a_obj_id);
372 $folder_ref_id = current($folder_ref_ids);
373 if ($crs_id = $tree->checkForParentType($folder_ref_id, 'crs')) {
374 include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
376 return $member_obj->getMembers();
377 }
378 break;
379 }
380
381 return array();
382 }
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _getAllReferences($a_id)
get all reference ids of object

References ilObject\_getAllReferences(), ilCourseParticipants\_getInstanceByObjId(), ilGroupParticipants\_getInstanceByObjId(), and ilObject\_lookupObjId().

Referenced by _getNotAttempted(), _lookupCompletedForObject(), _lookupFailedForObject(), and _lookupInProgressForObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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