32 $id = self::getTeamId($a_assignment_id, $a_user_id, $a_create_on_demand);
39 foreach(self::getAssignmentTeamMap($a_assignment_id) as $user_id => $team_id)
41 $teams[$team_id][] = $user_id;
45 foreach($teams as $team_id =>
$members)
49 $team->assignment_id = $a_assignment_id;
51 $res[$team_id] = $team;
62 protected function read($a_id)
67 $this->members =
array();
69 $sql =
"SELECT * FROM il_exc_team".
70 " WHERE id = ".$ilDB->quote($a_id,
"integer");
71 $set = $ilDB->query($sql);
72 if($ilDB->numRows($set))
76 while(
$row = $ilDB->fetchAssoc($set))
78 $this->assignment_id =
$row[
"ass_id"];
79 $this->members[] =
$row[
"user_id"];
93 public static function getTeamId($a_assignment_id, $a_user_id, $a_create_on_demand =
false)
97 $sql =
"SELECT id FROM il_exc_team".
98 " WHERE ass_id = ".$ilDB->quote($a_assignment_id,
"integer").
99 " AND user_id = ".$ilDB->quote($a_user_id,
"integer");
100 $set = $ilDB->query($sql);
101 $row = $ilDB->fetchAssoc($set);
104 if(!
$id && $a_create_on_demand)
106 $id = $ilDB->nextId(
"il_exc_team");
109 "ass_id" =>
array(
"integer", $a_assignment_id),
110 "user_id" =>
array(
"integer", $a_user_id));
111 $ilDB->insert(
"il_exc_team", $fields);
113 self::writeTeamLog(
$id, self::TEAM_LOG_CREATE_TEAM);
114 self::writeTeamLog(
$id, self::TEAM_LOG_ADD_MEMBER,
142 $sql =
"SELECT user_id".
144 " WHERE ass_id = ".$ilDB->quote($this->assignment_id,
"integer");
145 $set = $ilDB->query($sql);
146 while(
$row = $ilDB->fetchAssoc($set))
148 $ids[] =
$row[
"user_id"];
172 $fields =
array(
"id" =>
array(
"integer", $this->
id),
173 "ass_id" =>
array(
"integer", $this->assignment_id),
174 "user_id" =>
array(
"integer", $a_user_id));
175 $ilDB->insert(
"il_exc_team", $fields);
182 $this->
writeLog(self::TEAM_LOG_ADD_MEMBER,
185 $this->
read($this->
id);
208 $sql =
"DELETE FROM il_exc_team".
209 " WHERE ass_id = ".$ilDB->quote($this->assignment_id,
"integer").
210 " AND id = ".$ilDB->quote($this->
id,
"integer").
211 " AND user_id = ".$ilDB->quote($a_user_id,
"integer");
212 $ilDB->manipulate($sql);
219 $this->
writeLog(self::TEAM_LOG_REMOVE_MEMBER,
222 $this->
read($this->
id);
237 $sql =
"SELECT * FROM il_exc_team".
238 " WHERE ass_id = ".$ilDB->quote($a_ass_id,
"integer");
239 $set = $ilDB->query($sql);
240 while(
$row = $ilDB->fetchAssoc($set))
242 $map[
$row[
"user_id"]] = $row[
"id"];
248 public function writeLog($a_action, $a_details = null)
250 self::writeTeamLog($this->
id, $a_action, $a_details);
260 public static function writeTeamLog($a_team_id, $a_action, $a_details = null)
263 $id = $ilDB->nextId(
'il_exc_team_log');
267 "team_id" =>
array(
"integer", $a_team_id),
268 "user_id" =>
array(
"integer", $ilUser->getId()),
269 "action" =>
array(
"integer", $a_action),
270 "details" =>
array(
"text", $a_details),
274 $ilDB->insert(
"il_exc_team_log", $fields);
291 $sql =
"SELECT * FROM il_exc_team_log".
292 " WHERE team_id = ".$ilDB->quote($this->
id,
"integer").
293 " ORDER BY tstamp DESC";
294 $set = $ilDB->query($sql);
295 while(
$row = $ilDB->fetchAssoc($set))
314 $set = $ilDB->query(
"SELECT DISTINCT(id)".
315 " FROM il_exc_team");
316 while(
$row = $ilDB->fetchAssoc($set))
318 $teams[] =
$row[
"id"];
321 $set = $ilDB->query(
"SELECT DISTINCT(team_id)".
322 " FROM il_exc_team_log");
323 while(
$row = $ilDB->fetchAssoc($set))
325 $team_id =
$row[
"team_id"];
326 if(!in_array($team_id, $teams))
328 $ilDB->manipulate(
"DELETE FROM il_exc_team_log".
329 " WHERE team_id = ".$ilDB->quote($team_id,
"integer"));
347 $ilUser->getId() == $a_user_id)
354 include_once
"./Services/Notification/classes/class.ilSystemNotification.php";
356 $ntf->setLangModules(
array(
"exc"));
357 $ntf->setRefId($a_exc_ref_id);
358 $ntf->setChangedByUserId($ilUser->getId());
359 $ntf->setSubjectLangId(
'exc_team_notification_subject_'.$a_action);
360 $ntf->setIntroductionLangId(
'exc_team_notification_body_'.$a_action);
361 $ntf->addAdditionalInfo(
"exc_assignment", $ass->getTitle());
362 $ntf->setGotoLangId(
'exc_team_notification_link');
363 $ntf->setReasonLangId(
'exc_team_notification_reason');
364 $ntf->sendMail(
array($a_user_id));
375 if($a_exclude_ass_id && $row[
"id"] == $a_exclude_ass_id)
382 $map = self::getAssignmentTeamMap($row[
"id"]);
384 if($a_user_id && !array_key_exists($a_user_id, $map))
394 $user_team_id = $map[$a_user_id];
395 $user_team =
array();
396 foreach($map as $user_id => $team_id)
398 if($user_id != $a_user_id &&
399 $user_team_id == $team_id)
401 $user_team[] = $user_id;
410 "title" => $row[
"title"],
411 "teams" =>
sizeof(array_flip($map)),
416 $res[$row[
"id"]][
"user_team"] = $user_team;
426 public static function adoptTeams($a_source_ass_id, $a_target_ass_id, $a_user_id = null, $a_exc_ref_id = null)
431 foreach(self::getAssignmentTeamMap($a_source_ass_id) as $user_id => $team_id)
433 $teams[$team_id][] = $user_id;
435 if($a_user_id && $user_id == $a_user_id)
437 $old_team = $team_id;
445 self::getInstanceByUserId($a_target_ass_id, $a_user_id)->
getId())
451 $current_map = self::getAssignmentTeamMap($a_target_ass_id);
453 foreach($teams as $team_id => $user_ids)
455 if(!$old_team || $team_id == $old_team)
459 foreach($user_ids as $user_id)
461 if(!array_key_exists($user_id, $current_map))
463 $missing[] = $user_id;
470 $first = array_shift($missing);
471 $new_team = self::getInstanceByUserId($a_target_ass_id, $first,
true);
476 $new_team->sendNotification($a_exc_ref_id, $first,
"add");
479 foreach($missing as $user_id)
481 $new_team->addTeamMember($user_id, $a_exc_ref_id);
498 $parent_ref_id = $tree->getParentId($a_exc_ref_id);
501 foreach($tree->getChildsByType($parent_ref_id,
"grp") as $group)
503 $res[] = $group[
"obj_id"];
514 include_once
"Modules/Group/classes/class.ilGroupParticipants.php";
515 foreach(self::getAdoptableGroups($a_exc_ref_id) as $grp_obj_id)
521 ,
"members" => $members_obj->getMembers()
static getAssignmentDataOfExercise($a_exc_id)
Get assignments data of an exercise in an array.
const TEAM_LOG_REMOVE_MEMBER
static getAdoptableGroups($a_exc_ref_id)
static getGroupMembersMap($a_exc_ref_id)
static getAssignmentTeamMap($a_ass_id)
Get team structure for assignment.
static getTeamId($a_assignment_id, $a_user_id, $a_create_on_demand=false)
Get team id for member id.
static getInstancesFromMap($a_assignment_id)
static _lookupFullname($a_user_id)
Lookup Full Name.
addTeamMember($a_user_id, $a_exc_ref_id=null)
Add new member to team.
getLog()
Get all log entries for team.
Exercise assignment team.
static _lookupTitle($a_id)
lookup object title
static adoptTeams($a_source_ass_id, $a_target_ass_id, $a_user_id=null, $a_exc_ref_id=null)
static sortArray($array, $a_array_sortby, $a_array_sortorder=0, $a_numeric=false, $a_keep_keys=false)
sortArray
getMembers()
Get members of assignment team.
static getAdoptableTeamAssignments($a_exercise_id, $a_exclude_ass_id=null, $a_user_id=null)
const TEAM_LOG_REMOVE_FILE
sendNotification($a_exc_ref_id, $a_user_id, $a_action)
Send notification about team status.
static getInstanceByUserId($a_assignment_id, $a_user_id, $a_create_on_demand=false)
removeTeamMember($a_user_id, $a_exc_ref_id=null)
Remove member from team.
cleanLog()
Remove obsolete log entries.
getMembersOfAllTeams()
Get members for all teams of assignment.
Create styles array
The data for the language used.
writeLog($a_action, $a_details=null)
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
Wrapper classes for system notifications.
const TEAM_LOG_CREATE_TEAM
static writeTeamLog($a_team_id, $a_action, $a_details=null)
Add entry to team log.
const TEAM_LOG_ADD_MEMBER