ILIAS  Release_4_4_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 
16 {
20  const CMD_SHOW_FORM = 'showForm';
21  const CMD_SAVE_FORM = 'saveForm';
22  const CMD_CONFIRMED_SAVE_FORM = 'confirmedSaveForm';
23  const CMD_SHOW_RESET_TPL_CONFIRM = 'showResetTemplateConfirmation';
24  const CMD_CONFIRMED_RESET_TPL = 'confirmedResetTemplate';
25 
27  protected $ctrl = null;
28 
30  protected $access = null;
31 
33  protected $lng = null;
34 
36  protected $tpl = null;
37 
39  protected $tree = null;
40 
42  protected $db = null;
43 
45  protected $pluginAdmin = null;
46 
48  protected $activeUser = null;
49 
51  protected $testOBJ = null;
52 
54  protected $testGUI = null;
55 
58 
64  protected $settingsTemplate = null;
65 
74  private $participantDataExist = null;
75 
88  public function __construct(
89  ilCtrl $ctrl,
93  ilTree $tree,
94  ilDB $db,
98  )
99  {
100  $this->ctrl = $ctrl;
101  $this->access = $access;
102  $this->lng = $lng;
103  $this->tpl = $tpl;
104  $this->tree = $tree;
105  $this->db = $db;
106  $this->pluginAdmin = $pluginAdmin;
107  $this->activeUser = $activeUser;
108 
109  $this->testGUI = $testGUI;
110  $this->testOBJ = $testGUI->object;
111 
112  require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
113  $this->testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($this->tree, $this->db, $this->pluginAdmin, $this->testOBJ);
114 
115  $templateId = $this->testOBJ->getTemplate();
116 
117  if( $templateId )
118  {
119  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
120  $this->settingsTemplate = new ilSettingsTemplate($templateId, ilObjAssessmentFolderGUI::getSettingsTemplateConfig());
121  }
122  }
123 
127  public function executeCommand()
128  {
129  // allow only write access
130 
131  if (!$this->access->checkAccess("write", "", $this->testGUI->ref_id))
132  {
133  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
134  $this->ctrl->redirect($this->testGUI, "infoScreen");
135  }
136 
137  // process command
138 
139  $nextClass = $this->ctrl->getNextClass();
140 
141  switch($nextClass)
142  {
143  default:
144  $cmd = $this->ctrl->getCmd(self::CMD_SHOW_FORM).'Cmd';
145  $this->$cmd();
146  }
147  }
148 
149  private function showFormCmd(ilPropertyFormGUI $form = null)
150  {
151  $this->tpl->addJavascript("./Services/JavaScript/js/Basic.js");
152 
153  if( $form === null )
154  {
155  $form = $this->buildForm();
156  }
157 
158  $formHTML = $this->ctrl->getHTML($form);
159  $msgHTML = $this->getSettingsTemplateMessageHTML();
160 
161  $this->tpl->setContent($formHTML.$msgHTML);
162  }
163 
164  private function confirmedSaveFormCmd()
165  {
166  return $this->saveFormCmd(true);
167  }
168 
170  {
171  $fields = array('act_starting_time', 'act_ending_time', 'starting_time', 'ending_time');
172 
173  foreach($fields as $field)
174  {
175  if( !($form->getItemByPostVar($field) instanceof ilFormPropertyGUI) )
176  {
177  continue;
178  }
179 
180  if( !$form->getItemByPostVar($field)->getDisabled() )
181  {
182  continue;
183  }
184 
185  unset($_POST[$field]);
186  }
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()
197  $form->setValuesByPost(); // NEVER CALL THIS BEFORE checkInput()
198  // Sarcasm? No. Because checkInput checks the form graph against the POST without
199  // actually setting the values into the form. Sounds ridiculous? Indeed, and it is.
200 
201  // return to form when any form validation errors exist
202 
203  if($errors)
204  {
205  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
206  return $this->showFormCmd($form);
207  }
208 
209  // return to form when online is to be set, but no questions are configured
210 
211  $currentQuestionSetConfig = $this->testQuestionSetConfigFactory->getQuestionSetConfig();
212  if( $form->getItemByPostVar('online')->getChecked() && !$this->testOBJ->isComplete($currentQuestionSetConfig) )
213  {
214  $form->getItemByPostVar('online')->setAlert(
215  $this->lng->txt("cannot_switch_to_online_no_questions_andor_no_mark_steps")
216  );
217 
218  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
219  return $this->showFormCmd($form);
220  }
221 
222  // solve conflicts with question set type setting with confirmation screen if required
223  // determine wether question set type relating data is to be removed (questions/pools)
224 
225  $questionSetTypeRelatingDataCleanupRequired = false;
226 
227  if( $form->getItemByPostVar('question_set_type') instanceof ilFormPropertyGUI )
228  {
229  $oldQuestionSetType = $this->testOBJ->getQuestionSetType();
230  $newQuestionSetType = $form->getItemByPostVar('question_set_type')->getValue();
231 
232  if( !$this->testOBJ->participantDataExist() && $newQuestionSetType != $oldQuestionSetType )
233  {
234  $oldQuestionSetConfig = $this->testQuestionSetConfigFactory->getQuestionSetConfigByType(
235  $oldQuestionSetType
236  );
237 
238  if( $oldQuestionSetConfig->doesQuestionSetRelatedDataExist() )
239  {
240  if( !$isConfirmedSave )
241  {
242  if( $oldQuestionSetType == ilObjTest::QUESTION_SET_TYPE_FIXED )
243  {
244  return $this->showConfirmation(
245  $form, $oldQuestionSetType, $newQuestionSetType,
246  $this->testOBJ->hasQuestionsWithoutQuestionpool()
247  );
248  }
249 
250  return $this->showConfirmation(
251  $form, $oldQuestionSetType, $newQuestionSetType, false
252  );
253  }
254 
255  $questionSetTypeRelatingDataCleanupRequired = true;
256  }
257 
258  if( $form->getItemByPostVar('online')->getChecked() )
259  {
260  $form->getItemByPostVar('online')->setChecked(false);
261 
262  if( $this->testOBJ->isOnline() )
263  {
264  $infoMsg = $this->lng->txt("tst_set_offline_due_to_switched_question_set_type_setting");
265  }
266  else
267  {
268  $infoMsg = $this->lng->txt("tst_cannot_online_due_to_switched_quest_set_type_setting");
269  }
270 
271  ilUtil::sendInfo($infoMsg, true);
272  }
273  }
274  }
275 
276  // adjust use previous answers setting due to desired question set type
277 
278  if( $newQuestionSetType != ilObjTest::QUESTION_SET_TYPE_FIXED )
279  {
280  $form->getItemByPostVar('chb_use_previous_answers')->setValue(0);
281  }
282 
283  // perform saving the form data
284 
285  $this->performSaveForm($form);
286 
287  // clean up test mode relating configuration data (questions/questionpools)
288 
289  if( $questionSetTypeRelatingDataCleanupRequired )
290  {
291  $oldQuestionSetConfig->removeQuestionSetRelatedData();
292  }
293 
294  // disinvite all invited users if required
295 
296  if( !$this->testOBJ->participantDataExist() && !$this->testOBJ->getFixedParticipants() )
297  {
298  foreach ($this->testOBJ->getInvitedUsers() as $usrId => $usrData)
299  {
300  $this->testOBJ->disinviteUser($usrId);
301  }
302  }
303 
304  // redirect to form output
305 
306  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
307  $this->ctrl->redirect($this, self::CMD_SHOW_FORM);
308  }
309 
310  private function performSaveForm(ilPropertyFormGUI $form)
311  {
312  include_once 'Services/MetaData/classes/class.ilMD.php';
313  $md_obj =& new ilMD($this->testOBJ->getId(), 0, "tst");
314  $md_section = $md_obj->getGeneral();
315 
316  // title
317  $md_section->setTitle(ilUtil::stripSlashes($form->getItemByPostVar('title')->getValue()));
318  $md_section->update();
319 
320  // Description
321  $md_desc_ids = $md_section->getDescriptionIds();
322  if($md_desc_ids)
323  {
324  $md_desc = $md_section->getDescription(array_pop($md_desc_ids));
325  $md_desc->setDescription(ilUtil::stripSlashes($form->getItemByPostVar('description')->getValue()));
326  $md_desc->update();
327  }
328  else
329  {
330  $md_desc = $md_section->addDescription();
331  $md_desc->setDescription(ilUtil::stripSlashes($form->getItemByPostVar('description')->getValue()));
332  $md_desc->save();
333  }
334 
335  $this->testOBJ->setTitle(ilUtil::stripSlashes($form->getItemByPostVar('title')->getValue()));
336  $this->testOBJ->setDescription(ilUtil::stripSlashes($form->getItemByPostVar('description')->getValue()));
337  $this->testOBJ->update();
338 
339  // pool usage setting
340  if( $form->getItemByPostVar('use_pool') instanceof ilFormPropertyGUI )
341  {
342  $this->testOBJ->setPoolUsage($form->getItemByPostVar('use_pool')->getChecked());
343  }
344 
345  // Archiving
346  if($form->getItemByPostVar('anonymity')->getValue() == '1'
347  && $form->getItemByPostVar('enable_archiving')->getChecked() == true)
348  {
349  $this->testOBJ->setEnableArchiving(false);
350  ilUtil::sendInfo($this->lng->txt('no_archive_on_anonymous'), true);
351  }
352  else
353  {
354  $this->testOBJ->setEnableArchiving($form->getItemByPostVar('enable_archiving')->getChecked());
355  }
356 
357  // Examview
358  $this->testOBJ->setEnableExamview($form->getItemByPostVar('enable_examview')->getChecked());
359  $this->testOBJ->setShowExamviewHtml($form->getItemByPostVar('show_examview_html')->getChecked());
360  $this->testOBJ->setShowExamviewPdf($form->getItemByPostVar('show_examview_pdf')->getChecked());
361 
362  // online status
363  $this->testOBJ->setOnline($form->getItemByPostVar('online')->getChecked());
364 
365  // activation
366  if($form->getItemByPostVar('activation_type')->getChecked())
367  {
368  $this->testOBJ->setActivationLimited(true);
369  $this->testOBJ->setActivationVisibility($form->getItemByPostVar('activation_visibility')->getChecked());
370 
371  $period = $form->getItemByPostVar("access_period");
372  $this->testOBJ->setActivationStartingTime($period->getStart()->get(IL_CAL_UNIX));
373  $this->testOBJ->setActivationEndingTime($period->getEnd()->get(IL_CAL_UNIX));
374  }
375  else
376  {
377  $this->testOBJ->setActivationLimited(false);
378  }
379 
380  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
381  $this->testOBJ->setIntroduction($form->getItemByPostVar('introduction')->getValue(), false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment"));
382  $this->testOBJ->setShowInfo($form->getItemByPostVar('showinfo')->getChecked());
383  $this->testOBJ->setFinalStatement($form->getItemByPostVar('finalstatement')->getValue(), false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment"));
384  $this->testOBJ->setShowFinalStatement($form->getItemByPostVar('showfinalstatement')->getChecked());
385  if( $form->getItemByPostVar('chb_postpone') instanceof ilFormPropertyGUI )
386  {
387  $this->testOBJ->setSequenceSettings($form->getItemByPostVar('chb_postpone')->getChecked());
388  }
389  $this->testOBJ->setShuffleQuestions($form->getItemByPostVar('chb_shuffle_questions')->getChecked());
390  $this->testOBJ->setListOfQuestions($form->getItemByPostVar('list_of_questions')->getChecked());
391  $listOfQuestionsOptions = $form->getItemByPostVar('list_of_questions_options')->getValue();
392  if( is_array($listOfQuestionsOptions) )
393  {
394  $this->testOBJ->setListOfQuestionsStart( in_array('chb_list_of_questions_start', $listOfQuestionsOptions) );
395  $this->testOBJ->setListOfQuestionsEnd( in_array('chb_list_of_questions_end', $listOfQuestionsOptions) );
396  $this->testOBJ->setListOfQuestionsDescription( in_array('chb_list_of_questions_with_description', $listOfQuestionsOptions) );
397  }
398  else
399  {
400  $this->testOBJ->setListOfQuestionsStart(0);
401  $this->testOBJ->setListOfQuestionsEnd(0);
402  $this->testOBJ->setListOfQuestionsDescription(0);
403  }
404 
405  if( $form->getItemByPostVar('mailnotification') instanceof ilFormPropertyGUI )
406  {
407  $this->testOBJ->setMailNotification($form->getItemByPostVar('mailnotification')->getValue());
408  }
409  if( $form->getItemByPostVar('mailnottype') instanceof ilFormPropertyGUI )
410  {
411  $this->testOBJ->setMailNotificationType($form->getItemByPostVar('mailnottype')->getChecked());
412  }
413  if( $form->getItemByPostVar('chb_show_marker') instanceof ilFormPropertyGUI )
414  {
415  $this->testOBJ->setShowMarker($form->getItemByPostVar('chb_show_marker')->getChecked());
416  }
417  if( $form->getItemByPostVar('chb_show_cancel') instanceof ilFormPropertyGUI )
418  {
419  $this->testOBJ->setShowCancel($form->getItemByPostVar('chb_show_cancel')->getChecked());
420  }
421 
422  if($form->getItemByPostVar('kiosk') instanceof ilFormPropertyGUI)
423  {
424  $this->testOBJ->setKioskMode($form->getItemByPostVar('kiosk')->getChecked());
425  $kioskOptions = $form->getItemByPostVar('kiosk_options')->getValue();
426  if( is_array($kioskOptions) )
427  {
428  $this->testOBJ->setShowKioskModeTitle( in_array('kiosk_title', $kioskOptions) );
429  $this->testOBJ->setShowKioskModeParticipant( in_array('kiosk_participant', $kioskOptions) );
430  }
431  else
432  {
433  $this->testOBJ->setShowKioskModeTitle( false );
434  $this->testOBJ->setShowKioskModeParticipant( false );
435  }
436  }
437 
438  if( $form->getItemByPostVar('examid_in_test_pass') instanceof ilFormPropertyGUI)
439  {
440  $value = $form->getItemByPostVar('examid_in_test_pass')->getChecked();
441  $this->testOBJ->setShowExamIdInTestPassEnabled( $value );
442  }
443 
444  // redirect after test
445  if( $form->getItemByPostVar('redirection_enabled')->getChecked() )
446  {
447  $this->testOBJ->setRedirectionMode( $form->getItemByPostVar('redirection_mode')->getValue() );
448  }
449  else
450  {
451  $this->testOBJ->setRedirectionMode(REDIRECT_NONE);
452  }
453 
454  if( strlen($form->getItemByPostVar('redirection_url')->getValue()) )
455  {
456  $this->testOBJ->setRedirectionUrl( $form->getItemByPostVar('redirection_url')->getValue() );
457  }
458  else
459  {
460  $this->testOBJ->setRedirectionUrl(null);
461  }
462 
463  if( $form->getItemByPostVar('sign_submission')->getChecked() )
464  {
465  $this->testOBJ->setSignSubmission( true );
466  }
467  else
468  {
469  $this->testOBJ->setSignSubmission( false );
470  }
471 
472  $this->testOBJ->setEnableProcessingTime($form->getItemByPostVar('chb_processing_time')->getChecked());
473  if ($this->testOBJ->getEnableProcessingTime())
474  {
475  $processingTime = $form->getItemByPostVar('processing_time');
476  $this->testOBJ->setProcessingTime(sprintf("%02d:%02d:%02d",
477  $processingTime->getHours(), $processingTime->getMinutes(), $processingTime->getSeconds()
478  ));
479  }
480  else
481  {
482  $this->testOBJ->setProcessingTime('');
483  }
484  $this->testOBJ->setResetProcessingTime($form->getItemByPostVar('chb_reset_processing_time')->getChecked());
485 
486  if(!$this->testOBJ->participantDataExist() && $form->getItemByPostVar('chb_starting_time')->getChecked() )
487  {
488  $startingTimeSetting = $form->getItemByPostVar('starting_time');
489  $this->testOBJ->setStartingTime(ilFormat::dateDB2timestamp(
490  $startingTimeSetting->getDate()->get(IL_CAL_DATETIME)
491  ));
492  }
493  else if(!$this->testOBJ->participantDataExist())
494  {
495  $this->testOBJ->setStartingTime('');
496  }
497 
498  if( $form->getItemByPostVar('chb_ending_time')->getChecked() )
499  {
500  $endingTimeSetting = $form->getItemByPostVar('ending_time');
501  $this->testOBJ->setEndingTime(ilFormat::dateDB2timestamp(
502  $endingTimeSetting->getDate()->get(IL_CAL_DATETIME)
503  ));
504  }
505  else
506  {
507  $this->testOBJ->setEndingTime('');
508  }
509 
510  if($form->getItemByPostVar('forcejs') instanceof ilFormPropertyGUI)
511  {
512  $this->testOBJ->setForceJS($form->getItemByPostVar('forcejs')->getChecked());
513  }
514 
515  if( $form->getItemByPostVar('title_output') instanceof ilFormPropertyGUI )
516  {
517  $this->testOBJ->setTitleOutput($form->getItemByPostVar('title_output')->getValue());
518  }
519  if( $form->getItemByPostVar('password') instanceof ilFormPropertyGUI )
520  {
521  $this->testOBJ->setPassword($form->getItemByPostVar('password')->getValue());
522  }
523  if( $form->getItemByPostVar('allowedUsers') instanceof ilFormPropertyGUI )
524  {
525  $this->testOBJ->setAllowedUsers($form->getItemByPostVar('allowedUsers')->getValue());
526  }
527  if( $form->getItemByPostVar('allowedUsersTimeGap') instanceof ilFormPropertyGUI )
528  {
529  $this->testOBJ->setAllowedUsersTimeGap($form->getItemByPostVar('allowedUsersTimeGap')->getValue());
530  }
531 
532  // Selector for uicode characters
533  global $ilSetting;
534  if ($ilSetting->get('char_selector_availability') > 0)
535  {
536  require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
538  $char_selector->addFormProperties($form);
539  $char_selector->getFormValues($form);
540  $this->testOBJ->setCharSelectorAvailability($char_selector->getConfig()->getAvailability());
541  $this->testOBJ->setCharSelectorDefinition($char_selector->getConfig()->getDefinition());
542  }
543 
544  $this->testOBJ->setAutosave($form->getItemByPostVar('autosave')->getChecked());
545  $this->testOBJ->setAutosaveIval($form->getItemByPostVar('autosave_ival')->getValue() * 1000);
546 
547  $this->testOBJ->setUsePreviousAnswers($form->getItemByPostVar('chb_use_previous_answers')->getChecked());
548 
549  // highscore settings
550  $this->testOBJ->setHighscoreEnabled((bool) $form->getItemByPostVar('highscore_enabled')->getChecked());
551  $this->testOBJ->setHighscoreAnon((bool) $form->getItemByPostVar('highscore_anon')->getChecked());
552  $this->testOBJ->setHighscoreAchievedTS((bool) $form->getItemByPostVar('highscore_achieved_ts')->getChecked());
553  $this->testOBJ->setHighscoreScore((bool) $form->getItemByPostVar('highscore_score')->getChecked());
554  $this->testOBJ->setHighscorePercentage((bool) $form->getItemByPostVar('highscore_percentage')->getChecked());
555  $this->testOBJ->setHighscoreHints((bool) $form->getItemByPostVar('highscore_hints')->getChecked());
556  $this->testOBJ->setHighscoreWTime((bool) $form->getItemByPostVar('highscore_wtime')->getChecked());
557  $this->testOBJ->setHighscoreOwnTable((bool) $form->getItemByPostVar('highscore_own_table')->getChecked());
558  $this->testOBJ->setHighscoreTopTable((bool) $form->getItemByPostVar('highscore_top_table')->getChecked());
559  $this->testOBJ->setHighscoreTopNum((int) $form->getItemByPostVar('highscore_top_num')->getValue());
560 
561  if( !$this->testOBJ->participantDataExist() )
562  {
563  // question set type
564  if( $form->getItemByPostVar('question_set_type') instanceof ilFormPropertyGUI )
565  {
566  $this->testOBJ->setQuestionSetType($form->getItemByPostVar('question_set_type')->getValue());
567  }
568 
569  // anonymity setting
570  $this->testOBJ->setAnonymity($form->getItemByPostVar('anonymity')->getValue());
571 
572  // nr of tries (max passes)
573  $this->testOBJ->setNrOfTries($form->getItemByPostVar('nr_of_tries')->getValue());
574 
575  // fixed participants setting
576  if( $form->getItemByPostVar('fixedparticipants') instanceof ilFormPropertyGUI )
577  {
578  $this->testOBJ->setFixedParticipants($form->getItemByPostVar('fixedparticipants')->getChecked());
579  }
580  }
581 
582  // store settings to db
583  $this->testOBJ->saveToDb(true);
584 
585  // Update ecs export settings
586  include_once 'Modules/Test/classes/class.ilECSTestSettings.php';
587  $ecs = new ilECSTestSettings($this->testOBJ);
588  $ecs->handleSettingsUpdate();
589  }
590 
591  private function showConfirmation(ilPropertyFormGUI $form, $oldQuestionSetType, $newQuestionSetType, $hasQuestionsWithoutQuestionpool)
592  {
593  require_once 'Modules/Test/classes/confirmations/class.ilTestSettingsChangeConfirmationGUI.php';
594  $confirmation = new ilTestSettingsChangeConfirmationGUI($this->lng, $this->testOBJ);
595 
596  $confirmation->setFormAction( $this->ctrl->getFormAction($this) );
597  $confirmation->setCancel($this->lng->txt('cancel'), self::CMD_SHOW_FORM);
598  $confirmation->setConfirm($this->lng->txt('confirm'), self::CMD_CONFIRMED_SAVE_FORM);
599 
600  $confirmation->setOldQuestionSetType($oldQuestionSetType);
601  $confirmation->setNewQuestionSetType($newQuestionSetType);
602  $confirmation->setQuestionLossInfoEnabled($hasQuestionsWithoutQuestionpool);
603  $confirmation->build();
604 
605  $confirmation->populateParametersFromPropertyForm($form, $this->activeUser->getTimeZone());
606 
607  $this->tpl->setContent( $this->ctrl->getHTML($confirmation) );
608  }
609 
610  private function buildForm()
611  {
612  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
613  $form = new ilPropertyFormGUI();
614  $form->setFormAction($this->ctrl->getFormAction($this));
615  $form->addCommandButton(self::CMD_SAVE_FORM, $this->lng->txt("save"));
616  $form->setTableWidth("100%");
617  $form->setId("test_properties");
618 
619  if( !$this->settingsTemplate || $this->formShowGeneralSection($this->settingsTemplate->getSettings()) )
620  {
621  // general properties
622  $header = new ilFormSectionHeaderGUI();
623  $header->setTitle($this->lng->txt("tst_general_properties"));
624  $form->addItem($header);
625  }
626 
627  // title & description (meta data)
628 
629  include_once 'Services/MetaData/classes/class.ilMD.php';
630  $md_obj = new ilMD($this->testOBJ->getId(), 0, "tst");
631  $md_section = $md_obj->getGeneral();
632 
633  $title = new ilTextInputGUI($this->lng->txt("title"), "title");
634  $title->setRequired(true);
635  $title->setValue($md_section->getTitle());
636  $form->addItem($title);
637 
638  $ids = $md_section->getDescriptionIds();
639  if($ids)
640  {
641  $desc_obj = $md_section->getDescription(array_pop($ids));
642 
643  $desc = new ilTextAreaInputGUI($this->lng->txt("description"), "description");
644  $desc->setCols(50);
645  $desc->setRows(4);
646  $desc->setValue($desc_obj->getDescription());
647  $form->addItem($desc);
648  }
649 
650  // anonymity
651  $anonymity = new ilRadioGroupInputGUI($this->lng->txt('tst_anonymity'), 'anonymity');
652  if ($this->testOBJ->participantDataExist()) $anonymity->setDisabled(true);
653  $rb = new ilRadioOption($this->lng->txt('tst_anonymity_no_anonymization'), 0);
654  $anonymity->addOption($rb);
655  $rb = new ilRadioOption($this->lng->txt('tst_anonymity_anonymous_test'), 1);
656  $anonymity->addOption($rb);
657  $anonymity->setValue((int)$this->testOBJ->getAnonymity());
658  $form->addItem($anonymity);
659 
660  // test mode (question set type)
661  $questSetType = new ilRadioGroupInputGUI($this->lng->txt("tst_question_set_type"), 'question_set_type');
662  $questSetTypeFixed = new ilRadioOption(
663  $this->lng->txt("tst_question_set_type_fixed"), ilObjTest::QUESTION_SET_TYPE_FIXED,
664  $this->lng->txt("tst_question_set_type_fixed_desc")
665  );
666  $questSetType->addOption($questSetTypeFixed);
667  $questSetTypeRandom = new ilRadioOption(
668  $this->lng->txt("tst_question_set_type_random"), ilObjTest::QUESTION_SET_TYPE_RANDOM,
669  $this->lng->txt("tst_question_set_type_random_desc")
670  );
671  $questSetType->addOption($questSetTypeRandom);
672  $questSetTypeContinues = new ilRadioOption(
673  $this->lng->txt("tst_question_set_type_dynamic"), ilObjTest::QUESTION_SET_TYPE_DYNAMIC,
674  $this->lng->txt("tst_question_set_type_dynamic_desc")
675  );
676  $questSetType->addOption($questSetTypeContinues);
677  $questSetType->setValue($this->testOBJ->getQuestionSetType());
678  if( $this->testOBJ->participantDataExist() )
679  {
680  $questSetType->setDisabled(true);
681  }
682  $form->addItem($questSetType);
683 
684  // pool usage
685  $pool_usage = new ilCheckboxInputGUI($this->lng->txt("test_question_pool_usage"), "use_pool");
686  $pool_usage->setValue(1);
687  $pool_usage->setChecked($this->testOBJ->getPoolUsage());
688  $form->addItem($pool_usage);
689 
690  // enable_archiving
691  $enable_archiving = new ilCheckboxInputGUI($this->lng->txt('test_enable_archiving'), 'enable_archiving');
692  $enable_archiving->setValue(1);
693  $enable_archiving->setChecked($this->testOBJ->getEnableArchiving());
694  $form->addItem($enable_archiving);
695 
696  // activation/availability (no template support yet)
697 
698  include_once "Services/Object/classes/class.ilObjectActivation.php";
699  $this->lng->loadLanguageModule('rep');
700 
702  $section->setTitle($this->lng->txt('rep_activation_availability'));
703  $form->addItem($section);
704 
705  // additional info only with multiple references
706  $act_obj_info = $act_ref_info = "";
707  if(sizeof(ilObject::_getAllReferences($this->testOBJ->getId())) > 1)
708  {
709  $act_obj_info = ' '.$this->lng->txt('rep_activation_online_object_info');
710  $act_ref_info = $this->lng->txt('rep_activation_access_ref_info');
711  }
712 
713  $online = new ilCheckboxInputGUI($this->lng->txt('rep_activation_online'),'online');
714  $online->setChecked($this->testOBJ->isOnline());
715  $online->setInfo($this->lng->txt('tst_activation_online_info').$act_obj_info);
716  $form->addItem($online);
717 
718  $act_type = new ilCheckboxInputGUI($this->lng->txt('rep_visibility_until'), 'activation_type');
719  $act_type->setChecked($this->testOBJ->isActivationLimited());
720  // $act_type->setInfo($this->lng->txt('tst_availability_until_info'));
721 
722  $this->tpl->addJavaScript('./Services/Form/js/date_duration.js');
723  include_once "Services/Form/classes/class.ilDateDurationInputGUI.php";
724  $dur = new ilDateDurationInputGUI($this->lng->txt("rep_time_period"), "access_period");
725  $dur->setShowTime(true);
726  $date = $this->testOBJ->getActivationStartingTime();
727  $dur->setStart(new ilDateTime($date ? $date : time(), IL_CAL_UNIX));
728  $dur->setStartText($this->lng->txt('rep_activation_limited_start'));
729  $date = $this->testOBJ->getActivationEndingTime();
730  $dur->setEnd(new ilDateTime($date ? $date : time(), IL_CAL_UNIX));
731  $dur->setEndText($this->lng->txt('rep_activation_limited_end'));
732  $act_type->addSubItem($dur);
733 
734  $visible = new ilCheckboxInputGUI($this->lng->txt('rep_activation_limited_visibility'), 'activation_visibility');
735  $visible->setInfo($this->lng->txt('tst_activation_limited_visibility_info'));
736  $visible->setChecked($this->testOBJ->getActivationVisibility());
737  $act_type->addSubItem($visible);
738 
739  $form->addItem($act_type);
740 
741  if( !$this->settingsTemplate || $this->formShowBeginningEndingInformation($this->settingsTemplate->getSettings()) )
742  {
743  // general properties
744  $header = new ilFormSectionHeaderGUI();
745  $header->setTitle($this->lng->txt("tst_beginning_ending_information"));
746  $form->addItem($header);
747  }
748 
749  // introduction
750  $intro = new ilTextAreaInputGUI($this->lng->txt("tst_introduction"), "introduction");
751  $intro->setValue($this->testOBJ->prepareTextareaOutput($this->testOBJ->getIntroduction()));
752  $intro->setRows(10);
753  $intro->setCols(80);
754  $intro->setUseRte(TRUE);
755  $intro->addPlugin("latex");
756  $intro->addButton("latex");
757  $intro->setRTESupport($this->testOBJ->getId(), "tst", "assessment");
758  $intro->setRteTagSet('full');
759  $intro->setInfo($this->lng->txt('intro_desc'));
760  // showinfo
761  $showinfo = new ilCheckboxInputGUI('', "showinfo");
762  $showinfo->setValue(1);
763  $showinfo->setChecked($this->testOBJ->getShowInfo());
764  $showinfo->setOptionTitle($this->lng->txt("showinfo"));
765  $showinfo->setInfo($this->lng->txt("showinfo_desc"));
766  $intro->addSubItem($showinfo);
767  $form->addItem($intro);
768 
769  // final statement
770  $finalstatement = new ilTextAreaInputGUI($this->lng->txt("final_statement"), "finalstatement");
771  $finalstatement->setValue($this->testOBJ->prepareTextareaOutput($this->testOBJ->getFinalStatement()));
772  $finalstatement->setRows(10);
773  $finalstatement->setCols(80);
774  $finalstatement->setUseRte(TRUE);
775  $finalstatement->addPlugin("latex");
776  $finalstatement->addButton("latex");
777  $finalstatement->setRTESupport($this->testOBJ->getId(), "tst", "assessment");
778  $finalstatement->setRteTagSet('full');
779  // show final statement
780  $showfinal = new ilCheckboxInputGUI('', "showfinalstatement");
781  $showfinal->setValue(1);
782  $showfinal->setChecked($this->testOBJ->getShowFinalStatement());
783  $showfinal->setOptionTitle($this->lng->txt("final_statement_show"));
784  $showfinal->setInfo($this->lng->txt("final_statement_show_desc"));
785  $finalstatement->addSubItem($showfinal);
786  $form->addItem($finalstatement);
787 
788  // examview
789  $enable_examview = new ilCheckboxInputGUI($this->lng->txt("enable_examview"), 'enable_examview');
790  $enable_examview->setValue(1);
791  $enable_examview->setChecked($this->testOBJ->getEnableExamview());
792  $enable_examview->setInfo($this->lng->txt("enable_examview_desc"));
793  $show_examview_html = new ilCheckboxInputGUI('', 'show_examview_html');
794  $show_examview_html->setValue(1);
795  $show_examview_html->setChecked($this->testOBJ->getShowExamviewHtml());
796  $show_examview_html->setOptionTitle($this->lng->txt("show_examview_html"));
797  $show_examview_html->setInfo($this->lng->txt("show_examview_html_desc"));
798  $enable_examview->addSubItem($show_examview_html);
799  $show_examview_pdf = new ilCheckboxInputGUI('', 'show_examview_pdf');
800  $show_examview_pdf->setValue(1);
801  $show_examview_pdf->setChecked($this->testOBJ->getShowExamviewPdf());
802  $show_examview_pdf->setOptionTitle($this->lng->txt("show_examview_pdf"));
803  $show_examview_pdf->setInfo($this->lng->txt("show_examview_pdf_desc"));
804  $enable_examview->addSubItem($show_examview_pdf);
805  $form->addItem($enable_examview);
806 
807  if( !$this->settingsTemplate || $this->formShowSessionSection($this->settingsTemplate->getSettings()) )
808  {
809  // session properties
810  $sessionheader = new ilFormSectionHeaderGUI();
811  $sessionheader->setTitle($this->lng->txt("tst_session_settings"));
812  $form->addItem($sessionheader);
813  }
814 
815  // max. number of passes
816  $nr_of_tries = new ilTextInputGUI($this->lng->txt("tst_nr_of_tries"), "nr_of_tries");
817  $nr_of_tries->setSize(3);
818  $nr_of_tries->setValue($this->testOBJ->getNrOfTries());
819  $nr_of_tries->setRequired(true);
820  $nr_of_tries->setSuffix($this->lng->txt("0_unlimited"));
821  $total = $this->testOBJ->evalTotalPersons();
822  if ($total) $nr_of_tries->setDisabled(true);
823  $form->addItem($nr_of_tries);
824 
825  // enable max. processing time
826  $processing = new ilCheckboxInputGUI($this->lng->txt("tst_processing_time"), "chb_processing_time");
827  $processing->setValue(1);
828  //$processing->setOptionTitle($this->lng->txt("enabled"));
829 
830  if( $this->settingsTemplate && $this->getTemplateSettingValue('chb_processing_time') )
831  {
832  $processing->setChecked(true);
833  }
834  else
835  {
836  $processing->setChecked($this->testOBJ->getEnableProcessingTime());
837  }
838 
839  // max. processing time
840  $processingtime = new ilDurationInputGUI('', 'processing_time');
841  $ptime = $this->testOBJ->getProcessingTimeAsArray();
842  $processingtime->setHours($ptime['hh']);
843  $processingtime->setMinutes($ptime['mm']);
844  $processingtime->setSeconds($ptime['ss']);
845  $processingtime->setShowMonths(false);
846  $processingtime->setShowDays(false);
847  $processingtime->setShowHours(true);
848  $processingtime->setShowMinutes(true);
849  $processingtime->setShowSeconds(true);
850  $processingtime->setInfo($this->lng->txt("tst_processing_time_desc"));
851  $processing->addSubItem($processingtime);
852 
853  // reset max. processing time
854  $resetprocessing = new ilCheckboxInputGUI('', "chb_reset_processing_time");
855  $resetprocessing->setValue(1);
856  $resetprocessing->setOptionTitle($this->lng->txt("tst_reset_processing_time"));
857  $resetprocessing->setChecked($this->testOBJ->getResetProcessingTime());
858  $resetprocessing->setInfo($this->lng->txt("tst_reset_processing_time_desc"));
859  $processing->addSubItem($resetprocessing);
860  $form->addItem($processing);
861 
862  // enable starting time
863  $enablestartingtime = new ilCheckboxInputGUI($this->lng->txt("tst_starting_time"), "chb_starting_time");
864  $enablestartingtime->setValue(1);
865  //$enablestartingtime->setOptionTitle($this->lng->txt("enabled"));
866  if( $this->settingsTemplate && $this->getTemplateSettingValue('chb_starting_time') )
867  {
868  $enablestartingtime->setChecked(true);
869  }
870  else
871  {
872  $enablestartingtime->setChecked(strlen($this->testOBJ->getStartingTime()));
873  }
874  // starting time
875  $startingtime = new ilDateTimeInputGUI('', 'starting_time');
876  $startingtime->setShowDate(true);
877  $startingtime->setShowTime(true);
878  if( strlen($this->testOBJ->getStartingTime()) )
879  {
880  $startingtime->setDate(new ilDateTime($this->testOBJ->getStartingTime(), IL_CAL_TIMESTAMP));
881  }
882  else
883  {
884  $startingtime->setDate(new ilDateTime(time(), IL_CAL_UNIX));
885  }
886  $enablestartingtime->addSubItem($startingtime);
887  $form->addItem($enablestartingtime);
888  if( $this->testOBJ->participantDataExist() )
889  {
890  $enablestartingtime->setDisabled(true);
891  $startingtime->setDisabled(true);
892  }
893 
894  // enable ending time
895  $enableendingtime = new ilCheckboxInputGUI($this->lng->txt("tst_ending_time"), "chb_ending_time");
896  $enableendingtime->setValue(1);
897  //$enableendingtime->setOptionTitle($this->lng->txt("enabled"));
898  if ($this->settingsTemplate && $this->getTemplateSettingValue('chb_ending_time') )
899  $enableendingtime->setChecked(true);
900  else
901  $enableendingtime->setChecked(strlen($this->testOBJ->getEndingTime()));
902  // ending time
903  $endingtime = new ilDateTimeInputGUI('', 'ending_time');
904  $endingtime->setShowDate(true);
905  $endingtime->setShowTime(true);
906  if (strlen($this->testOBJ->getEndingTime()))
907  {
908  $endingtime->setDate(new ilDateTime($this->testOBJ->getEndingTime(), IL_CAL_TIMESTAMP));
909  }
910  else
911  {
912  $endingtime->setDate(new ilDateTime(time(), IL_CAL_UNIX));
913  }
914  $enableendingtime->addSubItem($endingtime);
915  $form->addItem($enableendingtime);
916 
917  // test password
918  $password = new ilTextInputGUI($this->lng->txt("tst_password"), "password");
919  $password->setSize(20);
920  $password->setValue($this->testOBJ->getPassword());
921  $password->setInfo($this->lng->txt("tst_password_details"));
922  $form->addItem($password);
923 
924  if( !$this->settingsTemplate || $this->formShowPresentationSection($this->settingsTemplate->getSettings()) )
925  {
926  // sequence properties
927  $seqheader = new ilFormSectionHeaderGUI();
928  $seqheader->setTitle($this->lng->txt("tst_presentation_properties"));
929  $form->addItem($seqheader);
930  }
931 
932  // use previous answers
933  $prevanswers = new ilCheckboxInputGUI($this->lng->txt("tst_use_previous_answers"), "chb_use_previous_answers");
934  $prevanswers->setValue(1);
935  $prevanswers->setChecked($this->testOBJ->getUsePreviousAnswers());
936  $prevanswers->setInfo($this->lng->txt("tst_use_previous_answers_description"));
937  $form->addItem($prevanswers);
938 
939  // force js
940  $forcejs = new ilCheckboxInputGUI($this->lng->txt("forcejs_short"), "forcejs");
941  $forcejs->setValue(1);
942  $forcejs->setChecked($this->testOBJ->getForceJS());
943  $forcejs->setOptionTitle($this->lng->txt("forcejs"));
944  $forcejs->setInfo($this->lng->txt("forcejs_desc"));
945  $form->addItem($forcejs);
946 
947  // question title output
948  $title_output = new ilRadioGroupInputGUI($this->lng->txt("tst_title_output"), "title_output");
949  $title_output->addOption(new ilRadioOption($this->lng->txt("tst_title_output_full"), 0, ''));
950  $title_output->addOption(new ilRadioOption($this->lng->txt("tst_title_output_hide_points"), 1, ''));
951  $title_output->addOption(new ilRadioOption($this->lng->txt("tst_title_output_no_title"), 2, ''));
952  $title_output->setValue($this->testOBJ->getTitleOutput());
953  $title_output->setInfo($this->lng->txt("tst_title_output_description"));
954  $form->addItem($title_output);
955 
956  // selector for unicode characters
957  global $ilSetting;
958  if ($ilSetting->get('char_selector_availability') > 0)
959  {
960  require_once 'Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php';
962  $char_selector->getConfig()->setAvailability($this->testOBJ->getCharSelectorAvailability());
963  $char_selector->getConfig()->setDefinition($this->testOBJ->getCharSelectorDefinition());
964  $char_selector->addFormProperties($form);
965  $char_selector->setFormValues($form);
966  }
967 
968  // Autosave
969  $autosave_output = new ilCheckboxInputGUI($this->lng->txt('autosave'), 'autosave');
970  $autosave_output->setValue(1);
971  $autosave_output->setChecked($this->testOBJ->getAutosave());
972  $autosave_output->setInfo($this->lng->txt('autosave_info'));
973 
974  $autosave_interval = new ilTextInputGUI($this->lng->txt('autosave_ival'), 'autosave_ival');
975  $autosave_interval->setSize(10);
976  $autosave_interval->setValue($this->testOBJ->getAutosaveIval()/1000);
977  $autosave_interval->setInfo($this->lng->txt('autosave_ival_info'));
978  $autosave_output->addSubItem($autosave_interval);
979  $form->addItem($autosave_output);
980 
981 
982  if( !$this->settingsTemplate || $this->formShowSequenceSection($this->settingsTemplate->getSettings()) )
983  {
984  // sequence properties
985  $seqheader = new ilFormSectionHeaderGUI();
986  $seqheader->setTitle($this->lng->txt("tst_sequence_properties"));
987  $form->addItem($seqheader);
988  }
989 
990  // postpone questions
991  $postpone = new ilCheckboxInputGUI($this->lng->txt("tst_postpone"), "chb_postpone");
992  $postpone->setValue(1);
993  $postpone->setChecked($this->testOBJ->getSequenceSettings());
994  $postpone->setInfo($this->lng->txt("tst_postpone_description"));
995  $form->addItem($postpone);
996 
997  // shuffle questions
998  $shuffle = new ilCheckboxInputGUI($this->lng->txt("tst_shuffle_questions"), "chb_shuffle_questions");
999  $shuffle->setValue(1);
1000  $shuffle->setChecked($this->testOBJ->getShuffleQuestions());
1001  $shuffle->setInfo($this->lng->txt("tst_shuffle_questions_description"));
1002  $form->addItem($shuffle);
1003 
1004  // show list of questions
1005  $list_of_questions = new ilCheckboxInputGUI($this->lng->txt("tst_show_summary"), "list_of_questions");
1006  //$list_of_questions->setOptionTitle($this->lng->txt("tst_show_summary"));
1007  $list_of_questions->setValue(1);
1008  $list_of_questions->setChecked($this->testOBJ->getListOfQuestions());
1009  $list_of_questions->setInfo($this->lng->txt("tst_show_summary_description"));
1010 
1011  $list_of_questions_options = new ilCheckboxGroupInputGUI('', "list_of_questions_options");
1012  $list_of_questions_options->addOption(new ilCheckboxOption($this->lng->txt("tst_list_of_questions_start"), 'chb_list_of_questions_start', ''));
1013  $list_of_questions_options->addOption(new ilCheckboxOption($this->lng->txt("tst_list_of_questions_end"), 'chb_list_of_questions_end', ''));
1014  $list_of_questions_options->addOption(new ilCheckboxOption($this->lng->txt("tst_list_of_questions_with_description"), 'chb_list_of_questions_with_description', ''));
1015  $values = array();
1016  if ($this->testOBJ->getListOfQuestionsStart()) array_push($values, 'chb_list_of_questions_start');
1017  if ($this->testOBJ->getListOfQuestionsEnd()) array_push($values, 'chb_list_of_questions_end');
1018  if ($this->testOBJ->getListOfQuestionsDescription()) array_push($values, 'chb_list_of_questions_with_description');
1019  $list_of_questions_options->setValue($values);
1020 
1021  $list_of_questions->addSubItem($list_of_questions_options);
1022  $form->addItem($list_of_questions);
1023 
1024  // show question marking
1025  $marking = new ilCheckboxInputGUI($this->lng->txt("question_marking"), "chb_show_marker");
1026  $marking->setValue(1);
1027  $marking->setChecked($this->testOBJ->getShowMarker());
1028  $marking->setInfo($this->lng->txt("question_marking_description"));
1029  $form->addItem($marking);
1030 
1031  // show suspend test
1032  $cancel = new ilCheckboxInputGUI($this->lng->txt("tst_show_cancel"), "chb_show_cancel");
1033  $cancel->setValue(1);
1034  $cancel->setChecked($this->testOBJ->getShowCancel());
1035  $cancel->setInfo($this->lng->txt("tst_show_cancel_description"));
1036  $form->addItem($cancel);
1037 
1038  if( !$this->settingsTemplate || $this->formShowNotificationSection($this->settingsTemplate->getSettings()) )
1039  {
1040  // notifications
1041  $notifications = new ilFormSectionHeaderGUI();
1042  $notifications->setTitle($this->lng->txt("tst_mail_notification"));
1043  $form->addItem($notifications);
1044  }
1045 
1046  // mail notification
1047  $mailnotification = new ilRadioGroupInputGUI($this->lng->txt("tst_finish_notification"), "mailnotification");
1048  $mailnotification->addOption(new ilRadioOption($this->lng->txt("tst_finish_notification_no"), 0, ''));
1049  $mailnotification->addOption(new ilRadioOption($this->lng->txt("tst_finish_notification_simple"), 1, ''));
1050  $mailnotification->addOption(new ilRadioOption($this->lng->txt("tst_finish_notification_advanced"), 2, ''));
1051  $mailnotification->setValue($this->testOBJ->getMailNotification());
1052  $form->addItem($mailnotification);
1053 
1054  $mailnottype = new ilCheckboxInputGUI('', "mailnottype");
1055  $mailnottype->setValue(1);
1056  $mailnottype->setOptionTitle($this->lng->txt("mailnottype"));
1057  $mailnottype->setChecked($this->testOBJ->getMailNotificationType());
1058  $form->addItem($mailnottype);
1059 
1060  /* This options always active (?) */
1061  $highscore_head = new ilFormSectionHeaderGUI();
1062  $highscore_head->setTitle($this->lng->txt("tst_highscore_options"));
1063  $form->addItem($highscore_head);
1064 
1065  $highscore = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_enabled"), "highscore_enabled");
1066  $highscore->setValue(1);
1067  $highscore->setChecked($this->testOBJ->getHighscoreEnabled());
1068  $highscore->setInfo($this->lng->txt("tst_highscore_description"));
1069  $form->addItem($highscore);
1070 
1071  $highscore_anon = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_anon"), "highscore_anon");
1072  $highscore_anon->setValue(1);
1073  $highscore_anon->setChecked($this->testOBJ->getHighscoreAnon());
1074  $highscore_anon->setInfo($this->lng->txt("tst_highscore_anon_description"));
1075  $highscore->addSubItem($highscore_anon);
1076 
1077  $highscore_achieved_ts = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_achieved_ts"), "highscore_achieved_ts");
1078  $highscore_achieved_ts->setValue(1);
1079  $highscore_achieved_ts->setChecked($this->testOBJ->getHighscoreAchievedTS());
1080  $highscore_achieved_ts->setInfo($this->lng->txt("tst_highscore_achieved_ts_description"));
1081  $highscore->addSubItem($highscore_achieved_ts);
1082 
1083  $highscore_score = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_score"), "highscore_score");
1084  $highscore_score->setValue(1);
1085  $highscore_score->setChecked($this->testOBJ->getHighscoreScore());
1086  $highscore_score->setInfo($this->lng->txt("tst_highscore_score_description"));
1087  $highscore->addSubItem($highscore_score);
1088 
1089  $highscore_percentage = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_percentage"), "highscore_percentage");
1090  $highscore_percentage->setValue(1);
1091  $highscore_percentage->setChecked($this->testOBJ->getHighscorePercentage());
1092  $highscore_percentage->setInfo($this->lng->txt("tst_highscore_percentage_description"));
1093  $highscore->addSubItem($highscore_percentage);
1094 
1095  $highscore_hints = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_hints"), "highscore_hints");
1096  $highscore_hints->setValue(1);
1097  $highscore_hints->setChecked($this->testOBJ->getHighscoreHints());
1098  $highscore_hints->setInfo($this->lng->txt("tst_highscore_hints_description"));
1099  $highscore->addSubItem($highscore_hints);
1100 
1101  $highscore_wtime = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_wtime"), "highscore_wtime");
1102  $highscore_wtime->setValue(1);
1103  $highscore_wtime->setChecked($this->testOBJ->getHighscoreWTime());
1104  $highscore_wtime->setInfo($this->lng->txt("tst_highscore_wtime_description"));
1105  $highscore->addSubItem($highscore_wtime);
1106 
1107  $highscore_own_table = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_own_table"), "highscore_own_table");
1108  $highscore_own_table->setValue(1);
1109  $highscore_own_table->setChecked($this->testOBJ->getHighscoreOwnTable());
1110  $highscore_own_table->setInfo($this->lng->txt("tst_highscore_own_table_description"));
1111  $highscore->addSubItem($highscore_own_table);
1112 
1113  $highscore_top_table = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_top_table"), "highscore_top_table");
1114  $highscore_top_table->setValue(1);
1115  $highscore_top_table->setChecked($this->testOBJ->getHighscoreTopTable());
1116  $highscore_top_table->setInfo($this->lng->txt("tst_highscore_top_table_description"));
1117  $highscore->addSubItem($highscore_top_table);
1118 
1119  $highscore_top_num = new ilTextInputGUI($this->lng->txt("tst_highscore_top_num"), "highscore_top_num");
1120  $highscore_top_num->setSize(4);
1121  $highscore_top_num->setSuffix($this->lng->txt("tst_highscore_top_num_unit"));
1122  $highscore_top_num->setValue($this->testOBJ->getHighscoreTopNum());
1123  $highscore_top_num->setInfo($this->lng->txt("tst_highscore_top_num_description"));
1124  $highscore->addSubItem($highscore_top_num);
1125 
1126  if( !$this->settingsTemplate || $this->formShowTestExecutionSection($this->settingsTemplate->getSettings()) )
1127  {
1128  $testExecution = new ilFormSectionHeaderGUI();
1129  $testExecution->setTitle($this->lng->txt("tst_test_execution"));
1130  $form->addItem($testExecution);
1131  }
1132 
1133  // kiosk mode
1134  $kiosk = new ilCheckboxInputGUI($this->lng->txt("kiosk"), "kiosk");
1135  $kiosk->setValue(1);
1136  $kiosk->setChecked($this->testOBJ->getKioskMode());
1137  $kiosk->setInfo($this->lng->txt("kiosk_description"));
1138 
1139  // kiosk mode options
1140  $kiosktitle = new ilCheckboxGroupInputGUI($this->lng->txt("kiosk_options"), "kiosk_options");
1141  $kiosktitle->addOption(new ilCheckboxOption($this->lng->txt("kiosk_show_title"), 'kiosk_title', ''));
1142  $kiosktitle->addOption(new ilCheckboxOption($this->lng->txt("kiosk_show_participant"), 'kiosk_participant', ''));
1143  $values = array();
1144  if ($this->testOBJ->getShowKioskModeTitle()) array_push($values, 'kiosk_title');
1145  if ($this->testOBJ->getShowKioskModeParticipant()) array_push($values, 'kiosk_participant');
1146  $kiosktitle->setValue($values);
1147  $kiosktitle->setInfo($this->lng->txt("kiosk_options_desc"));
1148  $kiosk->addSubItem($kiosktitle);
1149 
1150  $form->addItem($kiosk);
1151 
1152  $examIdInPass = new ilCheckboxInputGUI($this->lng->txt('examid_in_test_pass'), 'examid_in_test_pass');
1153  $examIdInPass->setInfo($this->lng->txt('examid_in_test_pass_desc'));
1154  $examIdInPass->setChecked($this->testOBJ->isShowExamIdInTestPassEnabled());
1155  $form->addItem($examIdInPass);
1156 
1157  $redirection_mode = $this->testOBJ->getRedirectionMode();
1158  $rm_enabled = new ilCheckboxInputGUI($this->lng->txt('redirect_after_finishing_tst'), 'redirection_enabled' );
1159  $rm_enabled->setInfo($this->lng->txt('redirect_after_finishing_tst_desc'));
1160  $rm_enabled->setChecked($redirection_mode == '0' ? false : true);
1161  $radio_rm = new ilRadioGroupInputGUI($this->lng->txt('redirect_after_finishing_tst'), 'redirection_mode');
1162  $always = new ilRadioOption($this->lng->txt('tst_results_access_always'), REDIRECT_ALWAYS);
1163  $radio_rm->addOption($always);
1164  $kiosk = new ilRadioOption($this->lng->txt('redirect_in_kiosk_mode'), REDIRECT_KIOSK);
1165  $radio_rm->addOption($kiosk);
1166  $radio_rm->setValue(in_array($redirection_mode, array(REDIRECT_ALWAYS, REDIRECT_KIOSK)) ? $redirection_mode : REDIRECT_ALWAYS);
1167  $rm_enabled->addSubItem($radio_rm);
1168  $redirection_url = new ilTextInputGUI($this->lng->txt('redirection_url'), 'redirection_url');
1169  $redirection_url->setValue((string)$this->testOBJ->getRedirectionUrl());
1170  $redirection_url->setRequired(true);
1171  $rm_enabled->addSubItem($redirection_url);
1172 
1173  $form->addItem($rm_enabled);
1174 
1175  // Sign submission
1176  $sign_submission = $this->testOBJ->getSignSubmission();
1177  $sign_submission_enabled = new ilCheckboxInputGUI($this->lng->txt('sign_submission'), 'sign_submission');
1178  $sign_submission_enabled->setChecked($sign_submission);
1179  $sign_submission_enabled->setInfo($this->lng->txt('sign_submission_info'));
1180  $form->addItem($sign_submission_enabled);
1181 
1182  if( !$this->settingsTemplate || $this->formShowParticipantSection($this->settingsTemplate->getSettings()) )
1183  {
1184  // participants properties
1185  $restrictions = new ilFormSectionHeaderGUI();
1186  $restrictions->setTitle($this->lng->txt("tst_max_allowed_users"));
1187  $form->addItem($restrictions);
1188  }
1189 
1190  $fixedparticipants = new ilCheckboxInputGUI($this->lng->txt('participants_invitation'), "fixedparticipants");
1191  $fixedparticipants->setValue(1);
1192  $fixedparticipants->setChecked($this->testOBJ->getFixedParticipants());
1193  $fixedparticipants->setOptionTitle($this->lng->txt("tst_allow_fixed_participants"));
1194  $fixedparticipants->setInfo($this->lng->txt("participants_invitation_description"));
1195  $invited_users = $this->testOBJ->getInvitedUsers();
1196  if ($total && (count($invited_users) == 0))
1197  {
1198  $fixedparticipants->setDisabled(true);
1199  }
1200  $form->addItem($fixedparticipants);
1201 
1202  // simultaneous users
1203  $simul = new ilTextInputGUI($this->lng->txt("tst_allowed_users"), "allowedUsers");
1204  $simul->setSize(3);
1205  $simul->setValue(($this->testOBJ->getAllowedUsers()) ? $this->testOBJ->getAllowedUsers() : '');
1206  $form->addItem($simul);
1207 
1208  // idle time
1209  $idle = new ilTextInputGUI($this->lng->txt("tst_allowed_users_time_gap"), "allowedUsersTimeGap");
1210  $idle->setSize(4);
1211  $idle->setSuffix($this->lng->txt("seconds"));
1212  $idle->setValue(($this->testOBJ->getAllowedUsersTimeGap()) ? $this->testOBJ->getAllowedUsersTimeGap() : '');
1213  $form->addItem($idle);
1214 
1215  // Edit ecs export settings
1216  include_once 'Modules/Test/classes/class.ilECSTestSettings.php';
1217  $ecs = new ilECSTestSettings($this->testOBJ);
1218  $ecs->addSettingsToForm($form, 'tst');
1219 
1220  // remove items when using template
1221  if($this->settingsTemplate)
1222  {
1223  foreach($this->settingsTemplate->getSettings() as $id => $item)
1224  {
1225  if($item["hide"])
1226  {
1227  $form->removeItemByPostVar($id);
1228  }
1229  }
1230  }
1231 
1232  return $form;
1233  }
1234 
1239  {
1240  require_once 'Services/Utilities/classes/class.ilConfirmationGUI.php';
1241  $confirmationGUI = new ilConfirmationGUI();
1242 
1243  $confirmationGUI->setFormAction($this->ctrl->getFormAction($this));
1244  $confirmationGUI->setHeaderText($this->lng->txt("test_confirm_template_reset"));
1245  $confirmationGUI->setCancel($this->lng->txt('cancel'), self::CMD_SHOW_FORM);
1246  $confirmationGUI->setConfirm($this->lng->txt('confirm'), self::CMD_CONFIRMED_RESET_TPL);
1247 
1248  $this->tpl->setContent( $this->ctrl->getHTML($confirmationGUI) );
1249  }
1250 
1254  private function confirmedResetTemplateCmd()
1255  {
1256  $this->testOBJ->setTemplate(null);
1257  $this->testOBJ->saveToDB();
1258 
1259  ilUtil::sendSuccess($this->lng->txt("test_template_reset"), true);
1260  $this->ctrl->redirect($this, self::CMD_SHOW_FORM);
1261  }
1262 
1263  protected function getTemplateSettingValue($settingName)
1264  {
1265  if( !$this->settingsTemplate )
1266  {
1267  return null;
1268  }
1269 
1270  $templateSettings = $this->settingsTemplate->getSettings();
1271 
1272  if( !isset($templateSettings[$settingName]) )
1273  {
1274  return false;
1275  }
1276 
1277  return $templateSettings[$settingName]['value'];
1278  }
1279 
1280  protected function getSettingsTemplateMessageHTML()
1281  {
1282  if( $this->settingsTemplate )
1283  {
1284  global $tpl;
1285 
1286  $link = $this->ctrl->getLinkTarget($this, self::CMD_SHOW_RESET_TPL_CONFIRM);
1287  $link = "<a href=\"".$link."\">".$this->lng->txt("test_using_template_link")."</a>";
1288 
1289  $msgHTML = $tpl->getMessageHTML(
1290  sprintf($this->lng->txt("test_using_template"), $this->settingsTemplate->getTitle(), $link), "info"
1291  );
1292 
1293  $msgHTML = "<div style=\"margin-top:10px\">$msgHTML</div>";
1294  }
1295  else
1296  {
1297  $msgHTML = '';
1298  }
1299 
1300  return $msgHTML;
1301  }
1302 
1303  private function formShowGeneralSection($templateData)
1304  {
1305  // alway show because of title and description
1306  return true;
1307  }
1308 
1309  private function formShowBeginningEndingInformation($templateData)
1310  {
1311  // show always because of statement text areas
1312  return true;
1313  }
1314 
1315  private function formShowSessionSection($templateData)
1316  {
1317  // show always because of "nr_of_tries", "chb_processing_time", "chb_starting_time", "chb_ending_time"
1318  return true;
1319  }
1320 
1321  private function formShowPresentationSection($templateData)
1322  {
1323  // show always because of "previous answer" setting
1324  return true;
1325  }
1326 
1327  private function formShowSequenceSection($templateData)
1328  {
1329  // show always because of "list of question" and "shuffle"
1330  return true;
1331  }
1332 
1333  private function formShowNotificationSection($templateData)
1334  {
1335  $fields = array(
1336  'mailnotification',
1337  'mailnottype',
1338  );
1339  return $this->formsectionHasVisibleFields($templateData, $fields);
1340  }
1341 
1342  private function formShowTestExecutionSection($templateData)
1343  {
1344  return true; // remove this when 'eredirection_enabled' and 'sign_submission' become hideable
1345 
1346  $fields = array(
1347  'kiosk',
1348  'redirection_enabled', 'sign_submission' // not hideable up to now
1349  );
1350  return $this->formsectionHasVisibleFields($templateData, $fields);
1351  }
1352 
1353  private function formShowParticipantSection($templateData)
1354  {
1355  $fields = array(
1356  'fixedparticipants',
1357  'allowedUsers',
1358  'allowedUsersTimeGap',
1359  );
1360  return $this->formsectionHasVisibleFields($templateData, $fields);
1361  }
1362 
1363  private function formsectionHasVisibleFields($templateData, $fields)
1364  {
1365  foreach($fields as $fld)
1366  {
1367  if( !isset($templateData[$fld]) || !$templateData[$fld]['hide'] )
1368  {
1369  return true;
1370  }
1371  }
1372 
1373  return false;
1374  }
1375 }