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

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

+ Inheritance diagram for ASS_AnswerBinaryState:
+ Collaboration diagram for ASS_AnswerBinaryState:

Public Member Functions

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

Private Attributes

bool $checked
 

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_AnswerBinaryState is a class for answers with a binary state indicator (checked/unchecked, set/unset)

Todo:

Get rid of duplicate methods (hiding behind different names.

Rework class to use a true binary state (boolean) instead of integer

Rename class to something that matches the filename properly.

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
Version
$Id$

\

See also
ASS_AnswerSimple

Definition at line 40 of file class.assAnswerBinaryState.php.

Constructor & Destructor Documentation

◆ __construct()

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.

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$stateA integer value indicating the state of the answer
integer$idThe database id of the answer

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

References ASS_AnswerSimple\$answertext, $checked, ASS_AnswerSimple\$id, ASS_AnswerSimple\$order, ASS_AnswerSimple\$points, ILIAS\GlobalScreen\Provider\__construct(), and ILIAS\UI\examples\Symbol\Glyph\Checked\checked().

+ Here is the call graph for this function:

Member Function Documentation

◆ fromNormalized()

ASS_AnswerBinaryState::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_AnswerBinaryStateImage, and ASS_AnswerImagemap.

Definition at line 199 of file class.assAnswerBinaryState.php.

202 : static
203 {
204 $clone = parent::fromNormalized($normalized, $transformations);
205 $clone->setState($transformations->bool($normalized['checked']));
206 return $clone;
207 }

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

+ Here is the call graph for this function:

◆ getState()

ASS_AnswerBinaryState::getState ( )

Gets the state.

Returns the state of the answer

Returns
boolean state
See also
$state

Definition at line 67 of file class.assAnswerBinaryState.php.

67 : bool
68 {
69 return $this->checked;
70 }

References $checked.

◆ isStateChecked()

ASS_AnswerBinaryState::isStateChecked ( )

Gets the state.

Returns the answer state

Returns
boolean state
See also
$state

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

80 : bool
81 {
82 return $this->checked;
83 }

References $checked.

◆ isStateSet()

ASS_AnswerBinaryState::isStateSet ( )

Gets the state.

Returns the answer state

Returns
boolean state
See also
$state

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

93 : bool
94 {
95 return $this->checked;
96 }

References $checked.

◆ isStateUnchecked()

ASS_AnswerBinaryState::isStateUnchecked ( )

Gets the state.

Returns the answer state

Returns
boolean state
See also
$state

Definition at line 119 of file class.assAnswerBinaryState.php.

119 : bool
120 {
121 return !$this->checked;
122 }

References $checked.

◆ isStateUnset()

ASS_AnswerBinaryState::isStateUnset ( )

Gets the state.

Returns the answer state

Returns
boolean state
See also
$state

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

106 : bool
107 {
108 return !$this->checked;
109 }

References $checked.

◆ setChecked()

ASS_AnswerBinaryState::setChecked ( )

Sets the answer as a checked answer.

Sets the state value of the answer to 1

See also
$state

Definition at line 145 of file class.assAnswerBinaryState.php.

145 : void
146 {
147 $this->checked = true;
148 }

References ILIAS\UI\examples\Symbol\Glyph\Checked\checked().

+ Here is the call graph for this function:

◆ setSet()

ASS_AnswerBinaryState::setSet ( )

Sets the answer as a set answer.

Sets the state value of the answer to 1

See also
$state

Definition at line 157 of file class.assAnswerBinaryState.php.

157 : void
158 {
159 $this->checked = true;
160 }

References ILIAS\UI\examples\Symbol\Glyph\Checked\checked().

+ Here is the call graph for this function:

◆ setState()

ASS_AnswerBinaryState::setState ( bool  $state = false)

Sets the state.

Sets the state of the answer using 1 or 0 as indicator

Parameters
bool | int$stateA integer value indicating the state of the answer
See also
$state

Definition at line 133 of file class.assAnswerBinaryState.php.

133 : void
134 {
135 $this->checked = $state;
136 }

References ILIAS\UI\examples\Symbol\Glyph\Checked\checked().

+ Here is the call graph for this function:

◆ setUnchecked()

ASS_AnswerBinaryState::setUnchecked ( )

Sets the answer as a unchecked answer.

Sets the state value of the answer to 0

See also
$state

Definition at line 181 of file class.assAnswerBinaryState.php.

181 : void
182 {
183 $this->checked = false;
184 }

References ILIAS\UI\examples\Symbol\Glyph\Checked\checked().

+ Here is the call graph for this function:

◆ setUnset()

ASS_AnswerBinaryState::setUnset ( )

Sets the answer as a unset answer.

Sets the state value of the answer to 0

See also
$state

Definition at line 169 of file class.assAnswerBinaryState.php.

169 : void
170 {
171 $this->checked = false;
172 }

References ILIAS\UI\examples\Symbol\Glyph\Checked\checked().

+ Here is the call graph for this function:

◆ toNormalized()

ASS_AnswerBinaryState::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_AnswerBinaryStateImage, and ASS_AnswerImagemap.

Definition at line 187 of file class.assAnswerBinaryState.php.

190 : array|float|bool|int|string|null
191 {
192 return [
193 ...$transformations->normalize(parent::toNormalized($transformations, $context)),
194 'checked' => $this->checked,
195 ];
196 }

References $checked.

Field Documentation

◆ $checked

bool ASS_AnswerBinaryState::$checked
private

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