ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
4 require_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  );
102 
103  // Require Pools with Homogeneous Scored Questions
104 
105  $requirePoolsQuestionsHomoScored = new ilCheckboxInputGUI(
106  $this->lng->txt('tst_inp_all_quest_points_equal_per_pool'), 'quest_points_equal_per_pool'
107  );
108 
109  $requirePoolsQuestionsHomoScored->setInfo(
110  $this->lng->txt('tst_inp_all_quest_points_equal_per_pool_desc')
111  );
112 
113  $requirePoolsQuestionsHomoScored->setChecked(
114  $this->questionSetConfig->arePoolsWithHomogeneousScoredQuestionsRequired()
115  );
116 
117  $this->addItem($requirePoolsQuestionsHomoScored);
118 
119  // question amount config mode (per test / per pool)
120 
121  $questionAmountConfigMode = new ilRadioGroupInputGUI(
122  $this->lng->txt('tst_inp_quest_amount_cfg_mode'), 'quest_amount_cfg_mode'
123  );
124 
125  $questionAmountConfigMode->setValue( $this->fetchValidQuestionAmountConfigModeWithFallbackModePerTest(
126  $this->questionSetConfig
127  ));
128 
129  $questionAmountConfigModePerTest = new ilRadioOption(
130  $this->lng->txt('tst_inp_quest_amount_cfg_mode_test'),
132  );
133 
134  $questionAmountConfigMode->addOption($questionAmountConfigModePerTest);
135 
136  $questionAmountConfigModePerPool = new ilRadioOption(
137  $this->lng->txt('tst_inp_quest_amount_cfg_mode_pool'),
139  );
140 
141  $questionAmountConfigMode->addOption($questionAmountConfigModePerPool);
142 
143  $questionAmountConfigMode->setRequired(true);
144 
145  $this->addItem($questionAmountConfigMode);
146 
147  // question amount per test
148 
149  $questionAmountPerTest = new ilNumberInputGUI(
150  $this->lng->txt('tst_inp_quest_amount_per_test'), 'quest_amount_per_test'
151  );
152 
153  $questionAmountPerTest->setRequired(true);
154  $questionAmountPerTest->setMinValue(1);
155  $questionAmountPerTest->allowDecimals(false);
156  $questionAmountPerTest->setMinvalueShouldBeGreater(false);
157  $questionAmountPerTest->setSize(4);
158 
159  $questionAmountPerTest->setValue(
160  $this->questionSetConfig->getQuestionAmountPerTest()
161  );
162 
163  $questionAmountConfigModePerTest->addSubItem($questionAmountPerTest);
164 
165  if( !$this->isEditModeEnabled() )
166  {
167  $requirePoolsQuestionsHomoScored->setDisabled(true);
168  $questionAmountConfigMode->setDisabled(true);
169  $questionAmountPerTest->setDisabled(true);
170 
171  }
172  }
173 
175  {
176  switch( $config->getQuestionAmountConfigurationMode() )
177  {
180 
181  return $config->getQuestionAmountConfigurationMode();
182  }
183 
185  }
186 
187  public function save()
188  {
189  $this->questionSetConfig->setPoolsWithHomogeneousScoredQuestionsRequired(
190  $this->getItemByPostVar('quest_points_equal_per_pool')->getChecked()
191  );
192 
193  switch( $this->getItemByPostVar('quest_amount_cfg_mode')->getValue() )
194  {
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 }
This class represents an option in a radio group.
This class provides processing control methods.
getItemByPostVar($a_post_var)
Get Item by POST variable.
setId($a_id)
Set Id.
This class represents a property form user interface.
This class represents a checkbox property in a property form.
setFormAction($a_formaction)
Set FormAction.
addItem($a_item)
Add Item (Property, SectionHeader).
setInfo($a_info)
Set Information Text.
This class represents a property in a property form.
setTitle($a_title)
Set Title.
fetchValidQuestionAmountConfigModeWithFallbackModePerTest(ilTestRandomQuestionSetConfig $config)
This class represents a number property in a property form.
addCommandButton($a_cmd, $a_text, $a_id="")
Add Command button.
language handling
setRequired($a_required)
Set Required.
__construct(ilCtrl $ctrl, ilLanguage $lng, ilObjTest $testOBJ, ilTestRandomQuestionSetConfigGUI $questionSetConfigGUI, ilTestRandomQuestionSetConfig $questionSetConfig)