ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.StatusManager.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25
32{
33 protected \ILIAS\Survey\Execution\RunManager $run_manager;
35 protected \ilObjSurvey $survey;
36 protected int $user_id;
37 protected \ILIAS\Survey\Access\AccessManager $access;
38 protected \ILIAS\Survey\Mode\FeatureConfig $feature_config;
40
41 public function __construct(
45 int $user_id
46 ) {
47 $this->domain_service = $domain_service;
48 $this->repo_service = $repo_service;
49 $this->access = $this->domain_service->access($survey->getRefId(), $user_id);
50 //$this->anonymous_session_repo = $this->
51 $this->feature_config = $this->domain_service->modeFeatureConfig($survey->getMode());
52 $this->survey = $survey;
53 $this->user_id = $user_id;
54 $this->run_manager = $domain_service->execution()->run($survey, $user_id);
55 }
56
60 public function canAddItselfAsAppraisee(): bool
61 {
66
67 if ($access->canRead() &&
68 $feature_config->usesAppraisees() &&
72 return true;
73 }
74 return false;
75 }
76
82 public function cantStartAgain(): bool
83 {
85
86 if ($feature_config->usesAppraisees()) {
87 return false;
88 }
89
90 if ($this->run_manager->hasStarted() && $this->run_manager->hasFinished()) {
91 // check for
92 // !(!$this->object->isAccessibleWithoutCode() && !$anonymous_code && $ilUser->getId() == ANONYMOUS_USER_ID)
93 // removed
94 // not code accessible an no anonymous code and anonymous user (see #0020333)
95 return true;
96 }
97 return false;
98 }
99
104 /*
105 public function canViewUserResults(): bool
106 {
107 if ($this->cantStartAgain() &&
108 $this->user_id !== ANONYMOUS_USER_ID &&
109 $this->survey->hasViewOwnResults()) {
110 return true;
111 }
112 return false;
113 }*/
114
119 public function canMailUserResults(): bool
120 {
121 if ($this->cantStartAgain() &&
122 $this->user_id !== ANONYMOUS_USER_ID &&
123 $this->survey->hasMailConfirmation()) {
124 return true;
125 }
126 return false;
127 }
128
132 public function mustEnterCode(string $code = ""): bool
133 {
134 if ($this->access->canStartSurvey()) {
135 // code is mandatory and not given yet
136 if (!$this->isAppraisee() &&
137 $code === "" &&
138 !$this->survey->isAccessibleWithoutCode()) {
139 return true;
140 }
141 }
142 return false;
143 }
144
145 public function isExternalRater(): bool
146 {
149 $anon_session = $this->repo_service->execution()->runSession();
150 if ($feature_config->usesAppraisees() &&
151 $anon_session->issetCode($survey->getId())) {
152 if (!$anon_session->isExternalRaterValidated($survey->getRefId())) {
153 $code = $anon_session->getCode($survey->getId());
154 $code_manager = $this->domain_service->code($survey, 0);
155 $feature_config = $this->domain_service->modeFeatureConfig($survey->getMode());
156 $access_manager = $this->domain_service->access($survey->getRefId(), 0);
157
158 if ($code_manager->exists($code)) {
159 $anonymous_id = $survey->getAnonymousIdByCode($code);
160 if ($anonymous_id) {
161 if (count($survey->getAppraiseesToRate(null, $anonymous_id))) {
162 $anon_session->setExternalRaterValidation($survey->getRefId(), true);
163 return true;
164 }
165 }
166 }
167 $anon_session->setExternalRaterValidation($survey->getRefId(), false);
168 return false;
169 }
170 return true;
171 }
172 return false;
173 }
174
175 public function isAppraisee(): bool
176 {
179 if ($feature_config->usesAppraisees() &&
180 $survey->isAppraisee($this->user_id)) {
181 return true;
182 }
183 return false;
184 }
185}
canMailUserResults()
Can the current user see the own results.
ILIAS Survey Mode FeatureConfig $feature_config
cantStartAgain()
This will return true, if a survey without appraisees is finished Note: Code will be gathered from se...
canAddItselfAsAppraisee()
Checks if a user can add himself as an appraisee.
ILIAS Survey Access AccessManager $access
mustEnterCode(string $code="")
Check if user must enter code to start (and currently is able to start)
__construct(InternalDomainService $domain_service, InternalRepoService $repo_service, \ilObjSurvey $survey, int $user_id)
ILIAS Survey Execution RunManager $run_manager
getAnonymousIdByCode(string $a_code)
isAppraisee(int $a_user_id)
getAppraiseesToRate(?int $a_user_id, ?int $a_anonymous_id=null)
const ANONYMOUS_USER_ID
Definition: constants.php:27