ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
class.assAnswerMultipleResponse.php
Go to the documentation of this file.
1<?php
2
20
32{
41
53 public function __construct(string $answertext = "", float $points = 0.0, int $order = 0, int $id = -1, int $state = 0)
54 {
56 }
57
58
68 public function getPointsUnchecked(): float
69 {
71 }
72
82 public function setPointsUnchecked($points_unchecked = 0.0): void
83 {
84 $new_points = str_replace(",", ".", $points_unchecked);
85
86 if ($this->checkPoints($new_points)) {
87 $this->points_unchecked = $new_points;
88 } else {
89 $this->points_unchecked = 0.0;
90 }
91 }
92
93 public function setPointsChecked($points_checked): void
94 {
95 $this->setPoints($points_checked);
96 }
97
98 public function getPointsChecked(): float
99 {
100 return $this->getPoints();
101 }
102
103 #[\Override]
104 public function toNormalized(
105 Transformations $transformations,
106 array $context = []
107 ): array|float|bool|int|string|null
108 {
109 return [
110 ...$transformations->normalize(parent::toNormalized($transformations, $context)),
111 'points_unchecked' => $this->points_unchecked,
112 ];
113 }
114
115 #[\Override]
116 public function fromNormalized(
117 array $normalized,
118 Transformations $transformations
119 ): static
120 {
121 $clone = parent::fromNormalized($normalized, $transformations);
122 $clone->points_unchecked = $transformations->nullableFloat($normalized['points_unchecked']);
123 return $clone;
124 }
125}
Class for true/false or yes/no answers.
setPointsUnchecked($points_unchecked=0.0)
Sets the points for an unchecked answer.
toNormalized(Transformations $transformations, array $context=[])
Convert the internal state of the implementing object into a language-neutral array structure.
fromNormalized(array $normalized, Transformations $transformations)
Restore the object from its normalized representation.
__construct(string $answertext="", float $points=0.0, int $order=0, int $id=-1, int $state=0)
ASS_AnswerMultipleResponse constructor.
getPointsUnchecked()
Returns the points for an unchecked answer.
Class for simple answers.
getPoints()
Gets the points.
checkPoints($a_points)
Checks, if the point value is numeric.
setPoints($points=0.0)
Sets the points.
Provides a set of transformations for normalizing and denormalizing values.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc