ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilExAssignmentTeam Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilExAssignmentTeam:

Public Member Functions

 __construct (?int $a_id=null)
 
 getId ()
 
 createTeam (int $a_assignment_id, int $a_user_id)
 
 getMembers ()
 
 getMembersOfAllTeams ()
 Get members for all teams of assignment. More...
 
 addTeamMember (int $a_user_id, ?int $a_exc_ref_id=null)
 
 removeTeamMember (int $a_user_id, ?int $a_exc_ref_id=null)
 
 writeLog (string $a_action, string $a_details=null)
 
 getLog ()
 
 sendNotification (int $a_exc_ref_id, int $a_user_id, string $a_action)
 Send notification about team status. More...
 
 createRandomTeams (int $a_exercise_id, int $a_assignment_id, int $a_number_teams, int $a_min_participants)
 Create random teams for assignment type "team upload" following specific rules. More...
 

Static Public Member Functions

static getInstanceByUserId (int $a_assignment_id, int $a_user_id, bool $a_create_on_demand=false)
 
static getInstancesFromMap (int $a_assignment_id)
 
static getTeamId (int $a_assignment_id, int $a_user_id, bool $a_create_on_demand=false)
 
static getAssignmentTeamMap (int $a_ass_id)
 
static writeTeamLog (int $a_team_id, string $a_action, string $a_details=null)
 Add entry to team log. More...
 
static getAdoptableTeamAssignments (int $a_exercise_id, int $a_exclude_ass_id=null, int $a_user_id=null)
 
static adoptTeams (int $a_source_ass_id, int $a_target_ass_id, int $a_user_id=null, int $a_exc_ref_id=null)
 
static getAdoptableGroups (int $a_exc_ref_id)
 
static getGroupMembersMap (int $a_exc_ref_id)
 

Data Fields

const TEAM_LOG_CREATE_TEAM = 1
 
const TEAM_LOG_ADD_MEMBER = 2
 
const TEAM_LOG_REMOVE_MEMBER = 3
 
const TEAM_LOG_ADD_FILE = 4
 
const TEAM_LOG_REMOVE_FILE = 5
 

Protected Member Functions

 read (int $a_id)
 
 cleanLog ()
 Remove obsolete log entries. More...
 

Protected Attributes

ilDBInterface $db
 
ilObjUser $user
 
int $id = null
 
int $assignment_id
 
array $members = array()
 

Private Member Functions

 setId (?int $a_id)
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Exercise assignment team

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 25 of file class.ilExAssignmentTeam.php.

Constructor & Destructor Documentation

◆ __construct()

ilExAssignmentTeam::__construct ( ?int  $a_id = null)

Definition at line 39 of file class.ilExAssignmentTeam.php.

References $DIC, read(), and ILIAS\Repository\user().

