ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\Test\Questions\Presentation\QuestionsBrowserTable Class Reference
+ Inheritance diagram for ILIAS\Test\Questions\Presentation\QuestionsBrowserTable:
+ Collaboration diagram for ILIAS\Test\Questions\Presentation\QuestionsBrowserTable:

Public Member Functions

 __construct (private readonly string $table_id, private readonly \ilObjUser $current_user, private readonly UIFactory $ui_factory, private readonly UIRenderer $ui_renderer, private readonly \ilLanguage $lng, private readonly \ilCtrl $ctrl, private readonly DataFactory $data_factory, private readonly \ilAssQuestionList $question_list, private readonly TaxonomyService $taxonomy, private readonly string $parent_title)
 
 getComponent (ServerRequestInterface $request, ?array $filter)
 
 getColumns ()
 
 getActions ()
 
 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...
 
 loadRecords (array $filters=[], ?Order $order=null, ?Range $range=null)
 

Data Fields

const ACTION_INSERT = 'insert'
 

Private Member Functions

 getInsertAction ()
 
 addFiltersToQuestionList (array $filters)
 
 resolveTaxonomiesRowData (int $obj_fi, int $questionId)
 
 loadTaxonomyAssignmentData (int $parentObjId, int $questionId, array $available_taxonomy_ids)
 

Detailed Description

Definition at line 39 of file QuestionsBrowserTable.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Test\Questions\Presentation\QuestionsBrowserTable::__construct ( private readonly string  $table_id,
private readonly \ilObjUser  $current_user,
private readonly UIFactory  $ui_factory,
private readonly UIRenderer  $ui_renderer,
private readonly \ilLanguage  $lng,
private readonly \ilCtrl  $ctrl,
private readonly DataFactory  $data_factory,
private readonly \ilAssQuestionList  $question_list,
private readonly TaxonomyService  $taxonomy,
private readonly string  $parent_title 
)

Definition at line 43 of file QuestionsBrowserTable.php.

54  {
55  }

Member Function Documentation

◆ addFiltersToQuestionList()

ILIAS\Test\Questions\Presentation\QuestionsBrowserTable::addFiltersToQuestionList ( array  $filters)
private

Definition at line 189 of file QuestionsBrowserTable.php.

Referenced by ILIAS\Test\Questions\Presentation\QuestionsBrowserTable\getTotalRowCount(), and ILIAS\Test\Questions\Presentation\QuestionsBrowserTable\loadRecords().

189  : void
190  {
191  foreach (array_filter($filters) as $key => $filter) {
192  if ($key === 'commented') {
193  $this->question_list->setCommentFilter((int) $filter);
194  continue;
195  }
196 
197  $this->question_list->addFieldFilter($key, $filter);
198  }
199  }
+ Here is the caller graph for this function:

◆ getActions()

ILIAS\Test\Questions\Presentation\QuestionsBrowserTable::getActions ( )

Definition at line 124 of file QuestionsBrowserTable.php.

References ILIAS\Test\Questions\Presentation\QuestionsBrowserTable\getInsertAction().

Referenced by ILIAS\Test\Questions\Presentation\QuestionsBrowserTable\getComponent().

124  : array
125  {
126  return [self::ACTION_INSERT => $this->getInsertAction()];
127  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getColumns()

ILIAS\Test\Questions\Presentation\QuestionsBrowserTable::getColumns ( )

Definition at line 69 of file QuestionsBrowserTable.php.

References ILIAS\Repository\lng(), and ILIAS\UI\Component\Table\Column\Column\withIsSortable().

Referenced by ILIAS\Test\Questions\Presentation\QuestionsBrowserTable\getComponent().

69  : array
70  {
71  $column_factory = $this->ui_factory->table()->column();
72  $icon_factory = $this->ui_factory->symbol()->icon();
73  $iconYes = $icon_factory->custom('assets/images/standard/icon_checked.svg', 'yes');
74  $iconNo = $icon_factory->custom('assets/images/standard/icon_unchecked.svg', 'no');
75 
76  $columns = [
77  'title' => $column_factory->text(
78  $this->lng->txt('tst_question_title')
79  )->withIsOptional(false, true),
80  'description' => $column_factory->text(
81  $this->lng->txt('description')
82  )->withIsOptional(true, true),
83  'type_tag' => $column_factory->text(
84  $this->lng->txt('tst_question_type')
85  )->withIsOptional(false, true),
86  'points' => $column_factory->number(
87  $this->lng->txt('points')
88  )->withIsOptional(false, true),
89  'author' => $column_factory->text(
90  $this->lng->txt('author')
91  )->withIsOptional(true, false),
92  'lifecycle' => $column_factory->text(
93  $this->lng->txt('qst_lifecycle')
94  )->withIsOptional(true, false),
95  'parent_title' => $column_factory->text(
96  $this->lng->txt($this->parent_title)
97  )->withIsOptional(false, true),
98  'taxonomies' => $column_factory->text(
99  $this->lng->txt('qpl_settings_subtab_taxonomies')
100  )->withIsOptional(false, true),
101  'feedback' => $column_factory->boolean(
102  $this->lng->txt('feedback'),
103  $iconYes,
104  $iconNo
105  )->withIsOptional(true, false),
106  'hints' => $column_factory->boolean(
107  $this->lng->txt('hints'),
108  $iconYes,
109  $iconNo
110  )->withIsOptional(true, false),
111  'created' => $column_factory->date(
112  $this->lng->txt('created'),
113  $this->current_user->getDateTimeFormat()
114  )->withIsOptional(true, false),
115  'tstamp' => $column_factory->date(
116  $this->lng->txt('updated'),
117  $this->current_user->getDateTimeFormat()
118  )->withIsOptional(true, false)
119  ];
120 
121  return array_map(static fn(Column $column): Column => $column->withIsSortable(true), $columns);
122  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getComponent()

ILIAS\Test\Questions\Presentation\QuestionsBrowserTable::getComponent ( ServerRequestInterface  $request,
?array  $filter 
)

Definition at line 57 of file QuestionsBrowserTable.php.

References ILIAS\Test\Questions\Presentation\QuestionsBrowserTable\getActions(), ILIAS\Test\Questions\Presentation\QuestionsBrowserTable\getColumns(), and ILIAS\Repository\lng().

57  : Data
58  {
59  return $this->ui_factory->table()->data(
60  $this,
61  $this->lng->txt('list_of_questions'),
62  $this->getColumns(),
63  )->withId($this->table_id)
64  ->withActions($this->getActions())
65  ->withRequest($request)
66  ->withFilter($filter);
67  }
+ Here is the call graph for this function:

◆ getInsertAction()

ILIAS\Test\Questions\Presentation\QuestionsBrowserTable::getInsertAction ( )
private

Definition at line 129 of file QuestionsBrowserTable.php.

References ilTestQuestionBrowserTableGUI\CMD_INSERT_QUESTIONS, and ILIAS\Repository\lng().

Referenced by ILIAS\Test\Questions\Presentation\QuestionsBrowserTable\getActions().

129  : TableAction
130  {
131  $url_builder = new URLBuilder($this->data_factory->uri(
132  ServerRequest::getUriFromGlobals() . $this->ctrl->getLinkTargetByClass(
133  ilTestQuestionBrowserTableGUI::class,
135  )
136  ));
137 
138  [$url_builder, $row_id_token] = $url_builder->acquireParameters(['qlist'], 'q_id');
139 
140  return $this->ui_factory->table()->action()->standard(
141  $this->lng->txt('tst_insert_in_test'),
142  $url_builder,
143  $row_id_token
144  );
145  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getRows()

ILIAS\Test\Questions\Presentation\QuestionsBrowserTable::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.

yield $row_builder->buildStandardRow($row_id, $record).

Parameters
string[]$visible_column_ids

Implements ILIAS\UI\Component\Table\DataRetrieval.

Definition at line 147 of file QuestionsBrowserTable.php.

References ILIAS\UI\Component\Table\DataRowBuilder\buildDataRow(), ilAssQuestionLifecycle\getInstance(), ILIAS\Repository\lng(), ILIAS\Test\Questions\Presentation\QuestionsBrowserTable\loadRecords(), and ILIAS\Test\Questions\Presentation\QuestionsBrowserTable\resolveTaxonomiesRowData().

154  : \Generator {
155  $timezone = new \DateTimeZone($this->current_user->getTimeZone());
156  foreach ($this->loadRecords($filter_data ?? [], $order, $range) as $record) {
157  $question_id = $record['question_id'];
158 
159  $record['type_tag'] = $this->lng->txt($record['type_tag']);
160  $record['complete'] = (bool) $record['complete'];
161  $record['lifecycle'] = \ilAssQuestionLifecycle::getInstance($record['lifecycle'])->getTranslation($this->lng) ?? '';
162 
163  $record['created'] = (new \DateTimeImmutable("@{$record['created']}"))->setTimezone($timezone);
164  $record['tstamp'] = (new \DateTimeImmutable("@{$record['tstamp']}"))->setTimezone($timezone);
165  $record['taxonomies'] = $this->resolveTaxonomiesRowData($record['obj_fi'], $question_id);
166 
167  yield $row_builder->buildDataRow((string) $question_id, $record);
168  }
169  }
loadRecords(array $filters=[], ?Order $order=null, ?Range $range=null)
+ Here is the call graph for this function:

◆ getTotalRowCount()

ILIAS\Test\Questions\Presentation\QuestionsBrowserTable::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 171 of file QuestionsBrowserTable.php.

References ILIAS\Test\Questions\Presentation\QuestionsBrowserTable\addFiltersToQuestionList().

171  : int
172  {
173  $filter_data ??= [];
174  $this->addFiltersToQuestionList($filter_data);
175  return $this->question_list->getTotalRowCount($filter_data, $additional_parameters);
176  }
+ Here is the call graph for this function:

◆ loadRecords()

ILIAS\Test\Questions\Presentation\QuestionsBrowserTable::loadRecords ( array  $filters = [],
?Order  $order = null,
?Range  $range = null 
)

Definition at line 178 of file QuestionsBrowserTable.php.

References ILIAS\UI\Implementation\Component\Table\$range, and ILIAS\Test\Questions\Presentation\QuestionsBrowserTable\addFiltersToQuestionList().

Referenced by ILIAS\Test\Questions\Presentation\QuestionsBrowserTable\getRows().

178  : array
179  {
180  $this->addFiltersToQuestionList($filters);
181 
182  $this->question_list->setOrder($order);
183  $this->question_list->setRange($range);
184  $this->question_list->load();
185 
186  return $this->question_list->getQuestionDataArray();
187  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ loadTaxonomyAssignmentData()

ILIAS\Test\Questions\Presentation\QuestionsBrowserTable::loadTaxonomyAssignmentData ( int  $parentObjId,
int  $questionId,
array  $available_taxonomy_ids 
)
private

Definition at line 222 of file QuestionsBrowserTable.php.

Referenced by ILIAS\Test\Questions\Presentation\QuestionsBrowserTable\resolveTaxonomiesRowData().

222  : array
223  {
224  $taxonomyAssignmentData = [];
225 
226  foreach ($available_taxonomy_ids as $taxId) {
227  $taxTree = new \ilTaxonomyTree($taxId);
228  $assignments = (new \ilTaxNodeAssignment(
229  'qpl',
230  $parentObjId,
231  'quest',
232  $taxId
233  ))->getAssignmentsOfItem($questionId);
234 
235  foreach ($assignments as $assData) {
236  $taxId = $assData['tax_id'];
237  if (!isset($taxonomyAssignmentData[$taxId])) {
238  $taxonomyAssignmentData[$taxId] = [];
239  }
240 
241  $nodeId = $assData['node_id'];
242  $assData['node_lft'] = $taxTree->getNodeData($nodeId)['lft'];
243  $taxonomyAssignmentData[$taxId][$nodeId] = $assData;
244  }
245  }
246 
247  return $taxonomyAssignmentData;
248  }
+ Here is the caller graph for this function:

◆ resolveTaxonomiesRowData()

ILIAS\Test\Questions\Presentation\QuestionsBrowserTable::resolveTaxonomiesRowData ( int  $obj_fi,
int  $questionId 
)
private

Definition at line 201 of file QuestionsBrowserTable.php.

References $data, ilObject\_lookupTitle(), and ILIAS\Test\Questions\Presentation\QuestionsBrowserTable\loadTaxonomyAssignmentData().

Referenced by ILIAS\Test\Questions\Presentation\QuestionsBrowserTable\getRows().

201  : string
202  {
203  $available_taxonomy_ids = $this->taxonomy->getUsageOfObject($obj_fi);
204  $data = $this->loadTaxonomyAssignmentData($obj_fi, $questionId, $available_taxonomy_ids);
205 
206  $taxonomies = [];
207 
208  foreach ($data as $taxonomyId => $taxData) {
209  $taxonomies[] = \ilObject::_lookupTitle($taxonomyId);
210  $taxonomies[] = $this->ui_renderer->render(
211  $this->ui_factory->listing()->unordered(
212  array_map(static function ($node) {
213  return \ilTaxonomyNode::_lookupTitle($node['node_id']);
214  }, $taxData)
215  )
216  );
217  }
218 
219  return implode('', $taxonomies);
220  }
loadTaxonomyAssignmentData(int $parentObjId, int $questionId, array $available_taxonomy_ids)
static _lookupTitle(int $obj_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ ACTION_INSERT

const ILIAS\Test\Questions\Presentation\QuestionsBrowserTable::ACTION_INSERT = 'insert'

Definition at line 41 of file QuestionsBrowserTable.php.


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