ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
class.ilTestResultsGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
29use ILIAS\Data\Factory as DataFactory;
30use ILIAS\UI\Factory as UIFactory;
31use ILIAS\UI\Renderer as UIRenderer;
32use ILIAS\Refinery\Factory as Refinery;
35
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 private readonly ParticipantRepository $participant_repository
78 ) {
79 }
80
81 public function executeCommand(): void
82 {
83 $this->test_tabs->activateTab(TabsManager::TAB_ID_YOUR_RESULTS);
84 $this->test_tabs->getYourResultsSubTabs();
85
86 switch ($this->ctrl->getNextClass()) {
87 case 'ilmytestresultsgui':
88 if (!$this->test_tabs->needsYourResultsTab()) {
89 ilObjTestGUI::accessViolationRedirect();
90 }
91
92 $this->test_tabs->activateSubTab(
93 $this->ctrl->getCmd() === 'outUserListOfAnswerPasses'
94 ? TabsManager::SUBTAB_ID_MY_SOLUTIONS
95 : TabsManager::SUBTAB_ID_MY_RESULTS
96 );
97
98 $gui = new ilMyTestResultsGUI(
99 $this->test_object,
100 $this->test_access,
101 $this->objective_parent,
102 $this->lng,
103 $this->ctrl,
104 $this->main_tpl,
105 $this->questionrepository,
106 $this->testrequest
107 );
108 $this->ctrl->forwardCommand($gui);
109 break;
110
111 case 'iltestevalobjectiveorientedgui':
112 if (!$this->test_tabs->needsLoResultsSubTab()) {
113 ilObjTestGUI::accessViolationRedirect();
114 }
115
116 $this->test_tabs->activateSubTab(TabsManager::SUBTAB_ID_LO_RESULTS);
117
118 $gui = new ilTestEvalObjectiveOrientedGUI($this->test_object);
119 $gui->setObjectiveOrientedContainer($this->objective_parent);
120 $this->ctrl->forwardCommand($gui);
121 break;
122
123 case 'iltesttoplistgui':
124 if (!$this->test_tabs->needsHighSoreSubTab()) {
125 ilObjTestGUI::accessViolationRedirect();
126 }
127
128 $this->test_tabs->activateSubTab(TabsManager::SUBTAB_ID_HIGHSCORE);
129
130 $gui = new ilTestToplistGUI(
131 $this->test_object,
132 $this->toplist_repository,
133 $this->ctrl,
134 $this->main_tpl,
135 $this->lng,
136 $this->user,
137 $this->ui_factory,
138 $this->ui_renderer,
139 $this->data_factory,
140 $this->http,
141 $this->participant_repository
142 );
143 $this->ctrl->forwardCommand($gui);
144 break;
145
146 case 'iltestskillevaluationgui':
147 $this->test_tabs->activateSubTab(TabsManager::SUBTAB_ID_SKILL_RESULTS);
148
149 $question_list = new ilAssQuestionList($this->db, $this->lng, $this->refinery, $this->component_repository);
150 $question_list->setParentObjId($this->test_object->getId());
151 $question_list->setQuestionInstanceTypeFilter(null);
152 $question_list->load();
153
154 $gui = new ilTestSkillEvaluationGUI(
155 $this->test_object,
156 $this->ctrl,
157 $this->main_tpl,
158 $this->lng,
159 $this->db,
160 $this->logger,
161 $this->skills_service,
162 $this->testrequest
163 );
164 $gui->setQuestionList($question_list);
165 $gui->setTestSession(
167 $this->test_object,
168 $this->db,
169 $this->user
170 ))->getSession()
171 );
172 $gui->setObjectiveOrientedContainer($this->objective_parent);
173
174 $this->ctrl->forwardCommand($gui);
175 break;
176
177 case strtolower(__CLASS__):
178 default:
179 $command = $this->ctrl->getCmd(self::DEFAULT_CMD) . 'Cmd';
180 $this->{$command}();
181 }
182 }
183
184 protected function showCmd(): void
185 {
186 if ($this->test_object->canShowTestResults($this->test_session)) {
187 if ($this->objective_parent->isObjectiveOrientedPresentationRequired()) {
188 $this->ctrl->redirectByClass('ilTestEvalObjectiveOrientedGUI');
189 }
190
191 $this->ctrl->redirectByClass(['ilMyTestResultsGUI', 'ilTestEvaluationGUI']);
192 }
193
194 $validator = new ilCertificateDownloadValidator();
195 if ($validator->isCertificateDownloadable($this->user->getId(), $this->test_object->getId())) {
196 $button = $this->ui->factory()->button()->standard('certficiate', $this->ctrl->getFormActionByClass(ilTestEvaluationGUI::class, 'outCertificate'));
197 $this->toolbar->addComponent($button);
198 }
199
201 }
202
203 protected function showNoResultsReportingMessage(): void
204 {
205 $message = $this->lng->txt('tst_res_tab_msg_res_after_taking_test');
206
207 switch ($this->test_object->getScoreReporting()) {
208 case ScoreReportingTypes::SCORE_REPORTING_FINISHED:
209 if ($this->test_object->hasAnyTestResult($this->test_session)) {
210 $message = $this->lng->txt('tst_res_tab_msg_res_after_finish_test');
211 }
212
213 break;
214
215 case ScoreReportingTypes::SCORE_REPORTING_DATE:
216 $date = $this->test_object->getScoreSettings()->getResultSummarySettings()->getReportingDate()
217 ->setTimezone(new \DateTimeZone($this->user->getTimeZone()));
218
219 if (!$this->test_object->hasAnyTestResult($this->test_session)) {
220 $message = sprintf(
221 $this->lng->txt('tst_res_tab_msg_res_after_date_no_res'),
222 $date->format($this->user->getDateTimeFormat()->toString())
223 );
224 break;
225 }
226
227 $message = sprintf(
228 $this->lng->txt('tst_res_tab_msg_res_after_date'),
229 $date->format($this->user->getDateTimeFormat()->toString())
230 );
231 break;
232
233 case ScoreReportingTypes::SCORE_REPORTING_AFTER_PASSED:
234 $message = $this->lng->txt('tst_res_tab_msg_res_after_test_passed');
235 break;
236 }
237
238 $this->main_tpl->setOnScreenMessage('info', $message);
239 }
240}
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, private readonly ParticipantRepository $participant_repository)
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