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

Formula Question Unit. More...

+ Inheritance diagram for assFormulaQuestionUnit:
+ Collaboration diagram for assFormulaQuestionUnit:

Public Member Functions

 initFormArray (array $data)
 
 setId (int $id)
 
 getId ()
 
 setUnit (string $unit)
 
 getUnit ()
 
 getSanitizedUnit ()
 
 setSequence (int $sequence)
 
 getSequence ()
 
 setFactor (float $factor)
 
 getFactor ()
 
 setBaseUnit (int $baseunit)
 
 getBaseUnit ()
 
 setBaseunitTitle (?string $baseunit_title)
 
 getBaseunitTitle ()
 
 getSanitizedBaseunitTitle ()
 
 setCategory (int $category)
 
 getCategory ()
 
 getDisplayString ()
 
 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...
 

Static Public Member Functions

static lookupUnitFactor (int $a_unit_id)
 

Private Member Functions

 sanitizeString (string $string)
 

Private Attributes

int $id = 0
 
string $unit = ''
 
float $factor = 0.0
 
int $category = 0
 
int $sequence = 0
 
int $baseunit = 0
 
string $baseunit_title = null
 

Detailed Description

Formula Question Unit.

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 31 of file class.assFormulaQuestionUnit.php.

Member Function Documentation

◆ fromNormalized()

assFormulaQuestionUnit::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 186 of file class.assFormulaQuestionUnit.php.

189 : static
190 {
191 $clone = clone $this;
192 $clone->id = $transformations->denormalize($normalized['id'], Id::class)->getId();
193 $clone->unit = $transformations->string($normalized['unit']);
194 $clone->factor = $transformations->float($normalized['factor']);
195 $clone->category = $transformations->denormalize($normalized['category_id'], Id::class)->getId();
196 $clone->sequence = $transformations->int($normalized['sequence']);
197 $clone->baseunit = $transformations->denormalize($normalized['baseunit'], Id::class)->getId();
198 $clone->baseunit_title = $transformations->string($normalized['baseunit_title']);
199
200 return $clone;
201 }
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\float(), ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\int(), and ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\string().

+ Here is the call graph for this function:

◆ getBaseUnit()

assFormulaQuestionUnit::getBaseUnit ( )

Definition at line 102 of file class.assFormulaQuestionUnit.php.

102 : int
103 {
104 if ($this->baseunit > 0) {
105 return $this->baseunit;
106 }
107
108 return $this->id;
109 }

References $baseunit, and $id.

Referenced by ilUnitConfigurationRepository\saveUnit().

+ Here is the caller graph for this function:

◆ getBaseunitTitle()

assFormulaQuestionUnit::getBaseunitTitle ( )

Definition at line 116 of file class.assFormulaQuestionUnit.php.

116 : ?string
117 {
119 }

References $baseunit_title.

Referenced by getSanitizedBaseunitTitle().

+ Here is the caller graph for this function:

◆ getCategory()

assFormulaQuestionUnit::getCategory ( )

Definition at line 131 of file class.assFormulaQuestionUnit.php.

131 : int
132 {
133 return $this->category;
134 }

References $category.

Referenced by ilUnitConfigurationRepository\createNewUnit(), and ilUnitConfigurationRepository\saveUnit().

+ Here is the caller graph for this function:

◆ getDisplayString()

assFormulaQuestionUnit::getDisplayString ( )

Definition at line 136 of file class.assFormulaQuestionUnit.php.

136 : string
137 {
138 global $DIC;
139
140 $unit = $this->getUnit();
141 $txt = $DIC->language()->txt("qpl_qst_formulaquestion_{$unit}");
142 return strcmp("-qpl_qst_formulaquestion_{$unit}-", $txt) !== 0
143 ? $this->sanitizeString($txt)
144 : $this->getSanitizedUnit();
145 }
global $DIC
Definition: shib_login.php:26

References $DIC, $unit, getSanitizedUnit(), getUnit(), and sanitizeString().

+ Here is the call graph for this function:

◆ getFactor()

assFormulaQuestionUnit::getFactor ( )

Definition at line 92 of file class.assFormulaQuestionUnit.php.

92 : float
93 {
94 return $this->factor;
95 }

References $factor.

Referenced by ilUnitConfigurationRepository\saveUnit().

+ Here is the caller graph for this function:

◆ getId()

assFormulaQuestionUnit::getId ( )

Definition at line 57 of file class.assFormulaQuestionUnit.php.

57 : int
58 {
59 return $this->id;
60 }

References $id.

Referenced by ilUnitConfigurationRepository\addUnit(), assFormulaQuestionResult\getResultInfo(), and ilUnitConfigurationRepository\saveUnit().

+ Here is the caller graph for this function:

◆ getSanitizedBaseunitTitle()

assFormulaQuestionUnit::getSanitizedBaseunitTitle ( )

Definition at line 121 of file class.assFormulaQuestionUnit.php.

121 : ?string
122 {
123 return $this->sanitizeString($this->getBaseunitTitle() ?? '');
124 }

References getBaseunitTitle(), and sanitizeString().

+ Here is the call graph for this function:

◆ getSanitizedUnit()

assFormulaQuestionUnit::getSanitizedUnit ( )

Definition at line 72 of file class.assFormulaQuestionUnit.php.

72 : string
73 {
74 return htmlspecialchars($this->getUnit(), ENT_QUOTES | ENT_SUBSTITUTE, 'utf-8');
75 }

References getUnit().

Referenced by getDisplayString().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSequence()

assFormulaQuestionUnit::getSequence ( )

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

82 : int
83 {
84 return $this->sequence;
85 }

References $sequence.

Referenced by ilUnitConfigurationRepository\saveUnit().

+ Here is the caller graph for this function:

◆ getUnit()

assFormulaQuestionUnit::getUnit ( )

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

67 : string
68 {
69 return $this->unit;
70 }

References $unit.

Referenced by ilUnitConfigurationRepository\createNewUnit(), getDisplayString(), getSanitizedUnit(), and ilUnitConfigurationRepository\saveUnit().

+ Here is the caller graph for this function:

◆ initFormArray()

assFormulaQuestionUnit::initFormArray ( array  $data)

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

41 : void
42 {
43 $this->id = (int) $data['unit_id'];
44 $this->unit = $data['unit'];
45 $this->factor = (float) $data['factor'];
46 $this->baseunit = (int) $data['baseunit_fi'];
47 $this->baseunit_title = $data['baseunit_title'] ?? null;
48 $this->category = (int) $data['category_fi'];
49 $this->sequence = (int) $data['sequence'];
50 }
$data
Definition: storeScorm.php:45

References $data, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ lookupUnitFactor()

static assFormulaQuestionUnit::lookupUnitFactor ( int  $a_unit_id)
static

Definition at line 147 of file class.assFormulaQuestionUnit.php.

147 : float
148 {
149 global $DIC;
150 $ilDB = $DIC['ilDB'];
151
152 $res = $ilDB->queryF(
153 'SELECT factor FROM il_qpl_qst_fq_unit WHERE unit_id = %s',
154 ['integer'],
155 [$a_unit_id]
156 );
157
158 $row = $ilDB->fetchAssoc($res);
159
160 return (float) $row['factor'];
161 }
foreach($_POST as $key=> $value) $res

References $DIC, $ilDB, and $res.

Referenced by assFormulaQuestion\getBestSolution().

+ Here is the caller graph for this function:

◆ sanitizeString()

assFormulaQuestionUnit::sanitizeString ( string  $string)
private

Definition at line 163 of file class.assFormulaQuestionUnit.php.

163 : string
164 {
165 return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, 'utf-8');
166 }

Referenced by getDisplayString(), and getSanitizedBaseunitTitle().

+ Here is the caller graph for this function:

◆ setBaseUnit()

