ILIAS  release_8 Revision v8.24
class.ilTestRandomQuestionSetPoolDefinitionFormGUI.php
Go to the documentation of this file.
1<?php
2
28{
30
32
34
35 private ?string $saveCommand = null;
36
37 private ?string $saveAndNewCommand = null;
38
40 {
42
43 $this->ctrl = $ctrl;
44 $this->lng = $lng;
45 $this->testOBJ = $testOBJ;
46 $this->questionSetConfigGUI = $questionSetConfigGUI;
47 $this->questionSetConfig = $questionSetConfig;
48 }
49
50 public function setSaveCommand(string $saveCommand): void
51 {
52 $this->saveCommand = $saveCommand;
53 }
54
55 public function getSaveCommand(): ?string
56 {
57 return $this->saveCommand;
58 }
59
60 public function setSaveAndNewCommand(string $saveAndNewCommand): void
61 {
62 $this->saveAndNewCommand = $saveAndNewCommand;
63 }
64
65 public function getSaveAndNewCommand(): ?string
66 {
68 }
69
70 public function build(ilTestRandomQuestionSetSourcePoolDefinition $sourcePool, $availableTaxonomyIds): void
71 {
72 $this->setFormAction($this->ctrl->getFormAction($this->questionSetConfigGUI));
73
74 $this->setTitle($this->lng->txt('tst_rnd_quest_set_cfg_pool_form'));
75 $this->setId('tstRndQuestSetCfgPoolForm');
76
77 $this->addCommandButton(
78 $this->getSaveCommand(),
79 $this->lng->txt('save_and_back')
80 );
81
82 if (null !== $this->getSaveAndNewCommand()) {
83 $this->addCommandButton(
84 $this->getSaveAndNewCommand(),
85 $this->lng->txt('tst_save_and_create_new_rule')
86 );
87 }
88
89 $this->addCommandButton(
91 $this->lng->txt('cancel')
92 );
93
94 $hiddenDefId = new ilHiddenInputGUI('src_pool_def_id');
95 $hiddenDefId->setValue((string) $sourcePool->getId());
96 $this->addItem($hiddenDefId);
97
98 $hiddenPoolId = new ilHiddenInputGUI('quest_pool_id');
99 $hiddenPoolId->setValue((string) $sourcePool->getPoolId());
100 $this->addItem($hiddenPoolId);
101
102 $nonEditablePoolLabel = new ilNonEditableValueGUI(
103 $this->lng->txt('tst_inp_source_pool_label'),
104 'quest_pool_label'
105 );
106 $nonEditablePoolLabel->setValue($sourcePool->getPoolInfoLabel($this->lng));
107
108 $this->addItem($nonEditablePoolLabel);
109
110
111 if (count($availableTaxonomyIds)) {
112 // fau: taxFilter/typeFilter - edit multiple taxonomy and node selections
113 require_once 'Services/Taxonomy/classes/class.ilTaxSelectInputGUI.php';
114
115 // this is needed by ilTaxSelectInputGUI in some cases
116 require_once 'Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php';
117 ilOverlayGUI::initJavaScript();
118
119 $filter = $sourcePool->getOriginalTaxonomyFilter();
120 foreach ($availableTaxonomyIds as $taxId) {
121 $taxonomy = new ilObjTaxonomy($taxId);
122 $taxLabel = sprintf($this->lng->txt('tst_inp_source_pool_filter_tax_x'), $taxonomy->getTitle());
123
124 $taxCheckbox = new ilCheckboxInputGUI($taxLabel, "filter_tax_id_$taxId");
125
126
127
128 $this->ctrl->setParameterByClass('iltaxselectinputgui', 'src_pool_def_id', $sourcePool->getId());
129 $this->ctrl->setParameterByClass('iltaxselectinputgui', 'quest_pool_id', $sourcePool->getPoolId());
130 $taxSelect = new ilTaxSelectInputGUI($taxId, "filter_tax_nodes_$taxId", true);
131 $taxSelect->setRequired(true);
132
133 if (isset($filter[$taxId])) {
134 $taxCheckbox->setChecked(true);
135 $taxSelect->setValue($filter[$taxId]);
136 }
137 $taxCheckbox->addSubItem($taxSelect);
138 $this->addItem($taxCheckbox);
139 }
140
141 #$taxRadio = new ilRadioGroupInputGUI(
142 # $this->lng->txt('tst_inp_source_pool_filter_tax'), 'filter_tax'
143 #);
144
145 #$taxRadio->setRequired(true);
146
147 #$taxRadio->addOption(new ilRadioOption(
148 # $this->lng->txt('tst_inp_source_pool_no_tax_filter'), 0
149 #));
150
151 #$taxRadio->setValue(0);
152
153 #require_once 'Services/Taxonomy/classes/class.ilTaxSelectInputGUI.php';
154
155 #foreach($availableTaxonomyIds as $taxId)
156 #{
157 # $taxonomy = new ilObjTaxonomy($taxId);
158 # $label = sprintf($this->lng->txt('tst_inp_source_pool_filter_tax_x'), $taxonomy->getTitle());
159
160 # $taxRadioOption = new ilRadioOption($label, $taxId);
161
162 # $taxRadio->addOption($taxRadioOption);
163
164 # $taxSelect = new ilTaxSelectInputGUI($taxId, "filter_tax_$taxId", false);
165 # $taxSelect->setRequired(true);
166 # $taxRadioOption->addSubItem($taxSelect);
167
168 # if( $taxId == $sourcePool->getOriginalFilterTaxId() )
169 # {
170 # $taxRadio->setValue( $sourcePool->getOriginalFilterTaxId() );
171 # $taxSelect->setValue( $sourcePool->getOriginalFilterTaxNodeId() );
172 # }
173 #}
174
175 #$this->addItem($taxRadio);
176 // fau.
177 } else {
178 $hiddenNoTax = new ilHiddenInputGUI('filter_tax');
179 $hiddenNoTax->setValue('0');
180 $this->addItem($hiddenNoTax);
181
182 $nonEditableNoTax = new ilNonEditableValueGUI(
183 $this->lng->txt('tst_inp_source_pool_filter_tax'),
184 'no_tax_label'
185 );
186 $nonEditableNoTax->setValue($this->lng->txt('tst_inp_no_available_tax_hint'));
187 $this->addItem($nonEditableNoTax);
188 }
189
190 $lifecycleFilterValues = $sourcePool->getLifecycleFilter();
191 $lifecycleCheckbox = new ilCheckboxInputGUI($this->lng->txt('tst_filter_lifecycle_enabled'), 'filter_lifecycle_enabled');
192 $lifecycleCheckbox->setChecked(!empty($lifecycleFilterValues));
193 $lifecycleFilter = new ilSelectInputGUI($this->lng->txt('qst_lifecycle'), 'filter_lifecycle');
194 $lifecycleFilter->setRequired(true);
195 $lifecycleFilter->setMulti(true);
196 $lifecycleFilter->setOptions(ilAssQuestionLifecycle::getDraftInstance()->getSelectOptions($this->lng));
197 $lifecycleFilter->setValue($lifecycleFilterValues);
198 $lifecycleCheckbox->addSubItem($lifecycleFilter);
199 $this->addItem($lifecycleCheckbox);
200
201 // fau: taxFilter/typeFilter - show type filter selection
202 $typeFilterOptions = array();
203 require_once("./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php");
204 foreach (ilObjQuestionPool::_getQuestionTypes(true) as $translation => $data) {
205 $typeFilterOptions[$data['question_type_id']] = $translation;
206 }
207 $filterIds = $sourcePool->getTypeFilter();
208 $typeCheckbox = new ilCheckboxInputGUI($this->lng->txt('tst_filter_question_type_enabled'), 'filter_type_enabled');
209 $typeCheckbox->setChecked(!empty($filterIds));
210 $typeFilter = new ilSelectInputGUI($this->lng->txt('tst_filter_question_type'), 'filter_type');
211 $typeFilter->setRequired(true);
212 $typeFilter->setMulti(true);
213 $typeFilter->setOptions($typeFilterOptions);
214 $typeFilter->setValue($filterIds);
215 $typeCheckbox->addSubItem($typeFilter);
216 $this->addItem($typeCheckbox);
217 // fau.
218
219 if ($this->questionSetConfig->isQuestionAmountConfigurationModePerPool()) {
220 $questionAmountPerSourcePool = new ilNumberInputGUI(
221 $this->lng->txt('tst_inp_quest_amount_per_source_pool'),
222 'question_amount_per_pool'
223 );
224
225 $questionAmountPerSourcePool->setRequired(true);
226 $questionAmountPerSourcePool->allowDecimals(false);
227 $questionAmountPerSourcePool->setMinValue(0);
228 $questionAmountPerSourcePool->setMinvalueShouldBeGreater(true);
229 $questionAmountPerSourcePool->setSize(4);
230
231 if ($sourcePool->getQuestionAmount()) {
232 $questionAmountPerSourcePool->setValue(
233 $sourcePool->getQuestionAmount() ? (string) $sourcePool->getQuestionAmount() : null
234 );
235 }
236
237 $this->addItem($questionAmountPerSourcePool);
238 }
239 }
240
241 public function applySubmit(ilTestRandomQuestionSetSourcePoolDefinition $sourcePoolDefinition, $availableTaxonomyIds): void
242 {
243 // fau: taxFilter/typeFilter - submit multiple taxonomy and node selections - submit type selections
244 $filter = array();
245 foreach ($availableTaxonomyIds as $taxId) {
246 if ($this->getItemByPostVar("filter_tax_id_$taxId")->getChecked()) {
247 $nodeIds = (array) $this->getItemByPostVar("filter_tax_nodes_$taxId")->getValue();
248 if (!empty($nodeIds)) {
249 foreach ($nodeIds as $nodeId) {
250 $filter[(int) $taxId][] = (int) $nodeId;
251 }
252 }
253 }
254 }
255 $sourcePoolDefinition->setOriginalTaxonomyFilter($filter);
256
257 #switch( true )
258 #{
259 # case $this->getItemByPostVar('source_pool_filter_tax') === null:
260
261 # case !in_array($this->getItemByPostVar('filter_tax')->getValue(), $availableTaxonomyIds):
262
263 # $sourcePoolDefinition->setOriginalFilterTaxId(null);
264 # $sourcePoolDefinition->setOriginalFilterTaxNodeId(null);
265 # break;
266
267 # default:
268
269 # $taxId = $this->getItemByPostVar('filter_tax')->getValue();
270
271 # $sourcePoolDefinition->setOriginalFilterTaxId( $taxId );
272
273 # $sourcePoolDefinition->setOriginalFilterTaxNodeId( $this->getItemByPostVar("filter_tax_$taxId")->getValue() );
274 #}
275
276 $filter = array();
277 if ($this->getItemByPostVar("filter_type_enabled")->getChecked()) {
278 $filter = $this->getItemByPostVar("filter_type")->getMultiValues();
279 }
280 $sourcePoolDefinition->setTypeFilter($filter);
281
282 $filter = array();
283 if ($this->getItemByPostVar("filter_lifecycle_enabled")->getChecked()) {
284 $filter = $this->getItemByPostVar("filter_lifecycle")->getMultiValues();
285 }
286 $sourcePoolDefinition->setLifecycleFilter($filter);
287
288 // fau.
289
290 if ($this->questionSetConfig->isQuestionAmountConfigurationModePerPool()) {
291 $sourcePoolDefinition->setQuestionAmount($this->getItemByPostVar('question_amount_per_pool')->getValue());
292 }
293 }
294}
This class represents a checkbox property in a property form.
setFormAction(string $a_formaction)
setId(string $a_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
language handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a number property in a property form.
static _getQuestionTypes($all_tags=false, $fixOrder=false, $withDeprecatedTypes=true)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a property form user interface.
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
getItemByPostVar(string $a_post_var)
This class represents a selection list property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
applySubmit(ilTestRandomQuestionSetSourcePoolDefinition $sourcePoolDefinition, $availableTaxonomyIds)
build(ilTestRandomQuestionSetSourcePoolDefinition $sourcePool, $availableTaxonomyIds)
__construct(ilCtrlInterface $ctrl, ilLanguage $lng, ilObjTest $testOBJ, ilTestRandomQuestionSetConfigGUI $questionSetConfigGUI, ilTestRandomQuestionSetConfig $questionSetConfig)
setOriginalTaxonomyFilter($filter=array())
set the original taxonomy filter condition
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
getValue()
Get the value that is displayed in the input client side.
Definition: Group.php:47