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

Class for answers with a binary state indicator. More...

+ Inheritance diagram for ASS_AnswerBinaryStateImage:
+ Collaboration diagram for ASS_AnswerBinaryStateImage:

Public Member Functions

 __construct (string $answertext='', float $points=0.0, int $order=0, bool $state=false, ?string $a_image=null, int $id=-1)
 ASS_AnswerBinaryStateImage constructor The constructor takes possible arguments an creates an instance of the ASS_AnswerBinaryStateImage object. More...
 
 getImage ()
 
 setImage (?string $image=null)
 
 hasImage ()
 
 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...
 

Protected Attributes

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

Detailed Description

Class for answers with a binary state indicator.

ASS_AnswerBinaryStateImage is a class for answers with a binary state indicator (checked/unchecked, set/unset) and an image file

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 39 of file class.assAnswerBinaryStateImage.php.

Constructor & Destructor Documentation

◆ __construct()

ASS_AnswerBinaryStateImage::__construct ( string  $answertext = '',
float  $points = 0.0,
int  $order = 0,
bool  $state = false,
?string  $a_image = null,
int  $id = -1 
)

ASS_AnswerBinaryStateImage constructor The constructor takes possible arguments an creates an instance of the ASS_AnswerBinaryStateImage 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
bool$stateA boolen value indicating the state of the answer
?string$a_image The image filename
integer$idThe database id of the answer

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

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

+ Here is the call graph for this function:

Member Function Documentation

◆ fromNormalized()

ASS_AnswerBinaryStateImage::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 98 of file class.assAnswerBinaryStateImage.php.

101 : static
102 {
103 $clone = parent::fromNormalized($normalized, $transformations);
104 $clone->setImage($transformations->denormalize($normalized['image'], QuestionImage::class)?->getFilename());
105 return $clone;
106 }
denormalize(array|float|bool|int|string|null $normalized, string|object $expected)

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

+ Here is the call graph for this function:

◆ getImage()

ASS_AnswerBinaryStateImage::getImage ( )

Definition at line 65 of file class.assAnswerBinaryStateImage.php.

65 : ?string
66 {
67 return $this->image;
68 }

References $image.

Referenced by assSingleChoiceGUI\buildAnswerPresentationForStatistics().

+ Here is the caller graph for this function:

◆ hasImage()

ASS_AnswerBinaryStateImage::hasImage ( )

Definition at line 78 of file class.assAnswerBinaryStateImage.php.

78 : bool
79 {
80 return $this->image !== null;
81 }

◆ setImage()

ASS_AnswerBinaryStateImage::setImage ( ?string  $image = null)

Definition at line 70 of file class.assAnswerBinaryStateImage.php.

70 : void
71 {
72 if ($image === '') {
73 throw new \Exception('imagename must not be empty');
74 }
75 $this->image = $image;
76 }

References $image.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ toNormalized()

ASS_AnswerBinaryStateImage::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 84 of file class.assAnswerBinaryStateImage.php.

87 : array|float|bool|int|string|null
88 {
89 return [
90 ...$transformations->normalize(parent::toNormalized($transformations, $context)),
91 'image' => $this->image ?
92 $transformations->normalize(new QuestionImage($this->image, $context['question_id'] ?? null))
93 : null,
94 ];
95 }
Wrapper object for an image file within a question (e.g.

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

+ Here is the call graph for this function:

Field Documentation

◆ $image

string ASS_AnswerBinaryStateImage::$image = null
protected

Definition at line 41 of file class.assAnswerBinaryStateImage.php.

Referenced by getImage(), and setImage().


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