1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Modules/Test/classes/class.ilTestSettingsGUI.php';
5require_once 'Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php';
6
7/**
8 * GUI class that manages the editing of general test settings/properties
9 * shown on "general" subtab
10 *
11 * @author		Björn Heyser <bheyser@databay.de>
12 * @version		$Id$
13 *
14 * @package		Modules/Test
15 *
16 * @ilCtrl_Calls ilObjTestSettingsGeneralGUI: ilPropertyFormGUI
17 * @ilCtrl_Calls ilObjTestSettingsGeneralGUI: ilConfirmationGUI
18 * @ilCtrl_Calls ilObjTestSettingsGeneralGUI: ilTestSettingsChangeConfirmationGUI
19 */
20class ilObjTestSettingsGeneralGUI extends ilTestSettingsGUI
21{
22    /**
23     * command constants
24     */
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 ANSWER_FIXATION_NONE = 'none';
32    const ANSWER_FIXATION_ON_INSTANT_FEEDBACK = 'instant_feedback';
33    const ANSWER_FIXATION_ON_FOLLOWUP_QUESTION = 'followup_question';
34    const ANSWER_FIXATION_ON_IFB_OR_FUQST = 'ifb_or_fuqst';
35
36    const INSTANT_FEEDBACK_TRIGGER_MANUAL = 0;
37    const INSTANT_FEEDBACK_TRIGGER_FORCED = 1;
38
39    /** @var ilCtrl $ctrl */
40    protected $ctrl = null;
41
42    /** @var ilAccessHandler $access */
43    protected $access = null;
44
45    /** @var ilLanguage $lng */
46    protected $lng = null;
47
48    /** @var ilGlobalTemplateInterface $tpl */
49    protected $tpl = null;
50
51    /** @var ilTree $tree */
52    protected $tree = null;
53
54    /** @var ilDBInterface $db */
55    protected $db = null;
56
57    /** @var ilPluginAdmin $pluginAdmin */
58    protected $pluginAdmin = null;
59
60    /** @var ilObjUser $activeUser */
61    protected $activeUser = null;
62
63    /** @var ilObjTestGUI $testGUI */
64    protected $testGUI = null;
65
66    /** @var ilTestQuestionSetConfigFactory $testQuestionSetConfigFactory Factory for question set config. */
67    private $testQuestionSetConfigFactory = null;
68
69    /**
70     * Constructor
71     *
72     * @param ilCtrl          $ctrl
73     * @param ilAccessHandler $access
74     * @param ilLanguage      $lng
75     * @param ilTemplate      $tpl
76     * @param ilDBInterface   $db
77     * @param ilObjTestGUI    $testGUI
78     *
79     * @return \ilObjTestSettingsGeneralGUI
80     */
81    public function __construct(
82        ilCtrl $ctrl,
83        ilAccessHandler $access,
84        ilLanguage $lng,
85        ilTree $tree,
86        ilDBInterface $db,
87        ilPluginAdmin $pluginAdmin,
88        ilObjUser $activeUser,
89        ilObjTestGUI $testGUI
90    ) {
91        global $DIC; /* @var ILIAS\DI\Container $DIC */
92
93        $this->ctrl = $ctrl;
94        $this->access = $access;
95        $this->lng = $lng;
96        $this->tpl = $DIC->ui()->mainTemplate();
97        $this->tree = $tree;
98        $this->db = $db;
99        $this->pluginAdmin = $pluginAdmin;
100        $this->activeUser = $activeUser;
101
102        $this->testGUI = $testGUI;
103
104        require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
105        $this->testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($this->tree, $this->db, $this->pluginAdmin, $testGUI->object);
106
107        parent::__construct($testGUI->object);
108    }
109
110    /**
111     * Command Execution
112     */
113    public function executeCommand()
114    {
115        global $DIC; /* @var ILIAS\DI\Container $DIC */
116
117        // allow only write access
118
119        if (!$this->access->checkAccess("write", "", $this->testGUI->ref_id)) {
120            ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
121            $this->ctrl->redirect($this->testGUI, "infoScreen");
122        }
123
124        $DIC->tabs()->activateTab(ilTestTabsManager::TAB_ID_SETTINGS);
125
126        // process command
127
128        $nextClass = $this->ctrl->getNextClass();
129
130        switch ($nextClass) {
131            default:
132                $cmd = $this->ctrl->getCmd(self::CMD_SHOW_FORM) . 'Cmd';
133                $this->$cmd();
134        }
135    }
136
137    private function showFormCmd(ilPropertyFormGUI $form = null)
138    {
139        $this->tpl->addJavascript("./Services/JavaScript/js/Basic.js");
140
141        if ($form === null) {
142            $form = $this->buildForm();
143        }
144
145        $formHTML = $this->ctrl->getHTML($form);
146        $msgHTML = $this->getSettingsTemplateMessageHTML();
147
148        $this->tpl->setContent($formHTML . $msgHTML);
149    }
150
151    private function showConfirmation(ilPropertyFormGUI $form, $oldQuestionSetType, $newQuestionSetType, $hasQuestionsWithoutQuestionpool)
152    {
153        require_once 'Modules/Test/classes/confirmations/class.ilTestSettingsChangeConfirmationGUI.php';
154        $confirmation = new ilTestSettingsChangeConfirmationGUI($this->lng, $this->testOBJ);
155
156        $confirmation->setFormAction($this->ctrl->getFormAction($this));
157        $confirmation->setCancel($this->lng->txt('cancel'), self::CMD_SHOW_FORM);
158        $confirmation->setConfirm($this->lng->txt('confirm'), self::CMD_CONFIRMED_SAVE_FORM);
159
160        $confirmation->setOldQuestionSetType($oldQuestionSetType);
161        $confirmation->setNewQuestionSetType($newQuestionSetType);
162        $confirmation->setQuestionLossInfoEnabled($hasQuestionsWithoutQuestionpool);
163        $confirmation->build();
164
165        $confirmation->populateParametersFromPropertyForm($form, $this->activeUser->getTimeZone());
166
167        $this->tpl->setContent($this->ctrl->getHTML($confirmation));
168    }
169
170    protected function getSettingsTemplateMessageHTML()
171    {
172        if ($this->settingsTemplate) {
173            $title = $this->settingsTemplate->getTitle();
174
175            if ($this->settingsTemplate->getAutoGenerated()) {
176                $title = $this->lng->txt($title);
177            }
178
179            global $DIC;
180            $tpl = $DIC['tpl'];
181
182            $link = $this->ctrl->getLinkTarget($this, self::CMD_SHOW_RESET_TPL_CONFIRM);
183            $link = "<a href=\"" . $link . "\">" . $this->lng->txt("test_using_template_link") . "</a>";
184
185            $msgHTML = ilUtil::getSystemMessageHTML(
186                sprintf($this->lng->txt("test_using_template"), $title, $link),
187                "info"
188            );
189
190            $msgHTML = "<div style=\"margin-top:10px\">$msgHTML</div>";
191        } else {
192            $msgHTML = '';
193        }
194
195        return $msgHTML;
196    }
197
198    private function confirmedSaveFormCmd()
199    {
200        return $this->saveFormCmd(true);
201    }
202
203    private function saveFormCmd($isConfirmedSave = false)
204    {
205        $form = $this->buildForm();
206
207        // form validation and initialisation
208
209        if ($isConfirmedSave) {
210            // since confirmation does only pickup POST and no FILES
211            // mocking the tile image file upload field is neccessary
212            // due to checkInput() behaviour (fixes mantis #24226)
213            $_FILES['tile_image'] = array(
214                'name' => '', 'type' => '', 'size' => '', 'tmp_name' => '', 'error' => ''
215            );
216
217            // TODO: get rid of question selection mode setting in settings form (move to creation screen)
218        }
219
220        $errors = !$form->checkInput(); // ALWAYS CALL BEFORE setValuesByPost()
221        $form->setValuesByPost(); // NEVER CALL THIS BEFORE checkInput()
222                                    // Sarcasm? No. Because checkInput checks the form graph against the POST without
223                                    // actually setting the values into the form. Sounds ridiculous? Indeed, and it is.
224
225        // return to form when any form validation errors exist
226
227        if ($errors) {
228            ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
229            return $this->showFormCmd($form);
230        }
231
232        // return to form when online is to be set, but no questions are configured
233
234        $currentQuestionSetConfig = $this->testQuestionSetConfigFactory->getQuestionSetConfig();
235        if ($form->getItemByPostVar('online')->getChecked() && !$this->testOBJ->isComplete($currentQuestionSetConfig)) {
236            $form->getItemByPostVar('online')->setAlert(
237                $this->lng->txt("cannot_switch_to_online_no_questions_andor_no_mark_steps")
238            );
239
240            ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
241            return $this->showFormCmd($form);
242        }
243
244        // avoid settings conflict "ctm" and "do not show question titles"
245
246        $qstSetSetting = $form->getItemByPostVar('question_set_type');
247        $qTitleSetting = $form->getItemByPostVar('title_output');
248
249        if ($qstSetSetting->getValue() == ilObjTest::QUESTION_SET_TYPE_DYNAMIC && $qTitleSetting->getValue() == 2) {
250            $qstSetSetting->setAlert($this->lng->txt('tst_conflicting_setting'));
251            $qTitleSetting->setAlert($this->lng->txt('tst_conflicting_setting'));
252
253            ilUtil::sendFailure($this->lng->txt('tst_settings_conflict_message'));
254            return $this->showFormCmd($form);
255        }
256
257        // avoid settings conflict "obligate questions" and "freeze answer"
258
259        $obligationsSetting = $form->getItemByPostVar('obligations_enabled');
260        $answerFixationSetting = $form->getItemByPostVar('answer_fixation_handling');
261
262        if ($obligationsSetting->getChecked() && $answerFixationSetting->getValue() != self::ANSWER_FIXATION_NONE) {
263            $obligationsSetting->setAlert($this->lng->txt('tst_conflicting_setting'));
264            $answerFixationSetting->setAlert($this->lng->txt('tst_conflicting_setting'));
265
266            ilUtil::sendFailure($this->lng->txt('tst_settings_conflict_message'));
267            return $this->showFormCmd($form);
268        }
269
270        // avoid settings conflict "freeze answer on followup question" and "question postponing"
271
272        $postponeSetting = $form->getItemByPostVar('postpone');
273        $answerFixationSetting = $form->getItemByPostVar('answer_fixation_handling');
274        $conflictModes = array(self::ANSWER_FIXATION_ON_FOLLOWUP_QUESTION, self::ANSWER_FIXATION_ON_IFB_OR_FUQST);
275
276        if ($postponeSetting->getValue() && in_array($answerFixationSetting->getValue(), $conflictModes)) {
277            $postponeSetting->setAlert($this->lng->txt('tst_conflicting_setting'));
278            $answerFixationSetting->setAlert($this->lng->txt('tst_conflicting_setting'));
279
280            ilUtil::sendFailure($this->lng->txt('tst_settings_conflict_message'));
281            return $this->showFormCmd($form);
282        }
283
284        // avoid settings conflict "freeze answer on followup question" and "question shuffling"
285
286        $shuffleSetting = $form->getItemByPostVar('chb_shuffle_questions');
287        $answerFixationSetting = $form->getItemByPostVar('answer_fixation_handling');
288        $conflictModes = array(self::ANSWER_FIXATION_ON_FOLLOWUP_QUESTION, self::ANSWER_FIXATION_ON_IFB_OR_FUQST);
289
290        if ($shuffleSetting->getChecked() && in_array($answerFixationSetting->getValue(), $conflictModes)) {
291            $shuffleSetting->setAlert($this->lng->txt('tst_conflicting_setting'));
292            $answerFixationSetting->setAlert($this->lng->txt('tst_conflicting_setting'));
293
294            ilUtil::sendFailure($this->lng->txt('tst_settings_conflict_message'));
295            return $this->showFormCmd($form);
296        }
297
298        $infoMsg = array();
299
300        // solve conflicts with question set type setting with confirmation screen if required
301        // determine wether question set type relating data is to be removed (questions/pools)
302
303        $questionSetTypeRelatingDataCleanupRequired = false;
304
305        $oldQuestionSetType = $this->testOBJ->getQuestionSetType();
306        if ($form->getItemByPostVar('question_set_type') instanceof ilFormPropertyGUI) {
307            $newQuestionSetType = $form->getItemByPostVar('question_set_type')->getValue();
308
309            if (!$this->testOBJ->participantDataExist() && $newQuestionSetType != $oldQuestionSetType) {
310                $oldQuestionSetConfig = $this->testQuestionSetConfigFactory->getQuestionSetConfigByType(
311                    $oldQuestionSetType
312                );
313
314                if ($oldQuestionSetConfig->doesQuestionSetRelatedDataExist()) {
315                    if (!$isConfirmedSave) {
316                        if ($oldQuestionSetType == ilObjTest::QUESTION_SET_TYPE_FIXED) {
317                            return $this->showConfirmation(
318                                $form,
319                                $oldQuestionSetType,
320                                $newQuestionSetType,
321                                $this->testOBJ->hasQuestionsWithoutQuestionpool()
322                            );
323                        }
324
325                        return $this->showConfirmation(
326                            $form,
327                            $oldQuestionSetType,
328                            $newQuestionSetType,
329                            false
330                        );
331                    }
332
333                    $questionSetTypeRelatingDataCleanupRequired = true;
334                }
335
336                if ($form->getItemByPostVar('online')->getChecked()) {
337                    $form->getItemByPostVar('online')->setChecked(false);
338
339                    if (!$this->testOBJ->getOfflineStatus()) {
340                        $infoMsg[] = $this->lng->txt("tst_set_offline_due_to_switched_question_set_type_setting");
341                    } else {
342                        $infoMsg[] = $this->lng->txt("tst_cannot_online_due_to_switched_quest_set_type_setting");
343                    }
344                }
345            }
346        } else {
347            $newQuestionSetType = $oldQuestionSetType;
348        }
349
350        // adjust settings due to chosen question set type
351
352        if ($newQuestionSetType != ilObjTest::QUESTION_SET_TYPE_FIXED) {
353            $form->getItemByPostVar('chb_use_previous_answers')->setChecked(false);
354        }
355
356        // perform saving the form data
357
358        $this->performSaveForm($form);
359
360        // clean up test mode relating configuration data (questions/questionpools)
361
362        if ($questionSetTypeRelatingDataCleanupRequired) {
363            $oldQuestionSetConfig->removeQuestionSetRelatedData();
364        }
365
366        // disinvite all invited users if required
367
368        if (!$this->testOBJ->participantDataExist() && !$this->testOBJ->getFixedParticipants()) {
369            foreach ($this->testOBJ->getInvitedUsers() as $usrId => $usrData) {
370                $this->testOBJ->disinviteUser($usrId);
371            }
372        }
373
374        // redirect to form output
375
376        if (count($infoMsg)) {
377            ilUtil::sendInfo(implode('<br />', $infoMsg), true);
378        }
379
380        ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
381        $this->ctrl->redirect($this, self::CMD_SHOW_FORM);
382    }
383
384    /**
385     * Enable all settings - Confirmation
386     */
387    private function showResetTemplateConfirmationCmd()
388    {
389        require_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
390        $confirmationGUI = new ilConfirmationGUI();
391
392        $confirmationGUI->setFormAction($this->ctrl->getFormAction($this));
393        $confirmationGUI->setHeaderText($this->lng->txt("test_confirm_template_reset"));
394        $confirmationGUI->setCancel($this->lng->txt('cancel'), self::CMD_SHOW_FORM);
395        $confirmationGUI->setConfirm($this->lng->txt('confirm'), self::CMD_CONFIRMED_RESET_TPL);
396
397        $this->tpl->setContent($this->ctrl->getHTML($confirmationGUI));
398    }
399
400    /**
401     * Enable all settings - remove template
402     */
403    private function confirmedResetTemplateCmd()
404    {
405        $this->testOBJ->setTemplate(null);
406        $this->testOBJ->saveToDB();
407
408        ilUtil::sendSuccess($this->lng->txt("test_template_reset"), true);
409        $this->ctrl->redirect($this, self::CMD_SHOW_FORM);
410    }
411
412    private function isSkillServiceSettingToBeAdjusted(ilPropertyFormGUI $form)
413    {
414        if (!($form->getItemByPostVar('skill_service') instanceof ilFormPropertyGUI)) {
415            return false;
416        }
417
418        if (!ilObjTest::isSkillManagementGloballyActivated()) {
419            return false;
420        }
421
422        if (!$form->getItemByPostVar('skill_service')->getChecked()) {
423            return false;
424        }
425
426        return true;
427    }
428
429    private function isCharSelectorPropertyRequired()
430    {
431        global $DIC;
432        $ilSetting = $DIC['ilSetting'];
433
434        return $ilSetting->get('char_selector_availability') > 0;
435    }
436
437
438    private function buildForm()
439    {
440        require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
441        $form = new ilPropertyFormGUI();
442        $form->setFormAction($this->ctrl->getFormAction($this));
443        $form->addCommandButton(self::CMD_SAVE_FORM, $this->lng->txt("save"));
444        $form->setTableWidth("100%");
445        $form->setId("test_properties");
446
447        $this->addGeneralProperties($form);
448        $this->addAvailabilityProperties($form);
449        $this->addPresentationProperties($form);
450        $this->addTestIntroProperties($form);
451        $this->addTestAccessProperties($form);
452        $this->addTestRunProperties($form);
453        $this->addQuestionBehaviourProperties($form);
454        $this->addTestSequenceProperties($form);
455        $this->addTestFinishProperties($form);
456
457        // Edit ecs export settings
458        include_once 'Modules/Test/classes/class.ilECSTestSettings.php';
459        $ecs = new ilECSTestSettings($this->testOBJ);
460        $ecs->addSettingsToForm($form, 'tst');
461
462        // additional features
463
464        $orgunitServiceActive = ilOrgUnitGlobalSettings::getInstance()->getObjectPositionSettingsByType(
465            $this->testOBJ->getType()
466        )->isActive();
467
468        $skillServiceActive = ilObjTest::isSkillManagementGloballyActivated();
469
470
471        if ($orgunitServiceActive || $skillServiceActive) {
472            $otherHead = new ilFormSectionHeaderGUI();
473            $otherHead->setTitle($this->lng->txt('obj_features'));
474            $form->addItem($otherHead);
475        }
476
477        require_once 'Services/Object/classes/class.ilObjectServiceSettingsGUI.php';
478        ilObjectServiceSettingsGUI::initServiceSettingsForm($this->testOBJ->getId(), $form, array(
479                ilObjectServiceSettingsGUI::ORGU_POSITION_ACCESS
480        ));
481
482        // skill service activation for FIXED tests only
483        if ($skillServiceActive) {
484            $skillService = new ilCheckboxInputGUI($this->lng->txt('tst_activate_skill_service'), 'skill_service');
485            $skillService->setInfo($this->lng->txt('tst_activate_skill_service_desc'));
486            $skillService->setChecked($this->testOBJ->isSkillServiceEnabled());
487            if ($this->testOBJ->participantDataExist()) {
488                $skillService->setDisabled(true);
489            }
490            $form->addItem($skillService);
491        }
492
493        // remove items when using template
494        $this->removeHiddenItems($form);
495
496        return $form;
497    }
498
499    private function performSaveForm(ilPropertyFormGUI $form)
500    {
501        $this->saveGeneralProperties($form);
502        $this->savePresentationProperties($form);
503        $this->saveAvailabilityProperties($form);
504        $this->saveTestIntroProperties($form);
505        $this->saveTestAccessProperties($form);
506        $this->saveTestRunProperties($form);
507        $this->saveQuestionBehaviourProperties($form);
508        $this->saveTestSequenceSettings($form);
509        $this->saveTestFinishProperties($form);
510
511        if (!$this->testOBJ->participantDataExist()) {
512            // skill service
513            if (ilObjTest::isSkillManagementGloballyActivated() && $form->getItemByPostVar('skill_service') instanceof ilFormPropertyGUI) {
514                $this->testOBJ->setSkillServiceEnabled($form->getItemByPostVar('skill_service')->getChecked());
515            }
516        }
517
518        require_once 'Services/Object/classes/class.ilObjectServiceSettingsGUI.php';
519        ilObjectServiceSettingsGUI::updateServiceSettingsForm($this->testOBJ->getId(), $form, array(
520            ilObjectServiceSettingsGUI::ORGU_POSITION_ACCESS
521        ));
522
523        // store settings to db
524        $this->testOBJ->saveToDb(true);
525
526        // Update ecs export settings
527        include_once 'Modules/Test/classes/class.ilECSTestSettings.php';
528        $ecs = new ilECSTestSettings($this->testOBJ);
529        $ecs->handleSettingsUpdate();
530    }
531
532    /**
533     * @param ilPropertyFormGUI $form
534     */
535    private function addGeneralProperties(ilPropertyFormGUI $form)
536    {
537        $header = new ilFormSectionHeaderGUI();
538        $header->setTitle($this->lng->txt("tst_general_properties"));
539        $form->addItem($header);
540
541        // title & description (meta data)
542
543        include_once 'Services/MetaData/classes/class.ilMD.php';
544        $md_obj = new ilMD($this->testOBJ->getId(), 0, "tst");
545        $md_section = $md_obj->getGeneral();
546
547        $title = new ilTextInputGUI($this->lng->txt("title"), "title");
548        $title->setRequired(true);
549        $title->setValue($md_section->getTitle());
550        $form->addItem($title);
551
552        $ids = $md_section->getDescriptionIds();
553        if ($ids) {
554            $desc_obj = $md_section->getDescription(array_pop($ids));
555
556            $desc = new ilTextAreaInputGUI($this->lng->txt("description"), "description");
557            $desc->setCols(50);
558            $desc->setRows(4);
559            $desc->setValue($desc_obj->getDescription());
560            $form->addItem($desc);
561        }
562
563        // pool usage
564        $pool_usage = new ilRadioGroupInputGUI($this->lng->txt('test_question_pool_usage'), 'use_pool');
565
566        $optional_qpl = new ilRadioOption($this->lng->txt('test_question_pool_usage_optional'), 1);
567        $optional_qpl->setInfo($this->lng->txt('test_question_pool_usage_optional_info'));
568        $pool_usage->addOption($optional_qpl);
569
570        $tst_directly = new ilRadioOption($this->lng->txt('test_question_pool_usage_tst_directly'), 0);
571        $tst_directly->setInfo($this->lng->txt('test_question_pool_usage_tst_directly_info'));
572        $pool_usage->addOption($tst_directly);
573
574        $pool_usage->setValue($this->testOBJ->getPoolUsage() ? 1 : 0);
575        $form->addItem($pool_usage);
576
577        // test mode (question set type)
578        $questSetType = new ilRadioGroupInputGUI($this->lng->txt("tst_question_set_type"), 'question_set_type');
579        $questSetTypeFixed = new ilRadioOption(
580            $this->lng->txt("tst_question_set_type_fixed"),
581            ilObjTest::QUESTION_SET_TYPE_FIXED,
582            $this->lng->txt("tst_question_set_type_fixed_desc")
583        );
584        $questSetType->addOption($questSetTypeFixed);
585        $questSetTypeRandom = new ilRadioOption(
586            $this->lng->txt("tst_question_set_type_random"),
587            ilObjTest::QUESTION_SET_TYPE_RANDOM,
588            $this->lng->txt("tst_question_set_type_random_desc")
589        );
590        $questSetType->addOption($questSetTypeRandom);
591        $questSetTypeContinues = new ilRadioOption(
592            $this->lng->txt("tst_question_set_type_dynamic"),
593            ilObjTest::QUESTION_SET_TYPE_DYNAMIC,
594            $this->lng->txt("tst_question_set_type_dynamic_desc")
595        );
596        $questSetType->addOption($questSetTypeContinues);
597        $questSetType->setValue($this->testOBJ->getQuestionSetType());
598        if ($this->testOBJ->participantDataExist()) {
599            $questSetType->setDisabled(true);
600        }
601        $form->addItem($questSetType);
602
603        // anonymity
604        $anonymity = new ilRadioGroupInputGUI($this->lng->txt('tst_anonymity'), 'anonymity');
605        if ($this->testOBJ->participantDataExist()) {
606            $anonymity->setDisabled(true);
607        }
608        $rb = new ilRadioOption($this->lng->txt('tst_anonymity_no_anonymization'), 0);
609        $anonymity->addOption($rb);
610        $rb = new ilRadioOption($this->lng->txt('tst_anonymity_anonymous_test'), 1);
611        $anonymity->addOption($rb);
612        $anonymity->setValue((int) $this->testOBJ->getAnonymity());
613        $form->addItem($anonymity);
614    }
615
616    /**
617     * @param ilPropertyFormGUI $form
618     */
619    private function saveGeneralProperties(ilPropertyFormGUI $form)
620    {
621        include_once 'Services/MetaData/classes/class.ilMD.php';
622        $md_obj = new ilMD($this->testOBJ->getId(), 0, "tst");
623        $md_section = $md_obj->getGeneral();
624
625        // title
626        $md_section->setTitle(ilUtil::stripSlashes($form->getItemByPostVar('title')->getValue()));
627        $md_section->update();
628
629        // Description
630        $md_desc_ids = $md_section->getDescriptionIds();
631        if ($md_desc_ids) {
632            $md_desc = $md_section->getDescription(array_pop($md_desc_ids));
633            $md_desc->setDescription(ilUtil::stripSlashes($form->getItemByPostVar('description')->getValue()));
634            $md_desc->update();
635        } else {
636            $md_desc = $md_section->addDescription();
637            $md_desc->setDescription(ilUtil::stripSlashes($form->getItemByPostVar('description')->getValue()));
638            $md_desc->save();
639        }
640
641        $this->testOBJ->setTitle(ilUtil::stripSlashes($form->getItemByPostVar('title')->getValue()));
642        $this->testOBJ->setDescription(ilUtil::stripSlashes($form->getItemByPostVar('description')->getValue()));
643        $this->testOBJ->setOfflineStatus(!$form->getItemByPostVar('online')->getChecked());
644        $this->testOBJ->update();
645
646        // pool usage setting
647        if ($form->getItemByPostVar('use_pool') instanceof ilFormPropertyGUI) {
648            $this->testOBJ->setPoolUsage((int) $form->getItemByPostVar('use_pool')->getValue());
649        }
650
651        if (!$this->testOBJ->participantDataExist()) {
652            // question set type
653            if ($form->getItemByPostVar('question_set_type') instanceof ilFormPropertyGUI) {
654                $this->testOBJ->setQuestionSetType($form->getItemByPostVar('question_set_type')->getValue());
655            }
656        }
657
658        // anonymity setting
659        if (!$this->testOBJ->participantDataExist() && $this->formPropertyExists($form, 'anonymity')) {
660            $this->testOBJ->setAnonymity($form->getItemByPostVar('anonymity')->getValue());
661        }
662    }
663
664    /**
665     * @param ilPropertyFormGUI $form
666     */
667    private function addAvailabilityProperties(ilPropertyFormGUI $form)
668    {
669        include_once "Services/Object/classes/class.ilObjectActivation.php";
670        $this->lng->loadLanguageModule('rep');
671
672        $section = new ilFormSectionHeaderGUI();
673        $section->setTitle($this->lng->txt('rep_activation_availability'));
674        $form->addItem($section);
675
676        // additional info only with multiple references
677        $act_obj_info = $act_ref_info = "";
678        if (sizeof(ilObject::_getAllReferences($this->testOBJ->getId())) > 1) {
679            $act_obj_info = ' ' . $this->lng->txt('rep_activation_online_object_info');
680            $act_ref_info = $this->lng->txt('rep_activation_access_ref_info');
681        }
682
683        $online = new ilCheckboxInputGUI($this->lng->txt('rep_activation_online'), 'online');
684        $online->setChecked(!$this->testOBJ->getOfflineStatus());
685        $online->setInfo($this->lng->txt('tst_activation_online_info') . $act_obj_info);
686        $form->addItem($online);
687
688        $act_type = new ilCheckboxInputGUI($this->lng->txt('rep_visibility_until'), 'activation_type');
689        $act_type->setChecked($this->testOBJ->isActivationLimited());
690        // $act_type->setInfo($this->lng->txt('tst_availability_until_info'));
691
692        include_once "Services/Form/classes/class.ilDateDurationInputGUI.php";
693        $dur = new ilDateDurationInputGUI($this->lng->txt("rep_time_period"), "access_period");
694        $dur->setRequired(true);
695        $dur->setShowTime(true);
696        $date = $this->testOBJ->getActivationStartingTime();
697        $dur->setStart(new ilDateTime($date ? $date : time(), IL_CAL_UNIX));
698        $dur->setStartText($this->lng->txt('rep_activation_limited_start'));
699        $date = $this->testOBJ->getActivationEndingTime();
700        $dur->setEnd(new ilDateTime($date ? $date : time(), IL_CAL_UNIX));
701        $dur->setEndText($this->lng->txt('rep_activation_limited_end'));
702        $act_type->addSubItem($dur);
703
704        $visible = new ilCheckboxInputGUI($this->lng->txt('rep_activation_limited_visibility'), 'activation_visibility');
705        $visible->setInfo($this->lng->txt('tst_activation_limited_visibility_info'));
706        $visible->setChecked($this->testOBJ->getActivationVisibility());
707        $act_type->addSubItem($visible);
708
709        $form->addItem($act_type);
710    }
711
712    /**
713     * @param ilPropertyFormGUI $form
714     */
715    private function saveAvailabilityProperties(ilPropertyFormGUI $form)
716    {
717        // activation
718        if ($form->getItemByPostVar('activation_type')->getChecked()) {
719            $this->testOBJ->setActivationLimited(true);
720            $this->testOBJ->setActivationVisibility($form->getItemByPostVar('activation_visibility')->getChecked());
721
722            $period = $form->getItemByPostVar("access_period");
723            $this->testOBJ->setActivationStartingTime($period->getStart()->get(IL_CAL_UNIX));
724            $this->testOBJ->setActivationEndingTime($period->getEnd()->get(IL_CAL_UNIX));
725        } else {
726            $this->testOBJ->setActivationLimited(false);
727        }
728    }
729
730    /**
731     * @param ilPropertyFormGUI $form
732     */
733    protected function addPresentationProperties(ilPropertyFormGUI $form)
734    {
735        global $DIC; /* @var ILIAS\DI\Container $DIC */
736
737        $section = new ilFormSectionHeaderGUI();
738        $section->setTitle($this->lng->txt('tst_presentation_settings_section'));
739        $form->addItem($section);
740
741        $DIC->object()->commonSettings()->legacyForm($form, $this->testOBJ)->addTileImage();
742    }
743
744    /**
745     * @param ilPropertyFormGUI $form
746     */
747    protected function savePresentationProperties(ilPropertyFormGUI $form)
748    {
749        global $DIC; /* @var ILIAS\DI\Container $DIC */
750
751        $DIC->object()->commonSettings()->legacyForm($form, $this->testOBJ)->saveTileImage();
752    }
753
754    /**
755     * @param ilPropertyFormGUI $form
756     */
757    private function addTestIntroProperties(ilPropertyFormGUI $form)
758    {
759        $section = new ilFormSectionHeaderGUI();
760        $section->setTitle($this->lng->txt('tst_settings_header_intro'));
761        $form->addItem($section);
762
763        // introduction
764        $introEnabled = new ilCheckboxInputGUI($this->lng->txt("tst_introduction"), 'intro_enabled');
765        $introEnabled->setChecked($this->testOBJ->isIntroductionEnabled());
766        $introEnabled->setInfo($this->lng->txt('tst_introduction_desc'));
767        $form->addItem($introEnabled);
768        $intro = new ilTextAreaInputGUI($this->lng->txt("tst_introduction_text"), "introduction");
769        $intro->setRequired(true);
770        $intro->setValue($this->testOBJ->prepareTextareaOutput($this->testOBJ->getIntroduction(), false, true));
771        $intro->setRows(10);
772        $intro->setCols(80);
773        $intro->setUseRte(true);
774        $intro->addPlugin("latex");
775        $intro->addButton("latex");
776        $intro->setRTESupport($this->testOBJ->getId(), "tst", "assessment");
777        $intro->setRteTagSet('full');
778        $introEnabled->addSubItem($intro);
779
780        // showinfo
781        $showinfo = new ilCheckboxInputGUI($this->lng->txt("showinfo"), "showinfo");
782        $showinfo->setValue(1);
783        $showinfo->setChecked($this->testOBJ->getShowInfo());
784        $showinfo->setInfo($this->lng->txt("showinfo_desc"));
785        $form->addItem($showinfo);
786    }
787
788    /**
789     * @param ilPropertyFormGUI $form
790     */
791    private function saveTestIntroProperties(ilPropertyFormGUI $form)
792    {
793        if ($form->getItemByPostVar('intro_enabled') instanceof ilFormPropertyGUI) {
794            $this->testOBJ->setIntroductionEnabled($form->getItemByPostVar('intro_enabled')->getChecked());
795
796            if ($form->getItemByPostVar('intro_enabled')->getChecked()) {
797                $this->testOBJ->setIntroduction($form->getItemByPostVar('introduction')->getValue());
798            } else {
799                $this->testOBJ->setIntroduction('');
800            }
801        }
802
803        if ($form->getItemByPostVar('showinfo') instanceof ilFormPropertyGUI) {
804            $this->testOBJ->setShowInfo($form->getItemByPostVar('showinfo')->getChecked());
805        }
806    }
807
808    /**
809     * @param ilPropertyFormGUI $form
810     */
811    private function addTestAccessProperties(ilPropertyFormGUI $form)
812    {
813        $header = new ilFormSectionHeaderGUI();
814        $header->setTitle($this->lng->txt("tst_settings_header_execution"));
815        $form->addItem($header);
816
817        // starting time
818        $startingtime = new ilDateTimeInputGUI($this->lng->txt("tst_starting_time"), 'starting_time');
819        $startingtime->setInfo($this->lng->txt("tst_starting_time_desc"));
820        $startingtime->setShowTime(true);
821        if ($this->testOBJ->getStartingTime() != 0) {
822            $startingtime->setDate(new ilDateTime($this->testOBJ->getStartingTime(), IL_CAL_UNIX));
823        } else {
824            $startingtime->setDate(null);
825        }
826
827        $form->addItem($startingtime);
828        if ($this->testOBJ->participantDataExist()) {
829            $startingtime->setDisabled(true);
830        }
831
832        // ending time
833        $endingtime = new ilDateTimeInputGUI($this->lng->txt("tst_ending_time"), 'ending_time');
834        $endingtime->setInfo($this->lng->txt("tst_ending_time_desc"));
835        $endingtime->setShowTime(true);
836        if ($this->testOBJ->getEndingTime() != 0) {
837            $endingtime->setDate(new ilDateTime($this->testOBJ->getEndingTime(), IL_CAL_UNIX));
838        } else {
839            $endingtime->setDate(null);
840        }
841        $form->addItem($endingtime);
842
843        // test password
844        $pwEnabled = new ilCheckboxInputGUI($this->lng->txt('tst_password'), 'password_enabled');
845        $pwEnabled->setChecked($this->testOBJ->isPasswordEnabled());
846        $pwEnabled->setInfo($this->lng->txt("tst_password_details"));
847        $password = new ilTextInputGUI($this->lng->txt("tst_password_enter"), "password");
848        $password->setRequired(true);
849        $password->setSize(20);
850        $password->setMaxLength(20);
851        $password->setValue($this->testOBJ->getPassword());
852        $pwEnabled->addSubItem($password);
853        $form->addItem($pwEnabled);
854
855        // fixed participants
856        $fixedparticipants = new ilCheckboxInputGUI($this->lng->txt('participants_invitation'), "fixedparticipants");
857        $fixedparticipants->setValue(1);
858        $fixedparticipants->setChecked($this->testOBJ->getFixedParticipants());
859        $fixedparticipants->setInfo($this->lng->txt("participants_invitation_description"));
860        if ($this->testOBJ->participantDataExist()) {
861            $fixedparticipants->setDisabled(true);
862        }
863        $form->addItem($fixedparticipants);
864
865        // simultaneous users
866        $simulLimited = new ilCheckboxInputGUI($this->lng->txt("tst_allowed_users"), 'limitUsers');
867        $simulLimited->setInfo($this->lng->txt("tst_allowed_users_desc"));
868        $simulLimited->setChecked($this->testOBJ->isLimitUsersEnabled());
869
870        // allowed simultaneous users
871        $simul = new ilNumberInputGUI($this->lng->txt("tst_allowed_users_max"), "allowedUsers");
872        $simul->setRequired(true);
873        $simul->allowDecimals(false);
874        $simul->setMinValue(1);
875        $simul->setMinvalueShouldBeGreater(false);
876        $simul->setSize(4);
877        $simul->setValue(($this->testOBJ->getAllowedUsers()) ? $this->testOBJ->getAllowedUsers() : '');
878        $simulLimited->addSubItem($simul);
879
880        // idle time
881        $idle = new ilNumberInputGUI($this->lng->txt("tst_allowed_users_time_gap"), "allowedUsersTimeGap");
882        $idle->setInfo($this->lng->txt("tst_allowed_users_time_gap_desc"));
883        $idle->setSize(4);
884        $idle->setSuffix($this->lng->txt("seconds"));
885        $idle->setValue(($this->testOBJ->getAllowedUsersTimeGap()) ? $this->testOBJ->getAllowedUsersTimeGap() : 300);
886        $simulLimited->addSubItem($idle);
887
888        $form->addItem($simulLimited);
889        return $header;
890    }
891
892    /**
893     * @param ilPropertyFormGUI $form
894     */
895    private function saveTestAccessProperties(ilPropertyFormGUI $form)
896    {
897        if (!$this->testOBJ->participantDataExist()) {
898            // starting time
899            $starting_time = $form->getItemByPostVar('starting_time')->getDate();
900            if ($starting_time instanceof ilDateTime) {
901                $this->testOBJ->setStartingTime($starting_time->getUnixtime());
902                $this->testOBJ->setStartingTimeEnabled(true);
903            } else {
904                $this->testOBJ->setStartingTime(null);
905                $this->testOBJ->setStartingTimeEnabled(false);
906            }
907        }
908
909        // ending time
910        $ending_time = $form->getItemByPostVar('ending_time')->getDate();
911        if ($ending_time instanceof ilDateTime) {
912            $this->testOBJ->setEndingTime($ending_time->getUnixtime());
913            $this->testOBJ->setEndingTimeEnabled(true);
914        } else {
915            $this->testOBJ->setEndingTime(null);
916            $this->testOBJ->setEndingTimeEnabled(false);
917        }
918
919        if ($this->formPropertyExists($form, 'password_enabled')) {
920            $this->testOBJ->setPasswordEnabled($form->getItemByPostVar('password_enabled')->getChecked());
921
922            if ($form->getItemByPostVar('password_enabled')->getChecked()) {
923                $this->testOBJ->setPassword($form->getItemByPostVar('password')->getValue());
924            } else {
925                $this->testOBJ->setPassword(''); // otherwise test will still respect value
926            }
927        }
928
929        if ($this->formPropertyExists($form, 'fixedparticipants') && !$this->testOBJ->participantDataExist()) {
930            $this->testOBJ->setFixedParticipants($form->getItemByPostVar('fixedparticipants')->getChecked());
931        }
932
933        if ($this->formPropertyExists($form, 'limitUsers')) {
934            $this->testOBJ->setLimitUsersEnabled($form->getItemByPostVar('limitUsers')->getChecked());
935
936            if ($form->getItemByPostVar('limitUsers')->getChecked()) {
937                $this->testOBJ->setAllowedUsers($form->getItemByPostVar('allowedUsers')->getValue());
938                $this->testOBJ->setAllowedUsersTimeGap($form->getItemByPostVar('allowedUsersTimeGap')->getValue());
939            } else {
940                $this->testOBJ->setAllowedUsers(''); // otherwise test will still respect value
941            }
942        }
943    }
944
945    /**
946     * @param ilPropertyFormGUI $form
947     */
948    private function addTestRunProperties(ilPropertyFormGUI $form)
949    {
950        // section header test run
951        $header = new ilFormSectionHeaderGUI();
952        $header->setTitle($this->lng->txt("tst_settings_header_test_run"));
953        $form->addItem($header);
954
955        // max. number of passes
956        $limitPasses = new ilCheckboxInputGUI($this->lng->txt("tst_limit_nr_of_tries"), 'limitPasses');
957        $limitPasses->setInfo($this->lng->txt("tst_nr_of_tries_desc"));
958        $limitPasses->setChecked($this->testOBJ->getNrOfTries() > 0);
959        $nr_of_tries = new ilNumberInputGUI($this->lng->txt("tst_nr_of_tries"), "nr_of_tries");
960        $nr_of_tries->setSize(3);
961        $nr_of_tries->allowDecimals(false);
962        $nr_of_tries->setMinValue(1);
963        $nr_of_tries->setMinvalueShouldBeGreater(false);
964        $nr_of_tries->setValue($this->testOBJ->getNrOfTries() ? $this->testOBJ->getNrOfTries() : 1);
965        $nr_of_tries->setRequired(true);
966        $limitPasses->addSubItem($nr_of_tries);
967        $blockAfterPassed = new ilCheckboxInputGUI(
968            $this->lng->txt('tst_block_passes_after_passed'),
969            'block_after_passed'
970        );
971        $blockAfterPassed->setInfo($this->lng->txt('tst_block_passes_after_passed_info'));
972        $blockAfterPassed->setChecked($this->testOBJ->isBlockPassesAfterPassedEnabled());
973        $limitPasses->addSubItem($blockAfterPassed);
974        if ($this->testOBJ->participantDataExist()) {
975            $limitPasses->setDisabled(true);
976            $blockAfterPassed->setDisabled(true);
977            $nr_of_tries->setDisabled(true);
978        }
979        $form->addItem($limitPasses);
980
981        // pass_waiting time between testruns
982        $pass_waiting_enabled = new ilCheckboxInputGUI($this->lng->txt('tst_pass_waiting_enabled'), 'pass_waiting_enabled');
983        $pass_waiting_enabled->setInfo($this->lng->txt('tst_pass_waiting_info'));
984        $pass_waiting_enabled->setChecked($this->testOBJ->isPassWaitingEnabled());
985
986        // pass_waiting
987        $duration = new ilDurationInputGUI($this->lng->txt("tst_pass_waiting_time"), "pass_waiting");
988
989        $duration->setShowMonths(true);
990        $duration->setShowDays(true);
991        $duration->setShowHours(true);
992        $duration->setShowMinutes(true);
993
994        $pw_time_array = explode(':', $this->testOBJ->getPassWaiting());
995        $duration->setMonths($pw_time_array[0]);
996        $duration->setDays($pw_time_array[1]);
997        $duration->setHours($pw_time_array[2]);
998        $duration->setMinutes($pw_time_array[3]);
999        $duration->setRequired(false);
1000        $pass_waiting_enabled->addSubItem($duration);
1001
1002        $form->addItem($pass_waiting_enabled);
1003
1004        // enable max. processing time
1005        $processing = new ilCheckboxInputGUI($this->lng->txt("tst_processing_time"), "chb_processing_time");
1006        $processing->setInfo($this->lng->txt("tst_processing_time_desc"));
1007        $processing->setValue(1);
1008
1009        if ($this->settingsTemplate && $this->getTemplateSettingValue('chb_processing_time')) {
1010            $processing->setChecked(true);
1011        } else {
1012            $processing->setChecked($this->testOBJ->getEnableProcessingTime());
1013        }
1014
1015        // max. processing time
1016        $processingtime = new ilNumberInputGUI($this->lng->txt("tst_processing_time_duration"), 'processing_time');
1017        $processingtime->allowDecimals(false);
1018        $processingtime->setMinValue(1);
1019        $processingtime->setMinvalueShouldBeGreater(false);
1020        $processingtime->setValue($this->testOBJ->getProcessingTimeAsMinutes());
1021        $processingtime->setSize(5);
1022        $processingtime->setSuffix($this->lng->txt('minutes'));
1023        $processingtime->setInfo($this->lng->txt("tst_processing_time_duration_desc"));
1024        $processing->addSubItem($processingtime);
1025
1026        // reset max. processing time
1027        $resetprocessing = new ilCheckboxInputGUI('', "chb_reset_processing_time");
1028        $resetprocessing->setValue(1);
1029        $resetprocessing->setOptionTitle($this->lng->txt("tst_reset_processing_time"));
1030        $resetprocessing->setChecked($this->testOBJ->getResetProcessingTime());
1031        $resetprocessing->setInfo($this->lng->txt("tst_reset_processing_time_desc"));
1032        $processing->addSubItem($resetprocessing);
1033        $form->addItem($processing);
1034
1035        if ($this->testOBJ->participantDataExist()) {
1036            $processing->setDisabled(true);
1037            $processingtime->setDisabled(true);
1038            $resetprocessing->setDisabled(true);
1039
1040            $duration->setDisabled(true);
1041            $pass_waiting_enabled->setDisabled(true);
1042        }
1043
1044        // kiosk mode
1045        $kiosk = new ilCheckboxInputGUI($this->lng->txt("kiosk"), "kiosk");
1046        $kiosk->setValue(1);
1047        $kiosk->setChecked($this->testOBJ->getKioskMode());
1048        $kiosk->setInfo($this->lng->txt("kiosk_description"));
1049
1050        // kiosk mode options
1051        $kiosktitle = new ilCheckboxGroupInputGUI($this->lng->txt("kiosk_options"), "kiosk_options");
1052        $kiosktitle->addOption(new ilCheckboxOption($this->lng->txt("kiosk_show_title"), 'kiosk_title', ''));
1053        $kiosktitle->addOption(new ilCheckboxOption($this->lng->txt("kiosk_show_participant"), 'kiosk_participant', ''));
1054        $values = array();
1055        if ($this->testOBJ->getShowKioskModeTitle()) {
1056            array_push($values, 'kiosk_title');
1057        }
1058        if ($this->testOBJ->getShowKioskModeParticipant()) {
1059            array_push($values, 'kiosk_participant');
1060        }
1061        $kiosktitle->setValue($values);
1062        $kiosktitle->setInfo($this->lng->txt("kiosk_options_desc"));
1063        $kiosk->addSubItem($kiosktitle);
1064
1065        $form->addItem($kiosk);
1066
1067        $examIdInPass = new ilCheckboxInputGUI($this->lng->txt('examid_in_test_pass'), 'examid_in_test_pass');
1068        $examIdInPass->setInfo($this->lng->txt('examid_in_test_pass_desc'));
1069        $examIdInPass->setChecked($this->testOBJ->isShowExamIdInTestPassEnabled());
1070        $form->addItem($examIdInPass);
1071    }
1072
1073    /**
1074     * @param ilPropertyFormGUI $form
1075     */
1076    private function saveTestRunProperties(ilPropertyFormGUI $form)
1077    {
1078        if (!$this->testOBJ->participantDataExist()) {
1079            // nr of tries (max passes)
1080            if ($form->getItemByPostVar('limitPasses') instanceof ilFormPropertyGUI) {
1081                if ($form->getItemByPostVar('limitPasses')->getChecked()) {
1082                    $this->testOBJ->setNrOfTries($form->getItemByPostVar('nr_of_tries')->getValue());
1083
1084                    $this->testOBJ->setBlockPassesAfterPassedEnabled(
1085                        (bool) $form->getItemByPostVar('block_after_passed')->getChecked()
1086                    );
1087                } else {
1088                    $this->testOBJ->setNrOfTries(0);
1089                    $this->testOBJ->setBlockPassesAfterPassedEnabled(false);
1090                }
1091            }
1092
1093            // pass_waiting
1094            if ($form->getItemByPostVar('pass_waiting_enabled') instanceof ilFormPropertyGUI) {
1095                if ($form->getItemByPostVar('pass_waiting_enabled')->getChecked()) {
1096                    $pass_waiting_values = $form->getItemByPostVar('pass_waiting');
1097
1098                    $pass_waiting_duration[] = sprintf("%'.02d", $pass_waiting_values->getMonths());
1099                    $pass_waiting_duration[] = sprintf("%'.03d", $pass_waiting_values->getDays());
1100                    $pass_waiting_duration[] = sprintf("%'.02d", $pass_waiting_values->getHours());
1101                    $pass_waiting_duration[] = sprintf("%'.02d", $pass_waiting_values->getMinutes());
1102                    $pass_waiting_duration[] = sprintf("%'.02d", $pass_waiting_values->getSeconds());
1103
1104                    $pass_waiting_string = implode(':', $pass_waiting_duration);
1105                    $this->testOBJ->setPassWaiting($pass_waiting_string);
1106                } else {
1107                    $this->testOBJ->setPassWaiting("00:000:00:00:00");
1108                }
1109            }
1110
1111            $this->testOBJ->setEnableProcessingTime($form->getItemByPostVar('chb_processing_time')->getChecked());
1112            if ($this->testOBJ->getEnableProcessingTime()) {
1113                $this->testOBJ->setProcessingTimeByMinutes($form->getItemByPostVar('processing_time')->getValue());
1114                $this->testOBJ->setResetProcessingTime($form->getItemByPostVar('chb_reset_processing_time')->getChecked());
1115            } else {
1116                $this->testOBJ->setProcessingTime('');
1117                $this->testOBJ->setResetProcessingTime(false);
1118            }
1119        }
1120
1121        if ($form->getItemByPostVar('kiosk') instanceof ilFormPropertyGUI) {
1122            $this->testOBJ->setKioskMode($form->getInput('kiosk'));
1123            $kioskOptions = $form->getItemByPostVar('kiosk_options')->getValue();
1124            if (is_array($kioskOptions)) {
1125                $this->testOBJ->setShowKioskModeTitle(in_array('kiosk_title', $kioskOptions));
1126                $this->testOBJ->setShowKioskModeParticipant(in_array('kiosk_participant', $kioskOptions));
1127            } else {
1128                $this->testOBJ->setShowKioskModeTitle(false);
1129                $this->testOBJ->setShowKioskModeParticipant(false);
1130            }
1131        }
1132
1133        if ($form->getItemByPostVar('examid_in_test_pass') instanceof ilFormPropertyGUI) {
1134            $value = $form->getItemByPostVar('examid_in_test_pass')->getChecked();
1135            $this->testOBJ->setShowExamIdInTestPassEnabled($value);
1136        }
1137    }
1138
1139    /**
1140     * @param ilPropertyFormGUI $form
1141     */
1142    private function addQuestionBehaviourProperties(ilPropertyFormGUI $form)
1143    {
1144        $fields = array(
1145            'title_output', 'autosave', 'chb_shuffle_questions', 'chb_shuffle_questions',
1146            'offer_hints', 'instant_feedback_contents', 'instant_feedback_trigger',
1147            'answer_fixation_handling', 'obligations_enabled'
1148        );
1149
1150        if ($this->isSectionHeaderRequired($fields) || $this->isCharSelectorPropertyRequired()) {
1151            // sequence properties
1152            $seqheader = new ilFormSectionHeaderGUI();
1153            $seqheader->setTitle($this->lng->txt("tst_presentation_properties"));
1154            $form->addItem($seqheader);
1155        }
1156
1157        // question title output
1158        $title_output = new ilRadioGroupInputGUI($this->lng->txt("tst_title_output"), "title_output");
1159        $title_output->addOption(new ilRadioOption($this->lng->txt("tst_title_output_full"), 0, ''));
1160        $title_output->addOption(new ilRadioOption($this->lng->txt("tst_title_output_hide_points"), 1, ''));
1161        $title_output->addOption(new ilRadioOption($this->lng->txt("tst_title_output_no_title"), 2, ''));
1162        $title_output->setValue($this->testOBJ->getTitleOutput());
1163        $form->addItem($title_output);
1164
1165        // Autosave
1166        $autosave_output = new ilCheckboxInputGUI($this->lng->txt('autosave'), 'autosave');
1167        $autosave_output->setValue(1);
1168        $autosave_output->setChecked($this->testOBJ->getAutosave());
1169        $autosave_output->setInfo($this->lng->txt('autosave_info'));
1170        $autosave_interval = new ilTextInputGUI($this->lng->txt('autosave_ival'), 'autosave_ival');
1171        $autosave_interval->setSize(10);
1172        $autosave_interval->setValue($this->testOBJ->getAutosaveIval() / 1000);
1173        $autosave_interval->setSuffix($this->lng->txt('seconds'));
1174        $autosave_output->addSubItem($autosave_interval);
1175        $form->addItem($autosave_output);
1176
1177        // shuffle questions
1178        $shuffle = new ilCheckboxInputGUI($this->lng->txt("tst_shuffle_questions"), "chb_shuffle_questions");
1179        $shuffle->setValue(1);
1180        $shuffle->setChecked($this->testOBJ->getShuffleQuestions());
1181        $shuffle->setInfo($this->lng->txt("tst_shuffle_questions_description"));
1182        $form->addItem($shuffle);
1183
1184        // offer hints
1185        $checkBoxOfferHints = new ilCheckboxInputGUI($this->lng->txt('tst_setting_offer_hints_label'), 'offer_hints');
1186        $checkBoxOfferHints->setChecked($this->testOBJ->isOfferingQuestionHintsEnabled());
1187        $checkBoxOfferHints->setInfo($this->lng->txt('tst_setting_offer_hints_info'));
1188        $form->addItem($checkBoxOfferHints);
1189
1190        // instant feedback
1191        $instant_feedback_enabled = new ilCheckboxInputGUI($this->lng->txt('tst_instant_feedback'), 'instant_feedback_enabled');
1192        $instant_feedback_enabled->setInfo($this->lng->txt('tst_instant_feedback_desc'));
1193        $instant_feedback_enabled->setChecked($this->testOBJ->isAnyInstantFeedbackOptionEnabled());
1194        $form->addItem($instant_feedback_enabled);
1195        $instant_feedback_contents = new ilCheckboxGroupInputGUI($this->lng->txt('tst_instant_feedback_contents'), 'instant_feedback_contents');
1196        $instant_feedback_contents->setRequired(true);
1197        $instant_feedback_contents->addOption(new ilCheckboxOption(
1198            $this->lng->txt('tst_instant_feedback_results'),
1199            'instant_feedback_points',
1200            $this->lng->txt('tst_instant_feedback_results_desc')
1201        ));
1202        $instant_feedback_contents->addOption(new ilCheckboxOption(
1203            $this->lng->txt('tst_instant_feedback_answer_generic'),
1204            'instant_feedback_generic',
1205            $this->lng->txt('tst_instant_feedback_answer_generic_desc')
1206        ));
1207        $instant_feedback_contents->addOption(new ilCheckboxOption(
1208            $this->lng->txt('tst_instant_feedback_answer_specific'),
1209            'instant_feedback_specific',
1210            $this->lng->txt('tst_instant_feedback_answer_specific_desc')
1211        ));
1212        $instant_feedback_contents->addOption(new ilCheckboxOption(
1213            $this->lng->txt('tst_instant_feedback_solution'),
1214            'instant_feedback_solution',
1215            $this->lng->txt('tst_instant_feedback_solution_desc')
1216        ));
1217        $instant_feedback_contents->setValue($this->testOBJ->getInstantFeedbackOptionsAsArray());
1218        $instant_feedback_enabled->addSubItem($instant_feedback_contents);
1219        $instant_feedback_trigger = new ilRadioGroupInputGUI(
1220            $this->lng->txt('tst_instant_feedback_trigger'),
1221            'instant_feedback_trigger'
1222        );
1223        $ifbTriggerOpt = new ilRadioOption(
1224            $this->lng->txt('tst_instant_feedback_trigger_manual'),
1225            self::INSTANT_FEEDBACK_TRIGGER_MANUAL
1226        );
1227        $ifbTriggerOpt->setInfo($this->lng->txt('tst_instant_feedback_trigger_manual_desc'));
1228        $instant_feedback_trigger->addOption($ifbTriggerOpt);
1229        $ifbTriggerOpt = new ilRadioOption(
1230            $this->lng->txt('tst_instant_feedback_trigger_forced'),
1231            self::INSTANT_FEEDBACK_TRIGGER_FORCED
1232        );
1233        $ifbTriggerOpt->setInfo($this->lng->txt('tst_instant_feedback_trigger_forced_desc'));
1234        $instant_feedback_trigger->addOption($ifbTriggerOpt);
1235        $instant_feedback_trigger->setValue($this->testOBJ->isForceInstantFeedbackEnabled());
1236        $instant_feedback_enabled->addSubItem($instant_feedback_trigger);
1237
1238        $answerFixation = new ilRadioGroupInputGUI(
1239            $this->lng->txt('tst_answer_fixation_handling'),
1240            'answer_fixation_handling'
1241        );
1242        $radioOption = new ilRadioOption(
1243            $this->lng->txt('tst_answer_fixation_none'),
1244            self::ANSWER_FIXATION_NONE
1245        );
1246        $radioOption->setInfo($this->lng->txt('tst_answer_fixation_none_desc'));
1247        $answerFixation->addOption($radioOption);
1248        $radioOption = new ilRadioOption(
1249            $this->lng->txt('tst_answer_fixation_on_instant_feedback'),
1250            self::ANSWER_FIXATION_ON_INSTANT_FEEDBACK
1251        );
1252        $radioOption->setInfo($this->lng->txt('tst_answer_fixation_on_instant_feedback_desc'));
1253        $answerFixation->addOption($radioOption);
1254        $radioOption = new ilRadioOption(
1255            $this->lng->txt('tst_answer_fixation_on_followup_question'),
1256            self::ANSWER_FIXATION_ON_FOLLOWUP_QUESTION
1257        );
1258        $radioOption->setInfo($this->lng->txt('tst_answer_fixation_on_followup_question_desc'));
1259        $answerFixation->addOption($radioOption);
1260        $radioOption = new ilRadioOption(
1261            $this->lng->txt('tst_answer_fixation_on_instantfb_or_followupqst'),
1262            self::ANSWER_FIXATION_ON_IFB_OR_FUQST
1263        );
1264        $radioOption->setInfo($this->lng->txt('tst_answer_fixation_on_instantfb_or_followupqst_desc'));
1265        $answerFixation->addOption($radioOption);
1266        $answerFixation->setValue($this->getAnswerFixationSettingsAsFormValue());
1267        $form->addItem($answerFixation);
1268
1269        // enable obligations
1270        $checkBoxEnableObligations = new ilCheckboxInputGUI($this->lng->txt('tst_setting_enable_obligations_label'), 'obligations_enabled');
1271        $checkBoxEnableObligations->setChecked($this->testOBJ->areObligationsEnabled());
1272        $checkBoxEnableObligations->setInfo($this->lng->txt('tst_setting_enable_obligations_info'));
1273        $form->addItem($checkBoxEnableObligations);
1274
1275        // selector for unicode characters
1276        if ($this->isCharSelectorPropertyRequired()) {
1277            require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
1278            $char_selector = new ilCharSelectorGUI(ilCharSelectorConfig::CONTEXT_TEST);
1279            $char_selector->getConfig()->setAvailability($this->testOBJ->getCharSelectorAvailability());
1280            $char_selector->getConfig()->setDefinition($this->testOBJ->getCharSelectorDefinition());
1281            $char_selector->addFormProperties($form);
1282            $char_selector->setFormValues($form);
1283        }
1284
1285        if ($this->testOBJ->participantDataExist()) {
1286            $checkBoxOfferHints->setDisabled(true);
1287            $instant_feedback_enabled->setDisabled(true);
1288            $instant_feedback_trigger->setDisabled(true);
1289            $instant_feedback_contents->setDisabled(true);
1290            $answerFixation->setDisabled(true);
1291            $checkBoxEnableObligations->setDisabled(true);
1292        }
1293    }
1294
1295    /**
1296     * @param ilPropertyFormGUI $form
1297     */
1298    private function saveQuestionBehaviourProperties(ilPropertyFormGUI $form)
1299    {
1300        if ($form->getItemByPostVar('title_output') instanceof ilFormPropertyGUI) {
1301            $this->testOBJ->setTitleOutput($form->getItemByPostVar('title_output')->getValue());
1302        }
1303
1304        if ($form->getItemByPostVar('autosave') instanceof ilFormPropertyGUI) {
1305            $this->testOBJ->setAutosave($form->getItemByPostVar('autosave')->getChecked());
1306            $this->testOBJ->setAutosaveIval($form->getItemByPostVar('autosave_ival')->getValue() * 1000);
1307        }
1308
1309        if ($form->getItemByPostVar('chb_shuffle_questions') instanceof ilFormPropertyGUI) {
1310            $this->testOBJ->setShuffleQuestions($form->getItemByPostVar('chb_shuffle_questions')->getChecked());
1311        }
1312
1313        if (!$this->testOBJ->participantDataExist() && $this->formPropertyExists($form, 'offer_hints')) {
1314            $this->testOBJ->setOfferingQuestionHintsEnabled($form->getItemByPostVar('offer_hints')->getChecked());
1315        }
1316
1317        if (!$this->testOBJ->participantDataExist() && $this->formPropertyExists($form, 'instant_feedback_enabled')) {
1318            if ($form->getItemByPostVar('instant_feedback_enabled')->getChecked()) {
1319                if ($this->formPropertyExists($form, 'instant_feedback_contents')) {
1320                    $this->testOBJ->setInstantFeedbackOptionsByArray(
1321                        $form->getItemByPostVar('instant_feedback_contents')->getValue()
1322                    );
1323                }
1324                if ($this->formPropertyExists($form, 'instant_feedback_trigger')) {
1325                    $this->testOBJ->setForceInstantFeedbackEnabled(
1326                        (bool) $form->getItemByPostVar('instant_feedback_trigger')->getValue()
1327                    );
1328                }
1329            } else {
1330                $this->testOBJ->setInstantFeedbackOptionsByArray(array());
1331                $this->testOBJ->setForceInstantFeedbackEnabled(false);
1332            }
1333        }
1334
1335        if (!$this->testOBJ->participantDataExist() && $this->formPropertyExists($form, 'answer_fixation_handling')) {
1336            $this->setAnswerFixationSettingsByFormValue($form->getItemByPostVar('answer_fixation_handling')->getValue());
1337        }
1338
1339        if (!$this->testOBJ->participantDataExist() && $this->formPropertyExists($form, 'obligations_enabled')) {
1340            $this->testOBJ->setObligationsEnabled($form->getItemByPostVar('obligations_enabled')->getChecked());
1341        }
1342
1343        if ($this->isCharSelectorPropertyRequired()) {
1344            require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
1345            $char_selector = new ilCharSelectorGUI(ilCharSelectorConfig::CONTEXT_TEST);
1346            $char_selector->addFormProperties($form);
1347            $char_selector->getFormValues($form);
1348            $this->testOBJ->setCharSelectorAvailability($char_selector->getConfig()->getAvailability());
1349            $this->testOBJ->setCharSelectorDefinition($char_selector->getConfig()->getDefinition());
1350        }
1351    }
1352
1353    /**
1354     * @param ilPropertyFormGUI $form
1355     */
1356    private function addTestSequenceProperties(ilPropertyFormGUI $form)
1357    {
1358        // sequence properties
1359        $seqheader = new ilFormSectionHeaderGUI();
1360        $seqheader->setTitle($this->lng->txt("tst_sequence_properties"));
1361        $form->addItem($seqheader);
1362
1363        // use previous answers
1364        $prevanswers = new ilCheckboxInputGUI($this->lng->txt("tst_use_previous_answers"), "chb_use_previous_answers");
1365        $prevanswers->setValue(1);
1366        $prevanswers->setChecked($this->testOBJ->getUsePreviousAnswers());
1367        $prevanswers->setInfo($this->lng->txt("tst_use_previous_answers_description"));
1368        $form->addItem($prevanswers);
1369
1370        // show suspend test
1371        $cancel = new ilCheckboxInputGUI($this->lng->txt("tst_show_cancel"), "chb_show_cancel");
1372        $cancel->setValue(1);
1373        $cancel->setChecked($this->testOBJ->getShowCancel());
1374        $cancel->setInfo($this->lng->txt("tst_show_cancel_description"));
1375        $form->addItem($cancel);
1376
1377        // postpone questions
1378        $postpone = new ilRadioGroupInputGUI($this->lng->txt("tst_postpone"), "postpone");
1379        $postpone->addOption(new ilRadioOption(
1380            $this->lng->txt("tst_postpone_off"),
1381            0,
1382            $this->lng->txt("tst_postpone_off_desc")
1383        ));
1384        $postpone->addOption(new ilRadioOption(
1385            $this->lng->txt("tst_postpone_on"),
1386            1,
1387            $this->lng->txt("tst_postpone_on_desc")
1388        ));
1389        $postpone->setValue((int) $this->testOBJ->getSequenceSettings());
1390        $form->addItem($postpone);
1391
1392        // show list of questions
1393        $list_of_questions = new ilCheckboxInputGUI($this->lng->txt("tst_show_summary"), "list_of_questions");
1394        //$list_of_questions->setOptionTitle($this->lng->txt("tst_show_summary"));
1395        $list_of_questions->setValue(1);
1396        $list_of_questions->setChecked($this->testOBJ->getListOfQuestions());
1397        $list_of_questions->setInfo($this->lng->txt("tst_show_summary_description"));
1398
1399        $list_of_questions_options = new ilCheckboxGroupInputGUI('', "list_of_questions_options");
1400        $list_of_questions_options->addOption(new ilCheckboxOption($this->lng->txt("tst_list_of_questions_start"), 'chb_list_of_questions_start', ''));
1401        $list_of_questions_options->addOption(new ilCheckboxOption($this->lng->txt("tst_list_of_questions_end"), 'chb_list_of_questions_end', ''));
1402        $list_of_questions_options->addOption(new ilCheckboxOption($this->lng->txt("tst_list_of_questions_with_description"), 'chb_list_of_questions_with_description', ''));
1403        $values = array();
1404        if ($this->testOBJ->getListOfQuestionsStart()) {
1405            array_push($values, 'chb_list_of_questions_start');
1406        }
1407        if ($this->testOBJ->getListOfQuestionsEnd()) {
1408            array_push($values, 'chb_list_of_questions_end');
1409        }
1410        if ($this->testOBJ->getListOfQuestionsDescription()) {
1411            array_push($values, 'chb_list_of_questions_with_description');
1412        }
1413        $list_of_questions_options->setValue($values);
1414
1415        $list_of_questions->addSubItem($list_of_questions_options);
1416        $form->addItem($list_of_questions);
1417
1418        // show question marking
1419        $marking = new ilCheckboxInputGUI($this->lng->txt("question_marking"), "chb_show_marker");
1420        $marking->setValue(1);
1421        $marking->setChecked($this->testOBJ->getShowMarker());
1422        $marking->setInfo($this->lng->txt("question_marking_description"));
1423        $form->addItem($marking);
1424    }
1425
1426    /**
1427     * @param ilPropertyFormGUI $form
1428     */
1429    private function saveTestSequenceSettings(ilPropertyFormGUI $form)
1430    {
1431        if ($this->formPropertyExists($form, 'chb_use_previous_answers')) {
1432            $this->testOBJ->setUsePreviousAnswers($form->getInput('chb_use_previous_answers'));
1433        }
1434
1435        if ($this->formPropertyExists($form, 'chb_show_cancel')) {
1436            $this->testOBJ->setShowCancel($form->getItemByPostVar('chb_show_cancel')->getChecked());
1437        }
1438
1439        if ($this->formPropertyExists($form, 'postpone')) {
1440            $this->testOBJ->setPostponingEnabled((bool) $form->getItemByPostVar('postpone')->getValue());
1441        }
1442
1443        $this->testOBJ->setListOfQuestions($form->getItemByPostVar('list_of_questions')->getChecked());
1444        $listOfQuestionsOptions = $form->getItemByPostVar('list_of_questions_options')->getValue();
1445        if (is_array($listOfQuestionsOptions)) {
1446            $this->testOBJ->setListOfQuestionsStart(in_array('chb_list_of_questions_start', $listOfQuestionsOptions));
1447            $this->testOBJ->setListOfQuestionsEnd(in_array('chb_list_of_questions_end', $listOfQuestionsOptions));
1448            $this->testOBJ->setListOfQuestionsDescription(in_array('chb_list_of_questions_with_description', $listOfQuestionsOptions));
1449        } else {
1450            $this->testOBJ->setListOfQuestionsStart(0);
1451            $this->testOBJ->setListOfQuestionsEnd(0);
1452            $this->testOBJ->setListOfQuestionsDescription(0);
1453        }
1454
1455        if ($this->formPropertyExists($form, 'chb_show_marker')) {
1456            $this->testOBJ->setShowMarker($form->getItemByPostVar('chb_show_marker')->getChecked());
1457        }
1458    }
1459
1460    /**
1461     * @param ilPropertyFormGUI $form
1462     */
1463    private function addTestFinishProperties(ilPropertyFormGUI $form)
1464    {
1465        $testFinishHeader = new ilFormSectionHeaderGUI();
1466        $testFinishHeader->setTitle($this->lng->txt("tst_final_information"));
1467        $form->addItem($testFinishHeader);
1468
1469        // examview
1470        $enable_examview = new ilCheckboxInputGUI($this->lng->txt("enable_examview"), 'enable_examview');
1471        $enable_examview->setValue(1);
1472        $enable_examview->setChecked($this->testOBJ->getEnableExamview());
1473        $enable_examview->setInfo($this->lng->txt("enable_examview_desc"));
1474        $show_examview_pdf = new ilCheckboxInputGUI('', 'show_examview_pdf');
1475        $show_examview_pdf->setValue(1);
1476        $show_examview_pdf->setChecked($this->testOBJ->getShowExamviewPdf());
1477        $show_examview_pdf->setOptionTitle($this->lng->txt("show_examview_pdf"));
1478        $enable_examview->addSubItem($show_examview_pdf);
1479        $form->addItem($enable_examview);
1480
1481        // show final statement
1482        $showfinal = new ilCheckboxInputGUI($this->lng->txt("final_statement"), "showfinalstatement");
1483        $showfinal->setChecked($this->testOBJ->getShowFinalStatement());
1484        $showfinal->setInfo($this->lng->txt("final_statement_show_desc"));
1485        $form->addItem($showfinal);
1486        // final statement
1487        $finalstatement = new ilTextAreaInputGUI($this->lng->txt("final_statement"), "finalstatement");
1488        $finalstatement->setRequired(true);
1489        $finalstatement->setValue($this->testOBJ->prepareTextareaOutput($this->testOBJ->getFinalStatement(), false, true));
1490        $finalstatement->setRows(10);
1491        $finalstatement->setCols(80);
1492        $finalstatement->setUseRte(true);
1493        $finalstatement->addPlugin("latex");
1494        $finalstatement->addButton("latex");
1495        $finalstatement->setRTESupport($this->testOBJ->getId(), "tst", "assessment");
1496        $finalstatement->setRteTagSet('full');
1497        $showfinal->addSubItem($finalstatement);
1498
1499        $redirection_mode = $this->testOBJ->getRedirectionMode();
1500        $rm_enabled = new ilCheckboxInputGUI($this->lng->txt('redirect_after_finishing_tst'), 'redirection_enabled');
1501        $rm_enabled->setInfo($this->lng->txt('redirect_after_finishing_tst_desc'));
1502        $rm_enabled->setChecked($redirection_mode == '0' ? false : true);
1503        $radio_rm = new ilRadioGroupInputGUI($this->lng->txt('redirect_after_finishing_rule'), 'redirection_mode');
1504        $always = new ilRadioOption($this->lng->txt('redirect_always'), REDIRECT_ALWAYS);
1505        $radio_rm->addOption($always);
1506        $kiosk = new ilRadioOption($this->lng->txt('redirect_in_kiosk_mode'), REDIRECT_KIOSK);
1507        $radio_rm->addOption($kiosk);
1508        $radio_rm->setValue(in_array($redirection_mode, array(REDIRECT_ALWAYS, REDIRECT_KIOSK)) ? $redirection_mode : REDIRECT_ALWAYS);
1509        $rm_enabled->addSubItem($radio_rm);
1510        $redirection_url = new ilTextInputGUI($this->lng->txt('redirection_url'), 'redirection_url');
1511        $redirection_url->setValue((string) $this->testOBJ->getRedirectionUrl());
1512        $redirection_url->setRequired(true);
1513        $rm_enabled->addSubItem($redirection_url);
1514
1515        $form->addItem($rm_enabled);
1516
1517        // Sign submission
1518        $sign_submission = $this->testOBJ->getSignSubmission();
1519        $sign_submission_enabled = new ilCheckboxInputGUI($this->lng->txt('sign_submission'), 'sign_submission');
1520        $sign_submission_enabled->setChecked($sign_submission);
1521        $sign_submission_enabled->setInfo($this->lng->txt('sign_submission_info'));
1522        $form->addItem($sign_submission_enabled);
1523
1524        // mail notification
1525        $mailnotification = new ilCheckboxInputGUI($this->lng->txt("tst_finish_notification"), "mailnotification");
1526        $mailnotification->setInfo($this->lng->txt("tst_finish_notification_desc"));
1527        $mailnotification->setChecked($this->testOBJ->getMailNotification() > 0);
1528        $form->addItem($mailnotification);
1529
1530        $mailnotificationContent = new ilRadioGroupInputGUI($this->lng->txt("tst_finish_notification_content"), "mailnotification_content");
1531        $mailnotificationContent->addOption(new ilRadioOption($this->lng->txt("tst_finish_notification_simple"), 1, ''));
1532        $mailnotificationContent->addOption(new ilRadioOption($this->lng->txt("tst_finish_notification_advanced"), 2, ''));
1533        $mailnotificationContent->setValue($this->testOBJ->getMailNotification() ? $this->testOBJ->getMailNotification() : 1);
1534        $mailnotificationContent->setRequired(true);
1535        $mailnotification->addSubItem($mailnotificationContent);
1536
1537        $mailnottype = new ilCheckboxInputGUI('', "mailnottype");
1538        $mailnottype->setValue(1);
1539        $mailnottype->setOptionTitle($this->lng->txt("mailnottype"));
1540        $mailnottype->setChecked($this->testOBJ->getMailNotificationType());
1541        $mailnotification->addSubItem($mailnottype);
1542    }
1543
1544    /**
1545     * @param ilPropertyFormGUI $form
1546     */
1547    private function saveTestFinishProperties(ilPropertyFormGUI $form)
1548    {
1549        if ($this->formPropertyExists($form, 'enable_examview')) {
1550            $this->testOBJ->setEnableExamview($form->getItemByPostVar('enable_examview')->getChecked());
1551            $this->testOBJ->setShowExamviewPdf($form->getItemByPostVar('show_examview_pdf')->getChecked());
1552        }
1553
1554        $this->testOBJ->setShowFinalStatement($form->getItemByPostVar('showfinalstatement')->getChecked());
1555        $this->testOBJ->setFinalStatement($form->getItemByPostVar('finalstatement')->getValue());
1556
1557        if ($form->getItemByPostVar('redirection_enabled')->getChecked()) {
1558            $this->testOBJ->setRedirectionMode($form->getItemByPostVar('redirection_mode')->getValue());
1559        } else {
1560            $this->testOBJ->setRedirectionMode(REDIRECT_NONE);
1561        }
1562        if (strlen($form->getItemByPostVar('redirection_url')->getValue())) {
1563            $this->testOBJ->setRedirectionUrl($form->getItemByPostVar('redirection_url')->getValue());
1564        } else {
1565            $this->testOBJ->setRedirectionUrl(null);
1566        }
1567
1568        if ($this->formPropertyExists($form, 'sign_submission')) {
1569            $this->testOBJ->setSignSubmission($form->getItemByPostVar('sign_submission')->getChecked());
1570        }
1571
1572        if ($this->formPropertyExists($form, 'mailnotification') && $form->getItemByPostVar('mailnotification')->getChecked()) {
1573            $this->testOBJ->setMailNotification($form->getItemByPostVar('mailnotification_content')->getValue());
1574            $this->testOBJ->setMailNotificationType($form->getItemByPostVar('mailnottype')->getChecked());
1575        } else {
1576            $this->testOBJ->setMailNotification(0);
1577            $this->testOBJ->setMailNotificationType(false);
1578        }
1579    }
1580
1581    protected function setAnswerFixationSettingsByFormValue($formValue)
1582    {
1583        switch ($formValue) {
1584            case self::ANSWER_FIXATION_NONE:
1585                $this->testOBJ->setInstantFeedbackAnswerFixationEnabled(false);
1586                $this->testOBJ->setFollowupQuestionAnswerFixationEnabled(false);
1587                break;
1588            case self::ANSWER_FIXATION_ON_INSTANT_FEEDBACK:
1589                $this->testOBJ->setInstantFeedbackAnswerFixationEnabled(true);
1590                $this->testOBJ->setFollowupQuestionAnswerFixationEnabled(false);
1591                break;
1592            case self::ANSWER_FIXATION_ON_FOLLOWUP_QUESTION:
1593                $this->testOBJ->setInstantFeedbackAnswerFixationEnabled(false);
1594                $this->testOBJ->setFollowupQuestionAnswerFixationEnabled(true);
1595                break;
1596            case self::ANSWER_FIXATION_ON_IFB_OR_FUQST:
1597                $this->testOBJ->setInstantFeedbackAnswerFixationEnabled(true);
1598                $this->testOBJ->setFollowupQuestionAnswerFixationEnabled(true);
1599                break;
1600        }
1601    }
1602
1603    protected function getAnswerFixationSettingsAsFormValue()
1604    {
1605        if ($this->testOBJ->isInstantFeedbackAnswerFixationEnabled() && $this->testOBJ->isFollowupQuestionAnswerFixationEnabled()) {
1606            return self::ANSWER_FIXATION_ON_IFB_OR_FUQST;
1607        }
1608
1609        if ($this->testOBJ->isFollowupQuestionAnswerFixationEnabled()) {
1610            return self::ANSWER_FIXATION_ON_FOLLOWUP_QUESTION;
1611        }
1612
1613        if ($this->testOBJ->isInstantFeedbackAnswerFixationEnabled()) {
1614            return self::ANSWER_FIXATION_ON_INSTANT_FEEDBACK;
1615        }
1616
1617        return self::ANSWER_FIXATION_NONE;
1618    }
1619}
1620