ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilTestRandomQuestionSetPoolDefinitionFormGUI.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/Form/classes/class.ilPropertyFormGUI.php';
5
17{
23 public $ctrl = null;
24
30 public $lng = null;
31
37 public $testOBJ = null;
38
44 public $questionSetConfigGUI = null;
45
51 public $questionSetConfig = null;
52
53 private $saveCommand = null;
54
58 private $saveAndNewCommand = null;
59
61 {
63
64 $this->ctrl = $ctrl;
65 $this->lng = $lng;
66 $this->testOBJ = $testOBJ;
67 $this->questionSetConfigGUI = $questionSetConfigGUI;
68 $this->questionSetConfig = $questionSetConfig;
69 }
70
72 {
73 $this->saveCommand = $saveCommand;
74 }
75
76 public function getSaveCommand()
77 {
78 return $this->saveCommand;
79 }
80
85 {
86 $this->saveAndNewCommand = $saveAndNewCommand;
87 }
88
92 public function getSaveAndNewCommand()
93 {
95 }
96
97 public function build(ilTestRandomQuestionSetSourcePoolDefinition $sourcePool, $availableTaxonomyIds)
98 {
99 $this->setFormAction($this->ctrl->getFormAction($this->questionSetConfigGUI));
100
101 $this->setTitle($this->lng->txt('tst_rnd_quest_set_cfg_pool_form'));
102 $this->setId('tstRndQuestSetCfgPoolForm');
103
104 $this->addCommandButton(
105 $this->getSaveCommand(),
106 $this->lng->txt('save_and_back')
107 );
108
109 if (null !== $this->getSaveAndNewCommand()) {
110 $this->addCommandButton(
111 $this->getSaveAndNewCommand(),
112 $this->lng->txt('tst_save_and_create_new_rule')
113 );
114 }
115
116 $this->addCommandButton(
118 $this->lng->txt('cancel')
119 );
120
121 $hiddenDefId = new ilHiddenInputGUI('src_pool_def_id');
122 $hiddenDefId->setValue($sourcePool->getId());
123 $this->addItem($hiddenDefId);
124
125 $hiddenPoolId = new ilHiddenInputGUI('quest_pool_id');
126 $hiddenPoolId->setValue($sourcePool->getPoolId());
127 $this->addItem($hiddenPoolId);
128
129 $nonEditablePoolLabel = new ilNonEditableValueGUI(
130 $this->lng->txt('tst_inp_source_pool_label'),
131 'quest_pool_label'
132 );
133 $nonEditablePoolLabel->setValue($sourcePool->getPoolInfoLabel($this->lng));
134
135 $this->addItem($nonEditablePoolLabel);
136
137
138 if (count($availableTaxonomyIds)) {
139 // fau: taxFilter/typeFilter - edit multiple taxonomy and node selections
140 require_once 'Services/Taxonomy/classes/class.ilTaxSelectInputGUI.php';
141
142 // this is needed by ilTaxSelectInputGUI in some cases
143 require_once 'Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php';
144 ilOverlayGUI::initJavaScript();
145
146 $filter = $sourcePool->getOriginalTaxonomyFilter();
147 foreach ($availableTaxonomyIds as $taxId) {
148 $taxonomy = new ilObjTaxonomy($taxId);
149 $taxLabel = sprintf($this->lng->txt('tst_inp_source_pool_filter_tax_x'), $taxonomy->getTitle());
150
151 $taxCheckbox = new ilCheckboxInputGUI($taxLabel, "filter_tax_id_$taxId");
152
153
154
155 $this->ctrl->setParameterByClass('iltaxselectinputgui', 'src_pool_def_id', $sourcePool->getId());
156 $this->ctrl->setParameterByClass('iltaxselectinputgui', 'quest_pool_id', $sourcePool->getPoolId());
157 $taxSelect = new ilTaxSelectInputGUI($taxId, "filter_tax_nodes_$taxId", true);
158 $taxSelect->setRequired(true);
159
160 if (isset($filter[$taxId])) {
161 $taxCheckbox->setChecked(true);
162 $taxSelect->setValue($filter[$taxId]);
163 }
164 $taxCheckbox->addSubItem($taxSelect);
165 $this->addItem($taxCheckbox);
166 }
167
168 #$taxRadio = new ilRadioGroupInputGUI(
169 # $this->lng->txt('tst_inp_source_pool_filter_tax'), 'filter_tax'
170 #);
171
172 #$taxRadio->setRequired(true);
173
174 #$taxRadio->addOption(new ilRadioOption(
175 # $this->lng->txt('tst_inp_source_pool_no_tax_filter'), 0
176 #));
177
178 #$taxRadio->setValue(0);
179
180 #require_once 'Services/Taxonomy/classes/class.ilTaxSelectInputGUI.php';
181
182 #foreach($availableTaxonomyIds as $taxId)
183 #{
184 # $taxonomy = new ilObjTaxonomy($taxId);
185 # $label = sprintf($this->lng->txt('tst_inp_source_pool_filter_tax_x'), $taxonomy->getTitle());
186
187 # $taxRadioOption = new ilRadioOption($label, $taxId);
188
189 # $taxRadio->addOption($taxRadioOption);
190
191 # $taxSelect = new ilTaxSelectInputGUI($taxId, "filter_tax_$taxId", false);
192 # $taxSelect->setRequired(true);
193 # $taxRadioOption->addSubItem($taxSelect);
194
195 # if( $taxId == $sourcePool->getOriginalFilterTaxId() )
196 # {
197 # $taxRadio->setValue( $sourcePool->getOriginalFilterTaxId() );
198 # $taxSelect->setValue( $sourcePool->getOriginalFilterTaxNodeId() );
199 # }
200 #}
201
202 #$this->addItem($taxRadio);
203 // fau.
204 } else {
205 $hiddenNoTax = new ilHiddenInputGUI('filter_tax');
206 $hiddenNoTax->setValue(0);
207 $this->addItem($hiddenNoTax);
208
209 $nonEditableNoTax = new ilNonEditableValueGUI(
210 $this->lng->txt('tst_inp_source_pool_filter_tax'),
211 'no_tax_label'
212 );
213 $nonEditableNoTax->setValue($this->lng->txt('tst_inp_no_available_tax_hint'));
214 $this->addItem($nonEditableNoTax);
215 }
216
217 $lifecycleFilterValues = $sourcePool->getLifecycleFilter();
218 $lifecycleCheckbox = new ilCheckboxInputGUI($this->lng->txt('tst_filter_lifecycle_enabled'), 'filter_lifecycle_enabled');
219 $lifecycleCheckbox->setChecked(!empty($lifecycleFilterValues));
220 $lifecycleFilter = new ilSelectInputGUI($this->lng->txt('qst_lifecycle'), 'filter_lifecycle');
221 $lifecycleFilter->setRequired(true);
222 $lifecycleFilter->setMulti(true);
223 $lifecycleFilter->setOptions(ilAssQuestionLifecycle::getDraftInstance()->getSelectOptions($this->lng));
224 $lifecycleFilter->setValue($lifecycleFilterValues);
225 $lifecycleCheckbox->addSubItem($lifecycleFilter);
226 $this->addItem($lifecycleCheckbox);
227
228 // fau: taxFilter/typeFilter - show type filter selection
229 $typeFilterOptions = array();
230 require_once("./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php");
231 foreach (ilObjQuestionPool::_getQuestionTypes(true) as $translation => $data) {
232 $typeFilterOptions[$data['question_type_id']] = $translation;
233 }
234 $filterIds = $sourcePool->getTypeFilter();
235 $typeCheckbox = new ilCheckboxInputGUI($this->lng->txt('tst_filter_question_type_enabled'), 'filter_type_enabled');
236 $typeCheckbox->setChecked(!empty($filterIds));
237 $typeFilter = new ilSelectInputGUI($this->lng->txt('tst_filter_question_type'), 'filter_type');
238 $typeFilter->setRequired(true);
239 $typeFilter->setMulti(true);
240 $typeFilter->setOptions($typeFilterOptions);
241 $typeFilter->setValue($filterIds);
242 $typeCheckbox->addSubItem($typeFilter);
243 $this->addItem($typeCheckbox);
244 // fau.
245
246 if ($this->questionSetConfig->isQuestionAmountConfigurationModePerPool()) {
247 $questionAmountPerSourcePool = new ilNumberInputGUI(
248 $this->lng->txt('tst_inp_quest_amount_per_source_pool'),
249 'question_amount_per_pool'
250 );
251
252 $questionAmountPerSourcePool->setRequired(true);
253 $questionAmountPerSourcePool->allowDecimals(false);
254 $questionAmountPerSourcePool->setMinValue(0);
255 $questionAmountPerSourcePool->setMinvalueShouldBeGreater(true);
256 $questionAmountPerSourcePool->setSize(4);
257
258 if ($sourcePool->getQuestionAmount()) {
259 $questionAmountPerSourcePool->setValue($sourcePool->getQuestionAmount());
260 }
261
262 $this->addItem($questionAmountPerSourcePool);
263 }
264 }
265
266 public function applySubmit(ilTestRandomQuestionSetSourcePoolDefinition $sourcePoolDefinition, $availableTaxonomyIds)
267 {
268 // fau: taxFilter/typeFilter - submit multiple taxonomy and node selections - submit type selections
269 $filter = array();
270 foreach ($availableTaxonomyIds as $taxId) {
271 if ($this->getItemByPostVar("filter_tax_id_$taxId")->getChecked()) {
272 $nodeIds = (array) $this->getItemByPostVar("filter_tax_nodes_$taxId")->getValue();
273 if (!empty($nodeIds)) {
274 foreach ($nodeIds as $nodeId) {
275 $filter[(int) $taxId][] = (int) $nodeId;
276 }
277 }
278 }
279 }
280 $sourcePoolDefinition->setOriginalTaxonomyFilter($filter);
281
282 #switch( true )
283 #{
284 # case $this->getItemByPostVar('source_pool_filter_tax') === null:
285
286 # case !in_array($this->getItemByPostVar('filter_tax')->getValue(), $availableTaxonomyIds):
287
288 # $sourcePoolDefinition->setOriginalFilterTaxId(null);
289 # $sourcePoolDefinition->setOriginalFilterTaxNodeId(null);
290 # break;
291
292 # default:
293
294 # $taxId = $this->getItemByPostVar('filter_tax')->getValue();
295
296 # $sourcePoolDefinition->setOriginalFilterTaxId( $taxId );
297
298 # $sourcePoolDefinition->setOriginalFilterTaxNodeId( $this->getItemByPostVar("filter_tax_$taxId")->getValue() );
299 #}
300
301 $filter = array();
302 if ($this->getItemByPostVar("filter_type_enabled")->getChecked()) {
303 $filter = $this->getItemByPostVar("filter_type")->getMultiValues();
304 }
305 $sourcePoolDefinition->setTypeFilter($filter);
306
307 $filter = array();
308 if ($this->getItemByPostVar("filter_lifecycle_enabled")->getChecked()) {
309 $filter = $this->getItemByPostVar("filter_lifecycle")->getMultiValues();
310 }
311 $sourcePoolDefinition->setLifecycleFilter($filter);
312
313 // fau.
314
315 if ($this->questionSetConfig->isQuestionAmountConfigurationModePerPool()) {
316 $sourcePoolDefinition->setQuestionAmount($this->getItemByPostVar('question_amount_per_pool')->getValue());
317 }
318 }
319}
An exception for terminatinating execution or to throw for unit testing.
This class represents a checkbox property in a property form.
This class provides processing control methods.
setFormAction($a_formaction)
Set FormAction.
setId($a_id)
Set Id.
This class represents a hidden form property in a property form.
language handling
This class represents a non editable value in a property form.
This class represents a number property in a property form.
static _getQuestionTypes($all_tags=false, $fixOrder=false, $withDeprecatedTypes=true)
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
addCommandButton($a_cmd, $a_text, $a_id="")
Add Command button.
getItemByPostVar($a_post_var)
Get Item by POST variable.
setTitle($a_title)
Set Title.
This class represents a selection list property in a property form.
Select taxonomy nodes input GUI.
__construct(ilCtrl $ctrl, ilLanguage $lng, ilObjTest $testOBJ, ilTestRandomQuestionSetConfigGUI $questionSetConfigGUI, ilTestRandomQuestionSetConfig $questionSetConfig)
applySubmit(ilTestRandomQuestionSetSourcePoolDefinition $sourcePoolDefinition, $availableTaxonomyIds)
build(ilTestRandomQuestionSetSourcePoolDefinition $sourcePool, $availableTaxonomyIds)
setOriginalTaxonomyFilter($filter=array())
set the original taxonomy filter condition
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$data
Definition: storeScorm.php:23