ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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;
29 protected ilCtrl $ctrl;
30 protected int $questionIndex;
31 protected bool $actionsColumnEnabled = false;
32 protected string $additionalHtml = '';
33
37 public function __construct(
38 ilTestCorrectionsGUI $a_parent_obj,
39 string $a_parent_cmd,
40 protected readonly assQuestion $question
41 ) {
43 global $DIC;
44
45 $this->language = $DIC['lng'];
46 $this->ui_factory = $DIC['ui.factory'];
47 $this->ui_renderer = $DIC['ui.renderer'];
48 $this->refinery = $DIC['refinery'];
49 $this->ctrl = $DIC['ilCtrl'];
50
51 $this->setId('tstAnswerStatistic');
52 $this->setPrefix('tstAnswerStatistic');
53 $this->setTitle($this->language->txt('tst_corrections_answers_tbl'));
54
55 $this->setRowTemplate('tpl.tst_corrections_answer_row.html', 'components/ILIAS/Test');
56
57 parent::__construct($a_parent_obj, $a_parent_cmd, $a_template_context = '');
58
59 $this->setDefaultOrderDirection('asc');
60 $this->setDefaultOrderField('answer');
61 }
62
63 public function isActionsColumnEnabled(): bool
64 {
66 }
67
69 {
70 $this->actionsColumnEnabled = $actionsColumnEnabled;
71 }
72
73 public function getAdditionalHtml(): string
74 {
76 }
77
78 public function setAdditionalHtml(string $additional_html): void
79 {
80 $this->additionalHtml = $additional_html;
81 }
82
83 public function addAdditionalHtml(string $additional_html): void
84 {
85 $this->additionalHtml .= $additional_html;
86 }
87
88 public function getQuestionIndex(): int
89 {
91 }
92
93 public function setQuestionIndex(int $questionIndex): void
94 {
95 $this->questionIndex = $questionIndex;
96 }
97
98 public function initColumns(): void
99 {
100 $this->addColumn($this->language->txt('tst_corr_answ_stat_tbl_header_answer'), '');
101 $this->addColumn($this->language->txt('tst_corr_answ_stat_tbl_header_frequency'), '');
102
103 foreach ($this->getData() as $row) {
104 if (isset($row['addable'])) {
105 $this->setActionsColumnEnabled(true);
106 $this->addColumn('');
107 break;
108 }
109 }
110 }
111
112 public function fillRow(array $a_set): void
113 {
114 $a_set['answer'] = ilLegacyFormElementsUtil::prepareFormOutput((string) $a_set['answer']);
115
116 $this->tpl->setCurrentBlock('answer');
117 $this->tpl->setVariable('ANSWER', $a_set['answer']);
118 $this->tpl->parseCurrentBlock();
119
120 $this->tpl->setCurrentBlock('frequency');
121 $this->tpl->setVariable('FREQUENCY', $a_set['frequency']);
122 $this->tpl->parseCurrentBlock();
123
124 if ($this->isActionsColumnEnabled()) {
125 if (isset($a_set['addable'])) {
126 $this->tpl->setCurrentBlock('actions');
127 $this->tpl->setVariable('ACTIONS', $this->buildAddAnswerAction($a_set));
128 $this->tpl->parseCurrentBlock();
129 } else {
130 $this->tpl->setCurrentBlock('actions');
131 $this->tpl->touchBlock('actions');
132 $this->tpl->parseCurrentBlock();
133 }
134 }
135 }
136
137 protected function buildAddAnswerAction($data): string
138 {
139 $data['question_id'] = $this->question->getId();
140 $data['question_index'] = $this->getQuestionIndex();
141
142 $modal = (new ilAddAnswerFormBuilder(
143 $this->ui_factory,
144 $this->refinery,
145 $this->language,
146 $this->ctrl
147 ))->buildAddAnswerModal($this->question->getTitleForHTMLOutput(), $data);
148
149 $show_modal_button = $this->ui_factory->button()->standard(
150 $this->language->txt('tst_corr_add_as_answer_btn'),
151 $modal->getShowSignal()
152 );
153
154 $this->addAdditionalHtml($this->ui_renderer->render($modal));
155
156 return $this->ui_renderer->render($show_modal_button);
157 }
158}
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.
language handling
static prepareFormOutput($a_str, bool $a_strip=false)
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