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

Class for simple answers. More...

+ Inheritance diagram for ASS_AnswerSimple:
+ Collaboration diagram for ASS_AnswerSimple:

Public Member Functions

 __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...
 

Protected Attributes

string $answertext
 
 $points
 
 $order
 
 $id
 

Detailed Description

Class for simple answers.

ASS_AnswerSimple is a class for simple answers used for example in cloze tests with text gap.

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
Maximilian Becker mbeck.nosp@m.er@d.nosp@m.ataba.nosp@m.y.de

\

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

Constructor & Destructor Documentation

◆ __construct()

ASS_AnswerSimple::__construct (   $answertext = "",
  $points = 0.0,
  $order = 0,
  $id = -1 
)

ASS_AnswerSimple constructor.

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

Parameters
string$answertextA string defining the answer text
double$pointsThe number of points given for the selected answer
integer$orderA nonnegative value representing a possible display or sort order
integer$idThe database id of the answer

Reimplemented in ASS_AnswerTrueFalse.

Definition at line 75 of file class.assAnswerSimple.php.

76 {
77 $this->answertext = $answertext;
78 $this->setPoints($points);
79 $this->order = $order;
80 $this->id = $id;
81 }
setPoints($points=0.0)
Sets the points.

References $answertext, $id, $order, $points, and setPoints().

+ Here is the call graph for this function:

Member Function Documentation

◆ checkPoints()

ASS_AnswerSimple::checkPoints (   $a_points)

Checks, if the point value is numeric.

Parameters
$a_pointsdouble Points which are checked if they're numeric.
Returns
boolean true if the point value is numeric, false otherwise
See also
$points

@TODO Find usages and see if this method can be set deprecated due to the simpleton-pattern it is on is_numeric.

Definition at line 136 of file class.assAnswerSimple.php.

136 : bool
137 {
138 return is_numeric($a_points);
139 }

Referenced by setPoints(), ASS_AnswerImagemap\setPointsUnchecked(), and ASS_AnswerMultipleResponse\setPointsUnchecked().

+ Here is the caller graph for this function:

◆ fromNormalized()

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

Restore the object from its normalized representation.

Parameters
array<array-key,mixed>$normalized

Implements ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\FromNormalized.

Reimplemented in ASS_AnswerBinaryState, ASS_AnswerBinaryStateImage, assAnswerCloze, ASS_AnswerImagemap, ASS_AnswerMultipleResponse, ASS_AnswerMultipleResponseImage, and ASS_AnswerTrueFalse.

Definition at line 235 of file class.assAnswerSimple.php.

238 : static
239 {
240 return new static(
241 $transformations->string($normalized['answertext']),
242 $transformations->float($normalized['points']),
243 $transformations->int($normalized['order']),
244 $transformations->denormalize($normalized['id'], Id::class)->getId()
245 );
246 }
denormalize(array|float|bool|int|string|null $normalized, string|object $expected)

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

+ Here is the call graph for this function:

◆ getAnswertext()

◆ getId()

ASS_AnswerSimple::getId ( )

Gets the answer id.

Returns the answer id

Returns
integer answer id
See also
$id

Definition at line 92 of file class.assAnswerSimple.php.

92 : int
93 {
94 return $this->id;
95 }

References $id.

◆ getOrder()

ASS_AnswerSimple::getOrder ( )

Gets the sort/display order.

Returns a nonnegative order value for display or sorting

Returns
integer order
See also
$order

Definition at line 150 of file class.assAnswerSimple.php.

150 : int
151 {
152 return $this->order;
153 }

References $order.

◆ getPoints()

ASS_AnswerSimple::getPoints ( )

Gets the points.

Returns the points

Returns
double points
See also
$points

Definition at line 120 of file class.assAnswerSimple.php.

120 : float
121 {
122 return $this->points;
123 }

References $points.

Referenced by assSingleChoice\getCorrectSolutionForTextOutput(), ASS_AnswerMultipleResponse\getPointsChecked(), assMultipleChoiceGUI\populateSpecificFeedbackInline(), assTextQuestion\toLog(), and assTextSubset\toLog().

+ Here is the caller graph for this function:

◆ setAnswertext()

ASS_AnswerSimple::setAnswertext (   $answertext = "")

Sets the answer text.

Sets the answer text

Parameters
string$answertextThe answer text
See also
$answertext

Definition at line 194 of file class.assAnswerSimple.php.

194 : void
195 {
196 $this->answertext = $answertext;
197 }

References $answertext.

Referenced by assClozeTestGUI\saveNumericGapCorrectionFormProperty().

+ Here is the caller graph for this function:

◆ setId()

ASS_AnswerSimple::setId (   $id = -1)

Sets the answer id.

Parameters
integer$idanswer id
See also
$id

Definition at line 180 of file class.assAnswerSimple.php.

180 : void
181 {
182 $this->id = $id;
183 }

References $id.

◆ setOrder()

ASS_AnswerSimple::setOrder (   $order = 0)

Sets the order.

Sets the nonnegative order value which can be used for sorting or displaying multiple answers

Parameters
integer$orderA nonnegative integer
See also
$order

@TODO Find usage and see if we can get rid of "magic ignorance" of the input value.

Definition at line 166 of file class.assAnswerSimple.php.

166 : void
167 {
168 if ($order >= 0) {
169 $this->order = $order;
170 }
171 }

References $order.

Referenced by assClozeTest\addAnswerOptionValue().

+ Here is the caller graph for this function:

◆ setPoints()

ASS_AnswerSimple::setPoints (   $points = 0.0)

Sets the points.

Sets the points given for selecting the answer. You can even use negative values for wrong answers.

Parameters
double$pointsThe points given for the answer
See also
$points

@TODO Find usages and see if we can get rid of "magic nullification" here.

Definition at line 210 of file class.assAnswerSimple.php.

210 : void
211 {
212 $new_points = str_replace(",", ".", $points);
213 if ($this->checkPoints($new_points)) {
214 $this->points = $new_points;
215 } else {
216 $this->points = 0.0;
217 }
218 }
checkPoints($a_points)
Checks, if the point value is numeric.

References $points, and checkPoints().

Referenced by __construct(), assSingleChoiceGUI\saveCorrectionsFormProperties(), assClozeTestGUI\saveNumericGapCorrectionFormProperty(), and ASS_AnswerMultipleResponse\setPointsChecked().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ toNormalized()

ASS_AnswerSimple::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

Implements ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\ToNormalized.

Reimplemented in ASS_AnswerBinaryState, ASS_AnswerBinaryStateImage, assAnswerCloze, ASS_AnswerImagemap, ASS_AnswerMultipleResponse, ASS_AnswerMultipleResponseImage, and ASS_AnswerTrueFalse.

Definition at line 221 of file class.assAnswerSimple.php.

224 : array|float|bool|int|string|null
225 {
226 return [
227 'id' => $transformations->normalize(new Id($this->id, 'answer')),
228 'answertext' => $this->answertext,
229 'points' => $this->points,
230 'order' => $this->order,
231 ];
232 }
Wrapper object for an object identifier and an optional object type the identifier belongs to.
Definition: Id.php:33

References $answertext, $order, $points, and ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\normalize().

+ Here is the call graph for this function:

Field Documentation

◆ $answertext

◆ $id

◆ $order

◆ $points


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