ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjTestGUI.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
5 
6 include_once 'Modules/Test/exceptions/class.ilTestException.php';
7 include_once "./Services/Object/classes/class.ilObjectGUI.php";
8 include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
9 include_once "./Modules/Test/classes/class.ilObjAssessmentFolderGUI.php";
10 include_once 'Modules/Test/classes/class.ilTestExpressPage.php';
11 
41 {
44 
48  public $object = null;
49 
54  function ilObjTestGUI()
55  {
56  global $lng, $ilCtrl;
57  $lng->loadLanguageModule("assessment");
58  $this->type = "tst";
59  $this->ctrl =& $ilCtrl;
60  $this->ctrl->saveParameter($this, array("ref_id", "test_ref_id", "calling_test", "test_express_mode", "q_id"));
61  $this->ilObjectGUI("",$_GET["ref_id"], true, false);
62  // Added parameter if called from crs_objectives
63  if((int) $_GET['crs_show_result'])
64  {
65  $this->ctrl->saveParameter($this,'crs_show_result',(int) $_GET['crs_show_result']);
66  }
67  }
68 
72  function executeCommand()
73  {
74  global $ilAccess, $ilNavigationHistory, $ilCtrl, $ilErr;
75 
76  if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"])) && (!$ilAccess->checkAccess("visible", "", $_GET["ref_id"])))
77  {
78  global $ilias;
79  $ilias->raiseError($this->lng->txt("permission_denied"), $ilias->error_obj->MESSAGE);
80  }
81 
82  $cmd = $this->ctrl->getCmd("properties");
83 
84  $cmdsDisabledDueToOfflineStatus = array(
85  'resume', 'start', 'outUserResultsOverview', 'outUserListOfAnswerPasses'
86  );
87 
88  if( !$this->getCreationMode() && !$this->object->isOnline() && in_array($cmd, $cmdsDisabledDueToOfflineStatus) )
89  {
90  $cmd = 'infoScreen';
91  }
92 
93  $next_class = $this->ctrl->getNextClass($this);
94  $this->ctrl->setReturn($this, "properties");
95 
96  if (method_exists($this->object, "getTestStyleLocation")) $this->tpl->addCss($this->object->getTestStyleLocation("output"), "screen");
97 
98  // add entry to navigation history
99  if (!$this->getCreationMode() &&
100  $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
101  {
102  $ilNavigationHistory->addItem($_GET["ref_id"],
103  "ilias.php?baseClass=ilObjTestGUI&cmd=infoScreen&ref_id=".$_GET["ref_id"], "tst");
104  }
105 
106  if(!$this->getCreationMode())
107  {
108  if(IS_PAYMENT_ENABLED)
109  {
110  include_once 'Services/Payment/classes/class.ilPaymentObject.php';
111  if(ilPaymentObject::_requiresPurchaseToAccess($this->object->getRefId(), $type = (isset($_GET['purchasetype']) ? $_GET['purchasetype'] : NULL) ))
112  {
113  $this->setLocator();
114  $this->tpl->getStandardTemplate();
115 
116  include_once 'Services/Payment/classes/class.ilShopPurchaseGUI.php';
117  $pp = new ilShopPurchaseGUI((int)$_GET['ref_id']);
118  $ret = $this->ctrl->forwardCommand($pp);
119  $this->tpl->show();
120  exit();
121  }
122  }
123  }
124 
125  // elba hack for storing question id for inserting new question after
126  if ($_REQUEST['prev_qid']) {
127  global $___prev_question_id;
128  $___prev_question_id = $_REQUEST['prev_qid'];
129  $this->ctrl->setParameter($this, 'prev_qid', $_REQUEST['prev_qid']);
130  }
131 
132  switch($next_class)
133  {
134  case "ilinfoscreengui":
135  $this->prepareOutput();
136  $this->addHeaderAction();
137  $this->infoScreen(); // forwards command
138  break;
139  case 'ilmdeditorgui':
140  if(!$ilAccess->checkAccess('write','',$this->object->getRefId()))
141  {
142  $ilErr->raiseError($this->lng->txt('permission_denied'),$ilErr->WARNING);
143  }
144 
145  $this->prepareOutput();
146  $this->addHeaderAction();
147  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
148  $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
149  $md_gui->addObserver($this->object,'MDUpdateListener','General');
150 
151  $this->ctrl->forwardCommand($md_gui);
152  break;
153  case "iltestoutputgui":
154  include_once "./Modules/Test/classes/class.ilTestOutputGUI.php";
155  if (!$this->object->getKioskMode()) $this->prepareOutput();
156  $output_gui =& new ilTestOutputGUI($this->object);
157  $this->ctrl->forwardCommand($output_gui);
158  break;
159 
160  case "iltestevaluationgui":
161  $this->prepareOutput();
162  $this->addHeaderAction();
163  include_once "./Modules/Test/classes/class.ilTestEvaluationGUI.php";
164  $evaluation_gui =& new ilTestEvaluationGUI($this->object);
165  $this->ctrl->forwardCommand($evaluation_gui);
166  break;
167 
168  case "iltestservicegui":
169  $this->prepareOutput();
170  $this->addHeaderAction();
171  include_once "./Modules/Test/classes/class.ilTestServiceGUI.php";
172  $serviceGUI =& new ilTestServiceGUI($this->object);
173  $this->ctrl->forwardCommand($serviceGUI);
174  break;
175 
176  case 'ilpermissiongui':
177  $this->prepareOutput();
178  $this->addHeaderAction();
179  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
180  $perm_gui =& new ilPermissionGUI($this);
181  $ret =& $this->ctrl->forwardCommand($perm_gui);
182  break;
183 
184  case "illearningprogressgui":
185  $this->prepareOutput();
186  $this->addHeaderAction();
187  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
188  $new_gui =& new ilLearningProgressGUI(LP_MODE_REPOSITORY,$this->object->getRefId());
189  $this->ctrl->forwardCommand($new_gui);
190 
191  break;
192 
193  case "ilcertificategui":
194  $this->prepareOutput();
195  $this->addHeaderAction();
196  include_once "./Services/Certificate/classes/class.ilCertificateGUI.php";
197  include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
198  $output_gui = new ilCertificateGUI(new ilTestCertificateAdapter($this->object));
199  $this->ctrl->forwardCommand($output_gui);
200  break;
201 
202  case "iltestscoringgui":
203  $this->prepareOutput();
204  $this->addHeaderAction();
205  include_once "./Modules/Test/classes/class.ilTestScoringGUI.php";
206  $output_gui = new ilTestScoringGUI($this->object);
207  $this->ctrl->forwardCommand($output_gui);
208  break;
209 
210  case 'ilobjectcopygui':
211  $this->prepareOutput();
212  $this->addHeaderAction();
213  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
214  $cp = new ilObjectCopyGUI($this);
215  $cp->setType('tst');
216  $this->ctrl->forwardCommand($cp);
217  break;
218 
219  case 'ilrepositorysearchgui':
220  $this->prepareOutput();
221  $this->addHeaderAction();
222  include_once('./Services/Search/classes/class.ilRepositorySearchGUI.php');
223  $rep_search =& new ilRepositorySearchGUI();
224  $rep_search->setCallback($this,
225  'addParticipantsObject',
226  array(
227  )
228  );
229 
230  // Set tabs
231  $this->ctrl->setReturn($this,'participants');
232  $ret =& $this->ctrl->forwardCommand($rep_search);
233  $this->tabs_gui->setTabActive('participants');
234  break;
235 
236  case 'ilpageeditorgui':
237  case 'iltestexpresspageobjectgui':
238 global $ilDB, $ilUser;
239  require_once 'Modules/TestQuestionPool/classes/class.ilAssIncompleteQuestionPurger.php';
240  $incompleteQuestionPurger = new ilAssIncompleteQuestionPurger($ilDB);
241  $incompleteQuestionPurger->setOwnerId($ilUser->getId());
242  $incompleteQuestionPurger->purge();
243 
244  $qid = $_REQUEST['q_id'];
245 
246  // :FIXME: does not work
247  // $this->ctrl->saveParameterByClass(array('iltestexpresspageobjectgui', 'assorderingquestiongui', 'ilpageeditorgui', 'ilpcquestion', 'ilpcquestiongui'), 'test_express_mode');
248 
249  if (!$qid || $qid == 'Array') {
250  $questions = $this->object->getQuestionTitlesAndIndexes();
251  if (!is_array($questions))
252  $questions = array();
253 
254  $keys = array_keys($questions);
255  $qid = $keys[0];
256 
257  $_REQUEST['q_id'] = $qid;
258  $_GET['q_id'] = $qid;
259  $_POST['q_id'] = $qid;
260  }
261 
262 
263 
264  $this->prepareOutput();
265  if (!in_array($cmd, array('addQuestion', 'browseForQuestions'))) {
266  $this->buildPageViewToolbar($qid);
267  }
268 
269  if (!$qid || in_array($cmd, array('insertQuestions', 'browseForQuestions'))) {
270  include_once("./Modules/Test/classes/class.ilTestExpressPageObjectGUI.php");
271  $pageObject = new ilTestExpressPageObjectGUI ("qpl", 0);
272  $pageObject->test_object = $this->object;
273  $ret =& $this->ctrl->forwardCommand($pageObject);
274  break;
275  }
276  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
277  $this->tpl->setCurrentBlock("ContentStyle");
278  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
280  $this->tpl->parseCurrentBlock();
281 
282  // syntax style
283  $this->tpl->setCurrentBlock("SyntaxStyle");
284  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
286  $this->tpl->parseCurrentBlock();
287  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
288 
289  $q_gui =& assQuestionGUI::_getQuestionGUI("", $qid);
290 
291  $q_gui->outAdditionalOutput();
292  $q_gui->object->setObjId($this->object->getId());
293  $question =& $q_gui->object;
294  $this->ctrl->saveParameter($this, "q_id");
295 
296  #$this->lng->loadLanguageModule("content");
297  $this->ctrl->setReturnByClass("ilTestExpressPageObjectGUI", "view");
298  $this->ctrl->setReturn($this, "questions");
299 
300  //$page =& new ilPageObject("qpl", $_GET["q_id"]);
301  include_once("./Services/COPage/classes/class.ilPageObject.php");
302  include_once("./Modules/Test/classes/class.ilTestExpressPageObjectGUI.php");
303 
304  $page_gui =& new ilTestExpressPageObjectGUI ("qpl", $qid);
305  $page_gui->test_object = $this->object;
306  $page_gui->setEditPreview(true);
307  $page_gui->setEnabledTabs(false);
308  $page_gui->setEnabledInternalLinks(false);
309  if (strlen($this->ctrl->getCmd()) == 0)
310  {
311  $this->ctrl->setCmdClass(get_class($page_gui));
312  $this->ctrl->setCmd("preview");
313  }
314 
315  $page_gui->setQuestionHTML(array($q_gui->object->getId() => $q_gui->getPreview(TRUE)));
316  $page_gui->setTemplateTargetVar("ADM_CONTENT");
317 
318  $page_gui->setOutputMode($this->object->evalTotalPersons() == 0 ? "edit" : 'preview');
319 
320  $page_gui->setHeader($question->getTitle());
321  $page_gui->setFileDownloadLink($this->ctrl->getLinkTarget($this, "downloadFile"));
322  $page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "fullscreen"));
323  $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTarget($this));
324  $page_gui->setPresentationTitle($question->getTitle());
325  $ret =& $this->ctrl->forwardCommand($page_gui);
326 
327  global $ilTabs;
328  $ilTabs->activateTab('assQuestions');
329 
330  $this->tpl->setContent($ret);
331  break;
332 
333  case 'ilpageobjectgui':
334  include_once ("./Services/COPage/classes/class.ilPageObjectGUI.php");
335  //echo $_REQUEST['prev_qid'];
336  if ($_REQUEST['prev_qid']) {
337  $this->ctrl->setParameter($this, 'prev_qid', $_REQUEST['prev_qid']);
338  }
339 
340  $this->prepareOutput();
341  //global $___test_express_mode;
342  //$___test_express_mode = true;
343  $_GET['calling_test'] = $this->object->getRefId();
344  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
345  $this->tpl->setCurrentBlock("ContentStyle");
346  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
348  $this->tpl->parseCurrentBlock();
349 
350  // syntax style
351  $this->tpl->setCurrentBlock("SyntaxStyle");
352  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
354  $this->tpl->parseCurrentBlock();
355  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
356  $q_gui =& assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
357  $q_gui->setQuestionTabs();
358  $q_gui->outAdditionalOutput();
359  $q_gui->object->setObjId($this->object->getId());
360  $question =& $q_gui->object;
361  $this->ctrl->saveParameter($this, "q_id");
362  include_once("./Services/COPage/classes/class.ilPageObject.php");
363  include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
364  $this->lng->loadLanguageModule("content");
365  $this->ctrl->setReturnByClass("ilPageObjectGUI", "view");
366  $this->ctrl->setReturn($this, "questions");
367  //$page =& new ilPageObject("qpl", $_GET["q_id"]);
368  $page_gui =& new ilPageObjectGUI("qpl", $_GET["q_id"]);
369  $page_gui->setEditPreview(true);
370  $page_gui->setEnabledTabs(false);
371  $page_gui->setEnabledInternalLinks(false);
372  if (strlen($this->ctrl->getCmd()) == 0)
373  {
374  $this->ctrl->setCmdClass(get_class($page_gui));
375  $this->ctrl->setCmd("preview");
376  }
377  //$page_gui->setQuestionXML($question->toXML(false, false, true));
378  $page_gui->setQuestionHTML(array($q_gui->object->getId() => $q_gui->getPreview(TRUE)));
379  $page_gui->setTemplateTargetVar("ADM_CONTENT");
380  $page_gui->setOutputMode($this->object->evalTotalPersons() == 0 ? "edit" : 'preview');
381  $page_gui->setHeader($question->getTitle());
382  $page_gui->setFileDownloadLink($this->ctrl->getLinkTarget($this, "downloadFile"));
383  $page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "fullscreen"));
384  $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTarget($this));
385  $page_gui->setPresentationTitle($question->getTitle());
386  $ret =& $this->ctrl->forwardCommand($page_gui);
387  $this->tpl->setContent($ret);
388 
389  break;
390 
391  case "ilcommonactiondispatchergui":
392  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
394  $this->ctrl->forwardCommand($gui);
395  break;
396 
397  case 'ilassquestionhintsgui':
398 
399  $this->prepareSubGuiOutput();
400 
401  // set return target
402  $this->ctrl->setReturn($this, "questions");
403 
404  // set context tabs
405  require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
406  $questionGUI =& assQuestionGUI::_getQuestionGUI($q_type, $_GET['q_id']);
407  $questionGUI->object->setObjId($this->object->getId());
408  $questionGUI->setQuestionTabs();
409 
410  // forward to ilAssQuestionHintsGUI
411  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintsGUI.php';
412  $gui = new ilAssQuestionHintsGUI($questionGUI);
413  $ilCtrl->forwardCommand($gui);
414 
415  break;
416 
417  case 'iltesttoplistgui':
418 
419  $this->prepareOutput();
420 
421  require_once 'Modules/Test/classes/class.ilTestToplistGUI.php';
422  $gui = new ilTestToplistGUI($this);
423 
424  $this->ctrl->forwardCommand($gui);
425 
426  break;
427 
428  case '':
429  case 'ilobjtestgui':
430  $this->prepareOutput();
431  $this->addHeaderAction();
432  if (preg_match("/deleteqpl_\d+/", $cmd))
433  {
434  $cmd = "randomQuestions";
435  }
436  if ((strcmp($cmd, "properties") == 0) && ($_GET["browse"]))
437  {
438  $this->questionBrowser();
439  return;
440  }
441  if ((strcmp($cmd, "properties") == 0) && ($_GET["up"] || $_GET["down"]))
442  {
443  $this->questionsObject();
444  return;
445  }
446  $cmd.= "Object";
447  $ret =& $this->$cmd();
448  break;
449  default:
450  // elba hack for storing question id for inserting new question after
451  if ($_REQUEST['prev_qid']) {
452  global $___prev_question_id;
453  $___prev_question_id = $_REQUEST['prev_qid'];
454  $this->ctrl->setParameterByClass('ilpageobjectgui', 'prev_qid', $_REQUEST['prev_qid']);
455  $this->ctrl->setParameterByClass($_GET['sel_question_types'] . 'gui', 'prev_qid', $_REQUEST['prev_qid']);
456  }
457  $this->create_question_mode = true;
458  $this->prepareOutput();
459 
460  $this->ctrl->setReturn($this, "questions");
461  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
462  $q_gui =& assQuestionGUI::_getQuestionGUI($_GET['sel_question_types'], $_GET["q_id"]);
463  $q_gui->object->setObjId($this->object->getId());
464  if (!$_GET['sel_question_types'])
465  $qType = assQuestion::getQuestionTypeFromDb($_GET['q_id']);
466  else {
467  $qType = $_GET['sel_question_types'];
468  }
469  $this->ctrl->setParameterByClass($qType . "GUI", 'prev_qid', $_REQUEST['prev_qid']);
470  $this->ctrl->setParameterByClass($qType . "GUI", 'test_ref_id', $_REQUEST['ref_id']);
471  $this->ctrl->setParameterByClass($qType . "GUI", 'q_id', $_REQUEST['q_id']);
472  if ($_REQUEST['test_express_mode'])
473  $this->ctrl->setParameterByClass($qType . "GUI", 'test_express_mode', 1);
474 
475  #global $___test_express_mode;
476  #$___test_express_mode = true;
477  if (!$q_gui->isSaveCommand())
478  $_GET['calling_test'] = $this->object->getRefId();
479 
480  $q_gui->setQuestionTabs();
481  #unset($___test_express_mode);
482  $ret =& $this->ctrl->forwardCommand($q_gui);
483  break;
484  }
485  if (strtolower($_GET["baseClass"]) != "iladministrationgui" &&
486  $this->getCreationMode() != true)
487  {
488  $this->tpl->show();
489  }
490  }
491 
500  private function prepareSubGuiOutput()
501  {
502  global $ilUser;
503 
504  $this->tpl->getStandardTemplate();
505 
506  // set locator
507  $this->setLocator();
508 
509  // catch feedback message
511 
512  // set title and description and title icon
513  $this->setTitleAndDescription();
514 
515  // BEGIN WebDAV: Display Mount Webfolder icon.
516  require_once 'Services/WebDAV/classes/class.ilDAVServer.php';
517  if (ilDAVServer::_isActive() && $ilUser->getId() != ANONYMOUS_USER_ID)
518  {
519  $this->showMountWebfolderIcon();
520  }
521  // END WebDAV: Display Mount Webfolder icon.
522  }
523 
524  function runObject()
525  {
526  $this->ctrl->redirect($this, "infoScreen");
527  }
528 
530  {
531  $this->ctrl->redirectByClass("iltestevaluationgui", "outEvaluation");
532  }
533 
537  function importFileObject()
538  {
539  $form = $this->initImportForm($_REQUEST["new_type"]);
540  if($form->checkInput())
541  {
542  $this->ctrl->setParameter($this, "new_type", $this->type);
543  $this->uploadTstObject();
544  }
545 
546  // display form to correct errors
547  $form->setValuesByPost();
548  $this->tpl->setContent($form->getHTML());
549  }
550 
551  function addDidacticTemplateOptions(array &$a_options)
552  {
553  include_once("./Modules/Test/classes/class.ilObjTest.php");
554  $tst = new ilObjTest();
555  $defaults = $tst->getAvailableDefaults();
556  if (count($defaults))
557  {
558  foreach ($defaults as $row)
559  {
560  $a_options["tstdef_".$row["test_defaults_id"]] = array($row["name"],
561  $this->lng->txt("tst_default_settings"));
562  }
563  }
564 
565  // using template?
566  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
568  if($templates)
569  {
570  foreach($templates as $item)
571  {
572  $a_options["tsttpl_".$item["id"]] = array($item["title"],
573  nl2br(trim($item["description"])));
574  }
575  }
576  }
577 
582  function afterSave(ilObject $a_new_object)
583  {
584  $tstdef = $this->getDidacticTemplateVar("tstdef");
585  if ($tstdef)
586  {
587  $testDefaultsId = $tstdef;
588  $testDefaults = ilObjTest::_getTestDefaults($testDefaultsId);
589  $a_new_object->applyDefaults($testDefaults);
590  }
591 
592  $template_id = $this->getDidacticTemplateVar("tsttpl");
593  if($template_id)
594  {
595  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
597 
598  $template_settings = $template->getSettings();
599  if($template_settings)
600  {
601  $this->applyTemplate($template_settings, $a_new_object);
602  }
603 
604  $a_new_object->setTemplate($template_id);
605  }
606 
607  $a_new_object->saveToDb();
608 
609  // always send a message
610  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
611  ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&ref_id=".
612  $a_new_object->getRefId()."&cmd=properties");
613  }
614 
616  {
617  include_once "./Services/Utilities/classes/class.ilUtil.php";
618  $path = $this->tree->getPathFull($this->object->getRefID());
619  ilUtil::redirect($this->getReturnLocation("cancel","./ilias.php?baseClass=ilRepositoryGUI&cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
620  }
621 
623  {
624  include_once "./Services/Utilities/classes/class.ilUtil.php";
625  ilUtil::redirect($this->getReturnLocation("cancel","./ilias.php?baseClass=ilRepositoryGUI&ref_id=".(int) $_GET['crs_show_result']));
626  }
627 
628  /*
629  * list all export files
630  */
631  function exportObject()
632  {
633  global $tree;
634  global $ilAccess;
635  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
636  {
637  // allow only write access
638  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
639  $this->ctrl->redirect($this, "infoScreen");
640  }
641 
642  $export_dir = $this->object->getExportDirectory();
643  $export_files = $this->object->getExportFiles($export_dir);
644  $data = array();
645  if(count($export_files) > 0)
646  {
647  foreach($export_files as $exp_file)
648  {
649  $file_arr = explode("__", $exp_file);
650  array_push($data, array(
651  'file' => $exp_file,
652  'size' => filesize($export_dir."/".$exp_file),
653  'date' => $file_arr[0]
654  ));
655  }
656  }
657 
658  include_once "./Modules/Test/classes/tables/class.ilTestExportTableGUI.php";
659  $table_gui = new ilTestExportTableGUI($this, 'export');
660  $table_gui->setData($data);
661  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
662  }
663 
668  {
669  global $ilAccess;
670 
671  if ($ilAccess->checkAccess("write", "", $this->ref_id))
672  {
673  include_once("./Modules/Test/classes/class.ilTestExport.php");
674  $test_exp = new ilTestExport($this->object, 'xml');
675  $test_exp->buildExportFile();
676  }
677  else
678  {
679  ilUtil::sendInfo("cannot_export_test", TRUE);
680  }
681  $this->ctrl->redirect($this, "export");
682  }
683 
688  {
689  global $ilAccess;
690 
691  if ($ilAccess->checkAccess("write", "", $this->ref_id))
692  {
693  include_once("./Modules/Test/classes/class.ilTestExport.php");
694  $test_exp = new ilTestExport($this->object, 'results');
695  $test_exp->buildExportFile();
696  }
697  else
698  {
699  ilUtil::sendInfo("cannot_export_test", TRUE);
700  }
701  $this->ctrl->redirect($this, "export");
702  }
703 
704 
709  {
710  global $ilAccess;
711  if( !$ilAccess->checkAccess('write', '', $this->ref_id) )
712  {
713  ilUtil::sendInfo($this->lng->txt('no_permission'), true);
714  $this->ctrl->redirect($this, 'infoScreen');
715  }
716 
717  if(!isset($_POST["file"]))
718  {
719  ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
720  $this->ctrl->redirect($this, "export");
721  }
722 
723  if (count($_POST["file"]) > 1)
724  {
725  ilUtil::sendInfo($this->lng->txt("select_max_one_item"), true);
726  $this->ctrl->redirect($this, "export");
727  }
728 
729  $filename = basename($_POST["file"][0]);
730  $file = $this->object->getExportDirectory().'/'.$filename;
731 
732  if( !file_exists($file) )
733  {
734  $this->ctrl->redirect($this, 'export');
735  }
736 
738  }
739 
744  {
745  global $ilAccess;
746  if( !$ilAccess->checkAccess('write', '', $this->ref_id) )
747  {
748  ilUtil::sendInfo($this->lng->txt('no_permission'), true);
749  $this->ctrl->redirect($this, 'infoScreen');
750  }
751 
752  if (!isset($_POST["file"]))
753  {
754  ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
755  $this->ctrl->redirect($this, "export");
756  }
757 
758  ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
759 
760  $export_dir = $this->object->getExportDirectory();
761  $export_files = $this->object->getExportFiles($export_dir);
762  $data = array();
763  if (count($_POST["file"]) > 0)
764  {
765  foreach ($_POST["file"] as $exp_file)
766  {
767  $file_arr = explode("__", $exp_file);
768  array_push($data, array(
769  'file' => $exp_file,
770  'size' => filesize($export_dir."/".$exp_file),
771  'date' => $file_arr[0]
772  ));
773  }
774  }
775 
776  include_once "./Modules/Test/classes/tables/class.ilTestExportTableGUI.php";
777  $table_gui = new ilTestExportTableGUI($this, 'export', true);
778  $table_gui->setData($data);
779  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
780  }
781 
786  {
787  global $ilAccess;
788  if( !$ilAccess->checkAccess('write', '', $this->ref_id) )
789  {
790  ilUtil::sendInfo($this->lng->txt('no_permission'), true);
791  $this->ctrl->redirect($this, 'infoScreen');
792  }
793 
794  ilUtil::sendInfo($this->lng->txt("msg_cancel"), true);
795  $this->ctrl->redirect($this, "export");
796  }
797 
798 
803  {
804  global $ilAccess;
805  if( !$ilAccess->checkAccess('write', '', $this->ref_id) )
806  {
807  ilUtil::sendInfo($this->lng->txt('no_permission'), true);
808  $this->ctrl->redirect($this, 'infoScreen');
809  }
810 
811  $export_dir = $this->object->getExportDirectory();
812  foreach ($_POST["file"] as $file)
813  {
814  $file = basename($file);
815  $dir = substr($file, 0, strlen($file) - 4);
816 
817  if( !strlen($file) || !strlen($dir) )
818  {
819  continue;
820  }
821 
822  $exp_file = $export_dir."/".$file;
823  $exp_dir = $export_dir."/".$dir;
824  if (@is_file($exp_file))
825  {
826  unlink($exp_file);
827  }
828  if (@is_dir($exp_dir))
829  {
830  ilUtil::delDir($exp_dir);
831  }
832  }
833  ilUtil::sendSuccess($this->lng->txt('msg_deleted_export_files'), true);
834  $this->ctrl->redirect($this, "export");
835  }
836 
840  function uploadTstObject()
841  {
842  if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
843  {
844  ilUtil::sendFailure($this->lng->txt("error_upload"));
845  $this->createObject();
846  return;
847  }
848  include_once("./Modules/Test/classes/class.ilObjTest.php");
849  // create import directory
851 
852  // copy uploaded file to import directory
853  $file = pathinfo($_FILES["xmldoc"]["name"]);
854  $full_path = $basedir."/".$_FILES["xmldoc"]["name"];
855  ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path);
856 
857  // unzip file
858  ilUtil::unzip($full_path);
859 
860  // determine filenames of xml files
861  $subdir = basename($file["basename"],".".$file["extension"]);
863  $xml_file = ilObjTest::_getImportDirectory().'/'.$subdir.'/'.$subdir.".xml";
864  $qti_file = ilObjTest::_getImportDirectory().'/'.$subdir.'/'. preg_replace("/test|tst/", "qti", $subdir).".xml";
865  $results_file = ilObjTest::_getImportDirectory().'/'.$subdir.'/'. preg_replace("/test|tst/", "results", $subdir).".xml";
866 
867  // start verification of QTI files
868  include_once "./Services/QTI/classes/class.ilQTIParser.php";
869  $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, "");
870  $result = $qtiParser->startParsing();
871  $founditems =& $qtiParser->getFoundItems();
872 
873  if (count($founditems) == 0)
874  {
875  // nothing found
876 
877  // delete import directory
878  ilUtil::delDir($basedir);
879 
880  ilUtil::sendInfo($this->lng->txt("tst_import_no_items"));
881  $this->createObject();
882  return;
883  }
884 
885  $complete = 0;
886  $incomplete = 0;
887  foreach ($founditems as $item)
888  {
889  if (strlen($item["type"]))
890  {
891  $complete++;
892  }
893  else
894  {
895  $incomplete++;
896  }
897  }
898 
899  if ($complete == 0)
900  {
901  // delete import directory
902  ilUtil::delDir($basedir);
903 
904  ilUtil::sendInfo($this->lng->txt("qpl_import_non_ilias_files"));
905  $this->createObject();
906  return;
907  }
908 
909  $_SESSION["tst_import_results_file"] = $results_file;
910  $_SESSION["tst_import_xml_file"] = $xml_file;
911  $_SESSION["tst_import_qti_file"] = $qti_file;
912  $_SESSION["tst_import_subdir"] = $subdir;
913  // display of found questions
914  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.tst_import_verification.html", "Modules/Test");
915  $row_class = array("tblrow1", "tblrow2");
916  $counter = 0;
917  foreach ($founditems as $item)
918  {
919  $this->tpl->setCurrentBlock("verification_row");
920  $this->tpl->setVariable("ROW_CLASS", $row_class[$counter++ % 2]);
921  $this->tpl->setVariable("QUESTION_TITLE", $item["title"]);
922  $this->tpl->setVariable("QUESTION_IDENT", $item["ident"]);
923  include_once "./Services/QTI/classes/class.ilQTIItem.php";
924  switch ($item["type"])
925  {
926  case "MULTIPLE CHOICE QUESTION":
928  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("qt_multiple_choice"));
929  break;
930  case "SINGLE CHOICE QUESTION":
932  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assSingleChoice"));
933  break;
934  case "NUMERIC QUESTION":
935  case QT_NUMERIC:
936  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assNumeric"));
937  break;
938  case "TEXTSUBSET QUESTION":
939  case QT_TEXTSUBSET:
940  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextSubset"));
941  break;
942  case "CLOZE QUESTION":
943  case QT_CLOZE:
944  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assClozeTest"));
945  break;
946  case "IMAGE MAP QUESTION":
947  case QT_IMAGEMAP:
948  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assImagemapQuestion"));
949  break;
950  case "JAVA APPLET QUESTION":
951  case QT_JAVAAPPLET:
952  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assJavaApplet"));
953  break;
954  case "MATCHING QUESTION":
955  case QT_MATCHING:
956  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assMatchingQuestion"));
957  break;
958  case "ORDERING QUESTION":
959  case QT_ORDERING:
960  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assOrderingQuestion"));
961  break;
962  case "TEXT QUESTION":
963  case QT_TEXT:
964  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextQuestion"));
965  break;
966  }
967  $this->tpl->parseCurrentBlock();
968  }
969 
970  // on import creation screen the pool was chosen (-1 for no pool)
971  // BUT when no pool is available the input on creation screen is missing, so the field value -1 for no pool is not submitted.
972  $QplOrTstID = isset($_POST["qpl"]) && (int)$_POST["qpl"] != 0 ? $_POST["qpl"] : -1;
973 
974  $this->tpl->setCurrentBlock("adm_content");
975  $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt("question_type"));
976  $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("question_title"));
977  $this->tpl->setVariable("FOUND_QUESTIONS_INTRODUCTION", $this->lng->txt("tst_import_verify_found_questions"));
978  $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_tst"));
979  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
980  $this->tpl->setVariable("ARROW", ilUtil::getImagePath("arrow_downright.png"));
981  $this->tpl->setVariable("QUESTIONPOOL_ID", $QplOrTstID);
982  $this->tpl->setVariable("VALUE_IMPORT", $this->lng->txt("import"));
983  $this->tpl->setVariable("VALUE_CANCEL", $this->lng->txt("cancel"));
984  $this->tpl->parseCurrentBlock();
985  }
986 
991  {
992  include_once "./Modules/Test/classes/class.ilObjTest.php";
993  // create new questionpool object
994  $newObj = new ilObjTest(0, true);
995  // set type of questionpool object
996  $newObj->setType($_GET["new_type"]);
997  // set title of questionpool object to "dummy"
998  $newObj->setTitle("dummy");
999  // set description of questionpool object
1000  $newObj->setDescription("test import");
1001  // create the questionpool class in the ILIAS database (object_data table)
1002  $newObj->create(true);
1003  // create a reference for the questionpool object in the ILIAS database (object_reference table)
1004  $newObj->createReference();
1005  // put the questionpool object in the administration tree
1006  $newObj->putInTree($_GET["ref_id"]);
1007  // get default permissions and set the permissions for the questionpool object
1008  $newObj->setPermissions($_GET["ref_id"]);
1009  // notify the questionpool object and all its parent objects that a "new" object was created
1010  $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
1011  // empty mark schema
1012  $newObj->mark_schema->flush();
1013 
1014  // start parsing of QTI files
1015  include_once "./Services/QTI/classes/class.ilQTIParser.php";
1016 
1017  // Handle selection of "no questionpool" as qpl_id = -1 -> use test object id instead.
1018  // TODO: chek if empty strings in $_POST["qpl_id"] relates to a bug or not
1019  if ($_POST["qpl_id"] == "-1")
1020  {
1021  $qpl_id = $newObj->id;
1022  }
1023  else
1024  {
1025  $qpl_id = $_POST["qpl_id"];
1026  }
1027 
1028  $qtiParser = new ilQTIParser($_SESSION["tst_import_qti_file"], IL_MO_PARSE_QTI, $qpl_id, $_POST["ident"]);
1029  $qtiParser->setTestObject($newObj);
1030  $result = $qtiParser->startParsing();
1031  $newObj->saveToDb();
1032 
1033  // import page data
1034  include_once ("./Modules/LearningModule/classes/class.ilContObjParser.php");
1035  $contParser = new ilContObjParser($newObj, $_SESSION["tst_import_xml_file"], $_SESSION["tst_import_subdir"]);
1036  $contParser->setQuestionMapping($qtiParser->getImportMapping());
1037  $contParser->startParsing();
1038 
1039  // import test results
1040  if (@file_exists($_SESSION["tst_import_results_file"]))
1041  {
1042  include_once ("./Modules/Test/classes/class.ilTestResultsImportParser.php");
1043  $results = new ilTestResultsImportParser($_SESSION["tst_import_results_file"], $newObj);
1044  $results->startParsing();
1045  }
1046 
1047  // delete import directory
1049  ilUtil::sendSuccess($this->lng->txt("object_imported"),true);
1050 
1051  $newObj->updateMetaData();
1052 
1053  ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
1054  "&baseClass=ilObjTestGUI");
1055  }
1056 
1063  function uploadObject($redirect = true)
1064  {
1065  $this->uploadTstObject();
1066  }
1067 
1079  function confirmChangeProperties($direction = self::SWITCH_RANDOM_TEST_SETTING_TO_DISABLED, $confirmCmd = 'saveProperties', $cancelCmd = 'properties')
1080  {
1081  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_properties_save_confirmation.html", "Modules/Test");
1082  $information = "";
1083  switch ($direction)
1084  {
1085  case self::SWITCH_RANDOM_TEST_SETTING_TO_DISABLED:
1086  $information = $this->lng->txt("change_properties_from_random_to_standard");
1087  break;
1088  case self::SWITCH_RANDOM_TEST_SETTING_TO_ENABLED:
1089  default:
1090  $information = $this->lng->txt("change_properties_from_standard_to_random");
1091  break;
1092  }
1093  foreach ($_POST as $key => $value)
1094  {
1095  if (strcmp($key, "cmd") != 0)
1096  {
1097  if (is_array($value))
1098  {
1099  foreach ($value as $k => $v)
1100  {
1101  $this->tpl->setCurrentBlock("hidden_variable");
1102  $this->tpl->setVariable("HIDDEN_KEY", $key . "[" . $k . "]");
1103  $this->tpl->setVariable("HIDDEN_VALUE", $v);
1104  $this->tpl->parseCurrentBlock();
1105  }
1106  }
1107  else
1108  {
1109  $this->tpl->setCurrentBlock("hidden_variable");
1110  $this->tpl->setVariable("HIDDEN_KEY", $key);
1111  $this->tpl->setVariable("HIDDEN_VALUE", $value);
1112  $this->tpl->parseCurrentBlock();
1113  }
1114  }
1115  }
1116  $this->tpl->setCurrentBlock("hidden_variable");
1117  $this->tpl->setVariable("HIDDEN_KEY", "tst_properties_confirmation");
1118  $this->tpl->setVariable("HIDDEN_VALUE", "1");
1119  $this->tpl->parseCurrentBlock();
1120  $this->tpl->setCurrentBlock("adm_content");
1121  $this->tpl->setVariable("TXT_CONFIRMATION", $this->lng->txt("confirmation"));
1122  $this->tpl->setVariable("TXT_INFORMATION", $information);
1123  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
1124  $this->tpl->setVariable("CMD_CONFIRM", $confirmCmd);
1125  $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
1126  $this->tpl->setVariable("CMD_CANCEL", $cancelCmd);
1127  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
1128  $this->tpl->parseCurrentBlock();
1129  }
1130 
1137  {
1138  $hasErrors = $this->scoringObject(true);
1139  if (!$hasErrors)
1140  {
1141  $total = $this->object->evalTotalPersons();
1142  // Check the values the user entered in the form
1143  if (!$total)
1144  {
1145  $this->object->setCountSystem($_POST["count_system"]);
1146  $this->object->setMCScoring($_POST["mc_scoring"]);
1147  $this->object->setScoreCutting($_POST["score_cutting"]);
1148  $this->object->setPassScoring($_POST["pass_scoring"]);
1149 
1150  if( isset($_POST['obligations_enabled']) && $_POST['obligations_enabled'] )
1151  {
1152  $this->object->setObligationsEnabled(true);
1153  }
1154  else
1155  {
1156  $this->object->setObligationsEnabled(false);
1157  }
1158 
1159  if( isset($_POST['offer_hints']) && $_POST['offer_hints'] )
1160  {
1161  $this->object->setOfferingQuestionHintsEnabled(true);
1162  }
1163  else
1164  {
1165  $this->object->setOfferingQuestionHintsEnabled(false);
1166  }
1167  }
1168 
1169  /*
1170  $this->object->setAnswerFeedback((is_array($_POST['instant_feedback']) && in_array('instant_feedback_answer', $_POST['instant_feedback'])) ? 1 : 0);
1171  $this->object->setAnswerFeedbackPoints((is_array($_POST['instant_feedback']) && in_array('instant_feedback_points', $_POST['instant_feedback'])) ? 1 : 0);
1172  $this->object->setInstantFeedbackSolution((is_array($_POST['instant_feedback']) && in_array('instant_feedback_solution', $_POST['instant_feedback'])) ? 1 : 0);
1173  */
1174 
1179  $this->object->setScoringFeedbackOptionsByArray($_POST['instant_feedback']);
1180 
1181 
1182  $this->object->setScoreReporting($_POST["results_access"]);
1183  if ($this->object->getScoreReporting() == REPORT_AFTER_DATE)
1184  {
1185  $this->object->setReportingDate(str_replace(array(':', '-'), '', $_POST["reporting_date"]['date'].$_POST["reporting_date"]['time']));
1186  }
1187  else
1188  {
1189  $this->object->setReportingDate('');
1190  }
1191 
1192  $this->object->setShowPassDetails((is_array($_POST['results_presentation']) && in_array('pass_details', $_POST['results_presentation'])) ? 1 : 0);
1193  $this->object->setShowSolutionDetails((is_array($_POST['results_presentation']) && in_array('solution_details', $_POST['results_presentation'])) ? 1 : 0);
1194  $this->object->setShowSolutionPrintview((is_array($_POST['results_presentation']) && in_array('solution_printview', $_POST['results_presentation'])) ? 1 : 0);
1195  $this->object->setShowSolutionFeedback((is_array($_POST['results_presentation']) && in_array('solution_feedback', $_POST['results_presentation'])) ? 1 : 0);
1196  $this->object->setShowSolutionAnswersOnly((is_array($_POST['results_presentation']) && in_array('solution_answers_only', $_POST['results_presentation'])) ? 1 : 0);
1197  $this->object->setShowSolutionSignature((is_array($_POST['results_presentation']) && in_array('solution_signature', $_POST['results_presentation'])) ? 1 : 0);
1198  $this->object->setShowSolutionSuggested((is_array($_POST['results_presentation']) && in_array('solution_suggested', $_POST['results_presentation'])) ? 1 : 0);
1199 
1200  $this->object->setExportSettingsSingleChoiceShort((is_array($_POST['export_settings']) && in_array('exp_sc_short', $_POST['export_settings'])) ? 1 : 0);
1201 
1202  $this->object->setPrintBestSolutionWithResult((int) $_POST['print_bs_with_res'] ? true : false);
1203 
1204  $this->object->setPassDeletionAllowed((bool)$_POST['pass_deletion_allowed']);
1205 
1206  $this->object->saveToDb(true);
1207  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), TRUE);
1208  $this->ctrl->redirect($this, "scoring");
1209  }
1210  }
1211 
1217  function scoringObject($checkonly = FALSE)
1218  {
1219  global $ilAccess;
1220  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
1221  {
1222  // allow only write access
1223  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
1224  $this->ctrl->redirect($this, "infoScreen");
1225  }
1226 
1227 
1228  // using template?
1229  $template_settings = null;
1230  $template = $this->object->getTemplate();
1231 
1232  if($template)
1233  {
1234  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
1235  include_once "Modules/Test/classes/class.ilObjAssessmentFolderGUI.php";
1236 
1238 
1239  $template_settings = $template->getSettings();
1240  }
1241 
1242  $save = (strcmp($this->ctrl->getCmd(), "saveScoring") == 0) ? TRUE : FALSE;
1243  $total = $this->object->evalTotalPersons();
1244  $this->tpl->addJavascript("./Services/JavaScript/js/Basic.js");
1245 
1246  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1247  $form = new ilPropertyFormGUI();
1248  $form->setFormAction($this->ctrl->getFormAction($this));
1249  $form->setTableWidth("100%");
1250  $form->setId("test_properties_scoring");
1251 
1252  // scoring properties
1253  $header = new ilFormSectionHeaderGUI();
1254  $header->setTitle($this->lng->txt("scoring"));
1255  $form->addItem($header);
1256 
1257  // scoring system
1258  $count_system = new ilRadioGroupInputGUI($this->lng->txt("tst_text_count_system"), "count_system");
1259  $count_system->addOption(new ilRadioOption($this->lng->txt("tst_count_partial_solutions"), 0, ''));
1260  $count_system->addOption(new ilRadioOption($this->lng->txt("tst_count_correct_solutions"), 1, ''));
1261  $count_system->setValue($this->object->getCountSystem());
1262  $count_system->setInfo($this->lng->txt("tst_count_system_description"));
1263  if ($total)
1264  {
1265  $count_system->setDisabled(true);
1266  }
1267  $form->addItem($count_system);
1268 
1269  // mc questions
1270  $mc_scoring = new ilRadioGroupInputGUI($this->lng->txt("tst_score_mcmr_questions"), "mc_scoring");
1271  $mc_scoring->addOption(new ilRadioOption($this->lng->txt("tst_score_mcmr_zero_points_when_unanswered"), 0, ''));
1272  $mc_scoring->addOption(new ilRadioOption($this->lng->txt("tst_score_mcmr_use_scoring_system"), 1, ''));
1273  $mc_scoring->setValue($this->object->getMCScoring());
1274  $mc_scoring->setInfo($this->lng->txt("tst_score_mcmr_questions_description"));
1275  if ($total)
1276  {
1277  $mc_scoring->setDisabled(true);
1278  }
1279  $form->addItem($mc_scoring);
1280 
1281  // score cutting
1282  $score_cutting = new ilRadioGroupInputGUI($this->lng->txt("tst_score_cutting"), "score_cutting");
1283  $score_cutting->addOption(new ilRadioOption($this->lng->txt("tst_score_cut_question"), 0, ''));
1284  $score_cutting->addOption(new ilRadioOption($this->lng->txt("tst_score_cut_test"), 1, ''));
1285  $score_cutting->setValue($this->object->getScoreCutting());
1286  $score_cutting->setInfo($this->lng->txt("tst_score_cutting_description"));
1287  if ($total)
1288  {
1289  $score_cutting->setDisabled(true);
1290  }
1291  $form->addItem($score_cutting);
1292 
1293  // pass scoring
1294  $pass_scoring = new ilRadioGroupInputGUI($this->lng->txt("tst_pass_scoring"), "pass_scoring");
1295  $pass_scoring->addOption(new ilRadioOption($this->lng->txt("tst_pass_last_pass"), 0, ''));
1296  $pass_scoring->addOption(new ilRadioOption($this->lng->txt("tst_pass_best_pass"), 1, ''));
1297  $pass_scoring->setValue($this->object->getPassScoring());
1298  $pass_scoring->setInfo($this->lng->txt("tst_pass_scoring_description"));
1299  if ($total)
1300  {
1301  $pass_scoring->setDisabled(true);
1302  }
1303  $form->addItem($pass_scoring);
1304 
1305  // enable obligations
1306  $checkBoxEnableObligations = new ilCheckboxInputGUI($this->lng->txt("tst_setting_enable_obligations_label"), "obligations_enabled");
1307  $checkBoxEnableObligations->setChecked($this->object->areObligationsEnabled());
1308  $checkBoxEnableObligations->setInfo($this->lng->txt("tst_setting_enable_obligations_info"));
1309  if( $total )
1310  {
1311  $checkBoxEnableObligations->setDisabled(true);
1312  }
1313  $form->addItem($checkBoxEnableObligations);
1314 
1315 
1316  // offer hints
1317  $checkBoxOfferHints = new ilCheckboxInputGUI($this->lng->txt("tst_setting_offer_hints_label"), "offer_hints");
1318  $checkBoxOfferHints->setChecked($this->object->isOfferingQuestionHintsEnabled());
1319  $checkBoxOfferHints->setInfo($this->lng->txt("tst_setting_offer_hints_info"));
1320  if( $total )
1321  {
1322  $checkBoxOfferHints->setDisabled(true);
1323  }
1324  $form->addItem($checkBoxOfferHints);
1325 
1326  // instant feedback
1327  $instant_feedback = new ilCheckboxGroupInputGUI($this->lng->txt("tst_instant_feedback"), "instant_feedback");
1328  $instant_feedback->addOption(new ilCheckboxOption($this->lng->txt("tst_instant_feedback_answer_specific"), 'instant_feedback_specific', ''));
1329  $instant_feedback->addOption(new ilCheckboxOption($this->lng->txt("tst_instant_feedback_answer_generic"), 'instant_feedback_generic', ''));
1330  $instant_feedback->addOption(new ilCheckboxOption($this->lng->txt("tst_instant_feedback_results"), 'instant_feedback_points', ''));
1331  $instant_feedback->addOption(new ilCheckboxOption($this->lng->txt("tst_instant_feedback_solution"), 'instant_feedback_solution', ''));
1332  $values = array();
1333  if ($this->object->getSpecificAnswerFeedback()) array_push($values, 'instant_feedback_specific');
1334  if ($this->object->getGenericAnswerFeedback()) array_push($values, 'instant_feedback_generic');
1335  if ($this->object->getAnswerFeedbackPoints()) array_push($values, 'instant_feedback_points');
1336  if ($this->object->getInstantFeedbackSolution()) array_push($values, 'instant_feedback_solution');
1337  $instant_feedback->setValue($values);
1338  $instant_feedback->setInfo($this->lng->txt("tst_instant_feedback_description"));
1339  $form->addItem($instant_feedback);
1340 
1341  // access to test results
1342  $results_access = new ilRadioGroupInputGUI($this->lng->txt("tst_results_access"), "results_access");
1343  $results_access->addOption(new ilRadioOption($this->lng->txt("tst_results_access_always"), 2, ''));
1344  $results_access->addOption(new ilRadioOption($this->lng->txt("tst_results_access_finished"), 1, ''));
1345  $results_access_date_limitation = new ilRadioOption($this->lng->txt("tst_results_access_date"), 3, '');
1346  $results_access->addOption($results_access_date_limitation);
1347  $results_access->addOption(new ilRadioOption($this->lng->txt("tst_results_access_never"), 4, ''));
1348  $results_access->setValue($this->object->getScoreReporting());
1349  $results_access->setInfo($this->lng->txt("tst_results_access_description"));
1350 
1351  // access date
1352  $reporting_date = new ilDateTimeInputGUI('', 'reporting_date');
1353  $reporting_date->setShowDate(true);
1354  $reporting_date->setShowTime(true);
1355  if (strlen($this->object->getReportingDate()))
1356  {
1357  $reporting_date->setDate(new ilDateTime($this->object->getReportingDate(), IL_CAL_TIMESTAMP));
1358  }
1359  else
1360  {
1361  $reporting_date->setDate(new ilDateTime(time(), IL_CAL_UNIX));
1362  }
1363  $results_access_date_limitation->addSubItem($reporting_date);
1364  $form->addItem($results_access);
1365 
1366  $results_print_best_solution = new ilCheckboxInputGUI($this->lng->txt("tst_results_print_best_solution"), "print_bs_with_res");
1367  $results_print_best_solution->setInfo($this->lng->txt('tst_results_print_best_solution_info'));
1368  $results_print_best_solution->setValue(1);
1369  $results_print_best_solution->setChecked((bool) $this->object->isBestSolutionPrintedWithResult());
1370  $form->addItem($results_print_best_solution);
1371 
1372  // results presentation
1373  $results_presentation = new ilCheckboxGroupInputGUI($this->lng->txt("tst_results_presentation"), "results_presentation");
1374  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_pass_details"), 'pass_details', ''));
1375  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_details"), 'solution_details', ''));
1376  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_printview"), 'solution_printview', ''));
1377  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_feedback"), 'solution_feedback', ''));
1378  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_answers_only"), 'solution_answers_only', ''));
1379  $signatureOption = new ilCheckboxOption($this->lng->txt("tst_show_solution_signature"), 'solution_signature', '');
1380  $results_presentation->addOption($signatureOption);
1381  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_suggested"), 'solution_suggested', ''));
1382  $values = array();
1383  if ($this->object->getShowPassDetails()) array_push($values, 'pass_details');
1384  if ($this->object->getShowSolutionDetails()) array_push($values, 'solution_details');
1385  if ($this->object->getShowSolutionPrintview()) array_push($values, 'solution_printview');
1386  if ($this->object->getShowSolutionFeedback()) array_push($values, 'solution_feedback');
1387  if ($this->object->getShowSolutionAnswersOnly()) array_push($values, 'solution_answers_only');
1388  if ($this->object->getShowSolutionSignature()) array_push($values, 'solution_signature');
1389  if ($this->object->getShowSolutionSuggested()) array_push($values, 'solution_suggested');
1390  $results_presentation->setValue($values);
1391  $results_presentation->setInfo($this->lng->txt("tst_results_presentation_description"));
1392  if ($this->object->getAnonymity())
1393  {
1394  $signatureOption->setDisabled(true);
1395  }
1396  $form->addItem($results_presentation);
1397 
1398  // deletion of test results
1399  $passDeletion = new ilRadioGroupInputGUI($this->lng->txt("tst_pass_deletion"), "pass_deletion_allowed");
1400  $passDeletion->addOption(new ilRadioOption($this->lng->txt("tst_pass_deletion_not_allowed"), 0, ''));
1401  $passDeletion->addOption(new ilRadioOption($this->lng->txt("tst_pass_deletion_allowed"), 1, ''));
1402  $passDeletion->setValue($this->object->isPassDeletionAllowed());
1403  $form->addItem($passDeletion);
1404 
1405  // export settings
1406  $export_settings = new ilCheckboxGroupInputGUI($this->lng->txt("tst_export_settings"), "export_settings");
1407  $export_settings->addOption(new ilCheckboxOption($this->lng->txt("tst_exp_sc_short"), 'exp_sc_short', ''));
1408  $values = array();
1409  if ($this->object->getExportSettingsSingleChoiceShort()) array_push($values, 'exp_sc_short');
1410  $export_settings->setValue($values);
1411  $form->addItem($export_settings);
1412 
1413  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) $form->addCommandButton("saveScoring", $this->lng->txt("save"));
1414 
1415  // remove items when using template
1416  if($template_settings)
1417  {
1418  foreach($template_settings as $id => $item)
1419  {
1420  if($item["hide"])
1421  {
1422  $form->removeItemByPostVar($id);
1423  }
1424  }
1425  }
1426 
1427  $errors = false;
1428 
1429  if ($save)
1430  {
1431  $errors = !$form->checkInput();
1432  $form->setValuesByPost();
1433  if ($errors) $checkonly = false;
1434  }
1435  if (!$checkonly) $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
1436  return $errors;
1437  }
1438 
1444  function propertiesObject($checkonly = FALSE)
1445  {
1446  global $ilAccess;
1447  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
1448  {
1449  // allow only write access
1450  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
1451  $this->ctrl->redirect($this, "infoScreen");
1452  }
1453 
1454  // using template?
1455  $template_settings = null;
1456  $template = $this->object->getTemplate();
1457 
1458  if($template)
1459  {
1460  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
1462 
1463  $template_settings = $template->getSettings();
1464  $hide_rte_switch = $template_settings["rte_switch"]["hide"];
1465  }
1466 
1467  $save = (strcmp($this->ctrl->getCmd(), "saveProperties") == 0) ? TRUE : FALSE;
1468  $total = $this->object->evalTotalPersons();
1469  $this->tpl->addJavascript("./Services/JavaScript/js/Basic.js");
1470 
1471  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1472  $form = new ilPropertyFormGUI();
1473  $form->setFormAction($this->ctrl->getFormAction($this));
1474  $form->setTableWidth("100%");
1475  $form->setId("test_properties");
1476 
1477  if(!$template || $template && $this->formShowGeneralSection($template_settings)) {
1478  // general properties
1479  $header = new ilFormSectionHeaderGUI();
1480  $header->setTitle($this->lng->txt("tst_general_properties"));
1481  $form->addItem($header);
1482  }
1483 
1484  // title & description (meta data)
1485 
1486  include_once 'Services/MetaData/classes/class.ilMD.php';
1487  $md_obj = new ilMD($this->object->getId(), 0, "tst");
1488  $md_section = $md_obj->getGeneral();
1489 
1490  $title = new ilTextInputGUI($this->lng->txt("title"), "title");
1491  $title->setRequired(true);
1492  $title->setValue($md_section->getTitle());
1493  $form->addItem($title);
1494 
1495  $ids = $md_section->getDescriptionIds();
1496  if($ids)
1497  {
1498  $desc_obj = $md_section->getDescription(array_pop($ids));
1499 
1500  $desc = new ilTextAreaInputGUI($this->lng->txt("description"), "description");
1501  $desc->setCols(50);
1502  $desc->setRows(4);
1503  $desc->setValue($desc_obj->getDescription());
1504  $form->addItem($desc);
1505  }
1506 
1507  // anonymity
1508  $anonymity = new ilRadioGroupInputGUI($this->lng->txt('tst_anonymity'), 'anonymity');
1509  if ($total) $anonymity->setDisabled(true);
1510  $rb = new ilRadioOption($this->lng->txt('tst_anonymity_no_anonymization'), 0);
1511  $anonymity->addOption($rb);
1512  $rb = new ilRadioOption($this->lng->txt('tst_anonymity_anonymous_test'), 1);
1513  $anonymity->addOption($rb);
1514  $anonymity->setValue((int)$this->object->getAnonymity());
1515  $form->addItem($anonymity);
1516 
1517  // random selection of questions
1518  $random = new ilCheckboxInputGUI($this->lng->txt("tst_random_selection"), "random_test");
1519  $random->setValue(1);
1520  if ($total) $random->setDisabled(true);
1521  $random->setChecked($this->object->isRandomTest());
1522 
1523  $info = $this->lng->txt("tst_random_test_description");
1524  if ($this->object->hasQuestionsWithoutQuestionpool()) {
1525  $info .= $this->lng->txt("tst_random_test_description_warning");
1526  }
1527  $random->setInfo($info);
1528  $form->addItem($random);
1529 
1530  // pool usage
1531  $pool_usage = new ilCheckboxInputGUI($this->lng->txt("test_question_pool_usage"), "use_pool");
1532  $pool_usage->setValue(1);
1533  $pool_usage->setChecked($this->object->getPoolUsage());
1534  $form->addItem($pool_usage);
1535 
1536 
1537  // activation/availability (no template support yet)
1538 
1539  include_once "Services/Object/classes/class.ilObjectActivation.php";
1540  $this->lng->loadLanguageModule('rep');
1541 
1543  $section->setTitle($this->lng->txt('rep_activation_availability'));
1544  $form->addItem($section);
1545 
1546  // additional info only with multiple references
1547  $act_obj_info = $act_ref_info = "";
1548  if(sizeof(ilObject::_getAllReferences($this->object->getId())) > 1)
1549  {
1550  $act_obj_info = ' '.$this->lng->txt('rep_activation_online_object_info');
1551  $act_ref_info = $this->lng->txt('rep_activation_access_ref_info');
1552  }
1553 
1554  $online = new ilCheckboxInputGUI($this->lng->txt('rep_activation_online'),'online');
1555  $online->setChecked($this->object->isOnline());
1556  $online->setInfo($this->lng->txt('tst_activation_online_info').$act_obj_info);
1557  $form->addItem($online);
1558 
1559  $act_type = new ilRadioGroupInputGUI($this->lng->txt('rep_activation_access'),'activation_type');
1560  $act_type->setInfo($act_ref_info);
1561  $act_type->setValue($this->object->isActivationLimited() ?
1563 
1564  $opt = new ilRadioOption($this->lng->txt('rep_visibility_limitless'), ilObjectActivation::TIMINGS_DEACTIVATED);
1565  $opt->setInfo($this->lng->txt('tst_availability_limitless_info'));
1566  $act_type->addOption($opt);
1567 
1568  $opt = new ilRadioOption($this->lng->txt('rep_visibility_until'), ilObjectActivation::TIMINGS_ACTIVATION);
1569  $opt->setInfo($this->lng->txt('tst_availability_until_info'));
1570 
1571  $date = $this->object->getActivationStartingTime();
1572 
1573  $start = new ilDateTimeInputGUI($this->lng->txt('rep_activation_limited_start'),'act_starting_time');
1574  #$start->setMode(ilDateTimeInputGUI::MODE_INPUT);
1575  $start->setShowTime(true);
1576  $start->setDate(new ilDateTime($date ? $date : time(),IL_CAL_UNIX));
1577  $opt->addSubItem($start);
1578 
1579  $date = $this->object->getActivationEndingTime();
1580 
1581  $end = new ilDateTimeInputGUI($this->lng->txt('rep_activation_limited_end'),'act_ending_time');
1582  #$end->setMode(ilDateTimeInputGUI::MODE_INPUT);
1583  $end->setShowTime(true);
1584  $end->setDate(new ilDateTime($date ? $date : time(),IL_CAL_UNIX));
1585  $opt->addSubItem($end);
1586 
1587  $visible = new ilCheckboxInputGUI($this->lng->txt('rep_activation_limited_visibility'), 'activation_visibility');
1588  $visible->setInfo($this->lng->txt('tst_activation_limited_visibility_info'));
1589  $visible->setChecked($this->object->getActivationVisibility());
1590  $opt->addSubItem($visible);
1591 
1592  $act_type->addOption($opt);
1593 
1594  $form->addItem($act_type);
1595 
1596 
1597  if(!$template || $template && $this->formShowBeginningEndingInformation($template_settings)) {
1598  // general properties
1599  $header = new ilFormSectionHeaderGUI();
1600  $header->setTitle($this->lng->txt("tst_beginning_ending_information"));
1601  $form->addItem($header);
1602  }
1603 
1604  // introduction
1605  $intro = new ilTextAreaInputGUI($this->lng->txt("tst_introduction"), "introduction");
1606  $intro->setValue($this->object->prepareTextareaOutput($this->object->getIntroduction()));
1607  $intro->setRows(10);
1608  $intro->setCols(80);
1609  $intro->setUseRte(TRUE);
1610  $intro->addPlugin("latex");
1611  $intro->addButton("latex");
1612  $intro->setRTESupport($this->object->getId(), "tst", 'assessment', null, false, '3.4.7');
1613  $intro->setRteTagSet('full');
1614  $intro->setInfo($this->lng->txt('intro_desc'));
1615  // showinfo
1616  $showinfo = new ilCheckboxInputGUI('', "showinfo");
1617  $showinfo->setValue(1);
1618  $showinfo->setChecked($this->object->getShowInfo());
1619  $showinfo->setOptionTitle($this->lng->txt("showinfo"));
1620  $showinfo->setInfo($this->lng->txt("showinfo_desc"));
1621  $intro->addSubItem($showinfo);
1622  $form->addItem($intro);
1623 
1624  // final statement
1625  $finalstatement = new ilTextAreaInputGUI($this->lng->txt("final_statement"), "finalstatement");
1626  $finalstatement->setValue($this->object->prepareTextareaOutput($this->object->getFinalStatement()));
1627  $finalstatement->setRows(10);
1628  $finalstatement->setCols(80);
1629  $finalstatement->setUseRte(TRUE);
1630  $finalstatement->addPlugin("latex");
1631  $finalstatement->addButton("latex");
1632  $finalstatement->setRTESupport($this->object->getId(), "tst", "assessment", null, false, '3.4.7');
1633  $finalstatement->setRteTagSet('full');
1634  // show final statement
1635  $showfinal = new ilCheckboxInputGUI('', "showfinalstatement");
1636  $showfinal->setValue(1);
1637  $showfinal->setChecked($this->object->getShowFinalStatement());
1638  $showfinal->setOptionTitle($this->lng->txt("final_statement_show"));
1639  $showfinal->setInfo($this->lng->txt("final_statement_show_desc"));
1640  $finalstatement->addSubItem($showfinal);
1641  $form->addItem($finalstatement);
1642 
1643  if(!$template || $template && $this->formShowSessionSection($template_settings)) {
1644  // session properties
1645  $sessionheader = new ilFormSectionHeaderGUI();
1646  $sessionheader->setTitle($this->lng->txt("tst_session_settings"));
1647  $form->addItem($sessionheader);
1648  }
1649 
1650  // max. number of passes
1651  $nr_of_tries = new ilTextInputGUI($this->lng->txt("tst_nr_of_tries"), "nr_of_tries");
1652  $nr_of_tries->setSize(3);
1653  $nr_of_tries->setValue($this->object->getNrOfTries());
1654  $nr_of_tries->setRequired(true);
1655  $nr_of_tries->setSuffix($this->lng->txt("0_unlimited"));
1656  if ($total) $nr_of_tries->setDisabled(true);
1657  $form->addItem($nr_of_tries);
1658 
1659  // enable max. processing time
1660  $processing = new ilCheckboxInputGUI($this->lng->txt("tst_processing_time"), "chb_processing_time");
1661  $processing->setValue(1);
1662  //$processing->setOptionTitle($this->lng->txt("enabled"));
1663 
1664  if ($template_settings && $template_settings['chb_processing_time'] && $template_settings['chb_processing_time']['value'])
1665  $processing->setChecked(true);
1666  else
1667  $processing->setChecked($this->object->getEnableProcessingTime());
1668 
1669  // max. processing time
1670  $processingtime = new ilDurationInputGUI('', 'processing_time');
1671  $ptime = $this->object->getProcessingTimeAsArray();
1672  $processingtime->setHours($ptime['hh']);
1673  $processingtime->setMinutes($ptime['mm']);
1674  $processingtime->setSeconds($ptime['ss']);
1675  $processingtime->setShowMonths(false);
1676  $processingtime->setShowDays(false);
1677  $processingtime->setShowHours(true);
1678  $processingtime->setShowMinutes(true);
1679  $processingtime->setShowSeconds(true);
1680  $processingtime->setInfo($this->lng->txt("tst_processing_time_desc"));
1681  $processing->addSubItem($processingtime);
1682 
1683  // reset max. processing time
1684  $resetprocessing = new ilCheckboxInputGUI('', "chb_reset_processing_time");
1685  $resetprocessing->setValue(1);
1686  $resetprocessing->setOptionTitle($this->lng->txt("tst_reset_processing_time"));
1687  $resetprocessing->setChecked($this->object->getResetProcessingTime());
1688  $resetprocessing->setInfo($this->lng->txt("tst_reset_processing_time_desc"));
1689  $processing->addSubItem($resetprocessing);
1690  $form->addItem($processing);
1691 
1692  // enable starting time
1693  $enablestartingtime = new ilCheckboxInputGUI($this->lng->txt("tst_starting_time"), "chb_starting_time");
1694  $enablestartingtime->setValue(1);
1695  //$enablestartingtime->setOptionTitle($this->lng->txt("enabled"));
1696 
1697  if ($template_settings && $template_settings['chb_starting_time'] && $template_settings['chb_starting_time']['value'])
1698  $enablestartingtime->setChecked(true);
1699  else
1700  $enablestartingtime->setChecked(strlen($this->object->getStartingTime()));
1701  // starting time
1702  $startingtime = new ilDateTimeInputGUI('', 'starting_time');
1703  $startingtime->setShowDate(true);
1704  $startingtime->setShowTime(true);
1705  if (strlen($this->object->getStartingTime()))
1706  {
1707  $startingtime->setDate(new ilDateTime($this->object->getStartingTime(), IL_CAL_TIMESTAMP));
1708  }
1709  else
1710  {
1711  $startingtime->setDate(new ilDateTime(time(), IL_CAL_UNIX));
1712  }
1713  $enablestartingtime->addSubItem($startingtime);
1714  if ($total) $enablestartingtime->setDisabled(true);
1715  if ($total) $startingtime->setDisabled(true);
1716  $form->addItem($enablestartingtime);
1717 
1718  // enable ending time
1719  $enableendingtime = new ilCheckboxInputGUI($this->lng->txt("tst_ending_time"), "chb_ending_time");
1720  $enableendingtime->setValue(1);
1721  //$enableendingtime->setOptionTitle($this->lng->txt("enabled"));
1722  if ($template_settings && $template_settings['chb_ending_time'] && $template_settings['chb_ending_time']['value'])
1723  $enableendingtime->setChecked(true);
1724  else
1725  $enableendingtime->setChecked(strlen($this->object->getEndingTime()));
1726  // ending time
1727  $endingtime = new ilDateTimeInputGUI('', 'ending_time');
1728  $endingtime->setShowDate(true);
1729  $endingtime->setShowTime(true);
1730  if (strlen($this->object->getEndingTime()))
1731  {
1732  $endingtime->setDate(new ilDateTime($this->object->getEndingTime(), IL_CAL_TIMESTAMP));
1733  }
1734  else
1735  {
1736  $endingtime->setDate(new ilDateTime(time(), IL_CAL_UNIX));
1737  }
1738  $enableendingtime->addSubItem($endingtime);
1739  $form->addItem($enableendingtime);
1740 
1741  // test password
1742  $password = new ilTextInputGUI($this->lng->txt("tst_password"), "password");
1743  $password->setSize(20);
1744  $password->setValue($this->object->getPassword());
1745  $password->setInfo($this->lng->txt("tst_password_details"));
1746  $form->addItem($password);
1747 
1748  if(!$template || $template && $this->formShowPresentationSection($template_settings)) {
1749  // sequence properties
1750  $seqheader = new ilFormSectionHeaderGUI();
1751  $seqheader->setTitle($this->lng->txt("tst_presentation_properties"));
1752  $form->addItem($seqheader);
1753  }
1754 
1755  // use previous answers
1756  $prevanswers = new ilCheckboxInputGUI($this->lng->txt("tst_use_previous_answers"), "chb_use_previous_answers");
1757  $prevanswers->setValue(1);
1758  $prevanswers->setChecked($this->object->getUsePreviousAnswers());
1759  $prevanswers->setInfo($this->lng->txt("tst_use_previous_answers_description"));
1760  $form->addItem($prevanswers);
1761 
1762  // force js
1763  $forcejs = new ilCheckboxInputGUI($this->lng->txt("forcejs_short"), "forcejs");
1764  $forcejs->setValue(1);
1765  $forcejs->setChecked($this->object->getForceJS());
1766  $forcejs->setOptionTitle($this->lng->txt("forcejs"));
1767  $forcejs->setInfo($this->lng->txt("forcejs_desc"));
1768  $form->addItem($forcejs);
1769 
1770  // question title output
1771  $title_output = new ilRadioGroupInputGUI($this->lng->txt("tst_title_output"), "title_output");
1772  $title_output->addOption(new ilRadioOption($this->lng->txt("tst_title_output_full"), 0, ''));
1773  $title_output->addOption(new ilRadioOption($this->lng->txt("tst_title_output_hide_points"), 1, ''));
1774  $title_output->addOption(new ilRadioOption($this->lng->txt("tst_title_output_no_title"), 2, ''));
1775  $title_output->setValue($this->object->getTitleOutput());
1776  $title_output->setInfo($this->lng->txt("tst_title_output_description"));
1777  $form->addItem($title_output);
1778 
1779  // Autosave
1780  $autosave_output = new ilCheckboxInputGUI($this->lng->txt('autosave'), 'autosave');
1781  $autosave_output->setValue(1);
1782  $autosave_output->setChecked($this->object->getAutosave());
1783  $autosave_output->setInfo($this->lng->txt('autosave_info'));
1784 
1785  $autosave_interval = new ilTextInputGUI($this->lng->txt('autosave_ival'), 'autosave_ival');
1786  $autosave_interval->setSize(10);
1787  $autosave_interval->setValue($this->object->getAutosaveIval() / 1000);
1788  $autosave_interval->setInfo($this->lng->txt('autosave_ival_info'));
1789  $autosave_output->addSubItem($autosave_interval);
1790  $form->addItem($autosave_output);
1791 
1792  if(!$template || $template && $this->formShowSequenceSection($template_settings)) {
1793  // sequence properties
1794  $seqheader = new ilFormSectionHeaderGUI();
1795  $seqheader->setTitle($this->lng->txt("tst_sequence_properties"));
1796  $form->addItem($seqheader);
1797  }
1798 
1799  // postpone questions
1800  $postpone = new ilCheckboxInputGUI($this->lng->txt("tst_postpone"), "chb_postpone");
1801  $postpone->setValue(1);
1802  $postpone->setChecked($this->object->getSequenceSettings());
1803  $postpone->setInfo($this->lng->txt("tst_postpone_description"));
1804  $form->addItem($postpone);
1805 
1806  // shuffle questions
1807  $shuffle = new ilCheckboxInputGUI($this->lng->txt("tst_shuffle_questions"), "chb_shuffle_questions");
1808  $shuffle->setValue(1);
1809  $shuffle->setChecked($this->object->getShuffleQuestions());
1810  $shuffle->setInfo($this->lng->txt("tst_shuffle_questions_description"));
1811  $form->addItem($shuffle);
1812 
1813  // show list of questions
1814  $list_of_questions = new ilCheckboxInputGUI($this->lng->txt("tst_show_summary"), "list_of_questions");
1815  //$list_of_questions->setOptionTitle($this->lng->txt("tst_show_summary"));
1816  $list_of_questions->setValue(1);
1817  $list_of_questions->setChecked($this->object->getListOfQuestions());
1818  $list_of_questions->setInfo($this->lng->txt("tst_show_summary_description"));
1819 
1820  $list_of_questions_options = new ilCheckboxGroupInputGUI('', "list_of_questions_options");
1821  $list_of_questions_options->addOption(new ilCheckboxOption($this->lng->txt("tst_list_of_questions_start"), 'chb_list_of_questions_start', ''));
1822  $list_of_questions_options->addOption(new ilCheckboxOption($this->lng->txt("tst_list_of_questions_end"), 'chb_list_of_questions_end', ''));
1823  $list_of_questions_options->addOption(new ilCheckboxOption($this->lng->txt("tst_list_of_questions_with_description"), 'chb_list_of_questions_with_description', ''));
1824  $values = array();
1825  if ($this->object->getListOfQuestionsStart()) array_push($values, 'chb_list_of_questions_start');
1826  if ($this->object->getListOfQuestionsEnd()) array_push($values, 'chb_list_of_questions_end');
1827  if ($this->object->getListOfQuestionsDescription()) array_push($values, 'chb_list_of_questions_with_description');
1828  $list_of_questions_options->setValue($values);
1829 
1830  $list_of_questions->addSubItem($list_of_questions_options);
1831  $form->addItem($list_of_questions);
1832 
1833  // show question marking
1834  $marking = new ilCheckboxInputGUI($this->lng->txt("question_marking"), "chb_show_marker");
1835  $marking->setValue(1);
1836  $marking->setChecked($this->object->getShowMarker());
1837  $marking->setInfo($this->lng->txt("question_marking_description"));
1838  $form->addItem($marking);
1839 
1840  // show suspend test
1841  $cancel = new ilCheckboxInputGUI($this->lng->txt("tst_show_cancel"), "chb_show_cancel");
1842  $cancel->setValue(1);
1843  $cancel->setChecked($this->object->getShowCancel());
1844  $cancel->setInfo($this->lng->txt("tst_show_cancel_description"));
1845  $form->addItem($cancel);
1846 
1847  if(!$template || $template && $this->formShowNotificationSection($template_settings)) {
1848  // notifications
1849  $notifications = new ilFormSectionHeaderGUI();
1850  $notifications->setTitle($this->lng->txt("tst_mail_notification"));
1851  $form->addItem($notifications);
1852  }
1853 
1854  // mail notification
1855  $mailnotification = new ilRadioGroupInputGUI($this->lng->txt("tst_finish_notification"), "mailnotification");
1856  $mailnotification->addOption(new ilRadioOption($this->lng->txt("tst_finish_notification_no"), 0, ''));
1857  $mailnotification->addOption(new ilRadioOption($this->lng->txt("tst_finish_notification_simple"), 1, ''));
1858  $mailnotification->addOption(new ilRadioOption($this->lng->txt("tst_finish_notification_advanced"), 2, ''));
1859  $mailnotification->setValue($this->object->getMailNotification());
1860  $form->addItem($mailnotification);
1861 
1862  $mailnottype = new ilCheckboxInputGUI('', "mailnottype");
1863  $mailnottype->setValue(1);
1864  $mailnottype->setOptionTitle($this->lng->txt("mailnottype"));
1865  $mailnottype->setChecked($this->object->getMailNotificationType());
1866  $form->addItem($mailnottype);
1867 
1868  /* This options always active (?) */
1869  $highscore_head = new ilFormSectionHeaderGUI();
1870  $highscore_head->setTitle($this->lng->txt("tst_highscore_options"));
1871  $form->addItem($highscore_head);
1872 
1873  $highscore = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_enabled"), "highscore_enabled");
1874  $highscore->setValue(1);
1875  $highscore->setChecked($this->object->getHighscoreEnabled());
1876  $highscore->setInfo($this->lng->txt("tst_highscore_description"));
1877  $form->addItem($highscore);
1878 
1879  $highscore_anon = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_anon"), "highscore_anon");
1880  $highscore_anon->setValue(1);
1881  $highscore_anon->setChecked($this->object->getHighscoreAnon());
1882  $highscore_anon->setInfo($this->lng->txt("tst_highscore_anon_description"));
1883  $highscore->addSubItem($highscore_anon);
1884 
1885  $highscore_achieved_ts = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_achieved_ts"), "highscore_achieved_ts");
1886  $highscore_achieved_ts->setValue(1);
1887  $highscore_achieved_ts->setChecked($this->object->getHighscoreAchievedTS());
1888  $highscore_achieved_ts->setInfo($this->lng->txt("tst_highscore_achieved_ts_description"));
1889  $highscore->addSubItem($highscore_achieved_ts);
1890 
1891  $highscore_score = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_score"), "highscore_score");
1892  $highscore_score->setValue(1);
1893  $highscore_score->setChecked($this->object->getHighscoreScore());
1894  $highscore_score->setInfo($this->lng->txt("tst_highscore_score_description"));
1895  $highscore->addSubItem($highscore_score);
1896 
1897  $highscore_percentage = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_percentage"), "highscore_percentage");
1898  $highscore_percentage->setValue(1);
1899  $highscore_percentage->setChecked($this->object->getHighscorePercentage());
1900  $highscore_percentage->setInfo($this->lng->txt("tst_highscore_percentage_description"));
1901  $highscore->addSubItem($highscore_percentage);
1902 
1903  $highscore_hints = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_hints"), "highscore_hints");
1904  $highscore_hints->setValue(1);
1905  $highscore_hints->setChecked($this->object->getHighscoreHints());
1906  $highscore_hints->setInfo($this->lng->txt("tst_highscore_hints_description"));
1907  $highscore->addSubItem($highscore_hints);
1908 
1909  $highscore_wtime = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_wtime"), "highscore_wtime");
1910  $highscore_wtime->setValue(1);
1911  $highscore_wtime->setChecked($this->object->getHighscoreWTime());
1912  $highscore_wtime->setInfo($this->lng->txt("tst_highscore_wtime_description"));
1913  $highscore->addSubItem($highscore_wtime);
1914 
1915  $highscore_own_table = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_own_table"), "highscore_own_table");
1916  $highscore_own_table->setValue(1);
1917  $highscore_own_table->setChecked($this->object->getHighscoreOwnTable());
1918  $highscore_own_table->setInfo($this->lng->txt("tst_highscore_own_table_description"));
1919  $highscore->addSubItem($highscore_own_table);
1920 
1921  $highscore_top_table = new ilCheckboxInputGUI($this->lng->txt("tst_highscore_top_table"), "highscore_top_table");
1922  $highscore_top_table->setValue(1);
1923  $highscore_top_table->setChecked($this->object->getHighscoreTopTable());
1924  $highscore_top_table->setInfo($this->lng->txt("tst_highscore_top_table_description"));
1925  $highscore->addSubItem($highscore_top_table);
1926 
1927  $highscore_top_num = new ilTextInputGUI($this->lng->txt("tst_highscore_top_num"), "highscore_top_num");
1928  $highscore_top_num->setSize(4);
1929  $highscore_top_num->setSuffix($this->lng->txt("tst_highscore_top_num_unit"));
1930  $highscore_top_num->setValue($this->object->getHighscoreTopNum());
1931  $highscore_top_table->setInfo($this->lng->txt("tst_highscore_top_num_description"));
1932  $highscore->addSubItem($highscore_top_num);
1933 
1934  if(!$template || $template && $this->formShowKioskSection($template_settings)) {
1935  // kiosk mode properties
1936  $kioskheader = new ilFormSectionHeaderGUI();
1937  $kioskheader->setTitle($this->lng->txt("kiosk"));
1938  $form->addItem($kioskheader);
1939  }
1940 
1941  // kiosk mode
1942  $kiosk = new ilCheckboxInputGUI($this->lng->txt("kiosk"), "kiosk");
1943  $kiosk->setValue(1);
1944  $kiosk->setChecked($this->object->getKioskMode());
1945  $kiosk->setInfo($this->lng->txt("kiosk_description"));
1946 
1947  // kiosk mode options
1948  $kiosktitle = new ilCheckboxGroupInputGUI($this->lng->txt("kiosk_options"), "kiosk_options");
1949  $kiosktitle->addOption(new ilCheckboxOption($this->lng->txt("kiosk_show_title"), 'kiosk_title', ''));
1950  $kiosktitle->addOption(new ilCheckboxOption($this->lng->txt("kiosk_show_participant"), 'kiosk_participant', ''));
1951  $values = array();
1952  if ($this->object->getShowKioskModeTitle()) array_push($values, 'kiosk_title');
1953  if ($this->object->getShowKioskModeParticipant()) array_push($values, 'kiosk_participant');
1954  $kiosktitle->setValue($values);
1955  $kiosktitle->setInfo($this->lng->txt("kiosk_options_desc"));
1956  $kiosk->addSubItem($kiosktitle);
1957 
1958  $form->addItem($kiosk);
1959 
1960  if(!$template || $template && $this->formShowParticipantSection($template_settings)) {
1961  // participants properties
1962  $restrictions = new ilFormSectionHeaderGUI();
1963  $restrictions->setTitle($this->lng->txt("tst_max_allowed_users"));
1964  $form->addItem($restrictions);
1965  }
1966 
1967  $fixedparticipants = new ilCheckboxInputGUI($this->lng->txt('participants_invitation'), "fixedparticipants");
1968  $fixedparticipants->setValue(1);
1969  $fixedparticipants->setChecked($this->object->getFixedParticipants());
1970  $fixedparticipants->setOptionTitle($this->lng->txt("tst_allow_fixed_participants"));
1971  $fixedparticipants->setInfo($this->lng->txt("participants_invitation_description"));
1972  $invited_users = $this->object->getInvitedUsers();
1973  if ($total && (count($invited_users) == 0))
1974  {
1975  $fixedparticipants->setDisabled(true);
1976  }
1977  $form->addItem($fixedparticipants);
1978 
1979 
1980  // simultaneous users
1981  $simul = new ilTextInputGUI($this->lng->txt("tst_allowed_users"), "allowedUsers");
1982  $simul->setSize(3);
1983  $simul->setValue(($this->object->getAllowedUsers()) ? $this->object->getAllowedUsers() : '');
1984  $form->addItem($simul);
1985 
1986  // idle time
1987  $idle = new ilTextInputGUI($this->lng->txt("tst_allowed_users_time_gap"), "allowedUsersTimeGap");
1988  $idle->setSize(4);
1989  $idle->setSuffix($this->lng->txt("seconds"));
1990  $idle->setValue(($this->object->getAllowedUsersTimeGap()) ? $this->object->getAllowedUsersTimeGap() : '');
1991  $form->addItem($idle);
1992 
1993  // Edit ecs export settings
1994  include_once 'Modules/Test/classes/class.ilECSTestSettings.php';
1995  $ecs = new ilECSTestSettings($this->object);
1996  $ecs->addSettingsToForm($form, 'tst');
1997 
1998  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) $form->addCommandButton("saveProperties", $this->lng->txt("save"));
1999 
2000  // remove items when using template
2001  if($template_settings)
2002  {
2003  foreach($template_settings as $id => $item)
2004  {
2005  if($item["hide"])
2006  {
2007  $form->removeItemByPostVar($id);
2008  }
2009  }
2010  }
2011 
2012  $errors = false;
2013 
2014  if ($save)
2015  {
2016  $errors = !$form->checkInput();
2017 
2019 
2020  $form->setValuesByPost();
2021  if( $online->getChecked() && !$this->object->isComplete() )
2022  {
2023  $online->setAlert($this->lng->txt("cannot_switch_to_online_no_questions_andor_no_mark_steps"));
2024  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
2025  $errors = true;
2026  }
2027  if ($errors) $checkonly = false;
2028  }
2029 
2030  if (!$checkonly)
2031  {
2032  // using template?
2033  $message = "";
2034  if($template)
2035  {
2036  global $tpl;
2037 
2038  $link = $this->ctrl->getLinkTarget($this, "confirmResetTemplate");
2039  $link = "<a href=\"".$link."\">".$this->lng->txt("test_using_template_link")."</a>";
2040  $message = "<div style=\"margin-top:10px\">".
2041  $tpl->getMessageHTML(sprintf($this->lng->txt("test_using_template"), $template->getTitle(), $link), "info").
2042  "</div>";
2043  }
2044 
2045  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML().$message);
2046  }
2047 
2048  return $errors;
2049  }
2050 
2052  {
2053  $fields = array('act_starting_time', 'act_ending_time', 'starting_time', 'ending_time');
2054 
2055  foreach($fields as $field)
2056  {
2057  if( !($form->getItemByPostVar($field) instanceof ilFormPropertyGUI) )
2058  {
2059  continue;
2060  }
2061 
2062  if( !$form->getItemByPostVar($field)->getDisabled() )
2063  {
2064  continue;
2065  }
2066 
2067  unset($_POST[$field]);
2068  }
2069  }
2070 
2077  {
2078  if (!array_key_exists("tst_properties_confirmation", $_POST))
2079  {
2080  $hasErrors = $this->propertiesObject(true);
2081  }
2082  else
2083  {
2084  $hasErrors = false;
2085  }
2086  if (!$hasErrors)
2087  {
2088  $template_settings = null;
2089  $template = $this->object->getTemplate();
2090  if($template)
2091  {
2092  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
2094 
2095  $template_settings = $template->getSettings();
2096  }
2097 
2098 
2099 
2100  include_once 'Services/MetaData/classes/class.ilMD.php';
2101  $md_obj =& new ilMD($this->object->getId(), 0, "tst");
2102  $md_section = $md_obj->getGeneral();
2103 
2104  // title
2105  $md_section->setTitle(ilUtil::stripSlashes($_POST['title']));
2106  $md_section->update();
2107 
2108  // Description
2109  $md_desc_ids = $md_section->getDescriptionIds();
2110  if($md_desc_ids)
2111  {
2112  $md_desc = $md_section->getDescription(array_pop($md_desc_ids));
2113  $md_desc->setDescription(ilUtil::stripSlashes($_POST['description']));
2114  $md_desc->update();
2115  }
2116  else {
2117  $md_desc = $md_section->addDescription();
2118  $md_desc->setDescription(ilUtil::stripSlashes($_POST['description']));
2119  $md_desc->save();
2120  }
2121 
2122  $this->object->setTitle(ilUtil::stripSlashes($_POST['title']));
2123  $this->object->setDescription(ilUtil::stripSlashes($_POST['description']));
2124  $this->object->update();
2125 
2126  $total = $this->object->evalTotalPersons();
2127  $randomtest_switch = false;
2128  // Check the values the user entered in the form
2129  if (!$total)
2130  {
2131  if (!strlen($_POST["random_test"]))
2132  {
2133  $random_test = 0;
2134  }
2135  else
2136  {
2137  $random_test = $_POST["random_test"];
2138  }
2139 
2140  if (!array_key_exists("tst_properties_confirmation", $_POST))
2141  {
2142  if( !$random_test && $this->object->areRandomTestQuestionpoolsConfigured() )
2143  {
2144  // user tries to change from a random test with existing random question pools to a non random test
2145  $this->confirmChangeProperties(self::SWITCH_RANDOM_TEST_SETTING_TO_DISABLED);
2146  return;
2147  }
2148  elseif( $random_test && $this->object->doesNonRandomTestQuestionsExist() )
2149  {
2150  // user tries to change from a non random test with existing questions to a random test
2151  $this->confirmChangeProperties(self::SWITCH_RANDOM_TEST_SETTING_TO_ENABLED);
2152  return;
2153  }
2154  }
2155  }
2156  else
2157  {
2158  $random_test = $this->object->isRandomTest();
2159  }
2160 
2161  // buffer online status sent by form in local variable and store
2162  // it to model after the following if block, because the new status
2163  // gets reset when random test setting is switched
2164  $online = $_POST["online"];
2165 
2166  $randomtest_switch = $this->isRandomTestSettingSwitched($random_test);
2167 
2168  if( !$total )
2169  {
2170  if( $randomtest_switch && $this->object->isOnline() && $online )
2171  {
2172  // reset online status that is stored to model later on
2173  // due to fact that the random test setting has been changed
2174  $online = false;
2175 
2176  $info = $this->lng->txt(
2177  "tst_set_offline_due_to_switched_random_test_setting"
2178  );
2179 
2180  ilUtil::sendInfo($info, true);
2181  }
2182 
2183  $this->object->setAnonymity($_POST["anonymity"]);
2184  $this->object->setRandomTest($random_test);
2185  $this->object->setNrOfTries($_POST["nr_of_tries"]);
2186  }
2187 
2188  // store effective online status to model
2189  $this->object->setOnline($online);
2190 
2191  // activation
2192  if($_POST["activation_type"] == ilObjectActivation::TIMINGS_ACTIVATION)
2193  {
2194  $this->object->setActivationLimited(true);
2195  $this->object->setActivationVisibility($_POST["activation_visibility"]);
2196 
2197  $date = new ilDateTime($_POST['act_starting_time']['date'] . ' ' . $_POST['act_starting_time']['time'], IL_CAL_DATETIME);
2198  $this->object->setActivationStartingTime($date->get(IL_CAL_UNIX));
2199 
2200  $date = new ilDateTime($_POST['act_ending_time']['date'] . ' ' . $_POST['act_ending_time']['time'], IL_CAL_DATETIME);
2201  $this->object->setActivationEndingTime($date->get(IL_CAL_UNIX));
2202  }
2203  else
2204  {
2205  $this->object->setActivationLimited(false);
2206  }
2207 
2208  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
2209  $this->object->setIntroduction($_POST["introduction"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment"));
2210  $this->object->setShowInfo(($_POST["showinfo"]) ? 1 : 0);
2211  $this->object->setFinalStatement($_POST["finalstatement"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment"));
2212  $this->object->setShowFinalStatement(($_POST["showfinalstatement"]) ? 1 : 0);
2213  $this->object->setSequenceSettings(($_POST["chb_postpone"]) ? 1 : 0);
2214  $this->object->setShuffleQuestions(($_POST["chb_shuffle_questions"]) ? 1 : 0);
2215  $this->object->setListOfQuestions($_POST["list_of_questions"]);
2216  if (is_array($_POST["list_of_questions_options"]))
2217  {
2218  $this->object->setListOfQuestionsStart((in_array('chb_list_of_questions_start', $_POST["list_of_questions_options"])) ? 1 : 0);
2219  $this->object->setListOfQuestionsEnd((in_array('chb_list_of_questions_end', $_POST["list_of_questions_options"])) ? 1 : 0);
2220  $this->object->setListOfQuestionsDescription((in_array('chb_list_of_questions_with_description', $_POST["list_of_questions_options"])) ? 1 : 0);
2221  }
2222  else
2223  {
2224  $this->object->setListOfQuestionsStart(0);
2225  $this->object->setListOfQuestionsEnd(0);
2226  $this->object->setListOfQuestionsDescription(0);
2227  }
2228  $this->object->setMailNotification($_POST["mailnotification"]);
2229  $this->object->setMailNotificationType($_POST["mailnottype"]);
2230  $this->object->setShowMarker(($_POST["chb_show_marker"]) ? 1 : 0);
2231  $this->object->setShowCancel(($_POST["chb_show_cancel"]) ? 1 : 0);
2232  $this->object->setKioskMode(($_POST["kiosk"]) ? 1 : 0);
2233  $this->object->setShowKioskModeTitle((is_array($_POST["kiosk_options"]) && in_array('kiosk_title', $_POST["kiosk_options"])) ? 1 : 0);
2234  $this->object->setShowKioskModeParticipant((is_array($_POST["kiosk_options"]) && in_array('kiosk_participant', $_POST["kiosk_options"])) ? 1 : 0);
2235  $this->object->setEnableProcessingTime(($_POST["chb_processing_time"]) ? 1 : 0);
2236  if ($this->object->getEnableProcessingTime())
2237  {
2238  $this->object->setProcessingTime(sprintf("%02d:%02d:%02d",
2239  $_POST["processing_time"]["hh"],
2240  $_POST["processing_time"]["mm"],
2241  $_POST["processing_time"]["ss"]
2242  ));
2243  }
2244  else
2245  {
2246  $this->object->setProcessingTime('');
2247  }
2248  $this->object->setResetProcessingTime(($_POST["chb_reset_processing_time"]) ? 1 : 0);
2249 
2250  if(!$total)
2251  {
2252  if( $_POST['chb_starting_time'] )
2253  {
2254  $this->object->setStartingTime(ilFormat::dateDB2timestamp($_POST['starting_time']['date'] . ' ' . $_POST['starting_time']['time']));
2255  }
2256  elseif( !$_POST['chb_starting_time'] )
2257  {
2258  $this->object->setStartingTime('');
2259  }
2260  }
2261 
2262  if ($_POST['chb_ending_time'])
2263  {
2264  $this->object->setEndingTime(ilFormat::dateDB2timestamp($_POST['ending_time']['date'] . ' ' . $_POST['ending_time']['time']));
2265  }
2266  else
2267  {
2268  $this->object->setEndingTime('');
2269  }
2270 
2271  $this->object->setUsePreviousAnswers(($_POST["chb_use_previous_answers"]) ? 1 : 0);
2272  $this->object->setForceJS(($_POST["forcejs"]) ? 1 : 0);
2273  $this->object->setTitleOutput($_POST["title_output"]);
2274  $this->object->setPassword($_POST["password"]);
2275  $this->object->setAllowedUsers($_POST["allowedUsers"]);
2276  $this->object->setAllowedUsersTimeGap($_POST["allowedUsersTimeGap"]);
2277 
2278  $this->object->setAutosave($_POST['autosave']);
2279  $this->object->setAutosaveIval(((int)$_POST['autosave_ival']) * 1000);
2280 
2281  if ($this->object->isRandomTest())
2282  {
2283  $this->object->setUsePreviousAnswers(0);
2284  }
2285 
2286  $invited_users = $this->object->getInvitedUsers();
2287  if (!($total && (count($invited_users) == 0)))
2288  {
2289  $fixed_participants = 0;
2290  if (array_key_exists("fixedparticipants", $_POST))
2291  {
2292  if ($_POST["fixedparticipants"])
2293  {
2294  $fixed_participants = 1;
2295  }
2296  }
2297  $this->object->setFixedParticipants($fixed_participants);
2298  if (!$fixed_participants)
2299  {
2300  $invited_users = $this->object->getInvitedUsers();
2301  foreach ($invited_users as $user_object)
2302  {
2303  $this->object->disinviteUser($user_object["usr_id"]);
2304  }
2305  }
2306  }
2307 
2308  $this->object->setHighscoreEnabled((bool) $_POST['highscore_enabled']);
2309  $this->object->setHighscoreAnon((bool) $_POST['highscore_anon']);
2310  $this->object->setHighscoreAchievedTS((bool) $_POST['highscore_achieved_ts']);
2311  $this->object->setHighscoreScore((bool) $_POST['highscore_score']);
2312  $this->object->setHighscorePercentage((bool) $_POST['highscore_percentage']);
2313  $this->object->setHighscoreHints((bool) $_POST['highscore_hints']);
2314  $this->object->setHighscoreWTime((bool) $_POST['highscore_wtime']);
2315  $this->object->setHighscoreOwnTable((bool) $_POST['highscore_own_table']);
2316  $this->object->setHighscoreTopTable((bool) $_POST['highscore_top_table']);
2317  $this->object->setHighscoreTopNum((int) $_POST['highscore_top_num']);
2318 
2319  //$this->object->setExpressModeQuestionPoolAllowed($_POST['express_allow_question_pool']);
2320  $this->object->setEnabledViewMode($_POST['enabled_view_mode']);
2321  $this->object->setPoolUsage($_POST['use_pool']);
2322 
2323  $this->object->saveToDb(true);
2324 
2325  // Update ecs export settings
2326  include_once 'Modules/Test/classes/class.ilECSTestSettings.php';
2327  $ecs = new ilECSTestSettings($this->object);
2328  $ecs->handleSettingsUpdate();
2329 
2330  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
2331  if ($randomtest_switch)
2332  {
2333  if($this->object->isRandomTest())
2334  {
2335  $this->object->removeNonRandomTestData();
2336  }
2337  else
2338  {
2339  $this->object->removeRandomTestData();
2340  }
2341  }
2342 
2343  $this->ctrl->redirect($this, 'properties');
2344  }
2345  }
2346 
2351  {
2352  $file = explode("_", $_GET["file_id"]);
2353  include_once("./Modules/File/classes/class.ilObjFile.php");
2354  $fileObj =& new ilObjFile($file[count($file) - 1], false);
2355  $fileObj->sendFile();
2356  exit;
2357  }
2358 
2362  function fullscreenObject()
2363  {
2364  include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
2365  //$page =& new ilPageObject("qpl", $_GET["pg_id"]);
2366  $page_gui =& new ilPageObjectGUI("qpl", $_GET["pg_id"]);
2367  $page_gui->showMediaFullscreen();
2368 
2369  }
2370 
2375  {
2376  include_once("./Services/COPage/classes/class.ilPageObject.php");
2377  $pg_obj =& new ilPageObject("qpl", $_GET["pg_id"]);
2378  $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
2379  exit;
2380  }
2381 
2389  function filterObject()
2390  {
2391  $this->questionBrowser();
2392  }
2393 
2402  {
2403  $this->questionBrowser();
2404  }
2405 
2413  function backObject()
2414  {
2415  $this->ctrl->redirect($this, "questions");
2416  }
2417 
2426  function createQuestionPool($name = "dummy", $description = "")
2427  {
2428  global $tree;
2429  $parent_ref = $tree->getParentId($this->object->getRefId());
2430  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
2431  $qpl = new ilObjQuestionPool();
2432  $qpl->setType("qpl");
2433  $qpl->setTitle($name);
2434  $qpl->setDescription($description);
2435  $qpl->create();
2436  $qpl->createReference();
2437  $qpl->putInTree($parent_ref);
2438  $qpl->setPermissions($parent_ref);
2439  $qpl->setOnline(1); // must be online to be available
2440  $qpl->saveToDb();
2441  return $qpl->getRefId();
2442  }
2443 
2447  public function randomselectObject()
2448  {
2449  global $ilUser;
2450  $this->getQuestionsSubTabs();
2451  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_random_select.html", "Modules/Test");
2452  $questionpools =& $this->object->getAvailableQuestionpools(FALSE, FALSE, FALSE, TRUE);
2453  $this->tpl->setCurrentBlock("option");
2454  $this->tpl->setVariable("VALUE_OPTION", "0");
2455  $this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("all_available_question_pools"));
2456  $this->tpl->parseCurrentBlock();
2457  foreach ($questionpools as $key => $value)
2458  {
2459  $this->tpl->setCurrentBlock("option");
2460  $this->tpl->setVariable("VALUE_OPTION", $key);
2461  $this->tpl->setVariable("TEXT_OPTION", $value["title"]);
2462  $this->tpl->parseCurrentBlock();
2463  }
2464  $this->tpl->setCurrentBlock("hidden");
2465  $this->tpl->setVariable("HIDDEN_NAME", "sel_question_types");
2466  $this->tpl->setVariable("HIDDEN_VALUE", $_POST["sel_question_types"]);
2467  $this->tpl->parseCurrentBlock();
2468  $this->tpl->setCurrentBlock("adm_content");
2469  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
2470  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_random_select_questionpool"));
2471  $this->tpl->setVariable("TXT_NR_OF_QUESTIONS", $this->lng->txt("tst_random_nr_of_questions"));
2472  $this->tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit"));
2473  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
2474  $this->tpl->parseCurrentBlock();
2475  }
2476 
2485  {
2486  $this->ctrl->redirect($this, "questions");
2487  }
2488 
2497  {
2498  $this->getQuestionsSubTabs();
2499  $question_array = $this->object->randomSelectQuestions($_POST["nr_of_questions"], $_POST["sel_qpl"]);
2500  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_random_question_offer.html", "Modules/Test");
2501  $color_class = array("tblrow1", "tblrow2");
2502  $counter = 0;
2503  $questionpools =& $this->object->getAvailableQuestionpools(true);
2504  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
2505  foreach ($question_array as $question_id)
2506  {
2507  $dataset = $this->object->getQuestionDataset($question_id);
2508  $this->tpl->setCurrentBlock("QTab");
2509  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
2510  $this->tpl->setVariable("QUESTION_TITLE", $dataset->title);
2511  $this->tpl->setVariable("QUESTION_COMMENT", $dataset->description);
2512  $this->tpl->setVariable("QUESTION_TYPE", assQuestion::_getQuestionTypeName($dataset->type_tag));
2513  $this->tpl->setVariable("QUESTION_AUTHOR", $dataset->author);
2514  $this->tpl->setVariable("QUESTION_POOL", $questionpools[$dataset->obj_fi]["title"]);
2515  $this->tpl->parseCurrentBlock();
2516  $counter++;
2517  }
2518  if (count($question_array) == 0)
2519  {
2520  $this->tpl->setCurrentBlock("Emptytable");
2521  $this->tpl->setVariable("TEXT_NO_QUESTIONS_AVAILABLE", $this->lng->txt("no_questions_available"));
2522  $this->tpl->parseCurrentBlock();
2523  }
2524  else
2525  {
2526  $this->tpl->setCurrentBlock("Selectionbuttons");
2527  $this->tpl->setVariable("BTN_YES", $this->lng->txt("random_accept_sample"));
2528  $this->tpl->setVariable("BTN_NO", $this->lng->txt("random_another_sample"));
2529  $this->tpl->parseCurrentBlock();
2530  }
2531  $chosen_questions = join($question_array, ",");
2532  $this->tpl->setCurrentBlock("adm_content");
2533  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
2534  $this->tpl->setVariable("QUESTION_TITLE", $this->lng->txt("tst_question_title"));
2535  $this->tpl->setVariable("QUESTION_COMMENT", $this->lng->txt("description"));
2536  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("tst_question_type"));
2537  $this->tpl->setVariable("QUESTION_AUTHOR", $this->lng->txt("author"));
2538  $this->tpl->setVariable("QUESTION_POOL", $this->lng->txt("qpl"));
2539  $this->tpl->setVariable("VALUE_CHOSEN_QUESTIONS", $chosen_questions);
2540  $this->tpl->setVariable("VALUE_QUESTIONPOOL_SELECTION", $_POST["sel_qpl"]);
2541  $this->tpl->setVariable("VALUE_NR_OF_QUESTIONS", $_POST["nr_of_questions"]);
2542  $this->tpl->setVariable("TEXT_QUESTION_OFFER", $this->lng->txt("tst_question_offer"));
2543  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
2544  $this->tpl->parseCurrentBlock();
2545  }
2546 
2555  {
2556  $selected_array = split(",", $_POST["chosen_questions"]);
2557  if (!count($selected_array))
2558  {
2559  ilUtil::sendInfo($this->lng->txt("tst_insert_missing_question"));
2560  }
2561  else
2562  {
2563  $total = $this->object->evalTotalPersons();
2564  if ($total)
2565  {
2566  // the test was executed previously
2567  ilUtil::sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total));
2568  }
2569  else
2570  {
2571  ilUtil::sendInfo($this->lng->txt("tst_insert_questions"));
2572  }
2573  foreach ($selected_array as $key => $value)
2574  {
2575  $this->object->insertQuestion($value);
2576  }
2577  $this->object->saveCompleteStatus();
2578  ilUtil::sendSuccess($this->lng->txt("tst_questions_inserted"), true);
2579  $this->ctrl->redirect($this, "questions");
2580  return;
2581  }
2582  }
2583 
2585  {
2586  $this->randomQuestionsObject();
2587  }
2588 
2595  function writeRandomQuestionInput($always = false)
2596  {
2597  $hasErrors = (!$always) ? $this->randomQuestionsObject(true) : false;
2598  if (!$hasErrors)
2599  {
2600  global $ilUser;
2601  $ilUser->setPref("tst_question_selection_mode_equal", ($_POST['chbQuestionSelectionMode']) ? 1 : 0);
2602  $ilUser->writePref("tst_question_selection_mode_equal", ($_POST['chbQuestionSelectionMode']) ? 1 : 0);
2603  $this->object->setRandomQuestionCount($_POST['total_questions']);
2604  if (is_array($_POST['source']['qpl']) && count(array_unique($_POST['source']['qpl'])) == count($_POST['source']['qpl']))
2605  {
2606  $data = array();
2607  include_once "./Modules/Test/classes/class.ilRandomTestData.php";
2608  foreach ($_POST['source']['qpl'] as $idx => $qpl)
2609  {
2610  array_push($data, new ilRandomTestData($_POST['source']['count'][$idx], $qpl));
2611  }
2612  $this->object->setRandomQuestionpoolData($data);
2613  }
2614  return 0;
2615  }
2616  return 1;
2617  }
2618 
2620  {
2621  if ($this->writeRandomQuestionInput() == 0)
2622  {
2623  $this->object->saveRandomQuestionCount($this->object->getRandomQuestionCount());
2624  $this->object->saveRandomQuestionpools();
2625  $this->object->saveCompleteStatus();
2626  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
2627  $this->ctrl->redirect($this, 'randomQuestions');
2628  }
2629  }
2630 
2631  function addsourceObject()
2632  {
2633  $this->writeRandomQuestionInput(true);
2634  $position = key($_POST['cmd']['addsource']);
2635  $this->object->addRandomQuestionpoolData(0, 0, $position+1);
2636  $this->randomQuestionsObject();
2637  }
2638 
2640  {
2641  $this->writeRandomQuestionInput(true);
2642  $position = key($_POST['cmd']['removesource']);
2643  $this->object->removeRandomQuestionpoolData($position);
2644  $this->randomQuestionsObject();
2645  }
2646 
2648  {
2649  global $ilUser;
2650 
2651  $total = $this->object->evalTotalPersons();
2652  $save = (strcmp($this->ctrl->getCmd(), "saveRandomQuestions") == 0) ? TRUE : FALSE;
2653 
2654  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
2655  $form = new ilPropertyFormGUI();
2656  $form->setFormAction($this->ctrl->getFormAction($this, 'randomQuestions'));
2657  $form->setTitle($this->lng->txt('random_selection'));
2658  $form->setDescription($this->lng->txt('tst_select_random_questions'));
2659  $form->setMultipart(FALSE);
2660  $form->setTableWidth("100%");
2661  $form->setId("randomSelectionForm");
2662 
2663  // question selection
2664  $selection_mode = ($save) ? $_POST['chbQuestionSelectionMode'] : $ilUser->getPref("tst_question_selection_mode_equal");
2665  $question_selection = new ilCheckboxInputGUI($this->lng->txt("tst_question_selection"), "chbQuestionSelectionMode");
2666  $question_selection->setValue(1);
2667  $question_selection->setChecked($selection_mode);
2668  $question_selection->setOptionTitle($this->lng->txt('tst_question_selection_equal'));
2669  $question_selection->setInfo($this->lng->txt('tst_question_selection_description'));
2670  $question_selection->setRequired(false);
2671  $form->addItem($question_selection);
2672 
2673  // total amount of questions
2674  $total_questions = new ilNumberInputGUI($this->lng->txt('tst_total_questions'), 'total_questions');
2675  $total_questions->setValue($this->object->getRandomQuestionCount());
2676  $total_questions->setSize(3);
2677  $total_questions->setInfo($this->lng->txt('tst_total_questions_description'));
2678  $total_questions->setRequired(false);
2679  $form->addItem($total_questions);
2680 
2681  if ($total == 0)
2682  {
2683  $found_qpls = $this->object->getRandomQuestionpoolData();
2684  include_once "./Modules/Test/classes/class.ilRandomTestData.php";
2685  if (count($found_qpls) == 0)
2686  {
2687  array_push($found_qpls, new ilRandomTestData());
2688  }
2689  $available_qpl =& $this->object->getAvailableQuestionpools(TRUE, $selection_mode, FALSE, TRUE, TRUE);
2690  include_once './Modules/Test/classes/class.ilRandomTestInputGUI.php';
2691  $source = new ilRandomTestInputGUI($this->lng->txt('tst_random_questionpools'), 'source');
2692  $source->setUseEqualPointsOnly($selection_mode);
2693  $source->setRandomQuestionPools($available_qpl);
2694  $source->setUseQuestionCount((array_key_exists('total_questions', $_POST)) ? ($_POST['total_questions'] < 1) : ($this->object->getRandomQuestionCount() < 1));
2695  $source->setValues($found_qpls);
2696  $form->addItem($source);
2697  }
2698  else
2699  {
2700  $qpls = $this->object->getUsedRandomQuestionpools();
2701  include_once './Modules/Test/classes/class.ilRandomTestROInputGUI.php';
2702  $source = new ilRandomTestROInputGUI($this->lng->txt('tst_random_questionpools'), 'source');
2703  $source->setValues($qpls);
2704  $form->addItem($source);
2705  }
2706 
2707  if ($total == 0) $form->addCommandButton("saveRandomQuestions", $this->lng->txt("save"));
2708 
2709  $errors = false;
2710 
2711  if ($save)
2712  {
2713  $form->setValuesByPost();
2714  $errors = !$form->checkInput();
2715  if (!$errors)
2716  {
2717  // check total amount of questions
2718  if ($_POST['total_questions'] > 0)
2719  {
2720  $totalcount = 0;
2721  foreach ($_POST['source']['qpl'] as $idx => $qpl)
2722  {
2723  $totalcount += $available_qpl[$qpl]['count'];
2724  }
2725  if ($_POST['total_questions'] > $totalcount)
2726  {
2727  $total_questions->setAlert($this->lng->txt('msg_total_questions_too_high'));
2728  $errors = true;
2729  }
2730  }
2731  }
2732  if ($errors) $checkonly = false;
2733  }
2734 
2735  if (!$checkonly) $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
2736  return $errors;
2737  }
2738 
2740  {
2741  global $ilUser;
2742  if ($_POST["chbQuestionSelectionMode"])
2743  {
2744  $ilUser->setPref("tst_question_selection_mode_equal", 1);
2745  $ilUser->writePref("tst_question_selection_mode_equal", 1);
2746  }
2747  else
2748  {
2749  $ilUser->setPref("tst_question_selection_mode_equal", 0);
2750  $ilUser->writePref("tst_question_selection_mode_equal", 0);
2751  }
2752  $this->randomQuestionsObject();
2753  }
2754 
2756  {
2757  $this->questionBrowser();
2758  }
2759 
2768  {
2769  $qpl_ref_id = $_REQUEST["sel_qpl"];
2770 
2771  $qpl_mode = $_REQUEST['usage'];
2772 
2773  if (!$qpl_mode || ($qpl_mode == 2 && strcmp($_REQUEST["txt_qpl"], "") == 0) || ($qpl_mode == 3 && strcmp($qpl_ref_id, "") == 0))
2774  //if ((strcmp($_REQUEST["txt_qpl"], "") == 0) && (strcmp($qpl_ref_id, "") == 0))
2775  {
2776  ilUtil::sendInfo($this->lng->txt("questionpool_not_entered"));
2777  $this->createQuestionObject();
2778  return;
2779  }
2780  else
2781  {
2782  $_SESSION["test_id"] = $this->object->getRefId();
2783  if ($qpl_mode == 2 && strcmp($_REQUEST["txt_qpl"], "") != 0)
2784  {
2785  // create a new question pool and return the reference id
2786  $qpl_ref_id = $this->createQuestionPool($_REQUEST["txt_qpl"]);
2787  }
2788  else if ($qpl_mode == 1)
2789  {
2790  $qpl_ref_id = $_GET["ref_id"];
2791  }
2792 
2793  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPoolGUI.php";
2794 
2795  $baselink = "ilias.php?baseClass=ilObjQuestionPoolGUI&ref_id=" . $qpl_ref_id . "&cmd=createQuestionForTest&test_ref_id=".$_GET["ref_id"]."&calling_test=".$_GET["ref_id"]."&sel_question_types=" . $_REQUEST["sel_question_types"];
2796 
2797  if ($_REQUEST['q_id']) {
2798  $baselink .= '&q_id=' . $_REQUEST['q_id'];
2799  }
2800  if ($_REQUEST['prev_qid']) {
2801  $baselink .= '&prev_qid=' . $_REQUEST['prev_qid'];
2802  }
2803  if ($_REQUEST['test_express_mode']) {
2804  $baselink .= '&test_express_mode=1';
2805  }
2806 #var_dump($_REQUEST['prev_qid']);
2807  ilUtil::redirect($baselink);
2808 
2809  exit();
2810  }
2811  }
2812 
2821  {
2822  $this->ctrl->redirect($this, "questions");
2823  }
2824 
2833  {
2834  global $ilUser;
2835  $this->getQuestionsSubTabs();
2836  //$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_qpl_select.html", "Modules/Test");
2837  $questionpools =& $this->object->getAvailableQuestionpools(FALSE, FALSE, FALSE, TRUE, FALSE, "write");
2838  if ($this->object->getPoolUsage()) {
2839  global $lng, $ilCtrl, $tpl;
2840 
2841  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
2842 
2843  $form = new ilPropertyFormGUI();
2844  $form->setFormAction($ilCtrl->getFormAction($this, "executeCreateQuestion"));
2845  $form->setTitle($lng->txt("test_create_question"));
2846  include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
2847 
2848 
2849  $hidden = new ilHiddenInputGUI('sel_question_types');
2850  $hidden->setValue($_REQUEST["sel_question_types"]);
2851  $form->addItem($hidden);
2852 
2853  // use pool
2854  $usage = new ilRadioGroupInputGUI($this->lng->txt("assessment_pool_selection"), "usage");
2855  $usage->setRequired(true);
2856  $no_pool = new ilRadioOption($this->lng->txt("assessment_no_pool"), 1);
2857  $usage->addOption($no_pool);
2858  $existing_pool = new ilRadioOption($this->lng->txt("assessment_existing_pool"), 3);
2859  $usage->addOption($existing_pool);
2860  $new_pool = new ilRadioOption($this->lng->txt("assessment_new_pool"), 2);
2861  $usage->addOption($new_pool);
2862  $form->addItem($usage);
2863 
2864  $usage->setValue(1);
2865 
2866  $questionpools = ilObjQuestionPool::_getAvailableQuestionpools(FALSE, FALSE, TRUE, FALSE, FALSE, "write");
2867  $pools_data = array();
2868  foreach($questionpools as $key => $p) {
2869  $pools_data[$key] = $p['title'];
2870  }
2871  $pools = new ilSelectInputGUI($this->lng->txt("select_questionpool"), "sel_qpl");
2872  $pools->setOptions($pools_data);
2873  $existing_pool->addSubItem($pools);
2874 
2875 
2876  $name = new ilTextInputGUI($this->lng->txt("cat_create_qpl"), "txt_qpl");
2877  $name->setSize(50);
2878  $name->setMaxLength(50);
2879  $new_pool->addSubItem($name);
2880 
2881  $form->addCommandButton("executeCreateQuestion", $lng->txt("submit"));
2882  $form->addCommandButton("cancelCreateQuestion", $lng->txt("cancel"));
2883 
2884  return $this->tpl->setVariable('ADM_CONTENT', $form->getHTML());
2885 
2886  }
2887  else {
2888  global $ilCtrl;
2889 
2890  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'sel_question_types', $_REQUEST["sel_question_types"]);
2891  $link = $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'handleToolbarCommand','',false,false);
2892  ilUtil::redirect($link);
2893  }
2894  }
2895 
2900  {
2901  $checked_questions = $_POST["q_id"];
2902 
2903  $questions = $this->object->getQuestionTitlesAndIndexes();
2904  $deleted = array();
2905  foreach((array)$checked_questions as $value)
2906  {
2907  $this->object->removeQuestion($value);
2908  $deleted[] = $value;
2909  }
2910 
2911  $this->object->saveCompleteStatus();
2912 
2913  ilUtil::sendSuccess($this->lng->txt("tst_questions_removed"));
2914 
2915  if($_REQUEST['test_express_mode'])
2916  {
2917  $prev = null;
2918  $return_to = null;
2919  $deleted_tmp = $deleted;
2920  $first = array_shift($deleted_tmp);
2921  foreach((array)$questions as $key => $value)
2922  {
2923  if(!in_array($key, $deleted))
2924  {
2925  $prev = $key;
2926  if(!$first)
2927  {
2928  $return_to = $prev;
2929  break;
2930  }
2931  else continue;
2932  }
2933  else if($key == $first)
2934  {
2935  if($prev)
2936  {
2937  $return_to = $prev;
2938  break;
2939  }
2940  $first = array_shift($deleted_tmp);
2941  }
2942  }
2943 
2944  if(
2945  count($questions) == count($checked_questions) ||
2946  !$return_to
2947  )
2948  {
2949  $this->ctrl->setParameter($this, 'q_id', '');
2950  $this->ctrl->redirect($this, 'showPage');
2951  }
2952 
2953  $this->ctrl->setParameter($this, 'q_id', $return_to);
2954  $this->ctrl->redirect($this, "showPage");
2955  }
2956  else
2957  {
2958  $this->ctrl->setParameter($this, 'q_id', '');
2959  $this->ctrl->redirect($this, 'questions');
2960  }
2961  }
2962 
2971  {
2972  if ($_REQUEST['test_express_mode']) {
2973  $this->ctrl->setParameter($this, 'q_id', $_REQUEST['q_id']);
2974  $this->ctrl->redirect($this, "showPage");
2975  }
2976  else {
2977  $this->ctrl->redirect($this, "questions");
2978  }
2979  }
2980 
2988  function removeQuestionsForm($checked_questions)
2989  {
2990  $total = $this->object->evalTotalPersons();
2991  if ($total)
2992  {
2993  // the test was executed previously
2994  $question = sprintf($this->lng->txt("tst_remove_questions_and_results"), $total);
2995  }
2996  else
2997  {
2998  if (count($checked_questions) == 1)
2999  {
3000  $question = $this->lng->txt("tst_remove_question");
3001  }
3002  else
3003  {
3004  $question = $this->lng->txt("tst_remove_questions");
3005  }
3006  }
3007 
3008  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
3009  $cgui = new ilConfirmationGUI();
3010  $cgui->setHeaderText($question);
3011 
3012  $this->ctrl->saveParameter($this, 'test_express_mode');
3013  $this->ctrl->saveParameter($this, 'q_id');
3014 
3015  $cgui->setFormAction($this->ctrl->getFormAction($this));
3016  $cgui->setCancel($this->lng->txt("cancel"), "cancelRemoveQuestions");
3017  $cgui->setConfirm($this->lng->txt("confirm"), "confirmRemoveQuestions");
3018 
3019  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
3020  $removablequestions =& $this->object->getTestQuestions();
3021  if (count($removablequestions))
3022  {
3023  foreach ($removablequestions as $data)
3024  {
3025  if (in_array($data["question_id"], $checked_questions))
3026  {
3027  $txt = $data["title"]." (".assQuestion::_getQuestionTypeName($data["type_tag"]).")";
3028  if($data["description"])
3029  {
3030  $txt .= "<div class=\"small\">".$data["description"]."</div>";
3031  }
3032 
3033  $cgui->addItem("q_id[]", $data["question_id"], $txt);
3034  }
3035  }
3036  }
3037 
3038  $this->tpl->setContent($cgui->getHTML());
3039  }
3040 
3049  {
3050  $this->getQuestionsSubTabs();
3051  $checked_questions = $_REQUEST["q_id"];
3052  if (!is_array($checked_questions) && $checked_questions) {
3053  $checked_questions = array($checked_questions);
3054  }
3055  if (count($checked_questions) > 0)
3056  {
3057  $this->removeQuestionsForm($checked_questions);
3058  return;
3059  }
3060  elseif (count($checked_questions) == 0)
3061  {
3062  ilUtil::sendInfo($this->lng->txt("tst_no_question_selected_for_removal"), true);
3063  $this->ctrl->redirect($this, "questions");
3064  }
3065  }
3066 
3071  {
3072  $selected_questions = NULL;
3073  $selected_questions = $_POST['q_id'];
3074  if (is_array($selected_questions))
3075  {
3076  $_SESSION['tst_qst_move_' . $this->object->getTestId()] = $_POST['q_id'];
3077  ilUtil::sendSuccess($this->lng->txt("msg_selected_for_move"), true);
3078  }
3079  else
3080  {
3081  ilUtil::sendFailure($this->lng->txt('no_selection_for_move'), TRUE);
3082  }
3083  $this->ctrl->redirect($this, 'questions');
3084  }
3085 
3090  {
3091  // get all questions to move
3092  $move_questions = $_SESSION['tst_qst_move_' . $this->object->getTestId()];
3093 
3094  if (count($_POST['q_id']) == 0)
3095  {
3096  ilUtil::sendFailure($this->lng->txt("no_target_selected_for_move"), true);
3097  $this->ctrl->redirect($this, 'questions');
3098  }
3099  if (count($_POST['q_id']) > 1)
3100  {
3101  ilUtil::sendFailure($this->lng->txt("too_many_targets_selected_for_move"), true);
3102  $this->ctrl->redirect($this, 'questions');
3103  }
3104  $insert_mode = 0;
3105  $this->object->moveQuestions($_SESSION['tst_qst_move_' . $this->object->getTestId()], $_POST['q_id'][0], $insert_mode);
3106  ilUtil::sendSuccess($this->lng->txt("msg_questions_moved"), true);
3107  unset($_SESSION['tst_qst_move_' . $this->object->getTestId()]);
3108  $this->ctrl->redirect($this, "questions");
3109  }
3110 
3114  public function insertQuestionsAfterObject()
3115  {
3116  // get all questions to move
3117  $move_questions = $_SESSION['tst_qst_move_' . $this->object->getTestId()];
3118  if (count($_POST['q_id']) == 0)
3119  {
3120  ilUtil::sendFailure($this->lng->txt("no_target_selected_for_move"), true);
3121  $this->ctrl->redirect($this, 'questions');
3122  }
3123  if (count($_POST['q_id']) > 1)
3124  {
3125  ilUtil::sendFailure($this->lng->txt("too_many_targets_selected_for_move"), true);
3126  $this->ctrl->redirect($this, 'questions');
3127  }
3128  $insert_mode = 1;
3129  $this->object->moveQuestions($_SESSION['tst_qst_move_' . $this->object->getTestId()], $_POST['q_id'][0], $insert_mode);
3130  ilUtil::sendSuccess($this->lng->txt("msg_questions_moved"), true);
3131  unset($_SESSION['tst_qst_move_' . $this->object->getTestId()]);
3132  $this->ctrl->redirect($this, "questions");
3133  }
3134 
3141  {
3142  $selected_array = (is_array($_POST['q_id'])) ? $_POST['q_id'] : array();
3143  if (!count($selected_array))
3144  {
3145  ilUtil::sendInfo($this->lng->txt("tst_insert_missing_question"), true);
3146  $this->ctrl->redirect($this, "browseForQuestions");
3147  }
3148  else
3149  {
3150  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
3151  $manscoring = FALSE;
3152  foreach ($selected_array as $key => $value)
3153  {
3154  $this->object->insertQuestion($value);
3155  if (!$manscoring)
3156  {
3157  $manscoring = $manscoring | assQuestion::_needsManualScoring($value);
3158  }
3159  }
3160  $this->object->saveCompleteStatus();
3161  if ($manscoring)
3162  {
3163  ilUtil::sendInfo($this->lng->txt("manscoring_hint"), TRUE);
3164  }
3165  else
3166  {
3167  ilUtil::sendSuccess($this->lng->txt("tst_questions_inserted"), TRUE);
3168  }
3169  $this->ctrl->redirect($this, "questions");
3170  return;
3171  }
3172  }
3173 
3175  {
3176  include_once "./Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php";
3177  $table_gui = new ilTestQuestionBrowserTableGUI($this, 'browseForQuestions');
3178  $table_gui->writeFilterToSession();
3179  $this->ctrl->redirect($this, "browseForQuestions");
3180  }
3181 
3183  {
3184  include_once "./Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php";
3185  $table_gui = new ilTestQuestionBrowserTableGUI($this, 'browseForQuestions');
3186  $table_gui->resetFilter();
3187  $this->ctrl->redirect($this, "browseForQuestions");
3188  }
3189 
3195  function questionBrowser()
3196  {
3197  global $ilAccess;
3198 
3199  $this->ctrl->setParameterByClass(get_class($this), "browse", "1");
3200 
3201  include_once "./Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php";
3202  $table_gui = new ilTestQuestionBrowserTableGUI($this, 'browseForQuestions', (($ilAccess->checkAccess("write", "", $this->ref_id) ? true : false)));
3203  $arrFilter = array();
3204  foreach ($table_gui->getFilterItems() as $item)
3205  {
3206  if ($item->getValue() !== false)
3207  {
3208  $arrFilter[$item->getPostVar()] = $item->getValue();
3209  }
3210  }
3211  $data = $this->object->getAvailableQuestions($arrFilter, 1);
3212  $table_gui->setData($data);
3213  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
3214  }
3215 
3216  function questionsObject()
3217  {
3218  global $ilAccess, $ilTabs;
3219 
3220  // #12590
3221  $this->ctrl->setParameter($this, 'test_express_mode', '');
3222 
3223  $ilTabs->activateTab('assQuestions');
3224 
3225  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
3226  {
3227  // allow only write access
3228  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3229  $this->ctrl->redirect($this, "infoScreen");
3230  }
3231 
3232  if ($_GET['browse'])
3233  {
3234  return $this->questionbrowser();
3235  }
3236 
3237  $this->getQuestionsSubTabs();
3238 
3239  // #11631, #12994
3240  $this->ctrl->setParameter($this, 'q_id', '');
3241 
3242  if ($this->object->isRandomTest())
3243  {
3244  $this->randomQuestionsObject();
3245  return;
3246  }
3247 
3248  if ($_GET["eqid"] && $_GET["eqpl"])
3249  {
3250  ilUtil::redirect("ilias.php?baseClass=ilObjQuestionPoolGUI&ref_id=" . $_GET["eqpl"] . "&cmd=editQuestionForTest&calling_test=".$_GET["ref_id"]."&q_id=" . $_GET["eqid"]);
3251  }
3252 
3253  if ($_GET["up"] > 0)
3254  {
3255  $this->object->questionMoveUp($_GET["up"]);
3256  }
3257  if ($_GET["down"] > 0)
3258  {
3259  $this->object->questionMoveDown($_GET["down"]);
3260  }
3261 
3262  if ($_GET["add"])
3263  {
3264  $selected_array = array();
3265  array_push($selected_array, $_GET["add"]);
3266  $total = $this->object->evalTotalPersons();
3267  if ($total)
3268  {
3269  // the test was executed previously
3270  ilUtil::sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total));
3271  }
3272  else
3273  {
3274  ilUtil::sendInfo($this->lng->txt("tst_insert_questions"));
3275  }
3276  $this->insertQuestions($selected_array);
3277  return;
3278  }
3279 
3280  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_questions.html", "Modules/Test");
3281 
3282  $total = $this->object->evalTotalPersons();
3283  if ($ilAccess->checkAccess("write", "", $this->ref_id))
3284  {
3285  if($total != 0)
3286  {
3287  $link = $this->ctrl->getLinkTarget($this, "participants");
3288  $link = "<a href=\"".$link."\">".$this->lng->txt("test_has_datasets_warning_page_view_link")."</a>";
3289  ilUtil::sendInfo($this->lng->txt("test_has_datasets_warning_page_view")." ".$link);
3290  }
3291  else {
3292  global $ilToolbar;
3293 
3294  $qtypes = array();
3295  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
3296  foreach (ilObjQuestionPool::_getQuestionTypes(false, true) as $trans => $data)
3297  {
3298  $qtypes[$data['type_tag']] = $trans;
3299  }
3300  $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
3301  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
3302  $types = new ilSelectInputGUI($this->lng->txt("create_new"), "sel_question_types");
3303  $types->setOptions($qtypes);
3304 
3305  $ilToolbar->addInputItem($types);
3306  $ilToolbar->addFormButton($this->lng->txt("test_create_question"), "createQuestion");
3307 
3308  if ($this->object->getPoolUsage()) {
3309  $ilToolbar->addSeparator();
3310  $ilToolbar->addButton($this->lng->txt("tst_browse_for_questions"), $this->ctrl->getLinkTarget($this, 'browseForQuestions'));
3311  }
3312 
3313  $ilToolbar->addSeparator();
3314  $ilToolbar->addButton($this->lng->txt("random_selection"), $this->ctrl->getLinkTarget($this, "randomselect"));
3315 
3316 
3317  global $ilAccess, $ilUser, $lng, $ilCtrl;
3318  $seq = $this->object->getTestSession()->getLastSequence();
3319  $online_access = false;
3320  if ($this->object->getFixedParticipants())
3321  {
3322  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
3323  $online_access_result = ilObjTestAccess::_lookupOnlineTestAccess($this->object->getId(), $ilUser->getId());
3324  if ($online_access_result === true)
3325  {
3326  $online_access = true;
3327  }
3328  }
3329 
3330  if( $this->object->isOnline() && $this->object->isComplete() )
3331  {
3332  if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id))
3333  {
3334  $executable = $this->object->isExecutable($ilUser->getId(), $allowPassIncrease = TRUE);
3335  if ($executable["executable"])
3336  {
3337  if ($this->object->getTestSession()->getActiveId() > 0)
3338  {
3339  $ilToolbar->addSeparator();
3340  $ilToolbar->addButton($lng->txt('tst_resume_test'), $ilCtrl->getLinkTargetByClass('iltestoutputgui', 'resume'));
3341  }
3342  else
3343  {
3344  $ilToolbar->addSeparator();
3345  $ilToolbar->addButton($lng->txt('tst_start_test'), $ilCtrl->getLinkTargetByClass('iltestoutputgui', 'startTest'));
3346  }
3347  }
3348  }
3349  }
3350 
3351 
3352  }
3353  }
3354 
3355  $this->tpl->setCurrentBlock("adm_content");
3356  include_once "./Modules/Test/classes/tables/class.ilTestQuestionsTableGUI.php";
3357  $checked_move = is_array($_SESSION['tst_qst_move_' . $this->object->getTestId()]) && (count($_SESSION['tst_qst_move_' . $this->object->getTestId()]));
3358  $table_gui = new ilTestQuestionsTableGUI($this, 'questions', (($ilAccess->checkAccess("write", "", $this->ref_id) ? true : false)), $checked_move, $total);
3359  $data = $this->object->getTestQuestions();
3360  $table_gui->setData($data);
3361  $this->tpl->setVariable('QUESTIONBROWSER', $table_gui->getHTML());
3362  $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this));
3363  $this->tpl->parseCurrentBlock();
3364  }
3365 
3366  function takenObject() {
3367  }
3368 
3377  {
3378  $this->saveMarkSchemaFormData();
3379  $this->object->mark_schema->addMarkStep();
3380  $this->marksObject();
3381  }
3382 
3391  {
3392  $this->object->mark_schema->flush();
3393  foreach ($_POST as $key => $value) {
3394  if (preg_match("/mark_short_(\d+)/", $key, $matches))
3395  {
3396  $this->object->mark_schema->addMarkStep(ilUtil::stripSlashes($_POST["mark_short_$matches[1]"]), ilUtil::stripSlashes($_POST["mark_official_$matches[1]"]), ilUtil::stripSlashes($_POST["mark_percentage_$matches[1]"]), ilUtil::stripSlashes($_POST["passed_$matches[1]"]));
3397  }
3398  }
3399  $this->object->ects_grades["A"] = $_POST["ects_grade_a"];
3400  $this->object->ects_grades["B"] = $_POST["ects_grade_b"];
3401  $this->object->ects_grades["C"] = $_POST["ects_grade_c"];
3402  $this->object->ects_grades["D"] = $_POST["ects_grade_d"];
3403  $this->object->ects_grades["E"] = $_POST["ects_grade_e"];
3404  if ($_POST["chbUseFX"])
3405  {
3406  $this->object->ects_fx = $_POST["percentFX"];
3407  }
3408  else
3409  {
3410  $this->object->ects_fx = "";
3411  }
3412  $this->object->ects_output = $_POST["chbECTS"];
3413  }
3414 
3423  {
3424  $this->object->mark_schema->createSimpleSchema($this->lng->txt("failed_short"), $this->lng->txt("failed_official"), 0, 0, $this->lng->txt("passed_short"), $this->lng->txt("passed_official"), 50, 1);
3425  $this->marksObject();
3426  }
3427 
3436  {
3437  $this->saveMarkSchemaFormData();
3438  $delete_mark_steps = array();
3439  foreach ($_POST as $key => $value) {
3440  if (preg_match("/cb_(\d+)/", $key, $matches)) {
3441  array_push($delete_mark_steps, $matches[1]);
3442  }
3443  }
3444  if (count($delete_mark_steps)) {
3445  $this->object->mark_schema->deleteMarkSteps($delete_mark_steps);
3446  } else {
3447  ilUtil::sendInfo($this->lng->txt("tst_delete_missing_mark"));
3448  }
3449  $this->marksObject();
3450  }
3451 
3460  {
3461  $this->ctrl->redirect($this, "marks");
3462  }
3463 
3471  function saveMarksObject()
3472  {
3473  try
3474  {
3475  $this->saveMarkSchemaFormData();
3476  $mark_check = $this->object->checkMarks();
3477  }
3478  catch (Exception $ex)
3479  {
3480  $mark_check = $this->lng->txt('mark_schema_invalid');
3481  }
3482 
3483  if ($mark_check !== true)
3484  {
3485  ilUtil::sendFailure($mark_check);
3486  }
3487  elseif ($_POST["chbECTS"] && ((strcmp($_POST["ects_grade_a"], "") == 0) or (strcmp($_POST["ects_grade_b"], "") == 0) or (strcmp($_POST["ects_grade_c"], "") == 0) or (strcmp($_POST["ects_grade_d"], "") == 0) or (strcmp($_POST["ects_grade_e"], "") == 0)))
3488  {
3489  ilUtil::sendInfo($this->lng->txt("ects_fill_out_all_values"), true);
3490  }
3491  elseif (($_POST["ects_grade_a"] > 100) or ($_POST["ects_grade_a"] < 0))
3492  {
3493  ilUtil::sendInfo($this->lng->txt("ects_range_error_a"), true);
3494  }
3495  elseif (($_POST["ects_grade_b"] > 100) or ($_POST["ects_grade_b"] < 0))
3496  {
3497  ilUtil::sendInfo($this->lng->txt("ects_range_error_b"), true);
3498  }
3499  elseif (($_POST["ects_grade_c"] > 100) or ($_POST["ects_grade_c"] < 0))
3500  {
3501  ilUtil::sendInfo($this->lng->txt("ects_range_error_c"), true);
3502  }
3503  elseif (($_POST["ects_grade_d"] > 100) or ($_POST["ects_grade_d"] < 0))
3504  {
3505  ilUtil::sendInfo($this->lng->txt("ects_range_error_d"), true);
3506  }
3507  elseif (($_POST["ects_grade_e"] > 100) or ($_POST["ects_grade_e"] < 0))
3508  {
3509  ilUtil::sendInfo($this->lng->txt("ects_range_error_e"), true);
3510  }
3511  else
3512  {
3513  $this->object->mark_schema->saveToDb($this->object->getTestId());
3514  $this->object->saveCompleteStatus();
3515  if ($this->object->getReportingDate())
3516  {
3517  $fxpercent = "";
3518  if ($_POST["chbUseFX"])
3519  {
3520  $fxpercent = ilUtil::stripSlashes($_POST["percentFX"]);
3521  }
3522  $this->object->saveECTSStatus($_POST["chbECTS"], $fxpercent, ilUtil::stripSlashes($this->object->ects_grades["A"]), ilUtil::stripSlashes($this->object->ects_grades["B"]), ilUtil::stripSlashes($this->object->ects_grades["C"]), ilUtil::stripSlashes($this->object->ects_grades["D"]), ilUtil::stripSlashes($this->object->ects_grades["E"]));
3523  }
3524  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
3525  }
3526  $this->marksObject();
3527  }
3528 
3529  function marksObject()
3530  {
3531  global $ilAccess;
3532  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
3533  {
3534  // allow only write access
3535  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3536  $this->ctrl->redirect($this, "infoScreen");
3537  }
3538 
3539  if (!$this->object->canEditMarks())
3540  {
3541  ilUtil::sendInfo($this->lng->txt("cannot_edit_marks"));
3542  }
3543 
3544  $this->object->mark_schema->sort();
3545 
3546  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_marks.html", "Modules/Test");
3547  $marks = $this->object->mark_schema->mark_steps;
3548  $rows = array("tblrow1", "tblrow2");
3549  $counter = 0;
3550  foreach ($marks as $key => $value)
3551  {
3552  $this->tpl->setCurrentBlock("markrow");
3553  $this->tpl->setVariable("MARK_SHORT", $value->getShortName());
3554  $this->tpl->setVariable("MARK_OFFICIAL", $value->getOfficialName());
3555  $this->tpl->setVariable("MARK_PERCENTAGE", sprintf("%.2f", $value->getMinimumLevel()));
3556  $this->tpl->setVariable("MARK_PASSED", strtolower($this->lng->txt("tst_mark_passed")));
3557  $this->tpl->setVariable("MARK_ID", "$key");
3558  $this->tpl->setVariable("ROW_CLASS", $rows[$counter % 2]);
3559 
3560  if( $value->getPassed() )
3561  {
3562  $this->tpl->setVariable("MARK_PASSED_CHECKED", " checked=\"checked\"");
3563  }
3564 
3565  $this->tpl->parseCurrentBlock();
3566  $counter++;
3567  }
3568  if (count($marks) == 0)
3569  {
3570  $this->tpl->setCurrentBlock("Emptyrow");
3571  $this->tpl->setVariable("EMPTY_ROW", $this->lng->txt("tst_no_marks_defined"));
3572  $this->tpl->setVariable("ROW_CLASS", $rows[$counter % 2]);
3573  $this->tpl->parseCurrentBlock();
3574  }
3575  else
3576  {
3577  if ($ilAccess->checkAccess("write", "", $this->ref_id) && $this->object->canEditMarks())
3578  {
3579  $this->tpl->setCurrentBlock("selectall");
3580  $counter++;
3581  $this->tpl->setVariable("ROW_CLASS", $rows[$counter % 2]);
3582  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
3583  $this->tpl->parseCurrentBlock();
3584  $this->tpl->setCurrentBlock("Footer");
3585  $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.png") . "\" alt=\"".$this->lng->txt("arrow_downright")."\"/>");
3586  $this->tpl->setVariable("BUTTON_EDIT", $this->lng->txt("edit"));
3587  $this->tpl->setVariable("BUTTON_DELETE", $this->lng->txt("delete"));
3588  $this->tpl->parseCurrentBlock();
3589  }
3590  }
3591 
3592  if ($this->object->getReportingDate())
3593  {
3594  $this->tpl->setCurrentBlock("ects");
3595  if ($this->object->ects_output)
3596  {
3597  $this->tpl->setVariable("CHECKED_ECTS", " checked=\"checked\"");
3598  }
3599  $this->tpl->setVariable("TEXT_OUTPUT_ECTS_GRADES", $this->lng->txt("ects_output_of_ects_grades"));
3600  $this->tpl->setVariable("TEXT_ALLOW_ECTS_GRADES", $this->lng->txt("ects_allow_ects_grades"));
3601  $this->tpl->setVariable("TEXT_USE_FX", $this->lng->txt("ects_use_fx_grade"));
3602  if (preg_match("/\d+/", $this->object->ects_fx))
3603  {
3604  $this->tpl->setVariable("CHECKED_FX", " checked=\"checked\"");
3605  $this->tpl->setVariable("VALUE_PERCENT_FX", sprintf("value=\"%s\" ", $this->object->ects_fx));
3606  }
3607  $this->tpl->setVariable("TEXT_PERCENT", $this->lng->txt("ects_use_fx_grade_part2"));
3608  $this->tpl->setVariable("ECTS_GRADE", $this->lng->txt("ects_grade"));
3609  $this->tpl->setVariable("PERCENTILE", $this->lng->txt("percentile"));
3610  $this->tpl->setVariable("ECTS_GRADE_A", "A - " . $this->lng->txt("ects_grade_a_short"));
3611  $this->tpl->setVariable("VALUE_GRADE_A", $this->object->ects_grades["A"]);
3612  $this->tpl->setVariable("ECTS_GRADE_B", "B - " . $this->lng->txt("ects_grade_b_short"));
3613  $this->tpl->setVariable("VALUE_GRADE_B", $this->object->ects_grades["B"]);
3614  $this->tpl->setVariable("ECTS_GRADE_C", "C - " . $this->lng->txt("ects_grade_c_short"));
3615  $this->tpl->setVariable("VALUE_GRADE_C", $this->object->ects_grades["C"]);
3616  $this->tpl->setVariable("ECTS_GRADE_D", "D - " . $this->lng->txt("ects_grade_d_short"));
3617  $this->tpl->setVariable("VALUE_GRADE_D", $this->object->ects_grades["D"]);
3618  $this->tpl->setVariable("ECTS_GRADE_E", "E - " . $this->lng->txt("ects_grade_e_short"));
3619  $this->tpl->setVariable("VALUE_GRADE_E", $this->object->ects_grades["E"]);
3620 
3621  $this->tpl->parseCurrentBlock();
3622  }
3623 
3624  $this->tpl->setCurrentBlock("adm_content");
3625  $this->tpl->setVariable("ACTION_MARKS", $this->ctrl->getFormAction($this));
3626  $this->tpl->setVariable("HEADER_SHORT", $this->lng->txt("tst_mark_short_form"));
3627  $this->tpl->setVariable("HEADER_OFFICIAL", $this->lng->txt("tst_mark_official_form"));
3628  $this->tpl->setVariable("HEADER_PERCENTAGE", $this->lng->txt("tst_mark_minimum_level"));
3629  $this->tpl->setVariable("HEADER_PASSED", $this->lng->txt("tst_mark_passed"));
3630  if ($ilAccess->checkAccess("write", "", $this->ref_id) && $this->object->canEditMarks())
3631  {
3632  $this->tpl->setVariable("BUTTON_NEW", $this->lng->txt("tst_mark_create_new_mark_step"));
3633  $this->tpl->setVariable("BUTTON_NEW_SIMPLE", $this->lng->txt("tst_mark_create_simple_mark_schema"));
3634  $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
3635  $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
3636  }
3637  $this->tpl->parseCurrentBlock();
3638  }
3639 
3648  {
3649  global $ilDB, $lng;
3650 
3651  require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
3652  $participantData = new ilTestParticipantData($ilDB, $lng);
3653  $participantData->load($this->object->getTestId());
3654 
3655  $this->object->removeTestResults($participantData);
3656 
3657  // Update lp status
3658  self::_deleteLpMarksForUsers($this->object->getId(), $participantData->getUserIds());
3659  self::_deleteReadEventsForUsers($this->object->getId(), $participantData->getUserIds());
3660  include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
3661  ilLPStatusWrapper::_refreshStatus($this->object->getId());
3662 
3663  $this->object->removeTestActives($participantData->getActiveIds());
3664 
3665  #$this->object->removeAllTestEditings();
3666 
3667  ilUtil::sendSuccess($this->lng->txt("tst_all_user_data_deleted"), true);
3668  $this->ctrl->redirect($this, "participants");
3669  }
3670 
3671  public static function _deleteLpMarksForUsers($a_obj_id, array $a_user_ids)
3672  {
3673  global $ilDB;
3674 
3675  $ilDB->manipulate("DELETE FROM ut_lp_marks".
3676  " WHERE obj_id = ".$ilDB->quote($a_obj_id, "integer").
3677  " AND ".$ilDB->in("usr_id", $a_user_ids, "", "integer"));
3678  }
3679 
3680  public static function _deleteReadEventsForUsers($a_obj_id, array $a_user_ids)
3681  {
3682  global $ilDB;
3683 
3684  $ilDB->manipulate("DELETE FROM read_event".
3685  " WHERE obj_id = ".$ilDB->quote($a_obj_id, "integer").
3686  " AND ".$ilDB->in("usr_id", $a_user_ids, "", "integer"));
3687  }
3688 
3697  {
3698  global $ilDB, $lng;
3699 
3700  require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
3701  $participantData = new ilTestParticipantData($ilDB, $lng);
3702 
3703  if( $this->object->getFixedParticipants() )
3704  {
3705  $participantData->setUserIds($_POST["chbUser"]);
3706  }
3707  else
3708  {
3709  $participantData->setActiveIds($_POST["chbUser"]);
3710  }
3711 
3712  $participantData->load($this->object->getTestId());
3713 
3714  $this->object->removeTestResults($participantData);
3715 
3716  if( count($participantData->getUserIds()) )
3717  {
3718  // Update lp status
3719  self::_deleteLpMarksForUsers($this->object->getId(), $participantData->getUserIds());
3720  self::_deleteReadEventsForUsers($this->object->getId(), $participantData->getUserIds());
3721  include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
3722  ilLPStatusWrapper::_refreshStatus($this->object->getId());
3723  }
3724 
3725  $this->object->removeTestActives($participantData->getActiveIds());
3726 
3727  #$this->object->removeSelectedTestResults($active_ids);
3728 
3729  ilUtil::sendSuccess($this->lng->txt("tst_selected_user_data_deleted"), true);
3730  $this->ctrl->redirect($this, "participants");
3731  }
3732 
3741  {
3742  $this->ctrl->redirect($this, "participants");
3743  }
3744 
3755  {
3756  ilUtil::sendQuestion($this->lng->txt("confirm_delete_all_user_data"));
3757  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_maintenance.html", "Modules/Test");
3758 
3759  $this->tpl->setCurrentBlock("confirm_delete");
3760  $this->tpl->setVariable("BTN_CONFIRM_DELETE_ALL", $this->lng->txt("confirm"));
3761  $this->tpl->setVariable("BTN_CANCEL_DELETE_ALL", $this->lng->txt("cancel"));
3762  $this->tpl->parseCurrentBlock();
3763 
3764  $this->tpl->setCurrentBlock("adm_content");
3765  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
3766  $this->tpl->parseCurrentBlock();
3767  }
3768 
3772  public function deleteAllUserResultsObject()
3773  {
3774  // display confirmation message
3775  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
3776  $cgui = new ilConfirmationGUI();
3777  $cgui->setFormAction($this->ctrl->getFormAction($this, "participants"));
3778  $cgui->setHeaderText($this->lng->txt("delete_all_user_data_confirmation"));
3779  $cgui->setCancel($this->lng->txt("cancel"), "participants");
3780  $cgui->setConfirm($this->lng->txt("proceed"), "confirmDeleteAllUserResults");
3781 
3782  $this->tpl->setContent($cgui->getHTML());
3783  }
3784 
3793  {
3794  if (count($_POST["chbUser"]) == 0)
3795  {
3796  ilUtil::sendInfo($this->lng->txt("select_one_user"), TRUE);
3797  $this->ctrl->redirect($this, "participants");
3798  }
3799 
3800  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
3801  $cgui = new ilConfirmationGUI();
3802  $cgui->setHeaderText($this->lng->txt("confirm_delete_single_user_data"));
3803 
3804  $cgui->setFormAction($this->ctrl->getFormAction($this));
3805  $cgui->setCancel($this->lng->txt("cancel"), "cancelDeleteSelectedUserData");
3806  $cgui->setConfirm($this->lng->txt("confirm"), "confirmDeleteSelectedUserData");
3807 
3808  include_once './Services/User/classes/class.ilObjUser.php';
3809  foreach ($_POST["chbUser"] as $key => $active_id)
3810  {
3811  if ($this->object->getFixedParticipants())
3812  {
3813  $user_id = $active_id;
3814  }
3815  else
3816  {
3817  $user_id = $this->object->_getUserIdFromActiveId($active_id);
3818  }
3819  $user = ilObjUser::_lookupName($user_id);
3820 
3821  if ($this->object->getAnonymity())
3822  {
3823  $name = $this->lng->txt("anonymous");
3824  }
3825  else if($user["lastname"])
3826  {
3827  $name = $user["lastname"].", ".$user["firstname"]." (".
3828  $user["login"].")";
3829  }
3830  else
3831  {
3832  $name = $this->lng->txt("deleted_user");
3833  }
3834 
3835  $cgui->addItem("chbUser[]", $active_id, $name,
3836  ilUtil::getImagePath("icon_usr.png"), $this->lng->txt("usr"));
3837  }
3838 
3839  $this->tpl->setContent($cgui->getHTML());
3840  }
3841 
3849  function historyObject()
3850  {
3851  include_once "./Modules/Test/classes/tables/class.ilTestHistoryTableGUI.php";
3852  $table_gui = new ilTestHistoryTableGUI($this, 'history');
3853  $table_gui->setTestObject($this->object);
3854  include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
3855  $log =& ilObjAssessmentFolder::_getLog(0, time(), $this->object->getId(), TRUE);
3856  $table_gui->setData($log);
3857  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
3858  }
3859 
3860  function initImportForm($a_new_type)
3861  {
3862  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
3863  $form = new ilPropertyFormGUI();
3864  $form->setTarget("_top");
3865  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
3866  $this->ctrl->setParameter($this, "new_type", $new_type);
3867  $form->setFormAction($this->ctrl->getFormAction($this));
3868  $form->setTitle($this->lng->txt("import_tst"));
3869 
3870  // file
3871  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
3872  $fi = new ilFileInputGUI($this->lng->txt("import_file"), "xmldoc");
3873  $fi->setSuffixes(array("zip"));
3874  $fi->setRequired(true);
3875  $form->addItem($fi);
3876 
3877  // question pool
3878  include_once("./Modules/Test/classes/class.ilObjTest.php");
3879  $tst = new ilObjTest();
3880  $questionpools = $tst->getAvailableQuestionpools(TRUE, FALSE, TRUE, TRUE);
3881  if (count($questionpools))
3882  {
3883  $options = array("-1" => $this->lng->txt("dont_use_questionpool"));
3884  foreach ($questionpools as $key => $value)
3885  {
3886  $options[$key] = $value["title"];
3887  }
3888 
3889  $pool = new ilSelectInputGUI($this->lng->txt("select_questionpool"), "qpl");
3890  $pool->setOptions($options);
3891  $form->addItem($pool);
3892  }
3893 
3894  $form->addCommandButton("importFile", $this->lng->txt("import"));
3895  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
3896 
3897  return $form;
3898  }
3899 
3906  {
3907  $command = $_POST["command"];
3908  if (strlen($command))
3909  {
3910  $method = $command . "Object";
3911  if (method_exists($this, $method))
3912  {
3913  $this->$method();
3914  return;
3915  }
3916  }
3917  $this->ctrl->redirect($this, "participants");
3918  }
3919 
3926  {
3927  global $ilAccess, $ilToolbar, $lng;
3928 
3929  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
3930  {
3931  // allow only write access
3932  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3933  $this->ctrl->redirect($this, "infoScreen");
3934  }
3935 
3936  if ($this->object->getFixedParticipants())
3937  {
3938  // search button
3939  include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
3941  $this,
3942  $tb,
3943  array(
3944  'auto_complete_name' => $lng->txt('user'),
3945  'submit_name' => $lng->txt('add')
3946  )
3947  );
3948 
3949  // search button
3950  $ilToolbar->addButton($this->lng->txt("tst_search_users"),
3951  $this->ctrl->getLinkTargetByClass('ilRepositorySearchGUI','start'));
3952 
3953 
3954  $participants =& $this->object->getInvitedUsers();
3955  $rows = array();
3956  foreach ($participants as $data)
3957  {
3958  $maxpass = $this->object->_getMaxPass($data["active_id"]);
3959  if (!is_null($maxpass))
3960  {
3961  $maxpass += 1;
3962  }
3963  $access = "";
3964  if (strlen($data["active_id"]))
3965  {
3966  $last_access = $this->object->_getLastAccess($data["active_id"]);
3967  $access = $last_access;
3968  }
3969  $this->ctrl->setParameterByClass('iltestevaluationgui', 'active_id', $data['active_id']);
3970 
3971  if ($data['active_id'] == null) // if no active id is set, user is invitee not participant...
3972  {
3973  if ( strlen($data["firstname"].$data["lastname"]) == 0 )
3974  {
3975  $fullname = $lng->txt("deleted_user");
3976  }
3977  else
3978  {
3979  $fullname = trim($data["lastname"] . ", " . $data["firstname"] . " " . $data["title"]);
3980  }
3981  } else {
3982  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
3983  $fullname = ilObjTestAccess::_getParticipantData($data['active_id']);
3984  }
3985 
3986  array_push($rows, array(
3987  'usr_id' => $data["usr_id"],
3988  'active_id' => $data['active_id'],
3989  'login' => $data["login"],
3990  'clientip' => $data["clientip"],
3991  'firstname' => $data["firstname"],
3992  'lastname' => $data["lastname"],
3993  'name' => $fullname,
3994  'started' => ($data["active_id"] > 0) ? 1 : 0,
3995  'finished' => ($data["test_finished"] == 1) ? 1 : 0,
3996  'access' => $access,
3997  'maxpass' => $maxpass,
3998  'result' => $this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'outParticipantsResultsOverview')
3999  ));
4000  }
4001  include_once "./Modules/Test/classes/tables/class.ilTestFixedParticipantsTableGUI.php";
4002  $table_gui = new ilTestFixedParticipantsTableGUI($this, 'participants', $this->object->getAnonymity(), count($rows));
4003  $table_gui->setFilterCommand('fpSetFilter');
4004  $table_gui->setResetCommand('fpResetFiler');
4005  $rows = $this->applyFilterCriteria($rows);
4006  $table_gui->setData($rows);
4007  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
4008  }
4009  else
4010  {
4011  $participants =& $this->object->getTestParticipants();
4012  $rows = array();
4013  foreach ($participants as $data)
4014  {
4015  $maxpass = $this->object->_getMaxPass($data["active_id"]);
4016  if (!is_null($maxpass))
4017  {
4018  $maxpass += 1;
4019  }
4020  $access = "";
4021  if (strlen($data["active_id"]))
4022  {
4023  $last_access = $this->object->_getLastAccess($data["active_id"]);
4024  $access = $last_access;
4025  }
4026  $this->ctrl->setParameterByClass('iltestevaluationgui', 'active_id', $data['active_id']);
4027 
4028  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
4029  $fullname = ilObjTestAccess::_getParticipantData($data['active_id']);
4030  array_push($rows, array(
4031  'usr_id' => $data["active_id"],
4032  'active_id' => $data['active_id'],
4033  'login' => $data["login"],
4034  'name' => $fullname,
4035  'firstname' => $data["firstname"],
4036  'lastname' => $data["lastname"],
4037  'started' => ($data["active_id"] > 0) ? 1 : 0,
4038  'finished' => ($data["test_finished"] == 1) ? 1 : 0,
4039  'access' => $access,
4040  'maxpass' => $maxpass,
4041  'result' => $this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'outParticipantsResultsOverview')
4042  ));
4043  }
4044  include_once "./Modules/Test/classes/tables/class.ilTestParticipantsTableGUI.php";
4045  $table_gui = new ilTestParticipantsTableGUI($this, 'participants', $this->object->getAnonymity(), count($rows));
4046  $table_gui->setFilterCommand('npSetFilter');
4047  $table_gui->setResetCommand('npResetFilter');
4048  $rows = $this->applyFilterCriteria($rows);
4049  $table_gui->setData($rows);
4050  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
4051  }
4052  }
4053 
4054  function applyFilterCriteria($in_rows)
4055  {
4056  global $ilDB;
4057 
4058  $sess_filter = $_SESSION['form_']['selection'];
4059  $sess_filter = str_replace('"','',$sess_filter);
4060  $sess_filter = explode(':', $sess_filter);
4061  $filter = substr($sess_filter[2],0, strlen($sess_filter[2])-1);
4062 
4063  if ($filter == 'all' || $filter == false)
4064  {
4065  return $in_rows; #unchanged - no filter.
4066  }
4067 
4068  $with_result = array();
4069  $without_result = array();
4070  foreach ($in_rows as $row)
4071  {
4072  $result = $ilDB->query(
4073  'SELECT count(solution_id) count
4074  FROM tst_solutions
4075  WHERE active_fi = ' . $ilDB->quote($row['active_id'])
4076  );
4077  $count = $ilDB->fetchAssoc($result);
4078  $count = $count['count'];
4079 
4080  if ($count == 0)
4081  {
4082  $without_result[] = $row;
4083  }
4084  else
4085  {
4086  $with_result[] = $row;
4087  }
4088  }
4089 
4090  if ($filter == 'withSolutions')
4091  {
4092  return $with_result;
4093  }
4094  return $without_result;
4095 
4096  }
4097 
4099  {
4100  include_once("./Modules/Test/classes/tables/class.ilTestFixedParticipantsTableGUI.php");
4101  $table_gui = new ilTestFixedParticipantsTableGUI($this, "participants", $this->object->getAnonymity(), count($rows));
4102  $table_gui->writeFilterToSession(); // writes filter to session
4103  $table_gui->resetOffset(); // sets record offest to 0 (first page)
4104  $this->participantsObject();
4105  }
4106 
4108  {
4109  include_once("./Modules/Test/classes/tables/class.ilTestFixedParticipantsTableGUI.php");
4110  $table_gui = new ilTestFixedParticipantsTableGUI($this, "participants", $this->object->getAnonymity(), count($rows));
4111  $table_gui->resetFilter(); // writes filter to session
4112  $table_gui->resetOffset(); // sets record offest to 0 (first page)
4113  $this->participantsObject();
4114  }
4115 
4117  {
4118  include_once("./Modules/Test/classes/tables/class.ilTestParticipantsTableGUI.php");
4119  $table_gui = new ilTestParticipantsTableGUI($this, "participants", $this->object->getAnonymity(), count($rows));
4120  $table_gui->writeFilterToSession(); // writes filter to session
4121  $table_gui->resetOffset(); // sets record offest to 0 (first page)
4122  $this->participantsObject();
4123 
4124  }
4125 
4127  {
4128  include_once("./Modules/Test/classes/tables/class.ilTestParticipantsTableGUI.php");
4129  $table_gui = new ilTestParticipantsTableGUI($this, "participants", $this->object->getAnonymity(), count($rows));
4130  $table_gui->resetFilter(); // writes filter to session
4131  $table_gui->resetOffset(); // sets record offest to 0 (first page)
4132  $this->participantsObject();
4133 
4134  }
4135 
4142  {
4143  if (count($_POST))
4144  {
4145  $_SESSION["show_user_results"] = $_POST["chbUser"];
4146  }
4147  $this->showUserResults($show_pass_details = TRUE, $show_answers = TRUE, $show_reached_points = TRUE);
4148  }
4149 
4156  {
4157  if (count($_POST))
4158  {
4159  $_SESSION["show_user_results"] = $_POST["chbUser"];
4160  }
4161  $this->showUserResults($show_pass_details = FALSE, $show_answers = TRUE);
4162  }
4163 
4170  {
4171  if (count($_POST))
4172  {
4173  $_SESSION["show_user_results"] = $_POST["chbUser"];
4174  }
4175  $this->showUserResults($show_pass_details = TRUE, $show_answers = FALSE);
4176  }
4177 
4183  function showUserResults($show_pass_details, $show_answers, $show_reached_points = FALSE)
4184  {
4185  $template = new ilTemplate("tpl.il_as_tst_participants_result_output.html", TRUE, TRUE, "Modules/Test");
4186 
4187  if (count($_SESSION["show_user_results"]) == 0)
4188  {
4189  ilUtil::sendInfo($this->lng->txt("select_one_user"), TRUE);
4190  $this->ctrl->redirect($this, "participants");
4191  }
4192 
4193  include_once "./Modules/Test/classes/class.ilTestServiceGUI.php";
4194  $serviceGUI =& new ilTestServiceGUI($this->object);
4195  $count = 0;
4196  foreach ($_SESSION["show_user_results"] as $key => $active_id)
4197  {
4198  $count++;
4199  $results = "";
4200  if ($this->object->getFixedParticipants())
4201  {
4202  $active_id = $this->object->getActiveIdOfUser($active_id);
4203  }
4204  if ($active_id > 0)
4205  {
4206  $results = $serviceGUI->getResultsOfUserOutput($active_id, $this->object->_getResultPass($active_id), $show_pass_details, $show_answers, FALSE, $show_reached_points);
4207  }
4208  if ($count < count($_SESSION["show_user_results"]))
4209  {
4210  $template->touchBlock("break");
4211  }
4212  $template->setCurrentBlock("user_result");
4213  $template->setVariable("USER_RESULT", $results);
4214  $template->parseCurrentBlock();
4215  }
4216  $template->setVariable("BACK_TEXT", $this->lng->txt("back"));
4217  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "participants"));
4218  $template->setVariable("PRINT_TEXT", $this->lng->txt("print"));
4219  $template->setVariable("PRINT_URL", "javascript:window.print();");
4220 
4221  $this->tpl->setVariable("ADM_CONTENT", $template->get());
4222  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
4223  if ($this->object->getShowSolutionAnswersOnly())
4224  {
4225  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
4226  }
4227  }
4228 
4230  {
4231  if (is_array($_POST["chbUser"]))
4232  {
4233  foreach ($_POST["chbUser"] as $user_id)
4234  {
4235  $this->object->disinviteUser($user_id);
4236  }
4237  }
4238  else
4239  {
4240  ilUtil::sendInfo($this->lng->txt("select_one_user"), true);
4241  }
4242  $this->ctrl->redirect($this, "participants");
4243  }
4244 
4246  {
4247  if (is_array($_POST["chbUser"]))
4248  {
4249  foreach ($_POST["chbUser"] as $user_id)
4250  {
4251  $this->object->setClientIP($user_id, $_POST["clientip_".$user_id]);
4252  }
4253  }
4254  else
4255  {
4256  ilUtil::sendInfo($this->lng->txt("select_one_user"), true);
4257  }
4258  $this->ctrl->redirect($this, "participants");
4259  }
4260 
4268  function printobject()
4269  {
4270  global $ilAccess, $ilias;
4271  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
4272  {
4273  // allow only write access
4274  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
4275  $this->ctrl->redirect($this, "infoScreen");
4276  }
4277  $this->getQuestionsSubTabs();
4278  $template = new ilTemplate("tpl.il_as_tst_print_test_confirm.html", TRUE, TRUE, "Modules/Test");
4279 
4280  include_once './Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
4281  if(ilRPCServerSettings::getInstance()->isEnabled())
4282  {
4283  $this->ctrl->setParameter($this, "pdf", "1");
4284  $template->setCurrentBlock("pdf_export");
4285  $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "print"));
4286  $this->ctrl->setParameter($this, "pdf", "");
4287  $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
4288  $template->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export"));
4289  $template->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")));
4290  $template->parseCurrentBlock();
4291  }
4292 
4293  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
4294 
4295  global $ilUser;
4296  $print_date = mktime(date("H"), date("i"), date("s"), date("m") , date("d"), date("Y"));
4297  $max_points= 0;
4298  $counter = 1;
4299 
4300  foreach ($this->object->questions as $question)
4301  {
4302  $template->setCurrentBlock("question");
4303  $question_gui = $this->object->createQuestionGUI("", $question);
4304  $template->setVariable("COUNTER_QUESTION", $counter.".");
4305  $template->setVariable("QUESTION_TITLE", ilUtil::prepareFormOutput($question_gui->object->getTitle()));
4306  if ($question_gui->object->getMaximumPoints() == 1)
4307  {
4308  $template->setVariable("QUESTION_POINTS", $question_gui->object->getMaximumPoints() . " " . $this->lng->txt("point"));
4309  }
4310  else
4311  {
4312  $template->setVariable("QUESTION_POINTS", $question_gui->object->getMaximumPoints() . " " . $this->lng->txt("points"));
4313  }
4314  $result_output = $question_gui->getSolutionOutput("", NULL, FALSE, TRUE, FALSE, $this->object->getShowSolutionFeedback());
4315  if (strlen($result_output) == 0) $result_output = $question_gui->getPreview(FALSE);
4316  $template->setVariable("SOLUTION_OUTPUT", $result_output);
4317  $template->parseCurrentBlock("question");
4318  $counter ++;
4319  $max_points += $question_gui->object->getMaximumPoints();
4320  }
4321 
4322  $template->setCurrentBlock("navigation_buttons");
4323  $template->setVariable("BUTTON_PRINT", $this->lng->txt("print"));
4324  $template->parseCurrentBlock();
4325 
4326  $template->setVariable("TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
4327  $template->setVariable("PRINT_TEST", ilUtil::prepareFormOutput($this->lng->txt("tst_print")));
4328  $template->setVariable("TXT_PRINT_DATE", ilUtil::prepareFormOutput($this->lng->txt("date")));
4329  $template->setVariable("VALUE_PRINT_DATE", ilUtil::prepareFormOutput(strftime("%c",$print_date)));
4330  $template->setVariable("TXT_MAXIMUM_POINTS", ilUtil::prepareFormOutput($this->lng->txt("tst_maximum_points")));
4331  $template->setVariable("VALUE_MAXIMUM_POINTS", ilUtil::prepareFormOutput($max_points));
4332 
4333  if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1))
4334  {
4335  $this->object->deliverPDFfromHTML($template->get(), $this->object->getTitle());
4336  }
4337  else
4338  {
4339  $this->tpl->setVariable("PRINT_CONTENT", $template->get());
4340  }
4341  }
4342 
4343  function addParticipantsObject($a_user_ids = array())
4344  {
4345  $countusers = 0;
4346  // add users
4347  if (is_array($a_user_ids))
4348  {
4349  $i = 0;
4350  foreach ($a_user_ids as $user_id)
4351  {
4352  $client_ip = $_POST["client_ip"][$i];
4353  $this->object->inviteUser($user_id, $client_ip);
4354  $countusers++;
4355  $i++;
4356  }
4357  }
4358  $message = "";
4359  if ($countusers)
4360  {
4361  $message = $this->lng->txt("tst_invited_selected_users");
4362  }
4363  if (strlen($message))
4364  {
4365  ilUtil::sendInfo($message, TRUE);
4366  }
4367  else
4368  {
4369  ilUtil::sendInfo($this->lng->txt("tst_invited_nobody"), TRUE);
4370  return false;
4371  }
4372 
4373  $this->ctrl->redirect($this, "participants");
4374  }
4375 
4381  function defaultsObject()
4382  {
4383  global $ilUser;
4384  global $ilAccess;
4385 
4386  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
4387  {
4388  // allow only write access
4389  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
4390  $this->ctrl->redirect($this, "infoScreen");
4391  }
4392 
4393  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_defaults.html", "Modules/Test");
4394 
4395  $maxentries = $ilUser->getPref("hits_per_page");
4396  if ($maxentries < 1)
4397  {
4398  $maxentries = 9999;
4399  }
4400 
4401  $offset = $_GET["offset"] ? $_GET["offset"] : 0;
4402  $sortby = $_GET["sort_by"] ? $_GET["sort_by"] : "name";
4403  $sortorder = $_GET["sort_order"] ? $_GET["sort_order"] : "asc";
4404 
4405  $defaults =& $this->object->getAvailableDefaults($sortby, $sortorder);
4406  if (count($defaults) > 0)
4407  {
4408  $tablerows = array();
4409  foreach ($defaults as $row)
4410  {
4411  array_push($tablerows, array("checkbox" => "<input type=\"checkbox\" name=\"chb_defaults[]\" value=\"" . $row["test_defaults_id"] . "\"/>", "name" => $row["name"]));
4412  }
4413  $headervars = array("", "name");
4414 
4415  include_once "./Services/Table/classes/class.ilTableGUI.php";
4416  $tbl = new ilTableGUI(0, FALSE);
4417  $tbl->setTitle($this->lng->txt("tst_defaults_available"));
4418  $header_names = array(
4419  "",
4420  $this->lng->txt("title")
4421  );
4422  $tbl->setHeaderNames($header_names);
4423 
4424  $tbl->disable("sort");
4425  $tbl->disable("auto_sort");
4426  $tbl->enable("title");
4427  $tbl->enable("action");
4428  $tbl->enable("select_all");
4429  $tbl->setLimit($maxentries);
4430  $tbl->setOffset($offset);
4431  $tbl->setData($tablerows);
4432  $tbl->setMaxCount(count($tablerows));
4433  $tbl->setOrderDirection($sortorder);
4434  $tbl->setSelectAllCheckbox("chb_defaults");
4435  $tbl->setFormName("formDefaults");
4436  $tbl->addActionButton("deleteDefaults", $this->lng->txt("delete"));
4437  $tbl->addActionButton("applyDefaults", $this->lng->txt("apply"));
4438 
4439  $header_params = $this->ctrl->getParameterArray($this, "defaults");
4440  $tbl->setHeaderVars($headervars, $header_params);
4441 
4442  // footer
4443  $tbl->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
4444  // render table
4445  $tableoutput = $tbl->render();
4446  $this->tpl->setVariable("TEST_DEFAULTS_TABLE", $tableoutput);
4447  }
4448  else
4449  {
4450  $this->tpl->setVariable("TEST_DEFAULTS_TABLE", $this->lng->txt("tst_defaults_not_defined"));
4451  }
4452  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "addDefaults"));
4453  $this->tpl->setVariable("BUTTON_ADD", $this->lng->txt("add"));
4454  $this->tpl->setVariable("TEXT_DEFAULTS_OF_TEST", $this->lng->txt("tst_defaults_defaults_of_test"));
4455  }
4456 
4461  {
4462  if (count($_POST["chb_defaults"]))
4463  {
4464  foreach ($_POST["chb_defaults"] as $test_default_id)
4465  {
4466  $this->object->deleteDefaults($test_default_id);
4467  }
4468  }
4469  $this->defaultsObject();
4470  }
4471 
4472  private function confirmedApplyDefaultsObject()
4473  {
4474  return $this->applyDefaultsObject(true);
4475  }
4476 
4480  function applyDefaultsObject($confirmed = false)
4481  {
4482  if( count($_POST["chb_defaults"]) != 1 )
4483  {
4485  $this->lng->txt("tst_defaults_apply_select_one")
4486  );
4487 
4488  return $this->defaultsObject();
4489  }
4490 
4491  // do not apply if user datasets exist
4492  if($this->object->evalTotalPersons() > 0)
4493  {
4495  $this->lng->txt("tst_defaults_apply_not_possible")
4496  );
4497 
4498  return $this->defaultsObject();
4499  }
4500 
4501  $defaults =& $this->object->getTestDefaults($_POST["chb_defaults"][0]);
4502  $defaultSettings = unserialize($defaults["defaults"]);
4503 
4504  $randomTestSettingSwitched = $this->isRandomTestSettingSwitched(
4505  $defaultSettings["isRandomTest"]
4506  );
4507 
4508  switch( true )
4509  {
4510  case !$randomTestSettingSwitched:
4511  case $this->object->getQuestionCount() == 0:
4512  case $confirmed:
4513 
4514  break;
4515 
4516  default:
4517 
4518  if( !$defaultSettings["isRandomTest"] ) //&& $this->object->areRandomTestQuestionpoolsConfigured() )
4519  {
4520  // user tries to change from a random test with existing random question pools to a non random test
4521  $this->confirmChangeProperties(self::SWITCH_RANDOM_TEST_SETTING_TO_DISABLED, 'confirmedApplyDefaults', 'defaults');
4522  return;
4523  }
4524  elseif( $defaultSettings["isRandomTest"] ) //&& $this->object->doesNonRandomTestQuestionsExist() )
4525  {
4526  // user tries to change from a non random test with existing questions to a random test
4527  $this->confirmChangeProperties(self::SWITCH_RANDOM_TEST_SETTING_TO_ENABLED, 'confirmedApplyDefaults', 'defaults');
4528  return;
4529  }
4530  }
4531 
4532  if( $randomTestSettingSwitched && $this->object->isOnline() )
4533  {
4534  $this->object->setOnline(false);
4535 
4536  $info = $this->lng->txt(
4537  "tst_set_offline_due_to_switched_random_test_setting"
4538  );
4539 
4540  ilUtil::sendInfo($info, true);
4541  }
4542 
4543  $this->object->applyDefaults($defaults);
4544 
4545  ilUtil::sendSuccess($this->lng->txt("tst_defaults_applied"), true);
4546 
4547  if($randomTestSettingSwitched)
4548  {
4549  if($this->object->isRandomTest())
4550  {
4551  $this->object->removeNonRandomTestData();
4552  }
4553  else
4554  {
4555  $this->object->removeRandomTestData();
4556  }
4557  }
4558 
4559  $this->ctrl->redirect($this, 'defaults');
4560  }
4561 
4566  {
4567  if (strlen($_POST["name"]) > 0)
4568  {
4569  $this->object->addDefaults($_POST['name']);
4570  }
4571  else
4572  {
4573  ilUtil::sendInfo($this->lng->txt("tst_defaults_enter_name"));
4574  }
4575  $this->defaultsObject();
4576  }
4577 
4583  function infoScreenObject()
4584  {
4585  $this->ctrl->setCmd("showSummary");
4586  $this->ctrl->setCmdClass("ilinfoscreengui");
4587  $this->infoScreen();
4588  }
4589 
4591  {
4592  $this->ctrl->setCmd("showSummary");
4593  $this->ctrl->setCmdClass("ilinfoscreengui");
4594  $this->infoScreen($_SESSION["lock"]);
4595  }
4596 
4600  function infoScreen($session_lock = "")
4601  {
4602  global $ilAccess;
4603  global $ilUser;
4604 
4605  // Disabled
4606  if ($_GET['crs_show_result'])
4607  {
4608  $this->object->hideCorrectAnsweredQuestions();
4609  }
4610  else
4611  {
4612  if ($this->object->getTestSequence()->hasHiddenQuestions())
4613  {
4614  $this->object->getTestSequence()->clearHiddenQuestions();
4615  $this->object->getTestSequence()->saveToDb();
4616  }
4617  }
4618 
4619  if ($_GET['createRandomSolutions'])
4620  {
4621  $this->object->createRandomSolutions($_GET['createRandomSolutions']);
4622  }
4623 
4624  if (!$ilAccess->checkAccess("visible", "", $this->ref_id))
4625  {
4626  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
4627  }
4628 
4629  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
4630  $info = new ilInfoScreenGUI($this);
4631 
4632  $seq = $this->object->getTestSession()->getLastSequence();
4633 
4634  include_once "./Modules/Test/classes/class.ilTestOutputGUI.php";
4635  $output_gui =& new ilTestOutputGUI($this->object);
4636  $this->ctrl->setParameter($output_gui, "sequence", $seq);
4637  $info->setFormAction($this->ctrl->getFormAction($output_gui));
4638  if (strlen($session_lock))
4639  {
4640  $info->addHiddenElement("lock", $session_lock);
4641  }
4642  else
4643  {
4644  $info->addHiddenElement("lock", md5($_COOKIE['PHPSESSID'] . time()));
4645  }
4646  $online_access = false;
4647  if ($this->object->getFixedParticipants())
4648  {
4649  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
4650  $online_access_result = ilObjTestAccess::_lookupOnlineTestAccess($this->object->getId(), $ilUser->getId());
4651  if ($online_access_result === true)
4652  {
4653  $online_access = true;
4654  }
4655  else
4656  {
4657  ilUtil::sendInfo($online_access_result);
4658  }
4659  }
4660  if( $this->object->isOnline() && $this->object->isComplete() )
4661  {
4662  if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id))
4663  {
4664  $executable = $this->object->isExecutable($ilUser->getId(), $allowPassIncrease = TRUE);
4665  if ($executable["executable"])
4666  {
4667  if( $this->object->areObligationsEnabled() && $this->object->hasObligations($this->object->getTestId()) )
4668  {
4669  ilUtil::sendInfo($GLOBALS['lng']->txt('tst_test_contains_obligatory_questions'));
4670  }
4671 
4672  if ($this->object->getTestSession()->getActiveId() > 0)
4673  {
4674  // resume test
4675  $resume_text = $this->lng->txt("tst_resume_test");
4676  if (($seq < 1) || ($seq == $this->object->getTestSequence()->getFirstSequence()))
4677  {
4678  $resume_text = $this->object->getStartTestLabel($this->object->getTestSession()->getActiveId());
4679  }
4680  // Disabled
4681  #if(!$_GET['crs_show_result'] or $this->object->getTestSequence()->getFirstSequence())
4682  {
4683  //$info->addFormButton("resume", $resume_text);
4684  $big_button[] = array('resume', $resume_text);
4685  }
4686  }
4687  else
4688  {
4689  // start new test
4690  //$info->addFormButton("start", $this->object->getStartTestLabel($this->object->getTestSession()->getActiveId()));
4691  $big_button[] = array("start", $this->object->getStartTestLabel($this->object->getTestSession()->getActiveId()));
4692  }
4693  }
4694  else
4695  {
4696  ilUtil::sendInfo($executable["errormessage"]);
4697  }
4698  if ($this->object->getTestSession()->getActiveId() > 0)
4699  {
4700  // test results button
4701  if ($this->object->canShowTestResults($ilUser->getId()))
4702  {
4703  //$info->addFormButton("outUserResultsOverview", $this->lng->txt("tst_show_results"));
4704  $big_button[] = array("outUserResultsOverview", $this->lng->txt("tst_show_results"));
4705  if ($this->object->getHighscoreEnabled())
4706  {
4707  // Can also compare results then
4708  $big_button[] = array("outResultsToplist", $this->lng->txt("tst_show_toplist"));
4709  }
4710  }
4711  }
4712  }
4713  if ($this->object->getTestSession()->getActiveId() > 0)
4714  {
4715  if ($this->object->canShowSolutionPrintview($ilUser->getId()))
4716  {
4717  //$info->addFormButton("outUserListOfAnswerPasses", $this->lng->txt("tst_list_of_answers_show"));
4718  $big_button[] = array("outUserListOfAnswerPasses", $this->lng->txt("tst_list_of_answers_show"));
4719  }
4720  }
4721  }
4722 
4723  if( !$this->object->isOnline() )
4724  {
4725  $message = $this->lng->txt("test_is_offline");
4726 
4727  if($ilAccess->checkAccess("write", "", $this->ref_id))
4728  {
4729  $message .= "<br /><a href=\"".$this->ctrl->getLinkTarget($this, "properties")."\">".
4730  $this->lng->txt("test_edit_settings")."</a>";
4731  }
4732 
4733  ilUtil::sendInfo($message);
4734  }
4735 
4736  if ($this->object->getShowInfo())
4737  {
4738  $info->enablePrivateNotes();
4739  }
4740  /*
4741  if (strlen($this->object->getIntroduction()))
4742  {
4743  $info->addSection($this->lng->txt("tst_introduction"));
4744  $info->addProperty("", $this->object->prepareTextareaOutput($this->object->getIntroduction()));
4745  }
4746  * */
4747  if($big_button)
4748  {
4749  $out = '<div class="il_ButtonGroup il_BigButton">';
4750  foreach($big_button as $button) {
4751  $out .= '<input type="submit" class="submit il_BigButton" name="cmd['.$button[0].']" value="'.
4752  $button[1].'" />';
4753  }
4754  $out .= '</div>';
4755  $big_button = $out;
4756  }
4757 
4758  if (strlen($this->object->getIntroduction()))
4759  {
4760  $introduction = $this->object->getIntroduction();
4761  $info->addSection($this->lng->txt("tst_introduction"));
4762  $info->addProperty("", $this->object->prepareTextareaOutput($this->object->getIntroduction()).
4763  $big_button."<br />".$info->getHiddenToggleButton());
4764  }
4765  else
4766  {
4767  $info->addSection("");
4768  $info->addProperty("", $big_button.$info->getHiddenToggleButton());
4769  }
4770 
4771 
4772 
4773  $info->addSection($this->lng->txt("tst_general_properties"));
4774  if ($this->object->getShowInfo())
4775  {
4776  $info->addProperty($this->lng->txt("author"), $this->object->getAuthor());
4777  $info->addProperty($this->lng->txt("title"), $this->object->getTitle());
4778  }
4779  if( $this->object->isOnline() && $this->object->isComplete() )
4780  {
4781  if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id))
4782  {
4783  if ($this->object->getShowInfo() || !$this->object->getForceJS())
4784  {
4785  // use javascript
4786  $checked_javascript = false;
4787  if ($this->object->getJavaScriptOutput())
4788  {
4789  $checked_javascript = true;
4790  }
4791  if ($this->object->getForceJS())
4792  {
4793  $info->addProperty($this->lng->txt("tst_test_output"), $this->lng->txt("tst_use_javascript"));
4794  }
4795  else
4796  {
4797  $info->addPropertyCheckbox($this->lng->txt("tst_test_output"), "chb_javascript", 1, $this->lng->txt("tst_use_javascript"), $checked_javascript);
4798  }
4799  }
4800  // hide previous results
4801  if( !$this->object->isRandomTest() )
4802  {
4803  if ($this->object->getNrOfTries() != 1)
4804  {
4805  if ($this->object->getUsePreviousAnswers() == 0)
4806  {
4807  if ($this->object->getShowInfo())
4808  {
4809  $info->addProperty($this->lng->txt("tst_use_previous_answers"), $this->lng->txt("tst_dont_use_previous_answers"));
4810  }
4811  }
4812  else
4813  {
4814  $use_previous_answers = FALSE;
4815  if ($ilUser->prefs["tst_use_previous_answers"])
4816  {
4817  $checked_previous_answers = TRUE;
4818  }
4819  $info->addPropertyCheckbox($this->lng->txt("tst_use_previous_answers"), "chb_use_previous_answers", 1, $this->lng->txt("tst_use_previous_answers_user"), $checked_previous_answers);
4820  }
4821  }
4822  }
4823  if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
4824  {
4825  $info->addPropertyTextinput($this->lng->txt("enter_anonymous_code"), "anonymous_id", "", 8, "setAnonymousId", $this->lng->txt("submit"));
4826  }
4827  }
4828  }
4829 
4830  $info->hideFurtherSections(false);
4831 
4832  if ($this->object->getShowInfo())
4833  {
4834  $info->addSection($this->lng->txt("tst_sequence_properties"));
4835  $info->addProperty($this->lng->txt("tst_sequence"), $this->lng->txt(($this->object->getSequenceSettings() == TEST_FIXED_SEQUENCE)? "tst_sequence_fixed":"tst_sequence_postpone"));
4836 
4837  $info->addSection($this->lng->txt("tst_heading_scoring"));
4838  $info->addProperty($this->lng->txt("tst_text_count_system"), $this->lng->txt(($this->object->getCountSystem() == COUNT_PARTIAL_SOLUTIONS)? "tst_count_partial_solutions":"tst_count_correct_solutions"));
4839  $info->addProperty($this->lng->txt("tst_score_mcmr_questions"), $this->lng->txt(($this->object->getMCScoring() == SCORE_ZERO_POINTS_WHEN_UNANSWERED)? "tst_score_mcmr_zero_points_when_unanswered":"tst_score_mcmr_use_scoring_system"));
4840  if ($this->object->isRandomTest())
4841  {
4842  $info->addProperty($this->lng->txt("tst_pass_scoring"), $this->lng->txt(($this->object->getPassScoring() == SCORE_BEST_PASS)? "tst_pass_best_pass":"tst_pass_last_pass"));
4843  }
4844 
4845  $info->addSection($this->lng->txt("tst_score_reporting"));
4846  $score_reporting_text = "";
4847  switch ($this->object->getScoreReporting())
4848  {
4849  case REPORT_AFTER_TEST:
4850  $score_reporting_text = $this->lng->txt("tst_report_after_test");
4851  break;
4852  case REPORT_ALWAYS:
4853  $score_reporting_text = $this->lng->txt("tst_report_after_first_question");
4854  break;
4855  case REPORT_AFTER_DATE:
4856  $score_reporting_text = $this->lng->txt("tst_report_after_date");
4857  break;
4858  case 4:
4859  $score_reporting_text = $this->lng->txt("tst_report_never");
4860  break;
4861  }
4862  $info->addProperty($this->lng->txt("tst_score_reporting"), $score_reporting_text);
4863  $reporting_date = $this->object->getReportingDate();
4864  if ($reporting_date)
4865  {
4866  #preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $reporting_date, $matches);
4867  #$txt_reporting_date = date($this->lng->text["lang_dateformat"] . " " . $this->lng->text["lang_timeformat"], mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]));
4868  #$info->addProperty($this->lng->txt("tst_score_reporting_date"), $txt_reporting_date);
4869  $info->addProperty($this->lng->txt('tst_score_reporting_date'),
4871  }
4872 
4873  $info->addSection($this->lng->txt("tst_session_settings"));
4874  $info->addProperty($this->lng->txt("tst_nr_of_tries"), ($this->object->getNrOfTries() == 0)?$this->lng->txt("unlimited"):$this->object->getNrOfTries());
4875  if ($this->object->getNrOfTries() != 1)
4876  {
4877  $info->addProperty($this->lng->txt("tst_nr_of_tries_of_user"), ($this->object->getTestSession()->getPass() == false)?$this->lng->txt("tst_no_tries"):$this->object->getTestSession()->getPass());
4878  }
4879 
4880  if ($this->object->getEnableProcessingTime())
4881  {
4882  $info->addProperty($this->lng->txt("tst_processing_time"), $this->object->getProcessingTime());
4883  }
4884  if (strlen($this->object->getAllowedUsers()) && ($this->object->getAllowedUsersTimeGap()))
4885  {
4886  $info->addProperty($this->lng->txt("tst_allowed_users"), $this->object->getAllowedUsers());
4887  }
4888 
4889  $starting_time = $this->object->getStartingTime();
4890  if ($starting_time)
4891  {
4892  $info->addProperty($this->lng->txt("tst_starting_time"),
4894  }
4895  $ending_time = $this->object->getEndingTime();
4896  if ($ending_time)
4897  {
4898  $info->addProperty($this->lng->txt("tst_ending_time"),
4900  }
4901  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
4902  // forward the command
4903 
4904  if($_GET['crs_show_result'] and !$this->object->getTestSequence()->getFirstSequence())
4905  {
4906  #ilUtil::sendInfo($this->lng->txt('crs_all_questions_answered_successfully'));
4907  }
4908  }
4909 
4910  $this->ctrl->forwardCommand($info);
4911  }
4912 
4913  function addLocatorItems()
4914  {
4915  global $ilLocator;
4916  switch ($this->ctrl->getCmd())
4917  {
4918  case "run":
4919  case "infoScreen":
4920  case "redirectToInfoScreen":
4921  case "start":
4922  case "resume":
4923  case "previous":
4924  case "next":
4925  case "summary":
4926  case "finishTest":
4927  case "outCorrectSolution":
4928  case "passDetails":
4929  case "showAnswersOfUser":
4930  case "outUserResultsOverview":
4931  case "backFromSummary":
4932  case "show_answers":
4933  case "setsolved":
4934  case "resetsolved":
4935  case "outTestSummary":
4936  case "outQuestionSummary":
4937  case "gotoQuestion":
4938  case "selectImagemapRegion":
4939  case "confirmSubmitAnswers":
4940  case "finalSubmission":
4941  case "postpone":
4942  case "redirectQuestion":
4943  case "outUserPassDetails":
4944  case "checkPassword":
4945  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"), "", $_GET["ref_id"]);
4946  break;
4947  case "eval_stat":
4948  case "evalAllUsers":
4949  case "evalUserDetail":
4950  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "eval_stat"), "", $_GET["ref_id"]);
4951  break;
4952  case "create":
4953  case "save":
4954  case "cancel":
4955  case "importFile":
4956  case "cloneAll":
4957  case "importVerifiedFile":
4958  case "cancelImport":
4959  break;
4960  default:
4961  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
4962  break;
4963  }
4964  }
4965 
4966  function getBrowseForQuestionsTab(&$tabs_gui)
4967  {
4968  global $ilAccess;
4969  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4970  {
4971  $this->ctrl->saveParameterByClass($this->ctrl->getCmdClass(), 'q_id');
4972  // edit page
4973  $tabs_gui->setBackTarget($this->lng->txt("backtocallingtest"), $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), "questions"));
4974  $tabs_gui->addTarget("tst_browse_for_questions",
4975  $this->ctrl->getLinkTarget($this, "browseForQuestions"),
4976  array("browseForQuestions", "filter", "resetFilter", "resetTextFilter", "insertQuestions"),
4977  "", "", TRUE
4978  );
4979  }
4980  }
4981 
4982  function getRandomQuestionsTab(&$tabs_gui)
4983  {
4984  global $ilAccess;
4985  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4986  {
4987  // edit page
4988  $tabs_gui->setBackTarget($this->lng->txt("backtocallingtest"), $this->ctrl->getLinkTarget($this, "questions"));
4989  $tabs_gui->addTarget("random_selection",
4990  $this->ctrl->getLinkTarget($this, "randomQuestions"),
4991  array("randomQuestions"),
4992  "", ""
4993  );
4994  }
4995  }
4996 
4997  function statisticsObject()
4998  {
4999  }
5000 
5005  {
5006  include_once "./Services/Certificate/classes/class.ilCertificateGUI.php";
5007  include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
5008  $output_gui = new ilCertificateGUI(new ilTestCertificateAdapter($this->object));
5009  $output_gui->certificateEditor();
5010  }
5011 
5013  {
5014  global $ilTabs, $ilCtrl;
5015  $ilTabs->activateTab('assQuestions');
5016  $a_cmd = $ilCtrl->getCmd();
5017 
5018  if (!$this->object->isRandomTest())
5019  {
5020  #if (in_array($this->object->getEnabledViewMode(), array('both', 'express'))) {
5021  $questions_per_page = ($a_cmd == 'questions_per_page' || ($a_cmd == 'removeQuestions' && $_REQUEST['test_express_mode'])) ? true : false;
5022 
5023  $this->tabs_gui->addSubTabTarget(
5024  "questions_per_page_view",
5025  $this->ctrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'showPage'),
5026  "", "", "", $questions_per_page);
5027  #}
5028  }
5029  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
5030  $template = new ilSettingsTemplate($this->object->getTemplate(), ilObjAssessmentFolderGUI::getSettingsTemplateConfig());
5031 
5032  if (!in_array('questions', $template->getHiddenTabs())) {
5033  // questions subtab
5034  $ilTabs->addSubTabTarget("edit_test_questions",
5035  $this->ctrl->getLinkTarget($this,'questions'),
5036  array("questions", "browseForQuestions", "questionBrowser", "createQuestion",
5037  "randomselect", "filter", "resetFilter", "insertQuestions",
5038  "back", "createRandomSelection", "cancelRandomSelect",
5039  "insertRandomSelection", "removeQuestions", "moveQuestions",
5040  "insertQuestionsBefore", "insertQuestionsAfter", "confirmRemoveQuestions",
5041  "cancelRemoveQuestions", "executeCreateQuestion", "cancelCreateQuestion",
5042  "addQuestionpool", "saveRandomQuestions", "saveQuestionSelectionMode"),
5043  "");
5044 
5045  if (in_array($a_cmd, array('questions', 'createQuestion')) || ($a_cmd == 'removeQuestions' && !$_REQUEST['test_express_mode']))
5046  $this->tabs_gui->activateSubTab('edit_test_questions');
5047  }
5048  #}
5049 
5050  // print view subtab
5051  if (!$this->object->isRandomTest())
5052  {
5053  $ilTabs->addSubTabTarget("print_view",
5054  $this->ctrl->getLinkTarget($this,'print'),
5055  "print", "", "", $this->ctrl->getCmd() == 'print');
5056  }
5057 
5058  }
5059 
5061  {
5062  global $ilTabs;
5063 
5064  // user results subtab
5065  $ilTabs->addSubTabTarget("eval_all_users",
5066  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "outEvaluation"),
5067  array("outEvaluation", "detailedEvaluation", "exportEvaluation", "evalUserDetail", "passDetails",
5068  "outStatisticsResultsOverview", "statisticsPassDetails")
5069  , "");
5070 
5071  // aggregated results subtab
5072  $ilTabs->addSubTabTarget("tst_results_aggregated",
5073  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "eval_a"),
5074  array("eval_a"),
5075  "", "");
5076 
5077  // question export
5078  $ilTabs->addSubTabTarget("tst_single_results",
5079  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "singleResults"),
5080  array("singleResults"),
5081  "", "");
5082  }
5083 
5084  function getSettingsSubTabs($hiddenTabs = array())
5085  {
5086  global $ilTabs, $ilias;
5087 
5088  // general subtab
5089  $force_active = ($this->ctrl->getCmd() == "")
5090  ? true
5091  : false;
5092  $ilTabs->addSubTabTarget("general",
5093  $this->ctrl->getLinkTarget($this,'properties'),
5094  array("properties", "saveProperties", "cancelProperties"),
5095  array("", "ilobjtestgui", "ilcertificategui"),
5096  "", $force_active);
5097 
5098  if (!in_array('mark_schema', $hiddenTabs)) {
5099  // mark schema subtab
5100  $ilTabs->addSubTabTarget(
5101  "mark_schema",
5102  $this->ctrl->getLinkTarget($this,'marks'),
5103  array("marks", "addMarkStep", "deleteMarkSteps", "addSimpleMarkSchema",
5104  "saveMarks", "cancelMarks"),
5105  array("", "ilobjtestgui", "ilcertificategui")
5106  );
5107  }
5108 
5109  // scoring subtab
5110  $ilTabs->addSubTabTarget(
5111  "scoring",
5112  $this->ctrl->getLinkTarget($this,'scoring'),
5113  array("scoring"),
5114  array("", "ilobjtestgui", "ilcertificategui")
5115  );
5116 
5117  // certificate subtab
5118  include_once "Services/Certificate/classes/class.ilCertificate.php";
5120  {
5121  $ilTabs->addSubTabTarget(
5122  "certificate",
5123  $this->ctrl->getLinkTarget($this,'certificate'),
5124  array("certificate", "certificateEditor", "certificateRemoveBackground", "certificateSave",
5125  "certificatePreview", "certificateDelete", "certificateUpload", "certificateImport"),
5126  array("", "ilobjtestgui", "ilcertificategui")
5127  );
5128  }
5129 
5130  if (!in_array('defaults', $hiddenTabs)) {
5131  // defaults subtab
5132  $ilTabs->addSubTabTarget(
5133  "tst_default_settings",
5134  $this->ctrl->getLinkTarget($this, "defaults"),
5135  array("defaults", "deleteDefaults", "addDefaults", "applyDefaults"),
5136  array("", "ilobjtestgui", "ilcertificategui")
5137  );
5138  }
5139  }
5140 
5146  function getTabs(&$tabs_gui)
5147  {
5148  global $ilAccess,$ilUser, $ilHelp;
5149 
5150  if (preg_match('/^ass(.*?)gui$/i', $this->ctrl->getNextClass($this))) {
5151  return;
5152  }
5153  else if ($this->ctrl->getNextClass($this) == 'ilpageobjectgui') {
5154  return;
5155  }
5156 
5157  $ilHelp->setScreenIdComponent("tst");
5158 
5159  $hidden_tabs = array();
5160 
5161  $template = $this->object->getTemplate();
5162  if($template)
5163  {
5164  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
5166 
5167  $hidden_tabs = $template->getHiddenTabs();
5168  }
5169 
5170  if( $this->ctrl->getNextClass($this) == 'iltestoutputgui')
5171  {
5172  return;
5173  }
5174 
5175  switch ($this->ctrl->getCmd())
5176  {
5177  case "resume":
5178  case "previous":
5179  case "next":
5180  case "summary":
5181  case "directfeedback":
5182  case "finishTest":
5183  case "outCorrectSolution":
5184  case "passDetails":
5185  case "showAnswersOfUser":
5186  case "outUserResultsOverview":
5187  case "backFromSummary":
5188  case "show_answers":
5189  case "setsolved":
5190  case "resetsolved":
5191  case "confirmFinish":
5192  case "outTestSummary":
5193  case "outQuestionSummary":
5194  case "gotoQuestion":
5195  case "selectImagemapRegion":
5196  case "confirmSubmitAnswers":
5197  case "finalSubmission":
5198  case "postpone":
5199  case "redirectQuestion":
5200  case "outUserPassDetails":
5201  case "checkPassword":
5202  case "exportCertificate":
5203  case "finishListOfAnswers":
5204  case "backConfirmFinish":
5205  case "showFinalStatement":
5206  return;
5207  break;
5208  case "browseForQuestions":
5209  case "filter":
5210  case "resetFilter":
5211  case "resetTextFilter":
5212  case "insertQuestions":
5213  // #8497: resetfilter is also used in lp
5214  if($this->ctrl->getNextClass($this) != "illearningprogressgui")
5215  {
5216  return $this->getBrowseForQuestionsTab($tabs_gui);
5217  }
5218  break;
5219  case "scoring":
5220  case "properties":
5221  case "marks":
5222  case "saveMarks":
5223  case "cancelMarks":
5224  case "addMarkStep":
5225  case "deleteMarkSteps":
5226  case "addSimpleMarkSchema":
5227  case "certificate":
5228  case "certificateservice":
5229  case "certificateImport":
5230  case "certificateUpload":
5231  case "certificateEditor":
5232  case "certificateDelete":
5233  case "certificateSave":
5234  case "defaults":
5235  case "deleteDefaults":
5236  case "addDefaults":
5237  case "applyDefaults":
5238  case "inviteParticipants":
5239  case "searchParticipants":
5240  case "":
5241  if (($ilAccess->checkAccess("write", "", $this->ref_id)) && ((strcmp($this->ctrl->getCmdClass(), "ilobjtestgui") == 0) || (strcmp($this->ctrl->getCmdClass(), "ilcertificategui") == 0) || (strlen($this->ctrl->getCmdClass()) == 0)))
5242  {
5243  $this->getSettingsSubTabs($hidden_tabs);
5244  }
5245  break;
5246  case "export":
5247  case "print":
5248  break;
5249  case "statistics":
5250  case "eval_a":
5251  case "detailedEvaluation":
5252  case "outEvaluation":
5253  case "singleResults":
5254  case "exportEvaluation":
5255  case "evalUserDetail":
5256  case "passDetails":
5257  case "outStatisticsResultsOverview":
5258  case "statisticsPassDetails":
5259  $this->getStatisticsSubTabs();
5260  break;
5261  }
5262 
5263  if (strcmp(strtolower(get_class($this->object)), "ilobjtest") == 0)
5264  {
5265  // questions tab
5266  if ($ilAccess->checkAccess("write", "", $this->ref_id) && !in_array('assQuestions', $hidden_tabs))
5267  {
5268  $force_active = ($_GET["up"] != "" || $_GET["down"] != "")
5269  ? true
5270  : false;
5271  if (!$force_active)
5272  {
5273  if ($_GET["browse"] == 1) $force_active = true;
5274  if (preg_match("/deleteqpl_\d+/", $this->ctrl->getCmd()))
5275  {
5276  $force_active = true;
5277  }
5278  }
5279 
5280  if ($this->object->isRandomTest()) {
5281  $target = $this->ctrl->getLinkTarget($this,'questions');
5282  }
5283  else {
5284  $target = $this->ctrl->getLinkTargetByClass('iltestexpresspageobjectgui','showPage');
5285  }
5286 
5287  $tabs_gui->addTarget("assQuestions",
5288  //$this->ctrl->getLinkTarget($this,'questions'),
5289  $target,
5290  array("questions", "browseForQuestions", "questionBrowser", "createQuestion",
5291  "randomselect", "filter", "resetFilter", "insertQuestions",
5292  "back", "createRandomSelection", "cancelRandomSelect",
5293  "insertRandomSelection", "removeQuestions", "moveQuestions",
5294  "insertQuestionsBefore", "insertQuestionsAfter", "confirmRemoveQuestions",
5295  "cancelRemoveQuestions", "executeCreateQuestion", "cancelCreateQuestion",
5296  "addQuestionpool", "saveRandomQuestions", "saveQuestionSelectionMode", "print",
5297  "addsource", "removesource", "randomQuestions"),
5298  "", "", $force_active);
5299  }
5300 
5301  // info tab
5302  if ($ilAccess->checkAccess("visible", "", $this->ref_id) && !in_array('info_short', $hidden_tabs))
5303  {
5304  $tabs_gui->addTarget("info_short",
5305  $this->ctrl->getLinkTarget($this,'infoScreen'),
5306  array("infoScreen", "outIntroductionPage", "showSummary",
5307  "setAnonymousId", "outUserListOfAnswerPasses", "redirectToInfoScreen"));
5308  }
5309 
5310  // settings tab
5311  if ($ilAccess->checkAccess("write", "", $this->ref_id))
5312  {
5313  if (!in_array('settings', $hidden_tabs)) {
5314  $tabs_gui->addTarget("settings",
5315  $this->ctrl->getLinkTarget($this,'properties'),
5316  array("properties", "saveProperties", "cancelProperties",
5317  "marks", "addMarkStep", "deleteMarkSteps", "addSimpleMarkSchema",
5318  "saveMarks", "cancelMarks",
5319  "certificate", "certificateEditor", "certificateRemoveBackground",
5320  "certificateSave", "certificatePreview", "certificateDelete", "certificateUpload",
5321  "certificateImport", "scoring", "defaults", "addDefaults", "deleteDefaults", "applyDefaults",
5322  "inviteParticipants", "saveFixedParticipantsStatus", "searchParticipants", "addParticipants",
5323  ""
5324  ),
5325  array("", "ilobjtestgui", "ilcertificategui")
5326  );
5327  }
5328 
5329  if (!in_array('participants', $hidden_tabs)) {
5330  // participants
5331  $tabs_gui->addTarget("participants",
5332  $this->ctrl->getLinkTarget($this,'participants'),
5333  array("participants", "saveClientIP",
5334  "removeParticipant",
5335  "showParticipantAnswersForAuthor",
5336  "deleteAllUserResults",
5337  "cancelDeleteAllUserData", "deleteSingleUserResults",
5338  "outParticipantsResultsOverview", "outParticipantsPassDetails",
5339  "showPassOverview", "showUserAnswers", "participantsAction",
5340  "showDetailedResults"),
5341  "");
5342  }
5343  }
5344 
5345  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
5346  if(ilLearningProgressAccess::checkAccess($this->object->getRefId()) && !in_array('learning_progress', $hidden_tabs))
5347  {
5348  $tabs_gui->addTarget('learning_progress',
5349  $this->ctrl->getLinkTargetByClass(array('illearningprogressgui'),''),
5350  '',
5351  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui'));
5352  }
5353 
5354  if ($ilAccess->checkAccess("write", "", $this->ref_id) && !in_array('manscoring', $hidden_tabs))
5355  {
5356  include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
5358  if (count($scoring))
5359  {
5360  // scoring tab
5361  $tabs_gui->addTarget(
5362  "manscoring", $this->ctrl->getLinkTargetByClass('ilTestScoringGUI', 'showManScoringParticipantsTable'),
5363  array('showManScoringParticipantsTable', 'applyManScoringParticipantsFilter', 'resetManScoringParticipantsFilter', 'showManScoringParticipantScreen'), ''
5364  );
5365  }
5366  }
5367 
5368  if ((($ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) || ($ilAccess->checkAccess("write", "", $this->ref_id))) && !in_array('statistics', $hidden_tabs))
5369  {
5370  // statistics tab
5371  $tabs_gui->addTarget("statistics",
5372  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "outEvaluation"),
5373  array("statistics", "outEvaluation", "exportEvaluation", "detailedEvaluation", "eval_a", "evalUserDetail",
5374  "passDetails", "outStatisticsResultsOverview", "statisticsPassDetails", "singleResults")
5375  , "");
5376  }
5377 
5378  if ($ilAccess->checkAccess("write", "", $this->ref_id))
5379  {
5380  if (!in_array('history', $hidden_tabs)) {
5381 
5382  // history
5383  $tabs_gui->addTarget("history",
5384  $this->ctrl->getLinkTarget($this,'history'),
5385  "history", "");
5386  }
5387 
5388  if (!in_array('meta_data', $hidden_tabs)) {
5389  // meta data
5390  $tabs_gui->addTarget("meta_data",
5391  $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'),
5392  "", "ilmdeditorgui");
5393  }
5394 
5395  if (!in_array('export', $hidden_tabs)) {
5396  // export tab
5397  $tabs_gui->addTarget("export",
5398  $this->ctrl->getLinkTarget($this,'export'),
5399  array("export", "createExportFile", "confirmDeleteExportFile",
5400  "downloadExportFile", "deleteExportFile", "cancelDeleteExportFile"),
5401  "");
5402  }
5403  }
5404 
5405  if ($ilAccess->checkAccess("edit_permission", "", $this->ref_id)&& !in_array('permissions', $hidden_tabs))
5406  {
5407  $tabs_gui->addTarget("perm_settings",
5408  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
5409  }
5410  }
5411  }
5412 
5421  function _goto($a_target)
5422  {
5423  global $ilAccess, $ilErr, $lng;
5424 
5425  if ($ilAccess->checkAccess("visible", "", $a_target))
5426  {
5427  //include_once "./Services/Utilities/classes/class.ilUtil.php";
5428  $_GET["baseClass"] = "ilObjTestGUI";
5429  $_GET["cmd"] = "infoScreen";
5430  $_GET["ref_id"] = $a_target;
5431  include_once("ilias.php");
5432  exit;
5433  //ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=infoScreen&ref_id=$a_target");
5434  }
5435  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
5436  {
5437  ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
5438  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
5440  }
5441 
5442  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
5443  }
5444 
5445 
5446 
5447 
5448 
5455  function buildPageViewToolbar($qid = 0)
5456  {
5457  if ($this->create_question_mode)
5458  return;
5459 
5460  global $ilToolbar, $ilCtrl, $lng;
5461 
5462  $this->getQuestionsSubTabs();
5463 
5464  $ilCtrl->saveParameter($this, 'q_mode');
5465 
5466  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'test_express_mode', 1);
5467  $ilCtrl->setParameter($this, 'test_express_mode', 1);
5468  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'q_id', $_REQUEST['q_id']);
5469  $ilCtrl->setParameter($this, 'q_id', $_REQUEST['q_id']);
5470  $ilToolbar->setFormAction($ilCtrl->getFormActionByClass('iltestexpresspageobjectgui', 'edit'));
5471 
5472  if ($this->object->evalTotalPersons() == 0) {
5473  /*
5474  include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
5475  $pool = new ilObjQuestionPool();
5476  $questionTypes = $pool->getQuestionTypes();$options = array();
5477  foreach($questionTypes as $label => $data) {
5478  $options[$data['question_type_id']] = $label;
5479  }
5480 
5481  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
5482  $si = new ilSelectInputGUI($lng->txt("test_add_new_question"), "qtype");
5483  $si->setOptions($options);
5484  $ilToolbar->addInputItem($si, true);
5485  /*
5486  // use pool
5487  if ($this->object->isExpressModeQuestionPoolAllowed()) {
5488  include_once("./Services/Form/classes/class.ilCheckboxInputGUI.php");
5489  $cb = new ilCheckboxInputGUI($lng->txt("test_use_pool"), "use_pool");
5490  $ilToolbar->addInputItem($cb, true);
5491  }
5492  */
5493  $ilToolbar->addFormButton($lng->txt("test_create_question"), "addQuestion");
5494 
5495  $ilToolbar->addSeparator();
5496 
5497  if ($this->object->getPoolUsage()) {
5498  $ilToolbar->addFormButton($lng->txt("tst_browse_for_questions"), "browseForQuestions");
5499 
5500  $show_separator = true;
5501  }
5502  }
5503 
5504  $questions = $this->object->getQuestionTitlesAndIndexes();
5505 
5506  // desc
5507  $options = array();
5508  foreach($questions as $id => $label) {
5509  $options[$id] = $label;
5510  }
5511 
5512  $optionKeys = array_keys($options);
5513 
5514  if (!$options) {
5515  $options[] = $lng->txt('none');
5516  }
5517  //else if (count($options) > 1) {
5518 // $addSeparator = false;
5519 // if ($optionKeys[0] != $qid) {
5520 // //$ilToolbar->addFormButton($lng->txt("test_prev_question"), "prevQuestion");
5521 // $ilToolbar->addLink($lng->txt("test_prev_question"), $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'prevQuestion'));
5522 // $addSeparator = true;
5523 // }
5524 // else {
5525 // $ilToolbar->addSpacer(45);
5526 // }
5527 //
5528 // if ($optionKeys[count($optionKeys)-1] != $qid) {
5529 // //$ilToolbar->addFormButton($lng->txt("test_next_question"), "nextQuestion");
5530 // $ilToolbar->addLink($lng->txt("test_next_question"), $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'nextQuestion'));
5531 // $addSeparator = true;
5532 // }
5533 // else {
5534 // $ilToolbar->addSpacer(45);
5535 // }
5536 //
5537 // //if ($addSeparator) {
5538 // $ilToolbar->addSeparator();
5539 // //}
5540 
5541  if (count($questions)) {
5542  if (isset($show_separator) && $show_separator) {
5543  $ilToolbar->addSeparator();
5544  }
5545 
5546  $ilToolbar->addLink($lng->txt("test_prev_question"), $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'prevQuestion'), !(count($options) > 1 && $optionKeys[0] != $qid));
5547  $ilToolbar->addLink($lng->txt("test_next_question"), $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'nextQuestion'), !(count($options) > 1 && $optionKeys[count($optionKeys)-1] != $qid));
5548  }
5549 
5550  if (count($questions) > 1) {
5551 
5552  $ilToolbar->addSeparator();
5553 
5554  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
5555  $si = new ilSelectInputGUI($lng->txt("test_jump_to"), "q_id");
5556  $si->addCustomAttribute("onChange=\"forms['ilToolbar'].submit();\"");
5557  $si->setOptions($options);
5558 
5559  if ($qid) {
5560  $si->setValue($qid);
5561  }
5562 
5563  $ilToolbar->addInputItem($si, true);
5564  }
5565 
5566  $total = $this->object->evalTotalPersons();
5567 
5568  /*if (count($options)) {
5569  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
5570  $si = new ilSelectInputGUI($lng->txt("test_jump_to"), "q_id");
5571  $si->addCustomAttribute("onChange=\"forms['ilToolbar'].submit();\"");
5572  $si->setOptions($options);
5573 
5574  if ($qid) {
5575  $si->setValue($qid);
5576  }
5577 
5578  $ilToolbar->addInputItem($si, true);
5579  }*/
5580 
5581  if (count($questions) && !$total) {
5582  $ilCtrl->setParameter($this, 'q_id', $_REQUEST['q_id']);
5583  $ilToolbar->addSeparator();
5584  $ilToolbar->addButton($lng->txt("test_delete_page"), $ilCtrl->getLinkTarget($this, "removeQuestions"));
5585  }
5586 
5587  if (count($questions) > 1 && !$total) {
5588  $ilToolbar->addSeparator();
5589  $ilToolbar->addButton($lng->txt("test_move_page"), $ilCtrl->getLinkTarget($this, "movePageForm"));
5590  }
5591 
5592  global $ilAccess, $ilUser;
5593  $seq = $this->object->getTestSession()->getLastSequence();
5594  $online_access = false;
5595  if ($this->object->getFixedParticipants())
5596  {
5597  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
5598  $online_access_result = ilObjTestAccess::_lookupOnlineTestAccess($this->object->getId(), $ilUser->getId());
5599  if ($online_access_result === true)
5600  {
5601  $online_access = true;
5602  }
5603  }
5604 
5605  if( $this->object->isOnline() && $this->object->isComplete() )
5606  {
5607  if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id))
5608  {
5609  $executable = $this->object->isExecutable($ilUser->getId(), $allowPassIncrease = TRUE);
5610  if ($executable["executable"])
5611  {
5612  if ($this->object->getTestSession()->getActiveId() > 0)
5613  {
5614  $ilToolbar->addSeparator();
5615  $ilToolbar->addButton($lng->txt('tst_resume_test'), $ilCtrl->getLinkTargetByClass('iltestoutputgui', 'resume'));
5616  }
5617  else
5618  {
5619  $ilToolbar->addSeparator();
5620  $ilToolbar->addButton($lng->txt('tst_start_test'), $ilCtrl->getLinkTargetByClass('iltestoutputgui', 'startTest'));
5621  }
5622  }
5623  }
5624  }
5625 
5626 
5627  }
5628 
5629  public function copyQuestionsToPoolObject($returnResult = false) {
5630  //var_dump($_REQUEST);
5631  include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
5632  $qpool = new ilObjQuestionPool($_REQUEST['sel_qpl'], true);
5633  $qpool->setOnline(ilObjQuestionPool::_lookupOnline($_REQUEST['sel_qpl'], true));
5634 
5635  $newIds = array();
5636  foreach($_REQUEST['q_id'] as $q_id) {
5637  $newId = $qpool->copyQuestion($q_id, $qpool->getId());
5638  $newIds[$q_id] = $newId;
5639  }
5640 
5641  $result = new stdClass();
5642  $result->ids = $newIds;
5643  $result->qpool = $qpool;
5644 
5645  if ($returnResult)
5646  return $result;
5647  else
5648  $this->backObject();
5649  }
5650 
5652  $result = $this->copyQuestionsToPoolObject(true);
5653 
5654  foreach($result->ids as $oldId => $newId) {
5655  $questionInstance = assQuestion::_instanciateQuestion($oldId);
5656  $questionInstance->setNewOriginalId($newId);
5657  $questionInstance->setObjId($result->qpool->getId());
5658  $questionInstance->saveToDb();
5659 
5660  }
5661 
5662  $this->backObject();
5663  }
5664 
5665  private function getQuestionpoolCreationForm()
5666  {
5667  global $lng;
5668  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
5669  $form = new ilPropertyFormGUI();
5670 
5671  $title = new ilTextInputGUI($lng->txt('title'), 'title');
5672  $title->setRequired(true);
5673  $form->addItem($title);
5674 
5675  $description = new ilTextAreaInputGUI($lng->txt('description'), 'description');
5676  $form->addItem($description);
5677 
5678  $form->addCommandButton('createQuestionPoolAndCopy', $lng->txt('create'));
5679 
5680  if(isset($_REQUEST['q_id']) && is_array($_REQUEST['q_id']))
5681  {
5682  foreach($_REQUEST['q_id'] as $id)
5683  {
5684  $hidden = new ilHiddenInputGUI('q_id[]');
5685  $hidden->setValue($id);
5686  $form->addItem($hidden);
5687  }
5688  }
5689 
5690  return $form;
5691  }
5692 
5693  public function copyToQuestionpoolObject()
5694  {
5695  $this->createQuestionpoolTargetObject('copyQuestionsToPool');
5696  }
5697 
5699  {
5700  global $lng;
5701 
5702  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
5703 
5704 
5705  if(isset($_REQUEST['q_id']) && is_array($_REQUEST['q_id']))
5706  {
5707  foreach($_REQUEST['q_id'] as $q_id)
5708  {
5709  $questionInstance = assQuestion::_instanciateQuestion($q_id);
5710  $type = ilObject::_lookupType($questionInstance->getObjId());
5711  if($type !== 'tst')
5712  {
5713  ilUtil::sendFailure($lng->txt('tst_link_only_unassigned'), true);
5714  $this->backObject();
5715  return;
5716  }
5717  }
5718  }
5719 
5720  $this->createQuestionpoolTargetObject('copyAndLinkQuestionsToPool');
5721  }
5722 
5724  {
5725  $form = $this->getQuestionpoolCreationForm();
5726 
5727  if($_REQUEST['title'])
5728  {
5729  $title = $_REQUEST['title'];
5730  }
5731  else
5732  {
5733  $title = $_REQUEST['txt_qpl'];
5734  }
5735 
5736  if(!$title)
5737  {
5738  ilUtil::sendInfo($this->lng->txt("questionpool_not_entered"));
5739  return $this->copyAndLinkToQuestionpoolObject();
5740  }
5741 
5742  $ref_id = $this->createQuestionPool($title, $_REQUEST['description']);
5743  $_REQUEST['sel_qpl'] = $ref_id;
5744 
5746  }
5747 
5755  {
5756  global $ilUser, $ilTabs;
5757  $this->getQuestionsSubTabs();
5758  $ilTabs->activateSubTab('edit_test_questions');
5759 
5760  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_qpl_select_copy.html", "Modules/Test");
5761  $questionpools =& $this->object->getAvailableQuestionpools(FALSE, FALSE, FALSE, TRUE, FALSE, "write");
5762  if(count($questionpools) == 0)
5763  {
5764  $this->tpl->setCurrentBlock("option");
5765  $this->tpl->setVariable("VALUE_QPL", "");
5766  $this->tpl->parseCurrentBlock();
5767  }
5768  else
5769  {
5770  foreach($questionpools as $key => $value)
5771  {
5772  $this->tpl->setCurrentBlock("option");
5773  $this->tpl->setVariable("VALUE_OPTION", $key);
5774  $this->tpl->setVariable("TEXT_OPTION", $value["title"]);
5775  $this->tpl->parseCurrentBlock();
5776  }
5777  }
5778 
5779  if(isset($_REQUEST['q_id']) && is_array($_REQUEST['q_id']))
5780  {
5781  foreach($_REQUEST['q_id'] as $id)
5782  {
5783  $this->tpl->setCurrentBlock("hidden");
5784  $this->tpl->setVariable("HIDDEN_NAME", "q_id[]");
5785  $this->tpl->setVariable("HIDDEN_VALUE", $id);
5786  $this->tpl->parseCurrentBlock();
5787  $this->tpl->setCurrentBlock("adm_content");
5788  }
5789  }
5790 
5791  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
5792 
5793  if(count($questionpools) == 0)
5794  {
5795  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_enter_questionpool"));
5796  $cmd = 'createQuestionPoolAndCopy';
5797  }
5798  else
5799  {
5800  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_select_questionpool"));
5801  }
5802 
5803  $this->tpl->setVariable("CMD_SUBMIT", $cmd);
5804  $this->tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit"));
5805  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
5806 
5807  $createForm = $this->getQuestionpoolCreationForm();
5808  switch($cmd)
5809  {
5810  case 'copyAndLinkQuestionsToPool':
5811  $hidden = new ilHiddenInputGUI('link');
5812  $hidden->setValue(1);
5813  $createForm->addItem($hidden);
5814  break;
5815  case 'copyQuestionsToPool':
5816  break;
5817  }
5818  $createForm->setFormAction($this->ctrl->getFormAction($this));
5819 
5820  $this->tpl->parseCurrentBlock();
5821  }
5822 
5823  private function applyTemplate($templateData, $object) {
5824  // map formFieldName => setterName
5825  $simpleSetters = array(
5826  'anonymity' => 'setAnonymity',
5827  'random_test' => 'setRandomTest',
5828  'use_pool' => 'setPoolUsage',
5829  'test_enabled_views' => 'setEnabledViewMode',
5830  //'express_allow_question_pool' => 'setExpressModeQuestionPoolAllowed',
5831  'introduction' => 'setIntroduction',
5832  'showinfo' => 'setShowInfo',
5833  'finalstatement' => 'setFinalStatement',
5834  'showfinalstatement' => 'setShowFinalStatement',
5835  'chb_shuffle_questions' => 'setShuffleQuestions',
5836  'list_of_questions' => 'setListOfQuestionsSettings',
5837  'chb_show_marker' => 'setShowMarker',
5838  'chb_show_cancel' => 'setShowCancel',
5839  'kiosk' => 'setKiosk',
5840  'nr_of_tries' => 'setNrOfTries',
5841  'chb_processing_time' => 'setEnableProcessingTime',
5842  'chb_use_previous_answers' => 'setUsePreviousAnswers',
5843  'forcejs' => 'setForceJS',
5844  'title_output' => 'setTitleOutput',
5845  'password' => 'setPassword',
5846  'fixedparticipants' => 'setFixedParticipants',
5847  'allowedUsers' => 'setAllowedUsers',
5848  'allowedUsersTimeGap' => 'setAllowedUsersTimeGap',
5849  'mailnotification' => 'setMailNotification',
5850  'mailnottype' => 'setMailNotificationType',
5851  //'' => '',
5852  'count_system' => 'setCountSystem',
5853  'mc_scoring' => 'setMCScoring',
5854  'score_cutting' => 'setScoreCutting',
5855  'pass_scoring' => 'setScoreReporting',
5856 
5857  'instant_feedback' => 'setScoringFeedbackOptionsByArray',
5858 
5859  'results_presentation' => 'setResultsPresentationOptionsByArray',
5860  'export_settings' => 'setExportSettings',
5861  'print_bs_with_res' => 'setPrintBestSolutionWithResult',
5862  );
5863 
5864  if (!$templateData['results_presentation']['value']) {
5865  $templateData['results_presentation']['value'] = array();
5866  }
5867 
5868  foreach($simpleSetters as $field => $setter) {
5869  if($templateData[$field]) {
5870  $object->$setter($templateData[$field]['value']);
5871  }
5872  }
5873  }
5874 
5875  private function formShowGeneralSection($templateData) {
5876  // alway show because of title and description
5877  return true;
5878  }
5879 
5880  private function formShowBeginningEndingInformation($templateData) {
5881  // show always because of statement text areas
5882  return true;
5883  }
5884 
5885  private function formShowPresentationSection($templateData) {
5886  // show always because of "previous answer" setting
5887  return true;
5888  }
5889 
5890  private function formShowSequenceSection($templateData) {
5891  // show always because of "list of question" and "shuffle"
5892  return true;
5893  }
5894 
5895  private function formShowKioskSection($templateData) {
5896  $fields = array(
5897  'kiosk',
5898  );
5899  return $this->formsectionHasVisibleFields($templateData, $fields);
5900  }
5901 
5902  private function formShowSessionSection($templateData) {
5903  // show always because of "nr_of_tries", "chb_processing_time", "chb_starting_time", "chb_ending_time"
5904  return true;
5905  }
5906 
5907  private function formShowParticipantSection($templateData) {
5908  $fields = array(
5909  'fixedparticipants',
5910  'allowedUsers',
5911  'allowedUsersTimeGap',
5912  );
5913  return $this->formsectionHasVisibleFields($templateData, $fields);
5914  }
5915 
5916  private function formShowNotificationSection($templateData) {
5917  $fields = array(
5918  'mailnotification',
5919  'mailnottype',
5920  );
5921  return $this->formsectionHasVisibleFields($templateData, $fields);
5922  }
5923 
5924  private function formsectionHasVisibleFields($templateData, $fields) {
5925  foreach($fields as $fld) {
5926  if (isset($templateData[$fld])) {
5927  if(!$templateData[$fld]['hide'])
5928  return true;
5929  }
5930  else {
5931  return true;
5932  }
5933  }
5934  return false;
5935  }
5936 
5941  {
5942  ilUtil::sendQuestion($this->lng->txt("test_confirm_template_reset"));
5943  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_tst_tst_confirm_resettemplate.html", "Modules/Test");
5944  $this->tpl->setCurrentBlock("adm_content");
5945  $this->tpl->setVariable("BTN_CONFIRM_REMOVE", $this->lng->txt("confirm"));
5946  $this->tpl->setVariable("BTN_CANCEL_REMOVE", $this->lng->txt("cancel"));
5947  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "resetTemplateObject"));
5948  $this->tpl->parseCurrentBlock();
5949  }
5950 
5955  {
5956  $this->object->setTemplate(null);
5957  $this->object->saveToDB();
5958 
5959  ilUtil::sendSuccess($this->lng->txt("test_template_reset"), true);
5960  $this->ctrl->redirect($this, "properties");
5961  }
5962 
5964  {
5965  global $ilAccess;
5966  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
5967  {
5968  // allow only write access
5969  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
5970  $this->ctrl->redirect($this, "infoScreen");
5971  }
5972 
5973  global $ilCtrl;
5974 
5975  $orders = $obligations = array();
5976 
5977  foreach($_REQUEST['order'] as $qId => $order)
5978  {
5979  $id = (int)str_replace('q_', '', $qId);
5980 
5981  $orders[$id] = $order;
5982  }
5983 
5984  if( $this->object->areObligationsEnabled() && isset($_REQUEST['obligatory']) && is_array($_REQUEST['obligatory']) )
5985  {
5986  foreach($_REQUEST['obligatory'] as $qId => $obligation)
5987  {
5988  $id = (int)str_replace('q_', '', $qId);
5989 
5991  {
5992  $obligations[$id] = $obligation;
5993  }
5994  }
5995  }
5996 
5997  $this->object->setQuestionOrderAndObligations(
5998  $orders, $obligations
5999  );
6000 
6001  $ilCtrl->redirect($this, 'questions');
6002  }
6003 
6007  protected function movePageFormObject()
6008  {
6009  global $lng, $ilCtrl, $tpl;
6010 
6011  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
6012  $form = new ilPropertyFormGUI();
6013  $form->setFormAction($ilCtrl->getFormAction($this, "movePage"));
6014  $form->setTitle($lng->txt("test_move_page"));
6015 
6016  $old_pos = new ilHiddenInputGUI("q_id");
6017  $old_pos->setValue($_REQUEST['q_id']);
6018  $form->addItem($old_pos);
6019 
6020  $questions = $this->object->getQuestionTitlesAndIndexes();
6021  if (!is_array($questions))
6022  $questions = array();
6023 
6024  foreach($questions as $k => $q) {
6025  if ($k == $_REQUEST['q_id']) {
6026  unset($questions[$k]);
6027  continue;
6028  }
6029  $questions[$k] = $lng->txt('behind') . ' '. $q;
6030  }
6031  #$questions['0'] = $lng->txt('first');
6032 
6033  $options = array(
6034  0 => $lng->txt('first')
6035  );
6036  foreach($questions as $k => $q) {
6037  $options[$k] = $q;
6038  }
6039 
6040  $pos = new ilSelectInputGUI($lng->txt("position"), "position_after");
6041  $pos->setOptions($options);
6042  $form->addItem($pos);
6043 
6044  $form->addCommandButton("movePage", $lng->txt("submit"));
6045  $form->addCommandButton("showPage", $lng->txt("cancel"));
6046 
6047  return $tpl->setContent($form->getHTML());
6048  }
6049 
6050  public function movePageObject() {
6051  global $ilAccess;
6052  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
6053  {
6054  // allow only write access
6055  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
6056  $this->ctrl->redirect($this, "infoScreen");
6057  }
6058 
6059  $this->object->moveQuestionAfter($_REQUEST['q_id'], $_REQUEST['position_after']);
6060  $this->showPageObject();
6061  }
6062 
6063  public function showPageObject() {
6064  global $ilCtrl;
6065 
6066  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'q_id', $_REQUEST['q_id']);
6067  $ilCtrl->redirectByClass('iltestexpresspageobjectgui', 'showPage');
6068  }
6069 
6070  public function copyQuestionObject() {
6071  global $ilAccess;
6072  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
6073  {
6074  // allow only write access
6075  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
6076  $this->ctrl->redirect($this, "infoScreen");
6077  }
6078 
6079  if ($_REQUEST['q_id'] && !is_array($_REQUEST['q_id']))
6080  $ids = array($_REQUEST['q_id']);
6081  else if ($_REQUEST['q_id'])
6082  $ids = $_REQUEST['q_id'];
6083  else
6084  {
6085  ilUtil::sendFailure( $this->lng->txt('copy_no_questions_selected'), true );
6086  $this->ctrl->redirect($this, 'questions');
6087  }
6088 
6089  $copy_count = 0;
6090 
6091  $questionTitles = $this->object->getQuestionTitles();
6092 
6093  foreach($ids as $id)
6094  {
6095  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
6096  $question = assQuestion::_instanciateQuestionGUI($id);
6097  if ($question)
6098  {
6099  $title = $question->object->getTitle();
6100  $i = 2;
6101  while( in_array( $title . ' (' . $i . ')', $questionTitles ))
6102  $i++;
6103 
6104  $title .= ' (' . $i . ')';
6105 
6106  $questionTitles[] = $title;
6107 
6108  $new_id = $question->object->duplicate(false, $title);
6109 
6110  $clone = assQuestion::_instanciateQuestionGUI($new_id);
6111  $clone->object->setObjId($this->object->getId());
6112  $clone->object->saveToDb();
6113 
6114  $this->object->insertQuestion($new_id, true);
6115 
6116  $copy_count++;
6117  }
6118  }
6119 
6120  ilUtil::sendSuccess($this->lng->txt('copy_questions_success'), true);
6121 
6122  $this->ctrl->redirect($this, 'questions');
6123  }
6124 
6125  private function isRandomTestSettingSwitched($random_test)
6126  {
6127  return ($random_test != $this->object->isRandomTest());
6128  }
6129 } // END class.ilObjTestGUI
6130 ?>