ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilObjTestDynamicQuestionSetConfigGUI Class Reference
+ Collaboration diagram for ilObjTestDynamicQuestionSetConfigGUI:

Public Member Functions

 __construct (ilCtrl $ctrl, ilAccessHandler $access, ilTabsGUI $tabs, ilLanguage $lng, ilTemplate $tpl, ilDB $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 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 ()
 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,
ilTemplate  $tpl,
ilDB  $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 ( )
private

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

Returns
ilPropertyFormGUI $form

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

References ilRadioOption\addSubItem(), buildQuestionPoolSelectInputOptionArray(), buildTaxonomySelectInputOptionArray(), ilRadioOption\setInfo(), ilSelectInputGUI\setOptions(), ilCheckboxInputGUI\setValue(), ilRadioGroupInputGUI\setValue(), ilRadioOption\setValue(), and ilNonEditableValueGUI\setValue().

Referenced by saveFormCmd(), and showFormCmd().

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

Referenced by buildForm().

362  {
363  $questionPoolSelectInputOptions = array( '' => $this->lng->txt('please_select') );
364 
365  foreach($questionPoolsData as $qplId => $qplData)
366  {
367  $questionPoolSelectInputOptions[$qplId] = $qplData['title'];
368  }
369 
370  return $questionPoolSelectInputOptions;
371  }
+ Here is the caller graph for this function:

◆ buildTaxonomySelectInputOptionArray()

ilObjTestDynamicQuestionSetConfigGUI::buildTaxonomySelectInputOptionArray (   $questionPoolId)
private

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

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

Referenced by buildForm(), and buildTaxonomySelectInputOptionJson().

374  {
375  $taxSelectOptions = array(
376  0 => $this->lng->txt('please_select')
377  );
378 
379  if( $questionPoolId )
380  {
381  require_once 'Services/Taxonomy/classes/class.ilObjTaxonomy.php';
382 
383  $taxIds = ilObjTaxonomy::getUsageOfObject($questionPoolId);
384 
385  foreach($taxIds as $taxId)
386  {
387  $taxSelectOptions[$taxId] = ilObject::_lookupTitle($taxId);
388  }
389  }
390 
391  return $taxSelectOptions;
392  }
static getUsageOfObject($a_obj_id, $a_include_titles=false)
Get usage of object.
static _lookupTitle($a_id)
lookup object title
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildTaxonomySelectInputOptionJson()

ilObjTestDynamicQuestionSetConfigGUI::buildTaxonomySelectInputOptionJson (   $questionPoolId)
private

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

References $options, and buildTaxonomySelectInputOptionArray().

Referenced by getTaxonomyOptionsAsyncCmd().

395  {
396  $options = array();
397 
398  foreach($this->buildTaxonomySelectInputOptionArray($questionPoolId) as $optValue => $optLabel)
399  {
400  $options[] = array('value' => $optValue, 'label' => $optLabel);
401  }
402 
403  return json_encode($options);
404  }
if(!is_array($argv)) $options
+ 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.

References $cmd, and ilUtil\sendInfo().

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

◆ getTaxonomyOptionsAsyncCmd()

ilObjTestDynamicQuestionSetConfigGUI::getTaxonomyOptionsAsyncCmd ( )

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

References $_POST, buildTaxonomySelectInputOptionJson(), and exit.

140  {
141  $questionPoolId = (int)$_POST['question_pool_id'];
142 
143  echo $this->buildTaxonomySelectInputOptionJson($questionPoolId);
144  exit;
145  }
exit
Definition: login.php:54
$_POST['username']
Definition: cron.php:12
+ 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 213 of file class.ilObjTestDynamicQuestionSetConfigGUI.php.

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

Referenced by saveFormCmd().

214  {
215  $this->questionSetConfig->setSourceQuestionPoolId(
216  $form->getItemByPostVar('source_qpl_id')->getValue()
217  );
218 
219  $this->questionSetConfig->setSourceQuestionPoolTitle( ilObject::_lookupTitle(
220  $form->getItemByPostVar('source_qpl_id')->getValue()
221  ));
222 
223  switch( $form->getItemByPostVar('question_ordering')->getValue() )
224  {
225  case self::QUESTION_ORDERING_TYPE_UPDATE_DATE:
226  $this->questionSetConfig->setOrderingTaxonomyId(null);
227  break;
228 
229  case self::QUESTION_ORDERING_TYPE_TAXONOMY:
230  $this->questionSetConfig->setOrderingTaxonomyId(
231  $form->getItemByPostVar('ordering_tax')->getValue()
232  );
233  break;
234  }
235 
236  $this->questionSetConfig->setTaxonomyFilterEnabled(
237  $form->getItemByPostVar('tax_filter_enabled')->getChecked()
238  );
239 
240  $this->questionSetConfig->setAnswerStatusFilterEnabled(
241  $form->getItemByPostVar('answer_status_filter_enabled')->getChecked()
242  );
243 
244  $this->questionSetConfig->setPreviousQuestionsListEnabled(
245  $form->getItemByPostVar('prev_quest_list_enabled')->getChecked()
246  );
247 
248  $this->questionSetConfig->saveToDb( $this->testOBJ->getTestId() );
249  }
getItemByPostVar($a_post_var)
Get Item by POST variable.
static _lookupTitle($a_id)
lookup object title
+ 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 181 of file class.ilObjTestDynamicQuestionSetConfigGUI.php.

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

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

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

Referenced by saveFormCmd().

153  {
154  $this->questionSetConfig->loadFromDb();
155 
156  if( $this->questionSetConfig->areDepenciesBroken($this->tree) )
157  {
158  ilUtil::sendFailure( $this->questionSetConfig->getDepenciesBrokenMessage($this->lng) );
159  }
160  elseif( $this->questionSetConfig->areDepenciesInVulnerableState($this->tree) )
161  {
162  ilUtil::sendInfo( $this->questionSetConfig->getDepenciesInVulnerableStateMessage($this->lng) );
163  }
164 
165  if( $form === null )
166  {
167  $form = $this->buildForm();
168  }
169 
170  $this->tpl->setContent( $this->ctrl->getHTML($form) );
171 
172  $this->tpl->addJavaScript('Modules/Test/js/ilTestDynamicQuestionSetConfig.js');
173  }
buildForm()
builds the question set config form and initialises the fields with the config currently saved in dat...
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ 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'

◆ QUESTION_ORDERING_TYPE_UPDATE_DATE

const ilObjTestDynamicQuestionSetConfigGUI::QUESTION_ORDERING_TYPE_UPDATE_DATE = 'ordering_by_date'

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