ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
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 if (!isset($a_set['sanitized']) || !$a_set['sanitized']) {
115 $a_set['answer'] = ilLegacyFormElementsUtil::prepareFormOutput((string) $a_set['answer']);
116 }
117
118 $this->tpl->setCurrentBlock('answer');
119 $this->tpl->setVariable('ANSWER', $a_set['answer']);
120 $this->tpl->parseCurrentBlock();
121
122 $this->tpl->setCurrentBlock('frequency');
123 $this->tpl->setVariable('FREQUENCY', $a_set['frequency']);
124 $this->tpl->parseCurrentBlock();
125
126 if ($this->isActionsColumnEnabled()) {
127 if (isset($a_set['addable'])) {
128 $this->tpl->setCurrentBlock('actions');
129 $this->tpl->setVariable('ACTIONS', $this->buildAddAnswerAction($a_set));
130 $this->tpl->parseCurrentBlock();
131 } else {
132 $this->tpl->setCurrentBlock('actions');
133 $this->tpl->touchBlock('actions');
134 $this->tpl->parseCurrentBlock();
135 }
136 }
137 }
138
139 protected function buildAddAnswerAction($data): string
140 {
141 $data['question_id'] = $this->question->getId();
142 $data['question_index'] = $this->getQuestionIndex();
143
144 $modal = (new ilAddAnswerFormBuilder(
145 $this->ui_factory,
146 $this->refinery,
147 $this->language,
148 $this->ctrl
149 ))->buildAddAnswerModal($this->question->getTitleForHTMLOutput(), $data);
150
151 $show_modal_button = $this->ui_factory->button()->standard(
152 $this->language->txt('tst_corr_add_as_answer_btn'),
153 $modal->getShowSignal()
154 );
155
156 $this->addAdditionalHtml($this->ui_renderer->render($modal));
157
158 return $this->ui_renderer->render($show_modal_button);
159 }
160}
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