ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ilExerciseMembers Class Reference

Class ilExerciseMembers. 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

IndividualDeadlineManager $individual_deadlines
 
ilDBInterface $db
 
ilRecommendedContentManager $recommended_content_manager
 
ilObjExercise $exc
 

Detailed Description

Class ilExerciseMembers.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilExerciseMembers::__construct ( ilObjExercise  $a_exc)

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

38 {
39 global $DIC;
40
41 $this->db = $DIC->database();
42 $this->exc = $a_exc;
43 $this->obj_id = $a_exc->getId();
44 $this->ref_id = $a_exc->getRefId();
45 $this->read();
46 $this->recommended_content_manager = new ilRecommendedContentManager();
47 $this->individual_deadlines = $DIC->exercise()->internal()->domain()->individualDeadline();
48 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: shib_login.php:26

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 401 of file class.ilExerciseMembers.php.

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

References $DIC, $ilDB, 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 230 of file class.ilExerciseMembers.php.

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

References $DIC, $ilDB, 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 381 of file class.ilExerciseMembers.php.

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

References $DIC, $ilDB, 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 341 of file class.ilExerciseMembers.php.

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

References $DIC, $ilDB, 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 363 of file class.ilExerciseMembers.php.

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

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 262 of file class.ilExerciseMembers.php.

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

References $DIC, $ilDB, and $res.

Referenced by ilObjExerciseAccess\checkCondition(), ilLPStatusExerciseReturned\determineStatus(), ilObjExercise\exportGradesExcel(), ilExGradesTableGUI\fillRow(), and ILIAS\Exercise\Certificate\CertificateExerciseMembersHelper\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 313 of file class.ilExerciseMembers.php.

317 : void {
318 global $DIC;
319
320 $ilDB = $DIC->database();
321
322 $ilDB->manipulate(
323 "UPDATE exc_members SET " .
324 " returned = " . $ilDB->quote($a_status, "integer") .
325 " WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") .
326 " AND usr_id = " . $ilDB->quote($a_user_id, "integer")
327 );
328
329 ilLPStatusWrapper::_updateStatus($a_obj_id, $a_user_id);
330 }
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 286 of file class.ilExerciseMembers.php.

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

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 80 of file class.ilExerciseMembers.php.

80 : void
81 {
83
84 $ilDB->manipulate("DELETE FROM exc_members " .
85 "WHERE obj_id = " . $ilDB->quote($this->getObjId(), "integer") . " " .
86 "AND usr_id = " . $ilDB->quote($a_usr_id, "integer") . " ");
87
88 // @todo: some of this fields may not be needed anymore
89 $ilDB->manipulateF(
90 "INSERT INTO exc_members (obj_id, usr_id, status, sent, feedback) " .
91 " VALUES (%s,%s,%s,%s,%s)",
92 array("integer", "integer", "text", "integer", "integer"),
93 array($this->getObjId(), $a_usr_id, 'notgraded', 0, 0)
94 );
95
97
98 $this->read();
99
100 ilLPStatusWrapper::_updateStatus($this->getObjId(), $a_usr_id);
101 }
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 114 of file class.ilExerciseMembers.php.

114 : bool
115 {
116 $assigned = 0;
117 if (is_array($a_members)) {
118 foreach ($a_members as $member) {
119 if (!$this->isAssigned($member)) {
120 $this->assignMember($member);
121 } else {
122 ++$assigned;
123 }
124 }
125 }
126 if ($assigned == count($a_members)) {
127 return false;
128 } else {
129 return true;
130 }
131 }
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 137 of file class.ilExerciseMembers.php.

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

References $db, $ilDB, 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 219 of file class.ilExerciseMembers.php.

219 : void
220 {
222
223 $query = "DELETE FROM exc_members WHERE obj_id = " .
224 $ilDB->quote($this->getObjId(), "integer");
225 $ilDB->manipulate($query);
226
228 }
static _refreshStatus(int $a_obj_id, ?array $a_users=null)

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

+ Here is the call graph for this function:

◆ getMembers()

ilExerciseMembers::getMembers ( )

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

67 : array
68 {
69 return $this->members ?: array();
70 }

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

+ Here is the caller graph for this function:

◆ getObjId()

ilExerciseMembers::getObjId ( )

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

57 : int
58 {
59 return $this->obj_id;
60 }

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 51 of file class.ilExerciseMembers.php.

51 : int
52 {
53 return $this->ref_id;
54 }

References $ref_id.

Referenced by deassignMember().

+ Here is the caller graph for this function:

◆ ilClone()

ilExerciseMembers::ilClone ( int  $a_new_id)

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

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

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

+ Here is the call graph for this function:

◆ isAssigned()

ilExerciseMembers::isAssigned ( int  $a_id)

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

104 : bool
105 {
106 return in_array($a_id, $this->getMembers());
107 }

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 166 of file class.ilExerciseMembers.php.

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

References $db, $ilDB, $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 72 of file class.ilExerciseMembers.php.

72 : void
73 {
74 $this->members = $a_members;
75 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setObjId()

ilExerciseMembers::setObjId ( int  $a_obj_id)

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

62 : void
63 {
64 $this->obj_id = $a_obj_id;
65 }

Field Documentation

◆ $db

ilDBInterface ilExerciseMembers::$db
protected

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

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

◆ $exc

ilObjExercise ilExerciseMembers::$exc
protected

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

◆ $individual_deadlines

IndividualDeadlineManager ilExerciseMembers::$individual_deadlines
protected

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

◆ $members

array ilExerciseMembers::$members

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

◆ $obj_id

int ilExerciseMembers::$obj_id

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

Referenced by getObjId().

◆ $recommended_content_manager

ilRecommendedContentManager ilExerciseMembers::$recommended_content_manager
protected

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

◆ $ref_id

int ilExerciseMembers::$ref_id

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

Referenced by getRefId().

◆ $status

string ilExerciseMembers::$status

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


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