ILIAS  trunk Revision v12.0_alpha-1221-g4e438232683
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

ILIAS Exercise InternalDomainService $domain
 
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 38 of file class.ilExerciseMembers.php.

39 {
40 global $DIC;
41
42 $this->db = $DIC->database();
43 $this->exc = $a_exc;
44 $this->obj_id = $a_exc->getId();
45 $this->ref_id = $a_exc->getRefId();
46 $this->read();
47 $this->recommended_content_manager = new ilRecommendedContentManager();
48 $this->individual_deadlines = $DIC->exercise()->internal()->domain()->individualDeadline();
49 $this->domain = $DIC->exercise()->internal()->domain();
50 }
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 407 of file class.ilExerciseMembers.php.

407 : array
408 {
409 global $DIC;
410
411 $ilDB = $DIC->database();
412
413 $query = "SELECT DISTINCT(usr_id) FROM exc_members " .
414 "WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") . " " .
415 "AND status = " . $ilDB->quote("failed", "text");
416 $res = $ilDB->query($query);
417 $usr_ids = [];
418 while ($row = $ilDB->fetchObject($res)) {
419 $usr_ids[] = $row->usr_id;
420 }
421 return $usr_ids;
422 }
$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 236 of file class.ilExerciseMembers.php.

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

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

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

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

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

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

369 : bool
370 {
371 global $DIC;
372
373 $ilDB = $DIC->database();
374
375 $set = $ilDB->query(
376 "SELECT DISTINCT(usr_id) FROM exc_members WHERE " .
377 " obj_id = " . $ilDB->quote($a_obj_id, "integer") . " AND " .
378 " returned = " . $ilDB->quote(1, "integer") . " AND " .
379 " usr_id = " . $ilDB->quote($a_user_id, "integer")
380 );
381 return (bool) $ilDB->fetchAssoc($set);
382 }

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

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

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

323 : void {
324 global $DIC;
325
326 $ilDB = $DIC->database();
327
328 $ilDB->manipulate(
329 "UPDATE exc_members SET " .
330 " returned = " . $ilDB->quote($a_status, "integer") .
331 " WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") .
332 " AND usr_id = " . $ilDB->quote($a_user_id, "integer")
333 );
334
335 ilLPStatusWrapper::_updateStatus($a_obj_id, $a_user_id);
336 }
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 292 of file class.ilExerciseMembers.php.

296 : void {
297 global $DIC;
298
299 $ilDB = $DIC->database();
300
301 $ilDB->manipulate(
302 "UPDATE exc_members SET " .
303 " status = " . $ilDB->quote($a_status, "text") .
304 " WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") .
305 " AND usr_id = " . $ilDB->quote($a_user_id, "integer")
306 );
307
308 ilLPStatusWrapper::_updateStatus($a_obj_id, $a_user_id);
309 }

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

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

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

139 : void
140 {
142
143 $this->recommended_content_manager->removeObjectRecommendation($a_usr_id, $this->getRefId());
144 $this->individual_deadlines->deleteAllOfUserInExercise($this->getObjId(), $a_usr_id, false);
145
146 $query = "DELETE FROM exc_members " .
147 "WHERE obj_id = " . $ilDB->quote($this->getObjId(), "integer") . " " .
148 "AND usr_id = " . $ilDB->quote($a_usr_id, "integer") . " ";
149
150 $ilDB->manipulate($query);
151
152 $this->read();
153
154 ilLPStatusWrapper::_updateStatus($this->getObjId(), $a_usr_id);
155
156 // delete all delivered files of the member
157 ilExSubmission::deleteUser($this->exc->getId(), $a_usr_id);
158
159 // delete individual deadline/starting time entries
160 foreach (ilExAssignment::getInstancesByExercise($this->exc->getId()) as $ass) {
161 $idl = ilExcIndividualDeadline::getInstance($ass->getId(), $a_usr_id, false);
162 $idl->delete();
163 }
164
165 // delete random assignments
166 $random = $this->domain->assignment()->randomAssignments($this->exc);
167 $random->deleteAssignmentsOfUser($a_usr_id);
168
169 // @todo: delete all assignment associations (and their files)
170 }
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 225 of file class.ilExerciseMembers.php.

225 : void
226 {
228
229 $query = "DELETE FROM exc_members WHERE obj_id = " .
230 $ilDB->quote($this->getObjId(), "integer");
231 $ilDB->manipulate($query);
232
234 }
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 69 of file class.ilExerciseMembers.php.

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

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

+ Here is the caller graph for this function:

◆ getObjId()

ilExerciseMembers::getObjId ( )

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

59 : int
60 {
61 return $this->obj_id;
62 }

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

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

References $ref_id.

Referenced by deassignMember().

+ Here is the caller graph for this function:

◆ ilClone()

ilExerciseMembers::ilClone ( int  $a_new_id)

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

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

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

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

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

172 : void
173 {
175
176 $tmp_arr_members = array();
177
178 $query = "SELECT * FROM exc_members " .
179 "WHERE obj_id = " . $ilDB->quote($this->getObjId(), "integer");
180
181 $res = $ilDB->query($query);
182 while ($row = $ilDB->fetchObject($res)) {
183 if (ilObject::_lookupType($row->usr_id) == "usr") {
184 $tmp_arr_members[] = $row->usr_id;
185 }
186 }
187 $this->setMembers($tmp_arr_members);
188 }
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 74 of file class.ilExerciseMembers.php.

74 : void
75 {
76 $this->members = $a_members;
77 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setObjId()

ilExerciseMembers::setObjId ( int  $a_obj_id)

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

64 : void
65 {
66 $this->obj_id = $a_obj_id;
67 }

Field Documentation

◆ $db

ilDBInterface ilExerciseMembers::$db
protected

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

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

◆ $domain

ILIAS Exercise InternalDomainService ilExerciseMembers::$domain
protected

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

◆ $exc

ilObjExercise ilExerciseMembers::$exc
protected

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

◆ $individual_deadlines

IndividualDeadlineManager ilExerciseMembers::$individual_deadlines
protected

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

◆ $members

array ilExerciseMembers::$members

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

◆ $obj_id

int ilExerciseMembers::$obj_id

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

Referenced by getObjId().

◆ $recommended_content_manager

ilRecommendedContentManager ilExerciseMembers::$recommended_content_manager
protected

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

◆ $ref_id

int ilExerciseMembers::$ref_id

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

Referenced by getRefId().

◆ $status

string ilExerciseMembers::$status

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


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