ILIAS  trunk Revision v12.0_alpha-1541-g23eaa5e013d
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 155 of file RequestDataCollector.php.

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

References ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ float()

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

Definition at line 141 of file RequestDataCollector.php.

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

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 239 of file RequestDataCollector.php.

239 : array
240 {
241 return $this->retrieveArray($key, 1, $this->refinery->kindlyTo()->float());
242 }
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 219 of file RequestDataCollector.php.

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

◆ getIds()

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

Implements ILIAS\TestQuestionPool\RequestDataCollectorInterface.

Definition at line 128 of file RequestDataCollector.php.

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

References ILIAS\TestQuestionPool\RequestDataCollector\strArray().

+ Here is the call graph for this function:

◆ getMatchingPairs()

ILIAS\TestQuestionPool\RequestDataCollector::getMatchingPairs ( )

Definition at line 181 of file RequestDataCollector.php.

181 : array
182 {
183 if (!$this->http->wrapper()->post()->has('matching')) {
184 return [];
185 }
186
187 return $this->http->wrapper()->post()->retrieve(
188 'matching',
189 $this->refinery->byTrying([
190 $this->refinery->container()->mapValues(
191 $this->refinery->custom()->transformation(
192 fn(string $v): array => $this->refinery->container()->mapValues(
193 $this->refinery->kindlyTo()->int()
194 )->transform(json_decode($v))
195 )
196 ),
197 $this->refinery->always([])
198 ])
199 );
200 }
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 272 of file RequestDataCollector.php.

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

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 202 of file RequestDataCollector.php.

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

◆ getNumericQuestionSolutionSubmit()

ILIAS\TestQuestionPool\RequestDataCollector::getNumericQuestionSolutionSubmit ( )

Definition at line 290 of file RequestDataCollector.php.

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

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 160 of file RequestDataCollector.php.

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

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 214 of file RequestDataCollector.php.

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

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 120 of file RequestDataCollector.php.

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

References ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getRefId()

ILIAS\TestQuestionPool\RequestDataCollector::getRefId ( )

Implements ILIAS\TestQuestionPool\RequestDataCollectorInterface.

Definition at line 110 of file RequestDataCollector.php.

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

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 260 of file RequestDataCollector.php.

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

References ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ getUnitCategoryIds()

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

Definition at line 176 of file RequestDataCollector.php.

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

References ILIAS\TestQuestionPool\RequestDataCollector\intArray().

+ Here is the call graph for this function:

◆ getUnitIds()

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

Definition at line 168 of file RequestDataCollector.php.

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

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 115 of file RequestDataCollector.php.

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

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 105 of file RequestDataCollector.php.

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

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 247 of file RequestDataCollector.php.

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

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 100 of file RequestDataCollector.php.

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

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 136 of file RequestDataCollector.php.

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

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 255 of file RequestDataCollector.php.

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

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 301 of file RequestDataCollector.php.

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

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 231 of file RequestDataCollector.php.

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

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 150 of file RequestDataCollector.php.

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

References ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ upload()

ILIAS\TestQuestionPool\RequestDataCollector::upload ( )

Definition at line 95 of file RequestDataCollector.php.

96 {
97 return $this->upload;
98 }

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: