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