ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjAssessmentFolderGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once "./Services/Object/classes/class.ilObjectGUI.php";
5 
6 require_once 'Modules/Test/classes/class.ilObjTest.php';
7 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionProcessLocker.php';
8 
20 {
21 
23 
27  public function ilObjAssessmentFolderGUI($a_data,$a_id,$a_call_by_reference)
28  {
29  global $rbacsystem;
30 
31  $this->type = "assf";
32  $this->ilObjectGUI($a_data,$a_id,$a_call_by_reference,false);
33 
34  if (!$rbacsystem->checkAccess('read',$this->object->getRefId()))
35  {
36  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read_assf"),$this->ilias->error_obj->WARNING);
37  }
38 
39  $this->lng->loadLanguageModule('assessment');
40  }
41 
42  public function &executeCommand()
43  {
48  global $rbacsystem, $ilTabs;
49 
50  $next_class = $this->ctrl->getNextClass($this);
51  $cmd = $this->ctrl->getCmd();
52  $this->prepareOutput();
53 
54  switch($next_class)
55  {
56  case 'ilpermissiongui':
57  $ilTabs->activateTab('perm_settings');
58  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
59  $perm_gui =& new ilPermissionGUI($this);
60  $ret =& $this->ctrl->forwardCommand($perm_gui);
61  break;
62 
63  case 'ilsettingstemplategui':
64  $ilTabs->setTabActive("templates");
65  include_once("./Services/Administration/classes/class.ilSettingsTemplateGUI.php");
66  $set_tpl_gui = new ilSettingsTemplateGUI($this->getSettingsTemplateConfig());
67  $this->ctrl->forwardCommand($set_tpl_gui);
68  break;
69 
70  case 'ilglobalunitconfigurationgui':
71  if(!$rbacsystem->checkAccess('write', $this->object->getRefId()))
72  {
73  $this->ilias->raiseError($this->lng->txt('permission_denied'), $this->ilias->error_obj->WARNING);
74  }
75 
76  $ilTabs->setTabActive('units');
77 
78  require_once 'Modules/TestQuestionPool/classes/class.ilGlobalUnitConfigurationGUI.php';
79  require_once 'Modules/TestQuestionPool/classes/class.ilUnitConfigurationRepository.php';
82  );
83  $this->ctrl->forwardCommand($gui);
84  break;
85 
86  default:
87  if($cmd == "" || $cmd == "view")
88  {
89  $cmd = "settings";
90  }
91  $cmd .= "Object";
92  $this->$cmd();
93 
94  break;
95  }
96  return true;
97  }
98 
99 
104  public function saveObject()
105  {
106  global $rbacadmin;
107 
108  // create and insert forum in objecttree
109  $newObj = parent::saveObject();
110 
111  // put here object specific stuff
112 
113  // always send a message
114  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
115 
116  $this->ctrl->redirect($this);
117  }
118 
119 
123  public function settingsObject(ilPropertyFormGUI $form = null)
124  {
125  global $ilTabs;
126 
127  $ilTabs->setTabActive('settings');
128 
129  if($form === null)
130  {
131  $form = $this->buildSettingsForm();
132  }
133 
134  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
135  }
136 
137  private function buildSettingsForm()
138  {
139  global $ilAccess;
140 
141  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
142  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
143  $form = new ilPropertyFormGUI();
144  $form->setFormAction($this->ctrl->getFormAction($this));
145  $form->setTableWidth("100%");
146  $form->setId("settings");
147 
148  $header = new ilFormSectionHeaderGUI();
149  $header->setTitle($this->lng->txt('settings'));
150  $form->addItem($header);
151 
152  // question process locking behaviour (e.g. on saving users working data)
153  $chb = new ilCheckboxInputGUI($this->lng->txt('ass_process_lock'), 'ass_process_lock');
154  $chb->setChecked($this->object->getAssessmentProcessLockMode() != ilObjAssessmentFolder::ASS_PROC_LOCK_MODE_NONE);
155  $chb->setInfo($this->lng->txt('ass_process_lock_desc'));
156  $form->addItem($chb);
157  $rg = new ilRadioGroupInputGUI($this->lng->txt('ass_process_lock_mode'), 'ass_process_lock_mode');
158  $rg->setRequired(true);
159  $opt = new ilRadioOption($this->lng->txt('ass_process_lock_mode_file'), ilObjAssessmentFolder::ASS_PROC_LOCK_MODE_FILE);
160  $opt->setInfo($this->lng->txt('ass_process_lock_mode_file_desc'));
161  $rg->addOption($opt);
162  $opt = new ilRadioOption($this->lng->txt('ass_process_lock_mode_db'), ilObjAssessmentFolder::ASS_PROC_LOCK_MODE_DB);
163  $opt->setInfo($this->lng->txt('ass_process_lock_mode_db_desc'));
164  $rg->addOption($opt);
165  if($this->object->getAssessmentProcessLockMode() != ilObjAssessmentFolder::ASS_PROC_LOCK_MODE_NONE)
166  {
167  $rg->setValue($this->object->getAssessmentProcessLockMode());
168  }
169  $chb->addSubItem($rg);
170 
171  // question settings
172  $header = new ilFormSectionHeaderGUI();
173  $header->setTitle($this->lng->txt("assf_questiontypes"));
174  $form->addItem($header);
175 
176  // available question types
177  $allowed = new ilCheckboxGroupInputGUI($this->lng->txt('assf_allowed_questiontypes'), "chb_allowed_questiontypes");
178  $questiontypes =& ilObjQuestionPool::_getQuestionTypes(TRUE);
179  $forbidden_types = $this->object->_getForbiddenQuestionTypes();
180  $allowedtypes = array();
181  foreach ($questiontypes as $qt)
182  {
183  if (!in_array($qt['question_type_id'], $forbidden_types)) array_push($allowedtypes, $qt['question_type_id']);
184  }
185  $allowed->setValue($allowedtypes);
186  foreach ($questiontypes as $type_name => $qtype)
187  {
188  $allowed->addOption(new ilCheckboxOption($type_name, $qtype["question_type_id"]));
189  }
190  $allowed->setInfo($this->lng->txt('assf_allowed_questiontypes_desc'));
191  $form->addItem($allowed);
192 
193  // manual scoring
194  $manual = new ilCheckboxGroupInputGUI($this->lng->txt('assessment_log_manual_scoring_activate'), "chb_manual_scoring");
195  $manscoring = $this->object->_getManualScoring();
196  $manual->setValue($manscoring);
197  foreach ($questiontypes as $type_name => $qtype)
198  {
199  $manual->addOption(new ilCheckboxOption($type_name, $qtype["question_type_id"]));
200  }
201  $manual->setInfo($this->lng->txt('assessment_log_manual_scoring_desc'));
202  $form->addItem($manual);
203 
204  // scoring adjustment active
205  $scoring_activation = new ilCheckboxInputGUI($this->lng->txt('assessment_scoring_adjust'),'chb_scoring_adjust');
206  $scoring_activation->setChecked($this->object->getScoringAdjustmentEnabled());
207  $scoring_activation->setInfo($this->lng->txt('assessment_scoring_adjust_desc'));
208  $form->addItem($scoring_activation);
209 
210  // scoring adjustment
211  $scoring = new ilCheckboxGroupInputGUI($this->lng->txt('assessment_log_scoring_adjustment_activate'), "chb_scoring_adjustment");
212  $scoring_active = $this->object->getScoringAdjustableQuestions();
213  $scoring->setValue($scoring_active);
214  foreach ($questiontypes as $type_name => $qtype)
215  {
216  $scoring->addOption(new ilCheckboxOption($type_name, $qtype["question_type_id"]));
217  }
218  $scoring->setInfo($this->lng->txt('assessment_log_scoring_adjustment_desc'));
219  $form->addItem($scoring);
220 
221  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
222  {
223  $form->addCommandButton("saveSettings", $this->lng->txt("save"));
224  }
225 
226  return $form;
227  }
228 
232  public function saveSettingsObject()
233  {
234  global $ilAccess;
235  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId())) $this->ctrl->redirect($this,'settings');
236 
237  $form = $this->buildSettingsForm();
238  if(!$form->checkInput())
239  {
240  $form->setValuesByPost();
241  return $this->settingsObject($form);
242  }
243 
244  $this->object->_setManualScoring($_POST["chb_manual_scoring"]);
245  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
246  $questiontypes =& ilObjQuestionPool::_getQuestionTypes(TRUE);
247  $forbidden_types = array();
248  foreach ($questiontypes as $name => $row)
249  {
250  if (!in_array($row["question_type_id"], $_POST["chb_allowed_questiontypes"]))
251  {
252  array_push($forbidden_types, $row["question_type_id"]);
253  }
254  }
255  $this->object->_setForbiddenQuestionTypes($forbidden_types);
256 
257  $this->object->setScoringAdjustmentEnabled($_POST['chb_scoring_adjust']);
258  $scoring_types = array();
259  foreach ($questiontypes as $name => $row)
260  {
261  if (in_array($row["question_type_id"], (array)$_POST["chb_scoring_adjustment"]))
262  {
263  array_push($scoring_types, $row["question_type_id"]);
264  }
265  }
266  $this->object->setScoringAdjustableQuestions($scoring_types);
267 
268  if( !$_POST['ass_process_lock'] )
269  {
270  $this->object->setAssessmentProcessLockMode(ilObjAssessmentFolder::ASS_PROC_LOCK_MODE_NONE);
271  }
272  elseif( in_array($_POST['ass_process_lock_mode'], ilObjAssessmentFolder::getValidAssessmentProcessLockModes()) )
273  {
274  $this->object->setAssessmentProcessLockMode($_POST['ass_process_lock_mode']);
275  }
276 
277  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"),true);
278 
279  $this->ctrl->redirect($this,'settings');
280  }
281 
285  public function showLogObject()
286  {
287  $from = mktime($_POST['log_from']['time']['h'], $_POST['log_from']['time']['m'], 0, $_POST['log_from']['date']['m'], $_POST['log_from']['date']['d'], $_POST['log_from']['date']['y']);
288  $until = mktime($_POST['log_until']['time']['h'], $_POST['log_until']['time']['m'], 0, $_POST['log_until']['date']['m'], $_POST['log_until']['date']['d'], $_POST['log_until']['date']['y']);
289  $test = $_POST['sel_test'];
290  $this->logsObject($from, $until, $test);
291  }
292 
296  public function exportLogObject()
297  {
298  $from = mktime($_POST['log_from']['time']['h'], $_POST['log_from']['time']['m'], 0, $_POST['log_from']['date']['m'], $_POST['log_from']['date']['d'], $_POST['log_from']['date']['y']);
299  $until = mktime($_POST['log_until']['time']['h'], $_POST['log_until']['time']['m'], 0, $_POST['log_until']['date']['m'], $_POST['log_until']['date']['d'], $_POST['log_until']['date']['y']);
300  $test = $_POST['sel_test'];
301 
302  $csv = array();
303  $separator = ";";
304  $row = array(
305  $this->lng->txt("assessment_log_datetime"),
306  $this->lng->txt("user"),
307  $this->lng->txt("assessment_log_text"),
308  $this->lng->txt("question")
309  );
310  include_once "./Modules/Test/classes/class.ilObjTest.php";
311  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
312  $available_tests =& ilObjTest::_getAvailableTests(1);
313  array_push($csv, ilUtil::processCSVRow($row, TRUE, $separator));
314  $log_output =& $this->object->getLog($from, $until, $test);
315  $users = array();
316  foreach ($log_output as $key => $log)
317  {
318  if (!array_key_exists($log["user_fi"], $users))
319  {
320  $users[$log["user_fi"]] = ilObjUser::_lookupName($log["user_fi"]);
321  }
322  $title = "";
323  if ($log["question_fi"] || $log["original_fi"])
324  {
325  $title = assQuestion::_getQuestionTitle($log["question_fi"]);
326  if (strlen($title) == 0)
327  {
328  $title = assQuestion::_getQuestionTitle($log["original_fi"]);
329  }
330  $title = $this->lng->txt("assessment_log_question") . ": " . $title;
331  }
332  $csvrow = array();
333  $date = new ilDateTime($log['tstamp'],IL_CAL_UNIX);
334  array_push($csvrow, $date->get(IL_CAL_FKT_DATE,'Y-m-d H:i'));
335  array_push($csvrow, trim($users[$log["user_fi"]]["title"] . " " . $users[$log["user_fi"]]["firstname"] . " " . $users[$log["user_fi"]]["lastname"]));
336  array_push($csvrow, trim($log["logtext"]));
337  array_push($csvrow, $title);
338  array_push($csv, ilUtil::processCSVRow($csvrow, TRUE, $separator));
339  }
340  $csvoutput = "";
341  foreach ($csv as $row)
342  {
343  $csvoutput .= join($row, $separator) . "\n";
344  }
345  ilUtil::deliverData($csvoutput, str_replace(" ", "_", "log_" . $from . "_" . $until . "_" . $available_tests[$test]).".csv");
346  }
347 
351  public function logsObject($p_from = null, $p_until = null, $p_test = null)
352  {
353  global $ilTabs;
354  $ilTabs->activateTab('logs');
355 
356  $template = new ilTemplate("tpl.assessment_logs.html", TRUE, TRUE, "Modules/Test");
357 
358  include_once "./Modules/Test/classes/class.ilObjTest.php";
359  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
360  $available_tests =& ilObjTest::_getAvailableTests(1);
361  if (count($available_tests) == 0)
362  {
363  ilUtil::sendInfo($this->lng->txt('assessment_log_no_data'));
364  return;
365  }
366 
367  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
368  $form = new ilPropertyFormGUI();
369  $form->setFormAction($this->ctrl->getFormAction($this));
370  $form->setTableWidth("100%");
371  $form->setId("logs");
372 
373  $header = new ilFormSectionHeaderGUI();
374  $header->setTitle($this->lng->txt("assessment_log"));
375  $form->addItem($header);
376 
377  // from
378  $from = new ilDateTimeInputGUI($this->lng->txt('cal_from'), "log_from");
379  $from->setShowDate(true);
380  $from->setShowTime(true);
381  $now = getdate();
382  $fromdate = ($p_from) ? $p_from : (($_GET['log_from']) ? $_GET['log_from'] : mktime(0, 0, 0, 1, 1, $now['year']));
383  $from->setDate(new ilDateTime($fromdate, IL_CAL_UNIX));
384  $form->addItem($from);
385 
386  // until
387  $until = new ilDateTimeInputGUI($this->lng->txt('cal_until'), "log_until");
388  $until->setShowDate(true);
389  $until->setShowTime(true);
390  $untildate = ($p_until) ? $p_until : (($_GET['log_until']) ? $_GET['log_until'] : time());
391  $until->setDate(new ilDateTime($untildate, IL_CAL_UNIX));
392  $form->addItem($until);
393 
394  // tests
395  $fortest = new ilSelectInputGUI($this->lng->txt('assessment_log_for_test'), "sel_test");
396  $sorted_options = array();
397  foreach($available_tests as $key => $value)
398  {
399  $sorted_options[] = array(
400  'title' => ilUtil::prepareFormOutput($value) . " [" . $this->object->getNrOfLogEntries($key) . " " . $this->lng->txt("assessment_log_log_entries") . "]",
401  'key' => $key
402  );
403  }
404  $sorted_options = ilUtil::sortArray($sorted_options, 'title','asc');
405  $options = array();
406  foreach($sorted_options as $option)
407  {
408  $options[$option['key']] = $option['title'];
409  }
410  $fortest->setOptions($options);
411  $p_test = ($p_test) ? $p_test : $_GET['sel_test'];
412  if ($p_test) $fortest->setValue($p_test);
413  $form->addItem($fortest);
414  $this->ctrl->setParameter($this, 'sel_test', $p_test);
415  $this->ctrl->setParameter($this, 'log_until', $untildate);
416  $this->ctrl->setParameter($this, 'log_from', $fromdate);
417  $form->addCommandButton("showLog", $this->lng->txt("show"));
418  $form->addCommandButton("exportLog", $this->lng->txt("export"));
419  $template->setVariable("FORM", $form->getHTML());
420 
421  if ($p_test)
422  {
423  include_once "./Modules/Test/classes/tables/class.ilAssessmentFolderLogTableGUI.php";
424  $table_gui = new ilAssessmentFolderLogTableGUI($this, 'logs');
425  $log_output =& $this->object->getLog($fromdate, $untildate, $p_test);
426  $table_gui->setData($log_output);
427  $template->setVariable('LOG', $table_gui->getHTML());
428  }
429  $this->tpl->setVariable("ADM_CONTENT", $template->get());
430  }
431 
435  public function deleteLogObject()
436  {
437  if (is_array($_POST["chb_test"]) && (count($_POST["chb_test"])))
438  {
439  $this->object->deleteLogEntries($_POST["chb_test"]);
440  ilUtil::sendSuccess($this->lng->txt("ass_log_deleted"));
441  }
442  else
443  {
444  ilUtil::sendInfo($this->lng->txt("ass_log_delete_no_selection"));
445  }
446  $this->logAdminObject();
447  }
448 
452  public function logAdminObject()
453  {
454  global $ilAccess, $ilTabs;
455 
456  $ilTabs->activateTab('logs');
457 
458  $a_write_access = ($ilAccess->checkAccess("write", "", $this->object->getRefId())) ? true : false;
459 
460  include_once "./Modules/Test/classes/tables/class.ilAssessmentFolderLogAdministrationTableGUI.php";
461  $table_gui = new ilAssessmentFolderLogAdministrationTableGUI($this, 'logAdmin', $a_write_access);
462  include_once "./Modules/Test/classes/class.ilObjTest.php";
463  $available_tests =& ilObjTest::_getAvailableTests(true);
464  $data = array();
465  foreach ($available_tests as $obj_id => $title)
466  {
467  $nr = $this->object->getNrOfLogEntries($obj_id);
468  array_push($data, array("title" => $title, "nr" => $nr, "id" => $obj_id));
469  }
470  $table_gui->setData($data);
471  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
472  }
473 
474  public function getAdminTabs(&$tabs_gui)
475  {
476  $this->getTabs($tabs_gui);
477  }
478 
479  public function getLogdataSubtabs()
480  {
481  global $ilTabs;
482 
483  // log settings
484  $ilTabs->addSubTabTarget("settings",
485  $this->ctrl->getLinkTarget($this, "showLogSettings"),
486  array("saveLogSettings", "showLogSettings")
487  , "");
488 
489  // log output
490  $ilTabs->addSubTabTarget("ass_log_output",
491  $this->ctrl->getLinkTarget($this, "logs"),
492  array("logs", "showLog", "exportLog")
493  , "");
494 
495  // log administration
496  $ilTabs->addSubTabTarget("ass_log_admin",
497  $this->ctrl->getLinkTarget($this, "logAdmin"),
498  array("logAdmin", "deleteLog"),
499  "", "");
500 
501  }
502 
506  public function defaultsObject()
507  {
508 
509  global $ilAccess, $rbacreview, $lng, $ilCtrl, $tpl, $ilTabs;
510 
511  $ilTabs->activateTab('defaults');
512 
513  $assessmentSetting = new ilSetting("assessment");
514  $use_javascript = array_key_exists("use_javascript", $_GET) ? $_GET["use_javascript"] : $assessmentSetting->get("use_javascript");
515  $imap_line_color = array_key_exists("imap_line_color", $_GET) ? $_GET["imap_line_color"] : $assessmentSetting->get("imap_line_color");
516  if (strlen($imap_line_color) == 0) $imap_line_color = "FF0000";
517 
518  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
519  $form = new ilPropertyFormGUI();
520  $form->setFormAction($ilCtrl->getFormAction($this));
521  $form->setTitle($lng->txt("assessment_defaults"));
522 
523  // Enable javascript
524  $enable = new ilCheckboxInputGUI($lng->txt("assessment_use_javascript"), "use_javascript");
525  $enable->setChecked($use_javascript);
526  $enable->setInfo($lng->txt("assessment_use_javascript_desc"));
527  $form->addItem($enable);
528 
529  $linepicker = new ilColorPickerInputGUI($lng->txt("assessment_imap_line_color"), "imap_line_color");
530  $linepicker->setValue($imap_line_color);
531  $form->addItem($linepicker);
532 
533  if (@file_exists("./Modules/Test/classes/class.ilTestResultsToXML.php"))
534  {
535  global $ilDB;
536  $user_criteria = array_key_exists("user_criteria", $_GET) ? $_GET["user_criteria"] : $assessmentSetting->get("user_criteria");
537  $userCriteria = new ilSelectInputGUI($this->lng->txt("user_criteria"), "user_criteria");
538  $userCriteria->setInfo($this->lng->txt("user_criteria_desc"));
539  $userCriteria->setRequired(true);
540 
541  //@Todo bheyser: $isSingleline is not defined...
542  $userCriteria->setValue(($isSingleline) ? 0 : 1);
543 
544  $manager = $ilDB->db->loadModule('Manager');
545  //$fields = $manager->listTableFields('usr_data');
546  $fields = array('usr_id', 'login', 'email', 'matriculation', 'ext_account');
547  $usr_fields = array();
548  foreach ($fields as $field)
549  {
550  $usr_fields[$field] = $field;
551  }
552  $userCriteria->setOptions($usr_fields);
553  $userCriteria->setValue($user_criteria);
554  $form->addItem($userCriteria);
555  }
556 
557  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
558  {
559  $form->addCommandButton("saveDefaults", $lng->txt("save"));
560  }
561 
562 
563  $tpl->setVariable("ADM_CONTENT", $form->getHTML());
564  }
565 
569  public function saveDefaultsObject()
570  {
571  global $ilCtrl;
572 
573  $assessmentSetting = new ilSetting("assessment");
574  if ($_POST["use_javascript"])
575  {
576  $assessmentSetting->set("use_javascript", "1");
577  }
578  else
579  {
580  $assessmentSetting->set("use_javascript", "0");
581  }
582  if (strlen($_POST["imap_line_color"]) == 6)
583  {
584  $assessmentSetting->set("imap_line_color", $_POST["imap_line_color"]);
585  }
586  if (@file_exists("./Modules/Test/classes/class.ilTestResultsToXML.php"))
587  {
588  $assessmentSetting->set("user_criteria", $_POST["user_criteria"]);
589  }
590  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
591  $ilCtrl->redirect($this, "defaults");
592  }
593 
594 
600  public function getTabs(&$tabs_gui)
601  {
602  global $rbacsystem, $lng;
603 
604  switch ($this->ctrl->getCmd())
605  {
606  case "saveLogSettings":
607  case "showLogSettings":
608  case "logs":
609  case "showLog":
610  case "exportLog":
611  case "logAdmin":
612  case "deleteLog":
613  $this->getLogdataSubtabs();
614  break;
615  }
616 
617  if ($rbacsystem->checkAccess("visible,read",$this->object->getRefId()))
618  {
619  $tabs_gui->addTarget("settings",
620  $this->ctrl->getLinkTarget($this, "settings"), array("settings","","view"), "", "");
621 
622  $tabs_gui->addTarget("logs",
623  $this->ctrl->getLinkTarget($this, "showLogSettings"),
624  array('saveLogSettings', 'showLogSettings', "logs","showLog", "exportLog", "logAdmin", "deleteLog"),
625  "", "");
626 
627  $tabs_gui->addTarget("defaults",
628  $this->ctrl->getLinkTarget($this, "defaults"), array("defaults","saveDefaults"), "", "");
629 
630  $tabs_gui->addTab("templates",
631  $lng->txt("adm_settings_templates"),
632  $this->ctrl->getLinkTargetByClass("ilsettingstemplategui", ""));
633  }
634 
635  if ($rbacsystem->checkAccess("write",$this->object->getRefId()))
636  {
637  $tabs_gui->addTarget('units', $this->ctrl->getLinkTargetByClass('ilGlobalUnitConfigurationGUI', ''), '', 'ilglobalunitconfigurationgui');
638  }
639 
640  if ($rbacsystem->checkAccess('edit_permission',$this->object->getRefId()))
641  {
642  $tabs_gui->addTarget("perm_settings",
643  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
644  }
645  }
646 
647 
653  public static function getSettingsTemplateConfig()
654  {
655  global $lng;
656 
657  $lng->loadLanguageModule("tst");
658  $lng->loadLanguageModule("assessment");
659 
660  include_once("./Services/Administration/classes/class.ilSettingsTemplateConfig.php");
661  $config = new ilSettingsTemplateConfig("tst");
662 
663  $config->addHidableTab("questions", $lng->txt('edit_test_questions'));
664  $config->addHidableTab("mark_schema", $lng->txt('settings') . ' - ' . $lng->txt("mark_schema"));
665  $config->addHidableTab("certificate", $lng->txt('settings') . ' - ' . $lng->txt("certificate"));
666  $config->addHidableTab("defaults", $lng->txt('settings') . ' - ' . $lng->txt("defaults"));
667 
668  $config->addHidableTab("learning_progress", $lng->txt("learning_progress"));
669  $config->addHidableTab("manscoring", $lng->txt("manscoring"));
670  $config->addHidableTab("history", $lng->txt("history"));
671  $config->addHidableTab("meta_data", $lng->txt("meta_data"));
672  $config->addHidableTab("export", $lng->txt("export"));
673  $config->addHidableTab("permissions", $lng->txt("permission"));
674 
676  // Settings
678 
679  //general properties
680  $config->addSetting(
681  "anonymity",
683  $lng->txt("tst_anonymity"),
684  false,
685  0,
686  array(
687  '0' => $lng->txt("tst_anonymity_no_anonymization"),
688  '1' => $lng->txt("tst_anonymity_anonymous_test"),
689  )
690  );
691 
692  $config->addSetting(
693  "title_output",
695  $lng->txt("tst_title_output"),
696  true,
697  0,
698  array(
699  '0' => $lng->txt("test_enable_view_table"),
700  '1' => $lng->txt("test_enable_view_express"),
701  '2' => $lng->txt("test_enable_view_both"),
702  )
703  );
704 
705  $config->addSetting(
706  "question_set_type",
708  $lng->txt("tst_question_set_type"),
709  true,
710  0,
711  array(
712  ilObjTest::QUESTION_SET_TYPE_FIXED => $lng->txt("tst_question_set_type_fixed"),
713  ilObjTest::QUESTION_SET_TYPE_RANDOM => $lng->txt("tst_question_set_type_random"),
714  ilObjTest::QUESTION_SET_TYPE_DYNAMIC => $lng->txt("tst_question_set_type_dynamic"),
715  )
716  );
717 
718  $config->addSetting(
719  "use_pool",
721  $lng->txt("test_question_pool_usage"),
722  true
723  );
724 
725  // Information at beginning and end of test
726  $config->addSetting(
727  "showinfo",
729  $lng->txt("showinfo"),
730  true
731  );
732 
733  $config->addSetting(
734  "showfinalstatement",
736  $lng->txt("final_statement_show"),
737  false
738  );
739 
740  // Session Settings
741  $config->addSetting(
742  "nr_of_tries",
744  $lng->txt("tst_nr_of_tries"),
745  false,
746  3
747  );
748 
749 
750  $config->addSetting(
751  "chb_processing_time",
753  $lng->txt("tst_processing_time"),
754  false
755  );
756 
757  $config->addSetting(
758  "chb_starting_time",
760  $lng->txt("tst_starting_time"),
761  false
762  );
763 
764  $config->addSetting(
765  "chb_ending_time",
767  $lng->txt("tst_ending_time"),
768  false
769  );
770 
771  $config->addSetting(
772  "password",
774  $lng->txt("tst_password"),
775  true,
776  20
777  );
778 
779  // Presentation Properties
780 
781  $config->addSetting(
782  "chb_use_previous_answers",
784  $lng->txt("tst_use_previous_answers"),
785  false
786  );
787  $config->addSetting(
788  "forcejs",
790  $lng->txt("forcejs_short"),
791  true
792  );
793 
794  $config->addSetting(
795  "title_output",
797  $lng->txt("tst_title_output"),
798  true,
799  0,
800  array(
801  '0' => $lng->txt("test_enable_view_table"),
802  '1' => $lng->txt("test_enable_view_express"),
803  '2' => $lng->txt("test_enable_view_both"),
804  )
805  );
806 
807  // Sequence Properties
808 
809  $config->addSetting(
810  "chb_postpone",
812  $lng->txt("tst_postpone"),
813  true
814  );
815  $config->addSetting(
816  "chb_shuffle_questions",
818  $lng->txt("tst_shuffle_questions"),
819  false
820  );
821  $config->addSetting(
822  "list_of_questions",
824  $lng->txt("tst_show_summary"),
825  false
826  );
827 
828  $config->addSetting(
829  "chb_show_marker",
831  $lng->txt("question_marking"),
832  true
833  );
834  $config->addSetting(
835  "chb_show_cancel",
837  $lng->txt("tst_show_cancel"),
838  true
839  );
840 
841  // Notifications
842 
843  $config->addSetting(
844  "mailnotification",
846  $lng->txt("tst_finish_notification"),
847  true,
848  0,
849  array(
850  '0' => $lng->txt("tst_finish_notification_no"),
851  '1' => $lng->txt("tst_finish_notification_simple"),
852  '2' => $lng->txt("tst_finish_notification_advanced"),
853  )
854  );
855 
856  $config->addSetting(
857  "mailnottype",
859  $lng->txt("mailnottype"),
860  true
861  );
862 
863  // Kiosk Mode
864 
865  $config->addSetting(
866  "kiosk",
868  $lng->txt("kiosk"),
869  true
870  );
871 
872 
873  // Participants Restriction
874 
875  $config->addSetting(
876  "fixedparticipants",
878  $lng->txt("participants_invitation"),
879  true
880  );
881 
882  $config->addSetting(
883  "allowedUsers",
885  $lng->txt("tst_allowed_users"),
886  true,
887  3
888  );
889 
890  $config->addSetting(
891  "allowedUsersTimeGap",
893  $lng->txt("tst_allowed_users_time_gap"),
894  true,
895  4
896  );
897 
899  // Scoring and Results
901 
902  $config->addSetting(
903  "count_system",
905  $lng->txt("tst_text_count_system"),
906  true,
907  0,
908  array(
909  '0' => $lng->txt("tst_count_partial_solutions"),
910  '1' => $lng->txt("tst_count_correct_solutions"),
911  )
912  );
913 
914  $config->addSetting(
915  "mc_scoring",
917  $lng->txt("tst_score_mcmr_questions"),
918  true,
919  0,
920  array(
921  '0' => $lng->txt("tst_score_mcmr_zero_points_when_unanswered"),
922  '1' => $lng->txt("tst_score_mcmr_use_scoring_system"),
923  )
924  );
925 
926  $config->addSetting(
927  "score_cutting",
929  $lng->txt("tst_score_cutting"),
930  true,
931  0,
932  array(
933  '0' => $lng->txt("tst_score_cut_question"),
934  '1' => $lng->txt("tst_score_cut_test"),
935  )
936  );
937 
938  $config->addSetting(
939  "pass_scoring",
941  $lng->txt("tst_pass_scoring"),
942  false,
943  0,
944  array(
945  '0' => $lng->txt("tst_pass_last_pass"),
946  '1' => $lng->txt("tst_pass_best_pass"),
947  )
948  );
949 
950  $config->addSetting(
951  "instant_feedback",
953  $lng->txt("tst_instant_feedback"),
954  false,
955  0,
956  array(
957  'instant_feedback_answer' => $lng->txt("tst_instant_feedback_answer_specific"),
958  'instant_feedback_points' => $lng->txt("tst_instant_feedback_results"),
959  'instant_feedback_solution' => $lng->txt("tst_instant_feedback_solution"),
960  )
961  );
962 
963  $config->addSetting(
964  "results_access",
966  $lng->txt("tst_results_access"),
967  false,
968  0,
969  array(
970  '1' => $lng->txt("tst_results_access_finished"),
971  '2' => $lng->txt("tst_results_access_always"),
972  '3' => $lng->txt("tst_results_access_never"),
973  '4' => $lng->txt("tst_results_access_date"),
974  )
975  );
976 
977  $config->addSetting(
978  "print_bs_with_res",
980  $lng->txt("tst_results_print_best_solution"),
981  true
982  );
983 
984  $config->addSetting(
985  "results_presentation",
987  $lng->txt("tst_results_presentation"),
988  false,
989  0,
990  array(
991  'pass_details' => $lng->txt("tst_show_pass_details"),
992  'solution_details' => $lng->txt("tst_show_solution_details"),
993  'solution_printview' => $lng->txt("tst_show_solution_printview"),
994  'solution_feedback' => $lng->txt("tst_show_solution_feedback"),
995  'solution_answers_only' => $lng->txt("tst_show_solution_answers_only"),
996  'solution_signature' => $lng->txt("tst_show_solution_signature"),
997  'solution_suggested' => $lng->txt("tst_show_solution_suggested"),
998  )
999  );
1000 
1001  $config->addSetting(
1002  "export_settings",
1004  $lng->txt("tst_export_settings"),
1005  true
1006  );
1007  return $config;
1008  }
1009 
1013  protected function showLogSettingsObject(ilPropertyFormGUI $form = null)
1014  {
1015  $this->tabs_gui->activateTab('logs');
1016 
1017  if(!($form instanceof ilPropertyFormGUI))
1018  {
1019  $form = $this->getLogSettingsForm();
1020  $form->setValuesByArray(array(
1021  'chb_assessment_logging' => $this->object->_enabledAssessmentLogging(),
1022  'reporting_language' => $this->object->_getLogLanguage()
1023  ));
1024  }
1025 
1026  $this->tpl->setContent($form->getHTML());
1027  }
1028 
1032  protected function saveLogSettingsObject()
1033  {
1037  global $ilAccess;
1038 
1039  if(!$ilAccess->checkAccess('write', '', $this->object->getRefId()))
1040  {
1041  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->WARNING);
1042  }
1043 
1044  $form = $this->getLogSettingsForm();
1045  if($form->checkInput())
1046  {
1047  $this->object->_enableAssessmentLogging((int)$form->getInput('chb_assessment_logging'));
1048  $this->object->_setLogLanguage($form->getInput('reporting_language'));
1049  $this->object->update();
1050  ilUtil::sendSuccess($this->lng->txt('saved_successfully'));
1051  }
1052 
1053  $form->setValuesByPost();
1054  $this->showLogSettingsObject($form);
1055  }
1056 
1060  protected function getLogSettingsForm()
1061  {
1065  global $ilAccess;
1066 
1067  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
1068  $form = new ilPropertyFormGUI();
1069  $form->setFormAction($this->ctrl->getFormAction($this, 'saveLogSettings'));
1070  $form->setTitle($this->lng->txt('assessment_log_logging'));
1071 
1072  $logging = new ilCheckboxInputGUI('', 'chb_assessment_logging');
1073  $logging->setValue(1);
1074  $logging->setOptionTitle($this->lng->txt('activate_assessment_logging'));
1075  $form->addItem($logging);
1076 
1077  $reporting = new ilSelectInputGUI($this->lng->txt('assessment_settings_reporting_language'), 'reporting_language');
1078  $languages = $this->lng->getInstalledLanguages();
1079  $this->lng->loadLanguageModule('meta');
1080  $options = array();
1081  foreach($languages as $lang)
1082  {
1083  $options[$lang] = $this->lng->txt('meta_l_' . $lang);
1084  }
1085  $reporting->setOptions($options);
1086  $form->addItem($reporting);
1087 
1088  if($ilAccess->checkAccess('write', '', $this->object->getRefId()))
1089  {
1090  $form->addCommandButton('saveLogSettings', $this->lng->txt('save'));
1091  }
1092 
1093  return $form;
1094  }
1095 }