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

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

+ Inheritance diagram for ASS_AnswerMultipleResponse:
+ Collaboration diagram for ASS_AnswerMultipleResponse:

Public Member Functions

 __construct (string $answertext="", float $points=0.0, int $order=0, int $id=-1, int $state=0)
 ASS_AnswerMultipleResponse constructor. More...
 
 getPointsUnchecked ()
 Returns the points for an unchecked answer. More...
 
 setPointsUnchecked ($points_unchecked=0.0)
 Sets the points for an unchecked answer. More...
 
 setPointsChecked ($points_checked)
 
 getPointsChecked ()
 
 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

 $points_unchecked
 

Additional Inherited Members

- Protected Attributes inherited from ASS_AnswerSimple
string $answertext
 
 $points
 
 $order
 
 $id
 

Detailed Description

Class for true/false or yes/no answers.

ASS_AnswerMultipleResponse is a class for answers with a binary state indicator (checked/unchecked, set/unset)

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
Version
$Id$ \
See also
ASS_AnswerSimple

Definition at line 31 of file class.assAnswerMultipleResponse.php.

Constructor & Destructor Documentation

◆ __construct()

ASS_AnswerMultipleResponse::__construct ( string  $answertext = "",
float  $points = 0.0,
int  $order = 0,
int  $id = -1,
int  $state = 0 
)

ASS_AnswerMultipleResponse constructor.

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

Parameters
string$answertextA string defining the answer text
double$pointsThe number of points given for the selected answer
double$points_uncheckedThe points when the answer is not checked
integer$orderA nonnegative value representing a possible display or sort order @access public

Reimplemented in ASS_AnswerMultipleResponseImage.

Definition at line 53 of file class.assAnswerMultipleResponse.php.

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

+ Here is the call graph for this function:

Member Function Documentation

◆ fromNormalized()

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

Restore the object from its normalized representation.

Parameters
array<array-key,mixed>$normalized

Reimplemented from ASS_AnswerSimple.

Reimplemented in ASS_AnswerMultipleResponseImage.

Definition at line 116 of file class.assAnswerMultipleResponse.php.

119 : static
120 {
121 $clone = parent::fromNormalized($normalized, $transformations);
122 $clone->points_unchecked = $transformations->nullableFloat($normalized['points_unchecked']);
123 return $clone;
124 }

References ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\nullableFloat().

+ Here is the call graph for this function:

◆ getPointsChecked()

ASS_AnswerMultipleResponse::getPointsChecked ( )

Definition at line 98 of file class.assAnswerMultipleResponse.php.

98 : float
99 {
100 return $this->getPoints();
101 }
getPoints()
Gets the points.

References ASS_AnswerSimple\getPoints().

+ Here is the call graph for this function:

◆ getPointsUnchecked()

ASS_AnswerMultipleResponse::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 68 of file class.assAnswerMultipleResponse.php.

References $points_unchecked.

◆ setPointsChecked()

ASS_AnswerMultipleResponse::setPointsChecked (   $points_checked)

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

93 : void
94 {
95 $this->setPoints($points_checked);
96 }
setPoints($points=0.0)
Sets the points.

References ASS_AnswerSimple\setPoints().

Referenced by assMultipleChoiceGUI\saveCorrectionsFormProperties().

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

◆ setPointsUnchecked()

ASS_AnswerMultipleResponse::setPointsUnchecked (   $points_unchecked = 0.0)

Sets the points for an unchecked answer.

Sets the points for an unchecked answer

Parameters
double$points_uncheckedThe points for an unchecked answer @access public
See also
$state

Definition at line 82 of file class.assAnswerMultipleResponse.php.

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

References $points_unchecked, and ASS_AnswerSimple\checkPoints().

Referenced by assMultipleChoiceGUI\saveCorrectionsFormProperties().

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

◆ toNormalized()

ASS_AnswerMultipleResponse::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_AnswerSimple.

Reimplemented in ASS_AnswerMultipleResponseImage.

Definition at line 104 of file class.assAnswerMultipleResponse.php.

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 }

References $points_unchecked.

Field Documentation

◆ $points_unchecked

ASS_AnswerMultipleResponse::$points_unchecked

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