ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\TestQuestionPool\RequestDataCollector Class Reference
+ Collaboration diagram for ILIAS\TestQuestionPool\RequestDataCollector:

Public Member Functions

 __construct (Services $http, Factory $refinery, protected readonly FileUpload $upload)
 
 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)
 

Private Member Functions

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

Detailed Description

Definition at line 30 of file RequestDataCollector.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 34 of file RequestDataCollector.php.

38 {
39 $this->initRequest($http, $refinery);
40 }
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\Standard\$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 149 of file RequestDataCollector.php.

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

References ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ float()

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

Definition at line 135 of file RequestDataCollector.php.

135 : float
136 {
137 try {
138 return $this->get($key, $this->refinery->kindlyTo()->float()) ?? 0.0;
139 } catch (ConstraintViolationException $e) {
140 return 0.0;
141 }
142 }

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

221 : array
222 {
223 return $this->retrieveArray($key, 1, $this->refinery->kindlyTo()->float());
224 }
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 201 of file RequestDataCollector.php.

201 : int|string|null
202 {
203 $cmd = $this->rawArray('cmd');
204 if (!isset($cmd[$key]) || !is_array($cmd[$key])) {
205 return null;
206 }
207 return key($cmd[$key]);
208 }

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>

Definition at line 122 of file RequestDataCollector.php.

122 : array
123 {
124 return $this->strArray('id');
125 }

References ILIAS\TestQuestionPool\RequestDataCollector\strArray().

+ Here is the call graph for this function:

◆ getMatchingPairs()

ILIAS\TestQuestionPool\RequestDataCollector::getMatchingPairs ( )

Definition at line 175 of file RequestDataCollector.php.

175 : array
176 {
177 if (!$this->http->wrapper()->post()->has('matching')) {
178 return [];
179 }
180
181 return $this->http->wrapper()->post()->retrieve(
182 'matching',
183 $this->refinery->byTrying([
184 $this->refinery->container()->mapValues(
185 $this->refinery->custom()->transformation(
186 fn(string $v): array => $this->refinery->container()->mapValues(
187 $this->refinery->kindlyTo()->int()
188 )->transform(json_decode($v))
189 )
190 ),
191 $this->refinery->always([])
192 ])
193 );
194 }
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:

◆ getParsedBody()

ILIAS\TestQuestionPool\RequestDataCollector::getParsedBody ( )

Definition at line 154 of file RequestDataCollector.php.

154 : object|array|null
155 {
156 return $this->http->request()->getParsedBody();
157 }

References ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ getPostKeys()

ILIAS\TestQuestionPool\RequestDataCollector::getPostKeys ( )

Definition at line 196 of file RequestDataCollector.php.

196 : array
197 {
198 return $this->http->wrapper()->post()->keys();
199 }

References ILIAS\FileDelivery\http().

+ Here is the call graph for this function:

◆ getProcessedUploads()

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

Definition at line 45 of file RequestDataCollector.php.

45 : array
46 {
47 $uploads = [];
48
49 if ($this->upload->hasUploads()) {
50 if (!$this->upload->hasBeenProcessed()) {
51 $this->upload->process();
52 }
53 $uploads = $this->upload->getResults();
54 }
55
56 return $uploads;
57 }

References ILIAS\TestQuestionPool\RequestDataCollector\upload().

+ Here is the call graph for this function:

◆ getQuestionId()

ILIAS\TestQuestionPool\RequestDataCollector::getQuestionId ( )

Definition at line 114 of file RequestDataCollector.php.

114 : int
115 {
116 return $this->int('q_id');
117 }

References ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getRefId()

ILIAS\TestQuestionPool\RequestDataCollector::getRefId ( )

Definition at line 104 of file RequestDataCollector.php.

104 : int
105 {
106 return $this->int('ref_id');
107 }

References ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getUnitCategoryIds()

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

Definition at line 170 of file RequestDataCollector.php.

170 : array
171 {
172 return $this->intArray('category_ids');
173 }

References ILIAS\TestQuestionPool\RequestDataCollector\intArray().

+ Here is the call graph for this function:

◆ getUnitIds()

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

Definition at line 162 of file RequestDataCollector.php.

162 : array
163 {
164 return $this->intArray('unit_ids');
165 }

References ILIAS\TestQuestionPool\RequestDataCollector\intArray().

+ Here is the call graph for this function:

◆ hasQuestionId()

ILIAS\TestQuestionPool\RequestDataCollector::hasQuestionId ( )

Definition at line 109 of file RequestDataCollector.php.

109 : bool
110 {
111 return $this->raw('q_id') !== null;
112 }

References ILIAS\TestQuestionPool\RequestDataCollector\raw().

+ Here is the call graph for this function:

◆ hasRefId()

ILIAS\TestQuestionPool\RequestDataCollector::hasRefId ( )

Definition at line 99 of file RequestDataCollector.php.

99 : int
100 {
101 return $this->raw('ref_id') !== null;
102 }

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

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

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)

Definition at line 94 of file RequestDataCollector.php.

94 : bool
95 {
96 return $this->raw($key) !== null;
97 }

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

Definition at line 130 of file RequestDataCollector.php.

130 : mixed
131 {
132 return $this->get($key, $this->refinery->identity());
133 }

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

237 : array
238 {
239 return $this->retrieveArray($key, 1, $this->refinery->identity());
240 }

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

242 : array
243 {
244 $chain = $this->refinery->kindlyTo()->dictOf($transformation);
245 for ($i = 1; $i < $depth; $i++) {
246 $chain = $this->refinery->kindlyTo()->dictOf($chain);
247 }
248
249 return $this->http->wrapper()->post()->retrieve(
250 $key,
251 $this->refinery->byTrying([
252 $chain,
253 $this->refinery->always([])
254 ])
255 );
256 }

References ILIAS\FileDelivery\http(), and 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 213 of file RequestDataCollector.php.

213 : array
214 {
215 return $this->retrieveArray($key, $depth, $this->refinery->kindlyTo()->string());
216 }

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

144 : string
145 {
146 return $this->get($key, $this->refinery->kindlyTo()->string()) ?? '';
147 }

References ILIAS\Repository\refinery().

+ Here is the call graph for this function:

◆ upload()

ILIAS\TestQuestionPool\RequestDataCollector::upload ( )

Definition at line 89 of file RequestDataCollector.php.

90 {
91 return $this->upload;
92 }

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: