ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
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 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,
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 (   $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 267 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().

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

Referenced by buildForm().

371  {
372  $questionPoolSelectInputOptions = array( '' => $this->lng->txt('please_select') );
373 
374  foreach($questionPoolsData as $qplId => $qplData)
375  {
376  $questionPoolSelectInputOptions[$qplId] = $qplData['title'];
377  }
378 
379  return $questionPoolSelectInputOptions;
380  }
+ Here is the caller graph for this function:

◆ buildTaxonomySelectInputOptionArray()

ilObjTestDynamicQuestionSetConfigGUI::buildTaxonomySelectInputOptionArray (   $questionPoolId)
private

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

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

Referenced by buildForm(), and buildTaxonomySelectInputOptionJson().

383  {
384  $taxSelectOptions = array(
385  0 => $this->lng->txt('please_select')
386  );
387 
388  if( $questionPoolId )
389  {
390  require_once 'Services/Taxonomy/classes/class.ilObjTaxonomy.php';
391 
392  $taxIds = ilObjTaxonomy::getUsageOfObject($questionPoolId);
393 
394  foreach($taxIds as $taxId)
395  {
396  $taxSelectOptions[$taxId] = ilObject::_lookupTitle($taxId);
397  }
398  }
399 
400  return $taxSelectOptions;
401  }
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 403 of file class.ilObjTestDynamicQuestionSetConfigGUI.php.

References $options, and buildTaxonomySelectInputOptionArray().

Referenced by getTaxonomyOptionsAsyncCmd().

404  {
405  $options = array();
406 
407  foreach($this->buildTaxonomySelectInputOptionArray($questionPoolId) as $optValue => $optLabel)
408  {
409  $options[] = array('value' => $optValue, 'label' => $optLabel);
410  }
411 
412  return json_encode($options);
413  }
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:

◆ 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']
Definition: cron.php:12
+ 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  }
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 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->setPreviousQuestionsListEnabled(
255  $form->getItemByPostVar('prev_quest_list_enabled')->getChecked()
256  );
257 
258  $this->questionSetConfig->saveToDb( $this->testOBJ->getTestId() );
259  }
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.
$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
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: