Skip to content

Commit

Permalink
TA, Question List: move title, username and test-id into header
Browse files Browse the repository at this point in the history
  • Loading branch information
nhaagen committed Jul 14, 2023
1 parent 1469d22 commit d5c5445
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 208 deletions.
58 changes: 25 additions & 33 deletions Modules/Test/classes/Screen/class.ilTestPlayerLayoutProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -42,46 +43,17 @@
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
{
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();
Expand Down Expand Up @@ -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 = '';
Expand Down
16 changes: 0 additions & 16 deletions Modules/Test/classes/class.ilTestNavigationToolbarGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
68 changes: 52 additions & 16 deletions Modules/Test/classes/class.ilTestOutputGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand All @@ -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) {
Expand Down Expand Up @@ -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);
}
}
Loading

0 comments on commit d5c5445

Please sign in to comment.