ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Test\Participants\ParticipantTable Class Reference
+ Inheritance diagram for ILIAS\Test\Participants\ParticipantTable:
+ Collaboration diagram for ILIAS\Test\Participants\ParticipantTable:

Public Member Functions

 __construct (private readonly UIFactory $ui_factory, private readonly \ilUIService $ui_service, private readonly Language $lng, private readonly \ilTestAccess $test_access, private readonly RequestDataCollector $test_request, private readonly \ilTestParticipantAccessFilterFactory $participant_access_filter, private readonly ParticipantRepository $repository, private readonly ResultsDataFactory $results_data_factory, private readonly ResultsPresentationSettings $results_presentation_settings, private readonly \ilObjUser $current_user, private readonly \ilObjTest $test_object, private readonly ParticipantTableActions $table_actions)
 
 execute (URLBuilder $url_builder)
 
 getComponents (URLBuilder $url_builder, string $filter_url)
 
 getTotalRowCount (?array $filter_data, ?array $additional_parameters)
 Mainly for the purpose of pagination-support, it is important to know about the total number of records available. More...
 
- Public Member Functions inherited from ILIAS\UI\Component\Table\DataRetrieval
 getRows (DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, ?array $filter_data, ?array $additional_parameters)
 This is called by the table to retrieve rows; map data-records to rows using the $row_builder e.g. More...
 
 getTotalRowCount (?array $filter_data, ?array $additional_parameters)
 Mainly for the purpose of pagination-support, it is important to know about the total number of records available. More...
 

Private Member Functions

 acquireParameters ($url_builder)
 
 getPostLoadFilters ()
 
 getPostLoadOrderFields ()
 
 getFilterComponent (string $action, ServerRequestInterface $request)
 
 getFilterFields (FieldFactory $field_factory)
 
 getTableComponent (ServerRequestInterface $request, ?array $filter)
 
 getColumns ()
 
 loadRecords (?array $filter, Order $order)
 
 buildAccessFilteredParticipantsList (array $records)
 
 getViewControlledRecords (?array $filter_data, Range $range, Order $order)
 
 filterRecords (iterable $records, ?array $filter_data)
 
 matchFilter (Participant $record, ?array $filter)
 
 orderRecords (iterable $records, Order $order)
 
 limitRecords (array $records, Range $range)
 

Private Attributes

const ID = 'pt'
 
iterable $records = null
 
bool $scoring_enabled = false
 

Detailed Description

Definition at line 39 of file ParticipantTable.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Test\Participants\ParticipantTable::__construct ( private readonly UIFactory  $ui_factory,
private readonly \ilUIService  $ui_service,
private readonly Language  $lng,
private readonly \ilTestAccess  $test_access,
private readonly RequestDataCollector  $test_request,
private readonly \ilTestParticipantAccessFilterFactory  $participant_access_filter,
private readonly ParticipantRepository  $repository,
private readonly ResultsDataFactory  $results_data_factory,
private readonly ResultsPresentationSettings  $results_presentation_settings,
private readonly \ilObjUser  $current_user,
private readonly \ilObjTest  $test_object,
private readonly ParticipantTableActions  $table_actions 
)

Definition at line 45 of file ParticipantTable.php.

58 {
59 $this->scoring_enabled = $this->test_object->getGlobalSettings()->isManualScoringEnabled();
60 }

Member Function Documentation

◆ acquireParameters()

◆ buildAccessFilteredParticipantsList()

ILIAS\Test\Participants\ParticipantTable::buildAccessFilteredParticipantsList ( array  $records)
private
Parameters
array<Participant>$records
Returns
array<int>

Definition at line 489 of file ParticipantTable.php.

489 : array
490 {
491 $manage_access_filter = $this->participant_access_filter
492 ->getManageParticipantsUserFilter($this->test_object->getRefId());
493 $access_results_access_filter = $this->participant_access_filter
494 ->getAccessResultsUserFilter($this->test_object->getRefId());
495 $participant_ids = array_map(
496 fn(Participant $participant) => $participant->getUserId(),
498 );
499 return $manage_access_filter($participant_ids) + $access_results_access_filter($participant_ids);
500 }

References ILIAS\Test\Participants\Participant\getUserId().

