ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
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 (int $a_obj_id)
 
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 10 of file class.ilLPStatusCollectionManual.php.

Member Function Documentation

◆ _getCompleted()

static ilLPStatusCollectionManual::_getCompleted ( int  $a_obj_id)
static

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

References ilLPStatusWrapper\_getStatusInfo().

28  : array
29  {
30  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
31 
32  $counter = 0;
33  $users = array();
34  foreach ($status_info['items'] as $item_id) {
35  $tmp_users = $status_info['completed'][$item_id];
36 
37  if (!$counter++) {
38  $users = $tmp_users;
39  } else {
40  $users = array_intersect($users, $tmp_users);
41  }
42  }
43  return array_unique($users);
44  }
static _getStatusInfo(int $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()

static ilLPStatusCollectionManual::_getInProgress ( int  $a_obj_id)
static

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

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

12  : array
13  {
14  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
15 
16  // find any completed item
17  $users = array();
18  if (isset($status_info['completed'])) {
19  foreach ($status_info['completed'] as $in_progress) {
20  $users = array_merge($users, $in_progress);
21  }
22  $users = array_unique($users);
23  }
24  // remove all users which have completed ALL items
25  return array_diff($users, ilLPStatusWrapper::_getCompleted($a_obj_id));
26  }
static _getCompleted(int $a_obj_id)
Static function to read the users who have the status 'completed'.
static _getStatusInfo(int $a_obj_id)
Reads informations about the object e.g test results, tlt, number of visits.
+ Here is the call graph for this function:

◆ _getObjectStatus()

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

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

References $DIC, $ilDB, $res, and ILIAS\Repository\int().

123  : array {
124  global $DIC;
125 
126  $ilDB = $DIC['ilDB'];
127 
128  $res = array();
129 
130  $sql = "SELECT subitem_id, completed, usr_id, last_change" .
131  " FROM ut_lp_coll_manual" .
132  " WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer");
133  if ($a_user_id) {
134  $sql .= " AND usr_id = " . $ilDB->quote($a_user_id, "integer");
135  }
136  $set = $ilDB->query($sql);
137  while ($row = $ilDB->fetchAssoc($set)) {
138  if (!$a_user_id) {
139  $res[(int) $row["subitem_id"]][(int) $row["usr_id"]] = (int) $row["completed"];
140  } else {
141  $res[(int) $row["subitem_id"]] = array((int) $row["completed"],
142  $row["last_change"]
143  );
144  }
145  }
146  return $res;
147  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

◆ _getStatusInfo()

static ilLPStatusCollectionManual::_getStatusInfo ( int  $a_obj_id)
static

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

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

46  : array
47  {
48  $status_info = array();
49 
50  $olp = ilObjectLP::getInstance($a_obj_id);
51  $collection = $olp->getCollectionInstance();
52  if ($collection) {
53  // @todo check if obj_id can be removed
54  $status_info["items"] = $collection->getItems($a_obj_id);
55 
56  foreach ($status_info["items"] as $item_id) {
57  $status_info["completed"][$item_id] = array();
58  }
59 
60  $ref_ids = ilObject::_getAllReferences($a_obj_id);
61  $ref_id = end($ref_ids);
62  $possible_items = $collection->getPossibleItems($ref_id);
63  $chapter_ids = array_intersect(
64  array_keys($possible_items),
65  $status_info["items"]
66  );
67 
68  // fix order (adapt from possible items)
69  $status_info["items"] = $chapter_ids;
70 
71  if ($chapter_ids) {
72  $status = self::_getObjectStatus($a_obj_id);
73 
74  foreach ($chapter_ids as $item_id) {
75  $status_info["item_titles"][$item_id] = $possible_items[$item_id]["title"];
76 
77  if (isset($status[$item_id])) {
78  foreach ($status[$item_id] as $user_id => $user_status) {
79  if ($user_status) {
80  $status_info["completed"][$item_id][] = $user_id;
81  }
82  }
83  }
84  }
85  }
86  }
87  return $status_info;
88  }
static _getAllReferences(int $id)
get all reference ids for object ID
$ref_id
Definition: ltiauth.php:67
static getInstance(int $obj_id)
+ 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 149 of file class.ilLPStatusCollectionManual.php.

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

153  : void {
154  global $DIC;
155 
156  $ilDB = $DIC['ilDB'];
157 
158  $now = time();
159 
160  if (!$a_completed) {
161  $a_completed = array();
162  }
163 
164  $olp = ilObjectLP::getInstance($a_obj_id);
165  $collection = $olp->getCollectionInstance();
166  if ($collection) {
167  $existing = self::_getObjectStatus($a_obj_id, $a_user_id);
168 
169  foreach ($collection->getItems() as $item_id) {
170  if (isset($existing[$item_id])) {
171  // value changed
172  if ((!$existing[$item_id][0] && in_array(
173  $item_id,
174  $a_completed
175  )) ||
176  ($existing[$item_id][0] && !in_array(
177  $item_id,
178  $a_completed
179  ))) {
180  $ilDB->manipulate(
181  "UPDATE ut_lp_coll_manual SET " .
182  " completed = " . $ilDB->quote(
183  in_array($item_id, $a_completed),
184  "integer"
185  ) .
186  " , last_change = " . $ilDB->quote(
187  $now,
188  "integer"
189  ) .
190  " WHERE obj_id = " . $ilDB->quote(
191  $a_obj_id,
192  "integer"
193  ) .
194  " AND usr_id = " . $ilDB->quote(
195  $a_user_id,
196  "integer"
197  ) .
198  " AND subitem_id = " . $ilDB->quote(
199  $item_id,
200  "integer"
201  )
202  );
203  }
204  } elseif (in_array($item_id, $a_completed)) {
205  $ilDB->manipulate(
206  "INSERT INTO ut_lp_coll_manual" .
207  "(obj_id,usr_id,subitem_id,completed,last_change)" .
208  " VALUES (" . $ilDB->quote($a_obj_id, "integer") .
209  " , " . $ilDB->quote($a_user_id, "integer") .
210  " , " . $ilDB->quote($item_id, "integer") .
211  " , " . $ilDB->quote(1, "integer") .
212  " , " . $ilDB->quote($now, "integer") . ")"
213  );
214  }
215  }
216  }
217 
218  ilLPStatusWrapper::_updateStatus($a_obj_id, $a_user_id);
219  }
global $DIC
Definition: feed.php:28
static getInstance(int $obj_id)
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
+ Here is the call graph for this function:

◆ determineStatus()

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

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

94  : int {
95  $info = self::_getStatusInfo($a_obj_id);
96 
97  if (isset($info["completed"])) {
98  $completed = true;
99  $in_progress = false;
100  foreach ($info["completed"] as $user_ids) {
101  // has completed at least 1 item
102  if (in_array($a_usr_id, $user_ids)) {
103  $in_progress = true;
104  } // must have completed all items to complete collection
105  else {
106  $completed = false;
107  }
108  }
109  if ($completed) {
110  return self::LP_STATUS_COMPLETED_NUM;
111  }
112  if ($in_progress) {
113  return self::LP_STATUS_IN_PROGRESS_NUM;
114  }
115  }
116 
117  return self::LP_STATUS_NOT_ATTEMPTED_NUM;
118  }

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