ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\TestQuestionPool\RequestDataCollector Class Reference
+ Inheritance diagram for ILIAS\TestQuestionPool\RequestDataCollector:
+ Collaboration diagram for ILIAS\TestQuestionPool\RequestDataCollector:

Public Member Functions

 __construct (Services $http, Factory $refinery, protected readonly FileUpload $upload)
 
 getRequest ()
 
 getProcessedUploads ()
 
 upload ()
 
 isset (string $key)
 
 hasRefId ()
 
 getRefId ()
 
 hasQuestionId ()
 
 getQuestionId ()
 
 getIds ()
 
 raw (string $key)
 
 float (string $key)
 
 string (string $key)
 
 bool (string $key)
 
 getParsedBody ()
 
 getUnitIds ()
 
 getUnitCategoryIds ()
 
 getMatchingPairs ()
 
 getNumericGapValue (int $gap_index)
 
 getPostKeys ()
 
 getCmdIndex (string $key)
 
 strArray (string $key, int $depth=1)
 
 floatArray (string $key)
 
 intArray (string $key)
 
 rawArray (string $key)
 
 getRowIdParameter (string $key)
 
 getMultiSelectionIds (string $key)
 
 getNumericQuestionSolutionSubmit ()
 
 getRequest ()
 
 isset (string $key)
 
 hasRefId ()
 
 getRefId ()
 
 hasQuestionId ()
 
 getQuestionId ()
 
 getIds ()
 
 raw (string $key)
 
 getParsedBody ()
 
 getPostKeys ()
 
 getMultiSelectionIds (string $key)
 
 getRowIdParameter (string $key)
 

Private Member Functions

 retrieveArray (string $key, int $depth, Transformation $transformation)
 

Detailed Description

Definition at line 31 of file RequestDataCollector.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\TestQuestionPool\RequestDataCollector::__construct ( Services  $http,
Factory  $refinery,
protected readonly FileUpload  $upload 
)

Definition at line 35 of file RequestDataCollector.php.

39 {
40 $this->initRequest($http, $refinery);
41 }
initRequest(HTTP\Services $http, Refinery\Factory $refinery, ?array $passed_query_params=null, ?array $passed_post_data=null)
Query params and post data parameters are used for testing.

References ILIAS\UI\examples\Layout\Page\Mail\$refinery, and ILIAS\Repository\initRequest().

+ Here is the call graph for this function:

Member Function Documentation

◆ bool()

ILIAS\TestQuestionPool\RequestDataCollector::bool ( string  $key)

Definition at line 153 of file RequestDataCollector.php.

153 : ?bool
154 {
155 return $this->get($key, $this->refinery->kindlyTo()->bool());
156 }

References ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ float()

ILIAS\TestQuestionPool\RequestDataCollector::float ( string  $key)

Definition at line 139 of file RequestDataCollector.php.

139 : float
140 {
141 try {
142 return $this->get($key, $this->refinery->kindlyTo()->float()) ?? 0.0;
143 } catch (ConstraintViolationException $e) {
144 return 0.0;
145 }
146 }

References Vendor\Package\$e, and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ floatArray()

ILIAS\TestQuestionPool\RequestDataCollector::floatArray ( string  $key)
Returns
array<float>

Definition at line 237 of file RequestDataCollector.php.

237 : array
238 {
239 return $this->retrieveArray($key, 1, $this->refinery->kindlyTo()->float());
240 }
retrieveArray(string $key, int $depth, Transformation $transformation)

References ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ getCmdIndex()

ILIAS\TestQuestionPool\RequestDataCollector::getCmdIndex ( string  $key)

Definition at line 217 of file RequestDataCollector.php.

217 : int|string|null
218 {
219 $cmd = $this->rawArray('cmd');
220 if (!isset($cmd[$key]) || !is_array($cmd[$key])) {
221 return null;
222 }
223 return key($cmd[$key]);
224 }

◆ getIds()

ILIAS\TestQuestionPool\RequestDataCollector::getIds ( )
Returns
array<string>

Implements ILIAS\TestQuestionPool\RequestDataCollectorInterface.

Definition at line 126 of file RequestDataCollector.php.

126 : array
127 {
128 return $this->strArray('id');
129 }

References ILIAS\TestQuestionPool\RequestDataCollector\strArray().

+ Here is the call graph for this function:

◆ getMatchingPairs()

ILIAS\TestQuestionPool\RequestDataCollector::getMatchingPairs ( )

Definition at line 179 of file RequestDataCollector.php.

179 : array
180 {
181 if (!$this->http->wrapper()->post()->has('matching')) {
182 return [];
183 }
184
185 return $this->http->wrapper()->post()->retrieve(
186 'matching',
187 $this->refinery->byTrying([
188 $this->refinery->container()->mapValues(
189 $this->refinery->custom()->transformation(
190 fn(string $v): array => $this->refinery->container()->mapValues(
191 $this->refinery->kindlyTo()->int()
192 )->transform(json_decode($v))
193 )
194 ),
195 $this->refinery->always([])
196 ])
197 );
198 }
static http()
Fetches the global http state from ILIAS.

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ getMultiSelectionIds()

ILIAS\TestQuestionPool\RequestDataCollector::getMultiSelectionIds ( string  $key)
Returns
array<int>|string

Implements ILIAS\TestQuestionPool\RequestDataCollectorInterface.

Definition at line 270 of file RequestDataCollector.php.

270 : array|string
271 {
272 $query = $this->http->wrapper()->query();
273
274 if (!$query->has($key)) {
275 return [];
276 }
277
278 return $query->retrieve(
279 $key,
280 $this->refinery->custom()->transformation(
281 static fn(array|string $value): array|string => $value === 'ALL_OBJECTS' || $value[0] === 'ALL_OBJECTS'
282 ? 'ALL_OBJECTS'
283 : array_map('intval', $value)
284 )
285 );
286 }

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ getNumericGapValue()

ILIAS\TestQuestionPool\RequestDataCollector::getNumericGapValue ( int  $gap_index)

Definition at line 200 of file RequestDataCollector.php.

202 : ?float {
203 return $this->http->wrapper()->post()->retrieve(
204 "gap_{$gap_index}_numeric",
205 $this->refinery->byTrying([
206 $this->refinery->kindlyTo()->float(),
207 $this->refinery->always(null)
208 ])
209 );
210 }

◆ getNumericQuestionSolutionSubmit()

ILIAS\TestQuestionPool\RequestDataCollector::getNumericQuestionSolutionSubmit ( )

Definition at line 288 of file RequestDataCollector.php.

288 : ?float
289 {
290 return $this->http->wrapper()->post()->retrieve(
291 'numeric_result',
292 $this->refinery->byTrying([
293 $this->refinery->kindlyTo()->float(),
294 $this->refinery->always(null)
295 ])
296 );
297 }

