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

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

+ Inheritance diagram for ASS_AnswerMultipleResponseImage:
+ Collaboration diagram for ASS_AnswerMultipleResponseImage:

Public Member Functions

 __construct (string $answertext='', float $points=0.0, int $order=0, int $id=-1, int $state=0)
 ASS_AnswerMultipleResponse constructor. 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_AnswerMultipleResponse
 __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

string $image = null
 
- Data Fields inherited from ASS_AnswerMultipleResponse
 $points_unchecked
 

Additional Inherited Members

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

Detailed Description

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

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

Definition at line 36 of file class.assAnswerMultipleResponseImage.php.

Constructor & Destructor Documentation

◆ __construct()

ASS_AnswerMultipleResponseImage::__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
integer$orderA nonnegative value representing a possible display or sort order
double$points_uncheckedThe points when the answer is not checked
string$a_imageThe image filename
integer$idThe database id of the answer @access public

Reimplemented from ASS_AnswerMultipleResponse.

Definition at line 53 of file class.assAnswerMultipleResponseImage.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_AnswerMultipleResponseImage::fromNormalized ( array  $normalized,
Transformations  $transformations 
)

Restore the object from its normalized representation.

Parameters
array<array-key,mixed>$normalized

Reimplemented from ASS_AnswerMultipleResponse.

Definition at line 96 of file class.assAnswerMultipleResponseImage.php.

99 : static
100 {
101 $clone = parent::fromNormalized($normalized, $transformations);
102 $clone->setImage($transformations->denormalize($normalized['image'], QuestionImage::class)?->getFilename());
103 return $clone;
104 }
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_AnswerMultipleResponseImage::getImage ( )

Definition at line 63 of file class.assAnswerMultipleResponseImage.php.

63 : ?string
64 {
65 return $this->image;
66 }

References $image.

Referenced by assMultipleChoiceGUI\buildAnswerPresentationForStatistics().

+ Here is the caller graph for this function:

◆ hasImage()

ASS_AnswerMultipleResponseImage::hasImage ( )

Definition at line 76 of file class.assAnswerMultipleResponseImage.php.

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

◆ setImage()

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

Definition at line 68 of file class.assAnswerMultipleResponseImage.php.

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

References $image.

◆ toNormalized()

ASS_AnswerMultipleResponseImage::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_AnswerMultipleResponse.

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

85 : array|float|bool|int|string|null
86 {
87 return [
88 ...$transformations->normalize(parent::toNormalized($transformations, $context)),
89 'image' => $this->image
90 ? $transformations->normalize(new QuestionImage($this->image, $context['question_id'] ?? null))
91 : null,
92 ];
93 }
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_AnswerMultipleResponseImage::$image = null

Definition at line 38 of file class.assAnswerMultipleResponseImage.php.

Referenced by getImage(), and setImage().


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