40  {
41  global $DIC;
42 
43  $this->db = $DIC->database();
44  $this->user = $DIC->user();
45  if ($a_id) {
46  $this->read($a_id);
47  }
48  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ addTeamMember()

ilExAssignmentTeam::addTeamMember ( int  $a_user_id,
?int  $a_exc_ref_id = null 
)
Exceptions
ilExcUnknownAssignmentTypeException

Definition at line 207 of file class.ilExAssignmentTeam.php.

References $db, $ilDB, ilObjUser\_lookupFullname(), getMembersOfAllTeams(), read(), sendNotification(), and writeLog().

Referenced by createRandomTeams().

210  : bool {
211  $ilDB = $this->db;
212 
213  if (!$this->id) {
214  return false;
215  }
216 
217  // must not be in any team already
218  if (!in_array($a_user_id, $this->getMembersOfAllTeams())) {
219  $fields = array("id" => array("integer", $this->id),
220  "ass_id" => array("integer", $this->assignment_id),
221  "user_id" => array("integer", $a_user_id));
222  $ilDB->insert("il_exc_team", $fields);
223 
224  if ($a_exc_ref_id) {
225  $this->sendNotification($a_exc_ref_id, $a_user_id, "add");
226  }
227 
228  $this->writeLog(
229  self::TEAM_LOG_ADD_MEMBER,
230  ilObjUser::_lookupFullname($a_user_id)
231  );
232 
233  $this->read($this->id);
234 
235  return true;
236  }
237 
238  return false;
239  }
writeLog(string $a_action, string $a_details=null)
static _lookupFullname(int $a_user_id)
sendNotification(int $a_exc_ref_id, int $a_user_id, string $a_action)
Send notification about team status.
getMembersOfAllTeams()
Get members for all teams of assignment.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ adoptTeams()

static ilExAssignmentTeam::adoptTeams ( int  $a_source_ass_id,
int  $a_target_ass_id,
int  $a_user_id = null,
int  $a_exc_ref_id = null 
)
static
Exceptions
ilExcUnknownAssignmentTypeException

Definition at line 453 of file class.ilExAssignmentTeam.php.

References getId(), and ilExcIndividualDeadline\getInstance().

Referenced by ilExSubmissionTeamGUI\createAdoptedTeamObject(), and ilExAssignmentEditorGUI\generateTeams().

458  : void {
459  $teams = array();
460 
461  $old_team = null;
462  foreach (self::getAssignmentTeamMap($a_source_ass_id) as $user_id => $team_id) {
463  $teams[$team_id][] = $user_id;
464 
465  if ($a_user_id && $user_id == $a_user_id) {
466  $old_team = $team_id;
467  }
468  }
469 
470  if ($a_user_id) {
471  // no existing team (in source) or user already in team (in current)
472  if (!$old_team ||
473  self::getInstanceByUserId($a_target_ass_id, $a_user_id)->getId()) {
474  return;
475  }
476  }
477 
478  $current_map = self::getAssignmentTeamMap($a_target_ass_id);
479 
480  foreach ($teams as $team_id => $user_ids) {
481  if (!$old_team || $team_id == $old_team) {
482  // only not assigned users
483  $missing = array();
484  foreach ($user_ids as $user_id) {
485  if (!array_key_exists($user_id, $current_map)) {
486  $missing[] = $user_id;
487  }
488  }
489 
490  if ($missing !== []) {
491  // create new team
492  $first = array_shift($missing);
493  $new_team = self::getInstanceByUserId($a_target_ass_id, $first, true);
494 
495  // give new team starting time of original user
496  if ($a_user_id > 0 && $old_team > 0) {
497  $idl = ilExcIndividualDeadline::getInstance($a_target_ass_id, $a_user_id);
498  if ($idl->getStartingTimestamp()) {
499  $idl_team = ilExcIndividualDeadline::getInstance($a_target_ass_id, $new_team->getId(), true);
500  $idl_team->setStartingTimestamp($idl->getStartingTimestamp());
501  $idl_team->save();
502  }
503  }
504 
505  if ($a_exc_ref_id) {
506  // getTeamId() does NOT send notification
507  $new_team->sendNotification($a_exc_ref_id, $first, "add");
508  }
509 
510  foreach ($missing as $user_id) {
511  $new_team->addTeamMember($user_id, $a_exc_ref_id);
512  }
513  }
514  }
515  }
516  }
static getInstance(int $a_ass_id, int $a_participant_id, bool $a_is_team=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cleanLog()

ilExAssignmentTeam::cleanLog ( )
protected

Remove obsolete log entries.

As there is no proper team deletion event, we are doing it this way

Definition at line 348 of file class.ilExAssignmentTeam.php.

References $db, and $ilDB.

Referenced by getLog().

348  : void
349  {
350  $ilDB = $this->db;
351 
352  // #18179
353 
354  // see also #31565
355  $obsolete_teams = [];
356  $set = $ilDB->query("SELECT DISTINCT l.team_id as id FROM il_exc_team_log as l LEFT JOIN il_exc_team as t ON (l.team_id = t.id) WHERE t.id IS NULL;");
357  while ($row = $ilDB->fetchAssoc($set)) {
358  $obsolete_teams[] = $row["id"];
359  }
360 
361  if (count($obsolete_teams) > 0) {
362  $q = "DELETE FROM il_exc_team_log" .
363  " WHERE " . $ilDB->in("team_id", $obsolete_teams, false, "integer");
364  $ilDB->manipulate($q);
365  }
366  }
+ Here is the caller graph for this function:

◆ createRandomTeams()

ilExAssignmentTeam::createRandomTeams ( int  $a_exercise_id,
int  $a_assignment_id,
int  $a_number_teams,
int  $a_min_participants 
)

Create random teams for assignment type "team upload" following specific rules.

example:

  • total exercise members : 9 members
  • total number of teams to create (defined via form): 4 groups
  • number of users per team –> 9 / 4 = 2 users
  • users to spread over groups –> 9 % 4 = 1 user
  • final teams: 3 teams of 2 users and 1 team of 3 users.
    Exceptions
    ilExcUnknownAssignmentTypeException
    Exception

Definition at line 571 of file class.ilExAssignmentTeam.php.

References $exercise, $i, addTeamMember(), createTeam(), and setId().

576  : void {
577  //just in case...
578  if (count(self::getAssignmentTeamMap($a_assignment_id))) {
579  return;
580  }
581  $exercise = new ilObjExercise($a_exercise_id, false);
582  $obj_exc_members = new ilExerciseMembers($exercise);
583  $members = $obj_exc_members->getMembers();
584  $total_exc_members = count($members);
585  $number_of_teams = $a_number_teams;
586  if (!$number_of_teams) {
587  if ($a_min_participants) {
588  $number_of_teams = round($total_exc_members / $a_min_participants);
589  } else {
590  $number_of_teams = random_int(1, $total_exc_members);
591  }
592  }
593  $members_per_team = round($total_exc_members / $number_of_teams);
594  shuffle($members);
595  for ($i = 0;$i < $number_of_teams;$i++) {
596  $members_counter = 0;
597  while (!empty($members) && $members_counter < $members_per_team) {
598  $member_id = array_pop($members);
599  if ($members_counter == 0) {
600  $team_id = $this->createTeam($a_assignment_id, $member_id);
601  $this->setId($team_id);
602  $this->assignment_id = $a_assignment_id;
603  } else {
604  $this->addTeamMember($member_id);
605  }
606  $members_counter++;
607  }
608  }
609  //get the new teams, remove duplicates.
610  $teams = array_unique(array_values(self::getAssignmentTeamMap($a_assignment_id)));
611  shuffle($teams);
612  while (!empty($members)) {
613  $member_id = array_pop($members);
614  $team_id = array_pop($teams);
615  $this->setId($team_id);
616  $this->addTeamMember($member_id);
617  }
618  }
createTeam(int $a_assignment_id, int $a_user_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addTeamMember(int $a_user_id, ?int $a_exc_ref_id=null)
Class ilObjExercise.
$i
Definition: metadata.php:41
+ Here is the call graph for this function:

◆ createTeam()

ilExAssignmentTeam::createTeam ( int  $a_assignment_id,
int  $a_user_id 
)

Definition at line 156 of file class.ilExAssignmentTeam.php.

References $db, $id, $ilDB, and ilObjUser\_lookupFullname().

Referenced by createRandomTeams().

159  : int {
160  $ilDB = $this->db;
161  $id = $ilDB->nextId("il_exc_team");
162  $fields = array("id" => array("integer", $id),
163  "ass_id" => array("integer", $a_assignment_id),
164  "user_id" => array("integer", $a_user_id));
165  $ilDB->insert("il_exc_team", $fields);
166  self::writeTeamLog($id, self::TEAM_LOG_CREATE_TEAM);
167  self::writeTeamLog(
168  $id,
169  self::TEAM_LOG_ADD_MEMBER,
170  ilObjUser::_lookupFullname($a_user_id)
171  );
172  return $id;
173  }
static _lookupFullname(int $a_user_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAdoptableGroups()

static ilExAssignmentTeam::getAdoptableGroups ( int  $a_exc_ref_id)
static
Parameters
int$a_exc_ref_id
Returns
int[] group obj ids

Definition at line 526 of file class.ilExAssignmentTeam.php.

References $DIC, and $res.

Referenced by ilExerciseManagementGUI\membersObject().

526  : array
527  {
528  global $DIC;
529 
530  $tree = $DIC->repositoryTree();
531 
532  $res = array();
533 
534  $parent_ref_id = $tree->getParentId($a_exc_ref_id);
535  if ($parent_ref_id) {
536  foreach ($tree->getChildsByType($parent_ref_id, "grp") as $group) {
537  $res[] = $group["obj_id"];
538  }
539  }
540 
541  return $res;
542  }
$res
Definition: ltiservices.php:69
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ getAdoptableTeamAssignments()

static ilExAssignmentTeam::getAdoptableTeamAssignments ( int  $a_exercise_id,
int  $a_exclude_ass_id = null,
int  $a_user_id = null 
)
static

Definition at line 399 of file class.ilExAssignmentTeam.php.

References $data, $res, ilExAssignment\getAssignmentDataOfExercise(), ilArrayUtil\sortArray(), and ilExAssignment\TYPE_UPLOAD_TEAM.

Referenced by ilExSubmissionTeamGUI\createTeamObject(), ilExSubmissionTeamGUI\getAdoptForm(), and ilExAssignmentEditorGUI\initAssignmentForm().

403  : array {
404  $res = array();
405 
407  foreach ($data as $row) {
408  if ($a_exclude_ass_id && $row["id"] == $a_exclude_ass_id) {
409  continue;
410  }
411 
412  if ($row["type"] == ilExAssignment::TYPE_UPLOAD_TEAM) {
413  $map = self::getAssignmentTeamMap($row["id"]);
414 
415  if ($a_user_id && !array_key_exists($a_user_id, $map)) {
416  continue;
417  }
418 
419  if ($map !== []) {
420  $user_team = null;
421  if ($a_user_id) {
422  $user_team_id = $map[$a_user_id];
423  $user_team = array();
424  foreach ($map as $user_id => $team_id) {
425  if ($user_id != $a_user_id &&
426  $user_team_id == $team_id) {
427  $user_team[] = $user_id;
428  }
429  }
430  }
431 
432  if (!$a_user_id ||
433  count($user_team)) {
434  $res[$row["id"]] = array(
435  "title" => $row["title"],
436  "teams" => count(array_flip($map)),
437  );
438 
439  if ($a_user_id) {
440  $res[$row["id"]]["user_team"] = $user_team;
441  }
442  }
443  }
444  }
445  }
446 
447  return ilArrayUtil::sortArray($res, "title", "asc", false, true);
448  }
$res
Definition: ltiservices.php:69
static getAssignmentDataOfExercise(int $a_exc_id)
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAssignmentTeamMap()

static ilExAssignmentTeam::getAssignmentTeamMap ( int  $a_ass_id)
static

Definition at line 273 of file class.ilExAssignmentTeam.php.

References $DIC, and $ilDB.

Referenced by ilExerciseManagementGUI\createTeamsFromGroupsObject(), ilExSubmission\downloadAllAssignmentFiles(), ilExAssignmentEditorGUI\generateTeams(), ilExSubmissionTeamGUI\getAdoptForm(), ilExAssignmentEditorGUI\initAssignmentForm(), ilAssignmentsPerParticipantTableGUI\parseData(), and ilParticipantsPerAssignmentTableGUI\parseData().

273  : array
274  {
275  global $DIC;
276 
277  $ilDB = $DIC->database();
278 
279  $map = array();
280 
281  $sql = "SELECT * FROM il_exc_team" .
282  " WHERE ass_id = " . $ilDB->quote($a_ass_id, "integer");
283  $set = $ilDB->query($sql);
284  while ($row = $ilDB->fetchAssoc($set)) {
285  $map[$row["user_id"]] = $row["id"];
286  }
287 
288  return $map;
289  }
global $DIC
Definition: feed.php:28
+ Here is the caller graph for this function:

◆ getGroupMembersMap()

static ilExAssignmentTeam::getGroupMembersMap ( int  $a_exc_ref_id)
static

Definition at line 544 of file class.ilExAssignmentTeam.php.

References $res, ilObject\_lookupTitle(), and ilArrayUtil\sortArray().

Referenced by ilExerciseManagementGUI\createTeamsFromGroupsObject(), and ilExerciseManagementGUI\initGroupForm().

544  : array
545  {
546  $res = array();
547 
548  foreach (self::getAdoptableGroups($a_exc_ref_id) as $grp_obj_id) {
549  $members_obj = new ilGroupParticipants($grp_obj_id);
550 
551  $res[$grp_obj_id] = array(
552  "title" => ilObject::_lookupTitle($grp_obj_id)
553  ,"members" => $members_obj->getMembers()
554  );
555  }
556 
557  return ilArrayUtil::sortArray($res, "title", "asc", false, true);
558  }
$res
Definition: ltiservices.php:69
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupTitle(int $obj_id)
static sortArray(array $array, string $a_array_sortby_key, string $a_array_sortorder="asc", bool $a_numeric=false, bool $a_keep_keys=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getId()

ilExAssignmentTeam::getId ( )

Definition at line 78 of file class.ilExAssignmentTeam.php.

References $id.

Referenced by adoptTeams().

78  : ?int
79  {
80  return $this->id;
81  }
+ Here is the caller graph for this function:

◆ getInstanceByUserId()

static ilExAssignmentTeam::getInstanceByUserId ( int  $a_assignment_id,
int  $a_user_id,
bool  $a_create_on_demand = false 
)
static

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

References $id.

Referenced by ilExSubmission\__construct(), ilExerciseManagementGUI\createTeamsFromGroupsObject(), ilExerciseManagementGUI\createTeamsObject(), ilExerciseManagementGUI\dissolveTeamsObject(), ilExcRepoObjAssignmentInfo\getInfo(), and ilExcAssMemberState\getInstanceByIds().

54  : self {
55  $id = self::getTeamId($a_assignment_id, $a_user_id, $a_create_on_demand);
56  return new self($id);
57  }
+ Here is the caller graph for this function:

◆ getInstancesFromMap()

static ilExAssignmentTeam::getInstancesFromMap ( int  $a_assignment_id)
static

Definition at line 59 of file class.ilExAssignmentTeam.php.

References $members, and $res.

Referenced by ilExerciseManagementGUI\initIndividualDeadlineForm(), and ilParticipantsPerAssignmentTableGUI\parseData().

59  : array
60  {
61  $teams = array();
62  foreach (self::getAssignmentTeamMap($a_assignment_id) as $user_id => $team_id) {
63  $teams[$team_id][] = $user_id;
64  }
65 
66  $res = array();
67  foreach ($teams as $team_id => $members) {
68  $team = new self();
69  $team->id = $team_id;
70  $team->assignment_id = $a_assignment_id;
71  $team->members = $members;
72  $res[$team_id] = $team;
73  }
74 
75  return $res;
76  }
$res
Definition: ltiservices.php:69
+ Here is the caller graph for this function:

◆ getLog()

ilExAssignmentTeam::getLog ( )

Definition at line 325 of file class.ilExAssignmentTeam.php.

References $db, $ilDB, $res, and cleanLog().

325  : array
326  {
327  $ilDB = $this->db;
328 
329  $this->cleanLog();
330 
331  $res = array();
332 
333  $sql = "SELECT * FROM il_exc_team_log" .
334  " WHERE team_id = " . $ilDB->quote($this->id, "integer") .
335  " ORDER BY tstamp DESC";
336  $set = $ilDB->query($sql);
337  while ($row = $ilDB->fetchAssoc($set)) {
338  $res[] = $row;
339  }
340  return $res;
341  }
$res
Definition: ltiservices.php:69
cleanLog()
Remove obsolete log entries.
+ Here is the call graph for this function:

◆ getMembers()

ilExAssignmentTeam::getMembers ( )

Definition at line 176 of file class.ilExAssignmentTeam.php.

References $members.

176  : array
177  {
178  return $this->members;
179  }

◆ getMembersOfAllTeams()

ilExAssignmentTeam::getMembersOfAllTeams ( )

Get members for all teams of assignment.

Returns
int[] user ids

Definition at line 185 of file class.ilExAssignmentTeam.php.

References $db, and $ilDB.

Referenced by addTeamMember().

185  : array
186  {
187  $ilDB = $this->db;
188 
189  $ids = array();
190 
191  $sql = "SELECT user_id" .
192  " FROM il_exc_team" .
193  " WHERE ass_id = " . $ilDB->quote($this->assignment_id, "integer");
194  $set = $ilDB->query($sql);
195  while ($row = $ilDB->fetchAssoc($set)) {
196  $ids[] = $row["user_id"];
197  }
198 
199  return $ids;
200  }
+ Here is the caller graph for this function:

◆ getTeamId()

static ilExAssignmentTeam::getTeamId ( int  $a_assignment_id,
int  $a_user_id,
bool  $a_create_on_demand = false 
)
static

Definition at line 109 of file class.ilExAssignmentTeam.php.

References $DIC, $id, $ilDB, ilObjUser\_lookupFullname(), and ilExcIndividualDeadline\getInstance().

Referenced by ilExAssignment\canParticipantReceiveFeedback(), ilExerciseManagementCollectFilesJob\collectAssignmentData(), ilExSubmissionTeamGUI\createAdoptedTeamObject(), ilExSubmissionTeamGUI\createSingleMemberTeamObject(), ilExSubmissionTeamGUI\createTeamObject(), ilExAssignment\getPersonalDeadline(), and ilExerciseSubmissionTableGUI\parseColumns().

113  : ?int {
114  global $DIC;
115 
116  $ilDB = $DIC->database();
117 
118  $sql = "SELECT id FROM il_exc_team" .
119  " WHERE ass_id = " . $ilDB->quote($a_assignment_id, "integer") .
120  " AND user_id = " . $ilDB->quote($a_user_id, "integer");
121  $set = $ilDB->query($sql);
122  $id = null;
123  if ($row = $ilDB->fetchAssoc($set)) {
124  $id = $row["id"];
125  }
126 
127  if (!$id && $a_create_on_demand) {
128  $id = $ilDB->nextId("il_exc_team");
129 
130  // get starting timestamp (relative deadlines) from individual deadline
131  $idl = ilExcIndividualDeadline::getInstance($a_assignment_id, $a_user_id);
132 
133  $fields = array("id" => array("integer", $id),
134  "ass_id" => array("integer", $a_assignment_id),
135  "user_id" => array("integer", $a_user_id));
136  $ilDB->insert("il_exc_team", $fields);
137 
138  // set starting timestamp for created team
139  if ($idl->getStartingTimestamp() > 0) {
140  $idl_team = ilExcIndividualDeadline::getInstance($a_assignment_id, $id, true);
141  $idl_team->setStartingTimestamp($idl->getStartingTimestamp());
142  $idl_team->save();
143  }
144 
145  self::writeTeamLog($id, self::TEAM_LOG_CREATE_TEAM);
146  self::writeTeamLog(
147  $id,
148  self::TEAM_LOG_ADD_MEMBER,
149  ilObjUser::_lookupFullname($a_user_id)
150  );
151  }
152 
153  return $id;
154  }
static _lookupFullname(int $a_user_id)
global $DIC
Definition: feed.php:28
static getInstance(int $a_ass_id, int $a_participant_id, bool $a_is_team=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ read()

ilExAssignmentTeam::read ( int  $a_id)
protected

Definition at line 88 of file class.ilExAssignmentTeam.php.

References $db, $ilDB, and setId().

Referenced by __construct(), addTeamMember(), and removeTeamMember().

88  : void
89  {
90  $ilDB = $this->db;
91 
92  // #18094
93  $this->members = array();
94 
95  $sql = "SELECT * FROM il_exc_team" .
96  " WHERE id = " . $ilDB->quote($a_id, "integer");
97  $set = $ilDB->query($sql);
98  if ($ilDB->numRows($set)) {
99  $this->setId($a_id);
100 
101  while ($row = $ilDB->fetchAssoc($set)) {
102  $this->assignment_id = $row["ass_id"];
103  $this->members[] = $row["user_id"];
104  }
105  }
106  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeTeamMember()

ilExAssignmentTeam::removeTeamMember ( int  $a_user_id,
?int  $a_exc_ref_id = null 
)
Exceptions
ilExcUnknownAssignmentTypeException

Definition at line 244 of file class.ilExAssignmentTeam.php.

References $db, $ilDB, ilObjUser\_lookupFullname(), read(), sendNotification(), and writeLog().

Referenced by ilExSubmission\deleteUser().

247  : void {
248  $ilDB = $this->db;
249 
250  if (!$this->id) {
251  return;
252  }
253 
254  $sql = "DELETE FROM il_exc_team" .
255  " WHERE ass_id = " . $ilDB->quote($this->assignment_id, "integer") .
256  " AND id = " . $ilDB->quote($this->id, "integer") .
257  " AND user_id = " . $ilDB->quote($a_user_id, "integer");
258  $ilDB->manipulate($sql);
259 
260  if ($a_exc_ref_id) {
261  $this->sendNotification($a_exc_ref_id, $a_user_id, "rmv");
262  }
263 
264  $this->writeLog(
265  self::TEAM_LOG_REMOVE_MEMBER,
266  ilObjUser::_lookupFullname($a_user_id)
267  );
268 
269  $this->read($this->id);
270  }
writeLog(string $a_action, string $a_details=null)
static _lookupFullname(int $a_user_id)
sendNotification(int $a_exc_ref_id, int $a_user_id, string $a_action)
Send notification about team status.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sendNotification()

ilExAssignmentTeam::sendNotification ( int  $a_exc_ref_id,
int  $a_user_id,
string  $a_action 
)

Send notification about team status.

Exceptions
ilExcUnknownAssignmentTypeException

Definition at line 372 of file class.ilExAssignmentTeam.php.

References $ilUser, and $user.

Referenced by addTeamMember(), and removeTeamMember().

376  : void {
378 
379  // no need to notify current user
380  if (!$a_exc_ref_id ||
381  $ilUser->getId() == $a_user_id) {
382  return;
383  }
384  $ass = new ilExAssignment($this->assignment_id);
385 
386  $ntf = new ilSystemNotification();
387  $ntf->setLangModules(array("exc"));
388  $ntf->setRefId($a_exc_ref_id);
389  $ntf->setChangedByUserId($ilUser->getId());
390  $ntf->setSubjectLangId('exc_team_notification_subject_' . $a_action);
391  $ntf->setIntroductionLangId('exc_team_notification_body_' . $a_action);
392  $ntf->addAdditionalInfo("exc_assignment", $ass->getTitle());
393  $ntf->setGotoLangId('exc_team_notification_link');
394  $ntf->setReasonLangId('exc_team_notification_reason');
395  $ntf->sendMailAndReturnRecipients(array($a_user_id));
396  }
Exercise assignment.
$ilUser
Definition: imgupload.php:34
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ setId()

ilExAssignmentTeam::setId ( ?int  $a_id)
private

Definition at line 83 of file class.ilExAssignmentTeam.php.

Referenced by createRandomTeams(), and read().

83  : void
84  {
85  $this->id = $a_id;
86  }
+ Here is the caller graph for this function:

◆ writeLog()

ilExAssignmentTeam::writeLog ( string  $a_action,
string  $a_details = null 
)

Definition at line 291 of file class.ilExAssignmentTeam.php.

Referenced by addTeamMember(), and removeTeamMember().

294  : void {
295  self::writeTeamLog($this->id, $a_action, $a_details);
296  }
+ Here is the caller graph for this function:

◆ writeTeamLog()

static ilExAssignmentTeam::writeTeamLog ( int  $a_team_id,
string  $a_action,
string  $a_details = null 
)
static

Add entry to team log.

Definition at line 301 of file class.ilExAssignmentTeam.php.

References $DIC, $ilDB, and $ilUser.

305  : void {
306  global $DIC;
307 
308  $ilDB = $DIC->database();
309  $ilUser = $DIC->user();
310  $id = $ilDB->nextId('il_exc_team_log');
311 
312  $fields = array(
313  "log_id" => array("integer", $id),
314  "team_id" => array("integer", $a_team_id),
315  "user_id" => array("integer", $ilUser->getId()),
316  "action" => array("integer", $a_action),
317  "details" => array("text", $a_details),
318  "tstamp" => array("integer", time())
319  );
320 
321  $ilDB->insert("il_exc_team_log", $fields);
322  }
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34

Field Documentation

◆ $assignment_id

int ilExAssignmentTeam::$assignment_id
protected

Definition at line 36 of file class.ilExAssignmentTeam.php.

◆ $db

ilDBInterface ilExAssignmentTeam::$db
protected

◆ $id

int ilExAssignmentTeam::$id = null
protected

Definition at line 35 of file class.ilExAssignmentTeam.php.

Referenced by createTeam(), getId(), getInstanceByUserId(), and getTeamId().

◆ $members

array ilExAssignmentTeam::$members = array()
protected

Definition at line 37 of file class.ilExAssignmentTeam.php.

Referenced by getInstancesFromMap(), and getMembers().

◆ $user

ilObjUser ilExAssignmentTeam::$user
protected

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

Referenced by sendNotification().

◆ TEAM_LOG_ADD_FILE

const ilExAssignmentTeam::TEAM_LOG_ADD_FILE = 4

◆ TEAM_LOG_ADD_MEMBER

const ilExAssignmentTeam::TEAM_LOG_ADD_MEMBER = 2

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

Referenced by ilExAssignmentTeamLogTableGUI\getItems().

◆ TEAM_LOG_CREATE_TEAM

const ilExAssignmentTeam::TEAM_LOG_CREATE_TEAM = 1

Definition at line 27 of file class.ilExAssignmentTeam.php.

Referenced by ilExAssignmentTeamLogTableGUI\getItems().

◆ TEAM_LOG_REMOVE_FILE

const ilExAssignmentTeam::TEAM_LOG_REMOVE_FILE = 5

◆ TEAM_LOG_REMOVE_MEMBER

const ilExAssignmentTeam::TEAM_LOG_REMOVE_MEMBER = 3

Definition at line 29 of file class.ilExAssignmentTeam.php.

Referenced by ilExAssignmentTeamLogTableGUI\getItems().


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