ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilTestAccess.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
6 
16 {
20  protected $access;
21 
25  protected $refId;
26 
30  protected $testId;
31 
36  public function __construct($refId, $testId)
37  {
38  global $DIC; /* @var ILIAS\DI\Container $DIC */
39  $this->setAccess($DIC->access());
40 
41  $this->setRefId($refId);
42  $this->setTestId($testId);
43  }
44 
48  public function getAccess()
49  {
50  return $this->access;
51  }
52 
56  public function setAccess($access)
57  {
58  $this->access = $access;
59  }
60 
64  public function getRefId()
65  {
66  return $this->refId;
67  }
68 
72  public function setRefId($refId)
73  {
74  $this->refId = $refId;
75  }
76 
80  public function getTestId()
81  {
82  return $this->testId;
83  }
84 
88  public function setTestId($testId)
89  {
90  $this->testId = $testId;
91  }
92 
96  public function checkCorrectionsAccess()
97  {
98  return $this->getAccess()->checkAccess('write', '', $this->getRefId());
99  }
100 
105  {
106  if ($this->getAccess()->checkAccess('write', '', $this->getRefId())) {
107  return true;
108  }
109 
110  if ($this->getAccess()->checkPositionAccess(ilOrgUnitOperation::OP_SCORE_PARTICIPANTS, $this->getRefId())) {
111  return true;
112  }
113 
114  return false;
115  }
116 
121  {
122  if ($this->getAccess()->checkAccess('write', '', $this->getRefId())) {
123  return true;
124  }
125 
126  if ($this->getAccess()->checkPositionAccess(ilOrgUnitOperation::OP_MANAGE_PARTICIPANTS, $this->getRefId())) {
127  return true;
128  }
129 
130  return false;
131  }
132 
137  {
138  if ($this->getAccess()->checkAccess('tst_results', '', $this->getRefId())) {
139  return true;
140  }
141 
142  if ($this->getAccess()->checkPositionAccess(ilOrgUnitOperation::OP_ACCESS_RESULTS, $this->getRefId())) {
143  return true;
144  }
145 
146  return false;
147  }
148 
152  public function checkStatisticsAccess()
153  {
154  if ($this->getAccess()->checkAccess('tst_statistics', '', $this->getRefId())) {
155  return true;
156  }
157 
158  return $this->checkParticipantsResultsAccess();
159  }
160 
166  protected function checkAccessForActiveId($accessFilter, $activeId)
167  {
168  global $DIC; /* @var ILIAS\DI\Container $DIC */
169 
170  $participantData = new ilTestParticipantData($DIC->database(), $DIC->language());
171  $participantData->setActiveIdsFilter(array($activeId));
172  $participantData->setParticipantAccessFilter($accessFilter);
173  $participantData->load($this->getTestId());
174 
175  return in_array($activeId, $participantData->getActiveIds());
176  }
177 
182  public function checkResultsAccessForActiveId($activeId)
183  {
185  return $this->checkAccessForActiveId($accessFilter, $activeId);
186  }
187 
192  public function checkScoreParticipantsAccessForActiveId($activeId)
193  {
195  return $this->checkAccessForActiveId($accessFilter, $activeId);
196  }
197 
202  public function checkStatisticsAccessForActiveId($activeId)
203  {
205  return $this->checkAccessForActiveId($accessFilter, $activeId);
206  }
207 }
checkScoreParticipantsAccessForActiveId($activeId)
checkAccessForActiveId($accessFilter, $activeId)
global $DIC
Definition: saml.php:7
__construct($refId, $testId)
checkResultsAccessForActiveId($activeId)
checkStatisticsAccessForActiveId($activeId)