ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilLPStatusExerciseReturned.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=0);
25 {
26  public static function _getNotAttempted(int $a_obj_id): array
27  {
28  $users = array();
29 
30  $members = self::getMembers($a_obj_id);
31  if ($members) {
32  $users = array_diff(
33  $members,
35  );
36  $users = array_diff(
37  $users,
39  );
40  $users = array_diff(
41  $users,
43  );
44  }
45  return $users;
46  }
47 
48  public static function _getInProgress(int $a_obj_id): array
49  {
50  $users = ilExerciseMembers::_getReturned($a_obj_id);
51  $all = ilChangeEvent::lookupUsersInProgress($a_obj_id);
52  $users = $users + $all;
53 
54  $users = array_diff(
55  $users,
57  );
58  $users = array_diff($users, ilLPStatusWrapper::_getFailed($a_obj_id));
59 
60  if ($users) {
61  // Exclude all non members
62  $users = array_intersect(self::getMembers($a_obj_id), $users);
63  }
64 
65  return $users;
66  }
67 
68  public static function _getCompleted(int $a_obj_id): array
69  {
70  return ilExerciseMembers::_getPassedUsers($a_obj_id);
71  }
72 
73  public static function _getFailed(int $a_obj_id): array
74  {
75  return ilExerciseMembers::_getFailedUsers($a_obj_id);
76  }
77 
81  public function determineStatus(
82  int $a_obj_id,
83  int $a_usr_id,
84  ?object $a_obj = null
85  ): int {
86  global $DIC;
87 
88  $ilObjDataCache = $DIC['ilObjDataCache'];
89 
90  $status = self::LP_STATUS_NOT_ATTEMPTED_NUM;
91  switch ($this->ilObjDataCache->lookupType($a_obj_id)) {
92  case 'exc':
93  if (ilChangeEvent::hasAccessed($a_obj_id, $a_usr_id) ||
94  ilExerciseMembers::_hasReturned($a_obj_id, $a_usr_id)) {
95  $status = self::LP_STATUS_IN_PROGRESS_NUM;
96  }
98  $a_obj_id,
99  $a_usr_id
100  );
101  if ($ex_stat == "passed") {
102  $status = self::LP_STATUS_COMPLETED_NUM;
103  }
104  if ($ex_stat == "failed") {
105  $status = self::LP_STATUS_FAILED_NUM;
106  }
107  break;
108  }
109  return $status;
110  }
111 
115  protected static function getMembers(int $a_obj_id)
116  {
117  return ilExerciseMembers::_getMembers($a_obj_id);
118  }
119 
123  public static function _lookupCompletedForObject(
124  int $a_obj_id,
125  ?array $a_user_ids = null
126  ): array {
127  if (!$a_user_ids) {
128  $a_user_ids = self::getMembers($a_obj_id);
129  if (!$a_user_ids) {
130  return array();
131  }
132  }
133  return self::_lookupStatusForObject(
134  $a_obj_id,
135  self::LP_STATUS_COMPLETED_NUM,
136  $a_user_ids
137  );
138  }
139 
143  public static function _lookupFailedForObject(
144  int $a_obj_id,
145  ?array $a_user_ids = null
146  ): array {
147  if (!$a_user_ids) {
148  $a_user_ids = self::getMembers($a_obj_id);
149  if (!$a_user_ids) {
150  return array();
151  }
152  }
153  return self::_lookupStatusForObject(
154  $a_obj_id,
155  self::LP_STATUS_FAILED_NUM,
156  $a_user_ids
157  );
158  }
159 
163  public static function _lookupInProgressForObject(
164  int $a_obj_id,
165  ?array $a_user_ids = null
166  ): array {
167  if (!$a_user_ids) {
168  $a_user_ids = self::getMembers($a_obj_id);
169  if (!$a_user_ids) {
170  return array();
171  }
172  }
173  return self::_lookupStatusForObject(
174  $a_obj_id,
175  self::LP_STATUS_IN_PROGRESS_NUM,
176  $a_user_ids
177  );
178  }
179 }
static _hasReturned(int $a_obj_id, int $a_user_id)
Has user returned anything in any assignment?
determineStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null)
Determine status.
static _lookupCompletedForObject(int $a_obj_id, ?array $a_user_ids=null)
Get completed users for object.
static _getCompleted(int $a_obj_id)
Static function to read the users who have the status &#39;completed&#39;.
static hasAccessed(int $a_obj_id, int $a_usr_id)
Has accessed.
static _getPassedUsers(int $a_obj_id)
Get all users that passed the exercise.
static _getInProgress(int $a_obj_id)
Static function to read users who have the status &#39;in_progress&#39;.
static getMembers(int $a_obj_id)
Get members for object.
static _getReturned(int $a_obj_id)
Get returned status for all members (if they have anything returned for any assignment) ...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static lookupUsersInProgress(int $a_obj_id)
static _lookupInProgressForObject(int $a_obj_id, ?array $a_user_ids=null)
Get in progress users for object.
static _getFailed(int $a_obj_id)
Static function to read the users who have the status &#39;completed&#39;.
static _getFailedUsers(int $a_obj_id)
Get all users that failed the exercise.
global $DIC
Definition: shib_login.php:22
static _lookupStatus(int $a_obj_id, int $a_user_id)
Lookup current status (notgraded|passed|failed)
ilObjectDataCache $ilObjDataCache
static _getMembers(int $a_obj_id)
static _lookupFailedForObject(int $a_obj_id, ?array $a_user_ids=null)
Get failed users for object.