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

Class for error text answers. More...

+ Inheritance diagram for assAnswerErrorText:
+ Collaboration diagram for assAnswerErrorText:

Public Member Functions

 __construct (string $text_wrong="", string $text_correct="", float $points=0.0, ?int $position=null)
 assAnswerErrorText constructor More...
 
 getTextWrong ()
 
 getTextCorrect ()
 
 getPoints ()
 
 withPoints (float $points)
 
 getPosition ()
 
 withPosition (int $position)
 
 getLength ()
 
 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 $text_wrong
 
string $text_correct
 
float $points
 
int $position
 
int $length
 

Detailed Description

Class for error text answers.

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

\

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

Constructor & Destructor Documentation

◆ __construct()

assAnswerErrorText::__construct ( string  $text_wrong = "",
string  $text_correct = "",
float  $points = 0.0,
?int  $position = null 
)

assAnswerErrorText constructor

Parameters
string$text_wrongWrong text
string$text_correctCorrect text
double$pointsPoints

Definition at line 45 of file class.assAnswerErrorText.php.

50 {
51 $this->text_wrong = $text_wrong;
52 $this->text_correct = $text_correct;
53 $this->points = $points;
54 $this->position = $position;
55
56 $word_array = preg_split("/\s+/", $text_wrong);
57
58 if ($word_array) {
59 $this->length = count($word_array);
60 }
61 }

References $points, $position, $text_correct, and $text_wrong.

Member Function Documentation

◆ fromNormalized()

assAnswerErrorText::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 117 of file class.assAnswerErrorText.php.

120 : self
121 {
122 return new self(
123 $transformations->string($normalized['text_wrong']),
124 $transformations->string($normalized['text_correct']),
125 $transformations->float($normalized['points']),
126 $transformations->int($normalized['position'])
127 );
128 }

References ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\float(), ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\int(), and ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\string().

+ Here is the call graph for this function:

◆ getLength()

assAnswerErrorText::getLength ( )

Definition at line 97 of file class.assAnswerErrorText.php.

97 : int
98 {
99 return $this->length;
100 }

References $length.

◆ getPoints()

assAnswerErrorText::getPoints ( )

Definition at line 73 of file class.assAnswerErrorText.php.

73 : float
74 {
75 return $this->points;
76 }

References $points.

◆ getPosition()

assAnswerErrorText::getPosition ( )

Definition at line 85 of file class.assAnswerErrorText.php.

85 : ?int
86 {
87 return $this->position;
88 }

References $position.

◆ getTextCorrect()

assAnswerErrorText::getTextCorrect ( )

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

68 : string
69 {
71 }

References $text_correct.

◆ getTextWrong()

assAnswerErrorText::getTextWrong ( )

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

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

References $text_wrong.

Referenced by assErrorText\addPositionToErrorAnswer().

+ Here is the caller graph for this function:

◆ toNormalized()

assAnswerErrorText::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 103 of file class.assAnswerErrorText.php.

106 : array|float|bool|int|string|null
107 {
108 return [
109 'text_wrong' => $this->text_wrong,
110 'text_correct' => $this->text_correct,
111 'points' => $this->points,
112 'position' => $this->position,
113 ];
114 }

References $points, $position, $text_correct, and $text_wrong.

◆ withPoints()

assAnswerErrorText::withPoints ( float  $points)

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

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

References $points.

◆ withPosition()

assAnswerErrorText::withPosition ( int  $position)

Definition at line 90 of file class.assAnswerErrorText.php.

90 : self
91 {
92 $clone = clone $this;
93 $clone->position = $position;
94 return $clone;
95 }

References $position.

Referenced by assErrorText\addPositionToErrorAnswer().

+ Here is the caller graph for this function:

Field Documentation

◆ $length

int assAnswerErrorText::$length
protected

Definition at line 37 of file class.assAnswerErrorText.php.

Referenced by getLength().

◆ $points

float assAnswerErrorText::$points
protected

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

Referenced by __construct(), getPoints(), toNormalized(), and withPoints().

◆ $position

int assAnswerErrorText::$position
protected

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

Referenced by __construct(), getPosition(), toNormalized(), and withPosition().

◆ $text_correct

string assAnswerErrorText::$text_correct
protected

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

Referenced by __construct(), getTextCorrect(), and toNormalized().

◆ $text_wrong

string assAnswerErrorText::$text_wrong
protected

Definition at line 33 of file class.assAnswerErrorText.php.

Referenced by __construct(), getTextWrong(), and toNormalized().


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