19declare(strict_types=1);
34 protected bool $show_answer_overview =
false,
35 protected bool $concluding_remarks_enabled =
false,
36 protected ?
int $concluding_remarks_page_id =
null,
38 protected ?
string $redirection_url =
null,
47 ?array $environment =
null
49 $inputs[
'show_answer_overview'] =
$f->checkbox(
50 $lng->txt(
'enable_examview'),
51 $lng->txt(
'enable_examview_desc')
54 $inputs[
'show_concluding_remarks'] =
$f->checkbox(
55 $lng->txt(
'final_statement'),
56 $lng->txt(
'final_statement_show_desc')
61 return $f->section(
$inputs,
$lng->txt(
'tst_final_information'));
70 static function (?array $v): array {
73 'redirect_mode' => RedirectionModes::NONE,
79 'redirect_mode' => RedirectionModes::tryFrom($v[
'redirect_mode'])
80 ?? RedirectionModes::NONE,
81 'redirect_url' => $v[
'redirect_url']
86 $sub_inputs_redirect = [
88 ->radio(
$lng->txt(
'redirect_after_finishing_rule'))
91 $lng->txt(
'redirect_always')
94 $lng->txt(
'redirect_always_to_logout')
96 (
string) RedirectionModes::IF_KIOSK_ACTIVATED->value,
97 $lng->txt(
'redirect_in_kiosk_mode')
99 ->withAdditionalTransformation(
$refinery->kindlyTo()->int()),
101 ->text(
$lng->txt(
'redirection_url'))
105 static function ($v) use (
$refinery):
bool {
108 }
catch (Throwable) {
112 $lng->txt(
'redirect_url_invalid')
117 $redirection_input =
$f
119 $sub_inputs_redirect,
120 $lng->txt(
'redirect_after_finishing_tst'),
121 $lng->txt(
'redirect_after_finishing_tst_desc')
124 ->withAdditionalTransformation($redirection_trafo)
125 ->withAdditionalTransformation(
127 static function (array $v):
bool {
132 ) || $v[
'redirect_url'] !==
'';
134 static function (\Closure $txt, array $value):
string {
136 $txt(
'redirect_url_required_for_rule'),
138 ? $txt(
'redirect_always')
139 : $txt(
'redirect_in_kiosk_mode')
145 if ($this->getRedirectionMode() === RedirectionModes::NONE) {
146 return $redirection_input;
149 return $redirection_input->withValue(
151 'redirect_mode' => $this->getRedirectionMode()->value,
152 'redirect_url' => $this->getRedirectionUrl()
160 'enable_examview' => [
'integer', (
int) $this->getShowAnswerOverview()],
161 'showfinalstatement' => [
'integer', (
int) $this->getConcludingRemarksEnabled()],
162 'concluding_remarks_page_id' => [
'integer', $this->getConcludingRemarksPageId()],
163 'redirection_mode' => [
'integer', $this->getRedirectionMode()->value],
164 'redirection_url' => [
'text', $this->getRedirectionUrl()],
171 AdditionalInformationGenerator::KEY_TEST_ANSWER_OVERVIEW_ENABLED => $additional_info
173 AdditionalInformationGenerator::KEY_TEST_CONCLUDING_REMARKS_ENABLED => $additional_info
175 AdditionalInformationGenerator::KEY_TEST_REDIRECT_URL => $this->getRedirectionUrl(),
179 switch ($this->getRedirectionMode()) {
180 case RedirectionModes::NONE:
181 $log_array[AdditionalInformationGenerator::KEY_TEST_REDIRECT_MODE] = $additional_info
185 $log_array[AdditionalInformationGenerator::KEY_TEST_REDIRECT_MODE] = $additional_info
188 case RedirectionModes::IF_KIOSK_ACTIVATED:
189 $log_array[AdditionalInformationGenerator::KEY_TEST_REDIRECT_MODE] = $additional_info
199 return $this->show_answer_overview;
204 $clone = clone $this;
205 $clone->show_answer_overview = $show_answer_overview;
211 return $this->concluding_remarks_enabled;
216 $clone = clone $this;
217 $clone->concluding_remarks_enabled = $concluding_remarks_enabled;
223 return $this->concluding_remarks_page_id;
228 $clone = clone $this;
229 $clone->concluding_remarks_page_id = $concluding_remarks_page_id;
235 return $this->redirection_mode;
240 $clone = clone $this;
241 $clone->redirection_mode = $redirection_mode;
247 return $this->redirection_url;
252 $clone = clone $this;
253 $clone->redirection_url = $redirection_url;
260 'enable_examview' => $this->getShowAnswerOverview(),
261 'showfinalstatement' => $this->getConcludingRemarksEnabled(),
262 'concluding_remarks_page_id' => $this->getConcludingRemarksPageId(),
263 'redirection_mode' => $this->getRedirectionMode()->value,
264 'redirection_url' => $this->getRedirectionUrl()
271 (bool)
$data[
'enable_examview'],
272 (
bool)
$data[
'showfinalstatement'],
273 $data[
'concluding_remarks_page_id'],
275 $data[
'redirection_url']
withConcludingRemarksPageId(?int $concluding_remarks_page_id)
withRedirectionUrl(?string $redirection_url)
static fromExport(array $data)
Creates an instance of the object from an array.
__construct(protected bool $show_answer_overview=false, protected bool $concluding_remarks_enabled=false, protected ?int $concluding_remarks_page_id=null, protected RedirectionModes $redirection_mode=RedirectionModes::NONE, protected ?string $redirection_url=null,)
getRedirectionInputs(\ilLanguage $lng, FieldFactory $f, Refinery $refinery)
getConcludingRemarksEnabled()
toExport()
Transform the object into a simple, associative array.
getConcludingRemarksPageId()
withRedirectionMode(RedirectionModes $redirection_mode)
toLog(AdditionalInformationGenerator $additional_info)
withShowAnswerOverview(bool $show_answer_overview)
toForm(\ilLanguage $lng, FieldFactory $f, Refinery $refinery, ?array $environment=null)
withConcludingRemarksEnabled(bool $concluding_remarks_enabled)
This interface allows an object to define its own transformation into a language-neutral,...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!file_exists('../ilias.ini.php'))