ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilTestRandomQuestionSetGeneralConfigFormGUI.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
56 protected $editModeEnabled = true;
57
66 {
67 $this->ctrl = $ctrl;
68 $this->lng = $lng;
69 // Bugfix for mantis: 0015081
70 $this->lng->loadLanguageModule('form');
71 $this->testOBJ = $testOBJ;
72 $this->questionSetConfigGUI = $questionSetConfigGUI;
73 $this->questionSetConfig = $questionSetConfig;
74 }
75
79 public function isEditModeEnabled()
80 {
82 }
83
88 {
89 $this->editModeEnabled = $editModeEnabled;
90 }
91
92 public function build()
93 {
94 $this->setFormAction($this->ctrl->getFormAction($this->questionSetConfigGUI));
95
96 $this->setTitle($this->lng->txt('tst_rnd_quest_set_cfg_general_form'));
97 $this->setId('tstRndQuestSetCfgGeneralForm');
98
99 $this->addCommandButton(
101 $this->lng->txt('save')
102 );
103
104 // Require Pools with Homogeneous Scored Questions
105
106 $requirePoolsQuestionsHomoScored = new ilCheckboxInputGUI(
107 $this->lng->txt('tst_inp_all_quest_points_equal_per_pool'),
108 'quest_points_equal_per_pool'
109 );
110
111 $requirePoolsQuestionsHomoScored->setInfo(
112 $this->lng->txt('tst_inp_all_quest_points_equal_per_pool_desc')
113 );
114
115 $requirePoolsQuestionsHomoScored->setChecked(
116 $this->questionSetConfig->arePoolsWithHomogeneousScoredQuestionsRequired()
117 );
118
119 $this->addItem($requirePoolsQuestionsHomoScored);
120
121 // question amount config mode (per test / per pool)
122
123 $questionAmountConfigMode = new ilRadioGroupInputGUI(
124 $this->lng->txt('tst_inp_quest_amount_cfg_mode'),
125 'quest_amount_cfg_mode'
126 );
127
128 $questionAmountConfigMode->setValue($this->fetchValidQuestionAmountConfigModeWithFallbackModePerTest(
129 $this->questionSetConfig
130 ));
131
132 $questionAmountConfigModePerTest = new ilRadioOption(
133 $this->lng->txt('tst_inp_quest_amount_cfg_mode_test'),
135 );
136
137 $questionAmountConfigMode->addOption($questionAmountConfigModePerTest);
138
139 $questionAmountConfigModePerPool = new ilRadioOption(
140 $this->lng->txt('tst_inp_quest_amount_cfg_mode_pool'),
142 );
143
144 $questionAmountConfigMode->addOption($questionAmountConfigModePerPool);
145
146 $questionAmountConfigMode->setRequired(true);
147
148 $this->addItem($questionAmountConfigMode);
149
150 // question amount per test
151
152 $questionAmountPerTest = new ilNumberInputGUI(
153 $this->lng->txt('tst_inp_quest_amount_per_test'),
154 'quest_amount_per_test'
155 );
156
157 $questionAmountPerTest->setRequired(true);
158 $questionAmountPerTest->setMinValue(1);
159 $questionAmountPerTest->allowDecimals(false);
160 $questionAmountPerTest->setMinvalueShouldBeGreater(false);
161 $questionAmountPerTest->setSize(4);
162
163 $questionAmountPerTest->setValue(
164 $this->questionSetConfig->getQuestionAmountPerTest()
165 );
166
167 $questionAmountConfigModePerTest->addSubItem($questionAmountPerTest);
168
169 if (!$this->isEditModeEnabled()) {
170 $requirePoolsQuestionsHomoScored->setDisabled(true);
171 $questionAmountConfigMode->setDisabled(true);
172 $questionAmountPerTest->setDisabled(true);
173 }
174 }
175
177 {
178 switch ($config->getQuestionAmountConfigurationMode()) {
181
182 return $config->getQuestionAmountConfigurationMode();
183 }
184
186 }
187
188 public function save()
189 {
190 $this->questionSetConfig->setPoolsWithHomogeneousScoredQuestionsRequired(
191 $this->getItemByPostVar('quest_points_equal_per_pool')->getChecked()
192 );
193
194 switch ($this->getItemByPostVar('quest_amount_cfg_mode')->getValue()) {
196
197 $this->questionSetConfig->setQuestionAmountConfigurationMode(
198 $this->getItemByPostVar('quest_amount_cfg_mode')->getValue()
199 );
200
201 $this->questionSetConfig->setQuestionAmountPerTest(
202 $this->getItemByPostVar('quest_amount_per_test')->getValue()
203 );
204
205 break;
206
208
209 $this->questionSetConfig->setQuestionAmountConfigurationMode(
210 $this->getItemByPostVar('quest_amount_cfg_mode')->getValue()
211 );
212
213 $this->questionSetConfig->setQuestionAmountPerTest(null);
214
215 break;
216 }
217
218 return $this->questionSetConfig->saveToDb($this->testOBJ->getTestId());
219 }
220}
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.
language handling
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).
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 property in a property form.
This class represents an option in a radio group.
__construct(ilCtrl $ctrl, ilLanguage $lng, ilObjTest $testOBJ, ilTestRandomQuestionSetConfigGUI $questionSetConfigGUI, ilTestRandomQuestionSetConfig $questionSetConfig)
fetchValidQuestionAmountConfigModeWithFallbackModePerTest(ilTestRandomQuestionSetConfig $config)