ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
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 ()
 
 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)
 
 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 227 of file RequestDataCollector.php.

227 : array
228 {
229 return $this->retrieveArray($key, 1, $this->refinery->kindlyTo()->float());
230 }
retrieveArray(string $key, int $depth, Transformation $transformation)

References ILIAS\Repository\refinery(), and ILIAS\TestQuestionPool\RequestDataCollector\retrieveArray().

+ Here is the call graph for this function:

◆ getCmdIndex()

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

Definition at line 207 of file RequestDataCollector.php.

207 : int|string|null
208 {
209 $cmd = $this->rawArray('cmd');
210 if (!isset($cmd[$key]) || !is_array($cmd[$key])) {
211 return null;
212 }
213 return key($cmd[$key]);
214 }

References ILIAS\TestQuestionPool\RequestDataCollector\isset(), and ILIAS\TestQuestionPool\RequestDataCollector\rawArray().

+ Here is the call graph for this function:

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

260 : array|string
261 {
262 $query = $this->http->wrapper()->query();
263
264 if (!$query->has($key)) {
265 return [];
266 }
267
268 return $query->retrieve(
269 $key,
270 $this->refinery->custom()->transformation(
271 static fn(array|string $value): array|string => $value === 'ALL_OBJECTS' || $value[0] === 'ALL_OBJECTS'
272 ? 'ALL_OBJECTS'
273 : array_map('intval', $value)
274 )
275 );
276 }

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

202 : array
203 {
204 return $this->http->wrapper()->post()->keys();
205 }

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

248 : string|int
249 {
250 return $this->get($key, $this->refinery->byTrying([
251 $this->refinery->kindlyTo()->int(),
252 $this->refinery->kindlyTo()->string(),
253 $this->refinery->custom()->transformation(fn(array $v): string|int => $v[0])
254 ]));
255 }

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

235 : array
236 {
237 return $this->retrieveArray($key, 1, $this->refinery->kindlyTo()->int());
238 }

References ILIAS\Repository\refinery(), and ILIAS\TestQuestionPool\RequestDataCollector\retrieveArray().

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().

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

+ Here is the call graph for this function:
+ Here is the caller 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 243 of file RequestDataCollector.php.

243 : array
244 {
245 return $this->retrieveArray($key, 1, $this->refinery->identity());
246 }

References ILIAS\Repository\refinery(), and ILIAS\TestQuestionPool\RequestDataCollector\retrieveArray().

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

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

◆ retrieveArray()

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

Definition at line 278 of file RequestDataCollector.php.

278 : array
279 {
280 $chain = $this->refinery->kindlyTo()->dictOf($transformation);
281 for ($i = 1; $i < $depth; $i++) {
282 $chain = $this->refinery->kindlyTo()->dictOf($chain);
283 }
284
285 return $this->get(
286 $key,
287 $this->refinery->byTrying([
288 $chain,
289 $this->refinery->always([])
290 ])
291 ) ?? [];
292 }

References ILIAS\Repository\refinery().

Referenced by ILIAS\TestQuestionPool\RequestDataCollector\floatArray(), ILIAS\TestQuestionPool\RequestDataCollector\intArray(), ILIAS\TestQuestionPool\RequestDataCollector\rawArray(), and ILIAS\TestQuestionPool\RequestDataCollector\strArray().

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

◆ strArray()

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

Definition at line 219 of file RequestDataCollector.php.

219 : array
220 {
221 return $this->retrieveArray($key, $depth, $this->refinery->kindlyTo()->string());
222 }

References ILIAS\Repository\refinery(), and ILIAS\TestQuestionPool\RequestDataCollector\retrieveArray().

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: