ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
class.ilAnswerFrequencyStatisticTableGUI.php
Go to the documentation of this file.
1<?php
2
19use ILIAS\UI\Factory as UIFactory;
20use ILIAS\UI\Renderer as UIRenderer;
21use ILIAS\Refinery\Factory as RefineryFactory;
22
24{
26 protected UIFactory $ui_factory;
27 protected UIRenderer $ui_renderer;
28 protected RefineryFactory $refinery;
30 protected ilCtrl $ctrl;
31 protected int $questionIndex;
32 protected bool $actionsColumnEnabled = false;
33 protected string $additionalHtml = '';
34
38 public function __construct(
39 ilTestCorrectionsGUI $a_parent_obj,
40 string $a_parent_cmd,
41 protected readonly assQuestion $question
42 ) {
44 global $DIC;
45
46 $this->language = $DIC['lng'];
47 $this->ui_factory = $DIC['ui.factory'];
48 $this->ui_renderer = $DIC['ui.renderer'];
49 $this->refinery = $DIC['refinery'];
50 $this->ctrl = $DIC['ilCtrl'];
52 'qpl_usersolution'
53 );
54
55 $this->setId('tstAnswerStatistic');
56 $this->setPrefix('tstAnswerStatistic');
57 $this->setTitle($this->language->txt('tst_corrections_answers_tbl'));
58
59 $this->setRowTemplate('tpl.tst_corrections_answer_row.html', 'components/ILIAS/Test');
60
61 parent::__construct($a_parent_obj, $a_parent_cmd, $a_template_context = '');
62
63 $this->setDefaultOrderDirection('asc');
64 $this->setDefaultOrderField('answer');
65 }
66
67 public function isActionsColumnEnabled(): bool
68 {
70 }
71
73 {
74 $this->actionsColumnEnabled = $actionsColumnEnabled;
75 }
76
77 public function getAdditionalHtml(): string
78 {
80 }
81
82 public function setAdditionalHtml(string $additional_html): void
83 {
84 $this->additionalHtml = $additional_html;
85 }
86
87 public function addAdditionalHtml(string $additional_html): void
88 {
89 $this->additionalHtml .= $additional_html;
90 }
91
92 public function getQuestionIndex(): int
93 {
95 }
96
97 public function setQuestionIndex(int $questionIndex): void
98 {
99 $this->questionIndex = $questionIndex;
100 }
101
102 public function initColumns(): void
103 {
104 $this->addColumn($this->language->txt('tst_corr_answ_stat_tbl_header_answer'), '');
105 $this->addColumn($this->language->txt('tst_corr_answ_stat_tbl_header_frequency'), '');
106
107 foreach ($this->getData() as $row) {
108 if (isset($row['addable'])) {
109 $this->setActionsColumnEnabled(true);
110 $this->addColumn('');
111 break;
112 }
113 }
114 }
115
116 public function fillRow(array $a_set): void
117 {
118 $a_set['answer'] = $this->purifier->purify($a_set['answer']);
119
120 $this->tpl->setCurrentBlock('answer');
121 $this->tpl->setVariable('ANSWER', $a_set['answer']);
122 $this->tpl->parseCurrentBlock();
123
124 $this->tpl->setCurrentBlock('frequency');
125 $this->tpl->setVariable('FREQUENCY', $a_set['frequency']);
126 $this->tpl->parseCurrentBlock();
127
128 if ($this->isActionsColumnEnabled()) {
129 if (isset($a_set['addable'])) {
130 $this->tpl->setCurrentBlock('actions');
131 $this->tpl->setVariable('ACTIONS', $this->buildAddAnswerAction($a_set));
132 $this->tpl->parseCurrentBlock();
133 } else {
134 $this->tpl->setCurrentBlock('actions');
135 $this->tpl->touchBlock('actions');
136 $this->tpl->parseCurrentBlock();
137 }
138 }
139 }
140
141 protected function buildAddAnswerAction($data): string
142 {
143 $data['question_id'] = $this->question->getId();
144 $data['question_index'] = $this->getQuestionIndex();
145
146 $modal = (new ilAddAnswerFormBuilder(
147 $this->ui_factory,
148 $this->refinery,
149 $this->language,
150 $this->ctrl
151 ))->buildAddAnswerModal($this->question->getTitleForHTMLOutput(), $data);
152
153 $show_modal_button = $this->ui_factory->button()->standard(
154 $this->language->txt('tst_corr_add_as_answer_btn'),
155 $modal->getShowSignal()
156 );
157
158 $this->addAdditionalHtml($this->ui_renderer->render($modal));
159
160 return $this->ui_renderer->render($show_modal_button);
161 }
162}
Builds a Color from either hex- or rgb values.
Definition: Factory.php:31
Builds data types.
Definition: Factory.php:36
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
fillRow(array $a_set)
Standard Version of Fill Row.
Class ilCtrl provides processing control methods.
static getInstanceByType(string $type)
language handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(?object $a_parent_obj, string $a_parent_cmd="", string $a_template_context="")
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
setPrefix(string $a_prefix)
set prefix for sort and offset fields (if you have two or more tables on a page that you want to sort...
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
An entity that renders components to a string output.
Definition: Renderer.php:31
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26