ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5
ilLPStatusCollection Class Reference
+ Inheritance diagram for ilLPStatusCollection:
+ Collaboration diagram for ilLPStatusCollection:

Public Member Functions

 ilLPStatusCollection ($a_obj_id)
 
 _getNotAttempted ($a_obj_id)
 
 _getInProgress ($a_obj_id)
 
 _getCompleted ($a_obj_id)
 Get completed users New handling for optional grouped assignments. More...
 
 _getFailed ($a_obj_id)
 
 _getStatusInfo ($a_obj_id)
 
 _getTypicalLearningTime ($a_obj_id)
 
 determineStatus ($a_obj_id, $a_user_id, $a_obj=null)
 Determine status. More...
 
- Public Member Functions inherited from ilLPStatus
 ilLPStatus ($a_obj_id)
 
 _getCountNotAttempted ($a_obj_id)
 
 _getNotAttempted ($a_obj_id)
 
 _getCountInProgress ($a_obj_id)
 
 _getInProgress ($a_obj_id)
 
 _getCountCompleted ($a_obj_id)
 
 _getCompleted ($a_obj_id)
 
 _getFailed ($a_obj_id)
 
 _getCountFailed ()
 
 _getStatusInfo ($a_obj_id)
 
 _getTypicalLearningTime ($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...
 
 _lookupStatusChanged ($a_obj_id, $a_user_id)
 Lookup status changed. More...
 

Static Public Member Functions

static determineGroupingStatus ($status, $gr_info, $user_id, $is_grouping)
 Determine grouping status $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 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 _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)
 

Static Protected Member Functions

static getMembers ($a_obj_id)
 Get members for object. More...
 
- Static Protected Member Functions inherited from ilLPStatus
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
 
- Protected Member Functions inherited from ilLPStatus
 raiseEvent ($a_obj_id, $a_usr_id, $a_status, $a_percentage)
 

Detailed Description

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

Member Function Documentation

◆ _getCompleted()

ilLPStatusCollection::_getCompleted (   $a_obj_id)

Get completed users New handling for optional grouped assignments.

Parameters
int$a_obj_id
Returns
array users

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

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

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

◆ _getFailed()

ilLPStatusCollection::_getFailed (   $a_obj_id)

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

References ilLPStatusWrapper\_getFailed(), and ilObjectLP\getInstance().

191  {
192  global $ilObjDataCache;
193 
194  $users = array();
195 
196  include_once './Services/Object/classes/class.ilObjectLP.php';
197  $olp = ilObjectLP::getInstance($a_obj_id);
198  $collection = $olp->getCollectionInstance();
199  if($collection)
200  {
201  foreach($collection->getGroupedItemsForLPStatus() as $grouping_id => $grouping)
202  {
203  $isGrouping = $grouping_id ? true : false;
204 
205  $gr_failed = array();
206  $gr_failed_users_num = array();
207  $counter = 0;
208  foreach((array) $grouping['items'] as $item)
209  {
210  $item_id = $ilObjDataCache->lookupObjId($item);
211  $tmp_users = ilLPStatusWrapper::_getFailed($item_id);
212 
213  if($isGrouping)
214  {
215  foreach($tmp_users as $tmp_user_id)
216  {
217  ++$gr_failed_users_num[$tmp_user_id];
218  }
219  }
220  else
221  {
222  // One item failed is sufficient for status failed.
223  $gr_failed = array_merge($gr_failed,$tmp_users);
224  }
225  $counter++;
226  }
227  if($isGrouping)
228  {
229  $allowed_failed = count($grouping['items']) - $grouping['num_obligatory'];
230  // Itereate over all failed users and check whether the allowd_failed value exceeded
231  foreach($gr_failed_users_num as $tmp_user_id => $num_failed)
232  {
233  if($num_failed > $allowed_failed)
234  {
235  $gr_failed[] = $tmp_user_id;
236  }
237  }
238 
239  }
240  $users = array_unique(array_merge($users, $gr_failed));
241  }
242  }
243 
244  if($users)
245  {
246  // Exclude all non members
247  $users = array_intersect(self::getMembers($a_obj_id), (array)$users);
248  }
249 
250  return array_unique($users);
251  }
_getFailed($a_obj_id)
Static function to read the users who have the status 'completed'.
static getInstance($a_obj_id)
+ Here is the call graph for this function:

◆ _getInProgress()

ilLPStatusCollection::_getInProgress (   $a_obj_id)

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

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

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

◆ _getNotAttempted()

ilLPStatusCollection::_getNotAttempted (   $a_obj_id)

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

References ilLPStatusWrapper\_getCompleted(), ilLPStatusWrapper\_getFailed(), and ilLPStatusWrapper\_getInProgress().

48  {
49  $users = array();
50 
51  $members = self::getMembers($a_obj_id);
52  if($members)
53  {
54  // diff in progress and completed (use stored result in LPStatusWrapper)
55  $users = array_diff((array) $members, ilLPStatusWrapper::_getInProgress($a_obj_id));
56  $users = array_diff((array) $users, ilLPStatusWrapper::_getCompleted($a_obj_id));
57  $users = array_diff((array) $users, ilLPStatusWrapper::_getFailed($a_obj_id));
58  }
59 
60  return $users;
61  }
_getFailed($a_obj_id)
Static function to read the users who have the status 'completed'.
_getCompleted($a_obj_id)
Static function to read the users who have the status 'completed'.
_getInProgress($a_obj_id)
Static function to read users who have the status 'in_progress'.
+ Here is the call graph for this function:

◆ _getStatusInfo()

ilLPStatusCollection::_getStatusInfo (   $a_obj_id)

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

References ilObjectLP\getInstance().

254  {
255  $status_info = array();
256 
257  include_once './Services/Object/classes/class.ilObjectLP.php';
258  $olp = ilObjectLP::getInstance($a_obj_id);
259  $collection = $olp->getCollectionInstance();
260  if($collection)
261  {
262  $status_info['collections'] = $collection->getItems();
263  $status_info['num_collections'] = count($status_info['collections']);
264  }
265 
266  return $status_info;
267  }
static getInstance($a_obj_id)
+ Here is the call graph for this function:

◆ _getTypicalLearningTime()

ilLPStatusCollection::_getTypicalLearningTime (   $a_obj_id)

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

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

270  {
271  global $ilObjDataCache;
272 
273  if($ilObjDataCache->lookupType($a_obj_id) == 'sahs')
274  {
275  return parent::_getTypicalLearningTime($a_obj_id);
276  }
277 
278  $tlt = 0;
279  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
280  foreach($status_info['collections'] as $item)
281  {
282  $tlt += ilLPStatusWrapper::_getTypicalLearningTime($ilObjDataCache->lookupObjId($item));
283  }
284  return $tlt;
285  }
_getStatusInfo($a_obj_id)
Reads informations about the object e.g test results, tlt, number of visits.
_getTypicalLearningTime($a_obj_id)
Reads Typical learning time.
+ 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

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

452  {
453  if(!$a_user_ids)
454  {
455  $a_user_ids = self::getMembers($a_obj_id);
456  if(!$a_user_ids)
457  {
458  return array();
459  }
460  }
461  return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_COMPLETED_NUM, $a_user_ids);
462  }

◆ _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

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

472  {
473  if(!$a_user_ids)
474  {
475  $a_user_ids = self::getMembers($a_obj_id);
476  if(!$a_user_ids)
477  {
478  return array();
479  }
480  }
481  return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_FAILED_NUM, $a_user_ids);
482  }

◆ _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

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

492  {
493  if(!$a_user_ids)
494  {
495  $a_user_ids = self::getMembers($a_obj_id);
496  if(!$a_user_ids)
497  {
498  return array();
499  }
500  }
501  return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_IN_PROGRESS_NUM, $a_user_ids);
502  }

◆ determineGroupingStatus()

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

Determine grouping status $ilObjDataCache.

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

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

References ilLPStatusWrapper\_determineStatus().

362  {
363  global $ilObjDataCache;
364 
365  $items = $gr_info['items'];
366  if($is_grouping)
367  {
368  $max_allowed_failed = count($items) - $gr_info['num_obligatory'];
369  $required_completed = $gr_info['num_obligatory'];
370  }
371  else
372  {
373  $max_allowed_failed = 0;
374  $required_completed = count($items);
375  }
376 
377  // Required for grouping with a number of obligatory items
378  $num_failed = 0;
379  $num_completed = 0;
380 
381  foreach($items as $item_id)
382  {
383  $item_id = $ilObjDataCache->lookupObjId($item_id);
384  $gr_status = ilLPStatusWrapper::_determineStatus($item_id, $user_id);
385 
386  if($gr_status == self::LP_STATUS_FAILED_NUM)
387  {
388  if(++$num_failed > $max_allowed_failed)
389  {
390  $status['failed'] = true;
391  $status['completed'] = false;
392  return $status;
393  }
394  }
395  if($gr_status == self::LP_STATUS_COMPLETED_NUM)
396  {
397  if(++$num_completed >= $required_completed)
398  {
399  return $status;
400  }
401  }
402  }
403  // Not completed since returned above
404  $status['completed'] = false;
405  return $status;
406  }
static _determineStatus($a_obj_id, $a_usr_id)
Determine status.
+ Here is the call 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

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

References ilObjectLP\getInstance(), and ilChangeEvent\hasAccessed().

296  {
297  global $ilObjDataCache;
298 
299  $status['completed'] = true;
300  $status['failed'] = false;
301  $status['in_progress'] = false;
302 
303  switch ($ilObjDataCache->lookupType($a_obj_id))
304  {
305  case "crs":
306  case "fold":
307  case "grp":
308  include_once "./Services/Tracking/classes/class.ilChangeEvent.php";
309  if (ilChangeEvent::hasAccessed($a_obj_id, $a_user_id))
310  {
311  $status['in_progress'] = true;
312  }
313 
314  include_once './Services/Object/classes/class.ilObjectLP.php';
315  $olp = ilObjectLP::getInstance($a_obj_id);
316  $collection = $olp->getCollectionInstance();
317  if($collection)
318  {
319  $grouped_items = $collection->getGroupedItemsForLPStatus();
320  }
321  if(!sizeof($grouped_items))
322  {
323  // #11513 - empty collections cannot be completed
324  $status['completed'] = false;
325  }
326  else
327  {
328  foreach($grouped_items as $grouping_id => $grouping)
329  {
330  $isGrouping = $grouping_id ? true : false;
331  $status = self::determineGroupingStatus($status,$grouping,$a_user_id,$isGrouping);
332  }
333  }
334 
335  if($status['completed'])
336  {
337  return self::LP_STATUS_COMPLETED_NUM;
338  }
339  if($status['failed'])
340  {
341  return self::LP_STATUS_FAILED_NUM;
342  }
343  if($status['in_progress'])
344  {
345  return self::LP_STATUS_IN_PROGRESS_NUM;
346  }
347  break;
348  }
349  return self::LP_STATUS_NOT_ATTEMPTED_NUM;
350  }
static hasAccessed($a_obj_id, $a_usr_id)
Has accessed.
static getInstance($a_obj_id)
+ 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 413 of file class.ilLPStatusCollection.php.

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

414  {
415  global $ilObjDataCache, $tree;
416 
417  switch($ilObjDataCache->lookupType($a_obj_id))
418  {
419  case 'crs':
420  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
421  $member_obj = ilCourseParticipants::_getInstanceByObjId($a_obj_id);
422  return $member_obj->getMembers();
423 
424  case 'grp':
425  include_once 'Modules/Group/classes/class.ilGroupParticipants.php';
426  $member_obj = ilGroupParticipants::_getInstanceByObjId($a_obj_id);
427  return $member_obj->getMembers();
428 
429  case 'fold':
430  $folder_ref_ids = ilObject::_getAllReferences($a_obj_id);
431  $folder_ref_id = current($folder_ref_ids);
432  if($crs_id = $tree->checkForParentType($folder_ref_id,'crs'))
433  {
434  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
436  return $member_obj->getMembers();
437  }
438  break;
439  }
440 
441  return array();
442  }
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
static _getAllReferences($a_id)
get all reference ids of object
static _lookupObjId($a_id)
static _getInstanceByObjId($a_obj_id)
Get singleton instance.
+ Here is the call graph for this function:

◆ ilLPStatusCollection()

ilLPStatusCollection::ilLPStatusCollection (   $a_obj_id)

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

References $ilDB.

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

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