ILIAS  release_8 Revision v8.24
ilExerciseMembers Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilExerciseMembers:

Public Member Functions

 __construct (ilObjExercise $a_exc)
 
 getRefId ()
 
 getObjId ()
 
 setObjId (int $a_obj_id)
 
 getMembers ()
 
 setMembers (array $a_members)
 
 assignMember (int $a_usr_id)
 Assign a user to the exercise. More...
 
 isAssigned (int $a_id)
 
 assignMembers (array $a_members)
 Assign members to exercise. More...
 
 deassignMember (int $a_usr_id)
 Detaches a user from an exercise. More...
 
 read ()
 
 ilClone (int $a_new_id)
 
 delete ()
 

Static Public Member Functions

static _getMembers (int $a_obj_id)
 
static _lookupStatus (int $a_obj_id, int $a_user_id)
 Lookup current status (notgraded|passed|failed) More...
 
static _writeStatus (int $a_obj_id, int $a_user_id, string $a_status)
 Write user status This information is determined by the assignment status and saved redundantly in this table for performance reasons. More...
 
static _writeReturned (int $a_obj_id, int $a_user_id, int $a_status)
 Write returned status. More...
 
static _getReturned (int $a_obj_id)
 Get returned status for all members (if they have anything returned for any assignment) More...
 
static _hasReturned (int $a_obj_id, int $a_user_id)
 Has user returned anything in any assignment? More...
 
static _getPassedUsers (int $a_obj_id)
 Get all users that passed the exercise. More...
 
static _getFailedUsers (int $a_obj_id)
 Get all users that failed the exercise. More...
 

Data Fields

int $ref_id
 
int $obj_id
 
array $members
 
string $status
 

Protected Attributes

ilDBInterface $db
 
ilRecommendedContentManager $recommended_content_manager
 
ilObjExercise $exc
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilExerciseMembers

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Constructor & Destructor Documentation

◆ __construct()

ilExerciseMembers::__construct ( ilObjExercise  $a_exc)

Definition at line 34 of file class.ilExerciseMembers.php.

35 {
36 global $DIC;
37
38 $this->db = $DIC->database();
39 $this->exc = $a_exc;
40 $this->obj_id = $a_exc->getId();
41 $this->ref_id = $a_exc->getRefId();
42 $this->read();
43 $this->recommended_content_manager = new ilRecommendedContentManager();
44 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28

References $DIC, ilObject\getId(), ilObject\getRefId(), and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ _getFailedUsers()

static ilExerciseMembers::_getFailedUsers ( int  $a_obj_id)
static

Get all users that failed the exercise.

Definition at line 396 of file class.ilExerciseMembers.php.

396 : array
397 {
398 global $DIC;
399
400 $ilDB = $DIC->database();
401
402 $query = "SELECT DISTINCT(usr_id) FROM exc_members " .
403 "WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") . " " .
404 "AND status = " . $ilDB->quote("failed", "text");
405 $res = $ilDB->query($query);
406 $usr_ids = [];
407 while ($row = $ilDB->fetchObject($res)) {
408 $usr_ids[] = $row->usr_id;
409 }
410 return $usr_ids;
411 }
$res
Definition: ltiservices.php:69
$query

References $DIC, $ilDB, $query, and $res.

Referenced by ilLPStatusExerciseReturned\_getFailed().

+ Here is the caller graph for this function:

◆ _getMembers()

static ilExerciseMembers::_getMembers ( int  $a_obj_id)
static

Definition at line 225 of file class.ilExerciseMembers.php.

225 : array
226 {
227 global $DIC;
228
229 $ilDB = $DIC->database();
230
231 // #14963 - see ilExAssignment::getMemberListData()
232 $query = "SELECT DISTINCT(excm.usr_id) ud" .
233 " FROM exc_members excm" .
234 " JOIN object_data od ON (od.obj_id = excm.usr_id)" .
235 " WHERE excm.obj_id = " . $ilDB->quote($a_obj_id, "integer") .
236 " AND od.type = " . $ilDB->quote("usr", "text");
237
238 $res = $ilDB->query($query);
239 $usr_ids = [];
240 while ($row = $ilDB->fetchObject($res)) {
241 $usr_ids[] = $row->ud;
242 }
243
244 return $usr_ids;
245 }

References $DIC, $ilDB, $query, and $res.

Referenced by ilLPStatusExerciseReturned\getMembers(), and ilExPeerReview\validatePeerReviewGroups().

+ Here is the caller graph for this function:

◆ _getPassedUsers()

static ilExerciseMembers::_getPassedUsers ( int  $a_obj_id)
static

Get all users that passed the exercise.

Definition at line 376 of file class.ilExerciseMembers.php.

376 : array
377 {
378 global $DIC;
379
380 $ilDB = $DIC->database();
381
382 $query = "SELECT DISTINCT(usr_id) FROM exc_members " .
383 "WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") . " " .
384 "AND status = " . $ilDB->quote("passed", "text");
385 $res = $ilDB->query($query);
386 $usr_ids = [];
387 while ($row = $ilDB->fetchObject($res)) {
388 $usr_ids[] = $row->usr_id;
389 }
390 return $usr_ids;
391 }

References $DIC, $ilDB, $query, and $res.

Referenced by ilLPStatusExerciseReturned\_getCompleted().

+ Here is the caller graph for this function:

◆ _getReturned()

static ilExerciseMembers::_getReturned ( int  $a_obj_id)
static

Get returned status for all members (if they have anything returned for any assignment)

Definition at line 336 of file class.ilExerciseMembers.php.

336 : array
337 {
338 global $DIC;
339
340 $ilDB = $DIC->database();
341
342 $query = "SELECT DISTINCT(usr_id) as ud FROM exc_members " .
343 "WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") . " " .
344 "AND returned = 1";
345
346 $res = $ilDB->query($query);
347 $usr_ids = [];
348 while ($row = $ilDB->fetchObject($res)) {
349 $usr_ids[] = $row->ud;
350 }
351
352 return $usr_ids;
353 }

References $DIC, $ilDB, $query, and $res.

Referenced by ilLPStatusExerciseReturned\_getInProgress().

+ Here is the caller graph for this function:

◆ _hasReturned()

static ilExerciseMembers::_hasReturned ( int  $a_obj_id,
int  $a_user_id 
)
static

Has user returned anything in any assignment?

Definition at line 358 of file class.ilExerciseMembers.php.

358 : bool
359 {
360 global $DIC;
361
362 $ilDB = $DIC->database();
363
364 $set = $ilDB->query(
365 "SELECT DISTINCT(usr_id) FROM exc_members WHERE " .
366 " obj_id = " . $ilDB->quote($a_obj_id, "integer") . " AND " .
367 " returned = " . $ilDB->quote(1, "integer") . " AND " .
368 " usr_id = " . $ilDB->quote($a_user_id, "integer")
369 );
370 return (bool) $ilDB->fetchAssoc($set);
371 }

References $DIC, and $ilDB.

Referenced by ilLPStatusExerciseReturned\determineStatus().

+ Here is the caller graph for this function:

◆ _lookupStatus()

static ilExerciseMembers::_lookupStatus ( int  $a_obj_id,
int  $a_user_id 
)
static

Lookup current status (notgraded|passed|failed)

This information is determined by the assignment status and saved redundantly in this table for performance reasons.

Parameters
int$a_obj_idexercise id
int$a_user_idmember id
Returns
?string null if user is no member, or notgraded|passed|failed

Definition at line 257 of file class.ilExerciseMembers.php.

257 : ?string
258 {
259 global $DIC;
260
261 $ilDB = $DIC->database();
262
263 $query = "SELECT status FROM exc_members " .
264 "WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") .
265 " AND usr_id = " . $ilDB->quote($a_user_id, "integer");
266
267 $res = $ilDB->query($query);
268 if ($row = $ilDB->fetchAssoc($res)) {
269 return $row["status"];
270 }
271
272 return null;
273 }

References $DIC, $ilDB, $query, and $res.

Referenced by ilObjExerciseAccess\checkCondition(), ilLPStatusExerciseReturned\determineStatus(), ilObjExercise\exportGradesExcel(), ilExGradesTableGUI\fillRow(), and ilCertificateExerciseMembersHelper\lookUpStatus().

+ Here is the caller graph for this function:

◆ _writeReturned()

static ilExerciseMembers::_writeReturned ( int  $a_obj_id,
int  $a_user_id,
int  $a_status 
)
static

Write returned status.

The returned status is initially 0. If the first file is returned by a user for any assignment of the exercise, the returned status is set to 1 and it will stay that way, even if this file is deleted again. -> learning progress uses this to determine "in progress" status

Definition at line 308 of file class.ilExerciseMembers.php.

312 : void {
313 global $DIC;
314
315 $ilDB = $DIC->database();
316
317 $ilDB->manipulate(
318 "UPDATE exc_members SET " .
319 " returned = " . $ilDB->quote($a_status, "integer") .
320 " WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") .
321 " AND usr_id = " . $ilDB->quote($a_user_id, "integer")
322 );
323
324 ilLPStatusWrapper::_updateStatus($a_obj_id, $a_user_id);
325 }
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)

Referenced by ilObjExercise\processExerciseStatus().

+ Here is the caller graph for this function:

◆ _writeStatus()

static ilExerciseMembers::_writeStatus ( int  $a_obj_id,
int  $a_user_id,
string  $a_status 
)
static

Write user status This information is determined by the assignment status and saved redundantly in this table for performance reasons.

See ilObjExercise->updateUserStatus().

Definition at line 281 of file class.ilExerciseMembers.php.

285 : void {
286 global $DIC;
287
288 $ilDB = $DIC->database();
289
290 $ilDB->manipulate(
291 "UPDATE exc_members SET " .
292 " status = " . $ilDB->quote($a_status, "text") .
293 " WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") .
294 " AND usr_id = " . $ilDB->quote($a_user_id, "integer")
295 );
296
297 ilLPStatusWrapper::_updateStatus($a_obj_id, $a_user_id);
298 }

Referenced by ilObjExercise\updateUserStatus().

+ Here is the caller graph for this function:

◆ assignMember()

ilExerciseMembers::assignMember ( int  $a_usr_id)

Assign a user to the exercise.

Definition at line 76 of file class.ilExerciseMembers.php.

76 : void
77 {
79
80 $ilDB->manipulate("DELETE FROM exc_members " .
81 "WHERE obj_id = " . $ilDB->quote($this->getObjId(), "integer") . " " .
82 "AND usr_id = " . $ilDB->quote($a_usr_id, "integer") . " ");
83
84 // @todo: some of this fields may not be needed anymore
85 $ilDB->manipulateF(
86 "INSERT INTO exc_members (obj_id, usr_id, status, sent, feedback) " .
87 " VALUES (%s,%s,%s,%s,%s)",
88 array("integer", "integer", "text", "integer", "integer"),
89 array($this->getObjId(), $a_usr_id, 'notgraded', 0, 0)
90 );
91
93
94 $this->read();
95
96 ilLPStatusWrapper::_updateStatus($this->getObjId(), $a_usr_id);
97 }
static createNewUserRecords(int $a_user_id, int $a_exc_id)

References $db, $ilDB, ilLPStatusWrapper\_updateStatus(), ilExAssignment\createNewUserRecords(), getObjId(), and read().

Referenced by assignMembers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ assignMembers()

ilExerciseMembers::assignMembers ( array  $a_members)

Assign members to exercise.

Parameters
int[]$a_members
Returns
bool true, if all passed users could be assigned, false otherwise

Definition at line 110 of file class.ilExerciseMembers.php.

110 : bool
111 {
112 $assigned = 0;
113 if (is_array($a_members)) {
114 foreach ($a_members as $member) {
115 if (!$this->isAssigned($member)) {
116 $this->assignMember($member);
117 } else {
118 ++$assigned;
119 }
120 }
121 }
122 if ($assigned == count($a_members)) {
123 return false;
124 } else {
125 return true;
126 }
127 }
assignMember(int $a_usr_id)
Assign a user to the exercise.

References assignMember(), and isAssigned().

+ Here is the call graph for this function:

◆ deassignMember()

ilExerciseMembers::deassignMember ( int  $a_usr_id)

Detaches a user from an exercise.

Exceptions
ilExcUnknownAssignmentTypeException

Definition at line 133 of file class.ilExerciseMembers.php.

133 : void
134 {
136
137 $this->recommended_content_manager->removeObjectRecommendation($a_usr_id, $this->getRefId());
138
139 $query = "DELETE FROM exc_members " .
140 "WHERE obj_id = " . $ilDB->quote($this->getObjId(), "integer") . " " .
141 "AND usr_id = " . $ilDB->quote($a_usr_id, "integer") . " ";
142
143 $ilDB->manipulate($query);
144
145 $this->read();
146
147 ilLPStatusWrapper::_updateStatus($this->getObjId(), $a_usr_id);
148
149 // delete all delivered files of the member
150 ilExSubmission::deleteUser($this->exc->getId(), $a_usr_id);
151
152 // delete individual deadline/starting time entries
153 foreach (ilExAssignment::getInstancesByExercise($this->exc->getId()) as $ass) {
154 $idl = ilExcIndividualDeadline::getInstance($ass->getId(), $a_usr_id, false);
155 $idl->delete();
156 }
157
158 // @todo: delete all assignment associations (and their files)
159 }
static getInstancesByExercise(int $a_exc_id)
static deleteUser(int $a_exc_id, int $a_user_id)
Delete all delivered files of user.
static getInstance(int $a_ass_id, int $a_participant_id, bool $a_is_team=false)

References $db, $ilDB, $query, ilLPStatusWrapper\_updateStatus(), ilExSubmission\deleteUser(), ilExcIndividualDeadline\getInstance(), ilExAssignment\getInstancesByExercise(), getObjId(), getRefId(), and read().

+ Here is the call graph for this function:

◆ delete()

ilExerciseMembers::delete ( )

Definition at line 214 of file class.ilExerciseMembers.php.

214 : void
215 {
217
218 $query = "DELETE FROM exc_members WHERE obj_id = " .
219 $ilDB->quote($this->getObjId(), "integer");
220 $ilDB->manipulate($query);
221
223 }
static _refreshStatus(int $a_obj_id, ?array $a_users=null)

References $db, $ilDB, $query, ilLPStatusWrapper\_refreshStatus(), and getObjId().

+ Here is the call graph for this function:

◆ getMembers()

ilExerciseMembers::getMembers ( )

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

63 : array
64 {
65 return $this->members ?: array();
66 }

Referenced by ilExGradesTableGUI\__construct(), and isAssigned().

+ Here is the caller graph for this function:

◆ getObjId()

ilExerciseMembers::getObjId ( )

Definition at line 53 of file class.ilExerciseMembers.php.

53 : int
54 {
55 return $this->obj_id;
56 }

References $obj_id.

Referenced by assignMember(), deassignMember(), delete(), ilClone(), and read().

+ Here is the caller graph for this function:

◆ getRefId()

ilExerciseMembers::getRefId ( )

Definition at line 47 of file class.ilExerciseMembers.php.

47 : int
48 {
49 return $this->ref_id;
50 }

References $ref_id.

Referenced by deassignMember().

+ Here is the caller graph for this function:

◆ ilClone()

ilExerciseMembers::ilClone ( int  $a_new_id)

Definition at line 180 of file class.ilExerciseMembers.php.

180 : void
181 {
183
184 $data = array();
185
186 $query = "SELECT * FROM exc_members " .
187 "WHERE obj_id = " . $ilDB->quote($this->getObjId(), "integer");
188
189 $res = $ilDB->query($query);
190 while ($row = $ilDB->fetchObject($res)) {
191 $data[] = array("usr_id" => $row->usr_id,
192 "notice" => $row->notice,
193 "returned" => $row->returned,
194 "status" => $row->status,
195 "sent" => $row->sent,
196 "feedback" => $row->feedback
197 );
198 }
199 foreach ($data as $row) {
200 $ilDB->manipulateF(
201 "INSERT INTO exc_members " .
202 " (obj_id, usr_id, notice, returned, status, feedback, sent) VALUES " .
203 " (%s,%s,%s,%s,%s,%s,%s)",
204 array("integer", "integer", "text", "integer", "text", "integer", "integer"),
205 array($a_new_id, $row["usr_id"], $row["notice"], (int) $row["returned"],
206 $row["status"], (int) $row["feedback"], (int) $row["sent"])
207 );
208
209 ilLPStatusWrapper::_updateStatus($a_new_id, $row["usr_id"]);
210 }
211 }

References $data, $db, $ilDB, $query, $res, ilLPStatusWrapper\_updateStatus(), and getObjId().

+ Here is the call graph for this function:

◆ isAssigned()

ilExerciseMembers::isAssigned ( int  $a_id)

Definition at line 100 of file class.ilExerciseMembers.php.

100 : bool
101 {
102 return in_array($a_id, $this->getMembers());
103 }

References getMembers().

Referenced by assignMembers().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilExerciseMembers::read ( )

Definition at line 161 of file class.ilExerciseMembers.php.

161 : void
162 {
164
165 $tmp_arr_members = array();
166
167 $query = "SELECT * FROM exc_members " .
168 "WHERE obj_id = " . $ilDB->quote($this->getObjId(), "integer");
169
170 $res = $ilDB->query($query);
171 while ($row = $ilDB->fetchObject($res)) {
172 if (ilObject::_lookupType($row->usr_id) == "usr") {
173 $tmp_arr_members[] = $row->usr_id;
174 }
175 }
176 $this->setMembers($tmp_arr_members);
177 }
setMembers(array $a_members)
static _lookupType(int $id, bool $reference=false)

References $db, $ilDB, $query, $res, ilObject\_lookupType(), getObjId(), and setMembers().

Referenced by __construct(), assignMember(), and deassignMember().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMembers()

ilExerciseMembers::setMembers ( array  $a_members)

Definition at line 68 of file class.ilExerciseMembers.php.

68 : void
69 {
70 $this->members = $a_members;
71 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setObjId()

ilExerciseMembers::setObjId ( int  $a_obj_id)

Definition at line 58 of file class.ilExerciseMembers.php.

58 : void
59 {
60 $this->obj_id = $a_obj_id;
61 }

Field Documentation

◆ $db

ilDBInterface ilExerciseMembers::$db
protected

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

Referenced by assignMember(), deassignMember(), delete(), ilClone(), and read().

◆ $exc

ilObjExercise ilExerciseMembers::$exc
protected

Definition at line 32 of file class.ilExerciseMembers.php.

◆ $members

array ilExerciseMembers::$members

Definition at line 29 of file class.ilExerciseMembers.php.

◆ $obj_id

int ilExerciseMembers::$obj_id

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

Referenced by getObjId().

◆ $recommended_content_manager

ilRecommendedContentManager ilExerciseMembers::$recommended_content_manager
protected

Definition at line 31 of file class.ilExerciseMembers.php.

◆ $ref_id

int ilExerciseMembers::$ref_id

Definition at line 27 of file class.ilExerciseMembers.php.

Referenced by getRefId().

◆ $status

string ilExerciseMembers::$status

Definition at line 30 of file class.ilExerciseMembers.php.


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