ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
class.assAnswerImagemap.php
Go to the documentation of this file.
1<?php
2
20
30{
34 protected $area;
35 public string $coords;
36
44 protected $points_unchecked = 0.0;
45
57 public function __construct(
58 $answertext = "",
59 $points = 0.0,
60 $order = 0,
61 $coords = "",
62 $area = "",
63 $id = -1,
65 ) {
67 $this->coords = $coords;
68 $this->area = $area;
69 $this->points_unchecked = $points_unchecked;
70 }
71
72
80 public function getCoords(): string
81 {
82 $this->coords = preg_replace("/\s/", "", $this->coords);
83 return $this->coords;
84 }
85
86
93 public function setCoords(string $coords = ""): void
94 {
95 $coords = preg_replace("/\s/", "", $coords);
96 $this->coords = $coords;
97 }
98
106 public function getArea(): string
107 {
108 return $this->area;
109 }
110
111
112 public function setArea(string $area = ""): void
113 {
114 $this->area = $area;
115 }
116
124 public function getPointsUnchecked()
125 {
127 }
128
138 {
139 $new_points = str_replace(",", ".", $points_unchecked);
140
141 if ($this->checkPoints($new_points)) {
142 $this->points_unchecked = $new_points;
143 } else {
144 $this->points_unchecked = 0.0;
145 }
146 }
147
148 #[\Override]
149 public function toNormalized(
150 Transformations $transformations,
151 array $context = []
152 ): array|float|bool|int|string|null
153 {
154 return [
155 ...$transformations->normalize(parent::toNormalized($transformations, $context)),
156 'coords' => $this->coords,
157 'area' => $this->area,
158 'points_unchecked' => $this->points_unchecked,
159 ];
160 }
161
162 #[\Override]
163 public function fromNormalized(
164 array $normalized,
165 Transformations $transformations
166 ): static
167 {
168 $clone = parent::fromNormalized($normalized, $transformations);
169 $clone->setCoords($transformations->string($normalized['coords']));
170 $clone->setArea($transformations->string($normalized['area']));
171 $clone->setPointsUnchecked($transformations->float($normalized['points_unchecked']));
172 return $clone;
173 }
174}
Class for true/false or yes/no answers.
Class for true/false or yes/no answers.
fromNormalized(array $normalized, Transformations $transformations)
Restore the object from its normalized representation.
__construct( $answertext="", $points=0.0, $order=0, $coords="", $area="", $id=-1, $points_unchecked=0)
ASS_AnswerImagemap constructor.
getArea()
Gets the area of an image map.
setCoords(string $coords="")
Sets the coordinates of an image map.
toNormalized(Transformations $transformations, array $context=[])
Convert the internal state of the implementing object into a language-neutral array structure.
getPointsUnchecked()
Returns the points for an unchecked answer Returns the points for an unchecked answer.
getCoords()
Gets the coordinates of an image map.
setPointsUnchecked($points_unchecked)
Sets the points for an unchecked answer.
checkPoints($a_points)
Checks, if the point value is numeric.
Provides a set of transformations for normalizing and denormalizing values.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc