ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilObjTestDynamicQuestionSetConfigGUI Class Reference
+ Collaboration diagram for ilObjTestDynamicQuestionSetConfigGUI:

Public Member Functions

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

264  {
265  $this->questionSetConfig->loadFromDb( $this->testOBJ->getTestId() );
266 
267  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
268  $form = new ilPropertyFormGUI();
269 
270  $form->setFormAction($this->ctrl->getFormAction($this));
271 
272  $form->setId("tst_form_dynamic_question_set_config");
273  $form->setTitle($this->lng->txt('tst_form_dynamic_question_set_config'));
274  $form->setTableWidth("100%");
275 
276  $hiddenInputTaxSelectOptAsyncUrl = new ilHiddenInputGUI('taxSelectOptAsyncUrl');
277  $hiddenInputTaxSelectOptAsyncUrl->setValue(
278  $this->ctrl->getLinkTarget($this, self::CMD_GET_TAXONOMY_OPTIONS_ASYNC, '', true)
279  );
280  $form->addItem($hiddenInputTaxSelectOptAsyncUrl);
281 
282  if( $this->testOBJ->participantDataExist() )
283  {
284  $pool = new ilNonEditableValueGUI($this->lng->txt('tst_input_dynamic_question_set_source_questionpool'), 'source_qpl_title');
285  $pool->setValue( $this->questionSetConfig->getSourceQuestionPoolSummaryString($this->lng, $this->tree) );
286  $pool->setDisabled(true);
287  $form->addItem($pool);
288  }
289  else
290  {
291  $poolInput = new ilSelectInputGUI($this->lng->txt('tst_input_dynamic_question_set_source_questionpool'), 'source_qpl_id');
293  $this->testOBJ->getAvailableQuestionpools(true, false, false, true, true)
294  ));
295  $poolInput->setValue( $sourceQuestionPoolId );
296  $poolInput->setRequired(true);
297  $form->addItem($poolInput);
298  }
299 
300  $questionOderingInput = new ilRadioGroupInputGUI(
301  $this->lng->txt('tst_input_dynamic_question_set_question_ordering'), 'question_ordering'
302  );
303  $questionOderingInput->setValue( $this->questionSetConfig->getOrderingTaxonomyId() ?
304  self::QUESTION_ORDERING_TYPE_TAXONOMY : self::QUESTION_ORDERING_TYPE_UPDATE_DATE
305  );
306  $optionOrderByDate = new ilRadioOption(
307  $this->lng->txt('tst_input_dynamic_question_set_question_ordering_by_date'),
308  self::QUESTION_ORDERING_TYPE_UPDATE_DATE,
309  $this->lng->txt('tst_inp_dyn_quest_set_quest_ordering_by_date_desc')
310  );
311  $questionOderingInput->addOption($optionOrderByDate);
312  $optionOrderByTax = new ilRadioOption(
313  $this->lng->txt('tst_input_dynamic_question_set_question_ordering_by_tax'),
314  self::QUESTION_ORDERING_TYPE_TAXONOMY,
315  $this->lng->txt('tst_inp_dyn_quest_set_quest_ordering_by_tax_desc')
316  );
317  $orderTaxInput = new ilSelectInputGUI($this->lng->txt('tst_input_dynamic_question_set_ordering_tax'), 'ordering_tax');
318  $orderTaxInput->setInfo($this->lng->txt('tst_input_dynamic_question_set_ordering_tax_description'));
319  $orderTaxInput->setValue($this->questionSetConfig->getOrderingTaxonomyId());
320  $orderTaxInput->setRequired(true);
321  $orderTaxInput->setOptions($this->buildTaxonomySelectInputOptionArray( $sourceQuestionPoolId ));
322  $optionOrderByTax->addSubItem($orderTaxInput);
323  $questionOderingInput->addOption($optionOrderByTax);
324  $form->addItem($questionOderingInput);
325 
326  $taxFilterInput = new ilCheckboxInputGUI($this->lng->txt('tst_input_dynamic_question_set_taxonomie_filter_enabled'), 'tax_filter_enabled');
327  $taxFilterInput->setValue(1);
328  $taxFilterInput->setChecked( $this->questionSetConfig->isTaxonomyFilterEnabled() );
329  $form->addItem($taxFilterInput);
330 
331  $answStatusFilterInput = new ilCheckboxInputGUI(
332  $this->lng->txt('tst_input_dyn_quest_set_answer_status_filter_enabled'), 'answer_status_filter_enabled'
333  );
334  $answStatusFilterInput->setValue(1);
335  $answStatusFilterInput->setChecked( $this->questionSetConfig->isAnswerStatusFilterEnabled() );
336  $form->addItem($answStatusFilterInput);
337 
338  if( $this->testOBJ->participantDataExist() )
339  {
340  $questionOderingInput->setDisabled(true);
341  $taxFilterInput->setDisabled(true);
342  $answStatusFilterInput->setDisabled(true);
343  }
344  else
345  {
346  $form->addCommandButton(self::CMD_SAVE_FORM, $this->lng->txt('save'));
347  }
348 
349  return $form;
350  }
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 358 of file class.ilObjTestDynamicQuestionSetConfigGUI.php.

References array.

Referenced by buildForm().

359  {
360  $questionPoolSelectInputOptions = array( '' => $this->lng->txt('please_select') );
361 
362  foreach($questionPoolsData as $qplId => $qplData)
363  {
364  $questionPoolSelectInputOptions[$qplId] = $qplData['title'];
365  }
366 
367  return $questionPoolSelectInputOptions;
368  }
Create styles array
The data for the language used.
+ Here is the caller graph for this function:

◆ buildTaxonomySelectInputOptionArray()

ilObjTestDynamicQuestionSetConfigGUI::buildTaxonomySelectInputOptionArray (   $questionPoolId)
private

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

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

Referenced by buildForm(), and buildTaxonomySelectInputOptionJson().

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

◆ buildTaxonomySelectInputOptionJson()

ilObjTestDynamicQuestionSetConfigGUI::buildTaxonomySelectInputOptionJson (   $questionPoolId)
private

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

References $options, array, and buildTaxonomySelectInputOptionArray().

Referenced by getTaxonomyOptionsAsyncCmd().

392  {
393  $options = array();
394 
395  foreach($this->buildTaxonomySelectInputOptionArray($questionPoolId) as $optValue => $optLabel)
396  {
397  $options[] = array('value' => $optValue, 'label' => $optLabel);
398  }
399 
400  return json_encode($options);
401  }
if(!is_array($argv)) $options
Create styles array
The data for the language used.
+ 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:

◆ getSubmittedSourceQuestionPoolId()

ilObjTestDynamicQuestionSetConfigGUI::getSubmittedSourceQuestionPoolId ( )
protected
Returns
integer

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

References $_POST.

Referenced by saveFormCmd().

179  {
180  return (int)$_POST['source_qpl_id'];
181  }
$_POST["username"]
+ Here is the caller 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  }
$_POST["username"]
+ 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 223 of file class.ilObjTestDynamicQuestionSetConfigGUI.php.

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

Referenced by saveFormCmd().

224  {
225  $this->questionSetConfig->setSourceQuestionPoolId(
226  $form->getItemByPostVar('source_qpl_id')->getValue()
227  );
228 
229  $this->questionSetConfig->setSourceQuestionPoolTitle( ilObject::_lookupTitle(
230  $form->getItemByPostVar('source_qpl_id')->getValue()
231  ));
232 
233  switch( $form->getItemByPostVar('question_ordering')->getValue() )
234  {
235  case self::QUESTION_ORDERING_TYPE_UPDATE_DATE:
236  $this->questionSetConfig->setOrderingTaxonomyId(null);
237  break;
238 
239  case self::QUESTION_ORDERING_TYPE_TAXONOMY:
240  $this->questionSetConfig->setOrderingTaxonomyId(
241  $form->getItemByPostVar('ordering_tax')->getValue()
242  );
243  break;
244  }
245 
246  $this->questionSetConfig->setTaxonomyFilterEnabled(
247  $form->getItemByPostVar('tax_filter_enabled')->getChecked()
248  );
249 
250  $this->questionSetConfig->setAnswerStatusFilterEnabled(
251  $form->getItemByPostVar('answer_status_filter_enabled')->getChecked()
252  );
253 
254  $this->questionSetConfig->saveToDb( $this->testOBJ->getTestId() );
255  }
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 189 of file class.ilObjTestDynamicQuestionSetConfigGUI.php.

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

190  {
191  $form = $this->buildForm(
193  );
194 
195  if( $this->testOBJ->participantDataExist() )
196  {
197  ilUtil::sendFailure($this->lng->txt("tst_msg_cannot_modify_dynamic_question_set_conf_due_to_part"), true);
198  return $this->showFormCmd($form);
199  }
200 
201  $errors = !$form->checkInput(); // ALWAYS CALL BEFORE setValuesByPost()
202  $form->setValuesByPost(); // NEVER CALL THIS BEFORE checkInput()
203 
204  if($errors)
205  {
206  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
207  return $this->showFormCmd($form);
208  }
209 
210  $this->performSaveForm($form);
211 
212  $this->testOBJ->saveCompleteStatus( $this->questionSetConfig );
213 
214  ilUtil::sendSuccess($this->lng->txt("tst_msg_dynamic_question_set_config_modified"), true);
215  $this->ctrl->redirect($this, self::CMD_SHOW_FORM);
216  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$errors
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
+ 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($this->questionSetConfig->getSourceQuestionPoolId());
168  }
169 
170  $this->tpl->setContent( $this->ctrl->getHTML($form) );
171 
172  $this->tpl->addJavaScript('Modules/Test/js/ilTestDynamicQuestionSetConfig.js');
173  }
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
buildForm($sourceQuestionPoolId)
builds the question set config form and initialises the fields with the config currently saved in dat...
+ 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: