ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.StatusManager.php
Go to the documentation of this file.
1 <?php
2 
19 declare(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(
42  InternalDomainService $domain_service,
43  InternalRepoService $repo_service,
44  \ilObjSurvey $survey,
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  {
62  $survey = $this->survey;
63  $user_id = $this->user_id;
64  $access = $this->access;
65  $feature_config = $this->feature_config;
66 
67  if ($access->canRead() &&
68  $feature_config->usesAppraisees() &&
69  $survey->get360SelfAppraisee() &&
70  !$survey->isAppraisee($user_id) &&
71  $user_id !== ANONYMOUS_USER_ID) {
72  return true;
73  }
74  return false;
75  }
76 
82  public function cantStartAgain(): bool
83  {
84  $feature_config = $this->feature_config;
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  {
147  $survey = $this->survey;
148  $feature_config = $this->feature_config;
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  {
177  $survey = $this->survey;
178  $feature_config = $this->feature_config;
179  if ($feature_config->usesAppraisees() &&
180  $survey->isAppraisee($this->user_id)) {
181  return true;
182  }
183  return false;
184  }
185 }
mustEnterCode(string $code="")
Check if user must enter code to start (and currently is able to start)
const ANONYMOUS_USER_ID
Definition: constants.php:27
ILIAS Survey Execution RunManager $run_manager
canMailUserResults()
Can the current user see the own results.
ILIAS Survey Mode FeatureConfig $feature_config
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
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.
__construct(InternalDomainService $domain_service, InternalRepoService $repo_service, \ilObjSurvey $survey, int $user_id)
ILIAS Survey Access AccessManager $access