assFormulaQuestionUnit::setBaseUnit ( int  $baseunit)

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

97 : void
98 {
99 $this->baseunit = $baseunit;
100 }

References $baseunit.

Referenced by ilUnitConfigurationRepository\createNewUnit().

+ Here is the caller graph for this function:

◆ setBaseunitTitle()

assFormulaQuestionUnit::setBaseunitTitle ( ?string  $baseunit_title)

Definition at line 111 of file class.assFormulaQuestionUnit.php.

111 : void
112 {
113 $this->baseunit_title = $baseunit_title;
114 }

References $baseunit_title.

◆ setCategory()

assFormulaQuestionUnit::setCategory ( int  $category)

Definition at line 126 of file class.assFormulaQuestionUnit.php.

126 : void
127 {
128 $this->category = $category;
129 }

References $category.

◆ setFactor()

assFormulaQuestionUnit::setFactor ( float  $factor)

Definition at line 87 of file class.assFormulaQuestionUnit.php.

87 : void
88 {
89 $this->factor = $factor;
90 }

References $factor.

Referenced by ilUnitConfigurationRepository\createNewUnit(), and ilUnitConfigurationRepository\saveUnit().

+ Here is the caller graph for this function:

◆ setId()

assFormulaQuestionUnit::setId ( int  $id)

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

52 : void
53 {
54 $this->id = $id;
55 }

References $id.

Referenced by ilUnitConfigurationRepository\createNewUnit().

+ Here is the caller graph for this function:

◆ setSequence()

assFormulaQuestionUnit::setSequence ( int  $sequence)

Definition at line 77 of file class.assFormulaQuestionUnit.php.

77 : void
78 {
79 $this->sequence = $sequence;
80 }

References $sequence.

Referenced by ilUnitConfigurationRepository\createNewUnit().

+ Here is the caller graph for this function:

◆ setUnit()

assFormulaQuestionUnit::setUnit ( string  $unit)

Definition at line 62 of file class.assFormulaQuestionUnit.php.

62 : void
63 {
64 $this->unit = $unit;
65 }

References $unit.

◆ toNormalized()

assFormulaQuestionUnit::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 169 of file class.assFormulaQuestionUnit.php.

172 : array|float|bool|int|string|null
173 {
174 return [
175 'id' => $transformations->normalize(new Id($this->id, 'unit')),
176 'unit' => $this->unit,
177 'factor' => $this->factor,
178 'category_id' => $transformations->normalize(new Id($this->category, 'unit_category')),
179 'sequence' => $this->sequence,
180 'baseunit' => $transformations->normalize(new Id($this->baseunit, 'unit')),
181 'baseunit_title' => $this->baseunit_title,
182 ];
183 }
Wrapper object for an object identifier and an optional object type the identifier belongs to.
Definition: Id.php:33

References $baseunit_title, $factor, $sequence, $unit, and ILIAS\TestQuestionPool\ExportImport\Foundation\Normalize\Transformations\normalize().

+ Here is the call graph for this function:

Field Documentation

◆ $baseunit

int assFormulaQuestionUnit::$baseunit = 0
private

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

Referenced by getBaseUnit(), and setBaseUnit().

◆ $baseunit_title

string assFormulaQuestionUnit::$baseunit_title = null
private

◆ $category

int assFormulaQuestionUnit::$category = 0
private

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

Referenced by getCategory(), and setCategory().

◆ $factor

float assFormulaQuestionUnit::$factor = 0.0
private

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

Referenced by getFactor(), setFactor(), and toNormalized().

◆ $id

int assFormulaQuestionUnit::$id = 0
private

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

Referenced by getBaseUnit(), getId(), and setId().

◆ $sequence

int assFormulaQuestionUnit::$sequence = 0
private

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

Referenced by getSequence(), setSequence(), and toNormalized().

◆ $unit

string assFormulaQuestionUnit::$unit = ''
private

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

Referenced by getDisplayString(), getUnit(), setUnit(), and toNormalized().


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