36 $this->db = $DIC->database();
37 $this->
user = $DIC->user();
45 $id = self::getTeamId($a_assignment_id, $a_user_id, $a_create_on_demand);
52 foreach (self::getAssignmentTeamMap($a_assignment_id) as $user_id => $team_id) {
53 $teams[$team_id][] = $user_id;
57 foreach ($teams as $team_id =>
$members) {
60 $team->assignment_id = $a_assignment_id;
62 $res[$team_id] = $team;
73 protected function read($a_id)
78 $this->members =
array();
80 $sql =
"SELECT * FROM il_exc_team" .
81 " WHERE id = " .
$ilDB->quote($a_id,
"integer");
82 $set =
$ilDB->query($sql);
83 if (
$ilDB->numRows($set)) {
87 $this->assignment_id =
$row[
"ass_id"];
88 $this->members[] =
$row[
"user_id"];
102 public static function getTeamId($a_assignment_id, $a_user_id, $a_create_on_demand =
false)
106 $ilDB = $DIC->database();
108 $sql =
"SELECT id FROM il_exc_team" .
109 " WHERE ass_id = " .
$ilDB->quote($a_assignment_id,
"integer") .
110 " AND user_id = " .
$ilDB->quote($a_user_id,
"integer");
111 $set =
$ilDB->query($sql);
115 if (!
$id && $a_create_on_demand) {
119 "ass_id" =>
array(
"integer", $a_assignment_id),
120 "user_id" =>
array(
"integer", $a_user_id));
121 $ilDB->insert(
"il_exc_team", $fields);
123 self::writeTeamLog(
$id, self::TEAM_LOG_CREATE_TEAM);
126 self::TEAM_LOG_ADD_MEMBER,
155 $sql =
"SELECT user_id" .
156 " FROM il_exc_team" .
157 " WHERE ass_id = " .
$ilDB->quote($this->assignment_id,
"integer");
158 $set =
$ilDB->query($sql);
160 $ids[] =
$row[
"user_id"];
182 $fields =
array(
"id" =>
array(
"integer", $this->
id),
183 "ass_id" =>
array(
"integer", $this->assignment_id),
184 "user_id" =>
array(
"integer", $a_user_id));
185 $ilDB->insert(
"il_exc_team", $fields);
192 self::TEAM_LOG_ADD_MEMBER,
196 $this->
read($this->
id);
218 $sql =
"DELETE FROM il_exc_team" .
219 " WHERE ass_id = " .
$ilDB->quote($this->assignment_id,
"integer") .
220 " AND id = " .
$ilDB->quote($this->
id,
"integer") .
221 " AND user_id = " .
$ilDB->quote($a_user_id,
"integer");
222 $ilDB->manipulate($sql);
229 self::TEAM_LOG_REMOVE_MEMBER,
233 $this->
read($this->
id);
246 $ilDB = $DIC->database();
250 $sql =
"SELECT * FROM il_exc_team" .
251 " WHERE ass_id = " .
$ilDB->quote($a_ass_id,
"integer");
252 $set =
$ilDB->query($sql);
254 $map[
$row[
"user_id"]] = $row[
"id"];
260 public function writeLog($a_action, $a_details = null)
262 self::writeTeamLog($this->
id, $a_action, $a_details);
272 public static function writeTeamLog($a_team_id, $a_action, $a_details = null)
276 $ilDB = $DIC->database();
278 $id =
$ilDB->nextId(
'il_exc_team_log');
282 "team_id" =>
array(
"integer", $a_team_id),
284 "action" =>
array(
"integer", $a_action),
285 "details" =>
array(
"text", $a_details),
289 $ilDB->insert(
"il_exc_team_log", $fields);
306 $sql =
"SELECT * FROM il_exc_team_log" .
307 " WHERE team_id = " .
$ilDB->quote($this->
id,
"integer") .
308 " ORDER BY tstamp DESC";
309 $set =
$ilDB->query($sql);
328 $set =
$ilDB->query(
"SELECT DISTINCT(id)" .
329 " FROM il_exc_team");
331 $teams[] =
$row[
"id"];
334 $set =
$ilDB->query(
"SELECT DISTINCT(team_id)" .
335 " FROM il_exc_team_log");
337 $team_id =
$row[
"team_id"];
338 if (!in_array($team_id, $teams)) {
339 $ilDB->manipulate(
"DELETE FROM il_exc_team_log" .
340 " WHERE team_id = " .
$ilDB->quote($team_id,
"integer"));
357 if (!$a_exc_ref_id ||
358 $ilUser->getId() == $a_user_id) {
364 include_once
"./Services/Notification/classes/class.ilSystemNotification.php";
366 $ntf->setLangModules(
array(
"exc"));
367 $ntf->setRefId($a_exc_ref_id);
368 $ntf->setChangedByUserId(
$ilUser->getId());
369 $ntf->setSubjectLangId(
'exc_team_notification_subject_' . $a_action);
370 $ntf->setIntroductionLangId(
'exc_team_notification_body_' . $a_action);
371 $ntf->addAdditionalInfo(
"exc_assignment", $ass->getTitle());
372 $ntf->setGotoLangId(
'exc_team_notification_link');
373 $ntf->setReasonLangId(
'exc_team_notification_reason');
374 $ntf->sendMail(
array($a_user_id));
384 if ($a_exclude_ass_id && $row[
"id"] == $a_exclude_ass_id) {
389 $map = self::getAssignmentTeamMap($row[
"id"]);
391 if ($a_user_id && !array_key_exists($a_user_id, $map)) {
398 $user_team_id = $map[$a_user_id];
399 $user_team =
array();
400 foreach ($map as $user_id => $team_id) {
401 if ($user_id != $a_user_id &&
402 $user_team_id == $team_id) {
403 $user_team[] = $user_id;
409 sizeof($user_team)) {
411 "title" => $row[
"title"],
412 "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) {
432 $teams[$team_id][] = $user_id;
434 if ($a_user_id && $user_id == $a_user_id) {
435 $old_team = $team_id;
442 self::getInstanceByUserId($a_target_ass_id, $a_user_id)->
getId()) {
447 $current_map = self::getAssignmentTeamMap($a_target_ass_id);
449 foreach ($teams as $team_id => $user_ids) {
450 if (!$old_team || $team_id == $old_team) {
453 foreach ($user_ids as $user_id) {
454 if (!array_key_exists($user_id, $current_map)) {
455 $missing[] = $user_id;
459 if (
sizeof($missing)) {
461 $first = array_shift($missing);
462 $new_team = self::getInstanceByUserId($a_target_ass_id, $first,
true);
466 $new_team->sendNotification($a_exc_ref_id, $first,
"add");
469 foreach ($missing as $user_id) {
470 $new_team->addTeamMember($user_id, $a_exc_ref_id);
485 $tree = $DIC->repositoryTree();
489 $parent_ref_id = $tree->getParentId($a_exc_ref_id);
490 if ($parent_ref_id) {
491 foreach ($tree->getChildsByType($parent_ref_id,
"grp") as $group) {
492 $res[] = $group[
"obj_id"];
503 include_once
"Modules/Group/classes/class.ilGroupParticipants.php";
504 foreach (self::getAdoptableGroups($a_exc_ref_id) as $grp_obj_id) {
509 ,
"members" => $members_obj->getMembers()
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.
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)
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
foreach($_POST as $key=> $value) $res
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