ILIAS  release_8 Revision v8.24
class.ilTestRandomQuestionSetGeneralConfigFormGUI.php
Go to the documentation of this file.
1<?php
2
30{
32
34
36
37 protected bool $editModeEnabled = true;
38
47 {
48 $this->ctrl = $ctrl;
49 $this->lng = $lng;
50 // Bugfix for mantis: 0015081
51 $this->lng->loadLanguageModule('form');
52 $this->testOBJ = $testOBJ;
53 $this->questionSetConfigGUI = $questionSetConfigGUI;
54 $this->questionSetConfig = $questionSetConfig;
56 }
57
58 public function isEditModeEnabled(): bool
59 {
61 }
62
63 public function setEditModeEnabled(bool $editModeEnabled): void
64 {
65 $this->editModeEnabled = $editModeEnabled;
66 }
67
68 public function build(): void
69 {
70 $this->setFormAction($this->ctrl->getFormAction($this->questionSetConfigGUI));
71
72 $this->setTitle($this->lng->txt('tst_rnd_quest_set_cfg_general_form'));
73 $this->setId('tstRndQuestSetCfgGeneralForm');
74
75 $this->addCommandButton(
77 $this->lng->txt('save')
78 );
79
80 // Require Pools with Homogeneous Scored Questions
81
82 $requirePoolsQuestionsHomoScored = new ilCheckboxInputGUI(
83 $this->lng->txt('tst_inp_all_quest_points_equal_per_pool'),
84 'quest_points_equal_per_pool'
85 );
86
87 $requirePoolsQuestionsHomoScored->setInfo(
88 $this->lng->txt('tst_inp_all_quest_points_equal_per_pool_desc')
89 );
90
91 $requirePoolsQuestionsHomoScored->setChecked(
92 (bool)
93 $this->questionSetConfig->arePoolsWithHomogeneousScoredQuestionsRequired()
94 );
95
96 $this->addItem($requirePoolsQuestionsHomoScored);
97
98 // question amount config mode (per test / per pool)
99
100 $questionAmountConfigMode = new ilRadioGroupInputGUI(
101 $this->lng->txt('tst_inp_quest_amount_cfg_mode'),
102 'quest_amount_cfg_mode'
103 );
104
105 $questionAmountConfigMode->setValue($this->fetchValidQuestionAmountConfigModeWithFallbackModePerTest(
106 $this->questionSetConfig
107 ));
108
109 $questionAmountConfigModePerTest = new ilRadioOption(
110 $this->lng->txt('tst_inp_quest_amount_cfg_mode_test'),
112 );
113
114 $questionAmountConfigMode->addOption($questionAmountConfigModePerTest);
115
116 $questionAmountConfigModePerPool = new ilRadioOption(
117 $this->lng->txt('tst_inp_quest_amount_cfg_mode_pool'),
119 );
120
121 $questionAmountConfigMode->addOption($questionAmountConfigModePerPool);
122
123 $questionAmountConfigMode->setRequired(true);
124
125 $this->addItem($questionAmountConfigMode);
126
127 // question amount per test
128
129 $questionAmountPerTest = new ilNumberInputGUI(
130 $this->lng->txt('tst_inp_quest_amount_per_test'),
131 'quest_amount_per_test'
132 );
133
134 $questionAmountPerTest->setRequired(true);
135 $questionAmountPerTest->setMinValue(1);
136 $questionAmountPerTest->allowDecimals(false);
137 $questionAmountPerTest->setMinvalueShouldBeGreater(false);
138 $questionAmountPerTest->setSize(4);
139
140 $questionAmountPerTest->setValue(
141 $this->questionSetConfig->getQuestionAmountPerTest()
142 );
143
144 $questionAmountConfigModePerTest->addSubItem($questionAmountPerTest);
145
146 if (!$this->isEditModeEnabled()) {
147 $requirePoolsQuestionsHomoScored->setDisabled(true);
148 $questionAmountConfigMode->setDisabled(true);
149 $questionAmountPerTest->setDisabled(true);
150 }
151 }
152
154 {
155 switch ($config->getQuestionAmountConfigurationMode()) {
158
159 return $config->getQuestionAmountConfigurationMode();
160 }
161
163 }
164
165 public function save(): void
166 {
167 $this->questionSetConfig->setPoolsWithHomogeneousScoredQuestionsRequired(
168 $this->getItemByPostVar('quest_points_equal_per_pool')->getChecked()
169 );
170
171 switch ($this->getItemByPostVar('quest_amount_cfg_mode')->getValue()) {
173
174 $this->questionSetConfig->setQuestionAmountConfigurationMode(
175 $this->getItemByPostVar('quest_amount_cfg_mode')->getValue()
176 );
177
178 $this->questionSetConfig->setQuestionAmountPerTest(
179 $this->getItemByPostVar('quest_amount_per_test')->getValue()
180 );
181
182 break;
183
185
186 $this->questionSetConfig->setQuestionAmountConfigurationMode(
187 $this->getItemByPostVar('quest_amount_cfg_mode')->getValue()
188 );
189
190 $this->questionSetConfig->setQuestionAmountPerTest(null);
191
192 break;
193 }
194
195 $this->questionSetConfig->saveToDb();
196 }
197}
This class represents a checkbox property in a property form.
Class ilCtrl provides processing control methods.
setFormAction(string $a_formaction)
setId(string $a_id)
language handling
This class represents a number property in a property form.
This class represents a property form user interface.
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
getItemByPostVar(string $a_post_var)
This class represents a property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(ilCtrl $ctrl, ilLanguage $lng, ilObjTest $testOBJ, ilTestRandomQuestionSetConfigGUI $questionSetConfigGUI, ilTestRandomQuestionSetConfig $questionSetConfig)
fetchValidQuestionAmountConfigModeWithFallbackModePerTest(ilTestRandomQuestionSetConfig $config)
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:85
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
getValue()
Get the value that is displayed in the input client side.
Definition: Group.php:47