ILIAS  release_8 Revision v8.24
class.StatusManager.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
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 public function canViewUserResults(): bool
105 {
106 if ($this->cantStartAgain() &&
107 $this->user_id !== ANONYMOUS_USER_ID &&
108 $this->survey->hasViewOwnResults()) {
109 return true;
110 }
111 return false;
112 }
113
118 public function canMailUserResults(): bool
119 {
120 if ($this->cantStartAgain() &&
121 $this->user_id !== ANONYMOUS_USER_ID &&
122 $this->survey->hasMailConfirmation()) {
123 return true;
124 }
125 return false;
126 }
127
131 public function mustEnterCode(string $code = ""): bool
132 {
133 if ($this->access->canStartSurvey()) {
134 // code is mandatory and not given yet
135 if (!$this->isAppraisee() &&
136 $code === "" &&
137 !$this->survey->isAccessibleWithoutCode()) {
138 return true;
139 }
140 }
141 return false;
142 }
143
144 public function isExternalRater(): bool
145 {
148 $anon_session = $this->repo_service->execution()->runSession();
149 if ($feature_config->usesAppraisees() &&
150 $anon_session->issetCode($survey->getId())) {
151 if (!$anon_session->isExternalRaterValidated($survey->getRefId())) {
152 $code = $anon_session->getCode($survey->getId());
153 $code_manager = $this->domain_service->code($survey, 0);
154 $feature_config = $this->domain_service->modeFeatureConfig($survey->getMode());
155 $access_manager = $this->domain_service->access($survey->getRefId(), 0);
156
157 if ($code_manager->exists($code)) {
158 $anonymous_id = $survey->getAnonymousIdByCode($code);
159 if ($anonymous_id) {
160 if (count($survey->getAppraiseesToRate(null, $anonymous_id))) {
161 $anon_session->setExternalRaterValidation($survey->getRefId(), true);
162 return true;
163 }
164 }
165 }
166 $anon_session->setExternalRaterValidation($survey->getRefId(), false);
167 return false;
168 }
169 return true;
170 }
171 return false;
172 }
173
174 public function isAppraisee(): bool
175 {
178 if ($feature_config->usesAppraisees() &&
179 $survey->isAppraisee($this->user_id)) {
180 return true;
181 }
182 return false;
183 }
184}
canMailUserResults()
Can the current user mail the confirmation.
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.
canViewUserResults()
Can the current user see the own results.
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
getAppraiseesToRate(?int $a_user_id, int $a_anonymous_id=null)
getAnonymousIdByCode(string $a_code)
isAppraisee(int $a_user_id)
const ANONYMOUS_USER_ID
Definition: constants.php:27
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...