ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
ilExerciseMembers Class Reference

Class ilExerciseMembers. More...

+ Collaboration diagram for ilExerciseMembers:

Public Member Functions

 __construct ($a_exc)
 
 getRefId ()
 Get exercise ref id. More...
 
 getObjId ()
 Get exercise id. More...
 
 setObjId ($a_obj_id)
 Set exercise id. More...
 
 getMembers ()
 Get members array. More...
 
 setMembers ($a_members)
 Set members array. More...
 
 assignMember ($a_usr_id)
 Assign a user to the exercise. More...
 
 isAssigned ($a_id)
 Is user assigned to exercise? More...
 
 assignMembers ($a_members)
 Assign members to exercise. More...
 
 deassignMember ($a_usr_id)
 Detaches a user from an exercise. More...
 
 deassignMembers ($a_members)
 Deassign members. More...
 
 read ()
 Read all members. More...
 
 ilClone ($a_new_id)
 
 delete ()
 

Static Public Member Functions

static _getMembers ($a_obj_id)
 
static _lookupStatus ($a_obj_id, $a_user_id)
 Lookup current status (notgraded|passed|failed) More...
 
static _writeStatus ($a_obj_id, $a_user_id, $a_status)
 Write user status. More...
 
static _writeReturned ($a_obj_id, $a_user_id, $a_status)
 Write returned status. More...
 
static _getReturned ($a_obj_id)
 Get returned status for all members (if they have anything returned for any assignment) More...
 
static _hasReturned ($a_obj_id, $a_user_id)
 Has user returned anything in any assignment? More...
 
static _getPassedUsers ($a_obj_id)
 Get all users that passed the exercise. More...
 
static _getFailedUsers ($a_obj_id)
 Get all users that failed the exercise. More...
 

Data Fields

 $ref_id
 
 $obj_id
 
 $members
 
 $status
 

Protected Attributes

 $db
 
 $recommended_content_manager
 

Detailed Description

Class ilExerciseMembers.

Author
Stefan Meyer meyer.nosp@m.@lei.nosp@m.fos.c.nosp@m.om

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

Constructor & Destructor Documentation

◆ __construct()

ilExerciseMembers::__construct (   $a_exc)

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

33 {
34 global $DIC;
35
36 $this->db = $DIC->database();
37 $this->exc = $a_exc;
38 $this->obj_id = $a_exc->getId();
39 $this->ref_id = $a_exc->getRefId();
40 $this->read();
41
42 $this->recommended_content_manager = new ilRecommendedContentManager();
43 }
Recommended content manager (business logic)
$DIC
Definition: xapitoken.php:46

References $DIC, and read().

+ Here is the call graph for this function:

Member Function Documentation

◆ _getFailedUsers()

static ilExerciseMembers::_getFailedUsers (   $a_obj_id)
static

Get all users that failed the exercise.

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

443 {
444 global $DIC;
445
446 $ilDB = $DIC->database();
447
448 $query = "SELECT DISTINCT(usr_id) FROM exc_members " .
449 "WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") . " " .
450 "AND status = " . $ilDB->quote("failed", "text");
451 $res = $ilDB->query($query);
452 while ($row = $ilDB->fetchObject($res)) {
453 $usr_ids[] = $row->usr_id;
454 }
455 return $usr_ids ? $usr_ids : array();
456 }
$query
foreach($_POST as $key=> $value) $res
global $ilDB

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

Referenced by ilLPStatusExerciseReturned\_getFailed().

+ Here is the caller graph for this function:

◆ _getMembers()

static ilExerciseMembers::_getMembers (   $a_obj_id)
static

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

265 {
266 global $DIC;
267
268 $ilDB = $DIC->database();
269
270 // #14963 - see ilExAssignment::getMemberListData()
271 $query = "SELECT DISTINCT(excm.usr_id) ud" .
272 " FROM exc_members excm" .
273 " JOIN object_data od ON (od.obj_id = excm.usr_id)" .
274 " WHERE excm.obj_id = " . $ilDB->quote($a_obj_id, "integer") .
275 " AND od.type = " . $ilDB->quote("usr", "text");
276
277 $res = $ilDB->query($query);
278 while ($row = $ilDB->fetchObject($res)) {
279 $usr_ids[] = $row->ud;
280 }
281
282 return $usr_ids ? $usr_ids : array();
283 }

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

Referenced by ilLPStatusExerciseReturned\getMembers(), ilExerciseXMLWriter\handleAssignmentMembers(), ilExAssignment\sendFeedbackNotifications(), and ilExPeerReview\validatePeerReviewGroups().

+ Here is the caller graph for this function:

◆ _getPassedUsers()

static ilExerciseMembers::_getPassedUsers (   $a_obj_id)
static

Get all users that passed the exercise.

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

424 {
425 global $DIC;
426
427 $ilDB = $DIC->database();
428
429 $query = "SELECT DISTINCT(usr_id) FROM exc_members " .
430 "WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") . " " .
431 "AND status = " . $ilDB->quote("passed", "text");
432 $res = $ilDB->query($query);
433 while ($row = $ilDB->fetchObject($res)) {
434 $usr_ids[] = $row->usr_id;
435 }
436 return $usr_ids ? $usr_ids : array();
437 }

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

Referenced by ilLPStatusExerciseReturned\_getCompleted().

+ Here is the caller graph for this function:

◆ _getReturned()

static ilExerciseMembers::_getReturned (   $a_obj_id)
static

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

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

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

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

Referenced by ilLPStatusExerciseReturned\_getInProgress().

+ Here is the caller graph for this function:

◆ _hasReturned()

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

Has user returned anything in any assignment?

Parameters
integerobject id
integeruser id
Returns
boolean true/false

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

403 {
404 global $DIC;
405
406 $ilDB = $DIC->database();
407
408 $set = $ilDB->query(
409 "SELECT DISTINCT(usr_id) FROM exc_members WHERE " .
410 " obj_id = " . $ilDB->quote($a_obj_id, "integer") . " AND " .
411 " returned = " . $ilDB->quote(1, "integer") . " AND " .
412 " usr_id = " . $ilDB->quote($a_user_id, "integer")
413 );
414 if ($rec = $ilDB->fetchAssoc($set)) {
415 return true;
416 }
417 return false;
418 }

References $DIC, and $ilDB.

Referenced by ilLPStatusExerciseReturned\determineStatus().

+ Here is the caller graph for this function:

◆ _lookupStatus()

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

Lookup current status (notgraded|passed|failed)

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

Parameters
int$a_obj_idexercise id
int$a_user_idmember id
Returns
mixed false (if user is no member) or notgraded|passed|failed

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

296 {
297 global $DIC;
298
299 $ilDB = $DIC->database();
300
301 $query = "SELECT status FROM exc_members " .
302 "WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") .
303 " AND usr_id = " . $ilDB->quote($a_user_id, "integer");
304
305 $res = $ilDB->query($query);
306 if ($row = $ilDB->fetchAssoc($res)) {
307 return $row["status"];
308 }
309
310 return false;
311 }

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 (   $a_obj_id,
  $a_user_id,
  $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

Parameters
intexercise id
intuser id
textstatus

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

353 {
354 global $DIC;
355
356 $ilDB = $DIC->database();
357
358 $ilDB->manipulate(
359 "UPDATE exc_members SET " .
360 " returned = " . $ilDB->quote($a_status, "integer") .
361 " WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") .
362 " AND usr_id = " . $ilDB->quote($a_user_id, "integer")
363 );
364
365 ilLPStatusWrapper::_updateStatus($a_obj_id, $a_user_id);
366 }
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.

References $DIC, $ilDB, and ilLPStatusWrapper\_updateStatus().

Referenced by ilObjExercise\processExerciseStatus().

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

◆ _writeStatus()

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

Write user status.

This information is determined by the assignment status and saved redundtantly in this table for performance reasons. See ilObjExercise->updateUserStatus().

Parameters
intexercise id
intuser id
textstatus

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

