ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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.

References ILIAS\Repository\initRequest().

38  {
39  $this->initRequest($http, $refinery);
40  }
$http
Definition: deliver.php:30
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.
+ 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.

References ILIAS\Repository\refinery().

149  : ?bool
150  {
151  return $this->get($key, $this->refinery->kindlyTo()->bool());
152  }
+ Here is the call graph for this function:

◆ float()

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

Definition at line 135 of file RequestDataCollector.php.

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

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  }
+ 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.

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

221  : array
222  {
223  return $this->retrieveArray($key, 1, $this->refinery->kindlyTo()->float());
224  }
retrieveArray(string $key, int $depth, Transformation $transformation)
+ Here is the call graph for this function:

◆ getCmdIndex()

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

Definition at line 201 of file RequestDataCollector.php.

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

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  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ getIds()

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

Definition at line 122 of file RequestDataCollector.php.

References ILIAS\TestQuestionPool\RequestDataCollector\strArray().

122  : array
123  {
124  return $this->strArray('id');
125  }
+ Here is the call graph for this function:

◆ getMatchingPairs()

ILIAS\TestQuestionPool\RequestDataCollector::getMatchingPairs ( )

Definition at line 175 of file RequestDataCollector.php.

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

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.
+ Here is the call graph for this function:

◆ getParsedBody()

ILIAS\TestQuestionPool\RequestDataCollector::getParsedBody ( )

Definition at line 154 of file RequestDataCollector.php.

References ILIAS\FileDelivery\http().

154  : object|array|null
155  {
156  return $this->http->request()->getParsedBody();
157  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:

◆ getPostKeys()

ILIAS\TestQuestionPool\RequestDataCollector::getPostKeys ( )

Definition at line 196 of file RequestDataCollector.php.

References ILIAS\FileDelivery\http().

196  : array
197  {
198  return $this->http->wrapper()->post()->keys();
199  }
static http()
Fetches the global http state from ILIAS.
+ Here is the call graph for this function:

◆ getProcessedUploads()

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

Definition at line 45 of file RequestDataCollector.php.

References $c, ILIAS\FileDelivery\http(), ILIAS\TestQuestionPool\RequestDataCollector\isset(), null, and ILIAS\TestQuestionPool\RequestDataCollector\upload().

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  }
+ Here is the call graph for this function:

◆ getQuestionId()

ILIAS\TestQuestionPool\RequestDataCollector::getQuestionId ( )

Definition at line 114 of file RequestDataCollector.php.

References ILIAS\Repository\int().

114  : int
115  {
116  return $this->int('q_id');
117  }
+ Here is the call graph for this function:

◆ getRefId()

ILIAS\TestQuestionPool\RequestDataCollector::getRefId ( )

Definition at line 104 of file RequestDataCollector.php.

References ILIAS\Repository\int().

104  : int
105  {
106  return $this->int('ref_id');
107  }
+ Here is the call graph for this function:

◆ getUnitCategoryIds()

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

Definition at line 170 of file RequestDataCollector.php.

References ILIAS\TestQuestionPool\RequestDataCollector\intArray().

170  : array
171  {
172  return $this->intArray('category_ids');
173  }
+ Here is the call graph for this function:

◆ getUnitIds()

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

Definition at line 162 of file RequestDataCollector.php.

References ILIAS\TestQuestionPool\RequestDataCollector\intArray().

162  : array
163  {
164  return $this->intArray('unit_ids');
165  }
+ Here is the call graph for this function:

◆ hasQuestionId()

ILIAS\TestQuestionPool\RequestDataCollector::hasQuestionId ( )

Definition at line 109 of file RequestDataCollector.php.

References null, and ILIAS\TestQuestionPool\RequestDataCollector\raw().

109  : bool
110  {
111  return $this->raw('q_id') !== null;
112  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:

◆ hasRefId()

ILIAS\TestQuestionPool\RequestDataCollector::hasRefId ( )

Definition at line 99 of file RequestDataCollector.php.

References null, and ILIAS\TestQuestionPool\RequestDataCollector\raw().

99  : int
100  {
101  return $this->raw('ref_id') !== null;
102  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ 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.

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

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

229  : array
230  {
231  return $this->retrieveArray($key, 1, $this->refinery->kindlyTo()->int());
232  }
retrieveArray(string $key, int $depth, Transformation $transformation)
+ 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.

References null, and ILIAS\TestQuestionPool\RequestDataCollector\raw().

Referenced by ILIAS\TestQuestionPool\RequestDataCollector\getCmdIndex(), and ILIAS\TestQuestionPool\RequestDataCollector\getProcessedUploads().

94  : bool
95  {
96  return $this->raw($key) !== null;
97  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ 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.

References ILIAS\Repository\refinery().

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

130  : mixed
131  {
132  return $this->get($key, $this->refinery->identity());
133  }
+ 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.

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

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

237  : array
238  {
239  return $this->retrieveArray($key, 1, $this->refinery->identity());
240  }
retrieveArray(string $key, int $depth, Transformation $transformation)
+ 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.

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

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  }
static http()
Fetches the global http state from ILIAS.
+ 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.

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

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

213  : array
214  {
215  return $this->retrieveArray($key, $depth, $this->refinery->kindlyTo()->string());
216  }
retrieveArray(string $key, int $depth, Transformation $transformation)
+ 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.

References ILIAS\Repository\refinery().

144  : string
145  {
146  return $this->get($key, $this->refinery->kindlyTo()->string()) ?? '';
147  }
+ Here is the call graph for this function:

◆ upload()

ILIAS\TestQuestionPool\RequestDataCollector::upload ( )

Definition at line 89 of file RequestDataCollector.php.

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

89  : FileUpload
90  {
91  return $this->upload;
92  }
+ Here is the caller graph for this function:

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