ILIAS  release_4-4 Revision
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 
54  {
55  $this->ctrl = $ctrl;
56  $this->lng = $lng;
57  $this->testOBJ = $testOBJ;
58  $this->questionSetConfigGUI = $questionSetConfigGUI;
59  $this->questionSetConfig = $questionSetConfig;
60  }
61 
62  public function build()
63  {
64  $this->setFormAction( $this->ctrl->getFormAction($this->questionSetConfigGUI) );
65 
66  $this->setTitle( $this->lng->txt('tst_rnd_quest_set_cfg_general_form') );
67  $this->setId('tstRndQuestSetCfgGeneralForm');
68 
69  $this->addCommandButton(
71  );
72 
73  // Require Pools with Homogeneous Scored Questions
74 
75  $requirePoolsQuestionsHomoScored = new ilCheckboxInputGUI(
76  $this->lng->txt('tst_inp_all_quest_points_equal_per_pool'), 'quest_points_equal_per_pool'
77  );
78 
79  $requirePoolsQuestionsHomoScored->setInfo(
80  $this->lng->txt('tst_inp_all_quest_points_equal_per_pool_desc')
81  );
82 
83  $requirePoolsQuestionsHomoScored->setChecked(
84  $this->questionSetConfig->arePoolsWithHomogeneousScoredQuestionsRequired()
85  );
86 
87  $this->addItem($requirePoolsQuestionsHomoScored);
88 
89  // question amount config mode (per test / per pool)
90 
91  $questionAmountConfigMode = new ilRadioGroupInputGUI(
92  $this->lng->txt('tst_inp_quest_amount_cfg_mode'), 'quest_amount_cfg_mode'
93  );
94 
96  $this->questionSetConfig
97  ));
98 
99  $questionAmountConfigModePerTest = new ilRadioOption(
100  $this->lng->txt('tst_inp_quest_amount_cfg_mode_test'),
102  );
103 
104  $questionAmountConfigMode->addOption($questionAmountConfigModePerTest);
105 
106  $questionAmountConfigModePerPool = new ilRadioOption(
107  $this->lng->txt('tst_inp_quest_amount_cfg_mode_pool'),
109  );
110 
111  $questionAmountConfigMode->addOption($questionAmountConfigModePerPool);
112 
113  $questionAmountConfigMode->setRequired(true);
114 
115  $this->addItem($questionAmountConfigMode);
116 
117  // question amount per test
118 
119  $questionAmountPerTest = new ilNumberInputGUI(
120  $this->lng->txt('tst_inp_quest_amount_per_test'), 'quest_amount_per_test'
121  );
122 
123  $questionAmountPerTest->setRequired(true);
124  $questionAmountPerTest->setMinValue(1);
125  $questionAmountPerTest->allowDecimals(false);
126  $questionAmountPerTest->setMinvalueShouldBeGreater(false);
127  $questionAmountPerTest->setSize(4);
128 
129  $questionAmountPerTest->setValue(
130  $this->questionSetConfig->getQuestionAmountPerTest()
131  );
132 
133  $questionAmountConfigModePerTest->addSubItem($questionAmountPerTest);
134 
135  if( $this->testOBJ->participantDataExist() )
136  {
137  $requirePoolsQuestionsHomoScored->setDisabled(true);
138  $questionAmountConfigMode->setDisabled(true);
139  $questionAmountPerTest->setDisabled(true);
140 
141  }
142  }
143 
145  {
146  switch( $config->getQuestionAmountConfigurationMode() )
147  {
150 
151  return $config->getQuestionAmountConfigurationMode();
152  }
153 
155  }
156 
157  public function save()
158  {
159  $this->questionSetConfig->setPoolsWithHomogeneousScoredQuestionsRequired(
160  $this->getItemByPostVar('quest_points_equal_per_pool')->getChecked()
161  );
162 
163  switch( $this->getItemByPostVar('quest_amount_cfg_mode')->getValue() )
164  {
166 
167  $this->questionSetConfig->setQuestionAmountConfigurationMode(
168  $this->getItemByPostVar('quest_amount_cfg_mode')->getValue()
169  );
170 
171  $this->questionSetConfig->setQuestionAmountPerTest(
172  $this->getItemByPostVar('quest_amount_per_test')->getValue()
173  );
174 
175  break;
176 
178 
179  $this->questionSetConfig->setQuestionAmountConfigurationMode(
180  $this->getItemByPostVar('quest_amount_cfg_mode')->getValue()
181  );
182 
183  $this->questionSetConfig->setQuestionAmountPerTest(null);
184 
185  break;
186  }
187 
188  return $this->questionSetConfig->saveToDb( $this->testOBJ->getTestId() );
189  }
190 }
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)
Add Command button.
language handling
setRequired($a_required)
Set Required.
__construct(ilCtrl $ctrl, ilLanguage $lng, ilObjTest $testOBJ, ilTestRandomQuestionSetConfigGUI $questionSetConfigGUI, ilTestRandomQuestionSetConfig $questionSetConfig)