325 {
326 global $DIC;
327
328 $ilDB = $DIC->database();
329
330 $ilDB->manipulate(
331 "UPDATE exc_members SET " .
332 " status = " . $ilDB->quote($a_status, "text") .
333 " WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") .
334 " AND usr_id = " . $ilDB->quote($a_user_id, "integer")
335 );
336
337 ilLPStatusWrapper::_updateStatus($a_obj_id, $a_user_id);
338 }

References $DIC, $ilDB, and ilLPStatusWrapper\_updateStatus().

Referenced by ilObjExercise\updateUserStatus().

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

◆ assignMember()

ilExerciseMembers::assignMember (   $a_usr_id)

Assign a user to the exercise.

Parameters
int$a_usr_iduser id

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

91 {
93
94 /*if($this->exc->hasAddToDesktop())
95 {
96 }*/
97
98 $ilDB->manipulate("DELETE FROM exc_members " .
99 "WHERE obj_id = " . $ilDB->quote($this->getObjId(), "integer") . " " .
100 "AND usr_id = " . $ilDB->quote($a_usr_id, "integer") . " ");
101
102 // @todo: some of this fields may not be needed anymore
103 $ilDB->manipulateF(
104 "INSERT INTO exc_members (obj_id, usr_id, status, sent, feedback) " .
105 " VALUES (%s,%s,%s,%s,%s)",
106 array("integer", "integer", "text", "integer", "integer"),
107 array($this->getObjId(), $a_usr_id, 'notgraded', 0, 0)
108 );
109
111
112 $this->read();
113
114 ilLPStatusWrapper::_updateStatus($this->getObjId(), $a_usr_id);
115
116 return true;
117 }
static createNewUserRecords($a_user_id, $a_exc_id)
Create member status record for a new participant for all assignments.
getObjId()
Get exercise 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 (   $a_members)

Assign members to exercise.

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

131 {
132 $assigned = 0;
133 if (is_array($a_members)) {
134 foreach ($a_members as $member) {
135 if (!$this->isAssigned($member)) {
136 $this->assignMember($member);
137 } else {
138 ++$assigned;
139 }
140 }
141 }
142 if ($assigned == count($a_members)) {
143 return false;
144 } else {
145 return true;
146 }
147 }
assignMember($a_usr_id)
Assign a user to the exercise.
isAssigned($a_id)
Is user assigned to exercise?

References assignMember(), and isAssigned().

+ Here is the call graph for this function:

◆ deassignMember()

ilExerciseMembers::deassignMember (   $a_usr_id)

Detaches a user from an exercise.

Parameters
int$a_usr_iduser id

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

155 {
157
158 $this->recommended_content_manager->removeObjectRecommendation($a_usr_id, $this->getRefId());
159
160 $query = "DELETE FROM exc_members " .
161 "WHERE obj_id = " . $ilDB->quote($this->getObjId(), "integer") . " " .
162 "AND usr_id = " . $ilDB->quote($a_usr_id, "integer") . " ";
163
164 $ilDB->manipulate($query);
165
166 $this->read();
167
168 ilLPStatusWrapper::_updateStatus($this->getObjId(), $a_usr_id);
169
170 // delete all delivered files of the member
171 ilExSubmission::deleteUser($this->exc->getId(), $a_usr_id);
172
173 // @todo: delete all assignment associations (and their files)
174
175 return false;
176 }
static deleteUser($a_exc_id, $a_user_id)
Delete all delivered files of user.
getRefId()
Get exercise ref id.

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

Referenced by deassignMembers().

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

◆ deassignMembers()

ilExerciseMembers::deassignMembers (   $a_members)

Deassign members.

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

182 {
183 if (is_array($a_members)) {
184 foreach ($a_members as $member) {
185 $this->deassignMember($member);
186 }
187 } else {
188 return false;
189 }
190 }
deassignMember($a_usr_id)
Detaches a user from an exercise.

References deassignMember().

+ Here is the call graph for this function:

◆ delete()

ilExerciseMembers::delete ( )

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

252 {
254
255 $query = "DELETE FROM exc_members WHERE obj_id = " .
256 $ilDB->quote($this->getObjId(), "integer");
257 $ilDB->manipulate($query);
258
260
261 return true;
262 }
static _refreshStatus($a_obj_id, $a_users=null)
Set dirty.

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

+ Here is the call graph for this function:

◆ getMembers()

ilExerciseMembers::getMembers ( )

Get members array.

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

73 {
74 return $this->members ? $this->members : array();
75 }

Referenced by isAssigned().

+ Here is the caller graph for this function:

◆ getObjId()

ilExerciseMembers::getObjId ( )

Get exercise id.

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

References $obj_id.

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

+ Here is the caller graph for this function:

◆ getRefId()

ilExerciseMembers::getRefId ( )

Get exercise ref id.

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

References $ref_id.

Referenced by deassignMember().

+ Here is the caller graph for this function:

◆ ilClone()

ilExerciseMembers::ilClone (   $a_new_id)

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

217 {
219
220 $data = array();
221
222 $query = "SELECT * FROM exc_members " .
223 "WHERE obj_id = " . $ilDB->quote($this->getObjId(), "integer");
224
225 $res = $ilDB->query($query);
226 while ($row = $ilDB->fetchObject($res)) {
227 $data[] = array("usr_id" => $row->usr_id,
228 "notice" => $row->notice,
229 "returned" => $row->returned,
230 "status" => $row->status,
231 "sent" => $row->sent,
232 "feedback" => $row->feedback
233 );
234 }
235 foreach ($data as $row) {
236 $ilDB->manipulateF(
237 "INSERT INTO exc_members " .
238 " (obj_id, usr_id, notice, returned, status, feedback, sent) VALUES " .
239 " (%s,%s,%s,%s,%s,%s,%s)",
240 array("integer", "integer", "text", "integer", "text", "integer", "integer"),
241 array($a_new_id, $row["usr_id"], $row["notice"], (int) $row["returned"],
242 $row["status"], (int) $row["feedback"], (int) $row["sent"])
243 );
244
245 ilLPStatusWrapper::_updateStatus($a_new_id, $row["usr_id"]);
246 }
247 return true;
248 }
$data
Definition: storeScorm.php:23

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

+ Here is the call graph for this function:

◆ isAssigned()

ilExerciseMembers::isAssigned (   $a_id)

Is user assigned to exercise?

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

123 {
124 return in_array($a_id, $this->getMembers());
125 }
getMembers()
Get members array.

References getMembers().

Referenced by assignMembers().

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

◆ read()

ilExerciseMembers::read ( )

Read all members.

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

196 {
198
199 $tmp_arr_members = array();
200
201 $query = "SELECT * FROM exc_members " .
202 "WHERE obj_id = " . $ilDB->quote($this->getObjId(), "integer");
203
204 $res = $ilDB->query($query);
205 while ($row = $ilDB->fetchObject($res)) {
206 if (ilObject::_lookupType($row->usr_id) == "usr") {
207 $tmp_arr_members[] = $row->usr_id;
208 }
209 }
210 $this->setMembers($tmp_arr_members);
211
212 return true;
213 }
setMembers($a_members)
Set members array.
static _lookupType($a_id, $a_reference=false)
lookup object type

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 (   $a_members)

Set members array.

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

81 {
82 $this->members = $a_members;
83 }

Referenced by read().

+ Here is the caller graph for this function:

◆ setObjId()

ilExerciseMembers::setObjId (   $a_obj_id)

Set exercise id.

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

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

Field Documentation

◆ $db

ilExerciseMembers::$db
protected

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

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

◆ $members

ilExerciseMembers::$members

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

◆ $obj_id

ilExerciseMembers::$obj_id

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

Referenced by getObjId().

◆ $recommended_content_manager

ilExerciseMembers::$recommended_content_manager
protected

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

◆ $ref_id

ilExerciseMembers::$ref_id

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

Referenced by getRefId().

◆ $status

ilExerciseMembers::$status

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


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