ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 {
62 $this->ctrl = $ctrl;
63 $this->lng = $lng;
64 $this->testOBJ = $testOBJ;
65 $this->questionSetConfigGUI = $questionSetConfigGUI;
66 $this->questionSetConfig = $questionSetConfig;
67 }
68
70 {
71 $this->saveCommand = $saveCommand;
72 }
73
74 public function getSaveCommand()
75 {
76 return $this->saveCommand;
77 }
78
83 {
84 $this->saveAndNewCommand = $saveAndNewCommand;
85 }
86
90 public function getSaveAndNewCommand()
91 {
93 }
94
95 public function build(ilTestRandomQuestionSetSourcePoolDefinition $sourcePool, $availableTaxonomyIds)
96 {
97 $this->setFormAction( $this->ctrl->getFormAction($this->questionSetConfigGUI) );
98
99 $this->setTitle( $this->lng->txt('tst_rnd_quest_set_cfg_pool_form') );
100 $this->setId('tstRndQuestSetCfgPoolForm');
101
102 $this->addCommandButton(
103 $this->getSaveCommand(), $this->lng->txt('save_and_back')
104 );
105
106 if(null !== $this->getSaveAndNewCommand())
107 {
108 $this->addCommandButton(
109 $this->getSaveAndNewCommand(), $this->lng->txt('tst_save_and_create_new_rule')
110 );
111 }
112
113 $this->addCommandButton(
115 );
116
117 $hiddenDefId = new ilHiddenInputGUI('src_pool_def_id');
118 $hiddenDefId->setValue( $sourcePool->getId() );
119 $this->addItem($hiddenDefId);
120
121 $hiddenPoolId = new ilHiddenInputGUI('quest_pool_id');
122 $hiddenPoolId->setValue( $sourcePool->getPoolId() );
123 $this->addItem($hiddenPoolId);
124
125 $nonEditablePoolLabel = new ilNonEditableValueGUI(
126 $this->lng->txt('tst_inp_source_pool_label'), 'quest_pool_label'
127 );
128 $nonEditablePoolLabel->setValue( $sourcePool->getPoolInfoLabel($this->lng) );
129
130 $this->addItem($nonEditablePoolLabel);
131
132
133 if( count($availableTaxonomyIds) )
134 {
135 $taxRadio = new ilRadioGroupInputGUI(
136 $this->lng->txt('tst_inp_source_pool_filter_tax'), 'filter_tax'
137 );
138
139 $taxRadio->setRequired(true);
140
141 $taxRadio->addOption(new ilRadioOption(
142 $this->lng->txt('tst_inp_source_pool_no_tax_filter'), 0
143 ));
144
145 $taxRadio->setValue(0);
146
147 require_once 'Services/Taxonomy/classes/class.ilTaxSelectInputGUI.php';
148
149 foreach($availableTaxonomyIds as $taxId)
150 {
151 $taxonomy = new ilObjTaxonomy($taxId);
152 $label = sprintf($this->lng->txt('tst_inp_source_pool_filter_tax_x'), $taxonomy->getTitle());
153
154 $taxRadioOption = new ilRadioOption($label, $taxId);
155
156 $taxRadio->addOption($taxRadioOption);
157
158 $taxSelect = new ilTaxSelectInputGUI($taxId, "filter_tax_$taxId", false);
159 $taxSelect->setRequired(true);
160 $taxRadioOption->addSubItem($taxSelect);
161
162 if( $taxId == $sourcePool->getOriginalFilterTaxId() )
163 {
164 $taxRadio->setValue( $sourcePool->getOriginalFilterTaxId() );
165 $taxSelect->setValue( $sourcePool->getOriginalFilterTaxNodeId() );
166 }
167 }
168
169 $this->addItem($taxRadio);
170 }
171 else
172 {
173 $hiddenNoTax = new ilHiddenInputGUI('filter_tax');
174 $hiddenNoTax->setValue(0);
175 $this->addItem($hiddenNoTax);
176
177 $nonEditableNoTax = new ilNonEditableValueGUI(
178 $this->lng->txt('tst_inp_source_pool_filter_tax'), 'no_tax_label'
179 );
180 $nonEditableNoTax->setValue( $this->lng->txt('tst_inp_no_available_tax_hint') );
181 $this->addItem($nonEditableNoTax);
182 }
183
184
185 if( $this->questionSetConfig->isQuestionAmountConfigurationModePerPool() )
186 {
187 $questionAmountPerSourcePool = new ilNumberInputGUI(
188 $this->lng->txt('tst_inp_quest_amount_per_source_pool'), 'question_amount_per_pool'
189 );
190
191 $questionAmountPerSourcePool->setRequired(true);
192 $questionAmountPerSourcePool->allowDecimals(false);
193 $questionAmountPerSourcePool->setMinValue(0);
194 $questionAmountPerSourcePool->setMinvalueShouldBeGreater(true);
195 $questionAmountPerSourcePool->setSize(4);
196
197 if( $sourcePool->getQuestionAmount() )
198 {
199 $questionAmountPerSourcePool->setValue( $sourcePool->getQuestionAmount() );
200 }
201
202 $this->addItem($questionAmountPerSourcePool);
203 }
204 }
205
206 public function applySubmit(ilTestRandomQuestionSetSourcePoolDefinition $sourcePoolDefinition, $availableTaxonomyIds)
207 {
208 switch( true )
209 {
210 case $this->getItemByPostVar('source_pool_filter_tax') === null:
211
212 case !in_array($this->getItemByPostVar('filter_tax')->getValue(), $availableTaxonomyIds):
213
214 $sourcePoolDefinition->setOriginalFilterTaxId(null);
215 $sourcePoolDefinition->setOriginalFilterTaxNodeId(null);
216 break;
217
218 default:
219
220 $taxId = $this->getItemByPostVar('filter_tax')->getValue();
221
222 $sourcePoolDefinition->setOriginalFilterTaxId( $taxId );
223
224 $sourcePoolDefinition->setOriginalFilterTaxNodeId( $this->getItemByPostVar("filter_tax_$taxId")->getValue() );
225 }
226
227 if( $this->questionSetConfig->isQuestionAmountConfigurationModePerPool() )
228 {
229 $sourcePoolDefinition->setQuestionAmount( $this->getItemByPostVar('question_amount_per_pool')->getValue() );
230 }
231 }
232}
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.
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
getItemByPostVar($a_post_var)
Get Item by POST variable.
addCommandButton($a_cmd, $a_text)
Add Command button.
setTitle($a_title)
Set Title.
This class represents a property in a property form.
This class represents an option in a radio group.
Select taxonomy nodes input GUI.
__construct(ilCtrl $ctrl, ilLanguage $lng, ilObjTest $testOBJ, ilTestRandomQuestionSetConfigGUI $questionSetConfigGUI, ilTestRandomQuestionSetConfig $questionSetConfig)
applySubmit(ilTestRandomQuestionSetSourcePoolDefinition $sourcePoolDefinition, $availableTaxonomyIds)
build(ilTestRandomQuestionSetSourcePoolDefinition $sourcePool, $availableTaxonomyIds)