ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ASS_AnswerImagemap Class Reference

Class for true/false or yes/no answers. More...

+ Inheritance diagram for ASS_AnswerImagemap:
+ Collaboration diagram for ASS_AnswerImagemap:

Public Member Functions

 __construct ( $answertext="", $points=0.0, $order=0, $coords="", $area="", $id=-1, $points_unchecked=0)
 ASS_AnswerImagemap constructor. More...
 
 getCoords ()
 Gets the coordinates of an image map. More...
 
 setCoords (string $coords="")
 Sets the coordinates of an image map. More...
 
 getArea ()
 Gets the area of an image map. More...
 
 setArea (string $area="")
 
 getPointsUnchecked ()
 Returns the points for an unchecked answer Returns the points for an unchecked answer. More...
 
 setPointsUnchecked ($points_unchecked)
 Sets the points for an unchecked answer. More...
 
 toNormalized (Transformations $transformations, array $context=[])
 Convert the internal state of the implementing object into a language-neutral array structure. More...
 
 fromNormalized (array $normalized, Transformations $transformations)
 Restore the object from its normalized representation. More...
 
- Public Member Functions inherited from ASS_AnswerBinaryState
 __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 the ASS_AnswerBinaryState object. More...
 
 getState ()
 Gets the state. More...
 
 isStateChecked ()
 Gets the state. More...
 
 isStateSet ()
 Gets the state. More...
 
 isStateUnset ()
 Gets the state. More...
 
 isStateUnchecked ()
 Gets the state. More...
 
 setState (bool $state=false)
 Sets the state. More...
 
 setChecked ()
 Sets the answer as a checked answer. More...
 
 setSet ()
 Sets the answer as a set answer. More...
 
 setUnset ()
 Sets the answer as a unset answer. More...
 
 setUnchecked ()
 Sets the answer as a unchecked answer. More...
 
 toNormalized (Transformations $transformations, array $context=[])
 Convert the internal state of the implementing object into a language-neutral array structure. More...
 
 fromNormalized (array $normalized, Transformations $transformations)
 Restore the object from its normalized representation. More...
 
- Public Member Functions inherited from ASS_AnswerSimple
 __construct ($answertext="", $points=0.0, $order=0, $id=-1)
 ASS_AnswerSimple constructor. More...
 
 getId ()
 Gets the answer id. More...
 
 getAnswertext ()
 Gets the answer text. More...
 
 getPoints ()
 Gets the points. More...
 
 checkPoints ($a_points)
 Checks, if the point value is numeric. More...
 
 getOrder ()
 Gets the sort/display order. More...
 
 setOrder ($order=0)
 Sets the order. More...
 
 setId ($id=-1)
 Sets the answer id. More...
 
 setAnswertext ($answertext="")
 Sets the answer text. More...
 
 setPoints ($points=0.0)
 Sets the points. More...
 
 toNormalized (Transformations $transformations, array $context=[])
 Convert the internal state of the implementing object into a language-neutral array structure. More...
 
 fromNormalized (array $normalized, Transformations $transformations)
 Restore the object from its normalized representation. More...
 
 toNormalized (Transformations $transformations, array $context=[])
 Convert the internal state of the implementing object into a language-neutral array structure. More...
 
 fromNormalized (array $normalized, Transformations $transformations)
 Restore the object from its normalized representation. More...
 

Data Fields

string $coords
 

Protected Attributes

 $area
 
 $points_unchecked = 0.0
 
- Protected Attributes inherited from ASS_AnswerSimple
string $answertext
 
 $points
 
 $order
 
 $id
 

Detailed Description

Class for true/false or yes/no answers.

ASS_AnswerImagemap is a class for true/false or yes/no answers used for example in multiple choice tests.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m \

Definition at line 29 of file class.assAnswerImagemap.php.

Constructor & Destructor Documentation

◆ __construct()

ASS_AnswerImagemap::__construct (   $answertext = "",
  $points = 0.0,
  $order = 0,
  $coords = "",
  $area = "",
  $id = -1,
  $points_unchecked = 0 
)

ASS_AnswerImagemap constructor.

The constructor takes possible arguments an creates an instance of the ASS_AnswerImagemap object.

Parameters
string$answertextA string defining the answer text
double$pointsThe number of points given for the selected answer
boolean$correctnessA boolean value indicating the correctness of the answer
integer$orderA nonnegative value representing a possible display or sort order @access public

Definition at line 57 of file class.assAnswerImagemap.php.

References ASS_AnswerSimple\$answertext, $area, $coords, ASS_AnswerSimple\$id, ASS_AnswerSimple\$points, $points_unchecked, and ILIAS\GlobalScreen\Provider\__construct().

+ Here is the call graph for this function:

Member Function Documentation

◆ fromNormalized()

ASS_AnswerImagemap::fromNormalized ( array  $normalized,
Transformations  $transformations 
)

Restore the object from its normalized representation.

Parameters
array<array-key,mixed>$normalized

Reimplemented from ASS_AnswerBinaryState.

Definition at line 163 of file class.assAnswerImagemap.php.

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 }

References ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\float(), and ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\string().

+ Here is the call graph for this function:

◆ getArea()

ASS_AnswerImagemap::getArea ( )

Gets the area of an image map.

Returns
string area @access public
See also
$area

Definition at line 106 of file class.assAnswerImagemap.php.

106 : string
107 {
108 return $this->area;
109 }

References $area.

◆ getCoords()

ASS_AnswerImagemap::getCoords ( )

Gets the coordinates of an image map.

Returns
string coords @access public
See also
$coords

Definition at line 80 of file class.assAnswerImagemap.php.

80 : string
81 {
82 $this->coords = preg_replace("/\s/", "", $this->coords);
83 return $this->coords;
84 }

References $coords.

◆ getPointsUnchecked()

ASS_AnswerImagemap::getPointsUnchecked ( )

Returns the points for an unchecked answer Returns the points for an unchecked answer.

Returns
double The points for an unchecked answer @access public
See also
$points_unchecked

Definition at line 124 of file class.assAnswerImagemap.php.

125 {
127 }

References $points_unchecked.

◆ setArea()

ASS_AnswerImagemap::setArea ( string  $area = "")

Definition at line 112 of file class.assAnswerImagemap.php.

112 : void
113 {
114 $this->area = $area;
115 }

References $area.

◆ setCoords()

ASS_AnswerImagemap::setCoords ( string  $coords = "")

Sets the coordinates of an image map.

Parameters
string$coords@access public
See also
$coords

Definition at line 93 of file class.assAnswerImagemap.php.

93 : void
94 {
95 $coords = preg_replace("/\s/", "", $coords);
96 $this->coords = $coords;
97 }

References $coords.

◆ setPointsUnchecked()

ASS_AnswerImagemap::setPointsUnchecked (   $points_unchecked)

Sets the points for an unchecked answer.

Parameters
int | string | null$points_uncheckedThe points for an unchecked answer
See also
$points_unchecked

@TODO Analyze usage and see if we can get rid of "magic nullification" here.

Definition at line 137 of file class.assAnswerImagemap.php.

137 : void
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 }
checkPoints($a_points)
Checks, if the point value is numeric.

References $points_unchecked, and ASS_AnswerSimple\checkPoints().

+ Here is the call graph for this function:

◆ toNormalized()

ASS_AnswerImagemap::toNormalized ( Transformations  $transformations,
array  $context = [] 
)

Convert the internal state of the implementing object into a language-neutral array structure.

The resulting array must contain only null, scalar values (string, int, float, bool) and nested arrays following the same rules.

Parameters
array<string,mixed>$context
Returns
array<array-key, mixed>|float|bool|int|string|null

Reimplemented from ASS_AnswerBinaryState.

Definition at line 149 of file class.assAnswerImagemap.php.

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 }

References $area, $coords, and $points_unchecked.

Field Documentation

◆ $area

ASS_AnswerImagemap::$area
protected

Definition at line 34 of file class.assAnswerImagemap.php.

Referenced by __construct(), getArea(), setArea(), and toNormalized().

◆ $coords

string ASS_AnswerImagemap::$coords

Definition at line 35 of file class.assAnswerImagemap.php.

Referenced by __construct(), getCoords(), setCoords(), and toNormalized().

◆ $points_unchecked

ASS_AnswerImagemap::$points_unchecked = 0.0
protected

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