ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilTestRandomQuestionSetSourcePoolDefinitionListTableGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/Table/classes/class.ilTable2GUI.php';
5
6use ILIAS\Modules\Test\QuestionPoolLinkedTitleBuilder;
7use ILIAS\UI\Factory as UIFactory;
8use ILIAS\UI\Renderer as UIRenderer;
9
18{
19 use QuestionPoolLinkedTitleBuilder;
20
21 const IDENTIFIER = 'tstRndPools';
22
26 protected $ctrl = null;
27
31 protected $lng = null;
32
37
42
43 // fau: taxFilter/typeFilter - flag to show the mapped taxonomy filter instead of the original
48 // fau.
49
54
55 private $access;
56 private $ui_factory;
57 private $ui_renderer;
58
59 public function __construct(ilCtrl $ctrl, ilLanguage $lng, $parentGUI, $parentCMD)
60 {
61 parent::__construct($parentGUI, $parentCMD);
62
63 $this->ctrl = $ctrl;
64 $this->lng = $lng;
65
66 global $DIC;
67 $this->access = $DIC['ilAccess'];
68 $this->ui_factory = $DIC['ui.factory'];
69 $this->ui_renderer = $DIC['ui.renderer'];
70 $this->definitionEditModeEnabled = false;
71 $this->questionAmountColumnEnabled = false;
72 }
73
75 {
76 $this->taxonomyLabelTranslater = $translater;
77 }
78
80 {
81 $this->definitionEditModeEnabled = $definitionEditModeEnabled;
82 }
83
85 {
87 }
88
90 {
91 $this->questionAmountColumnEnabled = $questionAmountColumnEnabled;
92 }
93
95 {
97 }
98
99 // fau: taxFilter - set flag to show the mapped tayonomy filter instead of original
101 {
102 $this->showMappedTaxonomyFilter = $showMappedTaxonomyFilter;
103 }
104 // fau.
105
106 public function fillRow($set)
107 {
108 if ($this->isDefinitionEditModeEnabled()) {
109 $this->tpl->setCurrentBlock('col_selection_checkbox');
110 $this->tpl->setVariable('SELECTION_CHECKBOX_HTML', $this->getSelectionCheckboxHTML($set['def_id']));
111 $this->tpl->parseCurrentBlock();
112
113 $this->tpl->setCurrentBlock('col_actions');
114 $this->tpl->setVariable('ACTIONS_HTML', $this->getActionsHTML($set['def_id']));
115 $this->tpl->parseCurrentBlock();
116
117 $this->tpl->setCurrentBlock('col_order_checkbox');
118 $this->tpl->setVariable('ORDER_INPUT_HTML', $this->getDefinitionOrderInputHTML(
119 $set['def_id'],
120 $this->getOrderNumberForSequencePosition($set['sequence_position'])
121 ));
122 $this->tpl->parseCurrentBlock();
123 }
124 // fau: taxFilter/typeFilter - show sequence position to identify the filter in the database
125 else {
126 $this->tpl->setCurrentBlock('col_order_checkbox');
127 $this->tpl->setVariable('ORDER_INPUT_HTML', $set['sequence_position']);
128 $this->tpl->parseCurrentBlock();
129 }
130 // fau.
131
132 if ($this->isQuestionAmountColumnEnabled()) {
133 if ($this->isDefinitionEditModeEnabled()) {
134 $questionAmountHTML = $this->getQuestionAmountInputHTML(
135 $set['def_id'],
136 $set['question_amount']
137 );
138 } else {
139 $questionAmountHTML = $set['question_amount'];
140 }
141
142 $this->tpl->setCurrentBlock('col_question_amount');
143 $this->tpl->setVariable('QUESTION_AMOUNT_INPUT_HTML', $questionAmountHTML);
144 $this->tpl->parseCurrentBlock();
145 }
146
147 $this->tpl->setVariable(
148 'SOURCE_POOL_LABEL',
149 $this->buildPossiblyLinkedQuestonPoolTitle(
150 $this->ctrl,
151 $this->access,
152 $this->lng,
153 $this->ui_factory,
154 $this->ui_renderer,
155 $set['ref_id'],
156 $set['source_pool_label'],
157 true
158 )
159 );
160 // fau: taxFilter/typeFilter - set taxonomy/type filter label in a single coulumn each
161 $this->tpl->setVariable('TAXONOMY_FILTER', $this->taxonomyLabelTranslater->getTaxonomyFilterLabel($set['taxonomy_filter'], '<br />'));
162 #$this->tpl->setVariable('FILTER_TAXONOMY', $this->getTaxonomyTreeLabel($set['filter_taxonomy']));
163 #$this->tpl->setVariable('FILTER_TAX_NODE', $this->getTaxonomyNodeLabel($set['filter_tax_node']));
164 $this->tpl->setVariable('LIFECYCLE_FILTER', $this->taxonomyLabelTranslater->getLifecycleFilterLabel($set['lifecycle_filter']));
165 $this->tpl->setVariable('TYPE_FILTER', $this->taxonomyLabelTranslater->getTypeFilterLabel($set['type_filter']));
166 // fau.
167 }
168
169 private function getSelectionCheckboxHTML($sourcePoolDefinitionId)
170 {
171 return '<input type="checkbox" value="' . $sourcePoolDefinitionId . '" name="src_pool_def_ids[]" />';
172 }
173
174 private function getDefinitionOrderInputHTML($srcPoolDefId, $defOrderNumber)
175 {
176 return '<input type="text" size="2" value="' . $defOrderNumber . '" name="def_order[' . $srcPoolDefId . ']" />';
177 }
178
179 private function getQuestionAmountInputHTML($srcPoolDefId, $questionAmount)
180 {
181 return '<input type="text" size="4" value="' . $questionAmount . '" name="quest_amount[' . $srcPoolDefId . ']" />';
182 }
183
184 private function getActionsHTML($sourcePoolDefinitionId)
185 {
186 require_once 'Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php';
187
188 $selectionList = new ilAdvancedSelectionListGUI();
189
190 $selectionList->setId('sourcePoolDefinitionActions_' . $sourcePoolDefinitionId);
191 $selectionList->setListTitle($this->lng->txt("actions"));
192
193 $selectionList->addItem($this->lng->txt('edit'), '', $this->getEditHref($sourcePoolDefinitionId));
194 $selectionList->addItem($this->lng->txt('delete'), '', $this->getDeleteHref($sourcePoolDefinitionId));
195
196 return $selectionList->getHTML();
197 }
198
199 private function getEditHref($sourcePoolDefinitionId)
200 {
201 $href = $this->ctrl->getLinkTarget(
202 $this->parent_obj,
204 );
205
206 $href = ilUtil::appendUrlParameterString($href, "src_pool_def_id=" . $sourcePoolDefinitionId, true);
207
208 return $href;
209 }
210
211 private function getDeleteHref($sourcePoolDefinitionId)
212 {
213 $href = $this->ctrl->getLinkTarget(
214 $this->parent_obj,
216 );
217
218 $href = ilUtil::appendUrlParameterString($href, "src_pool_def_id=" . $sourcePoolDefinitionId, true);
219
220 return $href;
221 }
222
223 private function getOrderNumberForSequencePosition($sequencePosition)
224 {
225 return ($sequencePosition * 10);
226 }
227
228 private function getTaxonomyTreeLabel($taxonomyTreeId)
229 {
230 if (!$taxonomyTreeId) {
231 return '';
232 }
233
234 return $this->taxonomyLabelTranslater->getTaxonomyTreeLabel($taxonomyTreeId);
235 }
236
237 private function getTaxonomyNodeLabel($taxonomyNodeId)
238 {
239 if (!$taxonomyNodeId) {
240 return '';
241 }
242
243 return $this->taxonomyLabelTranslater->getTaxonomyNodeLabel($taxonomyNodeId);
244 }
245
246 public function build()
247 {
248 $this->setTableIdentifiers();
249
250 $this->setTitle($this->lng->txt('tst_src_quest_pool_def_list_table'));
251
252 $this->setRowTemplate("tpl.il_tst_rnd_quest_set_src_pool_def_row.html", "Modules/Test");
253
254 $this->enable('header');
255 $this->disable('sort');
256
257 $this->enable('select_all');
258 $this->setSelectAllCheckbox('src_pool_def_ids[]');
259
260 $this->setExternalSegmentation(true);
261 $this->setLimit(PHP_INT_MAX);
262
263 $this->setFormAction($this->ctrl->getFormAction($this->parent_obj));
264
265 $this->addCommands();
266 $this->addColumns();
267 }
268
269 private function setTableIdentifiers()
270 {
271 $this->setId(self::IDENTIFIER);
272 $this->setPrefix(self::IDENTIFIER);
273 $this->setFormName(self::IDENTIFIER);
274 }
275
276 private function addCommands()
277 {
278 if ($this->isDefinitionEditModeEnabled()) {
281 }
282 }
283
284 private function addColumns()
285 {
286 if ($this->isDefinitionEditModeEnabled()) {
287 $this->addColumn('', 'select', '1%', true);
288 $this->addColumn('', 'order', '1%', true);
289 }
290 // fau: taxFilter/typeFilter - show order position to easily identify the filter in the database
291 else {
292 $this->addColumn($this->lng->txt("position"));
293 }
294 // fau.
295
296 $this->addColumn($this->lng->txt("tst_source_question_pool"), 'source_question_pool', '');
297 // fau: taxFilter/typeFilter - add one column for taxonomy and nodes and one for type filter
298 $this->addColumn($this->lng->txt("tst_filter_taxonomy") . ' / ' . $this->lng->txt("tst_filter_tax_node"), 'tst_filter_taxonomy', '');
299 #$this->addColumn($this->lng->txt("tst_filter_taxonomy"),'tst_filter_taxonomy', '');
300 #$this->addColumn($this->lng->txt("tst_filter_tax_node"),'tst_filter_tax_node', '');
301 $this->addColumn($this->lng->txt("qst_lifecycle"), 'tst_filter_lifecycle', '');
302 $this->addColumn($this->lng->txt("tst_filter_question_type"), 'tst_filter_question_type', '');
303 // fau.
304
305 if ($this->isQuestionAmountColumnEnabled()) {
306 $this->addColumn($this->lng->txt("tst_question_amount"), 'tst_question_amount', '');
307 }
308
309 if ($this->isDefinitionEditModeEnabled()) {
310 $this->addColumn($this->lng->txt("actions"), 'actions', '');
311 }
312 }
313
314 public function init(ilTestRandomQuestionSetSourcePoolDefinitionList $sourcePoolDefinitionList)
315 {
316 $rows = array();
317
318 foreach ($sourcePoolDefinitionList as $sourcePoolDefinition) {
321 $set = array();
322
323 $set['def_id'] = $sourcePoolDefinition->getId();
324 $set['sequence_position'] = $sourcePoolDefinition->getSequencePosition();
325 $set['source_pool_label'] = $sourcePoolDefinition->getPoolTitle();
326 // fau: taxFilter/typeFilter - get the type and taxonomy filter for display
327 if ($this->showMappedTaxonomyFilter) {
328 // mapped filter will be used after synchronisation
329 $set['taxonomy_filter'] = $sourcePoolDefinition->getMappedTaxonomyFilter();
330 } else {
331 // original filter will be used before synchronisation
332 $set['taxonomy_filter'] = $sourcePoolDefinition->getOriginalTaxonomyFilter();
333 }
334 #$set['filter_taxonomy'] = $sourcePoolDefinition->getMappedFilterTaxId();
335 #$set['filter_tax_node'] = $sourcePoolDefinition->getMappedFilterTaxNodeId();
336 $set['lifecycle_filter'] = $sourcePoolDefinition->getLifecycleFilter();
337 $set['type_filter'] = $sourcePoolDefinition->getTypeFilter();
338 // fau.
339 $set['question_amount'] = $sourcePoolDefinition->getQuestionAmount();
340 $set['ref_id'] = $sourcePoolDefinition->getPoolRefId();
341 $rows[] = $set;
342 }
343
344 $this->setData($rows);
345 }
346
347 public function applySubmit(ilTestRandomQuestionSetSourcePoolDefinitionList $sourcePoolDefinitionList)
348 {
349 foreach ($sourcePoolDefinitionList as $sourcePoolDefinition) {
352 $orderNumber = $this->fetchOrderNumberParameter($sourcePoolDefinition);
353 $sourcePoolDefinition->setSequencePosition($orderNumber);
354
355 if ($this->isQuestionAmountColumnEnabled()) {
356 $questionAmount = $this->fetchQuestionAmountParameter($sourcePoolDefinition);
357 $sourcePoolDefinition->setQuestionAmount($questionAmount);
358 } else {
359 $sourcePoolDefinition->setQuestionAmount(null);
360 }
361 }
362 }
363
365 {
366 return (int) $_POST['def_order'][$definition->getId()];
367 }
368
370 {
371 return (int) $_POST['quest_amount'][$definition->getId()];
372 }
373}
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
User interface class for advanced drop-down selection lists.
This class provides processing control methods.
language handling
Class ilTable2GUI.
setPrefix($a_prefix)
set prefix for sort and offset fields (if you have two or more tables on a page that you want to sort...
setTitle($a_title, $a_icon=0, $a_icon_alt=0)
Set title and title icon.
setSelectAllCheckbox($a_select_all_checkbox, $a_select_all_on_top=false)
Set the name of the checkbox that should be toggled with a select all button.
setData($a_data)
set table data @access public
setRowTemplate($a_template, $a_template_dir="")
Set row template.
setLimit($a_limit=0, $a_default_limit=0)
set max.
addMultiCommand($a_cmd, $a_text)
Add Command button.
addColumn( $a_text, $a_sort_field="", $a_width="", $a_is_checkbox_action_column=false, $a_class="", $a_tooltip="", $a_tooltip_with_html=false)
Add a column to the header.
setExternalSegmentation($a_val)
Set external segmentation.
setId($a_val)
Set id.
setFormName($a_formname="")
Set Form name.
setFormAction($a_form_action, $a_multipart=false)
Set Form action parameter.
addCommandButton($a_cmd, $a_text, $a_onclick='', $a_id="", $a_class=null)
Add Command button.
disable($a_module_name)
diesables particular modules of table
enable($a_module_name)
enables particular modules of table
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
global $DIC
Definition: goto.php:24
This is how the factory for UI elements looks.
Definition: Factory.php:18
An entity that renders components to a string output.
Definition: Renderer.php:15
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$rows
Definition: xhr_table.php:10