ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
EditSkillsOfQuestionTable.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
28use ILIAS\UI\Factory as UIFactory;
30
32{
33 public const string ID = 'ska';
34
35 public function __construct(
36 private readonly RequestDataCollectorInterface $pool_request,
37 private readonly \ilAssQuestionSkillAssignmentList $assignment_list,
38 private readonly UIFactory $ui_factory,
39 private readonly \ilLanguage $lng,
40 private readonly EditSkillsOfQuestionTableActions $table_actions
41 ) {
42 }
43
47 public function getComponents(URLBuilder $url_builder): array
48 {
49 $question = \assQuestion::instantiateQuestion($this->pool_request->getQuestionId());
50 return [
51 $this->ui_factory->table()->data(
52 $this,
53 sprintf($this->lng->txt('qpl_skl_assignment_for_question'), $question->getTitle()),
54 $this->getColumns()
55 )
56 ->withActions(
57 $this->table_actions->getEnabledActions(...$this->acquireParameters($url_builder))
58 )
59 ->withRequest($this->pool_request->getRequest())
60 ];
61 }
62
63 public function getRows(
64 DataRowBuilder $row_builder,
65 array $visible_column_ids,
67 Order $order,
68 mixed $additional_viewcontrol_data,
69 mixed $filter_data,
70 mixed $additional_parameters
71 ): \Generator {
73 foreach ($this->retrieveRecords() as $record) {
74 yield $this->table_actions->setAvailabilityOnDataRow(
75 $row_builder->buildDataRow(
76 "{$record->getQuestionId()}_{$record->getSkillBaseId()}_{$record->getSkillTrefId()}",
77 [
78 'competence' => htmlspecialchars($record->getSkillTitle(), ENT_QUOTES, 'UTF-8', false),
79 'competence_tree' => $record->getSkillPath(),
80 'eval_mode' => $this->lng->txt($record->hasEvalModeBySolution()
81 ? 'qpl_skill_point_eval_mode_solution_compare'
82 : 'qpl_skill_point_eval_mode_quest_result'),
83 'points' => $record->getSkillPoints(),
84 ]
85 ),
86 $record
87 );
88 }
89 }
90
91 public function getTotalRowCount(
92 mixed $additional_viewcontrol_data,
93 mixed $filter_data,
94 mixed $additional_parameters
95 ): ?int {
96 return count(
97 $this->assignment_list->getAssignmentsByQuestionId(
98 $this->pool_request->getQuestionId()
99 )
100 );
101 }
102
103 public function acquireParameters(URLBuilder $url_builder): array
104 {
105 return $url_builder->acquireParameters(
106 [self::ID],
107 EditSkillsOfQuestionTableActions::ROW_ID_PARAMETER,
108 EditSkillsOfQuestionTableActions::ACTION_PARAMETER,
109 EditSkillsOfQuestionTableActions::ACTION_TYPE_PARAMETER
110 );
111 }
112
113 private function retrieveRecords(): iterable
114 {
115 return $this->assignment_list->getAssignmentsByQuestionId($this->pool_request->getQuestionId());
116 }
117
118 private function getColumns(): array
119 {
120 $column = $this->ui_factory->table()->column();
121 return [
122 'competence' => $column->text($this->lng->txt('tst_competence'))->withIsSortable(true),
123 'competence_tree' => $column->text($this->lng->txt('tst_competence_tree'))->withIsSortable(true),
124 'eval_mode' => $column->text($this->lng->txt('tst_comp_eval_mode'))->withIsSortable(true),
125 'points' => $column->number($this->lng->txt('tst_comp_points'))->withIsSortable(true)
126 ];
127 }
128}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Both the subject and the direction need to be specified when expressing an order.
Definition: Order.php:29
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:29
__construct(private readonly RequestDataCollectorInterface $pool_request, private readonly \ilAssQuestionSkillAssignmentList $assignment_list, private readonly UIFactory $ui_factory, private readonly \ilLanguage $lng, private readonly EditSkillsOfQuestionTableActions $table_actions)
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...
acquireParameters(array $namespace, string ... $names)
Definition: URLBuilder.php:138
static instantiateQuestion(int $question_id)
language handling
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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....
buildDataRow(string $id, array $record)
global $lng
Definition: privfeed.php:31