ILIAS  release_8 Revision v8.24
class.ilTestAccess.php
Go to the documentation of this file.
1<?php
2
28{
32 protected $access;
33
37 protected $refId;
38
42 protected $testId;
43
48 public function __construct($refId, $testId)
49 {
50 global $DIC; /* @var ILIAS\DI\Container $DIC */
51 $this->setAccess($DIC->access());
52
53 $this->setRefId($refId);
54 $this->setTestId($testId);
55 }
56
60 public function getAccess(): ilAccessHandler
61 {
62 return $this->access;
63 }
64
68 public function setAccess($access)
69 {
70 $this->access = $access;
71 }
72
76 public function getRefId(): int
77 {
78 return $this->refId;
79 }
80
84 public function setRefId($refId)
85 {
86 $this->refId = $refId;
87 }
88
92 public function getTestId(): int
93 {
94 return $this->testId;
95 }
96
100 public function setTestId($testId)
101 {
102 $this->testId = $testId;
103 }
104
108 public function checkCorrectionsAccess(): bool
109 {
110 return $this->getAccess()->checkAccess('write', '', $this->getRefId());
111 }
112
116 public function checkScoreParticipantsAccess(): bool
117 {
118 if ($this->getAccess()->checkAccess('write', '', $this->getRefId())) {
119 return true;
120 }
121
122 if ($this->getAccess()->checkPositionAccess(ilOrgUnitOperation::OP_SCORE_PARTICIPANTS, $this->getRefId())) {
123 return true;
124 }
125
126 return false;
127 }
128
132 public function checkManageParticipantsAccess(): bool
133 {
134 if ($this->getAccess()->checkAccess('write', '', $this->getRefId())) {
135 return true;
136 }
137
138 if ($this->getAccess()->checkPositionAccess(ilOrgUnitOperation::OP_MANAGE_PARTICIPANTS, $this->getRefId())) {
139 return true;
140 }
141
142 return false;
143 }
144
148 public function checkParticipantsResultsAccess(): bool
149 {
150 if ($this->getAccess()->checkAccess('write', '', $this->getRefId())) {
151 return true;
152 }
153
154 if ($this->getAccess()->checkAccess('tst_results', '', $this->getRefId())) {
155 return true;
156 }
157
158 if ($this->getAccess()->checkPositionAccess(ilOrgUnitOperation::OP_MANAGE_PARTICIPANTS, $this->getRefId())) {
159 return true;
160 }
161
162 if ($this->getAccess()->checkPositionAccess(ilOrgUnitOperation::OP_ACCESS_RESULTS, $this->getRefId())) {
163 return true;
164 }
165
166 return false;
167 }
168
172 public function checkStatisticsAccess(): bool
173 {
174 if ($this->getAccess()->checkAccess('tst_statistics', '', $this->getRefId())) {
175 return true;
176 }
177
178 if ($this->getAccess()->checkPositionAccess(ilOrgUnitOperation::OP_ACCESS_RESULTS, $this->getRefId())) {
179 return true;
180 }
181
182 return false;
183 }
184
190 protected function checkAccessForActiveId($accessFilter, $activeId): bool
191 {
192 global $DIC; /* @var ILIAS\DI\Container $DIC */
193
194 $participantData = new ilTestParticipantData($DIC->database(), $DIC->language());
195 $participantData->setActiveIdsFilter(array($activeId));
196 $participantData->setParticipantAccessFilter($accessFilter);
197 $participantData->load($this->getTestId());
198
199 return in_array($activeId, $participantData->getActiveIds());
200 }
201
206 public function checkResultsAccessForActiveId($activeId): bool
207 {
209 return $this->checkAccessForActiveId($accessFilter, $activeId);
210 }
211
216 public function checkScoreParticipantsAccessForActiveId($activeId): bool
217 {
219 return $this->checkAccessForActiveId($accessFilter, $activeId);
220 }
221
226 public function checkStatisticsAccessForActiveId($activeId): bool
227 {
229 return $this->checkAccessForActiveId($accessFilter, $activeId);
230 }
231}
checkScoreParticipantsAccessForActiveId($activeId)
checkResultsAccessForActiveId($activeId)
__construct($refId, $testId)
checkAccessForActiveId($accessFilter, $activeId)
checkStatisticsAccessForActiveId($activeId)
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...