Skip to content

Commit

Permalink
TA: QuestionList in mainbar
Browse files Browse the repository at this point in the history
- remove toggle button
- show always as mainbar-tools
- translate 'Dashboard', remove SideListGUI
- move title, username and test-id into header
  • Loading branch information
nhaagen committed Aug 18, 2023
1 parent 063e8e0 commit 9d9a1d6
Show file tree
Hide file tree
Showing 11 changed files with 174 additions and 556 deletions.
94 changes: 61 additions & 33 deletions Modules/Test/classes/Screen/class.ilTestPlayerLayoutProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,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 @@ -44,58 +45,65 @@
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_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
public function getMainBarModification(CalledContexts $called_contexts): ?MainBarModification
{
if ($this->isKioskModeEnabled($called_contexts)) {
$logo = $this->globalScreen()->layout()->factory()->logo();

$logo = $logo->withModification(function (?Image $current): ?Image {
return null;
});
$mainbar = $this->globalScreen()->layout()->factory()->mainbar();
$additionalData = $called_contexts->current()->getAdditionalData();
$has_question_list = $additionalData->exists(self::TEST_PLAYER_QUESTIONLIST);
$is_kiosk_mode = $this->isKioskModeEnabled($called_contexts);

return $logo->withHighPriority();
if (! $is_kiosk_mode && ! $has_question_list) {
return null;
}

return null;
}
if ($is_kiosk_mode && ! $has_question_list) {
$mainbar_modification = static fn(?MainBar $mainbar): ?MainBar => null;
}

public function getResponsiveLogoModification(CalledContexts $called_contexts): ?LogoModification
{
if ($this->isKioskModeEnabled($called_contexts)) {
$logo = $this->globalScreen()->layout()->factory()->logo();
if ($has_question_list) {
$f = $this->dic->ui()->factory();
$r = $this->dic->ui()->renderer();
$lng = $this->dic->language();
$question_listing = $called_contexts->current()->getAdditionalData()->get(self::TEST_PLAYER_QUESTIONLIST);

$logo = $logo->withModification(function (?Image $current): ?Image {
return null;
});
$mainbar_modification = static function (?MainBar $mainbar) use ($f, $r, $lng, $question_listing, $is_kiosk_mode): ?MainBar {
if ($is_kiosk_mode) {
$mainbar = $mainbar->withClearedEntries();
}

return $logo->withHighPriority();
}
$icon = $f->symbol()->icon()->standard('tst', $lng->txt("more"));
$tools_button = $f->button()->bulky($icon, $lng->txt("tools"), "#")
->withEngagedState(true);

return null;
}
$question_listing = $f->legacy($r->render($question_listing));

public function getMainBarModification(CalledContexts $called_contexts): ?MainBarModification
{
if ($this->isKioskModeEnabled($called_contexts)) {
$mainBar = $this->globalScreen()->layout()->factory()->mainbar();
$label = $lng->txt('mainbar_button_label_questionlist');
$entry = $f->maincontrols()->slate()->legacy(
$label,
$f->symbol()->icon()->standard("tst", $label),
$question_listing
);

$mainBar = $mainBar->withModification(function (?MainBar $current): ?MainBar {
return null;
});

return $mainBar->withHighPriority();
return $mainbar
->withToolsButton($tools_button)
->withAdditionalToolEntry('questionlist', $entry);
};
}

return null;
return $mainbar
->withModification($mainbar_modification)
->withHighPriority();
}

public function getMetaBarModification(CalledContexts $called_contexts): ?MetaBarModification
Expand Down Expand Up @@ -157,6 +165,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
38 changes: 0 additions & 38 deletions Modules/Test/classes/class.ilTestNavigationToolbarGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,22 +138,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 Expand Up @@ -249,10 +233,6 @@ public function setDisabledStateEnabled($disabledStateEnabled)

public function build()
{
if ($this->isQuestionTreeButtonEnabled()) {
$this->addQuestionTreeButton();
}

if ($this->isQuestionListButtonEnabled()) {
$this->addQuestionListButton();
}
Expand Down Expand Up @@ -320,24 +300,6 @@ private function addQuestionSelectionButton()
$this->addButtonInstance($btn);
}

private function addQuestionTreeButton()
{
$btn = ilTestPlayerNavButton::getInstance();
$btn->setNextCommand(ilTestPlayerCommands::TOGGLE_SIDE_LIST);
$btn->setUrl($this->ctrl->getLinkTarget(
$this->playerGUI,
ilTestPlayerCommands::TOGGLE_SIDE_LIST
));
if ($this->isQuestionTreeVisible()) {
$btn->setCaption('tst_hide_side_list');
} else {
$btn->setCaption('tst_show_side_list');
}
//$btn->setDisabled($this->isDisabledStateEnabled());
$btn->addCSSClass('ilTstNavElem');
$this->addButtonInstance($btn);
}

private function addFinishTestButton(): void
{
if ($this->userHasAttemptsLeft()) {
Expand Down
65 changes: 48 additions & 17 deletions Modules/Test/classes/class.ilTestOutputGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,6 @@ public function executeCommand()

$this->initAssessmentSettings();

$this->global_screen->tool()->context()->current()->addAdditionalData(
ilTestPlayerLayoutProvider::TEST_PLAYER_KIOSK_MODE_ENABLED,
$this->object->getKioskMode()
);
$this->global_screen->tool()->context()->current()->addAdditionalData(
ilTestPlayerLayoutProvider::TEST_PLAYER_TITLE,
$this->object->getTitle()
);
$instance_name = $this->settings->get('short_inst_name') ?? '';
if (trim($instance_name) === '') {
$instance_name = 'ILIAS';
}
$this->global_screen->tool()->context()->current()->addAdditionalData(
ilTestPlayerLayoutProvider::TEST_PLAYER_SHORT_TITLE,
$instance_name
);

$testSessionFactory = new ilTestSessionFactory($this->object, $this->db, $this->user);
$this->test_session = $testSessionFactory->getSession($this->testrequest->int('active_id'));

Expand All @@ -92,6 +75,29 @@ public function executeCommand()

$this->handlePasswordProtectionRedirect();


$instance_name = $this->settings->get('short_inst_name') ?? '';
if (trim($instance_name) === '') {
$instance_name = 'ILIAS';
}
$this->global_screen->tool()->context()->current()->addAdditionalData(
ilTestPlayerLayoutProvider::TEST_PLAYER_SHORT_TITLE,
$instance_name
);
$this->global_screen->tool()->context()->current()->addAdditionalData(
ilTestPlayerLayoutProvider::TEST_PLAYER_KIOSK_MODE_ENABLED,
$this->object->getKioskMode()
);
$this->global_screen->tool()->context()->current()->addAdditionalData(
ilTestPlayerLayoutProvider::TEST_PLAYER_VIEW_TITLE,
$this->object->getTitle()
);
$this->global_screen->tool()->context()->current()->addAdditionalData(
ilTestPlayerLayoutProvider::TEST_PLAYER_TITLE,
$this->getTestPlayerTitle()
);


$cmd = $this->getCommand($cmd);

switch ($next_class) {
Expand Down Expand Up @@ -967,4 +973,29 @@ protected function handlePrimaryButton(ilTestNavigationToolbarGUI $navigationToo

return $isNextPrimary;
}

protected function getTestPlayerTitle(): string
{
$test_title = $this->object->getShowKioskModeTitle() ? $this->object->getTitle() : '';
$user_name = $this->object->getShowKioskModeParticipant() ? $this->user->getFullname() : '';
$exam_id = '';
if ($this->object->isShowExamIdInTestPassEnabled()) {
$exam_id = $this->lng->txt("exam_id")
. ' '
. ilObjTest::buildExamId(
$this->test_session->getActiveId(),
$this->test_session->getPass(),
$this->object->getId()
);
}

$layout = $this->ui_factory->layout()->alignment()->vertical(
$this->ui_factory->legacy($test_title),
$this->ui_factory->layout()->alignment()->horizontal()->dynamicallyDistributed(
$this->ui_factory->legacy($user_name),
$this->ui_factory->legacy($exam_id)
)
);
return $this->ui_renderer->render($layout);
}
}
Loading

0 comments on commit 9d9a1d6

Please sign in to comment.