ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
class.assAnswerBinaryState.php
Go to the documentation of this file.
1<?php
2
20
41{
42 private bool $checked;
43
53 public function __construct(string $answertext = "", float $points = 0.0, int $order = 0, bool $checked = false, int $id = -1)
54 {
56 $this->checked = $checked;
57 }
58
67 public function getState(): bool
68 {
69 return $this->checked;
70 }
71
80 public function isStateChecked(): bool
81 {
82 return $this->checked;
83 }
84
93 public function isStateSet(): bool
94 {
95 return $this->checked;
96 }
97
106 public function isStateUnset(): bool
107 {
108 return !$this->checked;
109 }
110
119 public function isStateUnchecked(): bool
120 {
121 return !$this->checked;
122 }
123
133 public function setState(bool $state = false): void
134 {
135 $this->checked = $state;
136 }
137
145 public function setChecked(): void
146 {
147 $this->checked = true;
148 }
149
157 public function setSet(): void
158 {
159 $this->checked = true;
160 }
161
169 public function setUnset(): void
170 {
171 $this->checked = false;
172 }
173
181 public function setUnchecked(): void
182 {
183 $this->checked = false;
184 }
185
186 #[\Override]
187 public function toNormalized(
188 Transformations $transformations,
189 array $context = []
190 ): array|float|bool|int|string|null
191 {
192 return [
193 ...$transformations->normalize(parent::toNormalized($transformations, $context)),
194 'checked' => $this->checked,
195 ];
196 }
197
198 #[\Override]
199 public function fromNormalized(
200 array $normalized,
201 Transformations $transformations
202 ): static
203 {
204 $clone = parent::fromNormalized($normalized, $transformations);
205 $clone->setState($transformations->bool($normalized['checked']));
206 return $clone;
207 }
208}
Class for true/false or yes/no answers.
setUnchecked()
Sets the answer as a unchecked answer.
setState(bool $state=false)
Sets the state.
toNormalized(Transformations $transformations, array $context=[])
Convert the internal state of the implementing object into a language-neutral array structure.
__construct(string $answertext="", float $points=0.0, int $order=0, bool $checked=false, int $id=-1)
ASS_AnswerBinaryState constructor The constructor takes possible arguments and creates an instance of...
setUnset()
Sets the answer as a unset answer.
setSet()
Sets the answer as a set answer.
fromNormalized(array $normalized, Transformations $transformations)
Restore the object from its normalized representation.
setChecked()
Sets the answer as a checked answer.
Class for simple answers.
Provides a set of transformations for normalizing and denormalizing values.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc