ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
TeamManager.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Exercise\Team;
22
27
29{
33
34 public function __construct(
37 protected \ilExcTutorTeamFeedbackFileStakeholder $feedback_stakeholder
38 ) {
39 $this->repo = $repo->team();
40 $this->domain = $domain;
41 $this->feedback_repo = $repo->tutorFeedbackFileTeam();
42 }
43
44 public function create(
45 int $ass_id,
46 int $first_user
47 ): int {
48 $id = $this->repo->create();
49 $this->repo->addUser($id, $ass_id, $first_user);
50 $this->domain->assignment()->tutorFeedbackFile($ass_id)->createCollection($first_user);
51 return $id;
52 }
53
54 public function getTeamForMember(int $ass_id, int $user_id): ?int
55 {
56 return $this->repo->getTeamForMember($ass_id, $user_id);
57 }
58
62 public function getMemberIds(int $team_id): array
63 {
64 return $this->repo->getMemberIds($team_id);
65 }
66
67 public function getTeamMemberIdsOrUserId(int $ass_id, int $user_id): array
68 {
69 $team_id = $this->getTeamForMember($ass_id, $user_id);
70 if (!is_null($team_id) && $team_id !== 0) {
71 return $this->getMemberIds(($team_id));
72 }
73 return [$user_id];
74 }
75
76
77 public function getStatusForTeam(int $team_id): string
78 {
79 $members = iterator_to_array($this->repo->getMembers($team_id));
80 $ass_id = $this->getAssignmentForTeam($team_id);
81 $mem_status = new \ilExAssignmentMemberStatus(
82 $ass_id,
83 current($members)->getUserId()
84 );
85 return $mem_status->getStatus();
86 }
87
88 public function getAssignmentForTeam(int $team_id): int
89 {
90 return $this->repo->getAssignmentForTeam($team_id);
91 }
92
93 protected function getTeam(int $team_id): \ilExAssignmentTeam
94 {
95 return new \ilExAssignmentTeam($team_id);
96 }
97
98 public function writeLog(
99 int $team_id,
100 int $action,
101 string $content
102 ): void {
103 $team = $this->getTeam($team_id);
104 $team->writeLog(
105 $action,
106 $content
107 );
108 }
109
110 public function deleteTeamsOfAssignment(int $ass_id): void
111 {
112 foreach ($this->repo->getTeamIdsOfAssignment($ass_id) as $team_id) {
113 $this->repo->deleteTeamLog($team_id);
114 $this->feedback_repo->deleteTeamCollection(
115 $team_id,
116 $this->feedback_stakeholder
117 );
118 $this->repo->deleteTeam($team_id);
119 }
120 }
121}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Internal factory for data objects.
Table exc_team_data: Team Table il_exc_team: Team participants (holds the sequence due to historic re...
getTeamForMember(int $ass_id, int $user_id)
Definition: TeamManager.php:54
__construct(InternalRepoService $repo, InternalDomainService $domain, protected \ilExcTutorTeamFeedbackFileStakeholder $feedback_stakeholder)
Definition: TeamManager.php:34
writeLog(int $team_id, int $action, string $content)
Definition: TeamManager.php:98
create(int $ass_id, int $first_user)
Definition: TeamManager.php:44
InternalDomainService $domain
Definition: TeamManager.php:32
getTeamMemberIdsOrUserId(int $ass_id, int $user_id)
Definition: TeamManager.php:67
TutorFeedbackFileTeamRepository $feedback_repo
Definition: TeamManager.php:30
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...