ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilLPStatusCollectionMobs Class Reference
+ Inheritance diagram for ilLPStatusCollectionMobs:
+ Collaboration diagram for ilLPStatusCollectionMobs:

Public Member Functions

 determineStatus (int $a_obj_id, int $a_usr_id, ?object $a_obj=null)
 
 determinePercentage (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 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 (string $type, int $obj_id, int $sub_id=0)
 
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)
 

Static Protected Member Functions

static getCollectionItems ( $a_obj_id, $a_include_titles=false)
 
- 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...
 

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
 
- Protected Attributes inherited from ilLPStatus
int $obj_id
 
ilDBInterface $db
 
ilObjectDataCache $ilObjDataCache
 

Detailed Description

Definition at line 24 of file class.ilLPStatusCollectionMobs.php.

Member Function Documentation

◆ _getCompleted()

static ilLPStatusCollectionMobs::_getCompleted ( int  $a_obj_id)
static

Definition at line 37 of file class.ilLPStatusCollectionMobs.php.

References ilLPStatusWrapper\_getStatusInfo().

37  : array
38  {
39  $users = array();
40 
41  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
42  if (isset($status_info["user_status"]["completed"])) {
43  $users = $status_info["user_status"]["completed"];
44  }
45 
46  return $users;
47  }
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 ilLPStatusCollectionMobs::_getInProgress ( int  $a_obj_id)
static

Definition at line 26 of file class.ilLPStatusCollectionMobs.php.

References ilLPStatusWrapper\_getStatusInfo().

26  : array
27  {
28  $users = array();
29 
30  $status_info = ilLPStatusWrapper::_getStatusInfo($a_obj_id);
31  if (isset($status_info["user_status"]["in_progress"])) {
32  $users = $status_info["user_status"]["in_progress"];
33  }
34  return $users;
35  }
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:

◆ _getStatusInfo()

static ilLPStatusCollectionMobs::_getStatusInfo ( int  $a_obj_id)
static

Definition at line 49 of file class.ilLPStatusCollectionMobs.php.

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

49  : array
50  {
51  global $DIC;
52 
53  $ilDB = $DIC['ilDB'];
54 
55  $res = array();
56 
57  $coll_items = self::getCollectionItems($a_obj_id, true);
58 
59  $res["items"] = array_keys($coll_items);
60  if (sizeof($res["items"])) {
61  // titles
62  foreach ($coll_items as $mob_id => $item) {
63  $res["item_titles"][$mob_id] = $item["title"];
64  }
65 
66  // status per item
67  foreach ($res["items"] as $mob_id) {
68  $res["completed"][$mob_id] = array();
69  $res["in_progress"][$mob_id] = array();
70  }
71 
72  $set = $ilDB->query(
73  "SELECT obj_id, usr_id FROM read_event" .
74  " WHERE " . $ilDB->in("obj_id", $res["items"], "", "integer")
75  );
76  while ($row = $ilDB->fetchAssoc($set)) {
77  $res["completed"][(int) $row["obj_id"]][] = (int) $row["usr_id"];
78  }
79 
80  // status per user
81  $tmp = array();
82  foreach ($res["items"] as $mob_id) {
83  foreach ($res["completed"][$mob_id] as $user_id) {
84  $tmp[$user_id][] = (int) $mob_id;
85  }
86  }
87  foreach ($tmp as $user_id => $completed_items) {
88  if (sizeof($completed_items) == sizeof($res["items"])) {
89  $res["user_status"]["completed"][] = (int) $user_id;
90  } else {
91  $res["user_status"]["in_progress"][] = (int) $user_id;
92  }
93  }
94  }
95 
96  $users = ilChangeEvent::lookupUsersInProgress($a_obj_id);
97  foreach ($users as $user_id) {
98  if ((!isset($res["user_status"]["in_progress"]) || !in_array(
99  $user_id,
100  $res["user_status"]["in_progress"]
101  )) &&
102  (!isset($res["user_status"]["completed"]) || !in_array(
103  $user_id,
104  $res["user_status"]["completed"]
105  ))) {
106  $res["user_status"]["in_progress"][] = (int) $user_id;
107  }
108  }
109 
110  return $res;
111  }
$res
Definition: ltiservices.php:66
static lookupUsersInProgress(int $a_obj_id)
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

