19declare(strict_types=1);
24use GuzzleHttp\Psr7\ServerRequest;
37use Psr\Http\Message\ServerRequestInterface;
45 private readonly
string $table_id,
46 private readonly \
ilObjUser $current_user,
47 private readonly UIFactory $ui_factory,
48 private readonly UIRenderer $ui_renderer,
50 private readonly \
ilCtrl $ctrl,
51 private readonly DataFactory $data_factory,
53 private readonly TaxonomyService $taxonomy,
54 private readonly
string $parent_title
60 return $this->ui_factory->table()->data(
62 $this->
lng->txt(
'list_of_questions'),
66 ->withRequest($request)
67 ->withFilter($filter);
72 $column_factory = $this->ui_factory->table()->column();
73 $icon_factory = $this->ui_factory->symbol()->icon();
74 $iconYes = $icon_factory->custom(
'assets/images/standard/icon_checked.svg',
'yes');
75 $iconNo = $icon_factory->custom(
'assets/images/standard/icon_unchecked.svg',
'no');
78 'title' => $column_factory->text(
79 $this->
lng->txt(
'tst_question_title')
80 )->withIsOptional(
false,
true),
81 'description' => $column_factory->text(
82 $this->
lng->txt(
'description')
83 )->withIsOptional(
true,
true),
84 'question_type' => $column_factory->text(
85 $this->
lng->txt(
'tst_question_type')
86 )->withIsOptional(
false,
true),
87 'points' => $column_factory->number(
88 $this->
lng->txt(
'points')
89 )->withIsOptional(
false,
true),
90 'author' => $column_factory->text(
91 $this->
lng->txt(
'author')
92 )->withIsOptional(
true,
false),
93 'lifecycle' => $column_factory->text(
94 $this->
lng->txt(
'qst_lifecycle')
95 )->withIsOptional(
true,
false),
96 'parent_title' => $column_factory->link(
97 $this->
lng->txt($this->parent_title)
98 )->withIsOptional(
false,
true),
99 'taxonomies' => $column_factory->text(
100 $this->
lng->txt(
'qpl_settings_subtab_taxonomies')
101 )->withIsOptional(
false,
true),
102 'feedback' => $column_factory->boolean(
103 $this->
lng->txt(
'tst_feedback'),
106 )->withIsOptional(
true,
false),
107 'created' => $column_factory->date(
108 $this->
lng->txt(
'created'),
109 $this->current_user->getDateTimeFormat()
110 )->withIsOptional(
true,
false),
111 'tstamp' => $column_factory->date(
112 $this->
lng->txt(
'updated'),
113 $this->current_user->getDateTimeFormat()
114 )->withIsOptional(
true,
false)
127 $url_builder =
new URLBuilder($this->data_factory->uri(
128 ILIAS_HTTP_PATH .
"/{$this->ctrl->getLinkTargetByClass(
129 ilTestQuestionBrowserTableGUI::class,
130 ilTestQuestionBrowserTableGUI::CMD_INSERT_QUESTIONS
134 [$url_builder, $row_id_token] = $url_builder->acquireParameters([
'qlist'],
'q_id');
136 return $this->ui_factory->table()->action()->standard(
137 $this->
lng->txt(
'tst_insert_in_test'),
145 array $visible_column_ids,
148 mixed $additional_viewcontrol_data,
150 mixed $additional_parameters
152 $timezone = new \DateTimeZone($this->current_user->getTimeZone());
154 $question_id = $record[
'question_id'];
156 $record[
'question_type'] = $record[
'question_type'];
157 $record[
'complete'] = (bool) $record[
'complete'];
160 $record[
'created'] = (new \DateTimeImmutable(
"@{$record['created']}"))->setTimezone($timezone);
161 $record[
'tstamp'] = (new \DateTimeImmutable(
"@{$record['tstamp']}"))->setTimezone($timezone);
165 yield $row_builder->
buildDataRow((
string) $question_id, $record);
171 [$parent_class, $parent_command] = match($record[
'parent_type']) {
174 default =>
throw new \RuntimeException(
"Unsupported parent type {$record['parent_type']}"),
177 $this->
ctrl->setParameterByClass($parent_class,
'ref_id', $record[
'parent_ref_id']);
178 $link = $this->ui_factory->link()->standard(
179 $record[
'parent_title'],
180 $this->
ctrl->getLinkTargetByClass($parent_class, $parent_command),
182 $this->
ctrl->setParameterByClass($parent_class,
'ref_id',
null);
188 mixed $additional_viewcontrol_data,
190 mixed $additional_parameters
193 $this->addFiltersToQuestionList($filter_data);
194 return $this->question_list->getTotalRowCount($additional_viewcontrol_data, $filter_data, $additional_parameters);
199 $this->addFiltersToQuestionList($filters);
201 $this->question_list->setOrder($order);
202 $this->question_list->setRange(
$range);
203 $this->question_list->load();
205 return $this->question_list->getQuestionDataArray();
210 foreach (array_filter($filters) as $key => $filter) {
211 if ($key ===
'commented') {
212 $this->question_list->setCommentFilter((
int) $filter);
216 $this->question_list->addFieldFilter($key, $filter);
222 $available_taxonomy_ids = $this->taxonomy->getUsageOfObject($obj_fi);
223 $data = $this->loadTaxonomyAssignmentData($obj_fi, $questionId, $available_taxonomy_ids);
227 foreach (
$data as $taxonomyId => $taxData) {
229 $taxonomies[] = $this->ui_renderer->render(
230 $this->ui_factory->listing()->unordered(
231 array_map(
static function ($node) {
232 return \ilTaxonomyNode::_lookupTitle($node[
'node_id']);
238 return implode(
'', $taxonomies);
243 $taxonomyAssignmentData = [];
245 foreach ($available_taxonomy_ids as $taxId) {
246 $taxTree = new \ilTaxonomyTree($taxId);
247 $assignments = (new \ilTaxNodeAssignment(
252 ))->getAssignmentsOfItem($questionId);
254 foreach ($assignments as $assData) {
255 $taxId = $assData[
'tax_id'];
256 if (!isset($taxonomyAssignmentData[$taxId])) {
257 $taxonomyAssignmentData[$taxId] = [];
260 $nodeId = $assData[
'node_id'];
261 $assData[
'node_lft'] = $taxTree->getNodeData($nodeId)[
'lft'];
262 $taxonomyAssignmentData[$taxId][$nodeId] = $assData;
266 return $taxonomyAssignmentData;
Builds a Color from either hex- or rgb values.
Both the subject and the direction need to be specified when expressing an order.
A simple class to express a naive range of whole positive numbers.
resolveTaxonomiesRowData(int $obj_fi, int $questionId)
loadTaxonomyAssignmentData(int $parentObjId, int $questionId, array $available_taxonomy_ids)
getParentObjectLink(array $record)
getTotalRowCount(mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
Mainly for the purpose of pagination-support, it is important to know about the total number of recor...
addFiltersToQuestionList(array $filters)
getRows(DataRowBuilder $row_builder, array $visible_column_ids, Range $range, Order $order, mixed $additional_viewcontrol_data, mixed $filter_data, mixed $additional_parameters)
This is called by the table to retrieve rows; map data-records to rows using the $row_builder e....
__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)
loadRecords(array $filters=[], ?Order $order=null, ?Range $range=null)
getComponent(ServerRequestInterface $request, ?array $filter)
static getInstance($identifier)
Class ilCtrl provides processing control methods.
static _lookupTitle(int $obj_id)
@ilCtrl_Calls ilTestQuestionBrowserTableGUI: ilFormPropertyDispatchGUI
A Column describes the form of presentation for a certain aspect of data, i.e.
withIsSortable(bool $flag)
buildDataRow(string $id, array $record)
This describes a Data Table.
withId(string $id)
The DataTable comes with a storage to keep e.g.
An entity that renders components to a string output.