ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
SettingsIntroduction.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25
28use ILIAS\Refinery\Factory as Refinery;
29
31{
32 public function __construct(
33 int $test_id,
34 protected bool $introduction_enabled = false,
35 protected ?string $introduction_text = null,
36 protected ?int $introduction_page_id = null,
37 protected bool $conditions_checkbox_enabled = false,
38 ) {
40 }
41
42 public function toForm(
44 FieldFactory $f,
46 ?array $environment = null
47 ): FormInput {
48 $inputs['introduction_enabled'] = $f->checkbox(
49 $lng->txt('tst_introduction'),
50 $lng->txt('tst_introduction_desc')
52
53 $inputs['conditions_checkbox_enabled'] = $f->checkbox(
54 $lng->txt('tst_conditions_checkbox_enabled'),
55 $lng->txt('tst_conditions_checkbox_enabled_desc')
56 )->withValue($this->getExamConditionsCheckboxEnabled());
57
58 return $f->section($inputs, $lng->txt('tst_settings_header_intro'));
59 }
60
61 public function toStorage(): array
62 {
63 return [
64 'intro_enabled' => ['integer', (int) $this->getIntroductionEnabled()],
65 'introduction' => ['text', $this->getIntroductionText()],
66 'introduction_page_id' => ['integer', $this->getIntroductionPageId()],
67 'conditions_checkbox_enabled' => ['integer', (int) $this->getExamConditionsCheckboxEnabled()],
68 ];
69 }
70
71 public function toLog(AdditionalInformationGenerator $additional_info): array
72 {
73 return [
75 ->getEnabledDisabledTagForBool($this->getIntroductionEnabled()),
77 ->getEnabledDisabledTagForBool($this->getExamConditionsCheckboxEnabled()),
78 ];
79 }
80
81 public function getIntroductionEnabled(): bool
82 {
83 return $this->introduction_enabled;
84 }
85
86 public function withIntroductionEnabled(bool $introduction_enabled): self
87 {
88 $clone = clone $this;
89 $clone->introduction_enabled = $introduction_enabled;
90 return $clone;
91 }
92
93 public function getIntroductionText(): string
94 {
95 return $this->introduction_text ?? '';
96 }
97 public function withIntroductionText(?string $introduction_text): self
98 {
99 $clone = clone $this;
100 $clone->introduction_text = $introduction_text;
101 return $clone;
102 }
103
104 public function getIntroductionPageId(): ?int
105 {
106 return $this->introduction_page_id;
107 }
108 public function withIntroductionPageId(?int $introduction_page_id): self
109 {
110 $clone = clone $this;
111 $clone->introduction_page_id = $introduction_page_id;
112 return $clone;
113 }
114
115 public function getExamConditionsCheckboxEnabled(): bool
116 {
117 return $this->conditions_checkbox_enabled;
118 }
119 public function withExamConditionsCheckboxEnabled(bool $conditions_checkbox_enabled): self
120 {
121 $clone = clone $this;
122 $clone->conditions_checkbox_enabled = $conditions_checkbox_enabled;
123 return $clone;
124 }
125}
Builds data types.
Definition: Factory.php:36
toForm(\ilLanguage $lng, FieldFactory $f, Refinery $refinery, ?array $environment=null)
withExamConditionsCheckboxEnabled(bool $conditions_checkbox_enabled)
__construct(int $test_id, protected bool $introduction_enabled=false, protected ?string $introduction_text=null, protected ?int $introduction_page_id=null, protected bool $conditions_checkbox_enabled=false,)
toLog(AdditionalInformationGenerator $additional_info)
language handling
This describes inputs that can be used in forms.
Definition: FormInput.php:33
This is what a factory for input fields looks like.
Definition: Factory.php:31
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
withValue($value)
Get an input like this with another value displayed on the client side.
Definition: Group.php:61
global $lng
Definition: privfeed.php:31