References ILIAS\FileDelivery\http(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ getParsedBody()

ILIAS\TestQuestionPool\RequestDataCollector::getParsedBody ( )

Implements ILIAS\TestQuestionPool\RequestDataCollectorInterface.

Definition at line 158 of file RequestDataCollector.php.

158 : object|array|null
159 {
160 return $this->http->request()->getParsedBody();
161 }

References ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ getPostKeys()

ILIAS\TestQuestionPool\RequestDataCollector::getPostKeys ( )
Returns
array<string|int>

Implements ILIAS\TestQuestionPool\RequestDataCollectorInterface.

Definition at line 212 of file RequestDataCollector.php.

212 : array
213 {
214 return $this->http->wrapper()->post()->keys();
215 }

References ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ getProcessedUploads()

ILIAS\TestQuestionPool\RequestDataCollector::getProcessedUploads ( )
Returns
array<UploadResult>

Definition at line 51 of file RequestDataCollector.php.

51 : array
52 {
53 $uploads = [];
54
55 if ($this->upload->hasUploads()) {
56 if (!$this->upload->hasBeenProcessed()) {
57 $this->upload->process();
58 }
59 $uploads = $this->upload->getResults();
60 }
61
62 return $uploads;
63 }

References ILIAS\TestQuestionPool\RequestDataCollector\upload().

+ Here is the call graph for this function:

◆ getQuestionId()

ILIAS\TestQuestionPool\RequestDataCollector::getQuestionId ( )

Implements ILIAS\TestQuestionPool\RequestDataCollectorInterface.

Definition at line 118 of file RequestDataCollector.php.

118 : int
119 {
120 return $this->int('q_id');
121 }

References ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getRefId()

ILIAS\TestQuestionPool\RequestDataCollector::getRefId ( )

Implements ILIAS\TestQuestionPool\RequestDataCollectorInterface.

Definition at line 108 of file RequestDataCollector.php.

108 : int
109 {
110 return $this->int('ref_id');
111 }

References ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getRequest()

ILIAS\TestQuestionPool\RequestDataCollector::getRequest ( )

Implements ILIAS\TestQuestionPool\RequestDataCollectorInterface.

Definition at line 43 of file RequestDataCollector.php.

43 : ServerRequestInterface
44 {
45 return $this->http->request();
46 }

References ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ getRowIdParameter()

ILIAS\TestQuestionPool\RequestDataCollector::getRowIdParameter ( string  $key)

Implements ILIAS\TestQuestionPool\RequestDataCollectorInterface.

Definition at line 258 of file RequestDataCollector.php.

258 : string|int
259 {
260 return $this->get($key, $this->refinery->byTrying([
261 $this->refinery->kindlyTo()->int(),
262 $this->refinery->kindlyTo()->string(),
263 $this->refinery->custom()->transformation(fn(array $v): string|int => $v[0])
264 ]));
265 }

References ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ getUnitCategoryIds()

ILIAS\TestQuestionPool\RequestDataCollector::getUnitCategoryIds ( )
Returns
array<int>

Definition at line 174 of file RequestDataCollector.php.

174 : array
175 {
176 return $this->intArray('category_ids');
177 }

References ILIAS\TestQuestionPool\RequestDataCollector\intArray().

+ Here is the call graph for this function:

◆ getUnitIds()

ILIAS\TestQuestionPool\RequestDataCollector::getUnitIds ( )
Returns
array<int>

Definition at line 166 of file RequestDataCollector.php.

166 : array
167 {
168 return $this->intArray('unit_ids');
169 }

References ILIAS\TestQuestionPool\RequestDataCollector\intArray().

+ Here is the call graph for this function:

◆ hasQuestionId()

ILIAS\TestQuestionPool\RequestDataCollector::hasQuestionId ( )

Implements ILIAS\TestQuestionPool\RequestDataCollectorInterface.

Definition at line 113 of file RequestDataCollector.php.

113 : bool
114 {
115 return $this->raw('q_id') !== null;
116 }

References ILIAS\TestQuestionPool\RequestDataCollector\raw().

+ Here is the call graph for this function:

◆ hasRefId()

ILIAS\TestQuestionPool\RequestDataCollector::hasRefId ( )

Implements ILIAS\TestQuestionPool\RequestDataCollectorInterface.

Definition at line 103 of file RequestDataCollector.php.

103 : bool
104 {
105 return $this->raw('ref_id') !== null;
106 }

References ILIAS\TestQuestionPool\RequestDataCollector\raw().

+ Here is the call graph for this function:

◆ intArray()

ILIAS\TestQuestionPool\RequestDataCollector::intArray ( string  $key)
Returns
array<int>

Definition at line 245 of file RequestDataCollector.php.

245 : array
246 {
247 return $this->retrieveArray($key, 1, $this->refinery->kindlyTo()->int());
248 }

References ILIAS\Repository\refinery().

Referenced by ILIAS\TestQuestionPool\RequestDataCollector\getUnitCategoryIds(), and ILIAS\TestQuestionPool\RequestDataCollector\getUnitIds().

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

◆ isset()

ILIAS\TestQuestionPool\RequestDataCollector::isset ( string  $key)

Implements ILIAS\TestQuestionPool\RequestDataCollectorInterface.

Definition at line 98 of file RequestDataCollector.php.

98 : bool
99 {
100 return $this->raw($key) !== null;
101 }

References ILIAS\TestQuestionPool\RequestDataCollector\raw().

+ Here is the call graph for this function:

◆ raw()

ILIAS\TestQuestionPool\RequestDataCollector::raw ( string  $key)
Returns
mixed|null

Implements ILIAS\TestQuestionPool\RequestDataCollectorInterface.

Definition at line 134 of file RequestDataCollector.php.

134 : mixed
135 {
136 return $this->get($key, $this->refinery->identity());
137 }

References ILIAS\Repository\refinery().

Referenced by ILIAS\TestQuestionPool\RequestDataCollector\hasQuestionId(), ILIAS\TestQuestionPool\RequestDataCollector\hasRefId(), and ILIAS\TestQuestionPool\RequestDataCollector\isset().

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

◆ rawArray()

ILIAS\TestQuestionPool\RequestDataCollector::rawArray ( string  $key)
Returns
array<mixed|array>

Definition at line 253 of file RequestDataCollector.php.

253 : array
254 {
255 return $this->retrieveArray($key, 1, $this->refinery->identity());
256 }

References ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ retrieveArray()

ILIAS\TestQuestionPool\RequestDataCollector::retrieveArray ( string  $key,
int  $depth,
Transformation  $transformation 
)
private

Definition at line 299 of file RequestDataCollector.php.

299 : array
300 {
301 $chain = $this->refinery->kindlyTo()->dictOf($transformation);
302 for ($i = 1; $i < $depth; $i++) {
303 $chain = $this->refinery->kindlyTo()->dictOf($chain);
304 }
305
306 return $this->get(
307 $key,
308 $this->refinery->byTrying([
309 $chain,
310 $this->refinery->always([])
311 ])
312 ) ?? [];
313 }

References ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ strArray()

ILIAS\TestQuestionPool\RequestDataCollector::strArray ( string  $key,
int  $depth = 1 
)
Returns
array<string|array>

Definition at line 229 of file RequestDataCollector.php.

229 : array
230 {
231 return $this->retrieveArray($key, $depth, $this->refinery->kindlyTo()->string());
232 }

References ILIAS\Repository\refinery().

Referenced by ILIAS\TestQuestionPool\RequestDataCollector\getIds().

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

◆ string()

ILIAS\TestQuestionPool\RequestDataCollector::string ( string  $key)

Definition at line 148 of file RequestDataCollector.php.

148 : string
149 {
150 return $this->get($key, $this->refinery->kindlyTo()->string()) ?? '';
151 }

References ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ upload()

ILIAS\TestQuestionPool\RequestDataCollector::upload ( )

Definition at line 93 of file RequestDataCollector.php.

94 {
95 return $this->upload;
96 }

Referenced by ILIAS\TestQuestionPool\RequestDataCollector\getProcessedUploads().

+ Here is the caller graph for this function:

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