ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilTestResultsGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
28use ILIAS\Data\Factory as DataFactory;
29use ILIAS\UI\Factory as UIFactory;
30use ILIAS\UI\Renderer as UIRenderer;
31use ILIAS\Refinery\Factory as Refinery;
34
50{
51 public const DEFAULT_CMD = 'show';
52 private \ILIAS\DI\UIServices $ui;
53
54 public function __construct(
55 private ilObjTest $test_object,
56 private readonly ilCtrlInterface $ctrl,
57 private readonly ilTestAccess $test_access,
58 private readonly ilDBInterface $db,
59 private readonly Refinery $refinery,
60 private readonly ilObjUser $user,
61 private readonly ilLanguage $lng,
62 private readonly TestLogger $logger,
63 private readonly ilComponentRepository $component_repository,
64 private TabsManager $test_tabs,
65 private readonly ilToolbarGUI $toolbar,
66 private readonly ilGlobalTemplateInterface $main_tpl,
67 private readonly UIFactory $ui_factory,
68 private readonly UIRenderer $ui_renderer,
69 private readonly SkillService $skills_service,
70 private readonly GeneralQuestionPropertiesRepository $questionrepository,
71 private readonly TestTopListRepository $toplist_repository,
72 private readonly RequestDataCollector $testrequest,
73 private readonly GlobalHttpState $http,
74 private readonly DataFactory $data_factory,
75 private readonly ilTestSession $test_session,
76 private readonly ilTestObjectiveOrientedContainer $objective_parent
77 ) {
78 }
79
80 public function executeCommand(): void
81 {
82 $this->test_tabs->activateTab(TabsManager::TAB_ID_YOUR_RESULTS);
83 $this->test_tabs->getYourResultsSubTabs();
84
85 switch ($this->ctrl->getNextClass()) {
86 case 'ilmytestresultsgui':
87 if (!$this->test_tabs->needsYourResultsTab()) {
88 ilObjTestGUI::accessViolationRedirect();
89 }
90
91 $this->test_tabs->activateSubTab(TabsManager::SUBTAB_ID_MY_RESULTS);
92
93 $gui = new ilMyTestResultsGUI(
94 $this->test_object,
95 $this->test_access,
96 $this->objective_parent,
97 $this->user,
98 $this->lng,
99 $this->ctrl,
100 $this->main_tpl,
101 $this->questionrepository,
102 $this->testrequest
103 );
104 $this->ctrl->forwardCommand($gui);
105 break;
106
107 case 'iltestevalobjectiveorientedgui':
108 if (!$this->test_tabs->needsLoResultsSubTab()) {
109 ilObjTestGUI::accessViolationRedirect();
110 }
111
112 $this->test_tabs->activateSubTab(TabsManager::SUBTAB_ID_LO_RESULTS);
113
114 $gui = new ilTestEvalObjectiveOrientedGUI($this->test_object);
115 $gui->setObjectiveOrientedContainer($this->objective_parent);
116 $this->ctrl->forwardCommand($gui);
117 break;
118
119 case 'ilmytestsolutionsgui':
120 if (!$this->test_tabs->needsYourSolutionsSubTab()) {
121 ilObjTestGUI::accessViolationRedirect();
122 }
123
124 $this->test_tabs->activateSubTab(TabsManager::SUBTAB_ID_MY_SOLUTIONS);
125
126 $gui = new ilMyTestSolutionsGUI(
127 $this->test_object,
128 $this->test_access,
129 $this->objective_parent,
130 $this->lng,
131 $this->ctrl,
132 $this->main_tpl,
133 $this->questionrepository,
134 $this->testrequest
135 );
136 $this->ctrl->forwardCommand($gui);
137 break;
138
139 case 'iltesttoplistgui':
140 if (!$this->test_tabs->needsHighSoreSubTab()) {
141 ilObjTestGUI::accessViolationRedirect();
142 }
143
144 $this->test_tabs->activateSubTab(TabsManager::SUBTAB_ID_HIGHSCORE);
145
146 $gui = new ilTestToplistGUI(
147 $this->test_object,
148 $this->toplist_repository,
149 $this->ctrl,
150 $this->main_tpl,
151 $this->lng,
152 $this->user,
153 $this->ui_factory,
154 $this->ui_renderer,
155 $this->data_factory,
156 $this->http
157 );
158 $this->ctrl->forwardCommand($gui);
159 break;
160
161 case 'iltestskillevaluationgui':
162 $this->test_tabs->activateSubTab(TabsManager::SUBTAB_ID_SKILL_RESULTS);
163
164 $question_list = new ilAssQuestionList($this->db, $this->lng, $this->refinery, $this->component_repository);
165 $question_list->setParentObjId($this->test_object->getId());
166 $question_list->setQuestionInstanceTypeFilter(null);
167 $question_list->load();
168
169 $gui = new ilTestSkillEvaluationGUI(
170 $this->test_object,
171 $this->ctrl,
172 $this->main_tpl,
173 $this->lng,
174 $this->db,
175 $this->logger,
176 $this->skills_service,
177 $this->testrequest
178 );
179 $gui->setQuestionList($question_list);
180 $gui->setTestSession(
182 $this->test_object,
183 $this->db,
184 $this->user
185 ))->getSession()
186 );
187 $gui->setObjectiveOrientedContainer($this->objective_parent);
188
189 $this->ctrl->forwardCommand($gui);
190 break;
191
192 case strtolower(__CLASS__):
193 default:
194 $command = $this->ctrl->getCmd(self::DEFAULT_CMD) . 'Cmd';
195 $this->{$command}();
196 }
197 }
198
199 protected function showCmd(): void
200 {
201 if ($this->test_object->canShowTestResults($this->test_session)) {
202 if ($this->objective_parent->isObjectiveOrientedPresentationRequired()) {
203 $this->ctrl->redirectByClass('ilTestEvalObjectiveOrientedGUI');
204 }
205
206 $this->ctrl->redirectByClass(['ilMyTestResultsGUI', 'ilTestEvaluationGUI']);
207 }
208
209 $validator = new ilCertificateDownloadValidator();
210 if ($validator->isCertificateDownloadable($this->user->getId(), $this->test_object->getId())) {
211 $button = $this->ui->factory()->button()->standard('certficiate', $this->ctrl->getFormActionByClass(ilTestEvaluationGUI::class, 'outCertificate'));
212 $this->toolbar->addComponent($button);
213 }
214
216 }
217
218 protected function showNoResultsReportingMessage(): void
219 {
220 $message = $this->lng->txt('tst_res_tab_msg_res_after_taking_test');
221
222 switch ($this->test_object->getScoreReporting()) {
223 case ScoreReportingTypes::SCORE_REPORTING_FINISHED:
224 if ($this->test_object->hasAnyTestResult($this->test_session)) {
225 $message = $this->lng->txt('tst_res_tab_msg_res_after_finish_test');
226 }
227
228 break;
229
230 case ScoreReportingTypes::SCORE_REPORTING_DATE:
231 $date = $this->test_object->getScoreSettings()->getResultSummarySettings()->getReportingDate()
232 ->setTimezone(new \DateTimeZone($this->user->getTimeZone()));
233
234 if (!$this->test_object->hasAnyTestResult($this->test_session)) {
235 $message = sprintf(
236 $this->lng->txt('tst_res_tab_msg_res_after_date_no_res'),
237 $date->format($this->user->getDateTimeFormat()->toString())
238 );
239 break;
240 }
241
242 $message = sprintf(
243 $this->lng->txt('tst_res_tab_msg_res_after_date'),
244 $date->format($this->user->getDateTimeFormat()->toString())
245 );
246 break;
247
248 case ScoreReportingTypes::SCORE_REPORTING_AFTER_PASSED:
249 $message = $this->lng->txt('tst_res_tab_msg_res_after_test_passed');
250 break;
251 }
252
253 $this->main_tpl->setOnScreenMessage('info', $message);
254 }
255}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Builds data types.
Definition: Factory.php:36
Validates if an active certificate is stored in the database and can be downloaded by the user.
language handling
User class.
ILIAS DI UIServices $ui
__construct(private ilObjTest $test_object, private readonly ilCtrlInterface $ctrl, private readonly ilTestAccess $test_access, private readonly ilDBInterface $db, private readonly Refinery $refinery, private readonly ilObjUser $user, private readonly ilLanguage $lng, private readonly TestLogger $logger, private readonly ilComponentRepository $component_repository, private TabsManager $test_tabs, private readonly ilToolbarGUI $toolbar, private readonly ilGlobalTemplateInterface $main_tpl, private readonly UIFactory $ui_factory, private readonly UIRenderer $ui_renderer, private readonly SkillService $skills_service, private readonly GeneralQuestionPropertiesRepository $questionrepository, private readonly TestTopListRepository $toplist_repository, private readonly RequestDataCollector $testrequest, private readonly GlobalHttpState $http, private readonly DataFactory $data_factory, private readonly ilTestSession $test_session, private readonly ilTestObjectiveOrientedContainer $objective_parent)
Test session handler.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$http
Definition: deliver.php:30
Interface GlobalHttpState.
An entity that renders components to a string output.
Definition: Renderer.php:31
Readable part of repository interface to ilComponentDataDB.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Interface ilDBInterface.
static http()
Fetches the global http state from ILIAS.
global $lng
Definition: privfeed.php:31
$message
Definition: xapiexit.php:31