ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilExAssignmentTeam Class Reference

Exercise assignment team. More...

+ Collaboration diagram for ilExAssignmentTeam:

Public Member Functions

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

Static Public Member Functions

static getInstanceByUserId ($a_assignment_id, $a_user_id, $a_create_on_demand=false)
 
static getInstancesFromMap ($a_assignment_id)
 
static getTeamId ($a_assignment_id, $a_user_id, $a_create_on_demand=false)
 Get team id for member id. More...
 
static getAssignmentTeamMap ($a_ass_id)
 Get team structure for assignment. More...
 
static writeTeamLog ($a_team_id, $a_action, $a_details=null)
 Add entry to team log. More...
 
static getAdoptableTeamAssignments ($a_exercise_id, $a_exclude_ass_id=null, $a_user_id=null)
 
static adoptTeams ($a_source_ass_id, $a_target_ass_id, $a_user_id=null, $a_exc_ref_id=null)
 
static getAdoptableGroups ($a_exc_ref_id)
 
static getGroupMembersMap ($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 ($a_id)
 
 cleanLog ()
 Remove obsolete log entries. More...
 

Protected Attributes

 $db
 
 $user
 
 $id
 
 $assignment_id
 
 $members = array()
 

Private Member Functions

 setId ($a_id)
 

Detailed Description

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

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

Constructor & Destructor Documentation

◆ __construct()

ilExAssignmentTeam::__construct (   $a_id = null)

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

References $DIC, read(), and user().

33  {
34  global $DIC;
35 
36  $this->db = $DIC->database();
37  $this->user = $DIC->user();
38  if ($a_id) {
39  $this->read($a_id);
40  }
41  }
user()
Definition: user.php:4
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

Member Function Documentation

◆ addTeamMember()

ilExAssignmentTeam::addTeamMember (   $a_user_id,
  $a_exc_ref_id = null 
)

Add new member to team.

Parameters
int$a_user_id
int$a_exc_ref_id

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

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

Referenced by createRandomTeams().

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

◆ adoptTeams()

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

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

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

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

458  {
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 (sizeof($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($a_ass_id, $a_participant_id, $a_is_team=false)
Get instance.
+ 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 353 of file class.ilExAssignmentTeam.php.

References $db, and $ilDB.

Referenced by getLog().

354  {
355  $ilDB = $this->db;
356 
357  // #18179
358 
359  $teams = array();
360  $set = $ilDB->query("SELECT DISTINCT(id)" .
361  " FROM il_exc_team");
362  while ($row = $ilDB->fetchAssoc($set)) {
363  $teams[] = $row["id"];
364  }
365 
366  $set = $ilDB->query("SELECT DISTINCT(team_id)" .
367  " FROM il_exc_team_log");
368  while ($row = $ilDB->fetchAssoc($set)) {
369  $team_id = $row["team_id"];
370  if (!in_array($team_id, $teams)) {
371  $ilDB->manipulate("DELETE FROM il_exc_team_log" .
372  " WHERE team_id = " . $ilDB->quote($team_id, "integer"));
373  }
374  }
375  }
global $ilDB
+ Here is the caller graph for this function:

◆ createRandomTeams()

ilExAssignmentTeam::createRandomTeams (   $a_exercise_id,
  $a_assignment_id,
  $a_number_teams,
  $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.
    Parameters
    $a_exercise_idinteger
    $a_assignment_idinteger
    $a_number_teamsinteger
    $a_min_participantsinteger
    Returns
    bool

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

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

571  {
572  //just in case...
573  if (count(self::getAssignmentTeamMap($a_assignment_id))) {
574  return false;
575  }
576  $exercise = new ilObjExercise($a_exercise_id, false);
577  $obj_exc_members = new ilExerciseMembers($exercise);
578  $members = $obj_exc_members->getMembers();
579  $total_exc_members = count($members);
580  $number_of_teams = $a_number_teams;
581  if (!$number_of_teams) {
582  if ($a_min_participants) {
583  $number_of_teams = round($total_exc_members / $a_min_participants);
584  } else {
585  $number_of_teams = random_int(1, $total_exc_members);
586  }
587  }
588  $members_per_team = round($total_exc_members / $number_of_teams);
589  shuffle($members);
590  for ($i = 0;$i < $number_of_teams;$i++) {
591  $members_counter = 0;
592  while (!empty($members) && $members_counter < $members_per_team) {
593  $member_id = array_pop($members);
594  if ($members_counter == 0) {
595  $team_id = $this->createTeam($a_assignment_id, $member_id);
596  $this->setId($team_id);
597  $this->assignment_id = $a_assignment_id;
598  } else {
599  $this->addTeamMember($member_id);
600  }
601  $members_counter++;
602  }
603  }
604  //get the new teams, remove duplicates.
605  $teams = array_unique(array_values(self::getAssignmentTeamMap($a_assignment_id)));
606  shuffle($teams);
607  while (!empty($members)) {
608  $member_id = array_pop($members);
609  $team_id = array_pop($teams);
610  $this->setId($team_id);
611  $this->addTeamMember($member_id);
612  }
613  return true;
614  }
Class ilExerciseMembers.
addTeamMember($a_user_id, $a_exc_ref_id=null)
Add new member to team.
Class ilObjExercise.
createTeam($a_assignment_id, $a_user_id)
$i
Definition: metadata.php:24
+ Here is the call graph for this function:

◆ createTeam()

ilExAssignmentTeam::createTeam (   $a_assignment_id,
  $a_user_id 
)

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

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

Referenced by createRandomTeams().

150  {
151  $ilDB = $this->db;
152  $id = $ilDB->nextId("il_exc_team");
153  $fields = array("id" => array("integer", $id),
154  "ass_id" => array("integer", $a_assignment_id),
155  "user_id" => array("integer", $a_user_id));
156  $ilDB->insert("il_exc_team", $fields);
157  self::writeTeamLog($id, self::TEAM_LOG_CREATE_TEAM);
158  self::writeTeamLog(
159  $id,
160  self::TEAM_LOG_ADD_MEMBER,
161  ilObjUser::_lookupFullname($a_user_id)
162  );
163  return $id;
164  }
static _lookupFullname($a_user_id)
Lookup Full Name.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAdoptableGroups()

static ilExAssignmentTeam::getAdoptableGroups (   $a_exc_ref_id)
static

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

References $DIC, and $res.

Referenced by ilExerciseManagementGUI\membersObject().

523  {
524  global $DIC;
525 
526  $tree = $DIC->repositoryTree();
527 
528  $res = array();
529 
530  $parent_ref_id = $tree->getParentId($a_exc_ref_id);
531  if ($parent_ref_id) {
532  foreach ($tree->getChildsByType($parent_ref_id, "grp") as $group) {
533  $res[] = $group["obj_id"];
534  }
535  }
536 
537  return $res;
538  }
foreach($_POST as $key=> $value) $res
$DIC
Definition: xapitoken.php:46
+ Here is the caller graph for this function:

◆ getAdoptableTeamAssignments()

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

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

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

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

410  {
411  $res = array();
412 
414  foreach ($data as $row) {
415  if ($a_exclude_ass_id && $row["id"] == $a_exclude_ass_id) {
416  continue;
417  }
418 
419  if ($row["type"] == ilExAssignment::TYPE_UPLOAD_TEAM) {
420  $map = self::getAssignmentTeamMap($row["id"]);
421 
422  if ($a_user_id && !array_key_exists($a_user_id, $map)) {
423  continue;
424  }
425 
426  if (sizeof($map)) {
427  $user_team = null;
428  if ($a_user_id) {
429  $user_team_id = $map[$a_user_id];
430  $user_team = array();
431  foreach ($map as $user_id => $team_id) {
432  if ($user_id != $a_user_id &&
433  $user_team_id == $team_id) {
434  $user_team[] = $user_id;
435  }
436  }
437  }
438 
439  if (!$a_user_id ||
440  sizeof($user_team)) {
441  $res[$row["id"]] = array(
442  "title" => $row["title"],
443  "teams" => sizeof(array_flip($map)),
444  );
445 
446  if ($a_user_id) {
447  $res[$row["id"]]["user_team"] = $user_team;
448  }
449  }
450  }
451  }
452  }
453 
454  return ilUtil::sortArray($res, "title", "asc", false, true);
455  }
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static getAssignmentDataOfExercise($a_exc_id)
Get assignments data of an exercise in an array.
$data
Definition: storeScorm.php:23
foreach($_POST as $key=> $value) $res
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAssignmentTeamMap()

static ilExAssignmentTeam::getAssignmentTeamMap (   $a_ass_id)
static

Get team structure for assignment.

Parameters
int$a_ass_id
Returns
array

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

References $DIC, and $ilDB.

Referenced by ilExSubmissionTeamGUI\createTeamObject(), ilExerciseManagementGUI\createTeamsFromGroupsObject(), ilExSubmission\downloadAllAssignmentFiles(), ilExAssignmentEditorGUI\generateTeams(), ilExAssignmentEditorGUI\initAssignmentForm(), ilExParticipantTableGUI\initMode(), and ilExerciseMemberTableGUI\parseData().

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

◆ getGroupMembersMap()

static ilExAssignmentTeam::getGroupMembersMap (   $a_exc_ref_id)
static

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

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

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

541  {
542  $res = array();
543 
544  foreach (self::getAdoptableGroups($a_exc_ref_id) as $grp_obj_id) {
545  $members_obj = new ilGroupParticipants($grp_obj_id);
546 
547  $res[$grp_obj_id] = array(
548  "title" => ilObject::_lookupTitle($grp_obj_id)
549  ,"members" => $members_obj->getMembers()
550  );
551  }
552 
553  return ilUtil::sortArray($res, "title", "asc", false, true);
554  }
static sortArray( $array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
static _lookupTitle($a_id)
lookup object title
foreach($_POST as $key=> $value) $res
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getId()

ilExAssignmentTeam::getId ( )

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

References $id.

Referenced by adoptTeams().

69  {
70  return $this->id;
71  }
+ Here is the caller graph for this function:

◆ getInstanceByUserId()

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

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

References $id.

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

44  {
45  $id = self::getTeamId($a_assignment_id, $a_user_id, $a_create_on_demand);
46  return new self($id);
47  }
+ Here is the caller graph for this function:

◆ getInstancesFromMap()

static ilExAssignmentTeam::getInstancesFromMap (   $a_assignment_id)
static

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

References $members, and $res.

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

50  {
51  $teams = array();
52  foreach (self::getAssignmentTeamMap($a_assignment_id) as $user_id => $team_id) {
53  $teams[$team_id][] = $user_id;
54  }
55 
56  $res = array();
57  foreach ($teams as $team_id => $members) {
58  $team = new self();
59  $team->id = $team_id;
60  $team->assignment_id = $a_assignment_id;
61  $team->members = $members;
62  $res[$team_id] = $team;
63  }
64 
65  return $res;
66  }
foreach($_POST as $key=> $value) $res
+ Here is the caller graph for this function:

◆ getLog()

ilExAssignmentTeam::getLog ( )

Get all log entries for team.

Parameters
int$a_team_id
Returns
array

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

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

331  {
332  $ilDB = $this->db;
333 
334  $this->cleanLog();
335 
336  $res = array();
337 
338  $sql = "SELECT * FROM il_exc_team_log" .
339  " WHERE team_id = " . $ilDB->quote($this->id, "integer") .
340  " ORDER BY tstamp DESC";
341  $set = $ilDB->query($sql);
342  while ($row = $ilDB->fetchAssoc($set)) {
343  $res[] = $row;
344  }
345  return $res;
346  }
foreach($_POST as $key=> $value) $res
cleanLog()
Remove obsolete log entries.
global $ilDB
+ Here is the call graph for this function:

◆ getMembers()

ilExAssignmentTeam::getMembers ( )

Get members of assignment team.

Returns
array

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

References $members.

172  {
173  return $this->members;
174  }

◆ getMembersOfAllTeams()

ilExAssignmentTeam::getMembersOfAllTeams ( )

Get members for all teams of assignment.

Returns
array

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

References $db, and $ilDB.

Referenced by addTeamMember().

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

◆ getTeamId()

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

Get team id for member id.

team will be created if no team yet

Parameters
int$a_user_id
bool$a_create_on_demand
Returns
int

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

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

Referenced by ilExSubmissionTeamGUI\createAdoptedTeamObject(), ilExSubmissionTeamGUI\createSingleMemberTeamObject(), ilExSubmissionTeamGUI\createTeamObject(), ilExAssignment\getPersonalDeadline(), and ilExerciseSubmissionTableGUI\parseRow().

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

◆ read()

ilExAssignmentTeam::read (   $a_id)
protected

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

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

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

79  {
80  $ilDB = $this->db;
81 
82  // #18094
83  $this->members = array();
84 
85  $sql = "SELECT * FROM il_exc_team" .
86  " WHERE id = " . $ilDB->quote($a_id, "integer");
87  $set = $ilDB->query($sql);
88  if ($ilDB->numRows($set)) {
89  $this->setId($a_id);
90 
91  while ($row = $ilDB->fetchAssoc($set)) {
92  $this->assignment_id = $row["ass_id"];
93  $this->members[] = $row["user_id"];
94  }
95  }
96  }
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeTeamMember()

ilExAssignmentTeam::removeTeamMember (   $a_user_id,
  $a_exc_ref_id = null 
)

Remove member from team.

Parameters
int$a_user_id
int$a_exc_ref_id

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

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

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

◆ sendNotification()

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

Send notification about team status.

Parameters
int$a_exc_ref_id
int$a_user_id
string$a_action

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

References $ilUser, and $user.

Referenced by addTeamMember(), and removeTeamMember().

385  {
387 
388  // no need to notify current user
389  if (!$a_exc_ref_id ||
390  $ilUser->getId() == $a_user_id) {
391  return;
392  }
393 
394  $ass = new ilExAssignment($this->assignment_id);
395 
396  $ntf = new ilSystemNotification();
397  $ntf->setLangModules(array("exc"));
398  $ntf->setRefId($a_exc_ref_id);
399  $ntf->setChangedByUserId($ilUser->getId());
400  $ntf->setSubjectLangId('exc_team_notification_subject_' . $a_action);
401  $ntf->setIntroductionLangId('exc_team_notification_body_' . $a_action);
402  $ntf->addAdditionalInfo("exc_assignment", $ass->getTitle());
403  $ntf->setGotoLangId('exc_team_notification_link');
404  $ntf->setReasonLangId('exc_team_notification_reason');
405  $ntf->sendMail(array($a_user_id));
406  }
Exercise assignment.
$ilUser
Definition: imgupload.php:18
Wrapper classes for system notifications.
+ Here is the caller graph for this function:

◆ setId()

ilExAssignmentTeam::setId (   $a_id)
private

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

Referenced by createRandomTeams(), and read().

74  {
75  $this->id = $a_id;
76  }
+ Here is the caller graph for this function:

◆ writeLog()

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

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

Referenced by addTeamMember(), and removeTeamMember().

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

◆ writeTeamLog()

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

Add entry to team log.

Parameters
int$a_team_id
int$a_action
string$a_details

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

References $DIC, $id, $ilDB, and $ilUser.

305  {
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  }
$ilUser
Definition: imgupload.php:18
global $ilDB
$DIC
Definition: xapitoken.php:46

Field Documentation

◆ $assignment_id

ilExAssignmentTeam::$assignment_id
protected

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

◆ $db

ilExAssignmentTeam::$db
protected

◆ $id

ilExAssignmentTeam::$id
protected

◆ $members

ilExAssignmentTeam::$members = array()
protected

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

Referenced by createRandomTeams(), getInstancesFromMap(), and getMembers().

◆ $user

ilExAssignmentTeam::$user
protected

Definition at line 20 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 27 of file class.ilExAssignmentTeam.php.

Referenced by ilExAssignmentTeamLogTableGUI\getItems().

◆ TEAM_LOG_CREATE_TEAM

const ilExAssignmentTeam::TEAM_LOG_CREATE_TEAM = 1

Definition at line 26 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 28 of file class.ilExAssignmentTeam.php.

Referenced by ilExAssignmentTeamLogTableGUI\getItems().


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