+ Here is the call graph for this function:

◆ execute()

ILIAS\Test\Participants\ParticipantTable::execute ( URLBuilder  $url_builder)

Definition at line 62 of file ParticipantTable.php.

62 : ?Modal
63 {
64 return $this->table_actions->execute(...$this->acquireParameters($url_builder));
65 }

References ILIAS\Test\Participants\ParticipantTable\acquireParameters().

+ Here is the call graph for this function:

◆ filterRecords()

ILIAS\Test\Participants\ParticipantTable::filterRecords ( iterable  $records,
?array  $filter_data 
)
private

Definition at line 524 of file ParticipantTable.php.

524 : iterable
525 {
526 foreach ($records as $record) {
527 if ($this->matchFilter($record, $filter_data)) {
528 yield $record;
529 }
530 }
531 }
matchFilter(Participant $record, ?array $filter)

◆ getColumns()

ILIAS\Test\Participants\ParticipantTable::getColumns ( )
private
Returns
array<string, Column>

Definition at line 354 of file ParticipantTable.php.

354 : array
355 {
356 $column_factory = $this->ui_factory->table()->column();
357
358 $columns = [
359 'name' => $column_factory->text($this->lng->txt('name'))
360 ->withIsSortable(!$this->test_object->getAnonymity())
361 ];
362 if (!$this->test_object->getAnonymity()) {
363 $columns['login'] = $column_factory->text($this->lng->txt('login'))->withIsSortable(true);
364 }
365
366 $columns += [
367 'matriculation' => $column_factory->text($this->lng->txt('matriculation'))
368 ->withIsOptional(true, false)
369 ->withIsSortable(true),
370 'ip_range' => $column_factory->text($this->lng->txt('client_ip_range'))
371 ->withIsOptional(true, false)
372 ->withIsSortable(true),
373 'attempt_started_at' => $column_factory->date(
374 $this->lng->txt('tst_attempt_started'),
375 $this->current_user->getDateTimeFormat()
376 )->withIsSortable(true),
377 'total_time_on_task' => $column_factory->text($this->lng->txt('working_time'))
378 ->withIsOptional(true, false),
379 'total_attempts' => $column_factory->number($this->lng->txt('total_attempts'))
380 ->withIsOptional(true, false)
381 ->withIsSortable(true),
382 ];
383
384 $columns['status_of_attempt'] = $column_factory->text($this->lng->txt('status_of_attempt'))
385 ->withIsSortable(true);
386
387 if ($this->test_object->getEnableProcessingTime()) {
388 $columns['remaining_duration'] = $column_factory->text($this->lng->txt('remaining_duration'))
389 ->withIsOptional(true);
390 $columns['total_duration'] = $column_factory->text($this->lng->txt('total_duration'))
391 ->withIsOptional(true, false);
392 $columns['extra_time'] = $column_factory->text($this->lng->txt('extratime'))
393 ->withIsOptional(true, false);
394 }
395
396 if ($this->test_object->getMainSettings()->getTestBehaviourSettings()->getExamIdInTestAttemptEnabled()) {
397 $columns['id_of_attempt'] = $column_factory->text($this->lng->txt('exam_id_of_attempt'))
398 ->withIsOptional(true, false)
399 ->withIsSortable(true);
400 }
401
402 if ($this->test_access->checkParticipantsResultsAccess()) {
403 $columns['reached_points'] = $column_factory->text($this->lng->txt('tst_reached_points'))
404 ->withIsSortable(true);
405 $columns['nr_of_answered_questions'] = $column_factory->text($this->lng->txt('tst_answered_questions'))
406 ->withIsOptional(true, false)
407 ->withIsSortable(true);
408 $columns['percent_of_available_points'] = $column_factory->number($this->lng->txt('tst_percent_solved'))
409 ->withUnit('%')
410 ->withIsOptional(true, false)
411 ->withIsSortable(true);
412 $columns['test_passed'] = $column_factory->boolean(
413 $this->lng->txt('tst_passed'),
414 $this->ui_factory->symbol()->icon()->custom(
415 'assets/images/standard/icon_checked.svg',
416 $this->lng->txt('yes'),
417 'small'
418 ),
419 $this->ui_factory->symbol()->icon()->custom(
420 'assets/images/standard/icon_unchecked.svg',
421 $this->lng->txt('no'),
422 'small'
423 )
424 )->withIsSortable(true)
425 ->withOrderingLabels(
426 "{$this->lng->txt('tst_passed')}, {$this->lng->txt('yes')} {$this->lng->txt('order_option_first')}",
427 "{$this->lng->txt('tst_passed')}, {$this->lng->txt('no')} {$this->lng->txt('order_option_first')}"
428 );
429 $columns['mark'] = $column_factory->text($this->lng->txt('tst_mark'))
430 ->withIsOptional(true, false)
431 ->withIsSortable(true);
432 }
433 if ($this->scoring_enabled) {
434 $columns['scoring_finalized'] = $column_factory->boolean(
435 $this->lng->txt('finalized_evaluation'),
436 $this->ui_factory->symbol()->icon()->custom(
437 'assets/images/standard/icon_checked.svg',
438 $this->lng->txt('yes'),
439 'small'
440 ),
441 $this->ui_factory->symbol()->icon()->custom(
442 'assets/images/standard/icon_unchecked.svg',
443 $this->lng->txt('no'),
444 'small'
445 )
446 )->withIsOptional(true, false)
447 ->withIsSortable(true);
448 }
449
450 $columns['last_access'] = $column_factory->date(
451 $this->lng->txt('last_access'),
452 $this->current_user->getDateTimeFormat()
453 );
454
455 return $columns;
456 }

References ILIAS\Repository\lng().

+ Here is the call graph for this function:

◆ getComponents()

ILIAS\Test\Participants\ParticipantTable::getComponents ( URLBuilder  $url_builder,
string  $filter_url 
)
Returns
array<Component>

Definition at line 70 of file ParticipantTable.php.

70 : array
71 {
72 $filter = $this->getFilterComponent($filter_url, $this->test_request->getRequest());
73 $table = $this->getTableComponent(
74 $this->test_request->getRequest(),
75 $this->ui_service->filter()->getData($filter)
76 );
77
78 return [
79 $filter,
80 $table->withActions($this->table_actions->getEnabledActions(...$this->acquireParameters($url_builder)))
81 ];
82 }
getFilterComponent(string $action, ServerRequestInterface $request)
getTableComponent(ServerRequestInterface $request, ?array $filter)

References ILIAS\Test\Participants\ParticipantTable\getFilterComponent(), and ILIAS\Test\Participants\ParticipantTable\getTableComponent().

+ Here is the call graph for this function:

◆ getFilterComponent()

ILIAS\Test\Participants\ParticipantTable::getFilterComponent ( string  $action,
ServerRequestInterface  $request 
)
private

Definition at line 259 of file ParticipantTable.php.

259 : FilterComponent
260 {
261 $filter_inputs = [];
262 $is_input_initially_rendered = [];
263 $field_factory = $this->ui_factory->input()->field();
264
265 foreach ($this->getFilterFields($field_factory) as $filter_id => $filter) {
266 [$filter_inputs[$filter_id], $is_input_initially_rendered[$filter_id]] = $filter;
267 }
268
269 return $this->ui_service->filter()->standard(
270 'participant_filter',
271 $action,
272 $filter_inputs,
273 $is_input_initially_rendered,
274 true,
275 true
276 );
277 }
getFilterFields(FieldFactory $field_factory)

Referenced by ILIAS\Test\Participants\ParticipantTable\getComponents().

+ Here is the caller graph for this function:

◆ getFilterFields()

ILIAS\Test\Participants\ParticipantTable::getFilterFields ( FieldFactory  $field_factory)
private
Parameters
FieldFactory$field_factory
Returns
array<string, FilterInput>

Definition at line 284 of file ParticipantTable.php.

