ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
class.assAnswerMatching.php
Go to the documentation of this file.
1<?php
2
22
32{
33 public float $points;
34
43
51 public $term_id;
52
61
73 public function __construct(
74 $points = 0.0,
75 $term_id = 0,
78 ) {
79 $this->term_id = $term_id;
80 $this->picture_or_definition = $picture_or_definition;
81 $this->picture_or_definition_id = $picture_or_definition_id;
82 $this->points = $points;
83 }
84
93 public function getPoints(): float
94 {
95 return $this->points;
96 }
97
106 public function getTermId(): int
107 {
108 return $this->term_id;
109 }
110
119 public function getPicture(): string
120 {
122 }
123
132 public function getDefinition(): string
133 {
135 }
136
145 public function getPictureId(): int
146 {
148 }
149
158 public function getDefinitionId(): int
159 {
161 }
162
172 public function setTermId($term_id = 0): void
173 {
174 if ($term_id >= 0) {
175 $this->term_id = $term_id;
176 }
177 }
178
186 public function setPictureId(int $picture_id = 0): void
187 {
188 if ($picture_id >= 0) {
189 $this->picture_or_definition_id = $picture_id;
190 }
191 }
192
200 public function setDefinitionId(int $definition_id = 0): void
201 {
202 if ($definition_id >= 0) {
203 $this->picture_or_definition_id = $definition_id;
204 }
205 }
206
214 public function setPicture(string $picture = ""): void
215 {
216 $this->picture_or_definition = $picture;
217 }
218
226 public function setDefinition(string $definition = ""): void
227 {
228 $this->picture_or_definition = $definition;
229 }
230
231
239 public function setPoints(float $points = 0.0): void
240 {
241 $this->points = $points;
242 }
243
244 #[\Override]
245 public function toNormalized(
246 Transformations $transformations,
247 array $context = []
248 ): array|float|bool|int|string|null
249 {
250 return [
251 'points' => $this->points,
252 'picture_or_definition' => $this->picture_or_definition,
253 'picture_or_definition_id' => $this->picture_or_definition_id,
254 'term_id' => $this->term_id,
255 ];
256 }
257
258 #[\Override]
259 public function fromNormalized(
260 array $normalized,
261 Transformations $transformations
262 ): static
263 {
264 $clone = clone $this;
265 $clone->setPoints($transformations->float($normalized['points']));
266 $clone->setPicture($transformations->string($normalized['picture_or_definition']));
267 $clone->setPictureId($transformations->int($normalized['picture_or_definition_id']));
268 $clone->setTermId($transformations->int($normalized['term_id']));
269 return $clone;
270 }
271}
Class for matching question answers.
__construct( $points=0.0, $term_id=0, $picture_or_definition="", $picture_or_definition_id=0)
ASS_AnswerMatching constructor.
setDefinition(string $definition="")
Sets the definition Sets the definition.
setPicture(string $picture="")
Sets the picture Sets the picture.
setPictureId(int $picture_id=0)
Sets the picture id Sets the nonnegative picture identifier which can be used for sorting or displayi...
getTermId()
Gets the term id.
fromNormalized(array $normalized, Transformations $transformations)
Restore the object from its normalized representation.
setPoints(float $points=0.0)
Sets the points Sets the points given for selecting the answer.
setDefinitionId(int $definition_id=0)
Sets the definition id Sets the nonnegative definition identifier which can be used for sorting or di...
getPictureId()
Gets the picture identifier.
getPicture()
Gets the picture.
getPoints()
Gets the points.
getDefinition()
Gets the definition.
toNormalized(Transformations $transformations, array $context=[])
Convert the internal state of the implementing object into a language-neutral array structure.
setTermId($term_id=0)
Sets the term id.
getDefinitionId()
Gets the definition identifier.
Provides a set of transformations for normalizing and denormalizing values.