ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.InvitationsManager.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
26
32{
35 protected Settings\SettingsDBRepository $set_repo;
36
37 public function __construct(
38 InternalRepoService $repo_service
39 ) {
40 $this->repo = $repo_service->participants()->invitations();
41 $this->run_repo = $repo_service->execution()->run();
42 $this->set_repo = $repo_service->settings();
43 }
44
51 public function remove(
52 int $survey_id,
53 int $user_id
54 ): void {
55 $this->repo->remove($survey_id, $user_id);
56 }
57
58 public function removeAll(
59 int $survey_id
60 ): void {
61 $this->repo->removeAll($survey_id);
62 }
63
64
71 public function add(
72 int $survey_id,
73 int $user_id
74 ): void {
75 $this->repo->add($survey_id, $user_id);
76 }
77
83 public function getAllForSurvey(
84 int $survey_id
85 ): array {
86 return $this->repo->getAllForSurvey($survey_id);
87 }
88
93 public function getOpenInvitationsOfUser(
94 int $user_id
95 ): array {
96 // get all invitations
97 $survey_ids = $this->repo->getAllForUser($user_id);
98
99 // check if user started already
100 $finished_surveys = $this->run_repo->getFinishedSurveysOfUser($user_id);
101
102 $open_surveys = array_filter($survey_ids, static function (int $i) use ($finished_surveys) {
103 return !in_array($i, $finished_surveys, true);
104 });
105
106 // filter all surveys that have ended
107 $has_ended = $this->set_repo->hasEnded($open_surveys);
108 $open_surveys = array_filter($open_surveys, static function (int $i) use ($has_ended): bool {
109 return !($has_ended[$i] ?? false);
110 });
111
112 return $open_surveys;
113 }
114}
add(int $survey_id, int $user_id)
Add invitation.
__construct(InternalRepoService $repo_service)
getAllForSurvey(int $survey_id)
Get invitations for survey.
getOpenInvitationsOfUser(int $user_id)
Get all open invitations of a user.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...