ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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.

References $DIC, and read().

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  }
global $DIC
Definition: goto.php:24
read()
Read all members.
Recommended content manager (business logic)
+ 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 448 of file class.ilExerciseMembers.php.

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

Referenced by ilLPStatusExerciseReturned\_getFailed().

449  {
450  global $DIC;
451 
452  $ilDB = $DIC->database();
453 
454  $query = "SELECT DISTINCT(usr_id) FROM exc_members " .
455  "WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") . " " .
456  "AND status = " . $ilDB->quote("failed", "text");
457  $res = $ilDB->query($query);
458  while ($row = $ilDB->fetchObject($res)) {
459  $usr_ids[] = $row->usr_id;
460  }
461  return $usr_ids ? $usr_ids : array();
462  }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
$query
global $ilDB
+ Here is the caller graph for this function:

◆ _getMembers()

static ilExerciseMembers::_getMembers (   $a_obj_id)
static

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

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

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

271  {
272  global $DIC;
273 
274  $ilDB = $DIC->database();
275 
276  // #14963 - see ilExAssignment::getMemberListData()
277  $query = "SELECT DISTINCT(excm.usr_id) ud" .
278  " FROM exc_members excm" .
279  " JOIN object_data od ON (od.obj_id = excm.usr_id)" .
280  " WHERE excm.obj_id = " . $ilDB->quote($a_obj_id, "integer") .
281  " AND od.type = " . $ilDB->quote("usr", "text");
282 
283  $res = $ilDB->query($query);
284  while ($row = $ilDB->fetchObject($res)) {
285  $usr_ids[] = $row->ud;
286  }
287 
288  return $usr_ids ? $usr_ids : array();
289  }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
$query
global $ilDB
+ 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 429 of file class.ilExerciseMembers.php.

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

Referenced by ilLPStatusExerciseReturned\_getCompleted().

430  {
431  global $DIC;
432 
433  $ilDB = $DIC->database();
434 
435  $query = "SELECT DISTINCT(usr_id) FROM exc_members " .
436  "WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") . " " .
437  "AND status = " . $ilDB->quote("passed", "text");
438  $res = $ilDB->query($query);
439  while ($row = $ilDB->fetchObject($res)) {
440  $usr_ids[] = $row->usr_id;
441  }
442  return $usr_ids ? $usr_ids : array();
443  }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
$query
global $ilDB
+ 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 383 of file class.ilExerciseMembers.php.

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

Referenced by ilLPStatusExerciseReturned\_getInProgress().

384  {
385  global $DIC;
386 
387  $ilDB = $DIC->database();
388 
389  $query = "SELECT DISTINCT(usr_id) as ud FROM exc_members " .
390  "WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") . " " .
391  "AND returned = 1";
392 
393  $res = $ilDB->query($query);
394  while ($row = $ilDB->fetchObject($res)) {
395  $usr_ids[] = $row->ud;
396  }
397 
398  return $usr_ids ? $usr_ids : array();
399  }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
$query
global $ilDB
+ 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 408 of file class.ilExerciseMembers.php.

References $DIC, and $ilDB.

Referenced by ilLPStatusExerciseReturned\determineStatus().

409  {
410  global $DIC;
411 
412  $ilDB = $DIC->database();
413 
414  $set = $ilDB->query(
415  "SELECT DISTINCT(usr_id) FROM exc_members WHERE " .
416  " obj_id = " . $ilDB->quote($a_obj_id, "integer") . " AND " .
417  " returned = " . $ilDB->quote(1, "integer") . " AND " .
418  " usr_id = " . $ilDB->quote($a_user_id, "integer")
419  );
420  if ($rec = $ilDB->fetchAssoc($set)) {
421  return true;
422  }
423  return false;
424  }
global $DIC
Definition: goto.php:24
global $ilDB
+ 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 301 of file class.ilExerciseMembers.php.

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

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

302  {
303  global $DIC;
304 
305  $ilDB = $DIC->database();
306 
307  $query = "SELECT status FROM exc_members " .
308  "WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") .
309  " AND usr_id = " . $ilDB->quote($a_user_id, "integer");
310 
311  $res = $ilDB->query($query);
312  if ($row = $ilDB->fetchAssoc($res)) {
313  return $row["status"];
314  }
315 
316  return false;
317  }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
$query
global $ilDB
+ 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 358 of file class.ilExerciseMembers.php.

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

Referenced by ilObjExercise\processExerciseStatus().

359  {
360  global $DIC;
361 
362  $ilDB = $DIC->database();
363 
364  $ilDB->manipulate(
365  "UPDATE exc_members SET " .
366  " returned = " . $ilDB->quote($a_status, "integer") .
367  " WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") .
368  " AND usr_id = " . $ilDB->quote($a_user_id, "integer")
369  );
370 
371  ilLPStatusWrapper::_updateStatus($a_obj_id, $a_user_id);
372  }
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
global $DIC
Definition: goto.php:24
global $ilDB
+ 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 330 of file class.ilExerciseMembers.php.

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

Referenced by ilObjExercise\updateUserStatus().

331  {
332  global $DIC;
333 
334  $ilDB = $DIC->database();
335 
336  $ilDB->manipulate(
337  "UPDATE exc_members SET " .
338  " status = " . $ilDB->quote($a_status, "text") .
339  " WHERE obj_id = " . $ilDB->quote($a_obj_id, "integer") .
340  " AND usr_id = " . $ilDB->quote($a_user_id, "integer")
341  );
342 
343  ilLPStatusWrapper::_updateStatus($a_obj_id, $a_user_id);
344  }
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
global $DIC
Definition: goto.php:24
global $ilDB
+ 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.

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

Referenced by assignMembers().

91  {
92  $ilDB = $this->db;
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 
110  ilExAssignment::createNewUserRecords($a_usr_id, $this->getObjId());
111 
112  $this->read();
113 
114  ilLPStatusWrapper::_updateStatus($this->getObjId(), $a_usr_id);
115 
116  return true;
117  }
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
getObjId()
Get exercise id.
read()
Read all members.
global $ilDB
static createNewUserRecords($a_user_id, $a_exc_id)
Create member status record for a new participant for all assignments.
+ 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.

References assignMember(), and isAssigned().

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  }
isAssigned($a_id)
Is user assigned to exercise?
assignMember($a_usr_id)
Assign a user to the exercise.
+ 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.

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

Referenced by deassignMembers().

155  {
156  $ilDB = $this->db;
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  // delete individual deadline/starting time entries
174  foreach (ilExAssignment::getInstancesByExercise($this->exc->getId()) as $ass) {
175  $idl = ilExcIndividualDeadline::getInstance($ass->getId(), $a_usr_id, false);
176  $idl->delete();
177  }
178 
179  // @todo: delete all assignment associations (and their files)
180 
181  return false;
182  }
static deleteUser($a_exc_id, $a_user_id)
Delete all delivered files of user.
getRefId()
Get exercise ref id.
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
getObjId()
Get exercise id.
static getInstance($a_ass_id, $a_participant_id, $a_is_team=false)
Get instance.
static getInstancesByExercise($a_exc_id)
$query
read()
Read all members.
global $ilDB
+ 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 187 of file class.ilExerciseMembers.php.

References deassignMember().

188  {
189  if (is_array($a_members)) {
190  foreach ($a_members as $member) {
191  $this->deassignMember($member);
192  }
193  } else {
194  return false;
195  }
196  }
deassignMember($a_usr_id)
Detaches a user from an exercise.
+ Here is the call graph for this function:

◆ delete()

ilExerciseMembers::delete ( )

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

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

258  {
259  $ilDB = $this->db;
260 
261  $query = "DELETE FROM exc_members WHERE obj_id = " .
262  $ilDB->quote($this->getObjId(), "integer");
263  $ilDB->manipulate($query);
264 
266 
267  return true;
268  }
getObjId()
Get exercise id.
static _refreshStatus($a_obj_id, $a_users=null)
Set dirty.
$query
global $ilDB
+ Here is the call graph for this function:

◆ getMembers()

ilExerciseMembers::getMembers ( )

Get members array.

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

Referenced by isAssigned().

73  {
74  return $this->members ? $this->members : array();
75  }
+ 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().

57  {
58  return $this->obj_id;
59  }
+ 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().

49  {
50  return $this->ref_id;
51  }
+ Here is the caller graph for this function:

◆ ilClone()

ilExerciseMembers::ilClone (   $a_new_id)

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

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

223  {
224  $ilDB = $this->db;
225 
226  $data = array();
227 
228  $query = "SELECT * FROM exc_members " .
229  "WHERE obj_id = " . $ilDB->quote($this->getObjId(), "integer");
230 
231  $res = $ilDB->query($query);
232  while ($row = $ilDB->fetchObject($res)) {
233  $data[] = array("usr_id" => $row->usr_id,
234  "notice" => $row->notice,
235  "returned" => $row->returned,
236  "status" => $row->status,
237  "sent" => $row->sent,
238  "feedback" => $row->feedback
239  );
240  }
241  foreach ($data as $row) {
242  $ilDB->manipulateF(
243  "INSERT INTO exc_members " .
244  " (obj_id, usr_id, notice, returned, status, feedback, sent) VALUES " .
245  " (%s,%s,%s,%s,%s,%s,%s)",
246  array("integer", "integer", "text", "integer", "text", "integer", "integer"),
247  array($a_new_id, $row["usr_id"], $row["notice"], (int) $row["returned"],
248  $row["status"], (int) $row["feedback"], (int) $row["sent"])
249  );
250 
251  ilLPStatusWrapper::_updateStatus($a_new_id, $row["usr_id"]);
252  }
253  return true;
254  }
$data
Definition: storeScorm.php:23
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
getObjId()
Get exercise id.
foreach($_POST as $key=> $value) $res
$query
global $ilDB
+ 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.

References getMembers().

Referenced by assignMembers().

123  {
124  return in_array($a_id, $this->getMembers());
125  }
getMembers()
Get members array.
+ 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 201 of file class.ilExerciseMembers.php.

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

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

202  {
203  $ilDB = $this->db;
204 
205  $tmp_arr_members = array();
206 
207  $query = "SELECT * FROM exc_members " .
208  "WHERE obj_id = " . $ilDB->quote($this->getObjId(), "integer");
209 
210  $res = $ilDB->query($query);
211  while ($row = $ilDB->fetchObject($res)) {
212  if (ilObject::_lookupType($row->usr_id) == "usr") {
213  $tmp_arr_members[] = $row->usr_id;
214  }
215  }
216  $this->setMembers($tmp_arr_members);
217 
218  return true;
219  }
getObjId()
Get exercise id.
foreach($_POST as $key=> $value) $res
$query
static _lookupType($a_id, $a_reference=false)
lookup object type
global $ilDB
setMembers($a_members)
Set members array.
+ 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.

Referenced by read().

81  {
82  $this->members = $a_members;
83  }
+ 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: