ILIAS  release_8 Revision v8.24
class.ilAnswerFrequencyStatisticTableGUI.php
Go to the documentation of this file.
1<?php
2
20use ILIAS\Refinery\Factory as RefineryFactory;
21
32{
34 protected UIServices $ui;
35 protected RefineryFactory $refinery;
36 protected ilCtrl $ctrl;
38 protected int $questionIndex;
39 protected bool $actionsColumnEnabled = false;
40 protected string $additionalHtml = '';
41
48 public function __construct($a_parent_obj, $a_parent_cmd = "", $question = "")
49 {
51 global $DIC;
52
53 $this->language = $DIC->language();
54 $this->ui = $DIC->ui();
55 $this->refinery = $DIC->refinery();
56 $this->ctrl = $DIC->ctrl();
57 $this->question = $question;
58
59 $this->setId('tstAnswerStatistic');
60 $this->setPrefix('tstAnswerStatistic');
61 $this->setTitle($this->language->txt('tst_corrections_answers_tbl'));
62
63 $this->setRowTemplate('tpl.tst_corrections_answer_row.html', 'Modules/Test');
64
65 parent::__construct($a_parent_obj, $a_parent_cmd, $a_template_context = '');
66
67 $this->setDefaultOrderDirection('asc');
68 $this->setDefaultOrderField('answer');
69 }
70
74 public function isActionsColumnEnabled(): bool
75 {
77 }
78
83 {
84 $this->actionsColumnEnabled = $actionsColumnEnabled;
85 }
86
90 public function getAdditionalHtml(): string
91 {
93 }
94
98 public function setAdditionalHtml(string $additionalHtml): void
99 {
100 $this->additionalHtml = $additionalHtml;
101 }
102
106 public function addAdditionalHtml(string $additionalHtml): void
107 {
108 $this->additionalHtml .= $additionalHtml;
109 }
110
114 public function getQuestionIndex(): int
115 {
117 }
118
122 public function setQuestionIndex(int $questionIndex): void
123 {
124 $this->questionIndex = $questionIndex;
125 }
126
127 public function initColumns(): void
128 {
129 $this->addColumn($this->language->txt('tst_corr_answ_stat_tbl_header_answer'), '');
130 $this->addColumn($this->language->txt('tst_corr_answ_stat_tbl_header_frequency'), '');
131
132 foreach ($this->getData() as $row) {
133 if (isset($row['addable'])) {
134 $this->setActionsColumnEnabled(true);
135 $this->addColumn('', '', '1%');
136 break;
137 }
138 }
139 }
140
141 public function fillRow(array $a_set): void
142 {
143 $this->tpl->setCurrentBlock('answer');
144 $this->tpl->setVariable('ANSWER', ilHtmlPurifierFactory::getInstanceByType('qpl_usersolution')->purify($a_set['answer']));
145 $this->tpl->parseCurrentBlock();
146
147 $this->tpl->setCurrentBlock('frequency');
148 $this->tpl->setVariable('FREQUENCY', $a_set['frequency']);
149 $this->tpl->parseCurrentBlock();
150
151 if ($this->isActionsColumnEnabled()) {
152 if (isset($a_set['addable'])) {
153 $this->tpl->setCurrentBlock('actions');
154 $this->tpl->setVariable('ACTIONS', $this->buildAddAnswerAction($a_set));
155 $this->tpl->parseCurrentBlock();
156 } else {
157 $this->tpl->setCurrentBlock('actions');
158 $this->tpl->touchBlock('actions');
159 $this->tpl->parseCurrentBlock();
160 }
161 }
162 }
163
164 protected function buildAddAnswerAction($data): string
165 {
166 $ui_factory = $this->ui->factory();
167 $ui_renderer = $this->ui->renderer();
168
169 $answer_form_builder = new ilAddAnswerFormBuilder($this->parent_obj, $ui_factory, $this->refinery, $this->language, $this->ctrl);
170
171 $data['question_id'] = $this->question->getId();
172 $data['question_index'] = $this->getQuestionIndex();
173
174 $form = $answer_form_builder->buildAddAnswerForm($data);
175 $modal = $ui_factory->modal()->roundtrip($this->question->getTitleForHTMLOutput(), $form);
176
177 $show_modal_button = $ui_factory->button()->standard(
178 $this->language->txt('tst_corr_add_as_answer_btn'),
179 $modal->getShowSignal()
180 );
181
182 $this->addAdditionalHtml($ui_renderer->render($modal));
183
184 return $ui_renderer->render($show_modal_button);
185 }
186
187 protected function purifyAndPrepareTextAreaOutput(string $content): string
188 {
189 $purified_content = $this->getHtmlQuestionContentPurifier()->purify($content);
190 if ($this->isAdditionalContentEditingModePageObject()
191 || !(new ilSetting('advanced_editing'))->get('advanced_editing_javascript_editor') === 'tinymce') {
192 $purified_content = nl2br($purified_content);
193 }
195 $purified_content,
196 true,
197 true
198 );
199 }
200}
Provides fluid interface to RBAC services.
Definition: UIServices.php:24
Builds data types.
Definition: Factory.php:21
Abstract basic class which is to be extended by the concrete assessment question type classes.
fillRow(array $a_set)
Standard Version of Fill Row.
Class ilCtrl provides processing control methods.
static getInstanceByType(string $type)
language handling
static prepareTextareaOutput(string $txt_output, bool $prepare_for_latex_output=false, bool $omitNl2BrWhenTextArea=false)
Prepares a string for a text area output where latex code may be in it If the text is HTML-free,...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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)
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc