ILIAS  release_7 Revision v7.30-3-g800a261c036
ilObjTestDynamicQuestionSetConfigGUI Class Reference
+ Collaboration diagram for ilObjTestDynamicQuestionSetConfigGUI:

Public Member Functions

 __construct (ilCtrl $ctrl, ilAccessHandler $access, ilTabsGUI $tabs, ilLanguage $lng, ilGlobalTemplateInterface $tpl, ilDBInterface $db, ilTree $tree, ilPluginAdmin $pluginAdmin, ilObjTest $testOBJ)
 Constructor. More...
 
 executeCommand ()
 Command Execution. More...
 
 getTaxonomyOptionsAsyncCmd ()
 
 showFormCmd (ilPropertyFormGUI $form=null)
 command method that prints the question set config form More...
 
 saveFormCmd ()
 command method that checks the question set config form More...
 

Data Fields

const CMD_SHOW_FORM = 'showForm'
 command constants More...
 
const CMD_SAVE_FORM = 'saveForm'
 
const CMD_GET_TAXONOMY_OPTIONS_ASYNC = 'getTaxonomyOptionsAsync'
 
const QUESTION_ORDERING_TYPE_UPDATE_DATE = 'ordering_by_date'
 
const QUESTION_ORDERING_TYPE_TAXONOMY = 'ordering_by_tax'
 

Protected Member Functions

 getSubmittedSourceQuestionPoolId ()
 

Protected Attributes

 $ctrl = null
 
 $access = null
 
 $tabs = null
 
 $lng = null
 
 $tpl = null
 
 $db = null
 
 $tree = null
 
 $testOBJ = null
 
 $questionSetConfig = null
 

Private Member Functions

 performSaveForm (ilPropertyFormGUI $form)
 saves the form fields to the database More...
 
 buildForm ($sourceQuestionPoolId)
 builds the question set config form and initialises the fields with the config currently saved in database More...
 
 buildQuestionPoolSelectInputOptionArray ($questionPoolsData)
 converts the passed question pools data array to select input option array More...
 
 buildTaxonomySelectInputOptionArray ($questionPoolId)
 
 buildTaxonomySelectInputOptionJson ($questionPoolId)
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilObjTestDynamicQuestionSetConfigGUI::__construct ( ilCtrl  $ctrl,
ilAccessHandler  $access,
ilTabsGUI  $tabs,
ilLanguage  $lng,
ilGlobalTemplateInterface  $tpl,
ilDBInterface  $db,
ilTree  $tree,
ilPluginAdmin  $pluginAdmin,
ilObjTest  $testOBJ 
)

Constructor.

Definition at line 94 of file class.ilObjTestDynamicQuestionSetConfigGUI.php.

References $access, $ctrl, $db, $lng, $tabs, $testOBJ, $tpl, and $tree.

Member Function Documentation

◆ buildForm()

ilObjTestDynamicQuestionSetConfigGUI::buildForm (   $sourceQuestionPoolId)
private

builds the question set config form and initialises the fields with the config currently saved in database

Returns
ilPropertyFormGUI $form

Definition at line 254 of file class.ilObjTestDynamicQuestionSetConfigGUI.php.

