ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f87
ilLPStatusCollectionManual Class Reference
+ Inheritance diagram for ilLPStatusCollectionManual:
+ Collaboration diagram for ilLPStatusCollectionManual:

Public Member Functions

 _getInProgress ($a_obj_id)
 
 _getCompleted ($a_obj_id)
 
 _getStatusInfo ($a_obj_id)
 
 determineStatus ($a_obj_id, $a_user_id, $a_obj=null)
 
 _getObjectStatus ($a_obj_id, $a_user_id=null)
 
 _setObjectStatus ($a_obj_id, $a_user_id, array $a_completed=null)
 
- 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_no_raise=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...
 

Additional Inherited Members

- 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)
 
- 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)
 
- 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...
 

Detailed Description

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

Member Function Documentation

◆ _getCompleted()

ilLPStatusCollectionManual::_getCompleted (   $a_obj_id)

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

References ilLPStatusWrapper\_getStatusInfo().

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

◆ _getInProgress()

ilLPStatusCollectionManual::_getInProgress (   $a_obj_id)

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

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

18  {
19  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
20 
21  // find any completed item
22  $users = array();
23  if(is_array($status_info['completed']))
24  {
25  foreach($status_info['completed'] as $in_progress)
26  {
27  $users = array_merge($users,$in_progress);
28  }
29  $users = array_unique($users);
30  }
31 
32  // remove all users which have completed ALL items
33  $users = array_diff($users,ilLPStatusWrapper::_getCompleted($a_obj_id));
34 
35  return $users;
36  }
_getStatusInfo($a_obj_id)
Reads informations about the object e.g test results, tlt, number of visits.
_getCompleted($a_obj_id)
Static function to read the users who have the status 'completed'.
+ Here is the call graph for this function:

◆ _getObjectStatus()

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

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

References $ilDB, $res, and $row.

147  {
148  global $ilDB;
149 
150  $res = array();
151 
152  $sql = "SELECT subitem_id, completed, usr_id, last_change".
153  " FROM ut_lp_coll_manual".
154  " WHERE obj_id = ".$ilDB->quote($a_obj_id, "integer");
155  if($a_user_id)
156  {
157  $sql .= " AND usr_id = ".$ilDB->quote($a_user_id, "integer");
158  }
159  $set = $ilDB->query($sql);
160  while($row = $ilDB->fetchAssoc($set))
161  {
162  if(!$a_user_id)
163  {
164  $res[$row["subitem_id"]][$row["usr_id"]] = $row["completed"];
165  }
166  else
167  {
168  $res[$row["subitem_id"]] = array($row["completed"], $row["last_change"]);
169  }
170  }
171 
172  return $res;
173  }
global $ilDB

◆ _getStatusInfo()

ilLPStatusCollectionManual::_getStatusInfo (   $a_obj_id)

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

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

63  {
64  $status_info = array();
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  {
71  $status_info["items"] = $collection->getItems($a_obj_id);
72 
73  foreach($status_info["items"] as $item_id)
74  {
75  $status_info["completed"][$item_id] = array();
76  }
77 
78  $ref_ids = ilObject::_getAllReferences($a_obj_id);
79  $ref_id = end($ref_ids);
80  $possible_items = $collection->getPossibleItems($ref_id);
81  $chapter_ids = array_intersect(array_keys($possible_items),
82  $status_info["items"]);
83 
84  // fix order (adapt from possible items)
85  $status_info["items"] = $chapter_ids;
86 
87  if($chapter_ids)
88  {
89  $status = self::_getObjectStatus($a_obj_id);
90 
91  foreach($chapter_ids as $item_id)
92  {
93  $status_info["item_titles"][$item_id] = $possible_items[$item_id]["title"];
94 
95  if(isset($status[$item_id]))
96  {
97  foreach($status[$item_id] as $user_id => $user_status)
98  {
99  if($user_status)
100  {
101  $status_info["completed"][$item_id][] = $user_id;
102  }
103  }
104  }
105  }
106  }
107  }
108 
109  return $status_info;
110  }
static _getAllReferences($a_id)
get all reference ids of object
$ref_id
Definition: sahs_server.php:39
static getInstance($a_obj_id)
+ Here is the call graph for this function:

◆ _setObjectStatus()

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

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

References $ilDB, ilLPStatusWrapper\_updateStatus(), and ilObjectLP\getInstance().

176  {
177  global $ilDB;
178 
179  $now = time();
180 
181  if(!$a_completed)
182  {
183  $a_completed = array();
184  }
185 
186  include_once './Services/Object/classes/class.ilObjectLP.php';
187  $olp = ilObjectLP::getInstance($a_obj_id);
188  $collection = $olp->getCollectionInstance();
189  if($collection)
190  {
191  $existing = self::_getObjectStatus($a_obj_id, $a_user_id);
192 
193  foreach($collection->getItems() as $item_id)
194  {
195  if(isset($existing[$item_id]))
196  {
197  // value changed
198  if((!$existing[$item_id][0] && in_array($item_id, $a_completed)) ||
199  ($existing[$item_id][0] && !in_array($item_id, $a_completed)))
200  {
201  $ilDB->manipulate("UPDATE ut_lp_coll_manual SET ".
202  " completed = ".$ilDB->quote(in_array($item_id, $a_completed), "integer").
203  " , last_change = ".$ilDB->quote($now, "integer").
204  " WHERE obj_id = ".$ilDB->quote($a_obj_id, "integer").
205  " AND usr_id = ".$ilDB->quote($a_user_id, "integer").
206  " AND subitem_id = ".$ilDB->quote($item_id, "integer"));
207  }
208  }
209  else if(in_array($item_id, $a_completed))
210  {
211  $ilDB->manipulate("INSERT INTO ut_lp_coll_manual".
212  "(obj_id,usr_id,subitem_id,completed,last_change)".
213  " VALUES (".$ilDB->quote($a_obj_id, "integer").
214  " , ".$ilDB->quote($a_user_id, "integer").
215  " , ".$ilDB->quote($item_id, "integer").
216  " , ".$ilDB->quote(1, "integer").
217  " , ".$ilDB->quote($now, "integer").")");
218  }
219  }
220  }
221 
222  include_once "Services/Tracking/classes/class.ilLPStatusWrapper.php";
223  ilLPStatusWrapper::_updateStatus($a_obj_id, $a_user_id);
224  }
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_no_raise=false, $a_force_raise=false)
Update status.
global $ilDB
static getInstance($a_obj_id)
+ Here is the call graph for this function:

◆ determineStatus()

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

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

113  {
114  $info = self::_getStatusInfo($a_obj_id);
115 
116  if(is_array($info["completed"]))
117  {
118  $completed = true;
119  $in_progress = false;
120  foreach($info["completed"] as $user_ids)
121  {
122  // has completed at least 1 item
123  if(in_array($a_user_id, $user_ids))
124  {
125  $in_progress = true;
126  }
127  // must have completed all items to complete collection
128  else
129  {
130  $completed = false;
131  }
132  }
133  if($completed)
134  {
135  return self::LP_STATUS_COMPLETED_NUM;
136  }
137  if($in_progress)
138  {
139  return self::LP_STATUS_IN_PROGRESS_NUM;
140  }
141  }
142 
143  return self::LP_STATUS_NOT_ATTEMPTED_NUM;
144  }

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