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.

References $DIC, and read().

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
read()
Read all members.
+ 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.

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

Referenced by ilLPStatusExerciseReturned\_getFailed().

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ 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.

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

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

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
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 427 of file class.ilExerciseMembers.php.

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

Referenced by ilLPStatusExerciseReturned\_getCompleted().

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
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 381 of file class.ilExerciseMembers.php.

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

Referenced by ilLPStatusExerciseReturned\_getInProgress().

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
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 406 of file class.ilExerciseMembers.php.

References $DIC, and $ilDB.

Referenced by ilLPStatusExerciseReturned\determineStatus().

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  }
global $DIC
Definition: saml.php:7
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 297 of file class.ilExerciseMembers.php.

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

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

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  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
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 355 of file class.ilExerciseMembers.php.

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

Referenced by ilObjExercise\processExerciseStatus().

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  }
global $DIC
Definition: saml.php:7
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
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 326 of file class.ilExerciseMembers.php.

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

Referenced by ilObjExercise\updateUserStatus().

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  }
global $DIC
Definition: saml.php:7
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
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 84 of file class.ilExerciseMembers.php.

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

Referenced by assignMembers().

85  {
86  $ilDB = $this->db;
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");
106  ilExAssignment::createNewUserRecords($a_usr_id, $this->getObjId());
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  }
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 getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object 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 127 of file class.ilExerciseMembers.php.

References assignMember(), and isAssigned().

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

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

Referenced by deassignMembers().

152  {
153  $ilDB = $this->db;
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.
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.
$query
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
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 181 of file class.ilExerciseMembers.php.

References deassignMember().

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.
+ Here is the call graph for this function:

◆ delete()

ilExerciseMembers::delete ( )

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

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

253  {
254  $ilDB = $this->db;
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  }
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 66 of file class.ilExerciseMembers.php.

Referenced by isAssigned().

67  {
68  return $this->members ? $this->members : array();
69  }
+ 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().

51  {
52  return $this->obj_id;
53  }
+ 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().

43  {
44  return $this->ref_id;
45  }
+ Here is the caller graph for this function:

◆ ilClone()

ilExerciseMembers::ilClone (   $a_new_id)

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

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

217  {
218  $ilDB = $this->db;
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  }
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
$row
global $ilDB
$data
Definition: bench.php:6
+ 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.

References getMembers().

Referenced by assignMembers().

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

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

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

196  {
197  $ilDB = $this->db;
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  }
getObjId()
Get exercise id.
foreach($_POST as $key=> $value) $res
$query
static _lookupType($a_id, $a_reference=false)
lookup object type
$row
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 74 of file class.ilExerciseMembers.php.

Referenced by read().

75  {
76  $this->members = $a_members;
77  }
+ 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: