ILIAS  release_8 Revision v8.24
class.ilTestResultsGUI.php
Go to the documentation of this file.
1<?php
2
35{
36 public const DEFAULT_CMD = 'show';
37
41 protected $testObj;
42
47
51 protected $testAccess;
52
56 protected $testSession;
57
61 protected $testTabs;
62
67 private \ilGlobalTemplateInterface $main_tpl;
68
74 {
75 global $DIC;
76 $this->main_tpl = $DIC->ui()->mainTemplate();
77 $this->testObj = $testObj;
78 $this->questionSetConfig = $questionSetConfig;
79 }
80
85 {
87 }
88
93 {
94 $this->objectiveParent = $objectiveParent;
95 }
96
100 public function getTestObj(): ilObjTest
101 {
102 return $this->testObj;
103 }
104
108 public function setTestObj($testObj)
109 {
110 $this->testObj = $testObj;
111 }
112
117 {
119 }
120
125 {
126 $this->questionSetConfig = $questionSetConfig;
127 }
128
132 public function getTestAccess(): ilTestAccess
133 {
134 return $this->testAccess;
135 }
136
140 public function setTestAccess($testAccess)
141 {
142 $this->testAccess = $testAccess;
143 }
144
148 public function getTestSession(): ilTestSession
149 {
150 return $this->testSession;
151 }
152
157 {
158 $this->testSession = $testSession;
159 }
160
165 {
166 return $this->testTabs;
167 }
168
172 public function setTestTabs($testTabs)
173 {
174 $this->testTabs = $testTabs;
175 }
176
180 public function executeCommand()
181 {
182 global $DIC; /* @var ILIAS\DI\Container $DIC */
183
184 $this->getTestTabs()->activateTab(ilTestTabsManager::TAB_ID_RESULTS);
185 $this->getTestTabs()->getResultsSubTabs();
186
187 switch ($DIC->ctrl()->getNextClass()) {
188 case 'ilparticipantstestresultsgui':
189
190 if (!$this->getTestAccess()->checkParticipantsResultsAccess()) {
192 }
193
195
196 $gui = new ilParticipantsTestResultsGUI();
197 $gui->setTestObj($this->getTestObj());
198 $gui->setQuestionSetConfig($this->getQuestionSetConfig());
199 $gui->setTestAccess($this->getTestAccess());
200 $gui->setObjectiveParent($this->getObjectiveParent());
201 $DIC->ctrl()->forwardCommand($gui);
202 break;
203
204 case 'ilmytestresultsgui':
205
206 if (!$this->getTestTabs()->needsMyResultsSubTab()) {
208 }
209
211
212 $gui = new ilMyTestResultsGUI();
213 $gui->setTestObj($this->getTestObj());
214 $gui->setTestAccess($this->getTestAccess());
215 $gui->setTestSession($this->getTestSession());
216 $gui->setObjectiveParent($this->getObjectiveParent());
217 $DIC->ctrl()->forwardCommand($gui);
218 break;
219
220 case 'iltestevalobjectiveorientedgui':
221
222 if (!$this->getTestTabs()->needsLoResultsSubTab()) {
224 }
225
227
228 $gui = new ilTestEvalObjectiveOrientedGUI($this->getTestObj());
229 $gui->setObjectiveOrientedContainer($this->getObjectiveParent());
230 $DIC->ctrl()->forwardCommand($gui);
231 break;
232
233 case 'ilmytestsolutionsgui':
234
235 if (!$this->getTestTabs()->needsMySolutionsSubTab()) {
237 }
238
240
241 $gui = new ilMyTestSolutionsGUI();
242 $gui->setTestObj($this->getTestObj());
243 $gui->setTestAccess($this->getTestAccess());
244 $gui->setObjectiveParent($this->getObjectiveParent());
245 $DIC->ctrl()->forwardCommand($gui);
246 break;
247
248 case 'iltesttoplistgui':
249
250 if (!$this->getTestTabs()->needsHighSoreSubTab()) {
252 }
253
254 $this->getTestTabs()->activateSubTab(ilTestTabsManager::SUBTAB_ID_HIGHSCORE);
255
256 $gui = new ilTestToplistGUI($this->getTestObj());
257 $DIC->ctrl()->forwardCommand($gui);
258 break;
259
260 case 'iltestskillevaluationgui':
261
263
264 global $DIC; /* @var ILIAS\DI\Container $DIC */
265 if ($this->getTestObj()->isDynamicTest()) {
266 $dynamicQuestionSetConfig = new ilObjTestDynamicQuestionSetConfig(
267 $DIC->repositoryTree(),
268 $DIC->database(),
269 $DIC['component.repository'],
270 $this->getTestObj()
271 );
272 $dynamicQuestionSetConfig->loadFromDb();
273 $questionList = new ilAssQuestionList($DIC->database(), $DIC->language(), $DIC['refinery'], $DIC['component.repository']);
274 $questionList->setParentObjId($dynamicQuestionSetConfig->getSourceQuestionPoolId());
275 $questionList->setQuestionInstanceTypeFilter(ilAssQuestionList::QUESTION_INSTANCE_TYPE_ORIGINALS);
276 } else {
277 $questionList = new ilAssQuestionList($DIC->database(), $DIC->language(), $DIC['refinery'], $DIC['component.repository']);
278 $questionList->setParentObjId($this->getTestObj()->getId());
279 $questionList->setQuestionInstanceTypeFilter(ilAssQuestionList::QUESTION_INSTANCE_TYPE_DUPLICATES);
280 }
281 $questionList->load();
282
283 $testSessionFactory = new ilTestSessionFactory($this->getTestObj());
284 $testSession = $testSessionFactory->getSession();
285
286 $gui = new ilTestSkillEvaluationGUI(
287 $DIC->ctrl(),
288 $DIC->tabs(),
289 $DIC->ui()->mainTemplate(),
290 $DIC->language(),
291 $DIC->database(),
292 $this->getTestObj()
293 );
294 $gui->setQuestionList($questionList);
295 $gui->setTestSession($testSession);
296 $gui->setObjectiveOrientedContainer($this->getObjectiveParent());
297
298 $DIC->ctrl()->forwardCommand($gui);
299 break;
300
301 case strtolower(__CLASS__):
302 default:
303
304 $command = $DIC->ctrl()->getCmd(self::DEFAULT_CMD) . 'Cmd';
305 $this->{$command}();
306 }
307 }
308
309 protected function showCmd()
310 {
311 global $DIC; /* @var ILIAS\DI\Container $DIC */
312
313 if ($this->testObj->canShowTestResults($this->getTestSession())) {
314 if ($this->objectiveParent->isObjectiveOrientedPresentationRequired()) {
315 $DIC->ctrl()->redirectByClass('ilTestEvalObjectiveOrientedGUI');
316 }
317
318 $DIC->ctrl()->redirectByClass(array('ilMyTestResultsGUI', 'ilTestEvaluationGUI'));
319 }
320
321 $toolbar = $DIC->toolbar();
322 $validator = new ilCertificateDownloadValidator();
323 if ($validator->isCertificateDownloadable($DIC->user()->getId(), $this->getTestObj()->getId())) {
324 $button = ilLinkButton::getInstance();
325 $button->setCaption('certificate');
326 $button->setUrl($DIC->ctrl()->getFormActionByClass(ilTestEvaluationGUI::class, 'outCertificate'));
327 $toolbar->addButtonInstance($button);
328 }
329
331 }
332
333 protected function showNoResultsReportingMessage()
334 {
335 global $DIC; /* @var ILIAS\DI\Container $DIC */
336
337 $message = $DIC->language()->txt('tst_res_tab_msg_res_after_taking_test');
338
339 switch ($this->testObj->getScoreReporting()) {
341
342 if ($this->testObj->hasAnyTestResult($this->getTestSession())) {
343 $message = $DIC->language()->txt('tst_res_tab_msg_res_after_finish_test');
344 }
345
346 break;
347
349 $reporting_date = $this->testObj->getScoreSettings()->getResultSummarySettings()->getReportingDate();
350 $reporting_date = new ilDateTime(
351 $reporting_date->format('YmdHis'),
353 $reporting_date->getTimezone()->getName() //date is provided in UTC, formatDate prints it in user timezone
354 );
355
356 if (!$this->testObj->hasAnyTestResult($this->getTestSession())) {
357 $message = sprintf(
358 $DIC->language()->txt('tst_res_tab_msg_res_after_date_no_res'),
359 ilDatePresentation::formatDate($reporting_date)
360 );
361 break;
362 }
363
364 $message = sprintf(
365 $DIC->language()->txt('tst_res_tab_msg_res_after_date'),
366 ilDatePresentation::formatDate($reporting_date)
367 );
368 break;
369
371 $message = $DIC->language()->txt('tst_res_tab_msg_res_after_test_passed');
372 break;
373 }
374
375 $this->main_tpl->setOnScreenMessage('info', $message);
376 }
377}
const IL_CAL_TIMESTAMP
Validates if an active certificate is stored in the database and can be downloaded by the user.
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false)
@classDescription Date and time handling
static accessViolationRedirect()
const SCORE_REPORTING_FINISHED
const SCORE_REPORTING_AFTER_PASSED
const SCORE_REPORTING_DATE
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(ilObjTest $testObj, ilTestQuestionSetConfig $questionSetConfig)
ilTestParticipantsGUI constructor.
executeCommand()
Execute Command.
setQuestionSetConfig($questionSetConfig)
ilGlobalTemplateInterface $main_tpl
setObjectiveParent($objectiveParent)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
$message
Definition: xapiexit.php:32