diff --git a/Modules/Test/classes/Screen/class.ilTestPlayerLayoutProvider.php b/Modules/Test/classes/Screen/class.ilTestPlayerLayoutProvider.php index 86b43a6e1eab..d0be1dcd159c 100644 --- a/Modules/Test/classes/Screen/class.ilTestPlayerLayoutProvider.php +++ b/Modules/Test/classes/Screen/class.ilTestPlayerLayoutProvider.php @@ -20,6 +20,7 @@ use ILIAS\GlobalScreen\Scope\Layout\Factory\LogoModification; use ILIAS\GlobalScreen\Scope\Layout\Factory\MainBarModification; use ILIAS\GlobalScreen\Scope\Layout\Factory\MetaBarModification; +use ILIAS\GlobalScreen\Scope\Layout\Factory\TitleModification; use ILIAS\GlobalScreen\Scope\Layout\Factory\ShortTitleModification; use ILIAS\GlobalScreen\Scope\Layout\Factory\ViewTitleModification; use ILIAS\GlobalScreen\Scope\Layout\Provider\AbstractModificationProvider; @@ -42,9 +43,10 @@ class ilTestPlayerLayoutProvider extends AbstractModificationProvider implements ModificationProvider { public const TEST_PLAYER_KIOSK_MODE_ENABLED = 'test_player_kiosk_mode_enabled'; - public const TEST_PLAYER_TITLE = 'test_player_kiosk_mode_title'; - public const TEST_PLAYER_SHORT_TITLE = 'test_player_kiosk_mode_instance_name'; - public const TEST_PLAYER_QUESTIONLIST = 'test_player_kiosk_mode_questionlist'; + public const TEST_PLAYER_TITLE = 'test_player_title'; + public const TEST_PLAYER_VIEW_TITLE = 'test_player_view_title'; + public const TEST_PLAYER_SHORT_TITLE = 'test_player_instance_name'; + public const TEST_PLAYER_QUESTIONLIST = 'test_player_questionlist'; public function isInterestedInContexts(): ContextCollection @@ -52,36 +54,6 @@ public function isInterestedInContexts(): ContextCollection return $this->context_collection->repository(); } - public function getLogoModification(CalledContexts $called_contexts): ?LogoModification - { - if ($this->isKioskModeEnabled($called_contexts)) { - $logo = $this->globalScreen()->layout()->factory()->logo(); - - $logo = $logo->withModification(function (?Image $current): ?Image { - return null; - }); - - return $logo->withHighPriority(); - } - - return null; - } - - public function getResponsiveLogoModification(CalledContexts $called_contexts): ?LogoModification - { - if ($this->isKioskModeEnabled($called_contexts)) { - $logo = $this->globalScreen()->layout()->factory()->logo(); - - $logo = $logo->withModification(function (?Image $current): ?Image { - return null; - }); - - return $logo->withHighPriority(); - } - - return null; - } - public function getMainBarModification(CalledContexts $called_contexts): ?MainBarModification { $mainbar = $this->globalScreen()->layout()->factory()->mainbar(); @@ -191,6 +163,26 @@ function (?string $content) use ($title): ?string { public function getViewTitleModification(CalledContexts $called_contexts): ?ViewTitleModification { if ($this->isKioskModeEnabled($called_contexts)) { + $title = $called_contexts->current()->getAdditionalData()->get(self::TEST_PLAYER_VIEW_TITLE); + if ($title == null) { + $title = ''; + } + return $this->globalScreen()->layout()->factory()->view_title() + ->withModification( + function (?string $content) use ($title): ?string { + return $title; + } + ) + ->withHighPriority(); + } + return null; + } + + public function getTitleModification(CalledContexts $called_contexts): ?TitleModification + { + $additionalData = $called_contexts->current()->getAdditionalData(); + $has_title = $additionalData->exists(self::TEST_PLAYER_TITLE); + if ($has_title) { $title = $called_contexts->current()->getAdditionalData()->get(self::TEST_PLAYER_TITLE); if ($title == null) { $title = ''; diff --git a/Modules/Test/classes/class.ilTestNavigationToolbarGUI.php b/Modules/Test/classes/class.ilTestNavigationToolbarGUI.php index 3dd5f976b017..2591e7ac211d 100644 --- a/Modules/Test/classes/class.ilTestNavigationToolbarGUI.php +++ b/Modules/Test/classes/class.ilTestNavigationToolbarGUI.php @@ -122,22 +122,6 @@ public function setQuestionListButtonEnabled($questionListButtonEnabled) $this->questionListButtonEnabled = $questionListButtonEnabled; } - /** - * @return boolean - */ - public function isQuestionTreeButtonEnabled(): bool - { - return $this->questionTreeButtonEnabled; - } - - /** - * @param boolean $questionTreeButtonEnabled - */ - public function setQuestionTreeButtonEnabled($questionTreeButtonEnabled) - { - $this->questionTreeButtonEnabled = $questionTreeButtonEnabled; - } - /** * @return boolean */ diff --git a/Modules/Test/classes/class.ilTestOutputGUI.php b/Modules/Test/classes/class.ilTestOutputGUI.php index 2a2f0df3b6f5..061132dc58c8 100755 --- a/Modules/Test/classes/class.ilTestOutputGUI.php +++ b/Modules/Test/classes/class.ilTestOutputGUI.php @@ -61,22 +61,6 @@ public function executeCommand() $this->initAssessmentSettings(); - $DIC->globalScreen()->tool()->context()->current()->addAdditionalData( - ilTestPlayerLayoutProvider::TEST_PLAYER_KIOSK_MODE_ENABLED, - $this->object->getKioskMode() - ); - $DIC->globalScreen()->tool()->context()->current()->addAdditionalData( - ilTestPlayerLayoutProvider::TEST_PLAYER_TITLE, - $this->object->getTitle() - ); - $instance_name = $DIC['ilSetting']->get('short_inst_name') ?? ''; - if (trim($instance_name) === '') { - $instance_name = 'ILIAS'; - } - $DIC->globalScreen()->tool()->context()->current()->addAdditionalData( - ilTestPlayerLayoutProvider::TEST_PLAYER_SHORT_TITLE, - $instance_name - ); $testSessionFactory = new ilTestSessionFactory($this->object); $this->testSession = $testSessionFactory->getSession($this->testrequest->raw('active_id')); @@ -98,6 +82,29 @@ public function executeCommand() $this->handlePasswordProtectionRedirect(); + + $instance_name = $DIC['ilSetting']->get('short_inst_name') ?? ''; + if (trim($instance_name) === '') { + $instance_name = 'ILIAS'; + } + $DIC->globalScreen()->tool()->context()->current()->addAdditionalData( + ilTestPlayerLayoutProvider::TEST_PLAYER_SHORT_TITLE, + $instance_name + ); + $DIC->globalScreen()->tool()->context()->current()->addAdditionalData( + ilTestPlayerLayoutProvider::TEST_PLAYER_KIOSK_MODE_ENABLED, + $this->object->getKioskMode() + ); + $DIC->globalScreen()->tool()->context()->current()->addAdditionalData( + ilTestPlayerLayoutProvider::TEST_PLAYER_VIEW_TITLE, + $this->object->getTitle() + ); + $DIC->globalScreen()->tool()->context()->current()->addAdditionalData( + ilTestPlayerLayoutProvider::TEST_PLAYER_TITLE, + $this->getTestPlayerTitle() + ); + + $cmd = $this->getCommand($cmd); switch ($next_class) { @@ -966,4 +973,33 @@ protected function handlePrimaryButton(ilTestNavigationToolbarGUI $navigationToo return $isNextPrimary; } + + protected function getTestPlayerTitle(): string + { + global $DIC; + $f = $DIC['ui.factory']; + $r = $DIC['ui.renderer']; + + $test_title = $this->object->getShowKioskModeTitle() ? $this->object->getTitle() : ''; + $user_name = $this->object->getShowKioskModeParticipant() ? $this->ilUser->getFullname() : ''; + $exam_id = ''; + if ($this->object->isShowExamIdInTestPassEnabled()) { + $exam_id = $this->lng->txt("exam_id") + . ' ' + . ilObjTest::buildExamId( + $this->testSession->getActiveId(), + $this->testSession->getPass(), + $this->object->getId() + ); + } + + $layout = $f->layout()->alignment()->vertical( + $f->legacy($test_title), + $f->layout()->alignment()->horizontal()->dynamicallyDistributed( + $f->legacy($user_name), + $f->legacy($exam_id) + ) + ); + return $r->render($layout); + } } diff --git a/Modules/Test/classes/class.ilTestPlayerAbstractGUI.php b/Modules/Test/classes/class.ilTestPlayerAbstractGUI.php index 9db79f00a4cf..a3a3e42540f0 100755 --- a/Modules/Test/classes/class.ilTestPlayerAbstractGUI.php +++ b/Modules/Test/classes/class.ilTestPlayerAbstractGUI.php @@ -83,9 +83,9 @@ public function __construct($a_object) global $DIC; $rbacsystem = $DIC['rbacsystem']; - $ilUser = $DIC['ilUser']; + $this->ilUser = $DIC['ilUser']; $lng = $DIC['lng']; - $this->passwordChecker = new ilTestPasswordChecker($rbacsystem, $ilUser, $this->object, $lng); + $this->passwordChecker = new ilTestPasswordChecker($rbacsystem, $this->ilUser, $this->object, $lng); $this->processLocker = null; $this->testSession = null; @@ -117,7 +117,7 @@ protected function checkTestSessionUser(ilTestSession $testSession) { global $DIC; /* @var ILIAS\DI\Container $DIC */ - if ($testSession->getUserId() != $DIC->user()->getId()) { + if ($testSession->getUserId() != $this->ilUser->getId()) { throw new ilTestException('active id given does not relate to current user!'); } } @@ -128,10 +128,7 @@ protected function ensureExistingTestSession(ilTestSession $testSession) return; } - global $DIC; - $ilUser = $DIC['ilUser']; - - $testSession->setUserId($ilUser->getId()); + $testSession->setUserId($this->ilUser->getId()); if ($testSession->isAnonymousUser()) { if (!$testSession->doesAccessCodeInSessionExists()) { @@ -219,8 +216,6 @@ public function suspendTestCmd() */ public function isMaxProcessingTimeReached(): bool { - global $DIC; - $ilUser = $DIC['ilUser']; $active_id = $this->testSession->getActiveId(); $starting_time = $this->object->getStartingTimeOfUser($active_id); if ($starting_time === false) { @@ -542,7 +537,6 @@ public function accessCodeConfirmedCmd() public function handleUserSettings() { global $DIC; - $ilUser = $DIC['ilUser']; $post_array = $_POST; if (! is_array($post_array)) { $request = $DIC->http()->request(); @@ -550,13 +544,13 @@ public function handleUserSettings() } $tst_javascript = array_key_exists("chb_javascript", $post_array) ? 1 : 0; - $ilUser->writePref("tst_javascript", $tst_javascript); + $this->ilUser->writePref("tst_javascript", $tst_javascript); if ($this->object->getNrOfTries() != 1 && $this->object->getUsePreviousAnswers() == 1 ) { $chb_use_previous_answers = array_key_exists("chb_use_previous_answers", $post_array) ? 1 : 0; - $ilUser->writePref("tst_use_previous_answers", $chb_use_previous_answers); + $this->ilUser->writePref("tst_use_previous_answers", $chb_use_previous_answers); } } @@ -678,19 +672,6 @@ protected function submitIntermediateSolutionCmd() $this->ctrl->redirect($this, ilTestPlayerCommands::SHOW_QUESTION); } - /** - * Toggle side list - */ - public function toggleSideListCmd() - { - global $DIC; - $ilUser = $DIC['ilUser']; - - $show_side_list = $ilUser->getPref('side_list_of_questions'); - $ilUser->writePref('side_list_of_questions', !$show_side_list); - $this->ctrl->redirect($this, ilTestPlayerCommands::SHOW_QUESTION); - } - protected function markQuestionAndSaveIntermediateCmd() { // fau: testNav - handle intermediate submit when marking the question @@ -748,12 +729,6 @@ protected function confirmFinishCmd() */ protected function confirmFinishTestCmd() { - /** - * @var $ilUser ilObjUser - */ - global $DIC; - $ilUser = $DIC['ilUser']; - $confirmation = new ilConfirmationGUI(); $confirmation->setFormAction($this->ctrl->getFormAction($this, 'confirmFinish')); $confirmation->setHeaderText($this->lng->txt("tst_finish_confirmation_question")); @@ -937,45 +912,9 @@ public function showFinalStatementCmd() $this->tpl->setVariable($this->getContentBlockName(), $template->get()); } - public function getKioskHead(): string - { - global $DIC; - $ilUser = $DIC['ilUser']; - - $template = new ilTemplate('tpl.il_as_tst_kiosk_head.html', true, true, 'Modules/Test'); - if ($this->object->getShowKioskModeTitle()) { - $template->setCurrentBlock("kiosk_show_title"); - $template->setVariable("TEST_TITLE", $this->object->getTitle()); - $template->parseCurrentBlock(); - } - if ($this->object->getShowKioskModeParticipant()) { - $template->setCurrentBlock("kiosk_show_participant"); - $template->setVariable("PARTICIPANT_NAME_TXT", $this->lng->txt("login_as")); - $template->setVariable("PARTICIPANT_NAME", $ilUser->getFullname()); - $template->setVariable("PARTICIPANT_LOGIN", $ilUser->getLogin()); - $template->setVariable("PARTICIPANT_MATRICULATION", $ilUser->getMatriculation()); - $template->setVariable("PARTICIPANT_EMAIL", $ilUser->getEmail()); - $template->parseCurrentBlock(); - } - if ($this->object->isShowExamIdInTestPassEnabled()) { - $exam_id = ilObjTest::buildExamId( - $this->testSession->getActiveId(), - $this->testSession->getPass(), - $this->object->getId() - ); - - $template->setCurrentBlock("kiosk_show_exam_id"); - $template->setVariable("EXAM_ID_TXT", $this->lng->txt("exam_id")); - $template->setVariable("EXAM_ID", $exam_id); - $template->parseCurrentBlock(); - } - return $template->get(); - } - protected function prepareTestPage($presentationMode, $sequenceElement, $questionId) { global $DIC; - $ilUser = $DIC['ilUser']; $ilNavigationHistory = $DIC['ilNavigationHistory']; $ilNavigationHistory->addItem( @@ -1004,12 +943,8 @@ protected function prepareTestPage($presentationMode, $sequenceElement, $questio return; } - if ($this->object->getKioskMode()) { - $this->populateKioskHead(); - } - $this->tpl->setVariable("TEST_ID", (string) $this->object->getTestId()); - $this->tpl->setVariable("LOGIN", $ilUser->getLogin()); + $this->tpl->setVariable("LOGIN", $this->ilUser->getLogin()); $this->tpl->setVariable("SEQ_ID", $sequenceElement); $this->tpl->setVariable("QUEST_ID", $questionId); @@ -1224,11 +1159,8 @@ abstract protected function startTestCmd(); */ public function checkOnlineTestAccess() { - global $DIC; - $ilUser = $DIC['ilUser']; - // check if user is invited to participate - $user = $this->object->getInvitedUsers($ilUser->getId()); + $user = $this->object->getInvitedUsers($this->ilUser->getId()); if (!is_array($user) || count($user) != 1) { $this->tpl->setOnScreenMessage('info', $this->lng->txt("user_not_invited"), true); $this->ctrl->redirectByClass("ilobjtestgui", "backToRepository"); @@ -1314,9 +1246,6 @@ public function confirmSubmitAnswers() public function outProcessingTime($active_id) { - global $DIC; - $ilUser = $DIC['ilUser']; - $starting_time = $this->object->getStartingTimeOfUser($active_id); $processing_time = $this->object->getProcessingTimeInSeconds($active_id); $processing_time_minutes = floor($processing_time / 60); @@ -1506,16 +1435,6 @@ public function outQuestionSummaryCmd($fullpage = true, $contextFinishTest = fal $this->tpl->setOnScreenMessage('failure', $this->lng->txt('not_all_obligations_answered')); } - if ($this->object->getKioskMode() && $fullpage) { - $head = $this->getKioskHead(); - if (strlen($head)) { - $this->tpl->setCurrentBlock("kiosk_options"); - $this->tpl->setVariable("KIOSK_HEAD", $head); - $this->tpl->parseCurrentBlock(); - } - } - - $active_id = $this->testSession->getActiveId(); $questionSummaryData = $this->service->getQuestionSummaryData($this->testSequence, $obligationsFilter); @@ -1624,9 +1543,6 @@ public function outCorrectSolution() */ public function showListOfAnswers($active_id, $pass = null, $top_data = "", $bottom_data = "") { - global $DIC; - $ilUser = $DIC['ilUser']; - $this->tpl->addBlockFile($this->getContentBlockName(), "adm_content", "tpl.il_as_tst_finish_list_of_answers.html", "Modules/Test"); $result_array = &$this->object->getTestResult( @@ -1681,11 +1597,11 @@ public function showListOfAnswers($active_id, $pass = null, $top_data = "", $bot $this->tpl->setVariable("SIGNATURE", $signature); $this->tpl->setVariable("TITLE", $this->object->getTitle()); $this->tpl->setVariable("TXT_TEST_PROLOG", $this->lng->txt("tst_your_answers")); - $invited_user = &$this->object->getInvitedUsers($ilUser->getId()); + $invited_user = &$this->object->getInvitedUsers($this->ilUser->getId()); $pagetitle = $this->object->getTitle() . " - " . $this->lng->txt("clientip") . - ": " . $invited_user[$ilUser->getId()]["clientip"] . " - " . + ": " . $invited_user[$this->ilUser->getId()]["clientip"] . " - " . $this->lng->txt("matriculation") . ": " . - $invited_user[$ilUser->getId()]["matriculation"]; + $invited_user[$this->ilUser->getId()]["matriculation"]; $this->tpl->setVariable("PAGETITLE", $pagetitle); $this->tpl->parseCurrentBlock(); } @@ -1765,10 +1681,6 @@ protected function prepareSummaryPage() 'tpl.il_as_tst_question_summary.html', 'Modules/Test' ); - - if ($this->object->getKioskMode()) { - $this->populateKioskHead(); - } } protected function initTestPageTemplate() @@ -1799,17 +1711,6 @@ protected function initTestPageTemplate() ); } - protected function populateKioskHead() - { - $head = $this->getKioskHead(); - - if (strlen($head)) { - $this->tpl->setCurrentBlock("kiosk_options"); - $this->tpl->setVariable("KIOSK_HEAD", $head); - $this->tpl->parseCurrentBlock(); - } - } - protected function handlePasswordProtectionRedirect() { if ($this->ctrl->getNextClass() == 'iltestpasswordprotectiongui') { @@ -1933,14 +1834,8 @@ protected function populateHelperGuiContent($helperGui) protected function getTestNavigationToolbarGUI(): ilTestNavigationToolbarGUI { - global $DIC; - $ilUser = $DIC['ilUser']; - $navigationToolbarGUI = new ilTestNavigationToolbarGUI($this->ctrl, $this->lng, $this); - $navigationToolbarGUI->setSuspendTestButtonEnabled($this->object->getShowCancel()); - $navigationToolbarGUI->setQuestionTreeButtonEnabled($this->object->getListOfQuestions()); - $navigationToolbarGUI->setQuestionTreeVisible((bool) $ilUser->getPref('side_list_of_questions')); $navigationToolbarGUI->setQuestionListButtonEnabled($this->object->getListOfQuestions()); $navigationToolbarGUI->setFinishTestCommand($this->getFinishTestCommand()); @@ -2403,7 +2298,6 @@ protected function getQuestionInstance($questionId, $fromCache = true): assQuest { global $DIC; $ilDB = $DIC['ilDB']; - $ilUser = $DIC['ilUser']; if (!$fromCache || !isset($this->cachedQuestionObjects[$questionId])) { $questionOBJ = assQuestion::_instantiateQuestion($questionId); @@ -2411,7 +2305,7 @@ protected function getQuestionInstance($questionId, $fromCache = true): assQuest $assSettings = new ilSetting('assessment'); $processLockerFactory = new ilAssQuestionProcessLockerFactory($assSettings, $ilDB); $processLockerFactory->setQuestionId($questionOBJ->getId()); - $processLockerFactory->setUserId($ilUser->getId()); + $processLockerFactory->setUserId($this->ilUser->getId()); $processLockerFactory->setAssessmentLogEnabled(ilObjAssessmentFolder::_enabledAssessmentLogging()); $questionOBJ->setProcessLocker($processLockerFactory->getLocker()); diff --git a/Modules/Test/templates/default/tpl.il_as_tst_kiosk_head.html b/Modules/Test/templates/default/tpl.il_as_tst_kiosk_head.html deleted file mode 100644 index 39abcfbf3b4e..000000000000 --- a/Modules/Test/templates/default/tpl.il_as_tst_kiosk_head.html +++ /dev/null @@ -1,16 +0,0 @@ -
-
- -{TEST_TITLE} - -
-
- -{PARTICIPANT_NAME} - - -
-{EXAM_ID_TXT} {EXAM_ID} - -
-
\ No newline at end of file diff --git a/Modules/Test/test/ilTestNavigationToolbarGUITest.php b/Modules/Test/test/ilTestNavigationToolbarGUITest.php index f0f1fe6afac5..b771e077f993 100644 --- a/Modules/Test/test/ilTestNavigationToolbarGUITest.php +++ b/Modules/Test/test/ilTestNavigationToolbarGUITest.php @@ -62,15 +62,6 @@ public function testQuestionListButtonEnabled(): void $this->assertTrue($this->testObj->isQuestionListButtonEnabled()); } - public function testQuestionTreeButtonEnabled(): void - { - $this->testObj->setQuestionTreeButtonEnabled(false); - $this->assertFalse($this->testObj->isQuestionTreeButtonEnabled()); - - $this->testObj->setQuestionTreeButtonEnabled(true); - $this->assertTrue($this->testObj->isQuestionTreeButtonEnabled()); - } - public function testQuestionTreeVisible(): void { $this->testObj->setQuestionTreeVisible(false);