ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilTestResultsGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
30 
47 {
48  public const DEFAULT_CMD = 'show';
49  private \ILIAS\DI\UIServices $ui;
50 
55 
56 
57  public function __construct(
58  private ilObjTest $testObj,
59  private ilTestQuestionSetConfig $question_set_config,
60  private ilCtrl $ctrl,
61  private ilAccess $access,
62  private ilDBInterface $db,
63  private Refinery $refinery,
64  private ilObjUser $user,
65  private ilLanguage $lng,
66  private LoggingServices $logging_services,
67  private ilComponentRepository $component_repository,
68  private ilTabsGUI $tabs,
69  private ilToolbarGUI $toolbar,
70  private ilGlobalTemplateInterface $main_tpl,
71  private UIFactory $ui_factory,
72  private UIRenderer $ui_renderer,
73  private SkillService $skills_service,
74  private InternalRequestService $testrequest,
75  private QuestionInfoService $questioninfo,
76  private GlobalHttpState $http
77  ) {
78  }
79 
84  {
86  }
87 
91  public function setObjectiveParent($objectiveParent)
92  {
93  $this->objectiveParent = $objectiveParent;
94  }
95 
99  public function getTestObj(): ilObjTest
100  {
101  return $this->testObj;
102  }
103 
107  public function setTestObj($testObj)
108  {
109  $this->testObj = $testObj;
110  }
111 
113  {
114  return $this->question_set_config;
115  }
116 
117  public function setQuestionSetConfig(ilTestQuestionSetConfig $question_set_config): void
118  {
119  $this->question_set_config = $question_set_config;
120  }
121 
122  public function getTestAccess(): ilTestAccess
123  {
124  return $this->testAccess;
125  }
126 
127  public function setTestAccess(ilTestAccess $testAccess): void
128  {
129  $this->testAccess = $testAccess;
130  }
131 
132  public function getTestSession(): ilTestSession
133  {
134  return $this->testSession;
135  }
136 
137  public function setTestSession(ilTestSession $testSession): void
138  {
139  $this->testSession = $testSession;
140  }
141 
142  public function getTestTabs(): ilTestTabsManager
143  {
144  return $this->testTabs;
145  }
146 
147  public function setTestTabs(ilTestTabsManager $testTabs): void
148  {
149  $this->testTabs = $testTabs;
150  }
151 
152  public function executeCommand(): void
153  {
154  $this->getTestTabs()->activateTab(ilTestTabsManager::TAB_ID_RESULTS);
155  $this->getTestTabs()->getResultsSubTabs();
156 
157  switch ($this->ctrl->getNextClass()) {
158  case 'ilparticipantstestresultsgui':
159  if (!$this->getTestAccess()->checkParticipantsResultsAccess()) {
160  ilObjTestGUI::accessViolationRedirect();
161  }
162 
164 
165  $gui = new ilParticipantsTestResultsGUI(
166  $this->ctrl,
167  $this->lng,
168  $this->db,
169  $this->user,
170  $this->tabs,
171  $this->toolbar,
172  $this->main_tpl,
173  $this->ui_factory,
174  $this->ui_renderer,
176  $this->testrequest,
177  $this->http,
178  $this->refinery
179  );
180  $gui->setTestObj($this->getTestObj());
181  $gui->setQuestionSetConfig($this->getQuestionSetConfig());
182  $gui->setTestAccess($this->getTestAccess());
183  $gui->setObjectiveParent($this->getObjectiveParent());
184  $this->ctrl->forwardCommand($gui);
185  break;
186 
187  case 'ilmytestresultsgui':
188  if (!$this->getTestTabs()->needsMyResultsSubTab()) {
189  ilObjTestGUI::accessViolationRedirect();
190  }
191 
192  $this->getTestTabs()->activateSubTab(ilTestTabsManager::SUBTAB_ID_MY_RESULTS);
193 
194  $gui = new ilMyTestResultsGUI();
195  $gui->setTestObj($this->getTestObj());
196  $gui->setTestAccess($this->getTestAccess());
197  $gui->setTestSession($this->getTestSession());
198  $gui->setObjectiveParent($this->getObjectiveParent());
199  $this->ctrl->forwardCommand($gui);
200  break;
201 
202  case 'iltestevalobjectiveorientedgui':
203  if (!$this->getTestTabs()->needsLoResultsSubTab()) {
204  ilObjTestGUI::accessViolationRedirect();
205  }
206 
207  $this->getTestTabs()->activateSubTab(ilTestTabsManager::SUBTAB_ID_LO_RESULTS);
208 
209  $gui = new ilTestEvalObjectiveOrientedGUI($this->getTestObj());
210  $gui->setObjectiveOrientedContainer($this->getObjectiveParent());
211  $this->ctrl->forwardCommand($gui);
212  break;
213 
214  case 'ilmytestsolutionsgui':
215  if (!$this->getTestTabs()->needsMySolutionsSubTab()) {
216  ilObjTestGUI::accessViolationRedirect();
217  }
218 
219  $this->getTestTabs()->activateSubTab(ilTestTabsManager::SUBTAB_ID_MY_SOLUTIONS);
220 
221  $gui = new ilMyTestSolutionsGUI();
222  $gui->setTestObj($this->getTestObj());
223  $gui->setTestAccess($this->getTestAccess());
224  $gui->setObjectiveParent($this->getObjectiveParent());
225  $this->ctrl->forwardCommand($gui);
226  break;
227 
228  case 'iltesttoplistgui':
229  if (!$this->getTestTabs()->needsHighSoreSubTab()) {
230  ilObjTestGUI::accessViolationRedirect();
231  }
232 
233  $this->getTestTabs()->activateSubTab(ilTestTabsManager::SUBTAB_ID_HIGHSCORE);
234 
235  $gui = new ilTestToplistGUI(
236  $this->getTestObj(),
237  new ilTestTopList($this->getTestObj(), $this->db),
238  $this->ctrl,
239  $this->main_tpl,
240  $this->lng,
241  $this->user,
242  $this->ui_factory,
243  $this->ui_renderer
244  );
245  $this->ctrl->forwardCommand($gui);
246  break;
247 
248  case 'iltestskillevaluationgui':
250 
251  $questionList = new ilAssQuestionList($this->db, $this->lng, $this->refinery, $this->component_repository);
252  $questionList->setParentObjId($this->getTestObj()->getId());
253  $questionList->setQuestionInstanceTypeFilter(ilAssQuestionList::QUESTION_INSTANCE_TYPE_DUPLICATES);
254  $questionList->load();
255 
256  $testSessionFactory = new ilTestSessionFactory($this->getTestObj(), $this->db, $this->user);
257  $testSession = $testSessionFactory->getSession();
258 
259  $gui = new ilTestSkillEvaluationGUI(
260  $this->getTestObj(),
261  $this->ctrl,
262  $this->main_tpl,
263  $this->lng,
264  $this->db,
265  $this->logging_services,
266  $this->skills_service,
267  $this->testrequest
268  );
269  $gui->setQuestionList($questionList);
270  $gui->setTestSession($testSession);
271  $gui->setObjectiveOrientedContainer($this->getObjectiveParent());
272 
273  $this->ctrl->forwardCommand($gui);
274  break;
275 
276  case strtolower(__CLASS__):
277  default:
278  $command = $this->ctrl->getCmd(self::DEFAULT_CMD) . 'Cmd';
279  $this->{$command}();
280  }
281  }
282 
283  protected function showCmd(): void
284  {
285  if ($this->testObj->canShowTestResults($this->getTestSession())) {
286  if ($this->objectiveParent->isObjectiveOrientedPresentationRequired()) {
287  $this->ctrl->redirectByClass('ilTestEvalObjectiveOrientedGUI');
288  }
289 
290  $this->ctrl->redirectByClass(['ilMyTestResultsGUI', 'ilTestEvaluationGUI']);
291  }
292 
293  $validator = new ilCertificateDownloadValidator();
294  if ($validator->isCertificateDownloadable($this->user->getId(), $this->getTestObj()->getId())) {
295  $button = $this->ui->factory()->button()->standard('certficiate', $this->ctrl->getFormActionByClass(ilTestEvaluationGUI::class, 'outCertificate'));
296  $this->toolbar->addComponent($button);
297  }
298 
300  }
301 
302  protected function showNoResultsReportingMessage(): void
303  {
304  $message = $this->lng->txt('tst_res_tab_msg_res_after_taking_test');
305 
306  switch ($this->testObj->getScoreReporting()) {
308  if ($this->testObj->hasAnyTestResult($this->getTestSession())) {
309  $message = $this->lng->txt('tst_res_tab_msg_res_after_finish_test');
310  }
311 
312  break;
313 
315  $date = $this->getTestObj()->getScoreSettings()->getResultSummarySettings()->getReportingDate()
316  ->setTimezone(new \DateTimeZone($this->user->getTimeZone()));
317  $date_format = $this->user->getDateFormat();
318  if ($this->user->getTimeFormat() === (string) ilCalendarSettings::TIME_FORMAT_12) {
319  $format = (new DataFactory())->dateFormat()->withTime12($date_format)->toString();
320  } else {
321  $format = (new DataFactory())->dateFormat()->withTime24($date_format)->toString();
322  }
323 
324  if (!$this->testObj->hasAnyTestResult($this->getTestSession())) {
325  $message = sprintf(
326  $this->lng->txt('tst_res_tab_msg_res_after_date_no_res'),
327  $date->format($format)
328  );
329  break;
330  }
331 
332  $message = sprintf(
333  $this->lng->txt('tst_res_tab_msg_res_after_date'),
334  $date->format($format)
335  );
336  break;
337 
339  $message = $this->lng->txt('tst_res_tab_msg_res_after_test_passed');
340  break;
341  }
342 
343  $this->main_tpl->setOnScreenMessage('info', $message);
344  }
345 }
Interface GlobalHttpState.
setTestSession(ilTestSession $testSession)
setTestAccess(ilTestAccess $testAccess)
Readable part of repository interface to ilComponentDataDB.
ilParticipantsTestResultsGUI: ilTestEvaluationGUI ilParticipantsTestResultsGUI: ilAssQuestionPageGUI...
setObjectiveParent($objectiveParent)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilTestObjectiveOrientedContainer $objectiveParent
Provides fluid interface to LoggingServices.
setQuestionSetConfig(ilTestQuestionSetConfig $question_set_config)
ILIAS DI UIServices $ui
ilTestTabsManager $testTabs
static http()
Fetches the global http state from ILIAS.
$lng
Validates if an active certificate is stored in the database and can be downloaded by the user...
$http
Definition: raiseError.php:7
setTestTabs(ilTestTabsManager $testTabs)
$message
Definition: xapiexit.php:32
__construct(private ilObjTest $testObj, private ilTestQuestionSetConfig $question_set_config, private ilCtrl $ctrl, private ilAccess $access, private ilDBInterface $db, private Refinery $refinery, private ilObjUser $user, private ilLanguage $lng, private LoggingServices $logging_services, private ilComponentRepository $component_repository, private ilTabsGUI $tabs, private ilToolbarGUI $toolbar, private ilGlobalTemplateInterface $main_tpl, private UIFactory $ui_factory, private UIRenderer $ui_renderer, private SkillService $skills_service, private InternalRequestService $testrequest, private QuestionInfoService $questioninfo, private GlobalHttpState $http)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Refinery Factory $refinery