ILIAS  trunk Revision v11.0_alpha-1753-gb21ca8c4367
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
RandomQuestionSetNonAvailablePoolsTable.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Test\Questions;
22 
23 use Generator;
34 use ilTestRandomQuestionSetSourcePoolDefinitionList as PoolDefinitionList;
37 
39 {
40  public function __construct(
41  protected readonly \ilCtrlInterface $ctrl,
42  protected readonly \ilLanguage $lng,
43  protected readonly UIFactory $ui_factory,
44  protected readonly DataFactory $data_factory,
45  protected readonly ServerRequestInterface $request,
46  protected readonly PoolDefinitionList $pool_definition_list
47  ) {
48  }
49 
50  public function getRows(
51  DataRowBuilder $row_builder,
52  array $visible_column_ids,
53  Range $range,
54  Order $order,
55  ?array $filter_data,
56  ?array $additional_parameters
57  ): Generator {
58  foreach ($this->getData($range, $order) as $record) {
60 
61  $record['status'] = $this->lng->txt('tst_non_avail_pool_msg_status_' . $record['status']);
62  yield $row_builder
63  ->buildDataRow((string) $record['id'], $record)
64  ->withDisabledAction('derive_pool', !$derive);
65  }
66  }
67 
68  public function getTotalRowCount(?array $filter_data, ?array $additional_parameters): ?int
69  {
70  return count($this->pool_definition_list->getNonAvailablePools());
71  }
72 
73  protected function getData(Range $range, Order $order): array
74  {
75  $data = array_map(fn($pool) => [
76  'id' => $pool->getId(),
77  'title' => $pool->getTitle(),
78  'path' => $pool->getPath(),
79  'status' => $pool->getUnavailabilityStatus(),
80  ], $this->pool_definition_list->getNonAvailablePools());
81  return array_slice($data, $range->getStart(), $range->getLength());
82  }
83 
84  public function getComponent(): DataTable
85  {
86  return $this->ui_factory->table()
87  ->data($this, $this->lng->txt('tst_non_avail_pools_table'), $this->getColumns())
88  ->withRequest($this->request)
89  ->withActions($this->getActions())
90  ->withId('tst_non_avail_pools_table');
91  }
92 
96  protected function getColumns(): array
97  {
98  $column_factory = $this->ui_factory->table()->column();
99  return [
100  'title' => $column_factory->text($this->lng->txt('title')),
101  'path' => $column_factory->text($this->lng->txt('path')),
102  'status' => $column_factory->text($this->lng->txt('status')),
103  ];
104  }
105 
109  protected function getActions(): array
110  {
111  $target = $this->data_factory->uri((string) $this->request->getUri());
112  $url_builder = new URLBuilder($target);
113  [$url_builder, $id_token] = $url_builder->acquireParameters(
114  ['derive_pool'],
115  'ids'
116  );
117  return [
118  'derive_pool' => $this->ui_factory->table()->action()->single(
119  $this->lng->txt('tst_derive_new_pool'),
120  $url_builder->withURI($target->withParameter('cmd', ConfigGUI::CMD_SELECT_DERIVATION_TARGET)),
121  $id_token
122  )
123  ];
124  }
125 }
__construct(protected readonly \ilCtrlInterface $ctrl, protected readonly \ilLanguage $lng, protected readonly UIFactory $ui_factory, protected readonly DataFactory $data_factory, protected readonly ServerRequestInterface $request, protected readonly PoolDefinitionList $pool_definition_list)
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...
Both the subject and the direction need to be specified when expressing an order. ...
Definition: Order.php:28
buildDataRow(string $id, array $record)
getTotalRowCount(?array $filter_data, ?array $additional_parameters)
Mainly for the purpose of pagination-support, it is important to know about the total number of recor...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $lng
Definition: privfeed.php:31
URLBuilder.
Definition: URLBuilder.php:40
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:28