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

Class for matching question terms. More...

+ Inheritance diagram for assAnswerMatchingTerm:
+ Collaboration diagram for assAnswerMatchingTerm:

Public Member Functions

 __construct (string $text="", string $picture="", int $identifier=0)
 
 getText ()
 
 withText (string $text)
 
 getPicture ()
 
 withPicture (string $picture)
 
 getIdentifier ()
 
 withIdentifier (int $identifier)
 
 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 Member Functions

 createIdentifier ()
 

Protected Attributes

string $text
 
string $picture
 
int $identifier
 

Detailed Description

Class for matching question terms.

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 \

Definition at line 32 of file class.assAnswerMatchingTerm.php.

Constructor & Destructor Documentation

◆ __construct()

assAnswerMatchingTerm::__construct ( string  $text = "",
string  $picture = "",
int  $identifier = 0 
)

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

39 {
40 $this->text = $text;
41 $this->picture = $picture;
42
43 $this->identifier = ($identifier !== 0) ? $identifier : $this->createIdentifier();
44 }

References $identifier, $picture, $text, and createIdentifier().

+ Here is the call graph for this function:

Member Function Documentation

◆ createIdentifier()

assAnswerMatchingTerm::createIdentifier ( )
protected

Definition at line 46 of file class.assAnswerMatchingTerm.php.

46 : int
47 {
48 $id = random_int(1, 100000);
49 return $id;
50 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

References $id.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ fromNormalized()

assAnswerMatchingTerm::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.

Definition at line 101 of file class.assAnswerMatchingTerm.php.

104 : self
105 {
106 return $this->withText($transformations->string($normalized['text']))
107 ->withPicture($transformations->denormalize($normalized['picture'], QuestionImage::class)?->getFilename() ?? '')
108 ->withIdentifier($transformations->int($normalized['identifier']));
109 }
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\int(), ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\string(), and withText().

+ Here is the call graph for this function:

◆ getIdentifier()

assAnswerMatchingTerm::getIdentifier ( )

Definition at line 74 of file class.assAnswerMatchingTerm.php.

74 : int
75 {
76 return $this->identifier;
77 }

References $identifier.

Referenced by assMatchingQuestionGUI\buildTermHtml(), and assMatchingQuestionGUI\populateDefinition().

+ Here is the caller graph for this function:

◆ getPicture()

assAnswerMatchingTerm::getPicture ( )

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

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

References $picture.

Referenced by assMatchingQuestionGUI\buildTermHtml(), and assMatchingQuestionGUI\populateDefinition().

+ Here is the caller graph for this function:

◆ getText()

assAnswerMatchingTerm::getText ( )

Definition at line 52 of file class.assAnswerMatchingTerm.php.

52 : string
53 {
54 return $this->text;
55 }

References $text.

Referenced by assMatchingQuestionGUI\buildTermHtml(), and assMatchingQuestionGUI\populateDefinition().

+ Here is the caller graph for this function:

◆ toNormalized()

assAnswerMatchingTerm::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.

Definition at line 86 of file class.assAnswerMatchingTerm.php.

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

References $identifier, $text, and ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\normalize().

+ Here is the call graph for this function:

◆ withIdentifier()

assAnswerMatchingTerm::withIdentifier ( int  $identifier)

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

78 : self
79 {
80 $clone = clone $this;
81 $clone->identifier = $identifier;
82 return $clone;
83 }

References $identifier.

◆ withPicture()

assAnswerMatchingTerm::withPicture ( string  $picture)

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

67 : self
68 {
69 $clone = clone $this;
70 $clone->picture = $picture;
71 return $clone;
72 }

References $picture.

◆ withText()

assAnswerMatchingTerm::withText ( string  $text)

Definition at line 56 of file class.assAnswerMatchingTerm.php.

56 : self
57 {
58 $clone = clone $this;
59 $clone->text = $text;
60 return $clone;
61 }

References $text.

Referenced by fromNormalized().

+ Here is the caller graph for this function:

Field Documentation

◆ $identifier

int assAnswerMatchingTerm::$identifier
protected

◆ $picture

string assAnswerMatchingTerm::$picture
protected

Definition at line 35 of file class.assAnswerMatchingTerm.php.

Referenced by __construct(), getPicture(), and withPicture().

◆ $text

string assAnswerMatchingTerm::$text
protected

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

Referenced by __construct(), getText(), toNormalized(), and withText().


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