Skip to content

Commit 9467c7f

Browse files
committed
Adds auto open of exam modal if test password is wrong
1 parent 0a5e2e6 commit 9467c7f

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

components/ILIAS/Test/src/Presentation/class.TestScreenGUI.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use ILIAS\Data\Link;
2828
use ILIAS\Data\Result;
2929
use ILIAS\Data\Password;
30+
use ILIAS\UI\Implementation\Component\Launcher\Inline;
3031
use ILIAS\UI\Component\Launcher\Launcher;
3132
use ILIAS\UI\Component\Launcher\Factory as LauncherFactory;
3233
use ILIAS\UI\Component\MessageBox\MessageBox;
@@ -315,9 +316,29 @@ function (Result $result) {
315316
&& $request->getQueryParams()[$key] === 'exam_modal') {
316317
$launcher = $launcher->withRequest($request);
317318
}
319+
320+
if ($this->shouldOpenModal()) {
321+
/** @var Inline $launcher */
322+
$modal = $launcher->getModal();
323+
$show_signal = $modal->getShowSignal();
324+
325+
$this->tpl->addOnLoadCode("
326+
(function() {
327+
setTimeout(function() {
328+
$(document).trigger('$show_signal', {});
329+
});
330+
})();
331+
");
332+
}
333+
318334
return $launcher;
319335
}
320336

337+
private function shouldOpenModal(): bool
338+
{
339+
return ($this->http->request()->getQueryParams()['launcher_id'] ?? '') === 'exam_modal';
340+
}
341+
321342
private function getModalLauncherLink(): Link
322343
{
323344
$uri = $this->data_factory->uri($this->http->request()->getUri()->__toString())->withParameter('launcher_id', 'exam_modal');
@@ -386,6 +407,10 @@ private function getModalLauncherMessageBox(): ?MessageBox
386407
$modal_message_box_message = $this->lng->txt('tst_exam_modal_message_password');
387408
}
388409

410+
if ($this->shouldOpenModal()) {
411+
return $this->ui_factory->messageBox()->failure($this->lng->txt('tst_exam_password_invalid_message'));
412+
}
413+
389414
return isset($modal_message_box_message) ? $this->ui_factory->messageBox()->info($modal_message_box_message) : null;
390415
}
391416

0 commit comments

Comments
 (0)