284 : array
285 {
286 $yes_no_all_options = [
287 'true' => $this->lng->txt('yes'),
288 'false' => $this->lng->txt('no')
289 ];
290
291 $solution_options = [
292 'false' => $this->lng->txt('without_solution'),
293 'true' => $this->lng->txt('with_solution')
294 ];
295
296 $status_of_attempt_options = [
297 StatusOfAttempt::NOT_YET_STARTED->value => $this->lng->txt(StatusOfAttempt::NOT_YET_STARTED->value),
298 StatusOfAttempt::RUNNING->value => $this->lng->txt(StatusOfAttempt::RUNNING->value),
299 StatusOfAttempt::FINISHED_BY_UNKNOWN->value => $this->lng->txt(StatusOfAttempt::FINISHED_BY_UNKNOWN->value),
300 StatusOfAttempt::FINISHED_BY_ADMINISTRATOR->value => $this->lng->txt(StatusOfAttempt::FINISHED_BY_ADMINISTRATOR->value),
301 StatusOfAttempt::FINISHED_BY_CRONJOB->value => $this->lng->txt(StatusOfAttempt::FINISHED_BY_CRONJOB->value),
302 StatusOfAttempt::FINISHED_BY_DURATION->value => $this->lng->txt(StatusOfAttempt::FINISHED_BY_DURATION->value),
303 StatusOfAttempt::FINISHED_BY_PARTICIPANT->value => $this->lng->txt(StatusOfAttempt::FINISHED_BY_PARTICIPANT->value),
304 ];
305
306 $filters = [
307 'name' => [$field_factory->text($this->lng->txt('name')), true],
308 'login' => [$field_factory->text($this->lng->txt('login')), true],
309 'ip_range' => [$field_factory->text($this->lng->txt('client_ip_range')), true],
310 'solution' => [$field_factory->select($this->lng->txt('solutions'), $solution_options), true],
311 ];
312
313 if ($this->test_object->getEnableProcessingTime()) {
314 $filters['extra_time'] = [$field_factory->select($this->lng->txt('extratime'), $yes_no_all_options), true];
315 }
316
317 $filters['status_of_attempt'] = [
318 $field_factory->select($this->lng->txt('status_of_attempt'), $status_of_attempt_options),
319 true
320 ];
321
322 $filters['test_passed'] = [
323 $field_factory->select($this->lng->txt('tst_passed'), $yes_no_all_options),
324 true
325 ];
326
327 if ($this->scoring_enabled) {
328 $filters['scoring_finalized'] = [
329 $field_factory->select($this->lng->txt('finalized_evaluation'), $yes_no_all_options),
330 true
331 ];
332 }
333
334 return $filters;
335 }
return true

References ILIAS\Repository\lng(), and true.

+ Here is the call graph for this function:

◆ getPostLoadFilters()

ILIAS\Test\Participants\ParticipantTable::getPostLoadFilters ( )
private
Returns
array<string, \Closure>

Definition at line 178 of file ParticipantTable.php.

178 : array
179 {
180 return [
181 'solution' => fn(string $value, Participant $record) =>
182 $value === 'true' ? $record->hasAnsweredQuestionsForScoredAttempt() : !$record->hasAnsweredQuestionsForScoredAttempt(),
183 'status_of_attempt' => fn(string $value, Participant $record) =>
184 ($value === StatusOfAttempt::NOT_YET_STARTED->value && $record->getAttemptOverviewInformation()?->getStatusOfAttempt() === null) ||
185 $value === $record->getAttemptOverviewInformation()?->getStatusOfAttempt()->value,
186 'test_passed' => fn(string $value, Participant $record) => $value === 'true'
187 ? $record->getAttemptOverviewInformation()?->hasPassingMark() === true
188 : $record->getAttemptOverviewInformation()?->hasPassingMark() !== true,
189 'scoring_finalized' => fn(string $value, Participant $record) => $value === 'true'
190 ? $record->isScoringFinalized() == true
191 : $record->isScoringFinalized() === false
192 ];
193 }

References ILIAS\Test\Participants\Participant\getAttemptOverviewInformation(), ILIAS\Test\Participants\Participant\hasAnsweredQuestionsForScoredAttempt(), ILIAS\Test\Participants\Participant\isScoringFinalized(), and true.

+ Here is the call graph for this function:

◆ getPostLoadOrderFields()

ILIAS\Test\Participants\ParticipantTable::getPostLoadOrderFields ( )
private
Returns
array<string, \Closure>

Definition at line 198 of file ParticipantTable.php.

198 : array
199 {
200 $processing_time = $this->test_object->getProcessingTimeInSeconds();
201 $reset_time_on_new_attempt = $this->test_object->getResetProcessingTime();
202
203 return [
204 'attempt_started_at' => static fn(Participant $a, Participant $b) => $a->getFirstAccess() <=> $b->getFirstAccess(),
205 'total_duration' => static fn(
208 ) => $a->getTotalDuration($processing_time) <=> $b->getTotalDuration($processing_time),
209 'remaining_duration' => static fn(
212 ) => $a->getRemainingDuration($processing_time, $reset_time_on_new_attempt)
213 <=> $b->getRemainingDuration($processing_time, $reset_time_on_new_attempt),
214 'last_access' => static fn(Participant $a, Participant $b) => $a->getLastAccess() <=> $b->getLastAccess(),
215 'status_of_attempt' => static fn(
218 ) => $a->getAttemptOverviewInformation()?->getStatusOfAttempt()
219 <=> $b->getAttemptOverviewInformation()?->getStatusOfAttempt(),
220 'reached_points' => static fn(
223 ) => $a->getAttemptOverviewInformation()?->getReachedPoints()
224 <=> $b->getAttemptOverviewInformation()?->getReachedPoints(),
225 'nr_of_answered_questions' => static fn(
228 ) => $a->getAttemptOverviewInformation()?->getNrOfAnsweredQuestions()
229 <=> $b->getAttemptOverviewInformation()?->getNrOfAnsweredQuestions(),
230 'percent_of_available_points' => static fn(
233 ) => $a->getAttemptOverviewInformation()?->getReachedPointsInPercent()
234 <=> $b->getAttemptOverviewInformation()?->getReachedPointsInPercent(),
235 'test_passed' => static fn(
238 ) => $a->getAttemptOverviewInformation()?->hasPassingMark()
239 <=> $b->getAttemptOverviewInformation()?->hasPassingMark(),
240 'mark' => static fn(
243 ) => $a->getAttemptOverviewInformation()?->getMark() <=> $b->getAttemptOverviewInformation()?->getMark(),
244 'matriculation' => static fn(
247 ) => $a->getMatriculation() <=> $b->getMatriculation(),
248 'id_of_attempt' => static fn(
251 ) => $a->getAttemptOverviewInformation()?->getExamId() <=> $b->getAttemptOverviewInformation()?->getExamId(),
252 'total_time_on_task' => static fn(
255 ) => $a->getAttemptOverviewInformation()?->getTotalTimeOnTask() <=> $b->getAttemptOverviewInformation()?->getTotalTimeOnTask()
256 ];
257 }
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples

References Vendor\Package\$a, and Vendor\Package\$b.

◆ getTableComponent()

ILIAS\Test\Participants\ParticipantTable::getTableComponent ( ServerRequestInterface  $request,
?array  $filter 
)
private

Definition at line 337 of file ParticipantTable.php.

338 {
339 return $this->ui_factory
340 ->table()
341 ->data(
342 $this,
343 $this->lng->txt('list_of_participants'),
344 $this->getColumns(),
345 )
346 ->withId(self::ID)
347 ->withRequest($request)
348 ->withFilter($filter);
349 }

References ILIAS\Repository\lng().

Referenced by ILIAS\Test\Participants\ParticipantTable\getComponents().

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

◆ getTotalRowCount()

ILIAS\Test\Participants\ParticipantTable::getTotalRowCount ( ?array  $filter_data,
?array  $additional_parameters 
)

Mainly for the purpose of pagination-support, it is important to know about the total number of records available.

Given the nature of a DataTable, which is, opposite to a PresentationTable, rather administrative than explorative, this information will increase user experience quite a bit. However, you may return null, if the call is to costly, but expect the View Control to look a little different in this case.

Make sure that potential filters or user restrictions are being applied to the count.

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 84 of file ParticipantTable.php.

84 : ?int
85 {
86 return $this->repository->countParticipants($this->test_object->getTestId(), $filter_data);
87 }

References ILIAS\UI\examples\Deck\repository().

+ Here is the call graph for this function:

◆ getViewControlledRecords()

ILIAS\Test\Participants\ParticipantTable::getViewControlledRecords ( ?array  $filter_data,
Range  $range,
Order  $order 
)
private
Returns
iterable<Participant>

Definition at line 506 of file ParticipantTable.php.

506 : iterable
507 {
508 return $this->limitRecords(
509 $this->orderRecords(
510 $this->filterRecords(
511 $this->results_data_factory->addAttemptOverviewInformationToParticipants(
512 $this->results_presentation_settings,
513 $this->test_object,
514 $this->loadRecords($filter_data, $order)
515 ),
516 $filter_data
517 ),
518 $order
519 ),
520 $range
521 );
522 }
filterRecords(iterable $records, ?array $filter_data)
orderRecords(iterable $records, Order $order)
limitRecords(array $records, Range $range)

References ILIAS\UI\Implementation\Component\Table\$range.

◆ limitRecords()

ILIAS\Test\Participants\ParticipantTable::limitRecords ( array  $records,
Range  $range 
)
private

Definition at line 575 of file ParticipantTable.php.

575 : array
576 {
577 return array_slice($records, $range->getStart(), $range->getLength());
578 }

References ILIAS\UI\Implementation\Component\Table\$range, ILIAS\Data\Range\getLength(), and ILIAS\Data\Range\getStart().

+ Here is the call graph for this function:

◆ loadRecords()

ILIAS\Test\Participants\ParticipantTable::loadRecords ( ?array  $filter,
Order  $order 
)
private

Definition at line 458 of file ParticipantTable.php.

458 : iterable
459 {
460 if ($this->records !== null) {
461 return $this->records;
462 }
463
464 $records = iterator_to_array(
465 $this->repository->getParticipants(
466 $this->test_object->getTestId(),
467 $filter,
468 null,
469 $order
470 )
471 );
472
473 $this->records = array_filter(
474 $records,
475 fn(Participant $participant) => in_array(
476 $participant->getUserId(),
477 $this->buildAccessFilteredParticipantsList($records)
478 )
479 );
480
481 return $this->records;
482 }

References ILIAS\Test\Participants\Participant\getUserId(), and ILIAS\UI\examples\Deck\repository().

+ Here is the call graph for this function:

◆ matchFilter()

ILIAS\Test\Participants\ParticipantTable::matchFilter ( Participant  $record,
?array  $filter 
)
private

Definition at line 533 of file ParticipantTable.php.

533 : bool
534 {
535 if ($filter === null) {
536 return true;
537 }
538
539 $post_load_filters = $this->getPostLoadFilters();
540 $allow = true;
541
542 foreach ($filter as $key => $value) {
543 if (!$value) {
544 continue;
545 }
546
547 $post_load_filter = $post_load_filters[$key] ?? fn() => true;
548 $allow = $allow && $post_load_filter($value, $record);
549 }
550
551 return $allow;
552 }

◆ orderRecords()

ILIAS\Test\Participants\ParticipantTable::orderRecords ( iterable  $records,
Order  $order 
)
private

Definition at line 554 of file ParticipantTable.php.

554 : array
555 {
556 $post_load_order_fields = $this->getPostLoadOrderFields();
557 $records = iterator_to_array($records);
558
559 uasort($records, static function (Participant $a, Participant $b) use ($order, $post_load_order_fields) {
560 foreach ($order->get() as $subject => $direction) {
561 $post_load_order_field = $post_load_order_fields[$subject] ?? fn() => 0;
562 $index = $post_load_order_field($a, $b);
563
564 if ($index !== 0) {
565 return $direction === 'DESC' ? $index * -1 : $index;
566 }
567 }
568
569 return 0;
570 });
571
572 return $records;
573 }

References Vendor\Package\$a, Vendor\Package\$b, and ILIAS\Data\Order\get().

+ Here is the call graph for this function:

Field Documentation

◆ $records

iterable ILIAS\Test\Participants\ParticipantTable::$records = null
private

Definition at line 42 of file ParticipantTable.php.

◆ $scoring_enabled

bool ILIAS\Test\Participants\ParticipantTable::$scoring_enabled = false
private

Definition at line 43 of file ParticipantTable.php.

◆ ID

const ILIAS\Test\Participants\ParticipantTable::ID = 'pt'
private

Definition at line 41 of file ParticipantTable.php.


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