255 {
256 $this->questionSetConfig->loadFromDb($this->testOBJ->getTestId());
257
258 require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
259 $form = new ilPropertyFormGUI();
260
261 $form->setFormAction($this->ctrl->getFormAction($this));
262
263 $form->setId("tst_form_dynamic_question_set_config");
264 $form->setTitle($this->lng->txt('tst_form_dynamic_question_set_config'));
265 $form->setTableWidth("100%");
266
267 $hiddenInputTaxSelectOptAsyncUrl = new ilHiddenInputGUI('taxSelectOptAsyncUrl');
268 $hiddenInputTaxSelectOptAsyncUrl->setValue(
269 $this->ctrl->getLinkTarget($this, self::CMD_GET_TAXONOMY_OPTIONS_ASYNC, '', true)
270 );
271 $form->addItem($hiddenInputTaxSelectOptAsyncUrl);
272
273 if ($this->testOBJ->participantDataExist()) {
274 $pool = new ilNonEditableValueGUI($this->lng->txt('tst_input_dynamic_question_set_source_questionpool'), 'source_qpl_title');
275 $pool->setValue($this->questionSetConfig->getSourceQuestionPoolSummaryString($this->lng, $this->tree));
276 $pool->setDisabled(true);
277 $form->addItem($pool);
278 } else {
279 $poolInput = new ilSelectInputGUI($this->lng->txt('tst_input_dynamic_question_set_source_questionpool'), 'source_qpl_id');
280 $poolInput->setOptions($this->buildQuestionPoolSelectInputOptionArray(
281 $this->testOBJ->getAvailableQuestionpools(true, false, false, true, true)
282 ));
283 $poolInput->setValue($sourceQuestionPoolId);
284 $poolInput->setRequired(true);
285 $form->addItem($poolInput);
286 }
287
288 $questionOderingInput = new ilRadioGroupInputGUI(
289 $this->lng->txt('tst_input_dynamic_question_set_question_ordering'),
290 'question_ordering'
291 );
292 $questionOderingInput->setValue(
293 $this->questionSetConfig->getOrderingTaxonomyId() ?
294 self::QUESTION_ORDERING_TYPE_TAXONOMY : self::QUESTION_ORDERING_TYPE_UPDATE_DATE
295 );
296 $optionOrderByDate = new ilRadioOption(
297 $this->lng->txt('tst_input_dynamic_question_set_question_ordering_by_date'),
298 self::QUESTION_ORDERING_TYPE_UPDATE_DATE,
299 $this->lng->txt('tst_inp_dyn_quest_set_quest_ordering_by_date_desc')
300 );
301 $questionOderingInput->addOption($optionOrderByDate);
302 $optionOrderByTax = new ilRadioOption(
303 $this->lng->txt('tst_input_dynamic_question_set_question_ordering_by_tax'),
304 self::QUESTION_ORDERING_TYPE_TAXONOMY,
305 $this->lng->txt('tst_inp_dyn_quest_set_quest_ordering_by_tax_desc')
306 );
307 $orderTaxInput = new ilSelectInputGUI($this->lng->txt('tst_input_dynamic_question_set_ordering_tax'), 'ordering_tax');
308 $orderTaxInput->setInfo($this->lng->txt('tst_input_dynamic_question_set_ordering_tax_description'));
309 $orderTaxInput->setValue($this->questionSetConfig->getOrderingTaxonomyId());
310 $orderTaxInput->setRequired(true);
311 $orderTaxInput->setOptions($this->buildTaxonomySelectInputOptionArray($sourceQuestionPoolId));
312 $optionOrderByTax->addSubItem($orderTaxInput);
313 $questionOderingInput->addOption($optionOrderByTax);
314 $form->addItem($questionOderingInput);
315
316 $taxFilterInput = new ilCheckboxInputGUI($this->lng->txt('tst_input_dynamic_question_set_taxonomie_filter_enabled'), 'tax_filter_enabled');
317 $taxFilterInput->setValue(1);
318 $taxFilterInput->setChecked($this->questionSetConfig->isTaxonomyFilterEnabled());
319 $form->addItem($taxFilterInput);
320
321 $answStatusFilterInput = new ilCheckboxInputGUI(
322 $this->lng->txt('tst_input_dyn_quest_set_answer_status_filter_enabled'),
323 'answer_status_filter_enabled'
324 );
325 $answStatusFilterInput->setValue(1);
326 $answStatusFilterInput->setChecked($this->questionSetConfig->isAnswerStatusFilterEnabled());
327 $form->addItem($answStatusFilterInput);
328
329 if ($this->testOBJ->participantDataExist()) {
330 $questionOderingInput->setDisabled(true);
331 $taxFilterInput->setDisabled(true);
332 $answStatusFilterInput->setDisabled(true);
333 } else {
334 $form->addCommandButton(self::CMD_SAVE_FORM, $this->lng->txt('save'));
335 }
336
337 return $form;
338 }
This class represents a checkbox property in a property form.
This class represents a hidden form property in a property form.
This class represents a non editable value in a property form.
buildQuestionPoolSelectInputOptionArray($questionPoolsData)
converts the passed question pools data array to select input option array
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
This class represents a selection list property in a property form.

References buildQuestionPoolSelectInputOptionArray(), and buildTaxonomySelectInputOptionArray().