◆ determinePercentage()

ilLPStatusCollectionMobs::determinePercentage ( int  $a_obj_id,
int  $a_usr_id,
?object  $a_obj = null 
)

Definition at line 178 of file class.ilLPStatusCollectionMobs.php.

References ILIAS\Repository\int().

182  : int {
183  $per = 0;
184 
185  // an empty collection is always not attempted
186  $items = self::getCollectionItems($a_obj_id);
187  if (count($items) > 0) {
188  // process mob status for user
189 
190  $found = array();
191  $set = $this->db->query(
192  "SELECT obj_id FROM read_event" .
193  " WHERE usr_id = " . $this->db->quote($a_usr_id, "integer") .
194  " AND " . $this->db->in("obj_id", $items, false, "integer")
195  );
196  while ($row = $this->db->fetchAssoc($set)) {
197  $found[] = (int) $row["obj_id"];
198  }
199 
200  if (count($found) > 0 && count($items) > 0) {
201  $per = (int) round(100 / count($items) * count($found));
202  }
203  }
204 
205  return $per;
206  }
+ Here is the call graph for this function:

◆ determineStatus()

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

Definition at line 141 of file class.ilLPStatusCollectionMobs.php.

References ilChangeEvent\hasAccessed(), and ILIAS\Repository\int().

145  : int {
146  $status = self::LP_STATUS_NOT_ATTEMPTED_NUM;
147  if (ilChangeEvent::hasAccessed($a_obj_id, $a_usr_id)) {
148  $status = self::LP_STATUS_IN_PROGRESS_NUM;
149  }
150 
151  // an empty collection is always not attempted
152  $items = self::getCollectionItems($a_obj_id);
153  if (count($items) > 0) {
154  // process mob status for user
155 
156  $found = array();
157 
158  $set = $this->db->query(
159  "SELECT obj_id FROM read_event" .
160  " WHERE usr_id = " . $this->db->quote($a_usr_id, "integer") .
161  " AND " . $this->db->in("obj_id", $items, false, "integer")
162  );
163  while ($row = $this->db->fetchAssoc($set)) {
164  $found[] = (int) $row["obj_id"];
165  }
166 
167  if (count($found) > 0) {
168  $status = self::LP_STATUS_IN_PROGRESS_NUM;
169 
170  if (count($found) == count($items)) {
171  $status = self::LP_STATUS_COMPLETED_NUM;
172  }
173  }
174  }
175  return $status;
176  }
static hasAccessed(int $a_obj_id, int $a_usr_id)
Has accessed.
+ Here is the call graph for this function:

◆ getCollectionItems()

static ilLPStatusCollectionMobs::getCollectionItems (   $a_obj_id,
  $a_include_titles = false 
)
staticprotected

Definition at line 113 of file class.ilLPStatusCollectionMobs.php.

References $res, $valid, and ilObjectLP\getInstance().

116  {
117  $res = array();
118 
119  $olp = ilObjectLP::getInstance($a_obj_id);
120  $collection = $olp->getCollectionInstance();
121  if ($collection) {
122  $possible = $collection->getPossibleItems();
123 
124  // there could be invalid items in the selection
125  $valid = array_intersect(
126  $collection->getItems(),
127  array_keys($possible)
128  );
129 
130  if ($a_include_titles) {
131  foreach ($valid as $item_id) {
132  $res[$item_id] = $possible[$item_id];
133  }
134  } else {
135  $res = $valid;
136  }
137  }
138  return $res;
139  }
$res
Definition: ltiservices.php:66
$valid
static getInstance(int $obj_id)
+ Here is the call graph for this function:

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