ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ILIAS\Test\Settings\MainSettings\SettingsFinishing Class Reference
+ Inheritance diagram for ILIAS\Test\Settings\MainSettings\SettingsFinishing:
+ Collaboration diagram for ILIAS\Test\Settings\MainSettings\SettingsFinishing:

Public Member Functions

 __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,)
 
 toForm (\ilLanguage $lng, FieldFactory $f, Refinery $refinery, ?array $environment=null)
 
 toStorage ()
 
 toLog (AdditionalInformationGenerator $additional_info)
 
 getShowAnswerOverview ()
 
 withShowAnswerOverview (bool $show_answer_overview)
 
 getConcludingRemarksEnabled ()
 
 withConcludingRemarksEnabled (bool $concluding_remarks_enabled)
 
 getConcludingRemarksPageId ()
 
 withConcludingRemarksPageId (?int $concluding_remarks_page_id)
 
 getRedirectionMode ()
 
 withRedirectionMode (RedirectionModes $redirection_mode)
 
 getRedirectionUrl ()
 
 withRedirectionUrl (?string $redirection_url)
 
 toExport ()
 Transform the object into a simple, associative array. More...
 
- Public Member Functions inherited from ILIAS\Test\Settings\TestSettings
 __construct ()
 
 toForm (\ilLanguage $lng, FieldFactory $f, Refinery $refinery, ?array $environment=null)
 
 toStorage ()
 
 toLog (AdditionalInformationGenerator $additional_info)
 
 toExport ()
 Transform the object into a simple, associative array. More...
 

Static Public Member Functions

static fromExport (array $data)
 Creates an instance of the object from an array. More...
 
static fromExport (array $data)
 Creates an instance of the object from an array. More...
 

Private Member Functions

 getRedirectionInputs (\ilLanguage $lng, FieldFactory $f, Refinery $refinery)
 

Detailed Description

Definition at line 31 of file SettingsFinishing.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Test\Settings\MainSettings\SettingsFinishing::__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 
)

Definition at line 33 of file SettingsFinishing.php.

39 {
41 }
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ fromExport()

static ILIAS\Test\Settings\MainSettings\SettingsFinishing::fromExport ( array  $data)
static

Creates an instance of the object from an array.

This static factory method is responsible for constructing a new object instance from the provided array data. It should validate the input and may throw an exception if the data is incomplete or malformed.

Parameters
ExportableArray$dataThe data to restore the object from
Returns
static A new instance of the class

Implements ILIAS\Test\ExportImport\Exportable.

Definition at line 268 of file SettingsFinishing.php.

268 : static
269 {
270 return new self(
271 (bool) $data['enable_examview'],
272 (bool) $data['showfinalstatement'],
273 $data['concluding_remarks_page_id'],
274 RedirectionModes::from($data['redirection_mode']),
275 $data['redirection_url']
276 );
277 }

References $data, and ILIAS\ResourceStorage\Flavour\Machine\DefaultMachines\from().

Referenced by ILIAS\Test\Settings\MainSettings\MainSettings\fromExport().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getConcludingRemarksEnabled()

ILIAS\Test\Settings\MainSettings\SettingsFinishing::getConcludingRemarksEnabled ( )

Definition at line 209 of file SettingsFinishing.php.

209 : bool
210 {
211 return $this->concluding_remarks_enabled;
212 }

◆ getConcludingRemarksPageId()

ILIAS\Test\Settings\MainSettings\SettingsFinishing::getConcludingRemarksPageId ( )

Definition at line 221 of file SettingsFinishing.php.

221 : ?int
222 {
223 return $this->concluding_remarks_page_id;
224 }

◆ getRedirectionInputs()

ILIAS\Test\Settings\MainSettings\SettingsFinishing::getRedirectionInputs ( \ilLanguage  $lng,
FieldFactory  $f,
Refinery  $refinery 
)
private

Definition at line 64 of file SettingsFinishing.php.

68 : OptionalGroup {
69 $redirection_trafo = $refinery->custom()->transformation(
70 static function (?array $v): array {
71 if ($v === null) {
72 return [
73 'redirect_mode' => RedirectionModes::NONE,
74 'redirect_url' => ''
75 ];
76 }
77
78 return [
79 'redirect_mode' => RedirectionModes::tryFrom($v['redirect_mode'])
80 ?? RedirectionModes::NONE,
81 'redirect_url' => $v['redirect_url']
82 ];
83 }
84 );
85
86 $sub_inputs_redirect = [
87 'redirect_mode' => $f
88 ->radio($lng->txt('redirect_after_finishing_rule'))
89 ->withOption(
90 (string) RedirectionModes::ALWAYS->value,
91 $lng->txt('redirect_always')
92 )->withOption(
94 $lng->txt('redirect_always_to_logout')
95 )->withOption(
96 (string) RedirectionModes::IF_KIOSK_ACTIVATED->value,
97 $lng->txt('redirect_in_kiosk_mode')
98 )->withRequired(true)
99 ->withAdditionalTransformation($refinery->kindlyTo()->int()),
100 'redirect_url' => $f
101 ->text($lng->txt('redirection_url'))
102 ->withAdditionalTransformation($refinery->string()->hasMaxLength(4000))
104 $refinery->custom()->constraint(
105 static function ($v) use ($refinery): bool {
106 try {
107 return $v === '' || $refinery->to()->data('uri')->transform($v);
108 } catch (Throwable) {
109 return false;
110 }
111 },
112 $lng->txt('redirect_url_invalid')
113 )
114 )
115 ];
116
117 $redirection_input = $f
118 ->optionalGroup(
119 $sub_inputs_redirect,
120 $lng->txt('redirect_after_finishing_tst'),
121 $lng->txt('redirect_after_finishing_tst_desc')
122 )
123 ->withValue(null)
124 ->withAdditionalTransformation($redirection_trafo)
125 ->withAdditionalTransformation(
126 $refinery->custom()->constraint(
127 static function (array $v): bool {
128 return in_array(
129 $v['redirect_mode'],
130 [RedirectionModes::NONE, RedirectionModes::ALWAYS_TO_LOGOUT],
131 true
132 ) || $v['redirect_url'] !== '';
133 },
134 static function (\Closure $txt, array $value): string {
135 return sprintf(
136 $txt('redirect_url_required_for_rule'),
137 $value['redirect_mode'] === RedirectionModes::ALWAYS
138 ? $txt('redirect_always')
139 : $txt('redirect_in_kiosk_mode')
140 );
141 }
142 )
143 );
144
145 if ($this->getRedirectionMode() === RedirectionModes::NONE) {
146 return $redirection_input;
147 }
148
149 return $redirection_input->withValue(
150 [
151 'redirect_mode' => $this->getRedirectionMode()->value,
152 'redirect_url' => $this->getRedirectionUrl()
153 ]
154 );
155 }
const ALWAYS
withAdditionalTransformation(Transformation $trafo)
@inheritDoc
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

◆ getRedirectionMode()

ILIAS\Test\Settings\MainSettings\SettingsFinishing::getRedirectionMode ( )

Definition at line 233 of file SettingsFinishing.php.

234 {
235 return $this->redirection_mode;
236 }

◆ getRedirectionUrl()

ILIAS\Test\Settings\MainSettings\SettingsFinishing::getRedirectionUrl ( )

Definition at line 245 of file SettingsFinishing.php.

245 : ?string
246 {
247 return $this->redirection_url;
248 }

◆ getShowAnswerOverview()

ILIAS\Test\Settings\MainSettings\SettingsFinishing::getShowAnswerOverview ( )

Definition at line 197 of file SettingsFinishing.php.

197 : bool
198 {
199 return $this->show_answer_overview;
200 }

◆ toExport()

ILIAS\Test\Settings\MainSettings\SettingsFinishing::toExport ( )

Transform the object into a simple, associative array.

The resulting array represents the object's state and should contain only scalar values, arrays, or other Exportable objects.

Returns
ExportableArray The exportable array representation of the object

Implements ILIAS\Test\ExportImport\Exportable.

Definition at line 257 of file SettingsFinishing.php.

257 : array
258 {
259 return [
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()
265 ];
266 }

◆ toForm()

ILIAS\Test\Settings\MainSettings\SettingsFinishing::toForm ( \ilLanguage  $lng,
FieldFactory  $f,
Refinery  $refinery,
?array  $environment = null 
)

Reimplemented from ILIAS\Test\Settings\TestSettings.

Definition at line 43 of file SettingsFinishing.php.

48 : FormInput {
49 $inputs['show_answer_overview'] = $f->checkbox(
50 $lng->txt('enable_examview'),
51 $lng->txt('enable_examview_desc')
52 )->withValue($this->getShowAnswerOverview());
53
54 $inputs['show_concluding_remarks'] = $f->checkbox(
55 $lng->txt('final_statement'),
56 $lng->txt('final_statement_show_desc')
57 )->withValue((bool) $this->getConcludingRemarksEnabled());
58
59 $inputs['redirect_after_finish'] = $this->getRedirectionInputs($lng, $f, $refinery);
60
61 return $f->section($inputs, $lng->txt('tst_final_information'));
62 }
getRedirectionInputs(\ilLanguage $lng, FieldFactory $f, Refinery $refinery)

◆ toLog()

ILIAS\Test\Settings\MainSettings\SettingsFinishing::toLog ( AdditionalInformationGenerator  $additional_info)

Reimplemented from ILIAS\Test\Settings\TestSettings.

Definition at line 168 of file SettingsFinishing.php.

168 : array
169 {
170 $log_array = [
176
177 ];
178
179 switch ($this->getRedirectionMode()) {
180 case RedirectionModes::NONE:
181 $log_array[AdditionalInformationGenerator::KEY_TEST_REDIRECT_MODE] = $additional_info
182 ->getNoneTag();
183 break;
185 $log_array[AdditionalInformationGenerator::KEY_TEST_REDIRECT_MODE] = $additional_info
186 ->getTagForLangVar('redirect_always');
187 break;
188 case RedirectionModes::IF_KIOSK_ACTIVATED:
189 $log_array[AdditionalInformationGenerator::KEY_TEST_REDIRECT_MODE] = $additional_info
190 ->getTagForLangVar('redirect_in_kiosk_mode');
191 break;
192 }
193
194 return $log_array;
195 }

References ALWAYS, ILIAS\Test\Logging\AdditionalInformationGenerator\getEnabledDisabledTagForBool(), ILIAS\Test\Logging\AdditionalInformationGenerator\getNoneTag(), and ILIAS\Test\Logging\AdditionalInformationGenerator\getTagForLangVar().

+ Here is the call graph for this function:

◆ toStorage()

ILIAS\Test\Settings\MainSettings\SettingsFinishing::toStorage ( )

Reimplemented from ILIAS\Test\Settings\TestSettings.

Definition at line 157 of file SettingsFinishing.php.

157 : array
158 {
159 return [
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()],
165 ];
166 }

References ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ withConcludingRemarksEnabled()

ILIAS\Test\Settings\MainSettings\SettingsFinishing::withConcludingRemarksEnabled ( bool  $concluding_remarks_enabled)

Definition at line 214 of file SettingsFinishing.php.

214 : self
215 {
216 $clone = clone $this;
217 $clone->concluding_remarks_enabled = $concluding_remarks_enabled;
218 return $clone;
219 }

◆ withConcludingRemarksPageId()

ILIAS\Test\Settings\MainSettings\SettingsFinishing::withConcludingRemarksPageId ( ?int  $concluding_remarks_page_id)

Definition at line 226 of file SettingsFinishing.php.

226 : self
227 {
228 $clone = clone $this;
229 $clone->concluding_remarks_page_id = $concluding_remarks_page_id;
230 return $clone;
231 }

◆ withRedirectionMode()

ILIAS\Test\Settings\MainSettings\SettingsFinishing::withRedirectionMode ( RedirectionModes  $redirection_mode)

Definition at line 238 of file SettingsFinishing.php.

238 : self
239 {
240 $clone = clone $this;
241 $clone->redirection_mode = $redirection_mode;
242 return $clone;
243 }

◆ withRedirectionUrl()

ILIAS\Test\Settings\MainSettings\SettingsFinishing::withRedirectionUrl ( ?string  $redirection_url)

Definition at line 250 of file SettingsFinishing.php.

250 : self
251 {
252 $clone = clone $this;
253 $clone->redirection_url = $redirection_url;
254 return $clone;
255 }

◆ withShowAnswerOverview()

ILIAS\Test\Settings\MainSettings\SettingsFinishing::withShowAnswerOverview ( bool  $show_answer_overview)

Definition at line 202 of file SettingsFinishing.php.

202 : self
203 {
204 $clone = clone $this;
205 $clone->show_answer_overview = $show_answer_overview;
206 return $clone;
207 }

Referenced by ILIAS\Test\Settings\MainSettings\SettingsMainGUI\getFinishingSettingsForStorage().

+ Here is the caller graph for this function:

The documentation for this class was generated from the following file: