ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
 

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

References read().

24  {
25  $this->exc = $a_exc;
26  $this->obj_id = $a_exc->getId();
27  $this->ref_id = $a_exc->getRefId();
28  $this->read();
29  }
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 437 of file class.ilExerciseMembers.php.

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

Referenced by ilLPStatusExerciseReturned\_getFailed().

438  {
439  global $ilDB;
440 
441  $query = "SELECT DISTINCT(usr_id) FROM exc_members ".
442  "WHERE obj_id = ".$ilDB->quote($a_obj_id, "integer")." ".
443  "AND status = ".$ilDB->quote("failed", "text");
444  $res = $ilDB->query($query);
445  while($row = $ilDB->fetchObject($res))
446  {
447  $usr_ids[] = $row->usr_id;
448  }
449  return $usr_ids ? $usr_ids : array();
450  }
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ _getMembers()

static ilExerciseMembers::_getMembers (   $a_obj_id)
static

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

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

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

270  {
271  global $ilDB;
272 
273  // #14963 - see ilExAssignment::getMemberListData()
274  $query = "SELECT DISTINCT(excm.usr_id) ud".
275  " FROM exc_members excm".
276  " JOIN object_data od ON (od.obj_id = excm.usr_id)".
277  " WHERE excm.obj_id = ".$ilDB->quote($a_obj_id, "integer").
278  " AND od.type = ".$ilDB->quote("usr", "text");
279 
280  $res = $ilDB->query($query);
281  while($row = $ilDB->fetchObject($res))
282  {
283  $usr_ids[] = $row->ud;
284  }
285 
286  return $usr_ids ? $usr_ids : array();
287  }
Create styles array
The data for the language used.
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 419 of file class.ilExerciseMembers.php.

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

Referenced by ilLPStatusExerciseReturned\_getCompleted().

420  {
421  global $ilDB;
422 
423  $query = "SELECT DISTINCT(usr_id) FROM exc_members ".
424  "WHERE obj_id = ".$ilDB->quote($a_obj_id, "integer")." ".
425  "AND status = ".$ilDB->quote("passed", "text");
426  $res = $ilDB->query($query);
427  while($row = $ilDB->fetchObject($res))
428  {
429  $usr_ids[] = $row->usr_id;
430  }
431  return $usr_ids ? $usr_ids : array();
432  }
Create styles array
The data for the language used.
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 376 of file class.ilExerciseMembers.php.

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

Referenced by ilLPStatusExerciseReturned\_getInProgress().

377  {
378  global $ilDB;
379 
380  $query = "SELECT DISTINCT(usr_id) as ud FROM exc_members ".
381  "WHERE obj_id = ".$ilDB->quote($a_obj_id, "integer")." ".
382  "AND returned = 1";
383 
384  $res = $ilDB->query($query);
385  while($row = $ilDB->fetchObject($res))
386  {
387  $usr_ids[] = $row->ud;
388  }
389 
390  return $usr_ids ? $usr_ids : array();
391  }
Create styles array
The data for the language used.
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 400 of file class.ilExerciseMembers.php.

References $ilDB.

Referenced by ilLPStatusExerciseReturned\determineStatus().

401  {
402  global $ilDB;
403 
404  $set = $ilDB->query("SELECT DISTINCT(usr_id) FROM exc_members WHERE ".
405  " obj_id = ".$ilDB->quote($a_obj_id, "integer")." AND ".
406  " returned = ".$ilDB->quote(1, "integer")." AND ".
407  " usr_id = ".$ilDB->quote($a_user_id, "integer")
408  );
409  if ($rec = $ilDB->fetchAssoc($set))
410  {
411  return true;
412  }
413  return false;
414  }
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 299 of file class.ilExerciseMembers.php.

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

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

300  {
301  global $ilDB;
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  {
310  return $row["status"];
311  }
312 
313  return false;
314  }
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 353 of file class.ilExerciseMembers.php.

References $ilDB, and ilLPStatusWrapper\_updateStatus().

Referenced by ilObjExercise\processExerciseStatus().

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

References $ilDB, and ilLPStatusWrapper\_updateStatus().

Referenced by ilObjExercise\updateUserStatus().

