ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilObjTestSettingsGeneralGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Modules/Test/classes/class.ilTestSettingsGUI.php';
5 require_once 'Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php';
6 
21 {
25  const CMD_SHOW_FORM = 'showForm';
26  const CMD_SAVE_FORM = 'saveForm';
27  const CMD_CONFIRMED_SAVE_FORM = 'confirmedSaveForm';
28  const CMD_SHOW_RESET_TPL_CONFIRM = 'showResetTemplateConfirmation';
29  const CMD_CONFIRMED_RESET_TPL = 'confirmedResetTemplate';
30 
31  const INST_FB_HANDLING_OPT_NONE = 'none';
32  const INST_FB_HANDLING_OPT_FREEZE = 'freeze';
33  const INST_FB_HANDLING_OPT_FORCE = 'force';
34  const INST_FB_HANDLING_OPT_FORCE_AND_FREEZE = 'force_freeze';
35 
37  protected $ctrl = null;
38 
40  protected $access = null;
41 
43  protected $lng = null;
44 
46  protected $tpl = null;
47 
49  protected $tree = null;
50 
52  protected $db = null;
53 
55  protected $pluginAdmin = null;
56 
58  protected $activeUser = null;
59 
61  protected $testGUI = null;
62 
65 
78  public function __construct(
79  ilCtrl $ctrl,
83  ilTree $tree,
84  ilDB $db,
88  )
89  {
90  $this->ctrl = $ctrl;
91  $this->access = $access;
92  $this->lng = $lng;
93  $this->tpl = $tpl;
94  $this->tree = $tree;
95  $this->db = $db;
96  $this->pluginAdmin = $pluginAdmin;
97  $this->activeUser = $activeUser;
98 
99  $this->testGUI = $testGUI;
100 
101  require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
102  $this->testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($this->tree, $this->db, $this->pluginAdmin, $testGUI->object);
103 
104  parent::__construct($testGUI->object);
105  }
106 
110  public function executeCommand()
111  {
112  // allow only write access
113 
114  if (!$this->access->checkAccess("write", "", $this->testGUI->ref_id))
115  {
116  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
117  $this->ctrl->redirect($this->testGUI, "infoScreen");
118  }
119 
120  // process command
121 
122  $nextClass = $this->ctrl->getNextClass();
123 
124  switch($nextClass)
125  {
126  default:
127  $cmd = $this->ctrl->getCmd(self::CMD_SHOW_FORM).'Cmd';
128  $this->$cmd();
129  }
130  }
131 
132  private function showFormCmd(ilPropertyFormGUI $form = null)
133  {
134  $this->tpl->addJavascript("./Services/JavaScript/js/Basic.js");
135 
136  if( $form === null )
137  {
138  $form = $this->buildForm();
139  }
140 
141  $formHTML = $this->ctrl->getHTML($form);
142  $msgHTML = $this->getSettingsTemplateMessageHTML();
143 
144  $this->tpl->setContent($formHTML.$msgHTML);
145  }
146 
147  private function showConfirmation(ilPropertyFormGUI $form, $oldQuestionSetType, $newQuestionSetType, $hasQuestionsWithoutQuestionpool)
148  {
149  require_once 'Modules/Test/classes/confirmations/class.ilTestSettingsChangeConfirmationGUI.php';
150  $confirmation = new ilTestSettingsChangeConfirmationGUI($this->lng, $this->testOBJ);
151 
152  $confirmation->setFormAction( $this->ctrl->getFormAction($this) );
153  $confirmation->setCancel($this->lng->txt('cancel'), self::CMD_SHOW_FORM);
154  $confirmation->setConfirm($this->lng->txt('confirm'), self::CMD_CONFIRMED_SAVE_FORM);
155 
156  $confirmation->setOldQuestionSetType($oldQuestionSetType);
157  $confirmation->setNewQuestionSetType($newQuestionSetType);
158  $confirmation->setQuestionLossInfoEnabled($hasQuestionsWithoutQuestionpool);
159  $confirmation->build();
160 
161  $confirmation->populateParametersFromPropertyForm($form, $this->activeUser->getTimeZone());
162 
163  $this->tpl->setContent( $this->ctrl->getHTML($confirmation) );
164  }
165 
166  protected function getSettingsTemplateMessageHTML()
167  {
168  if( $this->settingsTemplate )
169  {
170  $title = $this->settingsTemplate->getTitle();
171 
172  if( $this->settingsTemplate->getAutoGenerated() )
173  {
174  $title = $this->lng->txt($title);
175  }
176 
177  global $tpl;
178 
179  $link = $this->ctrl->getLinkTarget($this, self::CMD_SHOW_RESET_TPL_CONFIRM);
180  $link = "<a href=\"".$link."\">".$this->lng->txt("test_using_template_link")."</a>";
181 
182  $msgHTML = $tpl->getMessageHTML(
183  sprintf($this->lng->txt("test_using_template"), $title, $link), "info"
184  );
185 
186  $msgHTML = "<div style=\"margin-top:10px\">$msgHTML</div>";
187  }
188  else
189  {
190  $msgHTML = '';
191  }
192 
193  return $msgHTML;
194  }
195 
196  private function confirmedSaveFormCmd()
197  {
198  return $this->saveFormCmd(true);
199  }
200 
201  private function saveFormCmd($isConfirmedSave = false)
202  {
203  $form = $this->buildForm();
204 
205  // form validation and initialisation
206 
207  $errors = !$form->checkInput(); // ALWAYS CALL BEFORE setValuesByPost()
208  $form->setValuesByPost(); // NEVER CALL THIS BEFORE checkInput()
209  // Sarcasm? No. Because checkInput checks the form graph against the POST without
210  // actually setting the values into the form. Sounds ridiculous? Indeed, and it is.
211 
212  // return to form when any form validation errors exist
213 
214  if($errors)
215  {
216  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
217  return $this->showFormCmd($form);
218  }
219 
220  // return to form when online is to be set, but no questions are configured
221 
222  $currentQuestionSetConfig = $this->testQuestionSetConfigFactory->getQuestionSetConfig();
223  if( $form->getItemByPostVar('online')->getChecked() && !$this->testOBJ->isComplete($currentQuestionSetConfig) )
224  {
225  $form->getItemByPostVar('online')->setAlert(
226  $this->lng->txt("cannot_switch_to_online_no_questions_andor_no_mark_steps")
227  );
228 
229  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
230  return $this->showFormCmd($form);
231  }
232 
233  $infoMsg = array();
234 
235  // solve conflicts with question set type setting with confirmation screen if required
236  // determine wether question set type relating data is to be removed (questions/pools)
237 
238  $questionSetTypeRelatingDataCleanupRequired = false;
239 
240  $oldQuestionSetType = $this->testOBJ->getQuestionSetType();
241  if( $form->getItemByPostVar('question_set_type') instanceof ilFormPropertyGUI )
242  {
243  $newQuestionSetType = $form->getItemByPostVar('question_set_type')->getValue();
244 
245  if( !$this->testOBJ->participantDataExist() && $newQuestionSetType != $oldQuestionSetType )
246  {
247  $oldQuestionSetConfig = $this->testQuestionSetConfigFactory->getQuestionSetConfigByType(
248  $oldQuestionSetType
249  );
250 
251  if( $oldQuestionSetConfig->doesQuestionSetRelatedDataExist() )
252  {
253  if( !$isConfirmedSave )
254  {
255  if( $oldQuestionSetType == ilObjTest::QUESTION_SET_TYPE_FIXED )
256  {
257  return $this->showConfirmation(
258  $form, $oldQuestionSetType, $newQuestionSetType,
259  $this->testOBJ->hasQuestionsWithoutQuestionpool()
260  );
261  }
262 
263  return $this->showConfirmation(
264  $form, $oldQuestionSetType, $newQuestionSetType, false
265  );
266  }
267 
268  $questionSetTypeRelatingDataCleanupRequired = true;
269  }
270 
271  if( $form->getItemByPostVar('online')->getChecked() )
272  {
273  $form->getItemByPostVar('online')->setChecked(false);
274 
275  if( $this->testOBJ->isOnline() )
276  {
277  $infoMsg[] = $this->lng->txt("tst_set_offline_due_to_switched_question_set_type_setting");
278  }
279  else
280  {
281  $infoMsg[] = $this->lng->txt("tst_cannot_online_due_to_switched_quest_set_type_setting");
282  }
283  }
284  }
285  }
286  else
287  {
288  $newQuestionSetType = $oldQuestionSetType;
289  }
290 
291  // adjust settiue to desired question set type
292 
293  if( $newQuestionSetType != ilObjTest::QUESTION_SET_TYPE_FIXED )
294  {
295  $form->getItemByPostVar('chb_use_previous_answers')->setChecked(false);
296  }
297 
298  // avoid settings conflict "obligate questions" and "freeze answer"
299 
300  if( $form->getItemByPostVar('obligations_enabled')->getChecked() )
301  {
302  switch( $form->getItemByPostVar('instant_feedback_handling')->getValue() )
303  {
304  case self::INST_FB_HANDLING_OPT_FREEZE:
305 
306  $form->getItemByPostVar('instant_feedback_handling')->setValue(self::INST_FB_HANDLING_OPT_NONE);
307  $infoMsg[] = $this->lng->txt("tst_conflict_fbh_oblig_quest");
308  $infoMsg[] = $this->lng->txt("tst_conflict_reset_non_fbh");
309  break;
310 
311  case self::INST_FB_HANDLING_OPT_FORCE_AND_FREEZE:
312 
313  $form->getItemByPostVar('instant_feedback_handling')->setValue(self::INST_FB_HANDLING_OPT_FORCE);
314  $infoMsg[] = $this->lng->txt("tst_conflict_fbh_oblig_quest");
315  $infoMsg[] = $this->lng->txt("tst_conflict_reset_fbh_force");
316  break;
317  }
318  }
319 
320  // perform saving the form data
321 
322  $this->performSaveForm($form);
323 
324  // clean up test mode relating configuration data (questions/questionpools)
325 
326  if( $questionSetTypeRelatingDataCleanupRequired )
327  {
328  $oldQuestionSetConfig->removeQuestionSetRelatedData();
329  }
330 
331  // disinvite all invited users if required
332 
333  if( !$this->testOBJ->participantDataExist() && !$this->testOBJ->getFixedParticipants() )
334  {
335  foreach ($this->testOBJ->getInvitedUsers() as $usrId => $usrData)
336  {
337  $this->testOBJ->disinviteUser($usrId);
338  }
339  }
340 
341  // redirect to form output
342 
343  if( count($infoMsg) )
344  {
345  ilUtil::sendInfo(implode('<br />', $infoMsg), true);
346  }
347 
348  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
349  $this->ctrl->redirect($this, self::CMD_SHOW_FORM);
350  }
351 
356  {
357  require_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
358  $confirmationGUI = new ilConfirmationGUI();
359 
360  $confirmationGUI->setFormAction($this->ctrl->getFormAction($this));
361  $confirmationGUI->setHeaderText($this->lng->txt("test_confirm_template_reset"));
362  $confirmationGUI->setCancel($this->lng->txt('cancel'), self::CMD_SHOW_FORM);
363  $confirmationGUI->setConfirm($this->lng->txt('confirm'), self::CMD_CONFIRMED_RESET_TPL);
364 
365  $this->tpl->setContent( $this->ctrl->getHTML($confirmationGUI) );
366  }
367 
371  private function confirmedResetTemplateCmd()
372  {
373  $this->testOBJ->setTemplate(null);
374  $this->testOBJ->saveToDB();
375 
376  ilUtil::sendSuccess($this->lng->txt("test_template_reset"), true);
377  $this->ctrl->redirect($this, self::CMD_SHOW_FORM);
378  }
379 
381  {
382  if( !($form->getItemByPostVar('skill_service') instanceof ilFormPropertyGUI) )
383  {
384  return false;
385  }
386 
388  {
389  return false;
390  }
391 
392  if( !$form->getItemByPostVar('skill_service')->getChecked() )
393  {
394  return false;
395  }
396 
397  return true;
398  }
399 
401  {
402  global $ilSetting;
403 
404  return $ilSetting->get('char_selector_availability') > 0;
405  }
406 
407 
408  private function buildForm()
409  {
410  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
411  $form = new ilPropertyFormGUI();
412  $form->setFormAction($this->ctrl->getFormAction($this));
413  $form->addCommandButton(self::CMD_SAVE_FORM, $this->lng->txt("save"));
414  $form->setTableWidth("100%");
415  $form->setId("test_properties");
416 
417  $this->addGeneralProperties($form);
418  $this->addAvailabilityProperties($form);
419  $this->addTestIntroProperties($form);
420  $this->addTestAccessProperties($form);
421  $this->addTestRunProperties($form);
422  $this->addQuestionBehaviourProperties($form);
423  $this->addTestSequenceProperties($form);
424  $this->addTestFinishProperties($form);
425 
426  // Edit ecs export settings
427  include_once 'Modules/Test/classes/class.ilECSTestSettings.php';
428  $ecs = new ilECSTestSettings($this->testOBJ);
429  $ecs->addSettingsToForm($form, 'tst');
430 
431  // skill service activation for FIXED tests only
433  {
434  $otherHead = new ilFormSectionHeaderGUI();
435  $otherHead->setTitle($this->lng->txt('other'));
436  $form->addItem($otherHead);
437 
438  $skillService = new ilCheckboxInputGUI($this->lng->txt('tst_activate_skill_service'), 'skill_service');
439  $skillService->setInfo($this->lng->txt('tst_activate_skill_service_desc'));
440  $skillService->setChecked($this->testOBJ->isSkillServiceEnabled());
441  if($this->testOBJ->participantDataExist()) $skillService->setDisabled(true);
442  $form->addItem($skillService);
443  }
444 
445  // remove items when using template
446  $this->removeHiddenItems($form);
447 
448  return $form;
449  }
450 
451  private function performSaveForm(ilPropertyFormGUI $form)
452  {
453  $this->saveGeneralProperties($form);
454  $this->saveAvailabilityProperties($form);
455  $this->saveTestIntroProperties($form);
456  $this->saveTestAccessProperties($form);
457  $this->saveTestRunProperties($form);
458  $this->saveQuestionBehaviourProperties($form);
459  $this->saveTestSequenceSettings($form);
460  $this->saveTestFinishProperties($form);
461 
462  if( !$this->testOBJ->participantDataExist() )
463  {
464  // skill service
465  if( ilObjTest::isSkillManagementGloballyActivated() && $form->getItemByPostVar('skill_service') instanceof ilFormPropertyGUI )
466  {
467  $this->testOBJ->setSkillServiceEnabled($form->getItemByPostVar('skill_service')->getChecked());
468  }
469  }
470 
471  // store settings to db
472  $this->testOBJ->saveToDb(true);
473 
474  // Update ecs export settings
475  include_once 'Modules/Test/classes/class.ilECSTestSettings.php';
476  $ecs = new ilECSTestSettings($this->testOBJ);
477  $ecs->handleSettingsUpdate();
478  }
479 
483  private function addGeneralProperties(ilPropertyFormGUI $form)
484  {
486  $header->setTitle($this->lng->txt("tst_general_properties"));
487  $form->addItem($header);
488 
489  // title & description (meta data)
490 
491  include_once 'Services/MetaData/classes/class.ilMD.php';
492  $md_obj = new ilMD($this->testOBJ->getId(), 0, "tst");
493  $md_section = $md_obj->getGeneral();
494 
495  $title = new ilTextInputGUI($this->lng->txt("title"), "title");
496  $title->setRequired(true);
497  $title->setValue($md_section->getTitle());
498  $form->addItem($title);
499 
500  $ids = $md_section->getDescriptionIds();
501  if ($ids) {
502  $desc_obj = $md_section->getDescription(array_pop($ids));
503 
504  $desc = new ilTextAreaInputGUI($this->lng->txt("description"), "description");
505  $desc->setCols(50);
506  $desc->setRows(4);
507  $desc->setValue($desc_obj->getDescription());
508  $form->addItem($desc);
509  }
510 
511  // pool usage
512  $pool_usage = new ilRadioGroupInputGUI($this->lng->txt('test_question_pool_usage'), 'use_pool');
513 
514  $optional_qpl = new ilRadioOption($this->lng->txt('test_question_pool_usage_optional'), 1);
515  $optional_qpl->setInfo($this->lng->txt('test_question_pool_usage_optional_info'));
516  $pool_usage->addOption($optional_qpl);
517 
518  $tst_directly = new ilRadioOption($this->lng->txt('test_question_pool_usage_tst_directly'), 0);
519  $tst_directly->setInfo($this->lng->txt('test_question_pool_usage_tst_directly_info'));
520  $pool_usage->addOption($tst_directly);
521 
522  $pool_usage->setValue($this->testOBJ->getPoolUsage() ? 1 : 0);
523  $form->addItem($pool_usage);
524 
525  // test mode (question set type)
526  $questSetType = new ilRadioGroupInputGUI($this->lng->txt("tst_question_set_type"), 'question_set_type');
527  $questSetTypeFixed = new ilRadioOption(
528  $this->lng->txt("tst_question_set_type_fixed"), ilObjTest::QUESTION_SET_TYPE_FIXED,
529  $this->lng->txt("tst_question_set_type_fixed_desc")
530  );
531  $questSetType->addOption($questSetTypeFixed);
532  $questSetTypeRandom = new ilRadioOption(
533  $this->lng->txt("tst_question_set_type_random"), ilObjTest::QUESTION_SET_TYPE_RANDOM,
534  $this->lng->txt("tst_question_set_type_random_desc")
535  );
536  $questSetType->addOption($questSetTypeRandom);
537  $questSetTypeContinues = new ilRadioOption(
538  $this->lng->txt("tst_question_set_type_dynamic"), ilObjTest::QUESTION_SET_TYPE_DYNAMIC,
539  $this->lng->txt("tst_question_set_type_dynamic_desc")
540  );
541  $questSetType->addOption($questSetTypeContinues);
542  $questSetType->setValue($this->testOBJ->getQuestionSetType());
543  if ($this->testOBJ->participantDataExist()) {
544  $questSetType->setDisabled(true);
545  }
546  $form->addItem($questSetType);
547 
548  // anonymity
549  $anonymity = new ilRadioGroupInputGUI($this->lng->txt('tst_anonymity'), 'anonymity');
550  if ($this->testOBJ->participantDataExist()) $anonymity->setDisabled(true);
551  $rb = new ilRadioOption($this->lng->txt('tst_anonymity_no_anonymization'), 0);
552  $anonymity->addOption($rb);
553  $rb = new ilRadioOption($this->lng->txt('tst_anonymity_anonymous_test'), 1);
554  $anonymity->addOption($rb);
555  $anonymity->setValue((int)$this->testOBJ->getAnonymity());
556  $form->addItem($anonymity);
557  }
558 
562  private function saveGeneralProperties(ilPropertyFormGUI $form)
563  {
564  include_once 'Services/MetaData/classes/class.ilMD.php';
565  $md_obj =& new ilMD($this->testOBJ->getId(), 0, "tst");
566  $md_section = $md_obj->getGeneral();
567 
568  // title
569  $md_section->setTitle(ilUtil::stripSlashes($form->getItemByPostVar('title')->getValue()));
570  $md_section->update();
571 
572  // Description
573  $md_desc_ids = $md_section->getDescriptionIds();
574  if ($md_desc_ids)
575  {
576  $md_desc = $md_section->getDescription(array_pop($md_desc_ids));
577  $md_desc->setDescription(ilUtil::stripSlashes($form->getItemByPostVar('description')->getValue()));
578  $md_desc->update();
579  }
580  else
581  {
582  $md_desc = $md_section->addDescription();
583  $md_desc->setDescription(ilUtil::stripSlashes($form->getItemByPostVar('description')->getValue()));
584  $md_desc->save();
585  }
586 
587  $this->testOBJ->setTitle(ilUtil::stripSlashes($form->getItemByPostVar('title')->getValue()));
588  $this->testOBJ->setDescription(ilUtil::stripSlashes($form->getItemByPostVar('description')->getValue()));
589  $this->testOBJ->update();
590 
591  // pool usage setting
592  if ($form->getItemByPostVar('use_pool') instanceof ilFormPropertyGUI)
593  {
594  $this->testOBJ->setPoolUsage((int)$form->getItemByPostVar('use_pool')->getValue());
595  }
596 
597  if (!$this->testOBJ->participantDataExist())
598  {
599  // question set type
600  if ($form->getItemByPostVar('question_set_type') instanceof ilFormPropertyGUI)
601  {
602  $this->testOBJ->setQuestionSetType($form->getItemByPostVar('question_set_type')->getValue());
603  }
604  }
605 
606  // anonymity setting
607  if( !$this->testOBJ->participantDataExist() && $this->formPropertyExists($form, 'anonymity') )
608  {
609  $this->testOBJ->setAnonymity($form->getItemByPostVar('anonymity')->getValue());
610  }
611  }
612 
617  {
618  include_once "Services/Object/classes/class.ilObjectActivation.php";
619  $this->lng->loadLanguageModule('rep');
620 
622  $section->setTitle($this->lng->txt('rep_activation_availability'));
623  $form->addItem($section);
624 
625  // additional info only with multiple references
626  $act_obj_info = $act_ref_info = "";
627  if (sizeof(ilObject::_getAllReferences($this->testOBJ->getId())) > 1) {
628  $act_obj_info = ' ' . $this->lng->txt('rep_activation_online_object_info');
629  $act_ref_info = $this->lng->txt('rep_activation_access_ref_info');
630  }
631 
632  $online = new ilCheckboxInputGUI($this->lng->txt('rep_activation_online'), 'online');
633  $online->setChecked($this->testOBJ->isOnline());
634  $online->setInfo($this->lng->txt('tst_activation_online_info') . $act_obj_info);
635  $form->addItem($online);
636 
637  $act_type = new ilCheckboxInputGUI($this->lng->txt('rep_visibility_until'), 'activation_type');
638  $act_type->setChecked($this->testOBJ->isActivationLimited());
639  // $act_type->setInfo($this->lng->txt('tst_availability_until_info'));
640 
641  $this->tpl->addJavaScript('./Services/Form/js/date_duration.js');
642  include_once "Services/Form/classes/class.ilDateDurationInputGUI.php";
643  $dur = new ilDateDurationInputGUI($this->lng->txt("rep_time_period"), "access_period");
644  $dur->setShowTime(true);
645  $date = $this->testOBJ->getActivationStartingTime();
646  $dur->setStart(new ilDateTime($date ? $date : time(), IL_CAL_UNIX));
647  $dur->setStartText($this->lng->txt('rep_activation_limited_start'));
648  $date = $this->testOBJ->getActivationEndingTime();
649  $dur->setEnd(new ilDateTime($date ? $date : time(), IL_CAL_UNIX));
650  $dur->setEndText($this->lng->txt('rep_activation_limited_end'));
651  $act_type->addSubItem($dur);
652 
653  $visible = new ilCheckboxInputGUI($this->lng->txt('rep_activation_limited_visibility'), 'activation_visibility');
654  $visible->setInfo($this->lng->txt('tst_activation_limited_visibility_info'));
655  $visible->setChecked($this->testOBJ->getActivationVisibility());
656  $act_type->addSubItem($visible);
657 
658  $form->addItem($act_type);
659  }
660 
665  {
666  // online status
667  $this->testOBJ->setOnline($form->getItemByPostVar('online')->getChecked());
668 
669  // activation
670  if ($form->getItemByPostVar('activation_type')->getChecked())
671  {
672  $this->testOBJ->setActivationLimited(true);
673  $this->testOBJ->setActivationVisibility($form->getItemByPostVar('activation_visibility')->getChecked());
674 
675  $period = $form->getItemByPostVar("access_period");
676  $this->testOBJ->setActivationStartingTime($period->getStart()->get(IL_CAL_UNIX));
677  $this->testOBJ->setActivationEndingTime($period->getEnd()->get(IL_CAL_UNIX));
678  }
679  else
680  {
681  $this->testOBJ->setActivationLimited(false);
682  }
683  }
684 
689  {
691  $section->setTitle($this->lng->txt('tst_settings_header_intro'));
692  $form->addItem($section);
693 
694  // introduction
695  $introEnabled = new ilCheckboxInputGUI($this->lng->txt("tst_introduction"), 'intro_enabled');
696  $introEnabled->setChecked($this->testOBJ->isIntroductionEnabled());
697  $introEnabled->setInfo($this->lng->txt('tst_introduction_desc'));
698  $form->addItem($introEnabled);
699  $intro = new ilTextAreaInputGUI($this->lng->txt("tst_introduction_text"), "introduction");
700  $intro->setRequired(true);
701  $intro->setValue($this->testOBJ->prepareTextareaOutput($this->testOBJ->getIntroduction(), false, true));
702  $intro->setRows(10);
703  $intro->setCols(80);
704  $intro->setUseRte(TRUE);
705  $intro->addPlugin("latex");
706  $intro->addButton("latex");
707  $intro->setRTESupport($this->testOBJ->getId(), "tst", "assessment");
708  $intro->setRteTagSet('full');
709  $introEnabled->addSubItem($intro);
710 
711  // showinfo
712  $showinfo = new ilCheckboxInputGUI($this->lng->txt("showinfo"), "showinfo");
713  $showinfo->setValue(1);
714  $showinfo->setChecked($this->testOBJ->getShowInfo());
715  $showinfo->setInfo($this->lng->txt("showinfo_desc"));
716  $form->addItem($showinfo);
717  }
718 
723  {
724  if ($form->getItemByPostVar('intro_enabled') instanceof ilFormPropertyGUI)
725  {
726  $this->testOBJ->setIntroductionEnabled($form->getItemByPostVar('intro_enabled')->getChecked());
727 
728  if ($form->getItemByPostVar('intro_enabled')->getChecked())
729  {
730  $this->testOBJ->setIntroduction($form->getItemByPostVar('introduction')->getValue(), false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment"));
731  }
732  else
733  {
734  $this->testOBJ->setIntroduction('');
735  }
736  }
737 
738  if ($form->getItemByPostVar('showinfo') instanceof ilFormPropertyGUI)
739  {
740  $this->testOBJ->setShowInfo($form->getItemByPostVar('showinfo')->getChecked());
741  }
742  }
743 
748  {
750  $header->setTitle($this->lng->txt("tst_settings_header_execution"));
751  $form->addItem($header);
752 
753  // enable starting time
754  $enablestartingtime = new ilCheckboxInputGUI($this->lng->txt("tst_starting_time"), "chb_starting_time");
755  $enablestartingtime->setInfo($this->lng->txt("tst_starting_time_desc"));
756  $enablestartingtime->setChecked($this->testOBJ->isStartingTimeEnabled());
757 
758  // starting time
759  $startingtime = new ilDateTimeInputGUI('', 'starting_time');
760  $startingtime->setShowTime(true);
761  if( strlen($this->testOBJ->getStartingTime()) )
762  {
763  $startingtime->setDate(new ilDateTime($this->testOBJ->getStartingTime(), IL_CAL_TIMESTAMP));
764  }
765  else
766  {
767  $startingtime->setDate(new ilDateTime(time(), IL_CAL_UNIX));
768  }
769  $enablestartingtime->addSubItem($startingtime);
770  $form->addItem($enablestartingtime);
771  if ($this->testOBJ->participantDataExist())
772  {
773  $enablestartingtime->setDisabled(true);
774  $startingtime->setDisabled(true);
775  }
776 
777  // enable ending time
778  $enableendingtime = new ilCheckboxInputGUI($this->lng->txt("tst_ending_time"), "chb_ending_time");
779  $enableendingtime->setInfo($this->lng->txt("tst_ending_time_desc"));
780  $enableendingtime->setChecked($this->testOBJ->isEndingTimeEnabled());
781 
782  // ending time
783  $endingtime = new ilDateTimeInputGUI('', 'ending_time');
784  $endingtime->setShowTime(true);
785  if (strlen($this->testOBJ->getEndingTime()))
786  {
787  $endingtime->setDate(new ilDateTime($this->testOBJ->getEndingTime(), IL_CAL_TIMESTAMP));
788  }
789  else
790  {
791  $endingtime->setDate(new ilDateTime(time(), IL_CAL_UNIX));
792  }
793  $enableendingtime->addSubItem($endingtime);
794  $form->addItem($enableendingtime);
795 
796  // test password
797  $pwEnabled = new ilCheckboxInputGUI($this->lng->txt('tst_password'), 'password_enabled');
798  $pwEnabled->setChecked($this->testOBJ->isPasswordEnabled());
799  $pwEnabled->setInfo($this->lng->txt("tst_password_details"));
800  $password = new ilTextInputGUI($this->lng->txt("tst_password_enter"), "password");
801  $password->setRequired(true);
802  $password->setSize(20);
803  $password->setMaxLength(20);
804  $password->setValue($this->testOBJ->getPassword());
805  $pwEnabled->addSubItem($password);
806  $form->addItem($pwEnabled);
807 
808  // fixed participants
809  $fixedparticipants = new ilCheckboxInputGUI($this->lng->txt('participants_invitation'), "fixedparticipants");
810  $fixedparticipants->setValue(1);
811  $fixedparticipants->setChecked($this->testOBJ->getFixedParticipants());
812  $fixedparticipants->setInfo($this->lng->txt("participants_invitation_description"));
813  if ($this->testOBJ->participantDataExist())
814  {
815  $fixedparticipants->setDisabled(true);
816  }
817  $form->addItem($fixedparticipants);
818 
819  // simultaneous users
820  $simulLimited = new ilCheckboxInputGUI($this->lng->txt("tst_allowed_users"), 'limitUsers');
821  $simulLimited->setInfo($this->lng->txt("tst_allowed_users_desc"));
822  $simulLimited->setChecked($this->testOBJ->isLimitUsersEnabled());
823 
824  // allowed simultaneous users
825  $simul = new ilNumberInputGUI($this->lng->txt("tst_allowed_users_max"), "allowedUsers");
826  $simul->setRequired(true);
827  $simul->allowDecimals(false);
828  $simul->setMinValue(1);
829  $simul->setMinvalueShouldBeGreater(false);
830  $simul->setSize(4);
831  $simul->setValue(($this->testOBJ->getAllowedUsers()) ? $this->testOBJ->getAllowedUsers() : '');
832  $simulLimited->addSubItem($simul);
833 
834  // idle time
835  $idle = new ilNumberInputGUI($this->lng->txt("tst_allowed_users_time_gap"), "allowedUsersTimeGap");
836  $idle->setInfo($this->lng->txt("tst_allowed_users_time_gap_desc"));
837  $idle->setSize(4);
838  $idle->setSuffix($this->lng->txt("seconds"));
839  $idle->setValue(($this->testOBJ->getAllowedUsersTimeGap()) ? $this->testOBJ->getAllowedUsersTimeGap() : 300);
840  $simulLimited->addSubItem($idle);
841 
842  $form->addItem($simulLimited);
843  return $header;
844  }
845 
850  {
851  // starting time
852  if( $this->formPropertyExists($form, 'chb_starting_time') && !$this->testOBJ->participantDataExist() )
853  {
854  if( $form->getItemByPostVar('chb_starting_time')->getChecked() )
855  {
856  $this->testOBJ->setStartingTime(ilFormat::dateDB2timestamp(
857  $form->getItemByPostVar('starting_time')->getDate()->get(IL_CAL_DATETIME)
858  ));
859 
860  $this->testOBJ->setStartingTimeEnabled(true);
861  }
862  else
863  {
864  $this->testOBJ->setStartingTimeEnabled(false);
865  }
866  }
867 
868  // ending time
869  if( $this->formPropertyExists($form, 'chb_ending_time') )
870  {
871  if( $form->getItemByPostVar('chb_ending_time')->getChecked() )
872  {
873  $this->testOBJ->setEndingTime(ilFormat::dateDB2timestamp(
874  $form->getItemByPostVar('ending_time')->getDate()->get(IL_CAL_DATETIME)
875  ));
876 
877  $this->testOBJ->setEndingTimeEnabled(true);
878  }
879  else
880  {
881  $this->testOBJ->setEndingTimeEnabled(false);
882  }
883  }
884 
885  if( $this->formPropertyExists($form, 'password_enabled') )
886  {
887  $this->testOBJ->setPasswordEnabled($form->getItemByPostVar('password_enabled')->getChecked());
888 
889  if( $form->getItemByPostVar('password_enabled')->getChecked() )
890  {
891  $this->testOBJ->setPassword($form->getItemByPostVar('password')->getValue());
892  }
893  else
894  {
895  $this->testOBJ->setPassword(''); // otherwise test will still respect value
896  }
897  }
898 
899  if( $this->formPropertyExists($form, 'fixedparticipants') && !$this->testOBJ->participantDataExist() )
900  {
901  $this->testOBJ->setFixedParticipants($form->getItemByPostVar('fixedparticipants')->getChecked());
902  }
903 
904  if( $this->formPropertyExists($form, 'limitUsers') )
905  {
906  $this->testOBJ->setLimitUsersEnabled($form->getItemByPostVar('limitUsers')->getChecked());
907 
908  if( $form->getItemByPostVar('limitUsers')->getChecked() )
909  {
910  $this->testOBJ->setAllowedUsers($form->getItemByPostVar('allowedUsers')->getValue());
911  $this->testOBJ->setAllowedUsersTimeGap($form->getItemByPostVar('allowedUsersTimeGap')->getValue());
912  }
913  else
914  {
915  $this->testOBJ->setAllowedUsers(''); // otherwise test will still respect value
916  }
917  }
918  }
919 
923  private function addTestRunProperties(ilPropertyFormGUI $form)
924  {
925  // section header test run
927  $header->setTitle($this->lng->txt("tst_settings_header_test_run"));
928  $form->addItem($header);
929 
930  // max. number of passes
931  $limitPasses = new ilCheckboxInputGUI($this->lng->txt("tst_limit_nr_of_tries"), 'limitPasses');
932  $limitPasses->setInfo($this->lng->txt("tst_nr_of_tries_desc"));
933  $limitPasses->setChecked($this->testOBJ->getNrOfTries() > 0);
934  $nr_of_tries = new ilNumberInputGUI($this->lng->txt("tst_nr_of_tries"), "nr_of_tries");
935  $nr_of_tries->setSize(3);
936  $nr_of_tries->allowDecimals(false);
937  $nr_of_tries->setMinValue(1);
938  $nr_of_tries->setMinvalueShouldBeGreater(false);
939  $nr_of_tries->setValue($this->testOBJ->getNrOfTries() ? $this->testOBJ->getNrOfTries() : 1);
940  $nr_of_tries->setRequired(true);
941  if( $this->testOBJ->participantDataExist() )
942  {
943  $limitPasses->setDisabled(true);
944  $nr_of_tries->setDisabled(true);
945  }
946  $limitPasses->addSubItem($nr_of_tries);
947  $form->addItem($limitPasses);
948 
949  // enable max. processing time
950  $processing = new ilCheckboxInputGUI($this->lng->txt("tst_processing_time"), "chb_processing_time");
951  $processing->setInfo($this->lng->txt("tst_processing_time_desc"));
952  $processing->setValue(1);
953 
954  if ($this->settingsTemplate && $this->getTemplateSettingValue('chb_processing_time')) {
955  $processing->setChecked(true);
956  } else {
957  $processing->setChecked($this->testOBJ->getEnableProcessingTime());
958  }
959 
960  // max. processing time
961  $processingtime = new ilNumberInputGUI($this->lng->txt("tst_processing_time_duration"), 'processing_time');
962  $processingtime->allowDecimals(false);
963  $processingtime->setMinValue(1);
964  $processingtime->setMinvalueShouldBeGreater(false);
965  $processingtime->setValue($this->testOBJ->getProcessingTimeAsMinutes());
966  $processingtime->setSize(5);
967  $processingtime->setSuffix($this->lng->txt('minutes'));
968  $processingtime->setInfo($this->lng->txt("tst_processing_time_duration_desc"));
969  $processing->addSubItem($processingtime);
970 
971  // reset max. processing time
972  $resetprocessing = new ilCheckboxInputGUI('', "chb_reset_processing_time");
973  $resetprocessing->setValue(1);
974  $resetprocessing->setOptionTitle($this->lng->txt("tst_reset_processing_time"));
975  $resetprocessing->setChecked($this->testOBJ->getResetProcessingTime());
976  $resetprocessing->setInfo($this->lng->txt("tst_reset_processing_time_desc"));
977  $processing->addSubItem($resetprocessing);
978  $form->addItem($processing);
979 
980  if( $this->testOBJ->participantDataExist() )
981  {
982  $processing->setDisabled(true);
983  $processingtime->setDisabled(true);
984  $resetprocessing->setDisabled(true);
985  }
986 
987  // kiosk mode
988  $kiosk = new ilCheckboxInputGUI($this->lng->txt("kiosk"), "kiosk");
989  $kiosk->setValue(1);
990  $kiosk->setChecked($this->testOBJ->getKioskMode());
991  $kiosk->setInfo($this->lng->txt("kiosk_description"));
992 
993  // kiosk mode options
994  $kiosktitle = new ilCheckboxGroupInputGUI($this->lng->txt("kiosk_options"), "kiosk_options");
995  $kiosktitle->addOption(new ilCheckboxOption($this->lng->txt("kiosk_show_title"), 'kiosk_title', ''));
996  $kiosktitle->addOption(new ilCheckboxOption($this->lng->txt("kiosk_show_participant"), 'kiosk_participant', ''));
997  $values = array();
998  if ($this->testOBJ->getShowKioskModeTitle()) array_push($values, 'kiosk_title');
999  if ($this->testOBJ->getShowKioskModeParticipant()) array_push($values, 'kiosk_participant');
1000  $kiosktitle->setValue($values);
1001  $kiosktitle->setInfo($this->lng->txt("kiosk_options_desc"));
1002  $kiosk->addSubItem($kiosktitle);
1003 
1004  $form->addItem($kiosk);
1005 
1006  $examIdInPass = new ilCheckboxInputGUI($this->lng->txt('examid_in_test_pass'), 'examid_in_test_pass');
1007  $examIdInPass->setInfo($this->lng->txt('examid_in_test_pass_desc'));
1008  $examIdInPass->setChecked($this->testOBJ->isShowExamIdInTestPassEnabled());
1009  $form->addItem($examIdInPass);
1010  }
1011 
1016  {
1017  if (!$this->testOBJ->participantDataExist())
1018  {
1019  // nr of tries (max passes)
1020  if ($form->getItemByPostVar('limitPasses') instanceof ilFormPropertyGUI)
1021  {
1022  if ($form->getItemByPostVar('limitPasses')->getChecked())
1023  {
1024  $this->testOBJ->setNrOfTries($form->getItemByPostVar('nr_of_tries')->getValue());
1025  }
1026  else
1027  {
1028  $this->testOBJ->setNrOfTries(0);
1029  }
1030  }
1031 
1032  $this->testOBJ->setEnableProcessingTime($form->getItemByPostVar('chb_processing_time')->getChecked());
1033  if ($this->testOBJ->getEnableProcessingTime())
1034  {
1035  $this->testOBJ->setProcessingTimeByMinutes($form->getItemByPostVar('processing_time')->getValue());
1036  $this->testOBJ->setResetProcessingTime($form->getItemByPostVar('chb_reset_processing_time')->getChecked());
1037  }
1038  else
1039  {
1040  $this->testOBJ->setProcessingTime('');
1041  $this->testOBJ->setResetProcessingTime(false);
1042  }
1043  }
1044 
1045  if ($form->getItemByPostVar('kiosk') instanceof ilFormPropertyGUI)
1046  {
1047  $this->testOBJ->setKioskMode($form->getInput('kiosk'));
1048  $kioskOptions = $form->getItemByPostVar('kiosk_options')->getValue();
1049  if (is_array($kioskOptions))
1050  {
1051  $this->testOBJ->setShowKioskModeTitle(in_array('kiosk_title', $kioskOptions));
1052  $this->testOBJ->setShowKioskModeParticipant(in_array('kiosk_participant', $kioskOptions));
1053  }
1054  else
1055  {
1056  $this->testOBJ->setShowKioskModeTitle(false);
1057  $this->testOBJ->setShowKioskModeParticipant(false);
1058  }
1059  }
1060 
1061  if ($form->getItemByPostVar('examid_in_test_pass') instanceof ilFormPropertyGUI)
1062  {
1063  $value = $form->getItemByPostVar('examid_in_test_pass')->getChecked();
1064  $this->testOBJ->setShowExamIdInTestPassEnabled($value);
1065  }
1066  }
1067 
1072  {
1073  $fields = array(
1074  'title_output', 'autosave', 'chb_shuffle_questions', 'chb_shuffle_questions',
1075  'offer_hints', 'instant_feedback', 'obligations_enabled',
1076  );
1077 
1078  if( $this->isSectionHeaderRequired($fields) || $this->isCharSelectorPropertyRequired() )
1079  {
1080  // sequence properties
1081  $seqheader = new ilFormSectionHeaderGUI();
1082  $seqheader->setTitle($this->lng->txt("tst_presentation_properties"));
1083  $form->addItem($seqheader);
1084  }
1085 
1086  // question title output
1087  $title_output = new ilRadioGroupInputGUI($this->lng->txt("tst_title_output"), "title_output");
1088  $title_output->addOption(new ilRadioOption($this->lng->txt("tst_title_output_full"), 0, ''));
1089  $title_output->addOption(new ilRadioOption($this->lng->txt("tst_title_output_hide_points"), 1, ''));
1090  $title_output->addOption(new ilRadioOption($this->lng->txt("tst_title_output_no_title"), 2, ''));
1091  $title_output->setValue($this->testOBJ->getTitleOutput());
1092  $form->addItem($title_output);
1093 
1094  // Autosave
1095  $autosave_output = new ilCheckboxInputGUI($this->lng->txt('autosave'), 'autosave');
1096  $autosave_output->setValue(1);
1097  $autosave_output->setChecked($this->testOBJ->getAutosave());
1098  $autosave_output->setInfo($this->lng->txt('autosave_info'));
1099  $autosave_interval = new ilTextInputGUI($this->lng->txt('autosave_ival'), 'autosave_ival');
1100  $autosave_interval->setSize(10);
1101  $autosave_interval->setValue($this->testOBJ->getAutosaveIval()/1000);
1102  $autosave_interval->setSuffix($this->lng->txt('seconds'));
1103  $autosave_output->addSubItem($autosave_interval);
1104  $form->addItem($autosave_output);
1105 
1106  // shuffle questions
1107  $shuffle = new ilCheckboxInputGUI($this->lng->txt("tst_shuffle_questions"), "chb_shuffle_questions");
1108  $shuffle->setValue(1);
1109  $shuffle->setChecked($this->testOBJ->getShuffleQuestions());
1110  $shuffle->setInfo($this->lng->txt("tst_shuffle_questions_description"));
1111  $form->addItem($shuffle);
1112 
1113  // offer hints
1114  $checkBoxOfferHints = new ilCheckboxInputGUI($this->lng->txt('tst_setting_offer_hints_label'), 'offer_hints');
1115  $checkBoxOfferHints->setChecked($this->testOBJ->isOfferingQuestionHintsEnabled());
1116  $checkBoxOfferHints->setInfo($this->lng->txt('tst_setting_offer_hints_info'));
1117  if( $this->testOBJ->participantDataExist() )
1118  {
1119  $checkBoxOfferHints->setDisabled(true);
1120  }
1121  $form->addItem($checkBoxOfferHints);
1122 
1123  // instant feedback
1124  $instant_feedback = new ilCheckboxGroupInputGUI($this->lng->txt('tst_instant_feedback'), 'instant_feedback');
1125  $instant_feedback->addOption(new ilCheckboxOption(
1126  $this->lng->txt('tst_instant_feedback_results'), 'instant_feedback_points',
1127  $this->lng->txt('tst_instant_feedback_results_desc')
1128  ));
1129  $instant_feedback->addOption(new ilCheckboxOption(
1130  $this->lng->txt('tst_instant_feedback_answer_generic'), 'instant_feedback_generic',
1131  $this->lng->txt('tst_instant_feedback_answer_generic_desc')
1132  ));
1133  $instant_feedback->addOption(new ilCheckboxOption(
1134  $this->lng->txt('tst_instant_feedback_answer_specific'), 'instant_feedback_specific',
1135  $this->lng->txt('tst_instant_feedback_answer_specific_desc')
1136  ));
1137  $instant_feedback->addOption(new ilCheckboxOption(
1138  $this->lng->txt('tst_instant_feedback_solution'), 'instant_feedback_solution',
1139  $this->lng->txt('tst_instant_feedback_solution_desc')
1140  ));
1141  $values = array();
1142  if ($this->testOBJ->getSpecificAnswerFeedback()) array_push($values, 'instant_feedback_specific');
1143  if ($this->testOBJ->getGenericAnswerFeedback()) array_push($values, 'instant_feedback_generic');
1144  if ($this->testOBJ->getAnswerFeedbackPoints()) array_push($values, 'instant_feedback_points');
1145  if ($this->testOBJ->getInstantFeedbackSolution()) array_push($values, 'instant_feedback_solution');
1146  $instant_feedback->setValue($values);
1147  $form->addItem($instant_feedback);
1148 
1149  $radioGroup = new ilRadioGroupInputGUI(
1150  $this->lng->txt('tst_instant_feedback_handling'), 'instant_feedback_handling'
1151  );
1152  $radioOption = new ilRadioOption(
1153  $this->lng->txt('tst_instant_feedback_handling_none'),
1154  self::INST_FB_HANDLING_OPT_NONE
1155  );
1156  $radioOption->setInfo($this->lng->txt('tst_instant_feedback_handling_none_desc'));
1157  $radioGroup->addOption($radioOption);
1158  $radioOption = new ilRadioOption(
1159  $this->lng->txt('tst_instant_feedback_handling_freeze'),
1160  self::INST_FB_HANDLING_OPT_FREEZE
1161  );
1162  $radioOption->setInfo($this->lng->txt('tst_instant_feedback_handling_freeze_desc'));
1163  $radioGroup->addOption($radioOption);
1164  $radioOption = new ilRadioOption(
1165  $this->lng->txt('tst_instant_feedback_handling_force_and_freeze'),
1166  self::INST_FB_HANDLING_OPT_FORCE_AND_FREEZE
1167  );
1168  $radioOption->setInfo($this->lng->txt('tst_instant_feedback_handling_force_and_freeze_desc'));
1169  $radioGroup->addOption($radioOption);
1170  $radioOption = new ilRadioOption(
1171  $this->lng->txt('tst_instant_feedback_handling_force'),
1172  self::INST_FB_HANDLING_OPT_FORCE
1173  );
1174  $radioOption->setInfo($this->lng->txt('tst_instant_feedback_handling_force_desc'));
1175  $radioGroup->addOption($radioOption);
1176  $radioGroup->setValue($this->getInstFbHandlingValue(
1177  $this->testOBJ->isInstantFeedbackAnswerFixationEnabled(),
1178  $this->testOBJ->isForceInstantFeedbackEnabled()
1179  ));
1180  $form->addItem($radioGroup);
1181 
1182  // enable obligations
1183  $checkBoxEnableObligations = new ilCheckboxInputGUI($this->lng->txt('tst_setting_enable_obligations_label'), 'obligations_enabled');
1184  $checkBoxEnableObligations->setChecked($this->testOBJ->areObligationsEnabled());
1185  $checkBoxEnableObligations->setInfo($this->lng->txt('tst_setting_enable_obligations_info'));
1186  if( $this->testOBJ->participantDataExist() )
1187  {
1188  $checkBoxEnableObligations->setDisabled(true);
1189  }
1190  $form->addItem($checkBoxEnableObligations);
1191 
1192  // selector for unicode characters
1193  if( $this->isCharSelectorPropertyRequired() )
1194  {
1195  require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
1197  $char_selector->getConfig()->setAvailability($this->testOBJ->getCharSelectorAvailability());
1198  $char_selector->getConfig()->setDefinition($this->testOBJ->getCharSelectorDefinition());
1199  $char_selector->addFormProperties($form);
1200  $char_selector->setFormValues($form);
1201  }
1202  }
1203 
1208  {
1209  if ($form->getItemByPostVar('title_output') instanceof ilFormPropertyGUI)
1210  {
1211  $this->testOBJ->setTitleOutput($form->getItemByPostVar('title_output')->getValue());
1212  }
1213 
1214  if ($form->getItemByPostVar('autosave') instanceof ilFormPropertyGUI)
1215  {
1216  $this->testOBJ->setAutosave($form->getItemByPostVar('autosave')->getChecked());
1217  $this->testOBJ->setAutosaveIval($form->getItemByPostVar('autosave_ival')->getValue() * 1000);
1218  }
1219 
1220  if ($form->getItemByPostVar('chb_shuffle_questions') instanceof ilFormPropertyGUI)
1221  {
1222  $this->testOBJ->setShuffleQuestions($form->getItemByPostVar('chb_shuffle_questions')->getChecked());
1223  }
1224 
1225  if (!$this->testOBJ->participantDataExist() && $this->formPropertyExists($form, 'offer_hints'))
1226  {
1227  $this->testOBJ->setOfferingQuestionHintsEnabled($form->getItemByPostVar('offer_hints')->getChecked());
1228  }
1229 
1230  if ($this->formPropertyExists($form, 'instant_feedback'))
1231  {
1232  $this->testOBJ->setScoringFeedbackOptionsByArray($form->getItemByPostVar('instant_feedback')->getValue());
1233  }
1234 
1235  if ($this->formPropertyExists($form, 'instant_feedback_handling'))
1236  {
1237  $this->saveInstFbHandlingSettings($form->getItemByPostVar('instant_feedback_handling')->getValue());
1238  }
1239 
1240  if (!$this->testOBJ->participantDataExist() && $this->formPropertyExists($form, 'obligations_enabled'))
1241  {
1242  $this->testOBJ->setObligationsEnabled($form->getItemByPostVar('obligations_enabled')->getChecked());
1243  }
1244 
1245  if( $this->isCharSelectorPropertyRequired() )
1246  {
1247  require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
1249  $char_selector->addFormProperties($form);
1250  $char_selector->getFormValues($form);
1251  $this->testOBJ->setCharSelectorAvailability($char_selector->getConfig()->getAvailability());
1252  $this->testOBJ->setCharSelectorDefinition($char_selector->getConfig()->getDefinition());
1253  }
1254  }
1255 
1260  {
1261  // sequence properties
1262  $seqheader = new ilFormSectionHeaderGUI();
1263  $seqheader->setTitle($this->lng->txt("tst_sequence_properties"));
1264  $form->addItem($seqheader);
1265 
1266  // use previous answers
1267  $prevanswers = new ilCheckboxInputGUI($this->lng->txt("tst_use_previous_answers"), "chb_use_previous_answers");
1268  $prevanswers->setValue(1);
1269  $prevanswers->setChecked($this->testOBJ->getUsePreviousAnswers());
1270  $prevanswers->setInfo($this->lng->txt("tst_use_previous_answers_description"));
1271  $form->addItem($prevanswers);
1272 
1273  // show suspend test
1274  $cancel = new ilCheckboxInputGUI($this->lng->txt("tst_show_cancel"), "chb_show_cancel");
1275  $cancel->setValue(1);
1276  $cancel->setChecked($this->testOBJ->getShowCancel());
1277  $cancel->setInfo($this->lng->txt("tst_show_cancel_description"));
1278  $form->addItem($cancel);
1279 
1280  // postpone questions
1281  $postpone = new ilRadioGroupInputGUI($this->lng->txt("tst_postpone"), "postpone");
1282  $postpone->addOption(new ilRadioOption(
1283  $this->lng->txt("tst_postpone_off"), 0, $this->lng->txt("tst_postpone_off_desc")
1284  ));
1285  $postpone->addOption(new ilRadioOption(
1286  $this->lng->txt("tst_postpone_on"), 1, $this->lng->txt("tst_postpone_on_desc")
1287  ));
1288  $postpone->setValue((int)$this->testOBJ->getSequenceSettings());
1289  $form->addItem($postpone);
1290 
1291  // show list of questions
1292  $list_of_questions = new ilCheckboxInputGUI($this->lng->txt("tst_show_summary"), "list_of_questions");
1293  //$list_of_questions->setOptionTitle($this->lng->txt("tst_show_summary"));
1294  $list_of_questions->setValue(1);
1295  $list_of_questions->setChecked($this->testOBJ->getListOfQuestions());
1296  $list_of_questions->setInfo($this->lng->txt("tst_show_summary_description"));
1297 
1298  $list_of_questions_options = new ilCheckboxGroupInputGUI('', "list_of_questions_options");
1299  $list_of_questions_options->addOption(new ilCheckboxOption($this->lng->txt("tst_list_of_questions_start"), 'chb_list_of_questions_start', ''));
1300  $list_of_questions_options->addOption(new ilCheckboxOption($this->lng->txt("tst_list_of_questions_end"), 'chb_list_of_questions_end', ''));
1301  $list_of_questions_options->addOption(new ilCheckboxOption($this->lng->txt("tst_list_of_questions_with_description"), 'chb_list_of_questions_with_description', ''));
1302  $values = array();
1303  if ($this->testOBJ->getListOfQuestionsStart()) array_push($values, 'chb_list_of_questions_start');
1304  if ($this->testOBJ->getListOfQuestionsEnd()) array_push($values, 'chb_list_of_questions_end');
1305  if ($this->testOBJ->getListOfQuestionsDescription()) array_push($values, 'chb_list_of_questions_with_description');
1306  $list_of_questions_options->setValue($values);
1307 
1308  $list_of_questions->addSubItem($list_of_questions_options);
1309  $form->addItem($list_of_questions);
1310 
1311  // show question marking
1312  $marking = new ilCheckboxInputGUI($this->lng->txt("question_marking"), "chb_show_marker");
1313  $marking->setValue(1);
1314  $marking->setChecked($this->testOBJ->getShowMarker());
1315  $marking->setInfo($this->lng->txt("question_marking_description"));
1316  $form->addItem($marking);
1317  }
1318 
1323  {
1324  if( $this->formPropertyExists($form, 'chb_use_previous_answers') )
1325  {
1326  $this->testOBJ->setUsePreviousAnswers($form->getInput('chb_use_previous_answers'));
1327  }
1328 
1329  if( $this->formPropertyExists($form, 'chb_show_cancel') )
1330  {
1331  $this->testOBJ->setShowCancel($form->getItemByPostVar('chb_show_cancel')->getChecked());
1332  }
1333 
1334  if( $this->formPropertyExists($form, 'postpone') )
1335  {
1336  $this->testOBJ->setPostponingEnabled((bool)$form->getItemByPostVar('postpone')->getValue());
1337  }
1338 
1339  $this->testOBJ->setListOfQuestions($form->getItemByPostVar('list_of_questions')->getChecked());
1340  $listOfQuestionsOptions = $form->getItemByPostVar('list_of_questions_options')->getValue();
1341  if(is_array($listOfQuestionsOptions))
1342  {
1343  $this->testOBJ->setListOfQuestionsStart(in_array('chb_list_of_questions_start', $listOfQuestionsOptions));
1344  $this->testOBJ->setListOfQuestionsEnd(in_array('chb_list_of_questions_end', $listOfQuestionsOptions));
1345  $this->testOBJ->setListOfQuestionsDescription(in_array('chb_list_of_questions_with_description', $listOfQuestionsOptions));
1346  }
1347  else
1348  {
1349  $this->testOBJ->setListOfQuestionsStart(0);
1350  $this->testOBJ->setListOfQuestionsEnd(0);
1351  $this->testOBJ->setListOfQuestionsDescription(0);
1352  }
1353 
1354  if( $this->formPropertyExists($form, 'chb_show_marker') )
1355  {
1356  $this->testOBJ->setShowMarker($form->getItemByPostVar('chb_show_marker')->getChecked());
1357  }
1358  }
1359 
1364  {
1365  $testFinishHeader = new ilFormSectionHeaderGUI();
1366  $testFinishHeader->setTitle($this->lng->txt("tst_final_information"));
1367  $form->addItem($testFinishHeader);
1368 
1369  // examview
1370  $enable_examview = new ilCheckboxInputGUI($this->lng->txt("enable_examview"), 'enable_examview');
1371  $enable_examview->setValue(1);
1372  $enable_examview->setChecked($this->testOBJ->getEnableExamview());
1373  $enable_examview->setInfo($this->lng->txt("enable_examview_desc"));
1374  $show_examview_pdf = new ilCheckboxInputGUI('', 'show_examview_pdf');
1375  $show_examview_pdf->setValue(1);
1376  $show_examview_pdf->setChecked($this->testOBJ->getShowExamviewPdf());
1377  $show_examview_pdf->setOptionTitle($this->lng->txt("show_examview_pdf"));
1378  $enable_examview->addSubItem($show_examview_pdf);
1379  $form->addItem($enable_examview);
1380 
1381  // show final statement
1382  $showfinal = new ilCheckboxInputGUI($this->lng->txt("final_statement"), "showfinalstatement");
1383  $showfinal->setChecked($this->testOBJ->getShowFinalStatement());
1384  $showfinal->setInfo($this->lng->txt("final_statement_show_desc"));
1385  $form->addItem($showfinal);
1386  // final statement
1387  $finalstatement = new ilTextAreaInputGUI($this->lng->txt("final_statement"), "finalstatement");
1388  $finalstatement->setRequired(true);
1389  $finalstatement->setValue($this->testOBJ->prepareTextareaOutput($this->testOBJ->getFinalStatement(), false, true));
1390  $finalstatement->setRows(10);
1391  $finalstatement->setCols(80);
1392  $finalstatement->setUseRte(TRUE);
1393  $finalstatement->addPlugin("latex");
1394  $finalstatement->addButton("latex");
1395  $finalstatement->setRTESupport($this->testOBJ->getId(), "tst", "assessment");
1396  $finalstatement->setRteTagSet('full');
1397  $showfinal->addSubItem($finalstatement);
1398 
1399  $redirection_mode = $this->testOBJ->getRedirectionMode();
1400  $rm_enabled = new ilCheckboxInputGUI($this->lng->txt('redirect_after_finishing_tst'), 'redirection_enabled');
1401  $rm_enabled->setInfo($this->lng->txt('redirect_after_finishing_tst_desc'));
1402  $rm_enabled->setChecked($redirection_mode == '0' ? false : true);
1403  $radio_rm = new ilRadioGroupInputGUI($this->lng->txt('redirect_after_finishing_rule'), 'redirection_mode');
1404  $always = new ilRadioOption($this->lng->txt('redirect_always'), REDIRECT_ALWAYS);
1405  $radio_rm->addOption($always);
1406  $kiosk = new ilRadioOption($this->lng->txt('redirect_in_kiosk_mode'), REDIRECT_KIOSK);
1407  $radio_rm->addOption($kiosk);
1408  $radio_rm->setValue(in_array($redirection_mode, array(REDIRECT_ALWAYS, REDIRECT_KIOSK)) ? $redirection_mode : REDIRECT_ALWAYS);
1409  $rm_enabled->addSubItem($radio_rm);
1410  $redirection_url = new ilTextInputGUI($this->lng->txt('redirection_url'), 'redirection_url');
1411  $redirection_url->setValue((string)$this->testOBJ->getRedirectionUrl());
1412  $redirection_url->setRequired(true);
1413  $rm_enabled->addSubItem($redirection_url);
1414 
1415  $form->addItem($rm_enabled);
1416 
1417  // Sign submission
1418  $sign_submission = $this->testOBJ->getSignSubmission();
1419  $sign_submission_enabled = new ilCheckboxInputGUI($this->lng->txt('sign_submission'), 'sign_submission');
1420  $sign_submission_enabled->setChecked($sign_submission);
1421  $sign_submission_enabled->setInfo($this->lng->txt('sign_submission_info'));
1422  $form->addItem($sign_submission_enabled);
1423 
1424  // mail notification
1425  $mailnotification = new ilCheckboxInputGUI($this->lng->txt("tst_finish_notification"), "mailnotification");
1426  $mailnotification->setInfo($this->lng->txt("tst_finish_notification_desc"));
1427  $mailnotification->setChecked($this->testOBJ->getMailNotification() > 0);
1428  $form->addItem($mailnotification);
1429 
1430  $mailnotificationContent = new ilRadioGroupInputGUI($this->lng->txt("tst_finish_notification_content"), "mailnotification_content");
1431  $mailnotificationContent->addOption(new ilRadioOption($this->lng->txt("tst_finish_notification_simple"), 1, ''));
1432  $mailnotificationContent->addOption(new ilRadioOption($this->lng->txt("tst_finish_notification_advanced"), 2, ''));
1433  $mailnotificationContent->setValue($this->testOBJ->getMailNotification() ? $this->testOBJ->getMailNotification() : 1);
1434  $mailnotificationContent->setRequired(true);
1435  $mailnotification->addSubItem($mailnotificationContent);
1436 
1437  $mailnottype = new ilCheckboxInputGUI('', "mailnottype");
1438  $mailnottype->setValue(1);
1439  $mailnottype->setOptionTitle($this->lng->txt("mailnottype"));
1440  $mailnottype->setChecked($this->testOBJ->getMailNotificationType());
1441  $mailnotification->addSubItem($mailnottype);
1442  }
1443 
1448  {
1449  if( $this->formPropertyExists($form, 'enable_examview') )
1450  {
1451  $this->testOBJ->setEnableExamview($form->getItemByPostVar('enable_examview')->getChecked());
1452  $this->testOBJ->setShowExamviewPdf($form->getItemByPostVar('show_examview_pdf')->getChecked());
1453  }
1454 
1455  $this->testOBJ->setShowFinalStatement($form->getItemByPostVar('showfinalstatement')->getChecked());
1456  $this->testOBJ->setFinalStatement($form->getItemByPostVar('finalstatement')->getValue(), false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment"));
1457 
1458  if( $form->getItemByPostVar('redirection_enabled')->getChecked() )
1459  {
1460  $this->testOBJ->setRedirectionMode($form->getItemByPostVar('redirection_mode')->getValue());
1461  }
1462  else
1463  {
1464  $this->testOBJ->setRedirectionMode(REDIRECT_NONE);
1465  }
1466  if( strlen($form->getItemByPostVar('redirection_url')->getValue()) )
1467  {
1468  $this->testOBJ->setRedirectionUrl($form->getItemByPostVar('redirection_url')->getValue());
1469  }
1470  else
1471  {
1472  $this->testOBJ->setRedirectionUrl(null);
1473  }
1474 
1475  if( $this->formPropertyExists($form, 'sign_submission') )
1476  {
1477  $this->testOBJ->setSignSubmission($form->getItemByPostVar('sign_submission')->getChecked());
1478  }
1479 
1480  if( $this->formPropertyExists($form, 'mailnotification') && $form->getItemByPostVar('mailnotification')->getChecked() )
1481  {
1482  $this->testOBJ->setMailNotification($form->getItemByPostVar('mailnotification_content')->getValue());
1483  $this->testOBJ->setMailNotificationType($form->getItemByPostVar('mailnottype')->getChecked());
1484  }
1485  else
1486  {
1487  $this->testOBJ->setMailNotification(0);
1488  $this->testOBJ->setMailNotificationType(false);
1489  }
1490  }
1491 
1492  private function saveInstFbHandlingSettings($instantFeedbackHandlingValue)
1493  {
1494  switch($instantFeedbackHandlingValue)
1495  {
1496  case self::INST_FB_HANDLING_OPT_NONE:
1497  $this->testOBJ->setInstantFeedbackAnswerFixationEnabled(false);
1498  $this->testOBJ->setForceInstantFeedbackEnabled(false);
1499  break;
1500 
1501  case self::INST_FB_HANDLING_OPT_FREEZE:
1502  $this->testOBJ->setInstantFeedbackAnswerFixationEnabled(true);
1503  $this->testOBJ->setForceInstantFeedbackEnabled(false);
1504  break;
1505 
1506  case self::INST_FB_HANDLING_OPT_FORCE:
1507  $this->testOBJ->setInstantFeedbackAnswerFixationEnabled(false);
1508  $this->testOBJ->setForceInstantFeedbackEnabled(true);
1509  break;
1510 
1511  case self::INST_FB_HANDLING_OPT_FORCE_AND_FREEZE:
1512  $this->testOBJ->setInstantFeedbackAnswerFixationEnabled(true);
1513  $this->testOBJ->setForceInstantFeedbackEnabled(true);
1514  break;
1515  }
1516  }
1517 
1518  private function getInstFbHandlingValue($freezeAnswersEnabled, $forceInstFbEnabled)
1519  {
1520  switch( true )
1521  {
1522  case !$freezeAnswersEnabled && !$forceInstFbEnabled: return self::INST_FB_HANDLING_OPT_NONE;
1523  case $freezeAnswersEnabled && !$forceInstFbEnabled: return self::INST_FB_HANDLING_OPT_FREEZE;
1524  case !$freezeAnswersEnabled && $forceInstFbEnabled: return self::INST_FB_HANDLING_OPT_FORCE;
1525  case $freezeAnswersEnabled && $forceInstFbEnabled: return self::INST_FB_HANDLING_OPT_FORCE_AND_FREEZE;
1526  }
1527  }
1528 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
saveInstFbHandlingSettings($instantFeedbackHandlingValue)
This class represents an option in a radio group.
This class provides processing control methods.
getItemByPostVar($a_post_var)
Get Item by POST variable.
showResetTemplateConfirmationCmd()
Enable all settings - Confirmation.
const IL_CAL_DATETIME
This class represents an option in a checkbox group.
Class ilObjTestGUI.
This class represents a property form user interface.
const QUESTION_SET_TYPE_RANDOM
type setting value for random question set
& _getUsedHTMLTagsAsString($a_module="")
Returns a string of all allowed HTML tags for text editing.
This shows a character selector.
This class represents a section header in a property form.
$cmd
Definition: sahs_server.php:35
This class represents a checkbox property in a property form.
removeHiddenItems(ilPropertyFormGUI $form)
const REDIRECT_NONE
Redirect after finishing test constants.
addItem($a_item)
Add Item (Property, SectionHeader).
const IL_CAL_UNIX
setInfo($a_info)
Set Info.
dateDB2timestamp($ADatumSQL)
db-datetime to timestamp
static _getAllReferences($a_id)
get all reference ids of object
This class represents a date/time property in a property form.
allowDecimals($a_value)
Toggle Decimals.
setInfo($a_info)
Set Information Text.
Administration class for plugins.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$section
Definition: Utf8Test.php:84
const REDIRECT_ALWAYS
setChecked($a_checked)
Set Checked.
input GUI for a time span (start and end date)
addQuestionBehaviourProperties(ilPropertyFormGUI $form)
This class represents a property in a property form.
addOption($a_option)
Add Option.
setValue($a_value)
Set Value.
$header
__construct(ilCtrl $ctrl, ilAccessHandler $access, ilLanguage $lng, ilTemplate $tpl, ilTree $tree, ilDB $db, ilPluginAdmin $pluginAdmin, ilObjUser $activeUser, ilObjTestGUI $testGUI)
Constructor.
This class represents a number property in a property form.
setValue($a_value)
Set Value.
special template class to simplify handling of ITX/PEAR
Class ilECSTestSettings.
setSize($a_size)
Set Size.
This class represents a text property in a property form.
& getGeneral()
Definition: class.ilMD.php:55
Date and time handling
saveQuestionBehaviourProperties(ilPropertyFormGUI $form)
static isSkillManagementGloballyActivated()
This class represents a property in a property form.
setShowTime($a_showtime)
Set Show Time Information.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
const REDIRECT_KIOSK
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
setSize($a_size)
Set Size.
$errors
Database Wrapper.
Definition: class.ilDB.php:28
getTemplateSettingValue($settingName)
showConfirmation(ilPropertyFormGUI $form, $oldQuestionSetType, $newQuestionSetType, $hasQuestionsWithoutQuestionpool)
This class represents a property in a property form.
global $ilSetting
Definition: privfeed.php:40
This class represents a text area property in a property form.
isSkillServiceSettingToBeAdjusted(ilPropertyFormGUI $form)
const QUESTION_SET_TYPE_FIXED
type setting value for fixed question set
formPropertyExists(ilPropertyFormGUI $form, $propertyId)
language handling
const IL_CAL_TIMESTAMP
setValue($a_value)
Set Value.
const QUESTION_SET_TYPE_DYNAMIC
type setting value for dynamic question set (continues testing mode)
setDisabled($a_disabled)
Set Disabled.
getInstFbHandlingValue($freezeAnswersEnabled, $forceInstFbEnabled)
setRequired($a_required)
Set Required.
confirmedResetTemplateCmd()
Enable all settings - remove template.
Confirmation screen class.
Class ilAccessHandler.