ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 
32  protected $ctrl = null;
33 
35  protected $access = null;
36 
38  protected $lng = null;
39 
41  protected $tpl = null;
42 
44  protected $tree = null;
45 
47  protected $db = null;
48 
50  protected $pluginAdmin = null;
51 
53  protected $activeUser = null;
54 
56  protected $testGUI = null;
57 
60 
73  public function __construct(
74  ilCtrl $ctrl,
78  ilTree $tree,
79  ilDB $db,
83  )
84  {
85  $this->ctrl = $ctrl;
86  $this->access = $access;
87  $this->lng = $lng;
88  $this->tpl = $tpl;
89  $this->tree = $tree;
90  $this->db = $db;
91  $this->pluginAdmin = $pluginAdmin;
92  $this->activeUser = $activeUser;
93 
94  $this->testGUI = $testGUI;
95 
96  require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
97  $this->testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($this->tree, $this->db, $this->pluginAdmin, $testGUI->object);
98 
99  parent::__construct($testGUI->object);
100  }
101 
105  public function executeCommand()
106  {
107  // allow only write access
108 
109  if (!$this->access->checkAccess("write", "", $this->testGUI->ref_id))
110  {
111  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
112  $this->ctrl->redirect($this->testGUI, "infoScreen");
113  }
114 
115  // process command
116 
117  $nextClass = $this->ctrl->getNextClass();
118 
119  switch($nextClass)
120  {
121  default:
122  $cmd = $this->ctrl->getCmd(self::CMD_SHOW_FORM).'Cmd';
123  $this->$cmd();
124  }
125  }
126 
127  private function showFormCmd(ilPropertyFormGUI $form = null)
128  {
129  $this->tpl->addJavascript("./Services/JavaScript/js/Basic.js");
130 
131  if( $form === null )
132  {
133  $form = $this->buildForm();
134  }
135 
136  $formHTML = $this->ctrl->getHTML($form);
137  $msgHTML = $this->getSettingsTemplateMessageHTML();
138 
139  $this->tpl->setContent($formHTML.$msgHTML);
140  }
141 
142  private function showConfirmation(ilPropertyFormGUI $form, $oldQuestionSetType, $newQuestionSetType, $hasQuestionsWithoutQuestionpool)
143  {
144  require_once 'Modules/Test/classes/confirmations/class.ilTestSettingsChangeConfirmationGUI.php';
145  $confirmation = new ilTestSettingsChangeConfirmationGUI($this->lng, $this->testOBJ);
146 
147  $confirmation->setFormAction( $this->ctrl->getFormAction($this) );
148  $confirmation->setCancel($this->lng->txt('cancel'), self::CMD_SHOW_FORM);
149  $confirmation->setConfirm($this->lng->txt('confirm'), self::CMD_CONFIRMED_SAVE_FORM);
150 
151  $confirmation->setOldQuestionSetType($oldQuestionSetType);
152  $confirmation->setNewQuestionSetType($newQuestionSetType);
153  $confirmation->setQuestionLossInfoEnabled($hasQuestionsWithoutQuestionpool);
154  $confirmation->build();
155 
156  $confirmation->populateParametersFromPropertyForm($form, $this->activeUser->getTimeZone());
157 
158  $this->tpl->setContent( $this->ctrl->getHTML($confirmation) );
159  }
160 
161  protected function getSettingsTemplateMessageHTML()
162  {
163  if( $this->settingsTemplate )
164  {
165  global $tpl;
166 
167  $link = $this->ctrl->getLinkTarget($this, self::CMD_SHOW_RESET_TPL_CONFIRM);
168  $link = "<a href=\"".$link."\">".$this->lng->txt("test_using_template_link")."</a>";
169 
170  $msgHTML = $tpl->getMessageHTML(
171  sprintf($this->lng->txt("test_using_template"), $this->settingsTemplate->getTitle(), $link), "info"
172  );
173 
174  $msgHTML = "<div style=\"margin-top:10px\">$msgHTML</div>";
175  }
176  else
177  {
178  $msgHTML = '';
179  }
180 
181  return $msgHTML;
182  }
183 
184  private function confirmedSaveFormCmd()
185  {
186  return $this->saveFormCmd(true);
187  }
188 
189  private function saveFormCmd($isConfirmedSave = false)
190  {
191  $form = $this->buildForm();
192 
193  // form validation and initialisation
194 
195  $errors = !$form->checkInput(); // ALWAYS CALL BEFORE setValuesByPost()
196  $form->setValuesByPost(); // NEVER CALL THIS BEFORE checkInput()
197  // Sarcasm? No. Because checkInput checks the form graph against the POST without
198  // actually setting the values into the form. Sounds ridiculous? Indeed, and it is.
199 
200  // return to form when any form validation errors exist
201 
202  if($errors)
203  {
204  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
205  return $this->showFormCmd($form);
206  }
207 
208  // return to form when online is to be set, but no questions are configured
209 
210  $currentQuestionSetConfig = $this->testQuestionSetConfigFactory->getQuestionSetConfig();
211  if( $form->getItemByPostVar('online')->getChecked() && !$this->testOBJ->isComplete($currentQuestionSetConfig) )
212  {
213  $form->getItemByPostVar('online')->setAlert(
214  $this->lng->txt("cannot_switch_to_online_no_questions_andor_no_mark_steps")
215  );
216 
217  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
218  return $this->showFormCmd($form);
219  }
220 
221  $infoMsg = array();
222 
223  // solve conflicts with question set type setting with confirmation screen if required
224  // determine wether question set type relating data is to be removed (questions/pools)
225 
226  $questionSetTypeRelatingDataCleanupRequired = false;
227 
228  $oldQuestionSetType = $this->testOBJ->getQuestionSetType();
229  if( $form->getItemByPostVar('question_set_type') instanceof ilFormPropertyGUI )
230  {
231  $newQuestionSetType = $form->getItemByPostVar('question_set_type')->getValue();
232 
233  if( !$this->testOBJ->participantDataExist() && $newQuestionSetType != $oldQuestionSetType )
234  {
235  $oldQuestionSetConfig = $this->testQuestionSetConfigFactory->getQuestionSetConfigByType(
236  $oldQuestionSetType
237  );
238 
239  if( $oldQuestionSetConfig->doesQuestionSetRelatedDataExist() )
240  {
241  if( !$isConfirmedSave )
242  {
243  if( $oldQuestionSetType == ilObjTest::QUESTION_SET_TYPE_FIXED )
244  {
245  return $this->showConfirmation(
246  $form, $oldQuestionSetType, $newQuestionSetType,
247  $this->testOBJ->hasQuestionsWithoutQuestionpool()
248  );
249  }
250 
251  return $this->showConfirmation(
252  $form, $oldQuestionSetType, $newQuestionSetType, false
253  );
254  }
255 
256  $questionSetTypeRelatingDataCleanupRequired = true;
257  }
258 
259  if( $form->getItemByPostVar('online')->getChecked() )
260  {
261  $form->getItemByPostVar('online')->setChecked(false);
262 
263  if( $this->testOBJ->isOnline() )
264  {
265  $infoMsg[] = $this->lng->txt("tst_set_offline_due_to_switched_question_set_type_setting");
266  }
267  else
268  {
269  $infoMsg[] = $this->lng->txt("tst_cannot_online_due_to_switched_quest_set_type_setting");
270  }
271  }
272  }
273  }
274  else
275  {
276  $newQuestionSetType = $oldQuestionSetType;
277  }
278 
279  // adjust settiue to desired question set type
280 
281  if( $newQuestionSetType != ilObjTest::QUESTION_SET_TYPE_FIXED )
282  {
283  $form->getItemByPostVar('chb_use_previous_answers')->setChecked(false);
284 
285  if( $this->isSkillServiceSettingToBeAdjusted($form) )
286  {
287  $form->getItemByPostVar('skill_service')->setChecked(false);
288 
289  if( $this->testOBJ->isSkillServiceEnabled() )
290  {
291  $infoMsg[] = $this->lng->txt("tst_disabled_skl_due_to_non_fixed_quest_set_type");
292  }
293  else
294  {
295  $infoMsg[] = $this->lng->txt("tst_cannot_enable_skl_due_to_non_fixed_quest_set_type");
296  }
297  }
298  }
299 
300  // perform saving the form data
301 
302  $this->performSaveForm($form);
303 
304  // clean up test mode relating configuration data (questions/questionpools)
305 
306  if( $questionSetTypeRelatingDataCleanupRequired )
307  {
308  $oldQuestionSetConfig->removeQuestionSetRelatedData();
309  }
310 
311  // disinvite all invited users if required
312 
313  if( !$this->testOBJ->participantDataExist() && !$this->testOBJ->getFixedParticipants() )
314  {
315  foreach ($this->testOBJ->getInvitedUsers() as $usrId => $usrData)
316  {
317  $this->testOBJ->disinviteUser($usrId);
318  }
319  }
320 
321  // redirect to form output
322 
323  if( count($infoMsg) )
324  {
325  ilUtil::sendInfo(implode('<br />', $infoMsg), true);
326  }
327 
328  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
329  $this->ctrl->redirect($this, self::CMD_SHOW_FORM);
330  }
331 
336  {
337  require_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
338  $confirmationGUI = new ilConfirmationGUI();
339 
340  $confirmationGUI->setFormAction($this->ctrl->getFormAction($this));
341  $confirmationGUI->setHeaderText($this->lng->txt("test_confirm_template_reset"));
342  $confirmationGUI->setCancel($this->lng->txt('cancel'), self::CMD_SHOW_FORM);
343  $confirmationGUI->setConfirm($this->lng->txt('confirm'), self::CMD_CONFIRMED_RESET_TPL);
344 
345  $this->tpl->setContent( $this->ctrl->getHTML($confirmationGUI) );
346  }
347 
351  private function confirmedResetTemplateCmd()
352  {
353  $this->testOBJ->setTemplate(null);
354  $this->testOBJ->saveToDB();
355 
356  ilUtil::sendSuccess($this->lng->txt("test_template_reset"), true);
357  $this->ctrl->redirect($this, self::CMD_SHOW_FORM);
358  }
359 
361  {
362  if( !($form->getItemByPostVar('skill_service') instanceof ilFormPropertyGUI) )
363  {
364  return false;
365  }
366 
368  {
369  return false;
370  }
371 
372  if( !$form->getItemByPostVar('skill_service')->getChecked() )
373  {
374  return false;
375  }
376 
377  return true;
378  }
379 
381  {
382  global $ilSetting;
383 
384  return $ilSetting->get('char_selector_availability') > 0;
385  }
386 
387 
388  private function buildForm()
389  {
390  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
391  $form = new ilPropertyFormGUI();
392  $form->setFormAction($this->ctrl->getFormAction($this));
393  $form->addCommandButton(self::CMD_SAVE_FORM, $this->lng->txt("save"));
394  $form->setTableWidth("100%");
395  $form->setId("test_properties");
396 
397  $this->addGeneralProperties($form);
398  $this->addAvailabilityProperties($form);
399  $this->addTestIntroProperties($form);
400  $this->addTestAccessProperties($form);
401  $this->addTestRunProperties($form);
402  $this->addQuestionBehaviourProperties($form);
403  $this->addTestSequenceProperties($form);
404  $this->addTestFinishProperties($form);
405 
406  // Edit ecs export settings
407  include_once 'Modules/Test/classes/class.ilECSTestSettings.php';
408  $ecs = new ilECSTestSettings($this->testOBJ);
409  $ecs->addSettingsToForm($form, 'tst');
410 
411  // skill service activation for FIXED tests only
412  if( $this->testOBJ->isFixedTest() && ilObjTest::isSkillManagementGloballyActivated() )
413  {
414  $otherHead = new ilFormSectionHeaderGUI();
415  $otherHead->setTitle($this->lng->txt('other'));
416  $form->addItem($otherHead);
417 
418  $skillService = new ilCheckboxInputGUI($this->lng->txt('tst_activate_skill_service'), 'skill_service');
419  $skillService->setInfo($this->lng->txt('tst_activate_skill_service_desc'));
420  $skillService->setChecked($this->testOBJ->isSkillServiceEnabled());
421  if($this->testOBJ->participantDataExist()) $skillService->setDisabled(true);
422  $form->addItem($skillService);
423  }
424 
425  // remove items when using template
426  $this->removeHiddenItems($form);
427 
428  return $form;
429  }
430 
431  private function performSaveForm(ilPropertyFormGUI $form)
432  {
433  $this->saveGeneralProperties($form);
434  $this->saveAvailabilityProperties($form);
435  $this->saveTestIntroProperties($form);
436  $this->saveTestAccessProperties($form);
437  $this->saveTestRunProperties($form);
438  $this->saveQuestionBehaviourProperties($form);
439  $this->saveTestSequenceSettings($form);
440  $this->saveTestFinishProperties($form);
441 
442  if( !$this->testOBJ->participantDataExist() )
443  {
444  // skill service
445  if( ilObjTest::isSkillManagementGloballyActivated() && $form->getItemByPostVar('skill_service') instanceof ilFormPropertyGUI )
446  {
447  $this->testOBJ->setSkillServiceEnabled($form->getItemByPostVar('skill_service')->getChecked());
448  }
449  }
450 
451  // store settings to db
452  $this->testOBJ->saveToDb(true);
453 
454  // Update ecs export settings
455  include_once 'Modules/Test/classes/class.ilECSTestSettings.php';
456  $ecs = new ilECSTestSettings($this->testOBJ);
457  $ecs->handleSettingsUpdate();
458  }
459 
463  private function addGeneralProperties(ilPropertyFormGUI $form)
464  {
465  $header = new ilFormSectionHeaderGUI();
466  $header->setTitle($this->lng->txt("tst_general_properties"));
467  $form->addItem($header);
468 
469  // title & description (meta data)
470 
471  include_once 'Services/MetaData/classes/class.ilMD.php';
472  $md_obj = new ilMD($this->testOBJ->getId(), 0, "tst");
473  $md_section = $md_obj->getGeneral();
474 
475  $title = new ilTextInputGUI($this->lng->txt("title"), "title");
476  $title->setRequired(true);
477  $title->setValue($md_section->getTitle());
478  $form->addItem($title);
479 
480  $ids = $md_section->getDescriptionIds();
481  if ($ids) {
482  $desc_obj = $md_section->getDescription(array_pop($ids));
483 
484  $desc = new ilTextAreaInputGUI($this->lng->txt("description"), "description");
485  $desc->setCols(50);
486  $desc->setRows(4);
487  $desc->setValue($desc_obj->getDescription());
488  $form->addItem($desc);
489  }
490 
491  // pool usage
492  $pool_usage = new ilRadioGroupInputGUI($this->lng->txt('test_question_pool_usage'), 'use_pool');
493 
494  $optional_qpl = new ilRadioOption($this->lng->txt('test_question_pool_usage_optional'), 1);
495  $optional_qpl->setInfo($this->lng->txt('test_question_pool_usage_optional_info'));
496  $pool_usage->addOption($optional_qpl);
497 
498  $tst_directly = new ilRadioOption($this->lng->txt('test_question_pool_usage_tst_directly'), 0);
499  $tst_directly->setInfo($this->lng->txt('test_question_pool_usage_tst_directly_info'));
500  $pool_usage->addOption($tst_directly);
501 
502  $pool_usage->setValue($this->testOBJ->getPoolUsage() ? 1 : 0);
503  $form->addItem($pool_usage);
504 
505  // test mode (question set type)
506  $questSetType = new ilRadioGroupInputGUI($this->lng->txt("tst_question_set_type"), 'question_set_type');
507  $questSetTypeFixed = new ilRadioOption(
508  $this->lng->txt("tst_question_set_type_fixed"), ilObjTest::QUESTION_SET_TYPE_FIXED,
509  $this->lng->txt("tst_question_set_type_fixed_desc")
510  );
511  $questSetType->addOption($questSetTypeFixed);
512  $questSetTypeRandom = new ilRadioOption(
513  $this->lng->txt("tst_question_set_type_random"), ilObjTest::QUESTION_SET_TYPE_RANDOM,
514  $this->lng->txt("tst_question_set_type_random_desc")
515  );
516  $questSetType->addOption($questSetTypeRandom);
517  $questSetTypeContinues = new ilRadioOption(
518  $this->lng->txt("tst_question_set_type_dynamic"), ilObjTest::QUESTION_SET_TYPE_DYNAMIC,
519  $this->lng->txt("tst_question_set_type_dynamic_desc")
520  );
521  $questSetType->addOption($questSetTypeContinues);
522  $questSetType->setValue($this->testOBJ->getQuestionSetType());
523  if ($this->testOBJ->participantDataExist()) {
524  $questSetType->setDisabled(true);
525  }
526  $form->addItem($questSetType);
527  }
528 
532  private function saveGeneralProperties(ilPropertyFormGUI $form)
533  {
534  include_once 'Services/MetaData/classes/class.ilMD.php';
535  $md_obj =& new ilMD($this->testOBJ->getId(), 0, "tst");
536  $md_section = $md_obj->getGeneral();
537 
538  // title
539  $md_section->setTitle(ilUtil::stripSlashes($form->getItemByPostVar('title')->getValue()));
540  $md_section->update();
541 
542  // Description
543  $md_desc_ids = $md_section->getDescriptionIds();
544  if ($md_desc_ids)
545  {
546  $md_desc = $md_section->getDescription(array_pop($md_desc_ids));
547  $md_desc->setDescription(ilUtil::stripSlashes($form->getItemByPostVar('description')->getValue()));
548  $md_desc->update();
549  }
550  else
551  {
552  $md_desc = $md_section->addDescription();
553  $md_desc->setDescription(ilUtil::stripSlashes($form->getItemByPostVar('description')->getValue()));
554  $md_desc->save();
555  }
556 
557  $this->testOBJ->setTitle(ilUtil::stripSlashes($form->getItemByPostVar('title')->getValue()));
558  $this->testOBJ->setDescription(ilUtil::stripSlashes($form->getItemByPostVar('description')->getValue()));
559  $this->testOBJ->update();
560 
561  // pool usage setting
562  if ($form->getItemByPostVar('use_pool') instanceof ilFormPropertyGUI)
563  {
564  $this->testOBJ->setPoolUsage((int)$form->getItemByPostVar('use_pool')->getValue());
565  }
566 
567  if (!$this->testOBJ->participantDataExist())
568  {
569  // question set type
570  if ($form->getItemByPostVar('question_set_type') instanceof ilFormPropertyGUI)
571  {
572  $this->testOBJ->setQuestionSetType($form->getItemByPostVar('question_set_type')->getValue());
573  }
574  }
575  }
576 
581  {
582  include_once "Services/Object/classes/class.ilObjectActivation.php";
583  $this->lng->loadLanguageModule('rep');
584 
586  $section->setTitle($this->lng->txt('rep_activation_availability'));
587  $form->addItem($section);
588 
589  // additional info only with multiple references
590  $act_obj_info = $act_ref_info = "";
591  if (sizeof(ilObject::_getAllReferences($this->testOBJ->getId())) > 1) {
592  $act_obj_info = ' ' . $this->lng->txt('rep_activation_online_object_info');
593  $act_ref_info = $this->lng->txt('rep_activation_access_ref_info');
594  }
595 
596  $online = new ilCheckboxInputGUI($this->lng->txt('rep_activation_online'), 'online');
597  $online->setChecked($this->testOBJ->isOnline());
598  $online->setInfo($this->lng->txt('tst_activation_online_info') . $act_obj_info);
599  $form->addItem($online);
600 
601  $act_type = new ilCheckboxInputGUI($this->lng->txt('rep_visibility_until'), 'activation_type');
602  $act_type->setChecked($this->testOBJ->isActivationLimited());
603  // $act_type->setInfo($this->lng->txt('tst_availability_until_info'));
604 
605  $this->tpl->addJavaScript('./Services/Form/js/date_duration.js');
606  include_once "Services/Form/classes/class.ilDateDurationInputGUI.php";
607  $dur = new ilDateDurationInputGUI($this->lng->txt("rep_time_period"), "access_period");
608  $dur->setShowTime(true);
609  $date = $this->testOBJ->getActivationStartingTime();
610  $dur->setStart(new ilDateTime($date ? $date : time(), IL_CAL_UNIX));
611  $dur->setStartText($this->lng->txt('rep_activation_limited_start'));
612  $date = $this->testOBJ->getActivationEndingTime();
613  $dur->setEnd(new ilDateTime($date ? $date : time(), IL_CAL_UNIX));
614  $dur->setEndText($this->lng->txt('rep_activation_limited_end'));
615  $act_type->addSubItem($dur);
616 
617  $visible = new ilCheckboxInputGUI($this->lng->txt('rep_activation_limited_visibility'), 'activation_visibility');
618  $visible->setInfo($this->lng->txt('tst_activation_limited_visibility_info'));
619  $visible->setChecked($this->testOBJ->getActivationVisibility());
620  $act_type->addSubItem($visible);
621 
622  $form->addItem($act_type);
623  }
624 
629  {
630  // online status
631  $this->testOBJ->setOnline($form->getItemByPostVar('online')->getChecked());
632 
633  // activation
634  if ($form->getItemByPostVar('activation_type')->getChecked())
635  {
636  $this->testOBJ->setActivationLimited(true);
637  $this->testOBJ->setActivationVisibility($form->getItemByPostVar('activation_visibility')->getChecked());
638 
639  $period = $form->getItemByPostVar("access_period");
640  $this->testOBJ->setActivationStartingTime($period->getStart()->get(IL_CAL_UNIX));
641  $this->testOBJ->setActivationEndingTime($period->getEnd()->get(IL_CAL_UNIX));
642  }
643  else
644  {
645  $this->testOBJ->setActivationLimited(false);
646  }
647  }
648 
653  {
655  $section->setTitle($this->lng->txt('tst_settings_header_intro'));
656  $form->addItem($section);
657 
658  // introduction
659  $introEnabled = new ilCheckboxInputGUI($this->lng->txt("tst_introduction"), 'intro_enabled');
660  $introEnabled->setChecked($this->testOBJ->isIntroductionEnabled());
661  $introEnabled->setInfo($this->lng->txt('tst_introduction_desc'));
662  $form->addItem($introEnabled);
663  $intro = new ilTextAreaInputGUI($this->lng->txt("tst_introduction_text"), "introduction");
664  $intro->setRequired(true);
665  $intro->setValue($this->testOBJ->prepareTextareaOutput($this->testOBJ->getIntroduction(), false, true));
666  $intro->setRows(10);
667  $intro->setCols(80);
668  $intro->setUseRte(TRUE);
669  $intro->addPlugin("latex");
670  $intro->addButton("latex");
671  $intro->setRTESupport($this->testOBJ->getId(), "tst", "assessment");
672  $intro->setRteTagSet('full');
673  $introEnabled->addSubItem($intro);
674 
675  // showinfo
676  $showinfo = new ilCheckboxInputGUI($this->lng->txt("showinfo"), "showinfo");
677  $showinfo->setValue(1);
678  $showinfo->setChecked($this->testOBJ->getShowInfo());
679  $showinfo->setInfo($this->lng->txt("showinfo_desc"));
680  $form->addItem($showinfo);
681  }
682 
687  {
688  if ($form->getItemByPostVar('intro_enabled') instanceof ilFormPropertyGUI)
689  {
690  $this->testOBJ->setIntroductionEnabled($form->getItemByPostVar('intro_enabled')->getChecked());
691 
692  if ($form->getItemByPostVar('intro_enabled')->getChecked())
693  {
694  $this->testOBJ->setIntroduction($form->getItemByPostVar('introduction')->getValue(), false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment"));
695  }
696  else
697  {
698  $this->testOBJ->setIntroduction('');
699  }
700  }
701 
702  if ($form->getItemByPostVar('showinfo') instanceof ilFormPropertyGUI)
703  {
704  $this->testOBJ->setShowInfo($form->getItemByPostVar('showinfo')->getChecked());
705  }
706  }
707 
712  {
713  $header = new ilFormSectionHeaderGUI();
714  $header->setTitle($this->lng->txt("tst_settings_header_execution"));
715  $form->addItem($header);
716 
717  // enable starting time
718  $enablestartingtime = new ilCheckboxInputGUI($this->lng->txt("tst_starting_time"), "chb_starting_time");
719  $enablestartingtime->setInfo($this->lng->txt("tst_starting_time_desc"));
720  $enablestartingtime->setChecked($this->testOBJ->isStartingTimeEnabled());
721 
722  // starting time
723  $startingtime = new ilDateTimeInputGUI('', 'starting_time');
724  $startingtime->setShowTime(true);
725  if( strlen($this->testOBJ->getStartingTime()) )
726  {
727  $startingtime->setDate(new ilDateTime($this->testOBJ->getStartingTime(), IL_CAL_TIMESTAMP));
728  }
729  else
730  {
731  $startingtime->setDate(new ilDateTime(time(), IL_CAL_UNIX));
732  }
733  $enablestartingtime->addSubItem($startingtime);
734  $form->addItem($enablestartingtime);
735  if ($this->testOBJ->participantDataExist())
736  {
737  $enablestartingtime->setDisabled(true);
738  $startingtime->setDisabled(true);
739  }
740 
741  // enable ending time
742  $enableendingtime = new ilCheckboxInputGUI($this->lng->txt("tst_ending_time"), "chb_ending_time");
743  $enableendingtime->setInfo($this->lng->txt("tst_ending_time_desc"));
744  $enableendingtime->setChecked($this->testOBJ->isEndingTimeEnabled());
745 
746  // ending time
747  $endingtime = new ilDateTimeInputGUI('', 'ending_time');
748  $endingtime->setShowTime(true);
749  if (strlen($this->testOBJ->getEndingTime()))
750  {
751  $endingtime->setDate(new ilDateTime($this->testOBJ->getEndingTime(), IL_CAL_TIMESTAMP));
752  }
753  else
754  {
755  $endingtime->setDate(new ilDateTime(time(), IL_CAL_UNIX));
756  }
757  $enableendingtime->addSubItem($endingtime);
758  $form->addItem($enableendingtime);
759 
760  // test password
761  $pwEnabled = new ilCheckboxInputGUI($this->lng->txt('tst_password'), 'password_enabled');
762  $pwEnabled->setChecked($this->testOBJ->isPasswordEnabled());
763  $pwEnabled->setInfo($this->lng->txt("tst_password_details"));
764  $password = new ilTextInputGUI($this->lng->txt("tst_password_enter"), "password");
765  $password->setRequired(true);
766  $password->setSize(20);
767  $password->setValue($this->testOBJ->getPassword());
768  $pwEnabled->addSubItem($password);
769  $form->addItem($pwEnabled);
770 
771  // fixed participants
772  $fixedparticipants = new ilCheckboxInputGUI($this->lng->txt('participants_invitation'), "fixedparticipants");
773  $fixedparticipants->setValue(1);
774  $fixedparticipants->setChecked($this->testOBJ->getFixedParticipants());
775  $fixedparticipants->setInfo($this->lng->txt("participants_invitation_description"));
776  $invited_users = $this->testOBJ->getInvitedUsers();
777  if ($this->testOBJ->participantDataExist() && (count($invited_users) == 0))
778  {
779  $fixedparticipants->setDisabled(true);
780  }
781  $form->addItem($fixedparticipants);
782 
783  // simultaneous users
784  $simulLimited = new ilCheckboxInputGUI($this->lng->txt("tst_allowed_users"), 'limitUsers');
785  $simulLimited->setInfo($this->lng->txt("tst_allowed_users_desc"));
786  $simulLimited->setChecked($this->testOBJ->isLimitUsersEnabled());
787 
788  // allowed simultaneous users
789  $simul = new ilNumberInputGUI($this->lng->txt("tst_allowed_users_max"), "allowedUsers");
790  $simul->setRequired(true);
791  $simul->allowDecimals(false);
792  $simul->setMinValue(1);
793  $simul->setMinvalueShouldBeGreater(false);
794  $simul->setSize(4);
795  $simul->setValue(($this->testOBJ->getAllowedUsers()) ? $this->testOBJ->getAllowedUsers() : '');
796  $simulLimited->addSubItem($simul);
797 
798  // idle time
799  $idle = new ilNumberInputGUI($this->lng->txt("tst_allowed_users_time_gap"), "allowedUsersTimeGap");
800  $idle->setInfo($this->lng->txt("tst_allowed_users_time_gap_desc"));
801  $idle->setSize(4);
802  $idle->setSuffix($this->lng->txt("seconds"));
803  $idle->setValue(($this->testOBJ->getAllowedUsersTimeGap()) ? $this->testOBJ->getAllowedUsersTimeGap() : 300);
804  $simulLimited->addSubItem($idle);
805 
806  $form->addItem($simulLimited);
807  return $header;
808  }
809 
814  {
815  // starting time
816  if( $this->formPropertyExists($form, 'chb_starting_time') && !$this->testOBJ->participantDataExist() )
817  {
818  if( $form->getItemByPostVar('chb_starting_time')->getChecked() )
819  {
820  $this->testOBJ->setStartingTime(ilFormat::dateDB2timestamp(
821  $form->getItemByPostVar('starting_time')->getDate()->get(IL_CAL_DATETIME)
822  ));
823 
824  $this->testOBJ->setStartingTimeEnabled(true);
825  }
826  else
827  {
828  $this->testOBJ->setStartingTimeEnabled(false);
829  }
830  }
831 
832  // ending time
833  if( $this->formPropertyExists($form, 'chb_ending_time') )
834  {
835  if( $form->getItemByPostVar('chb_ending_time')->getChecked() )
836  {
837  $this->testOBJ->setEndingTime(ilFormat::dateDB2timestamp(
838  $form->getItemByPostVar('ending_time')->getDate()->get(IL_CAL_DATETIME)
839  ));
840 
841  $this->testOBJ->setEndingTimeEnabled(true);
842  }
843  else
844  {
845  $this->testOBJ->setEndingTimeEnabled(false);
846  }
847  }
848 
849  if( $this->formPropertyExists($form, 'password_enabled') )
850  {
851  $this->testOBJ->setPasswordEnabled($form->getItemByPostVar('password_enabled')->getChecked());
852 
853  if( $form->getItemByPostVar('password_enabled')->getChecked() )
854  {
855  $this->testOBJ->setPassword($form->getItemByPostVar('password')->getValue());
856  }
857  else
858  {
859  $this->testOBJ->setPassword(''); // otherwise test will still respect value
860  }
861  }
862 
863  if( $this->formPropertyExists($form, 'fixedparticipants') && !$this->testOBJ->participantDataExist() )
864  {
865  $this->testOBJ->setFixedParticipants($form->getItemByPostVar('fixedparticipants')->getChecked());
866  }
867 
868  if( $this->formPropertyExists($form, 'limitUsers') )
869  {
870  $this->testOBJ->setLimitUsersEnabled($form->getItemByPostVar('limitUsers')->getChecked());
871 
872  if( $form->getItemByPostVar('limitUsers')->getChecked() )
873  {
874  $this->testOBJ->setAllowedUsers($form->getItemByPostVar('allowedUsers')->getValue());
875  $this->testOBJ->setAllowedUsersTimeGap($form->getItemByPostVar('allowedUsersTimeGap')->getValue());
876  }
877  else
878  {
879  $this->testOBJ->setAllowedUsers(''); // otherwise test will still respect value
880  }
881  }
882  }
883 
887  private function addTestRunProperties(ilPropertyFormGUI $form)
888  {
889  // section header test run
890  $header = new ilFormSectionHeaderGUI();
891  $header->setTitle($this->lng->txt("tst_settings_header_test_run"));
892  $form->addItem($header);
893 
894  // max. number of passes
895  $limitPasses = new ilCheckboxInputGUI($this->lng->txt("tst_limit_nr_of_tries"), 'limitPasses');
896  $limitPasses->setInfo($this->lng->txt("tst_nr_of_tries_desc"));
897  $limitPasses->setChecked($this->testOBJ->getNrOfTries() > 0);
898  $nr_of_tries = new ilNumberInputGUI($this->lng->txt("tst_nr_of_tries"), "nr_of_tries");
899  $nr_of_tries->setSize(3);
900  $nr_of_tries->allowDecimals(false);
901  $nr_of_tries->setMinValue(1);
902  $nr_of_tries->setMinvalueShouldBeGreater(false);
903  $nr_of_tries->setValue($this->testOBJ->getNrOfTries() ? $this->testOBJ->getNrOfTries() : 1);
904  $nr_of_tries->setRequired(true);
905  if( $this->testOBJ->participantDataExist() )
906  {
907  $limitPasses->setDisabled(true);
908  $nr_of_tries->setDisabled(true);
909  }
910  $limitPasses->addSubItem($nr_of_tries);
911  $form->addItem($limitPasses);
912 
913  // enable max. processing time
914  $processing = new ilCheckboxInputGUI($this->lng->txt("tst_processing_time"), "chb_processing_time");
915  $processing->setInfo($this->lng->txt("tst_processing_time_desc"));
916  $processing->setValue(1);
917 
918  if ($this->settingsTemplate && $this->getTemplateSettingValue('chb_processing_time')) {
919  $processing->setChecked(true);
920  } else {
921  $processing->setChecked($this->testOBJ->getEnableProcessingTime());
922  }
923 
924  // max. processing time
925  $processingtime = new ilNumberInputGUI($this->lng->txt("tst_processing_time_duration"), 'processing_time');
926  $processingtime->allowDecimals(false);
927  $processingtime->setMinValue(1);
928  $processingtime->setMinvalueShouldBeGreater(false);
929  $processingtime->setValue($this->testOBJ->getProcessingTimeAsMinutes());
930  $processingtime->setSize(5);
931  $processingtime->setSuffix($this->lng->txt('minutes'));
932  $processingtime->setInfo($this->lng->txt("tst_processing_time_duration_desc"));
933  $processing->addSubItem($processingtime);
934 
935  // reset max. processing time
936  $resetprocessing = new ilCheckboxInputGUI('', "chb_reset_processing_time");
937  $resetprocessing->setValue(1);
938  $resetprocessing->setOptionTitle($this->lng->txt("tst_reset_processing_time"));
939  $resetprocessing->setChecked($this->testOBJ->getResetProcessingTime());
940  $resetprocessing->setInfo($this->lng->txt("tst_reset_processing_time_desc"));
941  $processing->addSubItem($resetprocessing);
942  $form->addItem($processing);
943 
944  if( $this->testOBJ->participantDataExist() )
945  {
946  $processing->setDisabled(true);
947  $processingtime->setDisabled(true);
948  $resetprocessing->setDisabled(true);
949  }
950 
951  // kiosk mode
952  $kiosk = new ilCheckboxInputGUI($this->lng->txt("kiosk"), "kiosk");
953  $kiosk->setValue(1);
954  $kiosk->setChecked($this->testOBJ->getKioskMode());
955  $kiosk->setInfo($this->lng->txt("kiosk_description"));
956 
957  // kiosk mode options
958  $kiosktitle = new ilCheckboxGroupInputGUI($this->lng->txt("kiosk_options"), "kiosk_options");
959  $kiosktitle->addOption(new ilCheckboxOption($this->lng->txt("kiosk_show_title"), 'kiosk_title', ''));
960  $kiosktitle->addOption(new ilCheckboxOption($this->lng->txt("kiosk_show_participant"), 'kiosk_participant', ''));
961  $values = array();
962  if ($this->testOBJ->getShowKioskModeTitle()) array_push($values, 'kiosk_title');
963  if ($this->testOBJ->getShowKioskModeParticipant()) array_push($values, 'kiosk_participant');
964  $kiosktitle->setValue($values);
965  $kiosktitle->setInfo($this->lng->txt("kiosk_options_desc"));
966  $kiosk->addSubItem($kiosktitle);
967 
968  $form->addItem($kiosk);
969 
970  $examIdInPass = new ilCheckboxInputGUI($this->lng->txt('examid_in_test_pass'), 'examid_in_test_pass');
971  $examIdInPass->setInfo($this->lng->txt('examid_in_test_pass_desc'));
972  $examIdInPass->setChecked($this->testOBJ->isShowExamIdInTestPassEnabled());
973  $form->addItem($examIdInPass);
974  }
975 
979  private function saveTestRunProperties(ilPropertyFormGUI $form)
980  {
981  if (!$this->testOBJ->participantDataExist())
982  {
983  // nr of tries (max passes)
984  if ($form->getItemByPostVar('limitPasses') instanceof ilFormPropertyGUI)
985  {
986  if ($form->getItemByPostVar('limitPasses')->getChecked())
987  {
988  $this->testOBJ->setNrOfTries($form->getItemByPostVar('nr_of_tries')->getValue());
989  }
990  else
991  {
992  $this->testOBJ->setNrOfTries(0);
993  }
994  }
995 
996  $this->testOBJ->setEnableProcessingTime($form->getItemByPostVar('chb_processing_time')->getChecked());
997  if ($this->testOBJ->getEnableProcessingTime())
998  {
999  $this->testOBJ->setProcessingTimeByMinutes($form->getItemByPostVar('processing_time')->getValue());
1000  $this->testOBJ->setResetProcessingTime($form->getItemByPostVar('chb_reset_processing_time')->getChecked());
1001  }
1002  else
1003  {
1004  $this->testOBJ->setProcessingTime('');
1005  $this->testOBJ->setResetProcessingTime(false);
1006  }
1007  }
1008 
1009  if ($form->getItemByPostVar('kiosk') instanceof ilFormPropertyGUI)
1010  {
1011  $this->testOBJ->setKioskMode($form->getInput('kiosk'));
1012  $kioskOptions = $form->getItemByPostVar('kiosk_options')->getValue();
1013  if (is_array($kioskOptions))
1014  {
1015  $this->testOBJ->setShowKioskModeTitle(in_array('kiosk_title', $kioskOptions));
1016  $this->testOBJ->setShowKioskModeParticipant(in_array('kiosk_participant', $kioskOptions));
1017  }
1018  else
1019  {
1020  $this->testOBJ->setShowKioskModeTitle(false);
1021  $this->testOBJ->setShowKioskModeParticipant(false);
1022  }
1023  }
1024 
1025  if ($form->getItemByPostVar('examid_in_test_pass') instanceof ilFormPropertyGUI)
1026  {
1027  $value = $form->getItemByPostVar('examid_in_test_pass')->getChecked();
1028  $this->testOBJ->setShowExamIdInTestPassEnabled($value);
1029  }
1030  }
1031 
1036  {
1037  $fields = array(
1038  'title_output', 'autosave', 'chb_shuffle_questions', 'chb_shuffle_questions',
1039  'offer_hints', 'instant_feedback', 'obligations_enabled',
1040  );
1041 
1042  if( $this->isSectionHeaderRequired($fields) || $this->isCharSelectorPropertyRequired() )
1043  {
1044  // sequence properties
1045  $seqheader = new ilFormSectionHeaderGUI();
1046  $seqheader->setTitle($this->lng->txt("tst_presentation_properties"));
1047  $form->addItem($seqheader);
1048  }
1049 
1050  // question title output
1051  $title_output = new ilRadioGroupInputGUI($this->lng->txt("tst_title_output"), "title_output");
1052  $title_output->addOption(new ilRadioOption($this->lng->txt("tst_title_output_full"), 0, ''));
1053  $title_output->addOption(new ilRadioOption($this->lng->txt("tst_title_output_hide_points"), 1, ''));
1054  $title_output->addOption(new ilRadioOption($this->lng->txt("tst_title_output_no_title"), 2, ''));
1055  $title_output->setValue($this->testOBJ->getTitleOutput());
1056  $form->addItem($title_output);
1057 
1058  // Autosave
1059  $autosave_output = new ilCheckboxInputGUI($this->lng->txt('autosave'), 'autosave');
1060  $autosave_output->setValue(1);
1061  $autosave_output->setChecked($this->testOBJ->getAutosave());
1062  $autosave_output->setInfo($this->lng->txt('autosave_info'));
1063  $autosave_interval = new ilTextInputGUI($this->lng->txt('autosave_ival'), 'autosave_ival');
1064  $autosave_interval->setSize(10);
1065  $autosave_interval->setValue($this->testOBJ->getAutosaveIval()/1000);
1066  $autosave_interval->setSuffix($this->lng->txt('seconds'));
1067  $autosave_output->addSubItem($autosave_interval);
1068  $form->addItem($autosave_output);
1069 
1070  // shuffle questions
1071  $shuffle = new ilCheckboxInputGUI($this->lng->txt("tst_shuffle_questions"), "chb_shuffle_questions");
1072  $shuffle->setValue(1);
1073  $shuffle->setChecked($this->testOBJ->getShuffleQuestions());
1074  $shuffle->setInfo($this->lng->txt("tst_shuffle_questions_description"));
1075  $form->addItem($shuffle);
1076 
1077  // offer hints
1078  $checkBoxOfferHints = new ilCheckboxInputGUI($this->lng->txt('tst_setting_offer_hints_label'), 'offer_hints');
1079  $checkBoxOfferHints->setChecked($this->testOBJ->isOfferingQuestionHintsEnabled());
1080  $checkBoxOfferHints->setInfo($this->lng->txt('tst_setting_offer_hints_info'));
1081  if( $this->testOBJ->participantDataExist() )
1082  {
1083  $checkBoxOfferHints->setDisabled(true);
1084  }
1085  $form->addItem($checkBoxOfferHints);
1086 
1087  // instant feedback
1088  $instant_feedback = new ilCheckboxGroupInputGUI($this->lng->txt('tst_instant_feedback'), 'instant_feedback');
1089  $instant_feedback->addOption(new ilCheckboxOption(
1090  $this->lng->txt('tst_instant_feedback_results'), 'instant_feedback_points',
1091  $this->lng->txt('tst_instant_feedback_results_desc')
1092  ));
1093  $instant_feedback->addOption(new ilCheckboxOption(
1094  $this->lng->txt('tst_instant_feedback_answer_generic'), 'instant_feedback_generic',
1095  $this->lng->txt('tst_instant_feedback_answer_generic_desc')
1096  ));
1097  $instant_feedback->addOption(new ilCheckboxOption(
1098  $this->lng->txt('tst_instant_feedback_answer_specific'), 'instant_feedback_specific',
1099  $this->lng->txt('tst_instant_feedback_answer_specific_desc')
1100  ));
1101  $instant_feedback->addOption(new ilCheckboxOption(
1102  $this->lng->txt('tst_instant_feedback_solution'), 'instant_feedback_solution',
1103  $this->lng->txt('tst_instant_feedback_solution_desc')
1104  ));
1105  $instant_feedback->addOption(new ilCheckboxOption(
1106  $this->lng->txt('tst_instant_feedback_fix_usr_answer'), 'instant_feedback_answer_fixation',
1107  $this->lng->txt('tst_instant_feedback_fix_usr_answer_desc')
1108  ));
1109  $values = array();
1110  if ($this->testOBJ->getSpecificAnswerFeedback()) array_push($values, 'instant_feedback_specific');
1111  if ($this->testOBJ->getGenericAnswerFeedback()) array_push($values, 'instant_feedback_generic');
1112  if ($this->testOBJ->getAnswerFeedbackPoints()) array_push($values, 'instant_feedback_points');
1113  if ($this->testOBJ->getInstantFeedbackSolution()) array_push($values, 'instant_feedback_solution');
1114  if( $this->testOBJ->isInstantFeedbackAnswerFixationEnabled() ) array_push($values, 'instant_feedback_answer_fixation');
1115  $instant_feedback->setValue($values);
1116  $form->addItem($instant_feedback);
1117 
1118  // enable obligations
1119  $checkBoxEnableObligations = new ilCheckboxInputGUI($this->lng->txt('tst_setting_enable_obligations_label'), 'obligations_enabled');
1120  $checkBoxEnableObligations->setChecked($this->testOBJ->areObligationsEnabled());
1121  $checkBoxEnableObligations->setInfo($this->lng->txt('tst_setting_enable_obligations_info'));
1122  if( $this->testOBJ->participantDataExist() )
1123  {
1124  $checkBoxEnableObligations->setDisabled(true);
1125  }
1126  $form->addItem($checkBoxEnableObligations);
1127 
1128  // selector for unicode characters
1129  if( $this->isCharSelectorPropertyRequired() )
1130  {
1131  require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
1133  $char_selector->getConfig()->setAvailability($this->testOBJ->getCharSelectorAvailability());
1134  $char_selector->getConfig()->setDefinition($this->testOBJ->getCharSelectorDefinition());
1135  $char_selector->addFormProperties($form);
1136  $char_selector->setFormValues($form);
1137  }
1138  }
1139 
1144  {
1145  if ($form->getItemByPostVar('title_output') instanceof ilFormPropertyGUI)
1146  {
1147  $this->testOBJ->setTitleOutput($form->getItemByPostVar('title_output')->getValue());
1148  }
1149 
1150  if ($form->getItemByPostVar('autosave') instanceof ilFormPropertyGUI)
1151  {
1152  $this->testOBJ->setAutosave($form->getItemByPostVar('autosave')->getChecked());
1153  $this->testOBJ->setAutosaveIval($form->getItemByPostVar('autosave_ival')->getValue() * 1000);
1154  }
1155 
1156  if ($form->getItemByPostVar('chb_shuffle_questions') instanceof ilFormPropertyGUI)
1157  {
1158  $this->testOBJ->setShuffleQuestions($form->getItemByPostVar('chb_shuffle_questions')->getChecked());
1159  }
1160 
1161  if (!$this->testOBJ->participantDataExist() && $this->formPropertyExists($form, 'offer_hints'))
1162  {
1163  $this->testOBJ->setOfferingQuestionHintsEnabled($form->getItemByPostVar('offer_hints')->getChecked());
1164  }
1165 
1166  if ($this->formPropertyExists($form, 'instant_feedback'))
1167  {
1168  $this->testOBJ->setScoringFeedbackOptionsByArray($form->getItemByPostVar('instant_feedback')->getValue());
1169  }
1170 
1171  if (!$this->testOBJ->participantDataExist() && $this->formPropertyExists($form, 'obligations_enabled'))
1172  {
1173  $this->testOBJ->setObligationsEnabled($form->getItemByPostVar('obligations_enabled')->getChecked());
1174  }
1175 
1176  if( $this->isCharSelectorPropertyRequired() )
1177  {
1178  require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
1180  $char_selector->addFormProperties($form);
1181  $char_selector->getFormValues($form);
1182  $this->testOBJ->setCharSelectorAvailability($char_selector->getConfig()->getAvailability());
1183  $this->testOBJ->setCharSelectorDefinition($char_selector->getConfig()->getDefinition());
1184  }
1185  }
1186 
1191  {
1192  // sequence properties
1193  $seqheader = new ilFormSectionHeaderGUI();
1194  $seqheader->setTitle($this->lng->txt("tst_sequence_properties"));
1195  $form->addItem($seqheader);
1196 
1197  // use previous answers
1198  $prevanswers = new ilCheckboxInputGUI($this->lng->txt("tst_use_previous_answers"), "chb_use_previous_answers");
1199  $prevanswers->setValue(1);
1200  $prevanswers->setChecked($this->testOBJ->getUsePreviousAnswers());
1201  $prevanswers->setInfo($this->lng->txt("tst_use_previous_answers_description"));
1202  $form->addItem($prevanswers);
1203 
1204  // show suspend test
1205  $cancel = new ilCheckboxInputGUI($this->lng->txt("tst_show_cancel"), "chb_show_cancel");
1206  $cancel->setValue(1);
1207  $cancel->setChecked($this->testOBJ->getShowCancel());
1208  $cancel->setInfo($this->lng->txt("tst_show_cancel_description"));
1209  $form->addItem($cancel);
1210 
1211  // postpone questions
1212  $postpone = new ilCheckboxInputGUI($this->lng->txt("tst_postpone"), "chb_postpone");
1213  $postpone->setValue(1);
1214  $postpone->setChecked($this->testOBJ->getSequenceSettings());
1215  $postpone->setInfo($this->lng->txt("tst_postpone_description"));
1216  $form->addItem($postpone);
1217 
1218  // show list of questions
1219  $list_of_questions = new ilCheckboxInputGUI($this->lng->txt("tst_show_summary"), "list_of_questions");
1220  //$list_of_questions->setOptionTitle($this->lng->txt("tst_show_summary"));
1221  $list_of_questions->setValue(1);
1222  $list_of_questions->setChecked($this->testOBJ->getListOfQuestions());
1223  $list_of_questions->setInfo($this->lng->txt("tst_show_summary_description"));
1224 
1225  $list_of_questions_options = new ilCheckboxGroupInputGUI('', "list_of_questions_options");
1226  $list_of_questions_options->addOption(new ilCheckboxOption($this->lng->txt("tst_list_of_questions_start"), 'chb_list_of_questions_start', ''));
1227  $list_of_questions_options->addOption(new ilCheckboxOption($this->lng->txt("tst_list_of_questions_end"), 'chb_list_of_questions_end', ''));
1228  $list_of_questions_options->addOption(new ilCheckboxOption($this->lng->txt("tst_list_of_questions_with_description"), 'chb_list_of_questions_with_description', ''));
1229  $values = array();
1230  if ($this->testOBJ->getListOfQuestionsStart()) array_push($values, 'chb_list_of_questions_start');
1231  if ($this->testOBJ->getListOfQuestionsEnd()) array_push($values, 'chb_list_of_questions_end');
1232  if ($this->testOBJ->getListOfQuestionsDescription()) array_push($values, 'chb_list_of_questions_with_description');
1233  $list_of_questions_options->setValue($values);
1234 
1235  $list_of_questions->addSubItem($list_of_questions_options);
1236  $form->addItem($list_of_questions);
1237 
1238  // show question marking
1239  $marking = new ilCheckboxInputGUI($this->lng->txt("question_marking"), "chb_show_marker");
1240  $marking->setValue(1);
1241  $marking->setChecked($this->testOBJ->getShowMarker());
1242  $marking->setInfo($this->lng->txt("question_marking_description"));
1243  $form->addItem($marking);
1244  }
1245 
1250  {
1251  if( $this->formPropertyExists($form, 'chb_use_previous_answers') )
1252  {
1253  $this->testOBJ->setUsePreviousAnswers($form->getInput('chb_use_previous_answers'));
1254  }
1255 
1256  if( $this->formPropertyExists($form, 'chb_show_cancel') )
1257  {
1258  $this->testOBJ->setShowCancel($form->getItemByPostVar('chb_show_cancel')->getChecked());
1259  }
1260 
1261  if( $this->formPropertyExists($form, 'chb_postpone') )
1262  {
1263  $this->testOBJ->setPostponingEnabled($form->getItemByPostVar('chb_postpone')->getChecked());
1264  }
1265 
1266  $this->testOBJ->setListOfQuestions($form->getItemByPostVar('list_of_questions')->getChecked());
1267  $listOfQuestionsOptions = $form->getItemByPostVar('list_of_questions_options')->getValue();
1268  if(is_array($listOfQuestionsOptions))
1269  {
1270  $this->testOBJ->setListOfQuestionsStart(in_array('chb_list_of_questions_start', $listOfQuestionsOptions));
1271  $this->testOBJ->setListOfQuestionsEnd(in_array('chb_list_of_questions_end', $listOfQuestionsOptions));
1272  $this->testOBJ->setListOfQuestionsDescription(in_array('chb_list_of_questions_with_description', $listOfQuestionsOptions));
1273  }
1274  else
1275  {
1276  $this->testOBJ->setListOfQuestionsStart(0);
1277  $this->testOBJ->setListOfQuestionsEnd(0);
1278  $this->testOBJ->setListOfQuestionsDescription(0);
1279  }
1280 
1281  if( $this->formPropertyExists($form, 'chb_show_marker') )
1282  {
1283  $this->testOBJ->setShowMarker($form->getItemByPostVar('chb_show_marker')->getChecked());
1284  }
1285  }
1286 
1291  {
1292  $testFinishHeader = new ilFormSectionHeaderGUI();
1293  $testFinishHeader->setTitle($this->lng->txt("tst_final_information"));
1294  $form->addItem($testFinishHeader);
1295 
1296  // examview
1297  $enable_examview = new ilCheckboxInputGUI($this->lng->txt("enable_examview"), 'enable_examview');
1298  $enable_examview->setValue(1);
1299  $enable_examview->setChecked($this->testOBJ->getEnableExamview());
1300  $enable_examview->setInfo($this->lng->txt("enable_examview_desc"));
1301  $show_examview_html = new ilCheckboxInputGUI('', 'show_examview_html');
1302  $show_examview_html->setValue(1);
1303  $show_examview_html->setChecked($this->testOBJ->getShowExamviewHtml());
1304  $show_examview_html->setOptionTitle($this->lng->txt("show_examview_html"));
1305  $enable_examview->addSubItem($show_examview_html);
1306  $show_examview_pdf = new ilCheckboxInputGUI('', 'show_examview_pdf');
1307  $show_examview_pdf->setValue(1);
1308  $show_examview_pdf->setChecked($this->testOBJ->getShowExamviewPdf());
1309  $show_examview_pdf->setOptionTitle($this->lng->txt("show_examview_pdf"));
1310  $enable_examview->addSubItem($show_examview_pdf);
1311  $form->addItem($enable_examview);
1312 
1313  // show final statement
1314  $showfinal = new ilCheckboxInputGUI($this->lng->txt("final_statement"), "showfinalstatement");
1315  $showfinal->setChecked($this->testOBJ->getShowFinalStatement());
1316  $showfinal->setInfo($this->lng->txt("final_statement_show_desc"));
1317  $form->addItem($showfinal);
1318  // final statement
1319  $finalstatement = new ilTextAreaInputGUI($this->lng->txt("final_statement"), "finalstatement");
1320  $finalstatement->setRequired(true);
1321  $finalstatement->setValue($this->testOBJ->prepareTextareaOutput($this->testOBJ->getFinalStatement(), false, true));
1322  $finalstatement->setRows(10);
1323  $finalstatement->setCols(80);
1324  $finalstatement->setUseRte(TRUE);
1325  $finalstatement->addPlugin("latex");
1326  $finalstatement->addButton("latex");
1327  $finalstatement->setRTESupport($this->testOBJ->getId(), "tst", "assessment");
1328  $finalstatement->setRteTagSet('full');
1329  $showfinal->addSubItem($finalstatement);
1330 
1331  $redirection_mode = $this->testOBJ->getRedirectionMode();
1332  $rm_enabled = new ilCheckboxInputGUI($this->lng->txt('redirect_after_finishing_tst'), 'redirection_enabled');
1333  $rm_enabled->setInfo($this->lng->txt('redirect_after_finishing_tst_desc'));
1334  $rm_enabled->setChecked($redirection_mode == '0' ? false : true);
1335  $radio_rm = new ilRadioGroupInputGUI($this->lng->txt('redirect_after_finishing_rule'), 'redirection_mode');
1336  $always = new ilRadioOption($this->lng->txt('redirect_always'), REDIRECT_ALWAYS);
1337  $radio_rm->addOption($always);
1338  $kiosk = new ilRadioOption($this->lng->txt('redirect_in_kiosk_mode'), REDIRECT_KIOSK);
1339  $radio_rm->addOption($kiosk);
1340  $radio_rm->setValue(in_array($redirection_mode, array(REDIRECT_ALWAYS, REDIRECT_KIOSK)) ? $redirection_mode : REDIRECT_ALWAYS);
1341  $rm_enabled->addSubItem($radio_rm);
1342  $redirection_url = new ilTextInputGUI($this->lng->txt('redirection_url'), 'redirection_url');
1343  $redirection_url->setValue((string)$this->testOBJ->getRedirectionUrl());
1344  $redirection_url->setRequired(true);
1345  $rm_enabled->addSubItem($redirection_url);
1346 
1347  $form->addItem($rm_enabled);
1348 
1349  // Sign submission
1350  $sign_submission = $this->testOBJ->getSignSubmission();
1351  $sign_submission_enabled = new ilCheckboxInputGUI($this->lng->txt('sign_submission'), 'sign_submission');
1352  $sign_submission_enabled->setChecked($sign_submission);
1353  $sign_submission_enabled->setInfo($this->lng->txt('sign_submission_info'));
1354  $form->addItem($sign_submission_enabled);
1355 
1356  // mail notification
1357  $mailnotification = new ilCheckboxInputGUI($this->lng->txt("tst_finish_notification"), "mailnotification");
1358  $mailnotification->setInfo($this->lng->txt("tst_finish_notification_desc"));
1359  $mailnotification->setChecked($this->testOBJ->getMailNotification() > 0);
1360  $form->addItem($mailnotification);
1361 
1362  $mailnotificationContent = new ilRadioGroupInputGUI($this->lng->txt("tst_finish_notification_content"), "mailnotification_content");
1363  $mailnotificationContent->addOption(new ilRadioOption($this->lng->txt("tst_finish_notification_simple"), 1, ''));
1364  $mailnotificationContent->addOption(new ilRadioOption($this->lng->txt("tst_finish_notification_advanced"), 2, ''));
1365  $mailnotificationContent->setValue($this->testOBJ->getMailNotification() ? $this->testOBJ->getMailNotification() : 1);
1366  $mailnotificationContent->setRequired(true);
1367  $mailnotification->addSubItem($mailnotificationContent);
1368 
1369  $mailnottype = new ilCheckboxInputGUI('', "mailnottype");
1370  $mailnottype->setValue(1);
1371  $mailnottype->setOptionTitle($this->lng->txt("mailnottype"));
1372  $mailnottype->setChecked($this->testOBJ->getMailNotificationType());
1373  $mailnotification->addSubItem($mailnottype);
1374  }
1375 
1380  {
1381  if( $this->formPropertyExists($form, 'enable_examview') )
1382  {
1383  $this->testOBJ->setEnableExamview($form->getItemByPostVar('enable_examview')->getChecked());
1384  $this->testOBJ->setShowExamviewHtml($form->getItemByPostVar('show_examview_html')->getChecked());
1385  $this->testOBJ->setShowExamviewPdf($form->getItemByPostVar('show_examview_pdf')->getChecked());
1386  }
1387 
1388  $this->testOBJ->setShowFinalStatement($form->getItemByPostVar('showfinalstatement')->getChecked());
1389  $this->testOBJ->setFinalStatement($form->getItemByPostVar('finalstatement')->getValue(), false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment"));
1390 
1391  if( $form->getItemByPostVar('redirection_enabled')->getChecked() )
1392  {
1393  $this->testOBJ->setRedirectionMode($form->getItemByPostVar('redirection_mode')->getValue());
1394  }
1395  else
1396  {
1397  $this->testOBJ->setRedirectionMode(REDIRECT_NONE);
1398  }
1399  if( strlen($form->getItemByPostVar('redirection_url')->getValue()) )
1400  {
1401  $this->testOBJ->setRedirectionUrl($form->getItemByPostVar('redirection_url')->getValue());
1402  }
1403  else
1404  {
1405  $this->testOBJ->setRedirectionUrl(null);
1406  }
1407 
1408  if( $this->formPropertyExists($form, 'sign_submission') )
1409  {
1410  $this->testOBJ->setSignSubmission($form->getItemByPostVar('sign_submission')->getChecked());
1411  }
1412 
1413  if( $this->formPropertyExists($form, 'mailnotification') && $form->getItemByPostVar('mailnotification')->getChecked() )
1414  {
1415  $this->testOBJ->setMailNotification($form->getItemByPostVar('mailnotification_content')->getValue());
1416  $this->testOBJ->setMailNotificationType($form->getItemByPostVar('mailnottype')->getChecked());
1417  }
1418  else
1419  {
1420  $this->testOBJ->setMailNotification(0);
1421  $this->testOBJ->setMailNotificationType(false);
1422  }
1423  }
1424 }