328  {
329  global $ilDB;
330 
331  $ilDB->manipulate("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  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
338  ilLPStatusWrapper::_updateStatus($a_obj_id, $a_user_id);
339  }
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 76 of file class.ilExerciseMembers.php.

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

Referenced by assignMembers().

77  {
78  global $ilDB;
79 
80  if($this->exc->hasAddToDesktop())
81  {
82  $tmp_user = ilObjectFactory::getInstanceByObjId($a_usr_id);
83  $tmp_user->addDesktopItem($this->getRefId(),"exc");
84  }
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("INSERT INTO exc_members (obj_id, usr_id, status, sent, feedback) ".
92  " VALUES (%s,%s,%s,%s,%s)",
93  array("integer", "integer", "text", "integer", "integer"),
94  array($this->getObjId(), $a_usr_id, 'notgraded', 0, 0));
95 
96  include_once("./Modules/Exercise/classes/class.ilExAssignment.php");
98 
99  $this->read();
100 
101  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
102  ilLPStatusWrapper::_updateStatus($this->getObjId(), $a_usr_id);
103 
104  return true;
105  }
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
Create styles array
The data for the language used.
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 118 of file class.ilExerciseMembers.php.

References assignMember(), and isAssigned().

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

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

Referenced by deassignMembers().

151  {
152  global $ilDB;
153 
154  $tmp_user = ilObjectFactory::getInstanceByObjId($a_usr_id);
155  $tmp_user->dropDesktopItem($this->getRefId(),"exc");
156 
157  $query = "DELETE FROM exc_members ".
158  "WHERE obj_id = ".$ilDB->quote($this->getObjId(), "integer")." ".
159  "AND usr_id = ".$ilDB->quote($a_usr_id, "integer")." ";
160 
161  $ilDB->manipulate($query);
162 
163  $this->read();
164 
165  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
166  ilLPStatusWrapper::_updateStatus($this->getObjId(), $a_usr_id);
167 
168  // delete all delivered files of the member
169  include_once("./Modules/Exercise/classes/class.ilExSubmission.php");
170  ilExSubmission::deleteUser($this->exc->getId(), $a_usr_id);
171 
172 // @todo: delete all assignment associations (and their files)
173 
174  return false;
175  }
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 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 180 of file class.ilExerciseMembers.php.

References deassignMember().

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

◆ delete()

ilExerciseMembers::delete ( )

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

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

256  {
257  global $ilDB;
258 
259  $query = "DELETE FROM exc_members WHERE obj_id = ".
260  $ilDB->quote($this->getObjId(), "integer");
261  $ilDB->manipulate($query);
262 
263  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
265 
266  return true;
267  }
getObjId()
Get exercise id.
static _refreshStatus($a_obj_id, $a_users=null)
Set dirty.
global $ilDB
+ Here is the call graph for this function:

◆ getMembers()

ilExerciseMembers::getMembers ( )

Get members array.

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

References array.

Referenced by isAssigned().

59  {
60  return $this->members ? $this->members : array();
61  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ getObjId()

ilExerciseMembers::getObjId ( )

Get exercise id.

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

References $obj_id.

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

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

◆ getRefId()

ilExerciseMembers::getRefId ( )

Get exercise ref id.

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

References $ref_id.

Referenced by assignMember(), and deassignMember().

35  {
36  return $this->ref_id;
37  }
+ Here is the caller graph for this function:

◆ ilClone()

ilExerciseMembers::ilClone (   $a_new_id)

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

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

219  {
220  global $ilDB;
221 
222  $data = array();
223 
224  $query = "SELECT * FROM exc_members ".
225  "WHERE obj_id = ".$ilDB->quote($this->getObjId(), "integer");
226 
227  $res = $ilDB->query($query);
228  while($row = $ilDB->fetchObject($res))
229  {
230  $data[] = array("usr_id" => $row->usr_id,
231  "notice" => $row->notice,
232  "returned" => $row->returned,
233  "status" => $row->status,
234  "sent" => $row->sent,
235  "feedback" => $row->feedback
236  );
237  }
238  foreach($data as $row)
239  {
240  $ilDB->manipulateF("INSERT INTO exc_members ".
241  " (obj_id, usr_id, notice, returned, status, feedback, sent) VALUES ".
242  " (%s,%s,%s,%s,%s,%s,%s)",
243  array ("integer", "integer", "text", "integer", "text", "integer", "integer"),
244  array ($a_new_id, $row["usr_id"], $row["notice"], (int) $row["returned"],
245  $row["status"], (int) $row["feedback"], (int) $row["sent"])
246  );
247 
248  include_once("./Services/Tracking/classes/class.ilLPStatusWrapper.php");
249  ilLPStatusWrapper::_updateStatus($a_new_id, $row["usr_id"]);
250  }
251  return true;
252  }
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
getObjId()
Get exercise id.
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ isAssigned()

ilExerciseMembers::isAssigned (   $a_id)

Is user assigned to exercise?

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

References getMembers().

Referenced by assignMembers().

111  {
112  return in_array($a_id,$this->getMembers());
113  }
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 198 of file class.ilExerciseMembers.php.

References $ilDB, $query, $res, $row, array, getObjId(), and setMembers().

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

199  {
200  global $ilDB;
201 
202  $tmp_arr_members = array();
203 
204  $query = "SELECT * FROM exc_members ".
205  "WHERE obj_id = ".$ilDB->quote($this->getObjId(), "integer");
206 
207  $res = $ilDB->query($query);
208  while($row = $ilDB->fetchObject($res))
209  {
210  $tmp_arr_members[] = $row->usr_id;
211  }
212  $this->setMembers($tmp_arr_members);
213 
214  return true;
215  }
getObjId()
Get exercise id.
Create styles array
The data for the language used.
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 66 of file class.ilExerciseMembers.php.

Referenced by read().

67  {
68  $this->members = $a_members;
69  }
+ Here is the caller graph for this function:

◆ setObjId()

ilExerciseMembers::setObjId (   $a_obj_id)

Set exercise id.

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

51  {
52  $this->obj_id = $a_obj_id;
53  }

Field Documentation

◆ $members

ilExerciseMembers::$members

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

◆ $obj_id

ilExerciseMembers::$obj_id

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

Referenced by getObjId().

◆ $ref_id

ilExerciseMembers::$ref_id

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

Referenced by getRefId().

◆ $status

ilExerciseMembers::$status

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


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