Referenced by saveFormCmd(), and showFormCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildQuestionPoolSelectInputOptionArray()

ilObjTestDynamicQuestionSetConfigGUI::buildQuestionPoolSelectInputOptionArray (   $questionPoolsData)
private

converts the passed question pools data array to select input option array

Parameters
array$questionPoolsData
Returns
array

Definition at line 346 of file class.ilObjTestDynamicQuestionSetConfigGUI.php.

347 {
348 $questionPoolSelectInputOptions = array( '' => $this->lng->txt('please_select') );
349
350 foreach ($questionPoolsData as $qplId => $qplData) {
351 $questionPoolSelectInputOptions[$qplId] = $qplData['title'];
352 }
353
354 return $questionPoolSelectInputOptions;
355 }

Referenced by buildForm().

+ Here is the caller graph for this function:

◆ buildTaxonomySelectInputOptionArray()

ilObjTestDynamicQuestionSetConfigGUI::buildTaxonomySelectInputOptionArray (   $questionPoolId)
private

Definition at line 357 of file class.ilObjTestDynamicQuestionSetConfigGUI.php.

358 {
359 $taxSelectOptions = array(
360 0 => $this->lng->txt('please_select')
361 );
362
363 if ($questionPoolId) {
364 require_once 'Services/Taxonomy/classes/class.ilObjTaxonomy.php';
365
366 $taxIds = ilObjTaxonomy::getUsageOfObject($questionPoolId);
367
368 foreach ($taxIds as $taxId) {
369 $taxSelectOptions[$taxId] = ilObject::_lookupTitle($taxId);
370 }
371 }
372
373 return $taxSelectOptions;
374 }
static getUsageOfObject($a_obj_id, $a_include_titles=false)
Get usage of object.
static _lookupTitle($a_id)
lookup object title

References ilObject\_lookupTitle(), and ilObjTaxonomy\getUsageOfObject().

Referenced by buildForm(), and buildTaxonomySelectInputOptionJson().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildTaxonomySelectInputOptionJson()

ilObjTestDynamicQuestionSetConfigGUI::buildTaxonomySelectInputOptionJson (   $questionPoolId)
private

Definition at line 376 of file class.ilObjTestDynamicQuestionSetConfigGUI.php.

377 {
378 $options = array();
379
380 foreach ($this->buildTaxonomySelectInputOptionArray($questionPoolId) as $optValue => $optLabel) {
381 $options[] = array('value' => $optValue, 'label' => $optLabel);
382 }
383
384 return json_encode($options);
385 }

References buildTaxonomySelectInputOptionArray().

Referenced by getTaxonomyOptionsAsyncCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ executeCommand()

ilObjTestDynamicQuestionSetConfigGUI::executeCommand ( )

Command Execution.

Definition at line 113 of file class.ilObjTestDynamicQuestionSetConfigGUI.php.

114 {
115 // allow only write access
116
117 if (!$this->access->checkAccess("write", "", $this->testOBJ->getRefId())) {
118 ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
119 $this->ctrl->redirectByClass('ilObjTestGUI', "infoScreen");
120 }
121
122 // activate corresponding tab (auto activation does not work in ilObjTestGUI-Tabs-Salad)
123
124 $this->tabs->activateTab('assQuestions');
125
126 // process command
127
128 $nextClass = $this->ctrl->getNextClass();
129
130 switch ($nextClass) {
131 default:
132 $cmd = $this->ctrl->getCmd(self::CMD_SHOW_FORM) . 'Cmd';
133 $this->$cmd();
134 }
135 }
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.

References ilUtil\sendInfo().

+ Here is the call graph for this function:

◆ getSubmittedSourceQuestionPoolId()

ilObjTestDynamicQuestionSetConfigGUI::getSubmittedSourceQuestionPoolId ( )
protected
Returns
integer

Definition at line 172 of file class.ilObjTestDynamicQuestionSetConfigGUI.php.

173 {
174 return (int) $_POST['source_qpl_id'];
175 }
$_POST["username"]

References $_POST.

Referenced by saveFormCmd().

+ Here is the caller graph for this function:

◆ getTaxonomyOptionsAsyncCmd()

ilObjTestDynamicQuestionSetConfigGUI::getTaxonomyOptionsAsyncCmd ( )

Definition at line 137 of file class.ilObjTestDynamicQuestionSetConfigGUI.php.

138 {
139 $questionPoolId = (int) $_POST['question_pool_id'];
140
141 echo $this->buildTaxonomySelectInputOptionJson($questionPoolId);
142 exit;
143 }
exit
Definition: login.php:29

References $_POST, buildTaxonomySelectInputOptionJson(), and exit.

+ Here is the call graph for this function:

◆ performSaveForm()

ilObjTestDynamicQuestionSetConfigGUI::performSaveForm ( ilPropertyFormGUI  $form)
private

saves the form fields to the database

Parameters
ilPropertyFormGUI$form

Definition at line 215 of file class.ilObjTestDynamicQuestionSetConfigGUI.php.

216 {
217 $this->questionSetConfig->setSourceQuestionPoolId(
218 $form->getItemByPostVar('source_qpl_id')->getValue()
219 );
220
221 $this->questionSetConfig->setSourceQuestionPoolTitle(ilObject::_lookupTitle(
222 $form->getItemByPostVar('source_qpl_id')->getValue()
223 ));
224
225 switch ($form->getItemByPostVar('question_ordering')->getValue()) {
227 $this->questionSetConfig->setOrderingTaxonomyId(null);
228 break;
229
231 $this->questionSetConfig->setOrderingTaxonomyId(
232 $form->getItemByPostVar('ordering_tax')->getValue()
233 );
234 break;
235 }
236
237 $this->questionSetConfig->setTaxonomyFilterEnabled(
238 $form->getItemByPostVar('tax_filter_enabled')->getChecked()
239 );
240
241 $this->questionSetConfig->setAnswerStatusFilterEnabled(
242 $form->getItemByPostVar('answer_status_filter_enabled')->getChecked()
243 );
244
245 $this->questionSetConfig->saveToDb($this->testOBJ->getTestId());
246 }
getItemByPostVar($a_post_var)
Get Item by POST variable.

References ilObject\_lookupTitle(), ilPropertyFormGUI\getItemByPostVar(), QUESTION_ORDERING_TYPE_TAXONOMY, and QUESTION_ORDERING_TYPE_UPDATE_DATE.

Referenced by saveFormCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveFormCmd()

ilObjTestDynamicQuestionSetConfigGUI::saveFormCmd ( )

command method that checks the question set config form

if form is valid it gets saved to the database, otherwise it will be reprinted with alerts

Definition at line 183 of file class.ilObjTestDynamicQuestionSetConfigGUI.php.

184 {
185 $form = $this->buildForm(
187 );
188
189 if ($this->testOBJ->participantDataExist()) {
190 ilUtil::sendFailure($this->lng->txt("tst_msg_cannot_modify_dynamic_question_set_conf_due_to_part"), true);
191 return $this->showFormCmd($form);
192 }
193
194 $errors = !$form->checkInput(); // ALWAYS CALL BEFORE setValuesByPost()
195 $form->setValuesByPost(); // NEVER CALL THIS BEFORE checkInput()
196
197 if ($errors) {
198 ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
199 return $this->showFormCmd($form);
200 }
201
202 $this->performSaveForm($form);
203
204 $this->testOBJ->saveCompleteStatus($this->questionSetConfig);
205
206 ilUtil::sendSuccess($this->lng->txt("tst_msg_dynamic_question_set_config_modified"), true);
207 $this->ctrl->redirect($this, self::CMD_SHOW_FORM);
208 }
showFormCmd(ilPropertyFormGUI $form=null)
command method that prints the question set config form
buildForm($sourceQuestionPoolId)
builds the question set config form and initialises the fields with the config currently saved in dat...
performSaveForm(ilPropertyFormGUI $form)
saves the form fields to the database
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$errors
Definition: imgupload.php:49

References $errors, buildForm(), getSubmittedSourceQuestionPoolId(), performSaveForm(), ilUtil\sendFailure(), and showFormCmd().

+ Here is the call graph for this function:

◆ showFormCmd()

ilObjTestDynamicQuestionSetConfigGUI::showFormCmd ( ilPropertyFormGUI  $form = null)

command method that prints the question set config form

Parameters
ilPropertyFormGUI$form

Definition at line 150 of file class.ilObjTestDynamicQuestionSetConfigGUI.php.

