ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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
 

Detailed Description

Class ilExerciseMembers.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilExerciseMembers::__construct (   $a_exc)

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

29 {
30 global $DIC;
31
32 $this->db = $DIC->database();
33 $this->exc = $a_exc;
34 $this->obj_id = $a_exc->getId();
35 $this->ref_id = $a_exc->getRefId();
36 $this->read();
37 }
global $DIC
Definition: saml.php:7

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

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

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

Referenced by ilLPStatusExerciseReturned\_getFailed().

+ Here is the caller graph for this function:

◆ _getMembers()

static ilExerciseMembers::_getMembers (   $a_obj_id)
static

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Referenced by ilObjExerciseAccess\checkCondition(), ilLPStatusExerciseReturned\determineStatus(), ilObjExercise\exportGradesExcel(), ilExGradesTableGUI\fillRow(), ilExerciseCertificateAdapter\getCertificateVariablesForPresentation(), ilExerciseCertificateAdapter\hasUserCertificate(), 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 355 of file class.ilExerciseMembers.php.

356 {
357 global $DIC;
358
359 $ilDB = $DIC->database();
360
361 $ilDB->manipulate(
362 "UPDATE exc_members SET " .
363 " returned = " . $ilDB->quote($a_status, "integer") .
364 " WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") .
365 " AND usr_id = " . $ilDB->quote($a_user_id, "integer")
366 );
367
368 include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
369 ilLPStatusWrapper::_updateStatus($a_obj_id, $a_user_id);
370 }
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 326 of file class.ilExerciseMembers.php.

327 {
328 global $DIC;
329
330 $ilDB = $DIC->database();
331
332 $ilDB->manipulate(
333 "UPDATE exc_members SET " .
334 " status = " . $ilDB->quote($a_status, "text") .
335 " WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") .
336 " AND usr_id = " . $ilDB->quote($a_user_id, "integer")
337 );
338
339 include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
340 ilLPStatusWrapper::_updateStatus($a_obj_id, $a_user_id);
341 }

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

85 {
87
88 if ($this->exc->hasAddToDesktop()) {
89 $tmp_user = ilObjectFactory::getInstanceByObjId($a_usr_id);
90 $tmp_user->addDesktopItem($this->getRefId(), "exc");
91 }
92
93 $ilDB->manipulate("DELETE FROM exc_members " .
94 "WHERE obj_id = " . $ilDB->quote($this->getObjId(), "integer") . " " .
95 "AND usr_id = " . $ilDB->quote($a_usr_id, "integer") . " ");
96
97 // @todo: some of this fields may not be needed anymore
98 $ilDB->manipulateF(
99 "INSERT INTO exc_members (obj_id, usr_id, status, sent, feedback) " .
100 " VALUES (%s,%s,%s,%s,%s)",
101 array("integer", "integer", "text", "integer", "integer"),
102 array($this->getObjId(), $a_usr_id, 'notgraded', 0, 0)
103 );
104
105 include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
107
108 $this->read();
109
110 include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
111 ilLPStatusWrapper::_updateStatus($this->getObjId(), $a_usr_id);
112
113 return true;
114 }
static createNewUserRecords($a_user_id, $a_exc_id)
Create member status record for a new participant for all assignments.
getRefId()
Get exercise ref id.
getObjId()
Get exercise id.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id

References $db, $ilDB, ilLPStatusWrapper\_updateStatus(), ilExAssignment\createNewUserRecords(), ilObjectFactory\getInstanceByObjId(), getObjId(), getRefId(), 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 127 of file class.ilExerciseMembers.php.

128 {
129 $assigned = 0;
130 if (is_array($a_members)) {
131 foreach ($a_members as $member) {
132 if (!$this->isAssigned($member)) {
133 $this->assignMember($member);
134 } else {
135 ++$assigned;
136 }
137 }
138 }
139 if ($assigned == count($a_members)) {
140 return false;
141 } else {
142 return true;
143 }
144 }
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 151 of file class.ilExerciseMembers.php.

152 {
154
155 $tmp_user = ilObjectFactory::getInstanceByObjId($a_usr_id);
156 $tmp_user->dropDesktopItem($this->getRefId(), "exc");
157
158 $query = "DELETE FROM exc_members " .
159 "WHERE obj_id = " . $ilDB->quote($this->getObjId(), "integer") . " " .
160 "AND usr_id = " . $ilDB->quote($a_usr_id, "integer") . " ";
161
162 $ilDB->manipulate($query);
163
164 $this->read();
165
166 include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
167 ilLPStatusWrapper::_updateStatus($this->getObjId(), $a_usr_id);
168
169 // delete all delivered files of the member
170 include_once("./Modules/Exercise/classes/class.ilExSubmission.php");
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.

References $db, $ilDB, $query, ilLPStatusWrapper\_updateStatus(), ilExSubmission\deleteUser(), ilObjectFactory\getInstanceByObjId(), 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 252 of file class.ilExerciseMembers.php.

253 {
255
256 $query = "DELETE FROM exc_members WHERE obj_id = " .
257 $ilDB->quote($this->getObjId(), "integer");
258 $ilDB->manipulate($query);
259
260 include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
262
263 return true;
264 }
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 66 of file class.ilExerciseMembers.php.

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

Referenced by isAssigned().

+ Here is the caller graph for this function:

◆ getObjId()

ilExerciseMembers::getObjId ( )

Get exercise id.

Definition at line 50 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 42 of file class.ilExerciseMembers.php.

References $ref_id.

Referenced by assignMember(), and 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 include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
246 ilLPStatusWrapper::_updateStatus($a_new_id, $row["usr_id"]);
247 }
248 return true;
249 }
$data
Definition: bench.php:6

References $data, $db, $ilDB, $query, $res, $row, 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 119 of file class.ilExerciseMembers.php.

120 {
121 return in_array($a_id, $this->getMembers());
122 }
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, $row, 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 74 of file class.ilExerciseMembers.php.

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

Referenced by read().

+ Here is the caller graph for this function:

◆ setObjId()

ilExerciseMembers::setObjId (   $a_obj_id)

Set exercise id.

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

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

Field Documentation

◆ $db

ilExerciseMembers::$db
protected

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

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

◆ $members

ilExerciseMembers::$members

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

◆ $obj_id

ilExerciseMembers::$obj_id

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

Referenced by getObjId().

◆ $ref_id

ilExerciseMembers::$ref_id

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

Referenced by getRefId().

◆ $status

ilExerciseMembers::$status

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


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