ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $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=true)
 

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)

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

References $DIC, and $ilDB.

39  {
40  global $DIC;
41 
42  $ilDB = $DIC['ilDB'];
43 
44  parent::__construct($a_obj_id);
45  $this->db = $ilDB;
46  }
global $DIC
Definition: saml.php:7
global $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

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

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

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

◆ _getFailed()

static ilLPStatusCollection::_getFailed (   $a_obj_id)
static

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

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

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

◆ _getInProgress()

static ilLPStatusCollection::_getInProgress (   $a_obj_id)
static

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

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

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

◆ _getNotAttempted()

static ilLPStatusCollection::_getNotAttempted (   $a_obj_id)
static

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

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

49  {
50  $users = array();
51 
52  $members = self::getMembers($a_obj_id);
53  if ($members) {
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  }
static _getInProgress($a_obj_id)
Static function to read users who have the status 'in_progress'.
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'.
$users
Definition: authpage.php:44
+ Here is the call graph for this function:

◆ _getStatusInfo()

static ilLPStatusCollection::_getStatusInfo (   $a_obj_id)
static

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

References ilObjectLP\getInstance().

223  {
224  $status_info = array();
225 
226  include_once './Services/Object/classes/class.ilObjectLP.php';
227  $olp = ilObjectLP::getInstance($a_obj_id);
228  $collection = $olp->getCollectionInstance();
229  if ($collection) {
230  $status_info['collections'] = $collection->getItems();
231  $status_info['num_collections'] = count($status_info['collections']);
232  }
233 
234  return $status_info;
235  }
static getInstance($a_obj_id)
+ Here is the call graph for this function:

◆ _getTypicalLearningTime()

static ilLPStatusCollection::_getTypicalLearningTime (   $a_obj_id)
static

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

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

238  {
239  global $DIC;
240 
241  $ilObjDataCache = $DIC['ilObjDataCache'];
242 
243  if ($ilObjDataCache->lookupType($a_obj_id) == 'sahs') {
244  return parent::_getTypicalLearningTime($a_obj_id);
245  }
246 
247  $tlt = 0;
248  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
249  foreach ($status_info['collections'] as $item) {
250  $tlt += ilLPStatusWrapper::_getTypicalLearningTime($ilObjDataCache->lookupObjId($item));
251  }
252  return $tlt;
253  }
global $DIC
Definition: saml.php:7
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.
+ 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 412 of file class.ilLPStatusCollection.php.

413  {
414  if (!$a_user_ids) {
415  $a_user_ids = self::getMembers($a_obj_id);
416  if (!$a_user_ids) {
417  return array();
418  }
419  }
420  return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_COMPLETED_NUM, $a_user_ids);
421  }

◆ _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 430 of file class.ilLPStatusCollection.php.

431  {
432  if (!$a_user_ids) {
433  $a_user_ids = self::getMembers($a_obj_id);
434  if (!$a_user_ids) {
435  return array();
436  }
437  }
438  return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_FAILED_NUM, $a_user_ids);
439  }

◆ _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 448 of file class.ilLPStatusCollection.php.

449  {
450  if (!$a_user_ids) {
451  $a_user_ids = self::getMembers($a_obj_id);
452  if (!$a_user_ids) {
453  return array();
454  }
455  }
456  return self::_lookupStatusForObject($a_obj_id, self::LP_STATUS_IN_PROGRESS_NUM, $a_user_ids);
457  }

◆ 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 322 of file class.ilLPStatusCollection.php.

References $DIC, and ilLPStatusWrapper\_determineStatus().

323  {
324  global $DIC;
325 
326  $ilObjDataCache = $DIC['ilObjDataCache'];
327 
328  $items = $gr_info['items'];
329  if ($is_grouping) {
330  $max_allowed_failed = count($items) - $gr_info['num_obligatory'];
331  $required_completed = $gr_info['num_obligatory'];
332  } else {
333  $max_allowed_failed = 0;
334  $required_completed = count($items);
335  }
336 
337  // Required for grouping with a number of obligatory items
338  $num_failed = 0;
339  $num_completed = 0;
340 
341  foreach ($items as $item_id) {
342  $item_id = $ilObjDataCache->lookupObjId($item_id);
343  $gr_status = ilLPStatusWrapper::_determineStatus($item_id, $user_id);
344 
345  if ($gr_status == self::LP_STATUS_FAILED_NUM) {
346  if (++$num_failed > $max_allowed_failed) {
347  $status['failed'] = true;
348  $status['completed'] = false;
349  return $status;
350  }
351  }
352  if ($gr_status == self::LP_STATUS_COMPLETED_NUM) {
353  if (++$num_completed >= $required_completed) {
354  return $status;
355  }
356  }
357  }
358  // Not completed since returned above
359  $status['completed'] = false;
360  return $status;
361  }
global $DIC
Definition: saml.php:7
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 263 of file class.ilLPStatusCollection.php.

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

264  {
265  global $DIC;
266 
267  $ilObjDataCache = $DIC['ilObjDataCache'];
268 
269  $status['completed'] = true;
270  $status['failed'] = false;
271  $status['in_progress'] = false;
272 
273  switch ($ilObjDataCache->lookupType($a_obj_id)) {
274  case "crs":
275  case "fold":
276  case "grp":
277  case "lso":
278  include_once "./Services/Tracking/classes/class.ilChangeEvent.php";
279  if (ilChangeEvent::hasAccessed($a_obj_id, $a_user_id)) {
280  $status['in_progress'] = true;
281  }
282 
283  include_once './Services/Object/classes/class.ilObjectLP.php';
284  $olp = ilObjectLP::getInstance($a_obj_id);
285  $collection = $olp->getCollectionInstance();
286  if ($collection) {
287  $grouped_items = $collection->getGroupedItemsForLPStatus();
288  }
289  if (!sizeof($grouped_items)) {
290  // #11513 - empty collections cannot be completed
291  $status['completed'] = false;
292  } else {
293  foreach ($grouped_items as $grouping_id => $grouping) {
294  $isGrouping = $grouping_id ? true : false;
295  $status = self::determineGroupingStatus($status, $grouping, $a_user_id, $isGrouping);
296  }
297  }
298 
299  if ($status['completed']) {
300  return self::LP_STATUS_COMPLETED_NUM;
301  }
302  if ($status['failed']) {
303  return self::LP_STATUS_FAILED_NUM;
304  }
305  if ($status['in_progress']) {
306  return self::LP_STATUS_IN_PROGRESS_NUM;
307  }
308  break;
309  }
310  return self::LP_STATUS_NOT_ATTEMPTED_NUM;
311  }
static hasAccessed($a_obj_id, $a_usr_id)
Has accessed.
global $DIC
Definition: saml.php:7
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 368 of file class.ilLPStatusCollection.php.

References $DIC, $tree, ilObject\_getAllReferences(), ilLearningSequenceParticipants\_getInstanceByObjId(), ilGroupParticipants\_getInstanceByObjId(), ilCourseParticipants\_getInstanceByObjId(), and ilObject\_lookupObjId().

369  {
370  global $DIC;
371 
372  $ilObjDataCache = $DIC['ilObjDataCache'];
373  $tree = $DIC['tree'];
374 
375  switch ($ilObjDataCache->lookupType($a_obj_id)) {
376  case 'crs':
377  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
378  $member_obj = ilCourseParticipants::_getInstanceByObjId($a_obj_id);
379  return $member_obj->getMembers();
380 
381  case 'grp':
382  include_once 'Modules/Group/classes/class.ilGroupParticipants.php';
383  $member_obj = ilGroupParticipants::_getInstanceByObjId($a_obj_id);
384  return $member_obj->getMembers();
385 
386  case 'fold':
387  $folder_ref_ids = ilObject::_getAllReferences($a_obj_id);
388  $folder_ref_id = current($folder_ref_ids);
389  if ($crs_id = $tree->checkForParentType($folder_ref_id, 'crs')) {
390  include_once 'Modules/Course/classes/class.ilCourseParticipants.php';
392  return $member_obj->getMembers();
393  }
394  break;
395 
396  case 'lso':
398  return $member_obj->getMembers();
399  break;
400  }
401 
402  return array();
403  }
global $DIC
Definition: saml.php:7
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:

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