151 {
152 $this->questionSetConfig->loadFromDb();
153
154 if ($this->questionSetConfig->areDepenciesBroken($this->tree)) {
155 ilUtil::sendFailure($this->questionSetConfig->getDepenciesBrokenMessage($this->lng));
156 } elseif ($this->questionSetConfig->areDepenciesInVulnerableState($this->tree)) {
157 ilUtil::sendInfo($this->questionSetConfig->getDepenciesInVulnerableStateMessage($this->lng));
158 }
159
160 if ($form === null) {
161 $form = $this->buildForm($this->questionSetConfig->getSourceQuestionPoolId());
162 }
163
164 $this->tpl->setContent($this->ctrl->getHTML($form));
165
166 $this->tpl->addJavaScript('Modules/Test/js/ilTestDynamicQuestionSetConfig.js');
167 }

References buildForm(), ilUtil\sendFailure(), and ilUtil\sendInfo().

Referenced by saveFormCmd().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilObjTestDynamicQuestionSetConfigGUI::$access = null
protected

Definition at line 37 of file class.ilObjTestDynamicQuestionSetConfigGUI.php.

Referenced by __construct().

◆ $ctrl

ilObjTestDynamicQuestionSetConfigGUI::$ctrl = null
protected

Definition at line 30 of file class.ilObjTestDynamicQuestionSetConfigGUI.php.

Referenced by __construct().

◆ $db

ilObjTestDynamicQuestionSetConfigGUI::$db = null
protected

Definition at line 65 of file class.ilObjTestDynamicQuestionSetConfigGUI.php.

Referenced by __construct().

◆ $lng

ilObjTestDynamicQuestionSetConfigGUI::$lng = null
protected

Definition at line 51 of file class.ilObjTestDynamicQuestionSetConfigGUI.php.

Referenced by __construct().

◆ $questionSetConfig

ilObjTestDynamicQuestionSetConfigGUI::$questionSetConfig = null
protected

◆ $tabs

ilObjTestDynamicQuestionSetConfigGUI::$tabs = null
protected

Definition at line 44 of file class.ilObjTestDynamicQuestionSetConfigGUI.php.

Referenced by __construct().

◆ $testOBJ

ilObjTestDynamicQuestionSetConfigGUI::$testOBJ = null
protected

Definition at line 79 of file class.ilObjTestDynamicQuestionSetConfigGUI.php.

Referenced by __construct().

◆ $tpl

ilObjTestDynamicQuestionSetConfigGUI::$tpl = null
protected

Definition at line 58 of file class.ilObjTestDynamicQuestionSetConfigGUI.php.

Referenced by __construct().

◆ $tree

ilObjTestDynamicQuestionSetConfigGUI::$tree = null
protected

Definition at line 72 of file class.ilObjTestDynamicQuestionSetConfigGUI.php.

Referenced by __construct().

◆ CMD_GET_TAXONOMY_OPTIONS_ASYNC

const ilObjTestDynamicQuestionSetConfigGUI::CMD_GET_TAXONOMY_OPTIONS_ASYNC = 'getTaxonomyOptionsAsync'

◆ CMD_SAVE_FORM

const ilObjTestDynamicQuestionSetConfigGUI::CMD_SAVE_FORM = 'saveForm'

◆ CMD_SHOW_FORM

const ilObjTestDynamicQuestionSetConfigGUI::CMD_SHOW_FORM = 'showForm'

command constants

Definition at line 21 of file class.ilObjTestDynamicQuestionSetConfigGUI.php.

◆ QUESTION_ORDERING_TYPE_TAXONOMY

const ilObjTestDynamicQuestionSetConfigGUI::QUESTION_ORDERING_TYPE_TAXONOMY = 'ordering_by_tax'

Definition at line 89 of file class.ilObjTestDynamicQuestionSetConfigGUI.php.

Referenced by performSaveForm().

◆ QUESTION_ORDERING_TYPE_UPDATE_DATE

const ilObjTestDynamicQuestionSetConfigGUI::QUESTION_ORDERING_TYPE_UPDATE_DATE = 'ordering_by_date'

Definition at line 88 of file class.ilObjTestDynamicQuestionSetConfigGUI.php.

Referenced by performSaveForm().


The documentation for this class was generated from the following file: