ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilTestNavigationToolbarGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\UI\Component\Modal\Interruptive as InterruptiveModal;
23
31{
32 private bool $suspendTestButtonEnabled = false;
33 private bool $questionTreeVisible = false;
34 private bool $finishTestButtonEnabled = false;
35 private string $finishTestCommand = '';
36 private bool $finishTestButtonPrimary = false;
37 private bool $disabledStateEnabled = false;
38 protected ?InterruptiveModal $finish_test_modal = null;
39 protected bool $user_pass_overview_button_enabled = false;
40
41 public function __construct(
42 protected ilCtrlInterface $ctrl,
43 protected ilTestPlayerAbstractGUI $player_gui
44 ) {
46 }
47
51 public function isSuspendTestButtonEnabled(): bool
52 {
54 }
55
60 {
61 $this->suspendTestButtonEnabled = $suspendTestButtonEnabled;
62 }
63
64 public function isUserPassOverviewEnabled(): bool
65 {
67 }
68
70 {
71 $this->user_pass_overview_button_enabled = $user_pass_overview_button_enabled;
72 }
73
74 public function isQuestionTreeVisible(): bool
75 {
77 }
78
79 public function setQuestionTreeVisible(bool $questionTreeVisible): void
80 {
81 $this->questionTreeVisible = $questionTreeVisible;
82 }
83
84 public function isFinishTestButtonEnabled(): bool
85 {
87 }
88
93 {
94 $this->finishTestButtonEnabled = $finishTestButtonEnabled;
95 }
96
100 public function getFinishTestCommand(): string
101 {
103 }
104
109 {
110 $this->finishTestCommand = $finishTestCommand;
111 }
112
116 public function isFinishTestButtonPrimary(): bool
117 {
119 }
120
125 {
126 $this->finishTestButtonPrimary = $finishTestButtonPrimary;
127 }
128
132 public function isDisabledStateEnabled(): bool
133 {
135 }
136
141 {
142 $this->disabledStateEnabled = $disabledStateEnabled;
143 }
144
145 public function build()
146 {
147 if ($this->isUserPassOverviewEnabled()) {
148 $this->addPassOverviewButton();
149 }
150
151 if ($this->isSuspendTestButtonEnabled()) {
152 $this->addSuspendTestButton();
153 }
154
155 if ($this->isFinishTestButtonEnabled()) {
157 }
158 }
159
160 private function addSuspendTestButton()
161 {
162 $button = $this->ui->factory()->button()->standard(
163 $this->lng->txt('cancel_test'),
164 ''
165 )->withUnavailableAction(true)->withAdditionalOnLoadCode(
167 $this->ctrl->getLinkTarget($this->player_gui, ilTestPlayerCommands::SUSPEND_TEST)
168 )
169 );
170 $this->addComponent($button);
171 }
172
173 private function addPassOverviewButton()
174 {
175 $button = $this->ui->factory()->button()->standard(
176 $this->lng->txt('question_summary_btn'),
177 ''
178 )->withUnavailableAction(true)->withAdditionalOnLoadCode(
180 $this->ctrl->getLinkTarget($this->player_gui, ilTestPlayerCommands::QUESTION_SUMMARY)
181 )
182 );
183 $this->addComponent($button);
184 }
185
187 {
188 $target = $this->ctrl->getLinkTarget($this->player_gui, $this->getFinishTestCommand());
189 if ($this->player_gui->getObject()->getMainSettings()->getFinishingSettings()->getShowAnswerOverview()
190 && $this->getFinishTestCommand() !== ilTestPlayerCommands::QUESTION_SUMMARY) {
191 $target = $this->ctrl->getLinkTargetByClass('ilTestSubmissionReviewGUI', 'show');
192 }
193
195 return $button->withUnavailableAction(true)->withAdditionalOnLoadCode(
196 $this->buildCheckNavigationClosure($target)
197 );
198 }
199
201 {
202 if ($this->isFinishTestButtonPrimary()) {
203 return $this->ui->factory()->button()->primary($this->lng->txt('finish_test'), '');
204 }
205
206 return $this->ui->factory()->button()->standard($this->lng->txt('finish_test'), '');
207 }
208
209 private function buildCheckNavigationClosure(string $target): Closure
210 {
211 return static function (string $id) use ($target): string {
212 return "document.getElementById('{$id}').addEventListener('click', "
213 . '(e) => {'
214 . " il.TestPlayerQuestionEditControl.checkNavigation('{$target}', 'show', e);"
215 . '}); '
216 . "document.getElementById('{$id}').removeAttribute('disabled');";
217 };
218 }
219}
setUserPassOverviewEnabled(bool $user_pass_overview_button_enabled)
__construct(protected ilCtrlInterface $ctrl, protected ilTestPlayerAbstractGUI $player_gui)
setFinishTestButtonEnabled($finishTestButtonEnabled)
setQuestionTreeVisible(bool $questionTreeVisible)
setSuspendTestButtonEnabled($suspendTestButtonEnabled)
setFinishTestButtonPrimary($finishTestButtonPrimary)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addComponent(\ILIAS\UI\Component\Component $a_comp)
addStickyItem( $a_item, bool $a_output_label=false)
Add a sticky item.
This describes commonalities between standard and primary buttons.
Definition: Button.php:34
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Bulky.php:21