ILIAS  Release_4_2_x_branch Revision 61807
 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 
32 include_once "./classes/class.ilObjectGUI.php";
33 include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
34 include_once "./Modules/Test/classes/class.ilObjAssessmentFolderGUI.php";
35 include_once 'Modules/Test/classes/class.ilTestExpressPage.php';
36 
38 {
43  function ilObjTestGUI()
44  {
45  global $lng, $ilCtrl;
46  $lng->loadLanguageModule("assessment");
47  $this->type = "tst";
48  $this->ctrl =& $ilCtrl;
49  $this->ctrl->saveParameter($this, "ref_id");
50  $this->ilObjectGUI("",$_GET["ref_id"], true, false);
51  // Added parameter if called from crs_objectives
52  if((int) $_GET['crs_show_result'])
53  {
54  $this->ctrl->saveParameter($this,'crs_show_result',(int) $_GET['crs_show_result']);
55  }
56  }
57 
61  function executeCommand()
62  {
63  global $ilAccess, $ilNavigationHistory,$ilCtrl;
64 
65  if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"])) && (!$ilAccess->checkAccess("visible", "", $_GET["ref_id"])))
66  {
67  global $ilias;
68  $ilias->raiseError($this->lng->txt("permission_denied"), $ilias->error_obj->MESSAGE);
69  }
70 
71  $cmd = $this->ctrl->getCmd("properties");
72 
73  $cmdsDisabledDueToOfflineStatus = array(
74  'resume', 'start', 'outUserResultsOverview', 'outUserListOfAnswerPasses'
75  );
76 
77  if( !$this->getCreationMode() && !$this->object->isOnline() && in_array($cmd, $cmdsDisabledDueToOfflineStatus) )
78  {
79  $cmd = 'infoScreen';
80  }
81 
82  $next_class = $this->ctrl->getNextClass($this);
83  $this->ctrl->setReturn($this, "properties");
84 
85  if (method_exists($this->object, "getTestStyleLocation")) $this->tpl->addCss($this->object->getTestStyleLocation("output"), "screen");
86 
87  // add entry to navigation history
88  if (!$this->getCreationMode() &&
89  $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
90  {
91  $ilNavigationHistory->addItem($_GET["ref_id"],
92  "ilias.php?baseClass=ilObjTestGUI&cmd=infoScreen&ref_id=".$_GET["ref_id"], "tst");
93  }
94 
95  if(!$this->getCreationMode())
96  {
97  if(IS_PAYMENT_ENABLED)
98  {
99  include_once 'Services/Payment/classes/class.ilPaymentObject.php';
100  if(ilPaymentObject::_requiresPurchaseToAccess($this->object->getRefId(), $type = (isset($_GET['purchasetype']) ? $_GET['purchasetype'] : NULL) ))
101  {
102  $this->setLocator();
103  $this->tpl->getStandardTemplate();
104 
105  include_once 'Services/Payment/classes/class.ilShopPurchaseGUI.php';
106  $pp = new ilShopPurchaseGUI((int)$_GET['ref_id']);
107  $ret = $this->ctrl->forwardCommand($pp);
108  $this->tpl->show();
109  exit();
110  }
111  }
112  }
113 
114  // elba hack for storing question id for inserting new question after
115  if ($_REQUEST['prev_qid']) {
116  global $___prev_question_id;
117  $___prev_question_id = $_REQUEST['prev_qid'];
118  $this->ctrl->setParameter($this, 'prev_qid', $_REQUEST['prev_qid']);
119  }
120 
121  switch($next_class)
122  {
123  case "ilinfoscreengui":
124  $this->prepareOutput();
125  $this->addHeaderAction();
126  $this->infoScreen(); // forwards command
127  break;
128  case 'ilmdeditorgui':
129  $this->prepareOutput();
130  $this->addHeaderAction();
131  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
132  $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
133  $md_gui->addObserver($this->object,'MDUpdateListener','General');
134 
135  $this->ctrl->forwardCommand($md_gui);
136  break;
137  case "iltestoutputgui":
138  include_once "./Modules/Test/classes/class.ilTestOutputGUI.php";
139  if (!$this->object->getKioskMode()) $this->prepareOutput();
140  $output_gui =& new ilTestOutputGUI($this->object);
141  $this->ctrl->forwardCommand($output_gui);
142  break;
143 
144  case "iltestevaluationgui":
145  $this->prepareOutput();
146  $this->addHeaderAction();
147  include_once "./Modules/Test/classes/class.ilTestEvaluationGUI.php";
148  $evaluation_gui =& new ilTestEvaluationGUI($this->object);
149  $this->ctrl->forwardCommand($evaluation_gui);
150  break;
151 
152  case "iltestservicegui":
153  $this->prepareOutput();
154  $this->addHeaderAction();
155  include_once "./Modules/Test/classes/class.ilTestServiceGUI.php";
156  $serviceGUI =& new ilTestServiceGUI($this->object);
157  $this->ctrl->forwardCommand($serviceGUI);
158  break;
159 
160  case 'ilpermissiongui':
161  $this->prepareOutput();
162  $this->addHeaderAction();
163  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
164  $perm_gui =& new ilPermissionGUI($this);
165  $ret =& $this->ctrl->forwardCommand($perm_gui);
166  break;
167 
168  case "illearningprogressgui":
169  $this->prepareOutput();
170  $this->addHeaderAction();
171  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
172  $new_gui =& new ilLearningProgressGUI(LP_MODE_REPOSITORY,$this->object->getRefId());
173  $this->ctrl->forwardCommand($new_gui);
174 
175  break;
176 
177  case "ilcertificategui":
178  $this->prepareOutput();
179  $this->addHeaderAction();
180  include_once "./Services/Certificate/classes/class.ilCertificateGUI.php";
181  include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
182  $output_gui = new ilCertificateGUI(new ilTestCertificateAdapter($this->object));
183  $this->ctrl->forwardCommand($output_gui);
184  break;
185 
186  case "iltestscoringgui":
187  $this->prepareOutput();
188  $this->addHeaderAction();
189  include_once "./Modules/Test/classes/class.ilTestScoringGUI.php";
190  $output_gui = new ilTestScoringGUI($this->object);
191  $this->ctrl->forwardCommand($output_gui);
192  break;
193 
194  case 'ilobjectcopygui':
195  $this->prepareOutput();
196  $this->addHeaderAction();
197  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
198  $cp = new ilObjectCopyGUI($this);
199  $cp->setType('tst');
200  $this->ctrl->forwardCommand($cp);
201  break;
202 
203  case 'ilrepositorysearchgui':
204  $this->prepareOutput();
205  $this->addHeaderAction();
206  include_once('./Services/Search/classes/class.ilRepositorySearchGUI.php');
207  $rep_search =& new ilRepositorySearchGUI();
208  $rep_search->setCallback($this,
209  'addParticipantsObject',
210  array(
211  )
212  );
213 
214  // Set tabs
215  $this->ctrl->setReturn($this,'participants');
216  $ret =& $this->ctrl->forwardCommand($rep_search);
217  $this->tabs_gui->setTabActive('participants');
218  break;
219 
220  case 'ilpageeditorgui':
221  case 'iltestexpresspageobjectgui':
222  $qid = $_REQUEST['q_id'];
223 
224  // :FIXME: does not work
225  // $this->ctrl->saveParameterByClass(array('iltestexpresspageobjectgui', 'assorderingquestiongui', 'ilpageeditorgui', 'ilpcquestion', 'ilpcquestiongui'), 'test_express_mode');
226 
227  if (!$qid) {
228  $questions = $this->object->getQuestionTitlesAndIndexes();
229  if (!is_array($questions))
230  $questions = array();
231 
232  $keys = array_keys($questions);
233  $qid = $keys[0];
234 
235  $_REQUEST['q_id'] = $qid;
236  $_GET['q_id'] = $qid;
237  $_POST['q_id'] = $qid;
238  }
239 
240 
241 
242  $this->prepareOutput();
243  if (!in_array($cmd, array('addQuestion', 'browseForQuestions'))) {
244  $this->buildPageViewToolbar($qid);
245  }
246 
247  if (!$qid || in_array($cmd, array('insertQuestions', 'browseForQuestions'))) {
248  include_once("./Modules/Test/classes/class.ilTestExpressPageObjectGUI.php");
249  $pageObject = new ilTestExpressPageObjectGUI ("qpl", 0);
250  $pageObject->test_object = $this->object;
251  $ret =& $this->ctrl->forwardCommand($pageObject);
252  break;
253  }
254  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
255  $this->tpl->setCurrentBlock("ContentStyle");
256  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
258  $this->tpl->parseCurrentBlock();
259 
260  // syntax style
261  $this->tpl->setCurrentBlock("SyntaxStyle");
262  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
264  $this->tpl->parseCurrentBlock();
265  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
266 
267  $q_gui =& assQuestionGUI::_getQuestionGUI("", $qid);
268  #$q_gui->setQuestionTabs();
269  $q_gui->outAdditionalOutput();
270  $q_gui->object->setObjId($this->object->getId());
271  $question =& $q_gui->object;
272  $this->ctrl->saveParameter($this, "q_id");
273 
274  #$this->lng->loadLanguageModule("content");
275  $this->ctrl->setReturnByClass("ilTestExpressPageObjectGUI", "view");
276  $this->ctrl->setReturn($this, "questions");
277 
278  //$page =& new ilPageObject("qpl", $_GET["q_id"]);
279  include_once("./Services/COPage/classes/class.ilPageObject.php");
280  include_once("./Modules/Test/classes/class.ilTestExpressPageObjectGUI.php");
281 
282  $page_gui =& new ilTestExpressPageObjectGUI ("qpl", $qid);
283  $page_gui->test_object = $this->object;
284  $page_gui->setEditPreview(true);
285  $page_gui->setEnabledTabs(false);
286  $page_gui->setEnabledInternalLinks(false);
287  if (strlen($this->ctrl->getCmd()) == 0)
288  {
289  $this->ctrl->setCmdClass(get_class($page_gui));
290  $this->ctrl->setCmd("preview");
291  }
292 
293  $page_gui->setQuestionHTML(array($q_gui->object->getId() => $q_gui->getPreview(TRUE)));
294  $page_gui->setTemplateTargetVar("ADM_CONTENT");
295 
296  $page_gui->setOutputMode($this->object->evalTotalPersons() == 0 ? "edit" : 'preview');
297 
298  $page_gui->setHeader($question->getTitle());
299  $page_gui->setFileDownloadLink($this->ctrl->getLinkTarget($this, "downloadFile"));
300  $page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "fullscreen"));
301  $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTarget($this));
302  $page_gui->setPresentationTitle($question->getTitle());
303  $ret =& $this->ctrl->forwardCommand($page_gui);
304 
305  global $ilTabs;
306  $ilTabs->activateTab('assQuestions');
307 
308  $this->tpl->setContent($ret);
309  break;
310 
311  case 'ilpageobjectgui':
312  include_once ("./Services/COPage/classes/class.ilPageObjectGUI.php");
313  //echo $_REQUEST['prev_qid'];
314  if ($_REQUEST['prev_qid']) {
315  $this->ctrl->setParameter($this, 'prev_qid', $_REQUEST['prev_qid']);
316  }
317 
318  $this->prepareOutput();
319  //global $___test_express_mode;
320  //$___test_express_mode = true;
321  $_GET['calling_test'] = $this->object->getRefId();
322  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
323  $this->tpl->setCurrentBlock("ContentStyle");
324  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
326  $this->tpl->parseCurrentBlock();
327 
328  // syntax style
329  $this->tpl->setCurrentBlock("SyntaxStyle");
330  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
332  $this->tpl->parseCurrentBlock();
333  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
334  $q_gui =& assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
335  $q_gui->setQuestionTabs();
336  $q_gui->outAdditionalOutput();
337  $q_gui->object->setObjId($this->object->getId());
338  $question =& $q_gui->object;
339  $this->ctrl->saveParameter($this, "q_id");
340  include_once("./Services/COPage/classes/class.ilPageObject.php");
341  include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
342  $this->lng->loadLanguageModule("content");
343  $this->ctrl->setReturnByClass("ilPageObjectGUI", "view");
344  $this->ctrl->setReturn($this, "questions");
345  //$page =& new ilPageObject("qpl", $_GET["q_id"]);
346  $page_gui =& new ilPageObjectGUI("qpl", $_GET["q_id"]);
347  $page_gui->setEditPreview(true);
348  $page_gui->setEnabledTabs(false);
349  $page_gui->setEnabledInternalLinks(false);
350  if (strlen($this->ctrl->getCmd()) == 0)
351  {
352  $this->ctrl->setCmdClass(get_class($page_gui));
353  $this->ctrl->setCmd("preview");
354  }
355  //$page_gui->setQuestionXML($question->toXML(false, false, true));
356  $page_gui->setQuestionHTML(array($q_gui->object->getId() => $q_gui->getPreview(TRUE)));
357  $page_gui->setTemplateTargetVar("ADM_CONTENT");
358  $page_gui->setOutputMode($this->object->evalTotalPersons() == 0 ? "edit" : 'preview');
359  $page_gui->setHeader($question->getTitle());
360  $page_gui->setFileDownloadLink($this->ctrl->getLinkTarget($this, "downloadFile"));
361  $page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "fullscreen"));
362  $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTarget($this));
363  $page_gui->setPresentationTitle($question->getTitle());
364  $ret =& $this->ctrl->forwardCommand($page_gui);
365  $this->tpl->setContent($ret);
366 
367  break;
368 
369  case "ilcommonactiondispatchergui":
370  include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
372  $this->ctrl->forwardCommand($gui);
373  break;
374 
375  case '':
376  case 'ilobjtestgui':
377  $this->prepareOutput();
378  $this->addHeaderAction();
379  if (preg_match("/deleteqpl_\d+/", $cmd))
380  {
381  $cmd = "randomQuestions";
382  }
383  if ((strcmp($cmd, "properties") == 0) && ($_GET["browse"]))
384  {
385  $this->questionBrowser();
386  return;
387  }
388  if ((strcmp($cmd, "properties") == 0) && ($_GET["up"] || $_GET["down"]))
389  {
390  $this->questionsObject();
391  return;
392  }
393  $cmd.= "Object";
394  $ret =& $this->$cmd();
395  break;
396  default:
397  // elba hack for storing question id for inserting new question after
398  if ($_REQUEST['prev_qid']) {
399  global $___prev_question_id;
400  $___prev_question_id = $_REQUEST['prev_qid'];
401  $this->ctrl->setParameterByClass('ilpageobjectgui', 'prev_qid', $_REQUEST['prev_qid']);
402  $this->ctrl->setParameterByClass($_GET['sel_question_types'] . 'gui', 'prev_qid', $_REQUEST['prev_qid']);
403  }
404  $this->create_question_mode = true;
405  $this->prepareOutput();
406 
407  $this->ctrl->setReturn($this, "questions");
408  include_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
409  $q_gui =& assQuestionGUI::_getQuestionGUI($_GET['sel_question_types'], $_GET["q_id"]);
410  $q_gui->object->setObjId($this->object->getId());
411  if (!$_GET['sel_question_types'])
412  $qType = assQuestion::getQuestionTypeFromDb($_GET['q_id']);
413  else {
414  $qType = $_GET['sel_question_types'];
415  }
416  $this->ctrl->setParameterByClass($qType . "GUI", 'prev_qid', $_REQUEST['prev_qid']);
417  $this->ctrl->setParameterByClass($qType . "GUI", 'test_ref_id', $_REQUEST['ref_id']);
418  $this->ctrl->setParameterByClass($qType . "GUI", 'q_id', $_REQUEST['q_id']);
419  if ($_REQUEST['test_express_mode'])
420  $this->ctrl->setParameterByClass($qType . "GUI", 'test_express_mode', 1);
421 
422  #global $___test_express_mode;
423  #$___test_express_mode = true;
424  if (!$q_gui->isSaveCommand())
425  $_GET['calling_test'] = $this->object->getRefId();
426 
427  $q_gui->setQuestionTabs();
428  #unset($___test_express_mode);
429  $ret =& $this->ctrl->forwardCommand($q_gui);
430  break;
431  }
432  if (strtolower($_GET["baseClass"]) != "iladministrationgui" &&
433  $this->getCreationMode() != true)
434  {
435  $this->tpl->show();
436  }
437  }
438 
439  function runObject()
440  {
441  $this->ctrl->redirect($this, "infoScreen");
442  }
443 
445  {
446  $this->ctrl->redirectByClass("iltestevaluationgui", "outEvaluation");
447  }
448 
452  function importFileObject()
453  {
454  $form = $this->initImportForm($_REQUEST["new_type"]);
455  if($form->checkInput())
456  {
457  $this->ctrl->setParameter($this, "new_type", $this->type);
458  $this->uploadTstObject();
459  }
460 
461  // display form to correct errors
462  $form->setValuesByPost();
463  $this->tpl->setContent($form->getHTML());
464  }
465 
466  function addDidacticTemplateOptions(array &$a_options)
467  {
468  include_once("./Modules/Test/classes/class.ilObjTest.php");
469  $tst = new ilObjTest();
470  $defaults = $tst->getAvailableDefaults();
471  if (count($defaults))
472  {
473  foreach ($defaults as $row)
474  {
475  $a_options["tstdef_".$row["test_defaults_id"]] = array($row["name"],
476  $this->lng->txt("tst_default_settings"));
477  }
478  }
479 
480  // using template?
481  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
483  if($templates)
484  {
485  foreach($templates as $item)
486  {
487  $a_options["tsttpl_".$item["id"]] = array($item["title"],
488  nl2br(trim($item["description"])));
489  }
490  }
491  }
492 
497  function afterSave(ilObject $a_new_object)
498  {
499  $tstdef = $this->getDidacticTemplateVar("tstdef");
500  if ($tstdef)
501  {
502  $a_new_object->applyDefaults($tstdef);
503  }
504 
505  $template_id = $this->getDidacticTemplateVar("tsttpl");
506  if($template_id)
507  {
508  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
510 
511  $template_settings = $template->getSettings();
512  if($template_settings)
513  {
514  $this->applyTemplate($template_settings, $a_new_object);
515  }
516 
517  $a_new_object->setTemplate($template_id);
518  $a_new_object->saveToDb();
519  }
520 
521  // always send a message
522  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
523  ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&ref_id=".
524  $a_new_object->getRefId()."&cmd=properties");
525  }
526 
528  {
529  include_once "./Services/Utilities/classes/class.ilUtil.php";
530  $path = $this->tree->getPathFull($this->object->getRefID());
531  ilUtil::redirect($this->getReturnLocation("cancel","./repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
532  }
533 
535  {
536  include_once "./Services/Utilities/classes/class.ilUtil.php";
537  ilUtil::redirect($this->getReturnLocation("cancel","./repository.php?ref_id=".(int) $_GET['crs_show_result']));
538  }
539 
540  /*
541  * list all export files
542  */
543  function exportObject()
544  {
545  global $tree;
546  global $ilAccess;
547  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
548  {
549  // allow only write access
550  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
551  $this->ctrl->redirect($this, "infoScreen");
552  }
553 
554  $export_dir = $this->object->getExportDirectory();
555  $export_files = $this->object->getExportFiles($export_dir);
556  $data = array();
557  if(count($export_files) > 0)
558  {
559  foreach($export_files as $exp_file)
560  {
561  $file_arr = explode("__", $exp_file);
562  array_push($data, array(
563  'file' => $exp_file,
564  'size' => filesize($export_dir."/".$exp_file),
565  'date' => $file_arr[0]
566  ));
567  }
568  }
569 
570  include_once "./Modules/Test/classes/tables/class.ilTestExportTableGUI.php";
571  $table_gui = new ilTestExportTableGUI($this, 'export');
572  $table_gui->setData($data);
573  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
574  }
575 
580  {
581  global $ilAccess;
582 
583  if ($ilAccess->checkAccess("write", "", $this->ref_id))
584  {
585  include_once("./Modules/Test/classes/class.ilTestExport.php");
586  $test_exp = new ilTestExport($this->object, 'xml');
587  $test_exp->buildExportFile();
588  }
589  else
590  {
591  ilUtil::sendInfo("cannot_export_test", TRUE);
592  }
593  $this->ctrl->redirect($this, "export");
594  }
595 
600  {
601  global $ilAccess;
602 
603  if ($ilAccess->checkAccess("write", "", $this->ref_id))
604  {
605  include_once("./Modules/Test/classes/class.ilTestExport.php");
606  $test_exp = new ilTestExport($this->object, 'results');
607  $test_exp->buildExportFile();
608  }
609  else
610  {
611  ilUtil::sendInfo("cannot_export_test", TRUE);
612  }
613  $this->ctrl->redirect($this, "export");
614  }
615 
616 
621  {
622  global $ilAccess;
623  if( !$ilAccess->checkAccess('write', '', $this->ref_id) )
624  {
625  ilUtil::sendInfo($this->lng->txt('no_permission'), true);
626  $this->ctrl->redirect($this, 'infoScreen');
627  }
628 
629  if(!isset($_POST["file"]))
630  {
631  ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
632  $this->ctrl->redirect($this, "export");
633  }
634 
635  if (count($_POST["file"]) > 1)
636  {
637  ilUtil::sendInfo($this->lng->txt("select_max_one_item"), true);
638  $this->ctrl->redirect($this, "export");
639  }
640 
641  $filename = basename($_POST["file"][0]);
642  $file = $this->object->getExportDirectory().'/'.$filename;
643 
644  if( !file_exists($file) )
645  {
646  $this->ctrl->redirect($this, 'export');
647  }
648 
650  }
651 
656  {
657  global $ilAccess;
658  if( !$ilAccess->checkAccess('write', '', $this->ref_id) )
659  {
660  ilUtil::sendInfo($this->lng->txt('no_permission'), true);
661  $this->ctrl->redirect($this, 'infoScreen');
662  }
663 
664  if (!isset($_POST["file"]))
665  {
666  ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
667  $this->ctrl->redirect($this, "export");
668  }
669 
670  ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
671 
672  $export_dir = $this->object->getExportDirectory();
673  $export_files = $this->object->getExportFiles($export_dir);
674  $data = array();
675  if (count($_POST["file"]) > 0)
676  {
677  foreach ($_POST["file"] as $exp_file)
678  {
679  $file_arr = explode("__", $exp_file);
680  array_push($data, array(
681  'file' => $exp_file,
682  'size' => filesize($export_dir."/".$exp_file),
683  'date' => $file_arr[0]
684  ));
685  }
686  }
687 
688  include_once "./Modules/Test/classes/tables/class.ilTestExportTableGUI.php";
689  $table_gui = new ilTestExportTableGUI($this, 'export', true);
690  $table_gui->setData($data);
691  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
692  }
693 
699  function cancelObject($in_rep = false)
700  {
701  ilUtil::redirect("repository.php?cmd=frameset&ref_id=".$_GET["ref_id"]);
702  }
703 
708  {
709  global $ilAccess;
710  if( !$ilAccess->checkAccess('write', '', $this->ref_id) )
711  {
712  ilUtil::sendInfo($this->lng->txt('no_permission'), true);
713  $this->ctrl->redirect($this, 'infoScreen');
714  }
715 
716  ilUtil::sendInfo($this->lng->txt("msg_cancel"), true);
717  $this->ctrl->redirect($this, "export");
718  }
719 
720 
725  {
726  global $ilAccess;
727  if( !$ilAccess->checkAccess('write', '', $this->ref_id) )
728  {
729  ilUtil::sendInfo($this->lng->txt('no_permission'), true);
730  $this->ctrl->redirect($this, 'infoScreen');
731  }
732 
733  $export_dir = $this->object->getExportDirectory();
734  foreach ($_POST["file"] as $file)
735  {
736  $file = basename($file);
737  $dir = substr($file, 0, strlen($file) - 4);
738 
739  if( !strlen($file) || !strlen($dir) )
740  {
741  continue;
742  }
743 
744  $exp_file = $export_dir."/".$file;
745  $exp_dir = $export_dir."/".$dir;
746  if (@is_file($exp_file))
747  {
748  unlink($exp_file);
749  }
750  if (@is_dir($exp_dir))
751  {
752  ilUtil::delDir($exp_dir);
753  }
754  }
755  ilUtil::sendSuccess($this->lng->txt('msg_deleted_export_files'), true);
756  $this->ctrl->redirect($this, "export");
757  }
758 
762  function uploadTstObject()
763  {
764  if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
765  {
766  ilUtil::sendFailure($this->lng->txt("error_upload"));
767  $this->createObject();
768  return;
769  }
770  include_once("./Modules/Test/classes/class.ilObjTest.php");
771  // create import directory
773 
774  // copy uploaded file to import directory
775  $file = pathinfo($_FILES["xmldoc"]["name"]);
776  $full_path = $basedir."/".$_FILES["xmldoc"]["name"];
777  ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path);
778 
779  // unzip file
780  ilUtil::unzip($full_path);
781 
782  // determine filenames of xml files
783  $subdir = basename($file["basename"],".".$file["extension"]);
785  $xml_file = ilObjTest::_getImportDirectory().'/'.$subdir.'/'.$subdir.".xml";
786  $qti_file = ilObjTest::_getImportDirectory().'/'.$subdir.'/'. preg_replace("/test|tst/", "qti", $subdir).".xml";
787  $results_file = ilObjTest::_getImportDirectory().'/'.$subdir.'/'. preg_replace("/test|tst/", "results", $subdir).".xml";
788 
789  // start verification of QTI files
790  include_once "./Services/QTI/classes/class.ilQTIParser.php";
791  $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, "");
792  $result = $qtiParser->startParsing();
793  $founditems =& $qtiParser->getFoundItems();
794 
795  if (count($founditems) == 0)
796  {
797  // nothing found
798 
799  // delete import directory
800  ilUtil::delDir($basedir);
801 
802  ilUtil::sendInfo($this->lng->txt("tst_import_no_items"));
803  $this->createObject();
804  return;
805  }
806 
807  $complete = 0;
808  $incomplete = 0;
809  foreach ($founditems as $item)
810  {
811  if (strlen($item["type"]))
812  {
813  $complete++;
814  }
815  else
816  {
817  $incomplete++;
818  }
819  }
820 
821  if ($complete == 0)
822  {
823  // delete import directory
824  ilUtil::delDir($basedir);
825 
826  ilUtil::sendInfo($this->lng->txt("qpl_import_non_ilias_files"));
827  $this->createObject();
828  return;
829  }
830 
831  $_SESSION["tst_import_results_file"] = $results_file;
832  $_SESSION["tst_import_xml_file"] = $xml_file;
833  $_SESSION["tst_import_qti_file"] = $qti_file;
834  $_SESSION["tst_import_subdir"] = $subdir;
835  // display of found questions
836  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.tst_import_verification.html");
837  $row_class = array("tblrow1", "tblrow2");
838  $counter = 0;
839  foreach ($founditems as $item)
840  {
841  $this->tpl->setCurrentBlock("verification_row");
842  $this->tpl->setVariable("ROW_CLASS", $row_class[$counter++ % 2]);
843  $this->tpl->setVariable("QUESTION_TITLE", $item["title"]);
844  $this->tpl->setVariable("QUESTION_IDENT", $item["ident"]);
845  include_once "./Services/QTI/classes/class.ilQTIItem.php";
846  switch ($item["type"])
847  {
848  case "MULTIPLE CHOICE QUESTION":
850  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("qt_multiple_choice"));
851  break;
852  case "SINGLE CHOICE QUESTION":
854  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assSingleChoice"));
855  break;
856  case "NUMERIC QUESTION":
857  case QT_NUMERIC:
858  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assNumeric"));
859  break;
860  case "TEXTSUBSET QUESTION":
861  case QT_TEXTSUBSET:
862  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextSubset"));
863  break;
864  case "CLOZE QUESTION":
865  case QT_CLOZE:
866  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assClozeTest"));
867  break;
868  case "IMAGE MAP QUESTION":
869  case QT_IMAGEMAP:
870  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assImagemapQuestion"));
871  break;
872  case "JAVA APPLET QUESTION":
873  case QT_JAVAAPPLET:
874  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assJavaApplet"));
875  break;
876  case "MATCHING QUESTION":
877  case QT_MATCHING:
878  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assMatchingQuestion"));
879  break;
880  case "ORDERING QUESTION":
881  case QT_ORDERING:
882  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assOrderingQuestion"));
883  break;
884  case "TEXT QUESTION":
885  case QT_TEXT:
886  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextQuestion"));
887  break;
888  }
889  $this->tpl->parseCurrentBlock();
890  }
891 
892  // on import creation screen the pool was chosen (-1 for no pool)
893  // BUT when no pool is available the input on creation screen is missing, so the field value -1 for no pool is not submitted.
894  $QplOrTstID = isset($_POST["qpl"]) && (int)$_POST["qpl"] != 0 ? $_POST["qpl"] : -1;
895 
896  $this->tpl->setCurrentBlock("adm_content");
897  $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt("question_type"));
898  $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("question_title"));
899  $this->tpl->setVariable("FOUND_QUESTIONS_INTRODUCTION", $this->lng->txt("tst_import_verify_found_questions"));
900  $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_tst"));
901  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
902  $this->tpl->setVariable("ARROW", ilUtil::getImagePath("arrow_downright.gif"));
903  $this->tpl->setVariable("QUESTIONPOOL_ID", $QplOrTstID);
904  $this->tpl->setVariable("VALUE_IMPORT", $this->lng->txt("import"));
905  $this->tpl->setVariable("VALUE_CANCEL", $this->lng->txt("cancel"));
906  $this->tpl->parseCurrentBlock();
907  }
908 
913  {
914  include_once "./Modules/Test/classes/class.ilObjTest.php";
915  // create new questionpool object
916  $newObj = new ilObjTest(0, true);
917  // set type of questionpool object
918  $newObj->setType($_GET["new_type"]);
919  // set title of questionpool object to "dummy"
920  $newObj->setTitle("dummy");
921  // set description of questionpool object
922  $newObj->setDescription("test import");
923  // create the questionpool class in the ILIAS database (object_data table)
924  $newObj->create(true);
925  // create a reference for the questionpool object in the ILIAS database (object_reference table)
926  $newObj->createReference();
927  // put the questionpool object in the administration tree
928  $newObj->putInTree($_GET["ref_id"]);
929  // get default permissions and set the permissions for the questionpool object
930  $newObj->setPermissions($_GET["ref_id"]);
931  // notify the questionpool object and all its parent objects that a "new" object was created
932  $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
933  // empty mark schema
934  $newObj->mark_schema->flush();
935 
936  // start parsing of QTI files
937  include_once "./Services/QTI/classes/class.ilQTIParser.php";
938 
939  // Handle selection of "no questionpool" as qpl_id = -1 -> use test object id instead.
940  if ($_POST["qpl_id"] == "-1")
941  {
942  $qpl_id = $newObj->id;
943  }
944  else
945  {
946  $qpl_id = $_POST["qpl_id"];
947  }
948 
949  $qtiParser = new ilQTIParser($_SESSION["tst_import_qti_file"], IL_MO_PARSE_QTI, $qpl_id, $_POST["ident"]);
950  $qtiParser->setTestObject($newObj);
951  $result = $qtiParser->startParsing();
952  $newObj->saveToDb();
953 
954  // import page data
955  include_once ("./Modules/LearningModule/classes/class.ilContObjParser.php");
956  $contParser = new ilContObjParser($newObj, $_SESSION["tst_import_xml_file"], $_SESSION["tst_import_subdir"]);
957  $contParser->setQuestionMapping($qtiParser->getImportMapping());
958  $contParser->startParsing();
959 
960  // import test results
961  if (@file_exists($_SESSION["tst_import_results_file"]))
962  {
963  include_once ("./Modules/Test/classes/class.ilTestResultsImportParser.php");
964  $results = new ilTestResultsImportParser($_SESSION["tst_import_results_file"], $newObj);
965  $results->startParsing();
966  }
967 
968  // delete import directory
970  ilUtil::sendSuccess($this->lng->txt("object_imported"),true);
971  ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
972  "&baseClass=ilObjTestGUI");
973  }
974 
981  function uploadObject($redirect = true)
982  {
983  $this->uploadTstObject();
984  }
985 
995  function confirmChangeProperties($direction = 0)
996  {
997  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_properties_save_confirmation.html", "Modules/Test");
998  $information = "";
999  switch ($direction)
1000  {
1001  case 0:
1002  $information = $this->lng->txt("change_properties_from_random_to_standard");
1003  break;
1004  default:
1005  $information = $this->lng->txt("change_properties_from_standard_to_random");
1006  break;
1007  }
1008  foreach ($_POST as $key => $value)
1009  {
1010  if (strcmp($key, "cmd") != 0)
1011  {
1012  if (is_array($value))
1013  {
1014  foreach ($value as $k => $v)
1015  {
1016  $this->tpl->setCurrentBlock("hidden_variable");
1017  $this->tpl->setVariable("HIDDEN_KEY", $key . "[" . $k . "]");
1018  $this->tpl->setVariable("HIDDEN_VALUE", $v);
1019  $this->tpl->parseCurrentBlock();
1020  }
1021  }
1022  else
1023  {
1024  $this->tpl->setCurrentBlock("hidden_variable");
1025  $this->tpl->setVariable("HIDDEN_KEY", $key);
1026  $this->tpl->setVariable("HIDDEN_VALUE", $value);
1027  $this->tpl->parseCurrentBlock();
1028  }
1029  }
1030  }
1031  $this->tpl->setCurrentBlock("hidden_variable");
1032  $this->tpl->setVariable("HIDDEN_KEY", "tst_properties_confirmation");
1033  $this->tpl->setVariable("HIDDEN_VALUE", "1");
1034  $this->tpl->parseCurrentBlock();
1035  $this->tpl->setCurrentBlock("adm_content");
1036  $this->tpl->setVariable("TXT_CONFIRMATION", $this->lng->txt("confirmation"));
1037  $this->tpl->setVariable("TXT_INFORMATION", $information);
1038  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
1039  $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
1040  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
1041  $this->tpl->parseCurrentBlock();
1042  }
1043 
1050  {
1051  $hasErrors = $this->scoringObject(true);
1052  if (!$hasErrors)
1053  {
1054  $total = $this->object->evalTotalPersons();
1055  // Check the values the user entered in the form
1056  if (!$total)
1057  {
1058  $this->object->setCountSystem($_POST["count_system"]);
1059  $this->object->setMCScoring($_POST["mc_scoring"]);
1060  $this->object->setScoreCutting($_POST["score_cutting"]);
1061  $this->object->setPassScoring($_POST["pass_scoring"]);
1062  }
1063 
1064  /*
1065  $this->object->setAnswerFeedback((is_array($_POST['instant_feedback']) && in_array('instant_feedback_answer', $_POST['instant_feedback'])) ? 1 : 0);
1066  $this->object->setAnswerFeedbackPoints((is_array($_POST['instant_feedback']) && in_array('instant_feedback_points', $_POST['instant_feedback'])) ? 1 : 0);
1067  $this->object->setInstantFeedbackSolution((is_array($_POST['instant_feedback']) && in_array('instant_feedback_solution', $_POST['instant_feedback'])) ? 1 : 0);
1068  */
1069 
1074  $this->object->setScoringFeedbackOptionsByArray($_POST['instant_feedback']);
1075 
1076 
1077  $this->object->setScoreReporting($_POST["results_access"]);
1078  if ($this->object->getScoreReporting() == REPORT_AFTER_DATE)
1079  {
1080  $this->object->setReportingDate(sprintf("%04d%02d%02d%02d%02d%02d",
1081  $_POST["reporting_date"]['date']["y"],
1082  $_POST["reporting_date"]['date']["m"],
1083  $_POST["reporting_date"]['date']["d"],
1084  $_POST["reporting_date"]['time']["h"],
1085  $_POST["reporting_date"]['time']["m"],
1086  $_POST["reporting_date"]['time']["s"]
1087  ));
1088  }
1089  else
1090  {
1091  $this->object->setReportingDate('');
1092  }
1093 
1094  $this->object->setShowPassDetails((is_array($_POST['results_presentation']) && in_array('pass_details', $_POST['results_presentation'])) ? 1 : 0);
1095  $this->object->setShowSolutionDetails((is_array($_POST['results_presentation']) && in_array('solution_details', $_POST['results_presentation'])) ? 1 : 0);
1096  $this->object->setShowSolutionPrintview((is_array($_POST['results_presentation']) && in_array('solution_printview', $_POST['results_presentation'])) ? 1 : 0);
1097  $this->object->setShowSolutionFeedback((is_array($_POST['results_presentation']) && in_array('solution_feedback', $_POST['results_presentation'])) ? 1 : 0);
1098  $this->object->setShowSolutionAnswersOnly((is_array($_POST['results_presentation']) && in_array('solution_answers_only', $_POST['results_presentation'])) ? 1 : 0);
1099  $this->object->setShowSolutionSignature((is_array($_POST['results_presentation']) && in_array('solution_signature', $_POST['results_presentation'])) ? 1 : 0);
1100  $this->object->setShowSolutionSuggested((is_array($_POST['results_presentation']) && in_array('solution_suggested', $_POST['results_presentation'])) ? 1 : 0);
1101 
1102  $this->object->setExportSettingsSingleChoiceShort((is_array($_POST['export_settings']) && in_array('exp_sc_short', $_POST['export_settings'])) ? 1 : 0);
1103 
1104  $this->object->saveToDb(true);
1105  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), TRUE);
1106  $this->ctrl->redirect($this, "scoring");
1107  }
1108  }
1109 
1115  function scoringObject($checkonly = FALSE)
1116  {
1117  global $ilAccess;
1118  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
1119  {
1120  // allow only write access
1121  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
1122  $this->ctrl->redirect($this, "infoScreen");
1123  }
1124 
1125 
1126  // using template?
1127  $template_settings = null;
1128  $template = $this->object->getTemplate();
1129 
1130  if($template)
1131  {
1132  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
1133  include_once "Modules/Test/classes/class.ilObjAssessmentFolderGUI.php";
1134 
1136 
1137  $template_settings = $template->getSettings();
1138  }
1139 
1140  $save = (strcmp($this->ctrl->getCmd(), "saveScoring") == 0) ? TRUE : FALSE;
1141  $total = $this->object->evalTotalPersons();
1142  $this->tpl->addJavascript("./Services/JavaScript/js/Basic.js");
1143 
1144  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1145  $form = new ilPropertyFormGUI();
1146  $form->setFormAction($this->ctrl->getFormAction($this));
1147  $form->setTableWidth("100%");
1148  $form->setId("test_properties_scoring");
1149 
1150  // scoring properties
1151  $header = new ilFormSectionHeaderGUI();
1152  $header->setTitle($this->lng->txt("scoring"));
1153  $form->addItem($header);
1154 
1155  // scoring system
1156  $count_system = new ilRadioGroupInputGUI($this->lng->txt("tst_text_count_system"), "count_system");
1157  $count_system->addOption(new ilRadioOption($this->lng->txt("tst_count_partial_solutions"), 0, ''));
1158  $count_system->addOption(new ilRadioOption($this->lng->txt("tst_count_correct_solutions"), 1, ''));
1159  $count_system->setValue($this->object->getCountSystem());
1160  $count_system->setInfo($this->lng->txt("tst_count_system_description"));
1161  if ($total)
1162  {
1163  $count_system->setDisabled(true);
1164  }
1165  $form->addItem($count_system);
1166 
1167  // mc questions
1168  $mc_scoring = new ilRadioGroupInputGUI($this->lng->txt("tst_score_mcmr_questions"), "mc_scoring");
1169  $mc_scoring->addOption(new ilRadioOption($this->lng->txt("tst_score_mcmr_zero_points_when_unanswered"), 0, ''));
1170  $mc_scoring->addOption(new ilRadioOption($this->lng->txt("tst_score_mcmr_use_scoring_system"), 1, ''));
1171  $mc_scoring->setValue($this->object->getMCScoring());
1172  $mc_scoring->setInfo($this->lng->txt("tst_score_mcmr_questions_description"));
1173  if ($total)
1174  {
1175  $mc_scoring->setDisabled(true);
1176  }
1177  $form->addItem($mc_scoring);
1178 
1179  // score cutting
1180  $score_cutting = new ilRadioGroupInputGUI($this->lng->txt("tst_score_cutting"), "score_cutting");
1181  $score_cutting->addOption(new ilRadioOption($this->lng->txt("tst_score_cut_question"), 0, ''));
1182  $score_cutting->addOption(new ilRadioOption($this->lng->txt("tst_score_cut_test"), 1, ''));
1183  $score_cutting->setValue($this->object->getScoreCutting());
1184  $score_cutting->setInfo($this->lng->txt("tst_score_cutting_description"));
1185  if ($total)
1186  {
1187  $score_cutting->setDisabled(true);
1188  }
1189  $form->addItem($score_cutting);
1190 
1191  // pass scoring
1192  $pass_scoring = new ilRadioGroupInputGUI($this->lng->txt("tst_pass_scoring"), "pass_scoring");
1193  $pass_scoring->addOption(new ilRadioOption($this->lng->txt("tst_pass_last_pass"), 0, ''));
1194  $pass_scoring->addOption(new ilRadioOption($this->lng->txt("tst_pass_best_pass"), 1, ''));
1195  $pass_scoring->setValue($this->object->getPassScoring());
1196  $pass_scoring->setInfo($this->lng->txt("tst_pass_scoring_description"));
1197  if ($total)
1198  {
1199  $pass_scoring->setDisabled(true);
1200  }
1201  $form->addItem($pass_scoring);
1202 
1203  // instant feedback
1204  $instant_feedback = new ilCheckboxGroupInputGUI($this->lng->txt("tst_instant_feedback"), "instant_feedback");
1205  $instant_feedback->addOption(new ilCheckboxOption($this->lng->txt("tst_instant_feedback_answer_specific"), 'instant_feedback_answer', ''));
1206  $instant_feedback->addOption(new ilCheckboxOption($this->lng->txt("tst_instant_feedback_results"), 'instant_feedback_points', ''));
1207  $instant_feedback->addOption(new ilCheckboxOption($this->lng->txt("tst_instant_feedback_solution"), 'instant_feedback_solution', ''));
1208  $values = array();
1209  if ($this->object->getAnswerFeedback()) array_push($values, 'instant_feedback_answer');
1210  if ($this->object->getAnswerFeedbackPoints()) array_push($values, 'instant_feedback_points');
1211  if ($this->object->getInstantFeedbackSolution()) array_push($values, 'instant_feedback_solution');
1212  $instant_feedback->setValue($values);
1213  $instant_feedback->setInfo($this->lng->txt("tst_instant_feedback_description"));
1214  $form->addItem($instant_feedback);
1215 
1216  // access to test results
1217  $results_access = new ilRadioGroupInputGUI($this->lng->txt("tst_results_access"), "results_access");
1218  $results_access->addOption(new ilRadioOption($this->lng->txt("tst_results_access_finished"), 1, ''));
1219  $results_access->addOption(new ilRadioOption($this->lng->txt("tst_results_access_always"), 2, ''));
1220  $results_access->addOption(new ilRadioOption($this->lng->txt("tst_results_access_never"), 4, ''));
1221  $results_access->addOption(new ilRadioOption($this->lng->txt("tst_results_access_date"), 3, ''));
1222  $results_access->setValue($this->object->getScoreReporting());
1223  $results_access->setInfo($this->lng->txt("tst_results_access_description"));
1224 
1225  // access date
1226  $reporting_date = new ilDateTimeInputGUI('', 'reporting_date');
1227  $reporting_date->setShowDate(true);
1228  $reporting_date->setShowTime(true);
1229  if (strlen($this->object->getReportingDate()))
1230  {
1231  $reporting_date->setDate(new ilDateTime($this->object->getReportingDate(), IL_CAL_TIMESTAMP));
1232  }
1233  else
1234  {
1235  $reporting_date->setDate(new ilDateTime(time(), IL_CAL_UNIX));
1236  }
1237  $results_access->addSubItem($reporting_date);
1238  $form->addItem($results_access);
1239 
1240  // results presentation
1241  $results_presentation = new ilCheckboxGroupInputGUI($this->lng->txt("tst_results_presentation"), "results_presentation");
1242  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_pass_details"), 'pass_details', ''));
1243  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_details"), 'solution_details', ''));
1244  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_printview"), 'solution_printview', ''));
1245  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_feedback"), 'solution_feedback', ''));
1246  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_answers_only"), 'solution_answers_only', ''));
1247  $signatureOption = new ilCheckboxOption($this->lng->txt("tst_show_solution_signature"), 'solution_signature', '');
1248  $results_presentation->addOption($signatureOption);
1249  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_suggested"), 'solution_suggested', ''));
1250  $values = array();
1251  if ($this->object->getShowPassDetails()) array_push($values, 'pass_details');
1252  if ($this->object->getShowSolutionDetails()) array_push($values, 'solution_details');
1253  if ($this->object->getShowSolutionPrintview()) array_push($values, 'solution_printview');
1254  if ($this->object->getShowSolutionFeedback()) array_push($values, 'solution_feedback');
1255  if ($this->object->getShowSolutionAnswersOnly()) array_push($values, 'solution_answers_only');
1256  if ($this->object->getShowSolutionSignature()) array_push($values, 'solution_signature');
1257  if ($this->object->getShowSolutionSuggested()) array_push($values, 'solution_suggested');
1258  $results_presentation->setValue($values);
1259  $results_presentation->setInfo($this->lng->txt("tst_results_presentation_description"));
1260  if ($this->object->getAnonymity())
1261  {
1262  $signatureOption->setDisabled(true);
1263  }
1264  $form->addItem($results_presentation);
1265 
1266  // export settings
1267  $export_settings = new ilCheckboxGroupInputGUI($this->lng->txt("tst_export_settings"), "export_settings");
1268  $export_settings->addOption(new ilCheckboxOption($this->lng->txt("tst_exp_sc_short"), 'exp_sc_short', ''));
1269  $values = array();
1270  if ($this->object->getExportSettingsSingleChoiceShort()) array_push($values, 'exp_sc_short');
1271  $export_settings->setValue($values);
1272  $form->addItem($export_settings);
1273 
1274  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) $form->addCommandButton("saveScoring", $this->lng->txt("save"));
1275 
1276  // remove items when using template
1277  if($template_settings)
1278  {
1279  foreach($template_settings as $id => $item)
1280  {
1281  if($item["hide"])
1282  {
1283  $form->removeItemByPostVar($id);
1284  }
1285  }
1286  }
1287 
1288  $errors = false;
1289 
1290  if ($save)
1291  {
1292  $errors = !$form->checkInput();
1293  $form->setValuesByPost();
1294  if ($errors) $checkonly = false;
1295  }
1296  if (!$checkonly) $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
1297  return $errors;
1298  }
1299 
1305  function propertiesObject($checkonly = FALSE)
1306  {
1307  global $ilAccess;
1308  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
1309  {
1310  // allow only write access
1311  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
1312  $this->ctrl->redirect($this, "infoScreen");
1313  }
1314 
1315  // using template?
1316  $template_settings = null;
1317  $template = $this->object->getTemplate();
1318 
1319  if($template)
1320  {
1321  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
1323 
1324  $template_settings = $template->getSettings();
1325  $hide_rte_switch = $template_settings["rte_switch"]["hide"];
1326  }
1327 
1328  $save = (strcmp($this->ctrl->getCmd(), "saveProperties") == 0) ? TRUE : FALSE;
1329  $total = $this->object->evalTotalPersons();
1330  $this->tpl->addJavascript("./Services/JavaScript/js/Basic.js");
1331 
1332  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1333  $form = new ilPropertyFormGUI();
1334  $form->setFormAction($this->ctrl->getFormAction($this));
1335  $form->setTableWidth("100%");
1336  $form->setId("test_properties");
1337 
1338  if(!$template || $template && $this->formShowGeneralSection($template_settings)) {
1339  // general properties
1340  $header = new ilFormSectionHeaderGUI();
1341  $header->setTitle($this->lng->txt("tst_general_properties"));
1342  $form->addItem($header);
1343  }
1344 
1345  // title & description (meta data)
1346 
1347  // online
1348  $online = new ilCheckboxInputGUI($this->lng->txt("online"), "online");
1349  $online->setValue(1);
1350  $online->setChecked($this->object->isOnline());
1351  $form->addItem($online);
1352 
1353  include_once 'Services/MetaData/classes/class.ilMD.php';
1354  $md_obj = new ilMD($this->object->getId(), 0, "tst");
1355  $md_section = $md_obj->getGeneral();
1356 
1357  $title = new ilTextInputGUI($this->lng->txt("title"), "title");
1358  $title->setRequired(true);
1359  $title->setValue($md_section->getTitle());
1360  $form->addItem($title);
1361 
1362  $ids = $md_section->getDescriptionIds();
1363  if($ids)
1364  {
1365  $desc_obj = $md_section->getDescription(array_pop($ids));
1366 
1367  $desc = new ilTextAreaInputGUI($this->lng->txt("description"), "description");
1368  $desc->setCols(50);
1369  $desc->setRows(4);
1370  $desc->setValue($desc_obj->getDescription());
1371  $form->addItem($desc);
1372  }
1373 
1374  // anonymity
1375  /*
1376  * old behaviour
1377  */
1378  /*
1379  $anonymity = new ilCheckboxInputGUI($this->lng->txt("tst_anonymity"), "anonymity");
1380  $anonymity->setValue(1);
1381  if ($total) $anonymity->setDisabled(true);
1382  $anonymity->setChecked($this->object->getAnonymity());
1383  $anonymity->setInfo($this->lng->txt("tst_anonymity_description"));
1384  $form->addItem($anonymity);
1385  */
1386 
1387  $anonymity = new ilRadioGroupInputGUI($this->lng->txt('tst_anonymity'), 'anonymity');
1388  if ($total) $anonymity->setDisabled(true);
1389  $rb = new ilRadioOption($this->lng->txt('tst_anonymity_no_anonymization'), 0);
1390  $anonymity->addOption($rb);
1391  $rb = new ilRadioOption($this->lng->txt('tst_anonymity_anonymous_test'), 1);
1392  $anonymity->addOption($rb);
1393  $anonymity->setValue((int)$this->object->getAnonymity());
1394  $form->addItem($anonymity);
1395 
1396  // random selection of questions
1397  $random = new ilCheckboxInputGUI($this->lng->txt("tst_random_selection"), "random_test");
1398  $random->setValue(1);
1399  if ($total) $random->setDisabled(true);
1400  $random->setChecked($this->object->isRandomTest());
1401 
1402  $info = $this->lng->txt("tst_random_test_description");
1403  if ($this->object->hasQuestionsWithoutQuestionpool()) {
1404  $info .= $this->lng->txt("tst_random_test_description_warning");
1405  }
1406  $random->setInfo($info);
1407  $form->addItem($random);
1408 
1409 
1410 /*
1411  $options = array(
1412  'table' => $this->lng->txt("test_enable_view_table"),
1413  'express' => $this->lng->txt("test_enable_view_express"),
1414  'both' => $this->lng->txt("test_enable_view_both"),
1415  );
1416  $enable_views = new ilSelectInputGUI($this->lng->txt("test_enable_views"), "enabled_view_mode");
1417  $enable_views->setOptions($options);
1418  $enable_views->setValue($this->object->getEnabledViewMode());
1419  $form->addItem($enable_views);
1420 
1421  // enable usage of question pool in express mode
1422  $express_qpool = new ilCheckboxInputGUI($this->lng->txt("tst_express_allow_question_pool"), "express_allow_question_pool");
1423  $express_qpool->setValue(1);
1424  //if ($total) $random->setDisabled(true);
1425  $express_qpool->setChecked($this->object->isExpressModeQuestionPoolAllowed());
1426  $express_qpool->setInfo($this->lng->txt("tst_express_allow_question_pool_description"));
1427  $form->addItem($express_qpool);
1428 */
1429  // pool usage
1430  $pool_usage = new ilCheckboxInputGUI($this->lng->txt("test_question_pool_usage"), "use_pool");
1431  $pool_usage->setValue(1);
1432  $pool_usage->setChecked($this->object->getPoolUsage());
1433  $form->addItem($pool_usage);
1434 
1435  if(!$template || $template && $this->formShowBeginningEndingInformation($template_settings)) {
1436  // general properties
1437  $header = new ilFormSectionHeaderGUI();
1438  $header->setTitle($this->lng->txt("tst_beginning_ending_information"));
1439  $form->addItem($header);
1440  }
1441 
1442  // introduction
1443  $intro = new ilTextAreaInputGUI($this->lng->txt("tst_introduction"), "introduction");
1444  $intro->setValue($this->object->prepareTextareaOutput($this->object->getIntroduction()));
1445  $intro->setRows(10);
1446  $intro->setCols(80);
1447  $intro->setUseRte(TRUE);
1448  $intro->addPlugin("latex");
1449  $intro->addButton("latex");
1450  $intro->setRTESupport($this->object->getId(), "tst", "assessment");
1451  $intro->setRteTagSet('full');
1452  $intro->setInfo($this->lng->txt('intro_desc'));
1453  // showinfo
1454  $showinfo = new ilCheckboxInputGUI('', "showinfo");
1455  $showinfo->setValue(1);
1456  $showinfo->setChecked($this->object->getShowInfo());
1457  $showinfo->setOptionTitle($this->lng->txt("showinfo"));
1458  $showinfo->setInfo($this->lng->txt("showinfo_desc"));
1459  $intro->addSubItem($showinfo);
1460  $form->addItem($intro);
1461 
1462  // final statement
1463  $finalstatement = new ilTextAreaInputGUI($this->lng->txt("final_statement"), "finalstatement");
1464  $finalstatement->setValue($this->object->prepareTextareaOutput($this->object->getFinalStatement()));
1465  $finalstatement->setRows(10);
1466  $finalstatement->setCols(80);
1467  $finalstatement->setUseRte(TRUE);
1468  $finalstatement->addPlugin("latex");
1469  $finalstatement->addButton("latex");
1470  $finalstatement->setRTESupport($this->object->getId(), "tst", "assessment");
1471  $finalstatement->setRteTagSet('full');
1472  // show final statement
1473  $showfinal = new ilCheckboxInputGUI('', "showfinalstatement");
1474  $showfinal->setValue(1);
1475  $showfinal->setChecked($this->object->getShowFinalStatement());
1476  $showfinal->setOptionTitle($this->lng->txt("final_statement_show"));
1477  $showfinal->setInfo($this->lng->txt("final_statement_show_desc"));
1478  $finalstatement->addSubItem($showfinal);
1479  $form->addItem($finalstatement);
1480 
1481  if(!$template || $template && $this->formShowSessionSection($template_settings)) {
1482  // session properties
1483  $sessionheader = new ilFormSectionHeaderGUI();
1484  $sessionheader->setTitle($this->lng->txt("tst_session_settings"));
1485  $form->addItem($sessionheader);
1486  }
1487 
1488  // max. number of passes
1489  $nr_of_tries = new ilTextInputGUI($this->lng->txt("tst_nr_of_tries"), "nr_of_tries");
1490  $nr_of_tries->setSize(3);
1491  $nr_of_tries->setValue($this->object->getNrOfTries());
1492  $nr_of_tries->setRequired(true);
1493  $nr_of_tries->setSuffix($this->lng->txt("0_unlimited"));
1494  if ($total) $nr_of_tries->setDisabled(true);
1495  $form->addItem($nr_of_tries);
1496 
1497  // enable max. processing time
1498  $processing = new ilCheckboxInputGUI($this->lng->txt("tst_processing_time"), "chb_processing_time");
1499  $processing->setValue(1);
1500  //$processing->setOptionTitle($this->lng->txt("enabled"));
1501 
1502  if ($template_settings && $template_settings['chb_processing_time'] && $template_settings['chb_processing_time']['value'])
1503  $processing->setChecked(true);
1504  else
1505  $processing->setChecked($this->object->getEnableProcessingTime());
1506 
1507  // max. processing time
1508  $processingtime = new ilDurationInputGUI('', 'processing_time');
1509  $ptime = $this->object->getProcessingTimeAsArray();
1510  $processingtime->setHours($ptime['hh']);
1511  $processingtime->setMinutes($ptime['mm']);
1512  $processingtime->setSeconds($ptime['ss']);
1513  $processingtime->setShowMonths(false);
1514  $processingtime->setShowDays(false);
1515  $processingtime->setShowHours(true);
1516  $processingtime->setShowMinutes(true);
1517  $processingtime->setShowSeconds(true);
1518  $processingtime->setInfo($this->lng->txt("tst_processing_time_desc"));
1519  $processing->addSubItem($processingtime);
1520 
1521  // reset max. processing time
1522  $resetprocessing = new ilCheckboxInputGUI('', "chb_reset_processing_time");
1523  $resetprocessing->setValue(1);
1524  $resetprocessing->setOptionTitle($this->lng->txt("tst_reset_processing_time"));
1525  $resetprocessing->setChecked($this->object->getResetProcessingTime());
1526  $resetprocessing->setInfo($this->lng->txt("tst_reset_processing_time_desc"));
1527  $processing->addSubItem($resetprocessing);
1528  $form->addItem($processing);
1529 
1530  // enable starting time
1531  $enablestartingtime = new ilCheckboxInputGUI($this->lng->txt("tst_starting_time"), "chb_starting_time");
1532  $enablestartingtime->setValue(1);
1533  //$enablestartingtime->setOptionTitle($this->lng->txt("enabled"));
1534 
1535  if ($template_settings && $template_settings['chb_starting_time'] && $template_settings['chb_starting_time']['value'])
1536  $enablestartingtime->setChecked(true);
1537  else
1538  $enablestartingtime->setChecked(strlen($this->object->getStartingTime()));
1539  // starting time
1540  $startingtime = new ilDateTimeInputGUI('', 'starting_time');
1541  $startingtime->setShowDate(true);
1542  $startingtime->setShowTime(true);
1543  if (strlen($this->object->getStartingTime()))
1544  {
1545  $startingtime->setDate(new ilDateTime($this->object->getStartingTime(), IL_CAL_TIMESTAMP));
1546  }
1547  else
1548  {
1549  $startingtime->setDate(new ilDateTime(time(), IL_CAL_UNIX));
1550  }
1551  $enablestartingtime->addSubItem($startingtime);
1552  if ($total) $enablestartingtime->setDisabled(true);
1553  if ($total) $startingtime->setDisabled(true);
1554  $form->addItem($enablestartingtime);
1555 
1556  // enable ending time
1557  $enableendingtime = new ilCheckboxInputGUI($this->lng->txt("tst_ending_time"), "chb_ending_time");
1558  $enableendingtime->setValue(1);
1559  //$enableendingtime->setOptionTitle($this->lng->txt("enabled"));
1560  if ($template_settings && $template_settings['chb_ending_time'] && $template_settings['chb_ending_time']['value'])
1561  $enableendingtime->setChecked(true);
1562  else
1563  $enableendingtime->setChecked(strlen($this->object->getEndingTime()));
1564  // ending time
1565  $endingtime = new ilDateTimeInputGUI('', 'ending_time');
1566  $endingtime->setShowDate(true);
1567  $endingtime->setShowTime(true);
1568  if (strlen($this->object->getEndingTime()))
1569  {
1570  $endingtime->setDate(new ilDateTime($this->object->getEndingTime(), IL_CAL_TIMESTAMP));
1571  }
1572  else
1573  {
1574  $endingtime->setDate(new ilDateTime(time(), IL_CAL_UNIX));
1575  }
1576  $enableendingtime->addSubItem($endingtime);
1577  $form->addItem($enableendingtime);
1578 
1579  // test password
1580  $password = new ilTextInputGUI($this->lng->txt("tst_password"), "password");
1581  $password->setSize(20);
1582  $password->setValue($this->object->getPassword());
1583  $password->setInfo($this->lng->txt("tst_password_details"));
1584  $form->addItem($password);
1585 
1586  if(!$template || $template && $this->formShowPresentationSection($template_settings)) {
1587  // sequence properties
1588  $seqheader = new ilFormSectionHeaderGUI();
1589  $seqheader->setTitle($this->lng->txt("tst_presentation_properties"));
1590  $form->addItem($seqheader);
1591  }
1592 
1593  // use previous answers
1594  $prevanswers = new ilCheckboxInputGUI($this->lng->txt("tst_use_previous_answers"), "chb_use_previous_answers");
1595  $prevanswers->setValue(1);
1596  $prevanswers->setChecked($this->object->getUsePreviousAnswers());
1597  $prevanswers->setInfo($this->lng->txt("tst_use_previous_answers_description"));
1598  $form->addItem($prevanswers);
1599 
1600  // force js
1601  $forcejs = new ilCheckboxInputGUI($this->lng->txt("forcejs_short"), "forcejs");
1602  $forcejs->setValue(1);
1603  $forcejs->setChecked($this->object->getForceJS());
1604  $forcejs->setOptionTitle($this->lng->txt("forcejs"));
1605  $forcejs->setInfo($this->lng->txt("forcejs_desc"));
1606  $form->addItem($forcejs);
1607 
1608  // question title output
1609  $title_output = new ilRadioGroupInputGUI($this->lng->txt("tst_title_output"), "title_output");
1610  $title_output->addOption(new ilRadioOption($this->lng->txt("tst_title_output_full"), 0, ''));
1611  $title_output->addOption(new ilRadioOption($this->lng->txt("tst_title_output_hide_points"), 1, ''));
1612  $title_output->addOption(new ilRadioOption($this->lng->txt("tst_title_output_no_title"), 2, ''));
1613  $title_output->setValue($this->object->getTitleOutput());
1614  $title_output->setInfo($this->lng->txt("tst_title_output_description"));
1615  $form->addItem($title_output);
1616 
1617  if(!$template || $template && $this->formShowSequenceSection($template_settings)) {
1618  // sequence properties
1619  $seqheader = new ilFormSectionHeaderGUI();
1620  $seqheader->setTitle($this->lng->txt("tst_sequence_properties"));
1621  $form->addItem($seqheader);
1622  }
1623 
1624  // postpone questions
1625  $postpone = new ilCheckboxInputGUI($this->lng->txt("tst_postpone"), "chb_postpone");
1626  $postpone->setValue(1);
1627  $postpone->setChecked($this->object->getSequenceSettings());
1628  $postpone->setInfo($this->lng->txt("tst_postpone_description"));
1629  $form->addItem($postpone);
1630 
1631  // shuffle questions
1632  $shuffle = new ilCheckboxInputGUI($this->lng->txt("tst_shuffle_questions"), "chb_shuffle_questions");
1633  $shuffle->setValue(1);
1634  $shuffle->setChecked($this->object->getShuffleQuestions());
1635  $shuffle->setInfo($this->lng->txt("tst_shuffle_questions_description"));
1636  $form->addItem($shuffle);
1637 
1638  // show list of questions
1639  $list_of_questions = new ilCheckboxInputGUI($this->lng->txt("tst_show_summary"), "list_of_questions");
1640  //$list_of_questions->setOptionTitle($this->lng->txt("tst_show_summary"));
1641  $list_of_questions->setValue(1);
1642  $list_of_questions->setChecked($this->object->getListOfQuestions());
1643  $list_of_questions->setInfo($this->lng->txt("tst_show_summary_description"));
1644 
1645  $list_of_questions_options = new ilCheckboxGroupInputGUI('', "list_of_questions_options");
1646  $list_of_questions_options->addOption(new ilCheckboxOption($this->lng->txt("tst_list_of_questions_start"), 'chb_list_of_questions_start', ''));
1647  $list_of_questions_options->addOption(new ilCheckboxOption($this->lng->txt("tst_list_of_questions_end"), 'chb_list_of_questions_end', ''));
1648  $list_of_questions_options->addOption(new ilCheckboxOption($this->lng->txt("tst_list_of_questions_with_description"), 'chb_list_of_questions_with_description', ''));
1649  $values = array();
1650  if ($this->object->getListOfQuestionsStart()) array_push($values, 'chb_list_of_questions_start');
1651  if ($this->object->getListOfQuestionsEnd()) array_push($values, 'chb_list_of_questions_end');
1652  if ($this->object->getListOfQuestionsDescription()) array_push($values, 'chb_list_of_questions_with_description');
1653  $list_of_questions_options->setValue($values);
1654 
1655  $list_of_questions->addSubItem($list_of_questions_options);
1656  $form->addItem($list_of_questions);
1657 
1658  // show question marking
1659  $marking = new ilCheckboxInputGUI($this->lng->txt("question_marking"), "chb_show_marker");
1660  $marking->setValue(1);
1661  $marking->setChecked($this->object->getShowMarker());
1662  $marking->setInfo($this->lng->txt("question_marking_description"));
1663  $form->addItem($marking);
1664 
1665  // show suspend test
1666  $cancel = new ilCheckboxInputGUI($this->lng->txt("tst_show_cancel"), "chb_show_cancel");
1667  $cancel->setValue(1);
1668  $cancel->setChecked($this->object->getShowCancel());
1669  $cancel->setInfo($this->lng->txt("tst_show_cancel_description"));
1670  $form->addItem($cancel);
1671 
1672  if(!$template || $template && $this->formShowNotificationSection($template_settings)) {
1673  // notifications
1674  $notifications = new ilFormSectionHeaderGUI();
1675  $notifications->setTitle($this->lng->txt("tst_mail_notification"));
1676  $form->addItem($notifications);
1677  }
1678 
1679  // mail notification
1680  $mailnotification = new ilRadioGroupInputGUI($this->lng->txt("tst_finish_notification"), "mailnotification");
1681  $mailnotification->addOption(new ilRadioOption($this->lng->txt("tst_finish_notification_no"), 0, ''));
1682  $mailnotification->addOption(new ilRadioOption($this->lng->txt("tst_finish_notification_simple"), 1, ''));
1683  $mailnotification->addOption(new ilRadioOption($this->lng->txt("tst_finish_notification_advanced"), 2, ''));
1684  $mailnotification->setValue($this->object->getMailNotification());
1685  $form->addItem($mailnotification);
1686 
1687  $mailnottype = new ilCheckboxInputGUI('', "mailnottype");
1688  $mailnottype->setValue(1);
1689  $mailnottype->setOptionTitle($this->lng->txt("mailnottype"));
1690  $mailnottype->setChecked($this->object->getMailNotificationType());
1691  $form->addItem($mailnottype);
1692 
1693 
1694  if(!$template || $template && $this->formShowKioskSection($template_settings)) {
1695  // kiosk mode properties
1696  $kioskheader = new ilFormSectionHeaderGUI();
1697  $kioskheader->setTitle($this->lng->txt("kiosk"));
1698  $form->addItem($kioskheader);
1699  }
1700 
1701  // kiosk mode
1702  $kiosk = new ilCheckboxInputGUI($this->lng->txt("kiosk"), "kiosk");
1703  $kiosk->setValue(1);
1704  $kiosk->setChecked($this->object->getKioskMode());
1705  $kiosk->setInfo($this->lng->txt("kiosk_description"));
1706 
1707  // kiosk mode options
1708  $kiosktitle = new ilCheckboxGroupInputGUI($this->lng->txt("kiosk_options"), "kiosk_options");
1709  $kiosktitle->addOption(new ilCheckboxOption($this->lng->txt("kiosk_show_title"), 'kiosk_title', ''));
1710  $kiosktitle->addOption(new ilCheckboxOption($this->lng->txt("kiosk_show_participant"), 'kiosk_participant', ''));
1711  $values = array();
1712  if ($this->object->getShowKioskModeTitle()) array_push($values, 'kiosk_title');
1713  if ($this->object->getShowKioskModeParticipant()) array_push($values, 'kiosk_participant');
1714  $kiosktitle->setValue($values);
1715  $kiosktitle->setInfo($this->lng->txt("kiosk_options_desc"));
1716  $kiosk->addSubItem($kiosktitle);
1717 
1718  $form->addItem($kiosk);
1719 
1720  if(!$template || $template && $this->formShowParticipantSection($template_settings)) {
1721  // participants properties
1722  $restrictions = new ilFormSectionHeaderGUI();
1723  $restrictions->setTitle($this->lng->txt("tst_max_allowed_users"));
1724  $form->addItem($restrictions);
1725  }
1726 
1727  $fixedparticipants = new ilCheckboxInputGUI($this->lng->txt('participants_invitation'), "fixedparticipants");
1728  $fixedparticipants->setValue(1);
1729  $fixedparticipants->setChecked($this->object->getFixedParticipants());
1730  $fixedparticipants->setOptionTitle($this->lng->txt("tst_allow_fixed_participants"));
1731  $fixedparticipants->setInfo($this->lng->txt("participants_invitation_description"));
1732  $invited_users = $this->object->getInvitedUsers();
1733  if ($total && (count($invited_users) == 0))
1734  {
1735  $fixedparticipants->setDisabled(true);
1736  }
1737  $form->addItem($fixedparticipants);
1738 
1739 
1740  // simultaneous users
1741  $simul = new ilTextInputGUI($this->lng->txt("tst_allowed_users"), "allowedUsers");
1742  $simul->setSize(3);
1743  $simul->setValue(($this->object->getAllowedUsers()) ? $this->object->getAllowedUsers() : '');
1744  $form->addItem($simul);
1745 
1746  // idle time
1747  $idle = new ilTextInputGUI($this->lng->txt("tst_allowed_users_time_gap"), "allowedUsersTimeGap");
1748  $idle->setSize(4);
1749  $idle->setSuffix($this->lng->txt("seconds"));
1750  $idle->setValue(($this->object->getAllowedUsersTimeGap()) ? $this->object->getAllowedUsersTimeGap() : '');
1751  $form->addItem($idle);
1752 
1753  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) $form->addCommandButton("saveProperties", $this->lng->txt("save"));
1754 
1755  // remove items when using template
1756  if($template_settings)
1757  {
1758  foreach($template_settings as $id => $item)
1759  {
1760  if($item["hide"])
1761  {
1762  $form->removeItemByPostVar($id);
1763  }
1764  }
1765  }
1766 
1767  $errors = false;
1768 
1769  if ($save)
1770  {
1771  $errors = !$form->checkInput();
1772  $form->setValuesByPost();
1773  if( $online->getChecked() && !$this->object->isComplete() )
1774  {
1775  $online->setAlert($this->lng->txt("cannot_switch_to_online_no_questions_andor_no_mark_steps"));
1776  ilUtil::sendFailure($this->lng->txt('form_input_not_valid'));
1777  $errors = true;
1778  }
1779  if ($errors) $checkonly = false;
1780  }
1781 
1782  if (!$checkonly)
1783  {
1784  // using template?
1785  $message = "";
1786  if($template)
1787  {
1788  global $tpl;
1789 
1790  $link = $this->ctrl->getLinkTarget($this, "confirmResetTemplate");
1791  $link = "<a href=\"".$link."\">".$this->lng->txt("test_using_template_link")."</a>";
1792  $message = "<div style=\"margin-top:10px\">".
1793  $tpl->getMessageHTML(sprintf($this->lng->txt("test_using_template"), $template->getTitle(), $link), "info").
1794  "</div>";
1795  }
1796 
1797  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML().$message);
1798  }
1799 
1800  return $errors;
1801  }
1802 
1809  {
1810  if (!array_key_exists("tst_properties_confirmation", $_POST))
1811  {
1812  $hasErrors = $this->propertiesObject(true);
1813  }
1814  else
1815  {
1816  $hasErrors = false;
1817  }
1818  if (!$hasErrors)
1819  {
1820  $template_settings = null;
1821  $template = $this->object->getTemplate();
1822  if($template)
1823  {
1824  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
1826 
1827  $template_settings = $template->getSettings();
1828  }
1829 
1830 
1831 
1832  include_once 'Services/MetaData/classes/class.ilMD.php';
1833  $md_obj =& new ilMD($this->object->getId(), 0, "svy");
1834  $md_section = $md_obj->getGeneral();
1835 
1836  // title
1837  $md_section->setTitle(ilUtil::stripSlashes($_POST['title']));
1838  $md_section->update();
1839 
1840  // Description
1841  $md_desc_ids = $md_section->getDescriptionIds();
1842  if($md_desc_ids)
1843  {
1844  $md_desc = $md_section->getDescription(array_pop($md_desc_ids));
1845  $md_desc->setDescription(ilUtil::stripSlashes($_POST['description']));
1846  $md_desc->update();
1847  }
1848  else {
1849  $md_desc = $md_section->addDescription();
1850  $md_desc->setDescription(ilUtil::stripSlashes($_POST['description']));
1851  $md_desc->save();
1852  }
1853 
1854  $this->object->setTitle(ilUtil::stripSlashes($_POST['title']));
1855  $this->object->setDescription(ilUtil::stripSlashes($_POST['description']));
1856  $this->object->update();
1857 
1858  $total = $this->object->evalTotalPersons();
1859  $randomtest_switch = false;
1860  // Check the values the user entered in the form
1861  if (!$total)
1862  {
1863  if (!array_key_exists("tst_properties_confirmation", $_POST))
1864  {
1865  if (($this->object->isRandomTest()) && (count($this->object->getRandomQuestionpools()) > 0))
1866  {
1867  if (!$_POST["random_test"])
1868  {
1869  // user tries to change from a random test with existing random question pools to a non random test
1870  $this->confirmChangeProperties(0);
1871  return;
1872  }
1873  }
1874  if ((!$this->object->isRandomTest()) && (count($this->object->questions) > 0))
1875  {
1876  if ($_POST["random_test"])
1877  {
1878  // user tries to change from a non random test with existing questions to a random test
1879  $this->confirmChangeProperties(1);
1880  return;
1881  }
1882  }
1883  }
1884 
1885  if (!strlen($_POST["random_test"]))
1886  {
1887  $random_test = 0;
1888  }
1889  else
1890  {
1891  $random_test = $_POST["random_test"];
1892  }
1893  }
1894  else
1895  {
1896  $random_test = $this->object->isRandomTest();
1897  }
1898  if ($random_test != $this->object->isRandomTest())
1899  {
1900  $randomtest_switch = true;
1901  }
1902 
1903  // buffer online status sent by form in local variable and store
1904  // it to model after the following if block, because the new status
1905  // gets reset when random test setting is switched
1906  $online = $_POST["online"];
1907 
1908  if (!$total)
1909  {
1910  if( $randomtest_switch && $this->object->isOnline() && $online )
1911  {
1912  // reset online status that is stored to model later on
1913  // due to fact that the random test setting has been changed
1914  $online = false;
1915 
1916  $info = $this->lng->txt(
1917  "tst_set_offline_due_to_switched_random_test_setting"
1918  );
1919 
1920  ilUtil::sendInfo($info, true);
1921  }
1922 
1923  $this->object->setAnonymity($_POST["anonymity"]);
1924  $this->object->setRandomTest($random_test);
1925  $this->object->setNrOfTries($_POST["nr_of_tries"]);
1926  if ($_POST['chb_starting_time'])
1927  {
1928  $this->object->setStartingTime(ilFormat::dateDB2timestamp($_POST['starting_time']['date'] . ' ' . $_POST['starting_time']['time']));
1929  }
1930  else
1931  {
1932  $this->object->setStartingTime('');
1933  }
1934  }
1935 
1936  // store effective online status to model
1937  $this->object->setOnline($online);
1938 
1939  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
1940  $this->object->setIntroduction($_POST["introduction"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment"));
1941  $this->object->setShowInfo(($_POST["showinfo"]) ? 1 : 0);
1942  $this->object->setFinalStatement($_POST["finalstatement"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment"));
1943  $this->object->setShowFinalStatement(($_POST["showfinalstatement"]) ? 1 : 0);
1944  $this->object->setSequenceSettings(($_POST["chb_postpone"]) ? 1 : 0);
1945  $this->object->setShuffleQuestions(($_POST["chb_shuffle_questions"]) ? 1 : 0);
1946  $this->object->setListOfQuestions($_POST["list_of_questions"]);
1947  if (is_array($_POST["list_of_questions_options"]))
1948  {
1949  $this->object->setListOfQuestionsStart((in_array('chb_list_of_questions_start', $_POST["list_of_questions_options"])) ? 1 : 0);
1950  $this->object->setListOfQuestionsEnd((in_array('chb_list_of_questions_end', $_POST["list_of_questions_options"])) ? 1 : 0);
1951  $this->object->setListOfQuestionsDescription((in_array('chb_list_of_questions_with_description', $_POST["list_of_questions_options"])) ? 1 : 0);
1952  }
1953  else
1954  {
1955  $this->object->setListOfQuestionsStart(0);
1956  $this->object->setListOfQuestionsEnd(0);
1957  $this->object->setListOfQuestionsDescription(0);
1958  }
1959  $this->object->setMailNotification($_POST["mailnotification"]);
1960  $this->object->setMailNotificationType($_POST["mailnottype"]);
1961  $this->object->setShowMarker(($_POST["chb_show_marker"]) ? 1 : 0);
1962  $this->object->setShowCancel(($_POST["chb_show_cancel"]) ? 1 : 0);
1963  $this->object->setKioskMode(($_POST["kiosk"]) ? 1 : 0);
1964  $this->object->setShowKioskModeTitle((is_array($_POST["kiosk_options"]) && in_array('kiosk_title', $_POST["kiosk_options"])) ? 1 : 0);
1965  $this->object->setShowKioskModeParticipant((is_array($_POST["kiosk_options"]) && in_array('kiosk_participant', $_POST["kiosk_options"])) ? 1 : 0);
1966  $this->object->setEnableProcessingTime(($_POST["chb_processing_time"]) ? 1 : 0);
1967  if ($this->object->getEnableProcessingTime())
1968  {
1969  $this->object->setProcessingTime(sprintf("%02d:%02d:%02d",
1970  $_POST["processing_time"]["hh"],
1971  $_POST["processing_time"]["mm"],
1972  $_POST["processing_time"]["ss"]
1973  ));
1974  }
1975  else
1976  {
1977  $this->object->setProcessingTime('');
1978  }
1979  $this->object->setResetProcessingTime(($_POST["chb_reset_processing_time"]) ? 1 : 0);
1980  if ($_POST['chb_ending_time'])
1981  {
1982  $this->object->setEndingTime(ilFormat::dateDB2timestamp($_POST['ending_time']['date'] . ' ' . $_POST['ending_time']['time']));
1983  }
1984  else
1985  {
1986  $this->object->setEndingTime('');
1987  }
1988  $this->object->setUsePreviousAnswers(($_POST["chb_use_previous_answers"]) ? 1 : 0);
1989  $this->object->setForceJS(($_POST["forcejs"]) ? 1 : 0);
1990  $this->object->setTitleOutput($_POST["title_output"]);
1991  $this->object->setPassword($_POST["password"]);
1992  $this->object->setAllowedUsers($_POST["allowedUsers"]);
1993  $this->object->setAllowedUsersTimeGap($_POST["allowedUsersTimeGap"]);
1994 
1995  if ($this->object->isRandomTest())
1996  {
1997  $this->object->setUsePreviousAnswers(0);
1998  }
1999 
2000  $invited_users = $this->object->getInvitedUsers();
2001  if (!($total && (count($invited_users) == 0)))
2002  {
2003  $fixed_participants = 0;
2004  if (array_key_exists("fixedparticipants", $_POST))
2005  {
2006  if ($_POST["fixedparticipants"])
2007  {
2008  $fixed_participants = 1;
2009  }
2010  }
2011  $this->object->setFixedParticipants($fixed_participants);
2012  if (!$fixed_participants)
2013  {
2014  $invited_users = $this->object->getInvitedUsers();
2015  foreach ($invited_users as $user_object)
2016  {
2017  $this->object->disinviteUser($user_object["usr_id"]);
2018  }
2019  }
2020  }
2021 
2022  //$this->object->setExpressModeQuestionPoolAllowed($_POST['express_allow_question_pool']);
2023  $this->object->setEnabledViewMode($_POST['enabled_view_mode']);
2024  $this->object->setPoolUsage($_POST['use_pool']);
2025 
2026  $this->object->saveToDb(true);
2027 
2028  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
2029  if ($randomtest_switch)
2030  {
2031  if ($this->object->isRandomTest())
2032  {
2033  $this->object->removeNonRandomTestData();
2034  }
2035  else
2036  {
2037  $this->object->removeRandomTestData();
2038  }
2039  }
2040 
2041  $this->ctrl->redirect($this, 'properties');
2042  }
2043  }
2044 
2049  {
2050  $file = explode("_", $_GET["file_id"]);
2051  include_once("./Modules/File/classes/class.ilObjFile.php");
2052  $fileObj =& new ilObjFile($file[count($file) - 1], false);
2053  $fileObj->sendFile();
2054  exit;
2055  }
2056 
2060  function fullscreenObject()
2061  {
2062  include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
2063  //$page =& new ilPageObject("qpl", $_GET["pg_id"]);
2064  $page_gui =& new ilPageObjectGUI("qpl", $_GET["pg_id"]);
2065  $page_gui->showMediaFullscreen();
2066 
2067  }
2068 
2073  {
2074  include_once("./Services/COPage/classes/class.ilPageObject.php");
2075  $pg_obj =& new ilPageObject("qpl", $_GET["pg_id"]);
2076  $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
2077  exit;
2078  }
2079 
2087  function filterObject()
2088  {
2089  $this->questionBrowser();
2090  }
2091 
2100  {
2101  $this->questionBrowser();
2102  }
2103 
2111  function backObject()
2112  {
2113  $this->ctrl->redirect($this, "questions");
2114  }
2115 
2124  function createQuestionPool($name = "dummy", $description = "")
2125  {
2126  global $tree;
2127  $parent_ref = $tree->getParentId($this->object->getRefId());
2128  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
2129  $qpl = new ilObjQuestionPool();
2130  $qpl->setType("qpl");
2131  $qpl->setTitle($name);
2132  $qpl->setDescription($description);
2133  $qpl->create();
2134  $qpl->createReference();
2135  $qpl->putInTree($parent_ref);
2136  $qpl->setPermissions($parent_ref);
2137  $qpl->setOnline(1); // must be online to be available
2138  $qpl->saveToDb();
2139  return $qpl->getRefId();
2140  }
2141 
2145  public function randomselectObject()
2146  {
2147  global $ilUser;
2148  $this->getQuestionsSubTabs();
2149  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_random_select.html", "Modules/Test");
2150  $questionpools =& $this->object->getAvailableQuestionpools(FALSE, FALSE, FALSE, TRUE);
2151  $this->tpl->setCurrentBlock("option");
2152  $this->tpl->setVariable("VALUE_OPTION", "0");
2153  $this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("all_available_question_pools"));
2154  $this->tpl->parseCurrentBlock();
2155  foreach ($questionpools as $key => $value)
2156  {
2157  $this->tpl->setCurrentBlock("option");
2158  $this->tpl->setVariable("VALUE_OPTION", $key);
2159  $this->tpl->setVariable("TEXT_OPTION", $value["title"]);
2160  $this->tpl->parseCurrentBlock();
2161  }
2162  $this->tpl->setCurrentBlock("hidden");
2163  $this->tpl->setVariable("HIDDEN_NAME", "sel_question_types");
2164  $this->tpl->setVariable("HIDDEN_VALUE", $_POST["sel_question_types"]);
2165  $this->tpl->parseCurrentBlock();
2166  $this->tpl->setCurrentBlock("adm_content");
2167  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
2168  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_random_select_questionpool"));
2169  $this->tpl->setVariable("TXT_NR_OF_QUESTIONS", $this->lng->txt("tst_random_nr_of_questions"));
2170  $this->tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit"));
2171  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
2172  $this->tpl->parseCurrentBlock();
2173  }
2174 
2183  {
2184  $this->ctrl->redirect($this, "questions");
2185  }
2186 
2195  {
2196  $this->getQuestionsSubTabs();
2197  $question_array = $this->object->randomSelectQuestions($_POST["nr_of_questions"], $_POST["sel_qpl"]);
2198  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_random_question_offer.html", "Modules/Test");
2199  $color_class = array("tblrow1", "tblrow2");
2200  $counter = 0;
2201  $questionpools =& $this->object->getAvailableQuestionpools(true);
2202  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
2203  foreach ($question_array as $question_id)
2204  {
2205  $dataset = $this->object->getQuestionDataset($question_id);
2206  $this->tpl->setCurrentBlock("QTab");
2207  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
2208  $this->tpl->setVariable("QUESTION_TITLE", $dataset->title);
2209  $this->tpl->setVariable("QUESTION_COMMENT", $dataset->description);
2210  $this->tpl->setVariable("QUESTION_TYPE", assQuestion::_getQuestionTypeName($dataset->type_tag));
2211  $this->tpl->setVariable("QUESTION_AUTHOR", $dataset->author);
2212  $this->tpl->setVariable("QUESTION_POOL", $questionpools[$dataset->obj_fi]["title"]);
2213  $this->tpl->parseCurrentBlock();
2214  $counter++;
2215  }
2216  if (count($question_array) == 0)
2217  {
2218  $this->tpl->setCurrentBlock("Emptytable");
2219  $this->tpl->setVariable("TEXT_NO_QUESTIONS_AVAILABLE", $this->lng->txt("no_questions_available"));
2220  $this->tpl->parseCurrentBlock();
2221  }
2222  else
2223  {
2224  $this->tpl->setCurrentBlock("Selectionbuttons");
2225  $this->tpl->setVariable("BTN_YES", $this->lng->txt("random_accept_sample"));
2226  $this->tpl->setVariable("BTN_NO", $this->lng->txt("random_another_sample"));
2227  $this->tpl->parseCurrentBlock();
2228  }
2229  $chosen_questions = join($question_array, ",");
2230  $this->tpl->setCurrentBlock("adm_content");
2231  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
2232  $this->tpl->setVariable("QUESTION_TITLE", $this->lng->txt("tst_question_title"));
2233  $this->tpl->setVariable("QUESTION_COMMENT", $this->lng->txt("description"));
2234  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("tst_question_type"));
2235  $this->tpl->setVariable("QUESTION_AUTHOR", $this->lng->txt("author"));
2236  $this->tpl->setVariable("QUESTION_POOL", $this->lng->txt("qpl"));
2237  $this->tpl->setVariable("VALUE_CHOSEN_QUESTIONS", $chosen_questions);
2238  $this->tpl->setVariable("VALUE_QUESTIONPOOL_SELECTION", $_POST["sel_qpl"]);
2239  $this->tpl->setVariable("VALUE_NR_OF_QUESTIONS", $_POST["nr_of_questions"]);
2240  $this->tpl->setVariable("TEXT_QUESTION_OFFER", $this->lng->txt("tst_question_offer"));
2241  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
2242  $this->tpl->parseCurrentBlock();
2243  }
2244 
2253  {
2254  $selected_array = split(",", $_POST["chosen_questions"]);
2255  if (!count($selected_array))
2256  {
2257  ilUtil::sendInfo($this->lng->txt("tst_insert_missing_question"));
2258  }
2259  else
2260  {
2261  $total = $this->object->evalTotalPersons();
2262  if ($total)
2263  {
2264  // the test was executed previously
2265  ilUtil::sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total));
2266  }
2267  else
2268  {
2269  ilUtil::sendInfo($this->lng->txt("tst_insert_questions"));
2270  }
2271  foreach ($selected_array as $key => $value)
2272  {
2273  $this->object->insertQuestion($value);
2274  }
2275  $this->object->saveCompleteStatus();
2276  ilUtil::sendSuccess($this->lng->txt("tst_questions_inserted"), true);
2277  $this->ctrl->redirect($this, "questions");
2278  return;
2279  }
2280  }
2281 
2283  {
2284  $this->randomQuestionsObject();
2285  }
2286 
2293  function writeRandomQuestionInput($always = false)
2294  {
2295  $hasErrors = (!$always) ? $this->randomQuestionsObject(true) : false;
2296  if (!$hasErrors)
2297  {
2298  global $ilUser;
2299  $ilUser->setPref("tst_question_selection_mode_equal", ($_POST['chbQuestionSelectionMode']) ? 1 : 0);
2300  $ilUser->writePref("tst_question_selection_mode_equal", ($_POST['chbQuestionSelectionMode']) ? 1 : 0);
2301  $this->object->setRandomQuestionCount($_POST['total_questions']);
2302  if (is_array($_POST['source']['qpl']) && count(array_unique($_POST['source']['qpl'])) == count($_POST['source']['qpl']))
2303  {
2304  $data = array();
2305  include_once "./Modules/Test/classes/class.ilRandomTestData.php";
2306  foreach ($_POST['source']['qpl'] as $idx => $qpl)
2307  {
2308  array_push($data, new ilRandomTestData($_POST['source']['count'][$idx], $qpl));
2309  }
2310  $this->object->setRandomQuestionpoolData($data);
2311  }
2312  return 0;
2313  }
2314  return 1;
2315  }
2316 
2318  {
2319  if ($this->writeRandomQuestionInput() == 0)
2320  {
2321  $this->object->saveRandomQuestionCount($this->object->getRandomQuestionCount());
2322  $this->object->saveRandomQuestionpools();
2323  $this->object->saveCompleteStatus();
2324  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
2325  $this->ctrl->redirect($this, 'randomQuestions');
2326  }
2327  }
2328 
2329  function addsourceObject()
2330  {
2331  $this->writeRandomQuestionInput(true);
2332  $position = key($_POST['cmd']['addsource']);
2333  $this->object->addRandomQuestionpoolData(0, 0, $position+1);
2334  $this->randomQuestionsObject();
2335  }
2336 
2338  {
2339  $this->writeRandomQuestionInput(true);
2340  $position = key($_POST['cmd']['removesource']);
2341  $this->object->removeRandomQuestionpoolData($position);
2342  $this->randomQuestionsObject();
2343  }
2344 
2346  {
2347  global $ilUser;
2348 
2349  $total = $this->object->evalTotalPersons();
2350  $save = (strcmp($this->ctrl->getCmd(), "saveRandomQuestions") == 0) ? TRUE : FALSE;
2351 
2352  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
2353  $form = new ilPropertyFormGUI();
2354  $form->setFormAction($this->ctrl->getFormAction($this, 'randomQuestions'));
2355  $form->setTitle($this->lng->txt('random_selection'));
2356  $form->setDescription($this->lng->txt('tst_select_random_questions'));
2357  $form->setMultipart(FALSE);
2358  $form->setTableWidth("100%");
2359  $form->setId("randomSelectionForm");
2360 
2361  // question selection
2362  $selection_mode = ($save) ? $_POST['chbQuestionSelectionMode'] : $ilUser->getPref("tst_question_selection_mode_equal");
2363  $question_selection = new ilCheckboxInputGUI($this->lng->txt("tst_question_selection"), "chbQuestionSelectionMode");
2364  $question_selection->setValue(1);
2365  $question_selection->setChecked($selection_mode);
2366  $question_selection->setOptionTitle($this->lng->txt('tst_question_selection_equal'));
2367  $question_selection->setInfo($this->lng->txt('tst_question_selection_description'));
2368  $question_selection->setRequired(false);
2369  $form->addItem($question_selection);
2370 
2371  // total amount of questions
2372  $total_questions = new ilNumberInputGUI($this->lng->txt('tst_total_questions'), 'total_questions');
2373  $total_questions->setValue($this->object->getRandomQuestionCount());
2374  $total_questions->setSize(3);
2375  $total_questions->setInfo($this->lng->txt('tst_total_questions_description'));
2376  $total_questions->setRequired(false);
2377  $form->addItem($total_questions);
2378 
2379  if ($total == 0)
2380  {
2381  $found_qpls = $this->object->getRandomQuestionpoolData();
2382  include_once "./Modules/Test/classes/class.ilRandomTestData.php";
2383  if (count($found_qpls) == 0)
2384  {
2385  array_push($found_qpls, new ilRandomTestData());
2386  }
2387  $available_qpl =& $this->object->getAvailableQuestionpools(TRUE, $selection_mode, FALSE, TRUE, TRUE);
2388  include_once './Modules/Test/classes/class.ilRandomTestInputGUI.php';
2389  $source = new ilRandomTestInputGUI($this->lng->txt('tst_random_questionpools'), 'source');
2390  $source->setUseEqualPointsOnly($selection_mode);
2391  $source->setRandomQuestionPools($available_qpl);
2392  $source->setUseQuestionCount((array_key_exists('total_questions', $_POST)) ? ($_POST['total_questions'] < 1) : ($this->object->getRandomQuestionCount() < 1));
2393  $source->setValues($found_qpls);
2394  $form->addItem($source);
2395  }
2396  else
2397  {
2398  $qpls = $this->object->getUsedRandomQuestionpools();
2399  include_once './Modules/Test/classes/class.ilRandomTestROInputGUI.php';
2400  $source = new ilRandomTestROInputGUI($this->lng->txt('tst_random_questionpools'), 'source');
2401  $source->setValues($qpls);
2402  $form->addItem($source);
2403  }
2404 
2405  if ($total == 0) $form->addCommandButton("saveRandomQuestions", $this->lng->txt("save"));
2406 
2407  $errors = false;
2408 
2409  if ($save)
2410  {
2411  $form->setValuesByPost();
2412  $errors = !$form->checkInput();
2413  if (!$errors)
2414  {
2415  // check total amount of questions
2416  if ($_POST['total_questions'] > 0)
2417  {
2418  $totalcount = 0;
2419  foreach ($_POST['source']['qpl'] as $idx => $qpl)
2420  {
2421  $totalcount += $available_qpl[$qpl]['count'];
2422  }
2423  if ($_POST['total_questions'] > $totalcount)
2424  {
2425  $total_questions->setAlert($this->lng->txt('msg_total_questions_too_high'));
2426  $errors = true;
2427  }
2428  }
2429  }
2430  if ($errors) $checkonly = false;
2431  }
2432 
2433  if (!$checkonly) $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
2434  return $errors;
2435  }
2436 
2438  {
2439  global $ilUser;
2440  if ($_POST["chbQuestionSelectionMode"])
2441  {
2442  $ilUser->setPref("tst_question_selection_mode_equal", 1);
2443  $ilUser->writePref("tst_question_selection_mode_equal", 1);
2444  }
2445  else
2446  {
2447  $ilUser->setPref("tst_question_selection_mode_equal", 0);
2448  $ilUser->writePref("tst_question_selection_mode_equal", 0);
2449  }
2450  $this->randomQuestionsObject();
2451  }
2452 
2454  {
2455  $this->questionBrowser();
2456  }
2457 
2466  {
2467  $qpl_ref_id = $_REQUEST["sel_qpl"];
2468 
2469  $qpl_mode = $_REQUEST['usage'];
2470 
2471  if (!$qpl_mode || ($qpl_mode == 2 && strcmp($_REQUEST["txt_qpl"], "") == 0) || ($qpl_mode == 3 && strcmp($qpl_ref_id, "") == 0))
2472  //if ((strcmp($_REQUEST["txt_qpl"], "") == 0) && (strcmp($qpl_ref_id, "") == 0))
2473  {
2474  ilUtil::sendInfo($this->lng->txt("questionpool_not_entered"));
2475  $this->createQuestionObject();
2476  return;
2477  }
2478  else
2479  {
2480  $_SESSION["test_id"] = $this->object->getRefId();
2481  if ($qpl_mode == 2 && strcmp($_REQUEST["txt_qpl"], "") != 0)
2482  {
2483  // create a new question pool and return the reference id
2484  $qpl_ref_id = $this->createQuestionPool($_REQUEST["txt_qpl"]);
2485  }
2486  else if ($qpl_mode == 1)
2487  {
2488  $qpl_ref_id = $_GET["ref_id"];
2489  }
2490 
2491  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPoolGUI.php";
2492 
2493  $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"];
2494 
2495  if ($_REQUEST['q_id']) {
2496  $baselink .= '&q_id=' . $_REQUEST['q_id'];
2497  }
2498  if ($_REQUEST['prev_qid']) {
2499  $baselink .= '&prev_qid=' . $_REQUEST['prev_qid'];
2500  }
2501  if ($_REQUEST['test_express_mode']) {
2502  $baselink .= '&test_express_mode=1';
2503  }
2504 #var_dump($_REQUEST['prev_qid']);
2505  ilUtil::redirect($baselink);
2506 
2507  exit();
2508  }
2509  }
2510 
2519  {
2520  $this->ctrl->redirect($this, "questions");
2521  }
2522 
2531  {
2532  global $ilUser;
2533  $this->getQuestionsSubTabs();
2534  //$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_qpl_select.html", "Modules/Test");
2535  $questionpools =& $this->object->getAvailableQuestionpools(FALSE, FALSE, FALSE, TRUE, FALSE, "write");
2536  if ($this->object->getPoolUsage()) {
2537  global $lng, $ilCtrl, $tpl;
2538 
2539  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
2540 
2541  $form = new ilPropertyFormGUI();
2542  $form->setFormAction($ilCtrl->getFormAction($this, "executeCreateQuestion"));
2543  $form->setTitle($lng->txt("test_create_question"));
2544  include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
2545 
2546 
2547  $hidden = new ilHiddenInputGUI('sel_question_types');
2548  $hidden->setValue($_REQUEST["sel_question_types"]);
2549  $form->addItem($hidden);
2550 
2551  // use pool
2552  $usage = new ilRadioGroupInputGUI($this->lng->txt("assessment_pool_selection"), "usage");
2553  $usage->setRequired(true);
2554  $no_pool = new ilRadioOption($this->lng->txt("assessment_no_pool"), 1);
2555  $usage->addOption($no_pool);
2556  $existing_pool = new ilRadioOption($this->lng->txt("assessment_existing_pool"), 3);
2557  $usage->addOption($existing_pool);
2558  $new_pool = new ilRadioOption($this->lng->txt("assessment_new_pool"), 2);
2559  $usage->addOption($new_pool);
2560  $form->addItem($usage);
2561 
2562  $usage->setValue(1);
2563 
2564  $questionpools = ilObjQuestionPool::_getAvailableQuestionpools(FALSE, FALSE, TRUE, FALSE, FALSE, "write");
2565  $pools_data = array();
2566  foreach($questionpools as $key => $p) {
2567  $pools_data[$key] = $p['title'];
2568  }
2569  $pools = new ilSelectInputGUI($this->lng->txt("select_questionpool"), "sel_qpl");
2570  $pools->setOptions($pools_data);
2571  $existing_pool->addSubItem($pools);
2572 
2573 
2574  $name = new ilTextInputGUI($this->lng->txt("cat_create_qpl"), "txt_qpl");
2575  $name->setSize(50);
2576  $name->setMaxLength(50);
2577  $new_pool->addSubItem($name);
2578 
2579  $form->addCommandButton("executeCreateQuestion", $lng->txt("submit"));
2580  $form->addCommandButton("cancelCreateQuestion", $lng->txt("cancel"));
2581 
2582  return $this->tpl->setVariable('ADM_CONTENT', $form->getHTML());
2583 
2584  }
2585  else {
2586  global $ilCtrl;
2587 
2588  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'sel_question_types', $_REQUEST["sel_question_types"]);
2589  $link = $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'handleToolbarCommand','',false,false);
2590  ilUtil::redirect($link);
2591  }
2592  }
2593 
2602  {
2603  ilUtil::sendSuccess($this->lng->txt("tst_questions_removed"));
2604  $checked_questions = array();
2605 
2606  foreach ($_POST as $key => $value) {
2607  if (preg_match("/id_(\d+)/", $key, $matches)) {
2608  array_push($checked_questions, $matches[1]);
2609  }
2610  }
2611 
2612  $questions = $this->object->getQuestionTitlesAndIndexes();
2613  $first = null;
2614 
2615  foreach ($checked_questions as $key => $value) {
2616  if (!$first)
2617  $first = $value;
2618  $this->object->removeQuestion($value);
2619  }
2620  $this->object->saveCompleteStatus();
2621 
2622  if ($_REQUEST['test_express_mode']) {
2623 
2624  //$questions = $this->object->getQuestionTitlesAndIndexes();
2625  $prev = null;
2626  foreach($questions as $key => $value) {
2627  if ($prev === null) {
2628  $prev = $key;
2629  continue;
2630  }
2631  if ($key == $first) {
2632  $return_to = $prev;
2633  }
2634  $prev = $key;
2635  }
2636 
2637  if (count($questions) == count($checked_questions)) {
2638  $this->ctrl->redirect($this, "showPage");
2639  }
2640  else if (!$return_to)
2641  $return_to = $questions[0];
2642 
2643  $this->ctrl->setParameter($this, 'q_id', $return_to);
2644  $this->ctrl->redirect($this, "showPage");
2645  }
2646  else {
2647  $this->ctrl->redirect($this, "questions");
2648  }
2649  }
2650 
2659  {
2660  if ($_REQUEST['test_express_mode']) {
2661  $this->ctrl->setParameter($this, 'q_id', $_REQUEST['q_id']);
2662  $this->ctrl->redirect($this, "showPage");
2663  }
2664  else {
2665  $this->ctrl->redirect($this, "questions");
2666  }
2667  }
2668 
2676  function removeQuestionsForm($checked_questions)
2677  {
2678  ilUtil::sendInfo();
2679  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_remove_questions.html", "Modules/Test");
2680  $removablequestions =& $this->object->getTestQuestions();
2681  $colors = array("tblrow1", "tblrow2");
2682  $counter = 0;
2683  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
2684  if (count($removablequestions))
2685  {
2686  foreach ($removablequestions as $data)
2687  {
2688  if (in_array($data["question_id"], $checked_questions))
2689  {
2690  $this->tpl->setCurrentBlock("row");
2691  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
2692  $this->tpl->setVariable("TXT_TITLE", $data["title"]);
2693  $this->tpl->setVariable("TXT_DESCRIPTION", $data["description"]);
2694  $this->tpl->setVariable("TXT_TYPE", assQuestion::_getQuestionTypeName($data["type_tag"]));
2695  $this->tpl->parseCurrentBlock();
2696  $counter++;
2697  }
2698  }
2699  }
2700  foreach ($checked_questions as $id)
2701  {
2702  $this->tpl->setCurrentBlock("hidden");
2703  $this->tpl->setVariable("HIDDEN_NAME", "id_$id");
2704  $this->tpl->setVariable("HIDDEN_VALUE", "1");
2705  $this->tpl->parseCurrentBlock();
2706  }
2707 
2708  $this->tpl->setCurrentBlock("adm_content");
2709  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("tst_question_title"));
2710  $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("description"));
2711  $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("tst_question_type"));
2712  $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
2713  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
2714 
2715  $this->ctrl->saveParameter($this, 'test_express_mode');
2716  $this->ctrl->saveParameter($this, 'q_id');
2717 
2718  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
2719  $this->tpl->parseCurrentBlock();
2720  }
2721 
2730  {
2731  $this->getQuestionsSubTabs();
2732  $checked_questions = $_REQUEST["q_id"];
2733  if (!is_array($checked_questions) && $checked_questions) {
2734  $checked_questions = array($checked_questions);
2735  }
2736  if (count($checked_questions) > 0)
2737  {
2738  $total = $this->object->evalTotalPersons();
2739  if ($total)
2740  {
2741  // the test was executed previously
2742  ilUtil::sendInfo(sprintf($this->lng->txt("tst_remove_questions_and_results"), $total));
2743  }
2744  else
2745  {
2746  if (count($checked_questions) == 1)
2747  ilUtil::sendQuestion($this->lng->txt("tst_remove_question"));
2748  else
2749  ilUtil::sendQuestion($this->lng->txt("tst_remove_questions"));
2750  }
2751  $this->removeQuestionsForm($checked_questions);
2752  return;
2753  }
2754  elseif (count($checked_questions) == 0)
2755  {
2756  ilUtil::sendInfo($this->lng->txt("tst_no_question_selected_for_removal"), true);
2757  $this->ctrl->redirect($this, "questions");
2758  }
2759  }
2760 
2765  {
2766  $_SESSION['tst_qst_move_' . $this->object->getTestId()] = $_POST['q_id'];
2767  ilUtil::sendSuccess($this->lng->txt("msg_selected_for_move"), true);
2768  $this->ctrl->redirect($this, 'questions');
2769  }
2770 
2775  {
2776  // get all questions to move
2777  $move_questions = $_SESSION['tst_qst_move_' . $this->object->getTestId()];
2778 
2779  if (count($_POST['q_id']) == 0)
2780  {
2781  ilUtil::sendFailure($this->lng->txt("no_target_selected_for_move"), true);
2782  $this->ctrl->redirect($this, 'questions');
2783  }
2784  if (count($_POST['q_id']) > 1)
2785  {
2786  ilUtil::sendFailure($this->lng->txt("too_many_targets_selected_for_move"), true);
2787  $this->ctrl->redirect($this, 'questions');
2788  }
2789  $insert_mode = 0;
2790  $this->object->moveQuestions($_SESSION['tst_qst_move_' . $this->object->getTestId()], $_POST['q_id'][0], $insert_mode);
2791  ilUtil::sendSuccess($this->lng->txt("msg_questions_moved"), true);
2792  unset($_SESSION['tst_qst_move_' . $this->object->getTestId()]);
2793  $this->ctrl->redirect($this, "questions");
2794  }
2795 
2799  public function insertQuestionsAfterObject()
2800  {
2801  // get all questions to move
2802  $move_questions = $_SESSION['tst_qst_move_' . $this->object->getTestId()];
2803  if (count($_POST['q_id']) == 0)
2804  {
2805  ilUtil::sendFailure($this->lng->txt("no_target_selected_for_move"), true);
2806  $this->ctrl->redirect($this, 'questions');
2807  }
2808  if (count($_POST['q_id']) > 1)
2809  {
2810  ilUtil::sendFailure($this->lng->txt("too_many_targets_selected_for_move"), true);
2811  $this->ctrl->redirect($this, 'questions');
2812  }
2813  $insert_mode = 1;
2814  $this->object->moveQuestions($_SESSION['tst_qst_move_' . $this->object->getTestId()], $_POST['q_id'][0], $insert_mode);
2815  ilUtil::sendSuccess($this->lng->txt("msg_questions_moved"), true);
2816  unset($_SESSION['tst_qst_move_' . $this->object->getTestId()]);
2817  $this->ctrl->redirect($this, "questions");
2818  }
2819 
2826  {
2827  $selected_array = (is_array($_POST['q_id'])) ? $_POST['q_id'] : array();
2828  if (!count($selected_array))
2829  {
2830  ilUtil::sendInfo($this->lng->txt("tst_insert_missing_question"), true);
2831  $this->ctrl->redirect($this, "browseForQuestions");
2832  }
2833  else
2834  {
2835  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
2836  $manscoring = FALSE;
2837  foreach ($selected_array as $key => $value)
2838  {
2839  $this->object->insertQuestion($value);
2840  if (!$manscoring)
2841  {
2842  $manscoring = $manscoring | assQuestion::_needsManualScoring($value);
2843  }
2844  }
2845  $this->object->saveCompleteStatus();
2846  if ($manscoring)
2847  {
2848  ilUtil::sendInfo($this->lng->txt("manscoring_hint"), TRUE);
2849  }
2850  else
2851  {
2852  ilUtil::sendSuccess($this->lng->txt("tst_questions_inserted"), TRUE);
2853  }
2854  $this->ctrl->redirect($this, "questions");
2855  return;
2856  }
2857  }
2858 
2860  {
2861  include_once "./Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php";
2862  $table_gui = new ilTestQuestionBrowserTableGUI($this, 'browseForQuestions');
2863  $table_gui->writeFilterToSession();
2864  $this->ctrl->redirect($this, "browseForQuestions");
2865  }
2866 
2868  {
2869  include_once "./Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php";
2870  $table_gui = new ilTestQuestionBrowserTableGUI($this, 'browseForQuestions');
2871  $table_gui->resetFilter();
2872  $this->ctrl->redirect($this, "browseForQuestions");
2873  }
2874 
2880  function questionBrowser()
2881  {
2882  global $ilAccess;
2883 
2884  $this->ctrl->setParameterByClass(get_class($this), "browse", "1");
2885 
2886  include_once "./Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php";
2887  $table_gui = new ilTestQuestionBrowserTableGUI($this, 'browseForQuestions', (($ilAccess->checkAccess("write", "", $this->ref_id) ? true : false)));
2888  $arrFilter = array();
2889  foreach ($table_gui->getFilterItems() as $item)
2890  {
2891  if ($item->getValue() !== false)
2892  {
2893  $arrFilter[$item->getPostVar()] = $item->getValue();
2894  }
2895  }
2896  $data = $this->object->getAvailableQuestions($arrFilter, 1);
2897  $table_gui->setData($data);
2898  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
2899  }
2900 
2901  function questionsObject()
2902  {
2903  global $ilAccess, $ilTabs;
2904 
2905  $ilTabs->activateTab('assQuestions');
2906 
2907  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
2908  {
2909  // allow only write access
2910  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
2911  $this->ctrl->redirect($this, "infoScreen");
2912  }
2913 
2914  if ($_GET['browse'])
2915  {
2916  return $this->questionbrowser();
2917  }
2918 
2919  $this->getQuestionsSubTabs();
2920  if ($this->object->isRandomTest())
2921  {
2922  $this->randomQuestionsObject();
2923  return;
2924  }
2925 
2926  if ($_GET["eqid"] && $_GET["eqpl"])
2927  {
2928  ilUtil::redirect("ilias.php?baseClass=ilObjQuestionPoolGUI&ref_id=" . $_GET["eqpl"] . "&cmd=editQuestionForTest&calling_test=".$_GET["ref_id"]."&q_id=" . $_GET["eqid"]);
2929  }
2930 
2931  if ($_GET["up"] > 0)
2932  {
2933  $this->object->questionMoveUp($_GET["up"]);
2934  }
2935  if ($_GET["down"] > 0)
2936  {
2937  $this->object->questionMoveDown($_GET["down"]);
2938  }
2939 
2940  if ($_GET["add"])
2941  {
2942  $selected_array = array();
2943  array_push($selected_array, $_GET["add"]);
2944  $total = $this->object->evalTotalPersons();
2945  if ($total)
2946  {
2947  // the test was executed previously
2948  ilUtil::sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total));
2949  }
2950  else
2951  {
2952  ilUtil::sendInfo($this->lng->txt("tst_insert_questions"));
2953  }
2954  $this->insertQuestions($selected_array);
2955  return;
2956  }
2957 
2958  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_questions.html", "Modules/Test");
2959 
2960  $total = $this->object->evalTotalPersons();
2961  if ($ilAccess->checkAccess("write", "", $this->ref_id))
2962  {
2963  if($total != 0)
2964  {
2965  $link = $this->ctrl->getLinkTarget($this, "participants");
2966  $link = "<a href=\"".$link."\">".$this->lng->txt("test_has_datasets_warning_page_view_link")."</a>";
2967  ilUtil::sendInfo($this->lng->txt("test_has_datasets_warning_page_view")." ".$link);
2968  }
2969  else {
2970  global $ilToolbar;
2971 
2972  $qtypes = array();
2973  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
2974  foreach (ilObjQuestionPool::_getQuestionTypes() as $trans => $data)
2975  {
2976  $qtypes[$data['type_tag']] = $trans;
2977  }
2978  $ilToolbar->setFormAction($this->ctrl->getFormAction($this));
2979  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
2980  $types = new ilSelectInputGUI($this->lng->txt("create_new"), "sel_question_types");
2981  $types->setOptions($qtypes);
2982 
2983  $ilToolbar->addInputItem($types);
2984  $ilToolbar->addFormButton($this->lng->txt("test_create_question"), "createQuestion");
2985 
2986  if ($this->object->getPoolUsage()) {
2987  $ilToolbar->addSeparator();
2988  $ilToolbar->addButton($this->lng->txt("tst_browse_for_questions"), $this->ctrl->getLinkTarget($this, 'browseForQuestions'));
2989  }
2990 
2991  $ilToolbar->addSeparator();
2992  $ilToolbar->addButton($this->lng->txt("random_selection"), $this->ctrl->getLinkTarget($this, "randomselect"));
2993  }
2994  }
2995 
2996  $this->tpl->setCurrentBlock("adm_content");
2997  include_once "./Modules/Test/classes/tables/class.ilTestQuestionsTableGUI.php";
2998  $checked_move = is_array($_SESSION['tst_qst_move_' . $this->object->getTestId()]) && (count($_SESSION['tst_qst_move_' . $this->object->getTestId()]));
2999  $table_gui = new ilTestQuestionsTableGUI($this, 'questions', (($ilAccess->checkAccess("write", "", $this->ref_id) ? true : false)), $checked_move, $total);
3000  $data = $this->object->getTestQuestions();
3001  $table_gui->setData($data);
3002  $this->tpl->setVariable('QUESTIONBROWSER', $table_gui->getHTML());
3003  $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this));
3004  $this->tpl->parseCurrentBlock();
3005  }
3006 
3007  function takenObject() {
3008  }
3009 
3018  {
3019  $this->saveMarkSchemaFormData();
3020  $this->object->mark_schema->addMarkStep();
3021  $this->marksObject();
3022  }
3023 
3032  {
3033  $this->object->mark_schema->flush();
3034  foreach ($_POST as $key => $value) {
3035  if (preg_match("/mark_short_(\d+)/", $key, $matches))
3036  {
3037  $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]"]));
3038  }
3039  }
3040  $this->object->ects_grades["A"] = $_POST["ects_grade_a"];
3041  $this->object->ects_grades["B"] = $_POST["ects_grade_b"];
3042  $this->object->ects_grades["C"] = $_POST["ects_grade_c"];
3043  $this->object->ects_grades["D"] = $_POST["ects_grade_d"];
3044  $this->object->ects_grades["E"] = $_POST["ects_grade_e"];
3045  if ($_POST["chbUseFX"])
3046  {
3047  $this->object->ects_fx = $_POST["percentFX"];
3048  }
3049  else
3050  {
3051  $this->object->ects_fx = "";
3052  }
3053  $this->object->ects_output = $_POST["chbECTS"];
3054  }
3055 
3064  {
3065  $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);
3066  $this->marksObject();
3067  }
3068 
3077  {
3078  $this->saveMarkSchemaFormData();
3079  $delete_mark_steps = array();
3080  foreach ($_POST as $key => $value) {
3081  if (preg_match("/cb_(\d+)/", $key, $matches)) {
3082  array_push($delete_mark_steps, $matches[1]);
3083  }
3084  }
3085  if (count($delete_mark_steps)) {
3086  $this->object->mark_schema->deleteMarkSteps($delete_mark_steps);
3087  } else {
3088  ilUtil::sendInfo($this->lng->txt("tst_delete_missing_mark"));
3089  }
3090  $this->marksObject();
3091  }
3092 
3101  {
3102  $this->ctrl->redirect($this, "marks");
3103  }
3104 
3112  function saveMarksObject()
3113  {
3114  try
3115  {
3116  $this->saveMarkSchemaFormData();
3117  $mark_check = $this->object->checkMarks();
3118  }
3119  catch (Exception $ex)
3120  {
3121  $mark_check = $this->lng->txt('mark_schema_invalid');
3122  }
3123 
3124  if ($mark_check !== true)
3125  {
3126  ilUtil::sendFailure($mark_check);
3127  }
3128  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)))
3129  {
3130  ilUtil::sendInfo($this->lng->txt("ects_fill_out_all_values"), true);
3131  }
3132  elseif (($_POST["ects_grade_a"] > 100) or ($_POST["ects_grade_a"] < 0))
3133  {
3134  ilUtil::sendInfo($this->lng->txt("ects_range_error_a"), true);
3135  }
3136  elseif (($_POST["ects_grade_b"] > 100) or ($_POST["ects_grade_b"] < 0))
3137  {
3138  ilUtil::sendInfo($this->lng->txt("ects_range_error_b"), true);
3139  }
3140  elseif (($_POST["ects_grade_c"] > 100) or ($_POST["ects_grade_c"] < 0))
3141  {
3142  ilUtil::sendInfo($this->lng->txt("ects_range_error_c"), true);
3143  }
3144  elseif (($_POST["ects_grade_d"] > 100) or ($_POST["ects_grade_d"] < 0))
3145  {
3146  ilUtil::sendInfo($this->lng->txt("ects_range_error_d"), true);
3147  }
3148  elseif (($_POST["ects_grade_e"] > 100) or ($_POST["ects_grade_e"] < 0))
3149  {
3150  ilUtil::sendInfo($this->lng->txt("ects_range_error_e"), true);
3151  }
3152  else
3153  {
3154  $this->object->mark_schema->saveToDb($this->object->getTestId());
3155  $this->object->saveCompleteStatus();
3156  if ($this->object->getReportingDate())
3157  {
3158  $fxpercent = "";
3159  if ($_POST["chbUseFX"])
3160  {
3161  $fxpercent = ilUtil::stripSlashes($_POST["percentFX"]);
3162  }
3163  $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"]));
3164  }
3165  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
3166  }
3167  $this->marksObject();
3168  }
3169 
3170  function marksObject()
3171  {
3172  global $ilAccess;
3173  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
3174  {
3175  // allow only write access
3176  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3177  $this->ctrl->redirect($this, "infoScreen");
3178  }
3179 
3180  if (!$this->object->canEditMarks())
3181  {
3182  ilUtil::sendInfo($this->lng->txt("cannot_edit_marks"));
3183  }
3184 
3185  $this->object->mark_schema->sort();
3186 
3187  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_marks.html", "Modules/Test");
3188  $marks = $this->object->mark_schema->mark_steps;
3189  $rows = array("tblrow1", "tblrow2");
3190  $counter = 0;
3191  foreach ($marks as $key => $value) {
3192  $this->tpl->setCurrentBlock("markrow");
3193  $this->tpl->setVariable("MARK_SHORT", $value->getShortName());
3194  $this->tpl->setVariable("MARK_OFFICIAL", $value->getOfficialName());
3195  $this->tpl->setVariable("MARK_PERCENTAGE", sprintf("%.2f", $value->getMinimumLevel()));
3196  $this->tpl->setVariable("MARK_PASSED", strtolower($this->lng->txt("tst_mark_passed")));
3197  $this->tpl->setVariable("MARK_ID", "$key");
3198  $this->tpl->setVariable("ROW_CLASS", $rows[$counter % 2]);
3199  if ($value->getPassed()) {
3200  $this->tpl->setVariable("MARK_PASSED_CHECKED", " checked=\"checked\"");
3201  }
3202  $this->tpl->parseCurrentBlock();
3203  $counter++;
3204  }
3205  if (count($marks) == 0)
3206  {
3207  $this->tpl->setCurrentBlock("Emptyrow");
3208  $this->tpl->setVariable("EMPTY_ROW", $this->lng->txt("tst_no_marks_defined"));
3209  $this->tpl->setVariable("ROW_CLASS", $rows[$counter % 2]);
3210  $this->tpl->parseCurrentBlock();
3211  }
3212  else
3213  {
3214  if ($ilAccess->checkAccess("write", "", $this->ref_id) && $this->object->canEditMarks())
3215  {
3216  $this->tpl->setCurrentBlock("selectall");
3217  $counter++;
3218  $this->tpl->setVariable("ROW_CLASS", $rows[$counter % 2]);
3219  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
3220  $this->tpl->parseCurrentBlock();
3221  $this->tpl->setCurrentBlock("Footer");
3222  $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\"/>");
3223  $this->tpl->setVariable("BUTTON_EDIT", $this->lng->txt("edit"));
3224  $this->tpl->setVariable("BUTTON_DELETE", $this->lng->txt("delete"));
3225  $this->tpl->parseCurrentBlock();
3226  }
3227  }
3228 
3229  if ($this->object->getReportingDate())
3230  {
3231  $this->tpl->setCurrentBlock("ects");
3232  if ($this->object->ects_output)
3233  {
3234  $this->tpl->setVariable("CHECKED_ECTS", " checked=\"checked\"");
3235  }
3236  $this->tpl->setVariable("TEXT_OUTPUT_ECTS_GRADES", $this->lng->txt("ects_output_of_ects_grades"));
3237  $this->tpl->setVariable("TEXT_ALLOW_ECTS_GRADES", $this->lng->txt("ects_allow_ects_grades"));
3238  $this->tpl->setVariable("TEXT_USE_FX", $this->lng->txt("ects_use_fx_grade"));
3239  if (preg_match("/\d+/", $this->object->ects_fx))
3240  {
3241  $this->tpl->setVariable("CHECKED_FX", " checked=\"checked\"");
3242  $this->tpl->setVariable("VALUE_PERCENT_FX", sprintf("value=\"%s\" ", $this->object->ects_fx));
3243  }
3244  $this->tpl->setVariable("TEXT_PERCENT", $this->lng->txt("ects_use_fx_grade_part2"));
3245  $this->tpl->setVariable("ECTS_GRADE", $this->lng->txt("ects_grade"));
3246  $this->tpl->setVariable("PERCENTILE", $this->lng->txt("percentile"));
3247  $this->tpl->setVariable("ECTS_GRADE_A", "A - " . $this->lng->txt("ects_grade_a_short"));
3248  $this->tpl->setVariable("VALUE_GRADE_A", $this->object->ects_grades["A"]);
3249  $this->tpl->setVariable("ECTS_GRADE_B", "B - " . $this->lng->txt("ects_grade_b_short"));
3250  $this->tpl->setVariable("VALUE_GRADE_B", $this->object->ects_grades["B"]);
3251  $this->tpl->setVariable("ECTS_GRADE_C", "C - " . $this->lng->txt("ects_grade_c_short"));
3252  $this->tpl->setVariable("VALUE_GRADE_C", $this->object->ects_grades["C"]);
3253  $this->tpl->setVariable("ECTS_GRADE_D", "D - " . $this->lng->txt("ects_grade_d_short"));
3254  $this->tpl->setVariable("VALUE_GRADE_D", $this->object->ects_grades["D"]);
3255  $this->tpl->setVariable("ECTS_GRADE_E", "E - " . $this->lng->txt("ects_grade_e_short"));
3256  $this->tpl->setVariable("VALUE_GRADE_E", $this->object->ects_grades["E"]);
3257 
3258  $this->tpl->parseCurrentBlock();
3259  }
3260 
3261  $this->tpl->setCurrentBlock("adm_content");
3262  $this->tpl->setVariable("ACTION_MARKS", $this->ctrl->getFormAction($this));
3263  $this->tpl->setVariable("HEADER_SHORT", $this->lng->txt("tst_mark_short_form"));
3264  $this->tpl->setVariable("HEADER_OFFICIAL", $this->lng->txt("tst_mark_official_form"));
3265  $this->tpl->setVariable("HEADER_PERCENTAGE", $this->lng->txt("tst_mark_minimum_level"));
3266  $this->tpl->setVariable("HEADER_PASSED", $this->lng->txt("tst_mark_passed"));
3267  if ($ilAccess->checkAccess("write", "", $this->ref_id) && $this->object->canEditMarks())
3268  {
3269  $this->tpl->setVariable("BUTTON_NEW", $this->lng->txt("tst_mark_create_new_mark_step"));
3270  $this->tpl->setVariable("BUTTON_NEW_SIMPLE", $this->lng->txt("tst_mark_create_simple_mark_schema"));
3271  $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
3272  $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
3273  }
3274  $this->tpl->parseCurrentBlock();
3275  }
3276 
3285  {
3286  $this->object->removeAllTestEditings();
3287 
3288  // Update lp status
3289  include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
3290  ilLPStatusWrapper::_refreshStatus($this->object->getId());
3291 
3292  ilUtil::sendSuccess($this->lng->txt("tst_all_user_data_deleted"), true);
3293  $this->ctrl->redirect($this, "participants");
3294  }
3295 
3304  {
3305  $active_ids = array();
3306  foreach ($_POST["chbUser"] as $active_id)
3307  {
3308  if ($this->object->getFixedParticipants())
3309  {
3310  array_push($active_ids, $this->object->getActiveIdOfUser($active_id));
3311  }
3312  else
3313  {
3314  array_push($active_ids, $active_id);
3315  }
3316  }
3317  $this->object->removeSelectedTestResults($active_ids);
3318 
3319  // Update lp status
3320  include_once './Services/Tracking/classes/class.ilLPStatusWrapper.php';
3321  ilLPStatusWrapper::_refreshStatus($this->object->getId());
3322 
3323  ilUtil::sendSuccess($this->lng->txt("tst_selected_user_data_deleted"), true);
3324  $this->ctrl->redirect($this, "participants");
3325  }
3326 
3335  {
3336  $this->ctrl->redirect($this, "participants");
3337  }
3338 
3347  {
3348  ilUtil::sendQuestion($this->lng->txt("confirm_delete_all_user_data"));
3349  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_maintenance.html", "Modules/Test");
3350 
3351  $this->tpl->setCurrentBlock("confirm_delete");
3352  $this->tpl->setVariable("BTN_CONFIRM_DELETE_ALL", $this->lng->txt("confirm"));
3353  $this->tpl->setVariable("BTN_CANCEL_DELETE_ALL", $this->lng->txt("cancel"));
3354  $this->tpl->parseCurrentBlock();
3355 
3356  $this->tpl->setCurrentBlock("adm_content");
3357  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
3358  $this->tpl->parseCurrentBlock();
3359  }
3360 
3364  public function deleteAllUserResultsObject()
3365  {
3366  ilUtil::sendQuestion($this->lng->txt("delete_all_user_data_confirmation"));
3367  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", "Modules/Test");
3368  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "participants"));
3369 
3370  // cancel/confirm button
3371  $buttons = array( "confirmDeleteAllUserResults" => $this->lng->txt("proceed"),
3372  "participants" => $this->lng->txt("cancel"));
3373  foreach ($buttons as $name => $value)
3374  {
3375  $this->tpl->setCurrentBlock("operation_btn");
3376  $this->tpl->setVariable("BTN_NAME",$name);
3377  $this->tpl->setVariable("BTN_VALUE",$value);
3378  $this->tpl->parseCurrentBlock();
3379  }
3380  }
3381 
3390  {
3391  if (count($_POST["chbUser"]) == 0)
3392  {
3393  ilUtil::sendInfo($this->lng->txt("select_one_user"), TRUE);
3394  $this->ctrl->redirect($this, "participants");
3395  }
3396  ilUtil::sendQuestion($this->lng->txt("confirm_delete_single_user_data"));
3397  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_maintenance.html", "Modules/Test");
3398 
3399  foreach ($_POST["chbUser"] as $key => $value)
3400  {
3401  $this->tpl->setCurrentBlock("hidden");
3402  $this->tpl->setVariable("USER_ID", $value);
3403  $this->tpl->parseCurrentBlock();
3404  }
3405 
3406  include_once './Services/User/classes/class.ilObjUser.php';
3407  $color_class = array("tblrow1", "tblrow2");
3408  $counter = 0;
3409  foreach ($_POST["chbUser"] as $key => $active_id)
3410  {
3411  if ($this->object->getFixedParticipants())
3412  {
3413  $user_id = $active_id;
3414  }
3415  else
3416  {
3417  $user_id = $this->object->_getUserIdFromActiveId($active_id);
3418  }
3419  $user = ilObjUser::_lookupName($user_id);
3420  $this->tpl->setCurrentBlock("row");
3421  $this->tpl->setVariable("USER_ICON", ilUtil::getImagePath("icon_usr.gif"));
3422  $this->tpl->setVariable("USER_ALT", $this->lng->txt("usr"));
3423  $this->tpl->setVariable("USER_TITLE", $this->lng->txt("usr"));
3424  if ($this->object->getAnonymity())
3425  {
3426  $this->tpl->setVariable("TXT_FIRSTNAME", "");
3427  $this->tpl->setVariable("TXT_LASTNAME", $this->lng->txt("unknown"));
3428  $this->tpl->setVariable("TXT_LOGIN", "");
3429  }
3430  else
3431  {
3432  $this->tpl->setVariable("TXT_FIRSTNAME", $user["firstname"]);
3433  if (strlen($user["lastname"]))
3434  {
3435  $this->tpl->setVariable("TXT_LASTNAME", $user["lastname"]);
3436  }
3437  else
3438  {
3439  $this->tpl->setVariable("TXT_LASTNAME", $this->lng->txt("deleted_user"));
3440  }
3441  $this->tpl->setVariable("TXT_LOGIN", ilObjUser::_lookupLogin($user_id));
3442  }
3443  $this->tpl->setVariable("ROW_CLASS", $color_class[$counter % 2]);
3444  $this->tpl->parseCurrentBlock();
3445  $counter++;
3446  }
3447  $this->tpl->setCurrentBlock("selectedusers");
3448  $this->tpl->setVariable("HEADER_TXT_FIRSTNAME", $this->lng->txt("firstname"));
3449  $this->tpl->setVariable("HEADER_TXT_LASTNAME", $this->lng->txt("lastname"));
3450  $this->tpl->setVariable("HEADER_TXT_LOGIN", $this->lng->txt("login"));
3451  $this->tpl->setVariable("BTN_CONFIRM_DELETE_SELECTED", $this->lng->txt("confirm"));
3452  $this->tpl->setVariable("BTN_CANCEL_DELETE_SELECTED", $this->lng->txt("cancel"));
3453  $this->tpl->parseCurrentBlock();
3454 
3455  $this->tpl->setCurrentBlock("adm_content");
3456  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
3457  $this->tpl->parseCurrentBlock();
3458  }
3459 
3467  function historyObject()
3468  {
3469  include_once "./Modules/Test/classes/tables/class.ilTestHistoryTableGUI.php";
3470  $table_gui = new ilTestHistoryTableGUI($this, 'history');
3471  $table_gui->setTestObject($this->object);
3472  include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
3473  $log =& ilObjAssessmentFolder::_getLog(0, time(), $this->object->getId(), TRUE);
3474  $table_gui->setData($log);
3475  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
3476  }
3477 
3478  function initImportForm($a_new_type)
3479  {
3480  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
3481  $form = new ilPropertyFormGUI();
3482  $form->setTarget("_top");
3483  $form->setFormAction($this->ctrl->getFormAction($this));
3484  $form->setTitle($this->lng->txt("import_tst"));
3485 
3486  // file
3487  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
3488  $fi = new ilFileInputGUI($this->lng->txt("import_file"), "xmldoc");
3489  $fi->setSuffixes(array("zip"));
3490  $fi->setRequired(true);
3491  $form->addItem($fi);
3492 
3493  // question pool
3494  include_once("./Modules/Test/classes/class.ilObjTest.php");
3495  $tst = new ilObjTest();
3496  $questionpools = $tst->getAvailableQuestionpools(TRUE, FALSE, TRUE, TRUE);
3497  if (count($questionpools))
3498  {
3499  $options = array("-1" => $this->lng->txt("dont_use_questionpool"));
3500  foreach ($questionpools as $key => $value)
3501  {
3502  $options[$key] = $value["title"];
3503  }
3504 
3505  $pool = new ilSelectInputGUI($this->lng->txt("select_questionpool"), "qpl");
3506  $pool->setOptions($options);
3507  $form->addItem($pool);
3508  }
3509 
3510  $form->addCommandButton("importFile", $this->lng->txt("import"));
3511  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
3512 
3513  return $form;
3514  }
3515 
3522  {
3523  $command = $_POST["command"];
3524  if (strlen($command))
3525  {
3526  $method = $command . "Object";
3527  if (method_exists($this, $method))
3528  {
3529  $this->$method();
3530  return;
3531  }
3532  }
3533  $this->ctrl->redirect($this, "participants");
3534  }
3535 
3542  {
3543  global $ilAccess, $ilToolbar, $lng;
3544 
3545  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
3546  {
3547  // allow only write access
3548  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3549  $this->ctrl->redirect($this, "infoScreen");
3550  }
3551 
3552  if ($this->object->getFixedParticipants())
3553  {
3554  // search button
3555  include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
3557  $this,
3558  $tb,
3559  array(
3560  'auto_complete_name' => $lng->txt('user'),
3561  'submit_name' => $lng->txt('add')
3562  )
3563  );
3564 
3565  // search button
3566  $ilToolbar->addButton($this->lng->txt("tst_search_users"),
3567  $this->ctrl->getLinkTargetByClass('ilRepositorySearchGUI','start'));
3568 
3569 
3570  $participants =& $this->object->getInvitedUsers();
3571  $rows = array();
3572  foreach ($participants as $data)
3573  {
3574  $maxpass = $this->object->_getMaxPass($data["active_id"]);
3575  if (!is_null($maxpass))
3576  {
3577  $maxpass += 1;
3578  }
3579  $access = "";
3580  if (strlen($data["active_id"]))
3581  {
3582  $last_access = $this->object->_getLastAccess($data["active_id"]);
3583  $access = $last_access;
3584  }
3585  $this->ctrl->setParameterByClass('iltestevaluationgui', 'active_id', $data['active_id']);
3586 
3587  if ($data['active_id'] == null) // if no active id is set, user is invitee not participant...
3588  {
3589  if ( strlen($data["firstname"].$data["lastname"]) == 0 )
3590  {
3591  $fullname = $lng->txt("deleted_user");
3592  }
3593  else
3594  {
3595  $fullname = trim($data["lastname"] . ", " . $data["firstname"] . " " . $data["title"]);
3596  }
3597  } else {
3598  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
3599  $fullname = ilObjTestAccess::_getParticipantData($data['active_id']);
3600  }
3601 
3602  array_push($rows, array(
3603  'usr_id' => $data["usr_id"],
3604  'active_id' => $data['active_id'],
3605  'login' => $data["login"],
3606  'clientip' => $data["clientip"],
3607  'firstname' => $data["firstname"],
3608  'lastname' => $data["lastname"],
3609  'name' => $fullname,
3610  'started' => ($data["active_id"] > 0) ? 1 : 0,
3611  'finished' => ($data["test_finished"] == 1) ? 1 : 0,
3612  'access' => $access,
3613  'maxpass' => $maxpass,
3614  'result' => $this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'outParticipantsResultsOverview')
3615  ));
3616  }
3617  include_once "./Modules/Test/classes/tables/class.ilTestFixedParticipantsTableGUI.php";
3618  $table_gui = new ilTestFixedParticipantsTableGUI($this, 'participants', $this->object->getAnonymity(), count($rows));
3619  $table_gui->setData($rows);
3620  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
3621  }
3622  else
3623  {
3624  $participants =& $this->object->getTestParticipants();
3625  $rows = array();
3626  foreach ($participants as $data)
3627  {
3628  $maxpass = $this->object->_getMaxPass($data["active_id"]);
3629  if (!is_null($maxpass))
3630  {
3631  $maxpass += 1;
3632  }
3633  $access = "";
3634  if (strlen($data["active_id"]))
3635  {
3636  $last_access = $this->object->_getLastAccess($data["active_id"]);
3637  $access = $last_access;
3638  }
3639  $this->ctrl->setParameterByClass('iltestevaluationgui', 'active_id', $data['active_id']);
3640  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
3641  $fullname = ilObjTestAccess::_getParticipantData($data['active_id']);
3642  array_push($rows, array(
3643  'usr_id' => $data["active_id"],
3644  'active_id' => $data['active_id'],
3645  'login' => $data["login"],
3646  'name' => $fullname,
3647  'firstname' => $data["firstname"],
3648  'lastname' => $data["lastname"],
3649  'started' => ($data["active_id"] > 0) ? 1 : 0,
3650  'finished' => ($data["test_finished"] == 1) ? 1 : 0,
3651  'access' => $access,
3652  'maxpass' => $maxpass,
3653  'result' => $this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'outParticipantsResultsOverview')
3654  ));
3655  }
3656  include_once "./Modules/Test/classes/tables/class.ilTestParticipantsTableGUI.php";
3657  $table_gui = new ilTestParticipantsTableGUI($this, 'participants', $this->object->getAnonymity(), count($rows));
3658  $table_gui->setData($rows);
3659  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
3660  }
3661  }
3662 
3669  {
3670  if (count($_POST))
3671  {
3672  $_SESSION["show_user_results"] = $_POST["chbUser"];
3673  }
3674  $this->showUserResults($show_pass_details = TRUE, $show_answers = TRUE, $show_reached_points = TRUE);
3675  }
3676 
3683  {
3684  if (count($_POST))
3685  {
3686  $_SESSION["show_user_results"] = $_POST["chbUser"];
3687  }
3688  $this->showUserResults($show_pass_details = FALSE, $show_answers = TRUE);
3689  }
3690 
3697  {
3698  if (count($_POST))
3699  {
3700  $_SESSION["show_user_results"] = $_POST["chbUser"];
3701  }
3702  $this->showUserResults($show_pass_details = TRUE, $show_answers = FALSE);
3703  }
3704 
3710  function showUserResults($show_pass_details, $show_answers, $show_reached_points = FALSE)
3711  {
3712  $template = new ilTemplate("tpl.il_as_tst_participants_result_output.html", TRUE, TRUE, "Modules/Test");
3713 
3714  if (count($_SESSION["show_user_results"]) == 0)
3715  {
3716  ilUtil::sendInfo($this->lng->txt("select_one_user"), TRUE);
3717  $this->ctrl->redirect($this, "participants");
3718  }
3719 
3720  include_once "./Modules/Test/classes/class.ilTestServiceGUI.php";
3721  $serviceGUI =& new ilTestServiceGUI($this->object);
3722  $count = 0;
3723  foreach ($_SESSION["show_user_results"] as $key => $active_id)
3724  {
3725  $count++;
3726  $results = "";
3727  if ($this->object->getFixedParticipants())
3728  {
3729  $active_id = $this->object->getActiveIdOfUser($active_id);
3730  }
3731  if ($active_id > 0)
3732  {
3733  $results = $serviceGUI->getResultsOfUserOutput($active_id, $this->object->_getResultPass($active_id), $show_pass_details, $show_answers, FALSE, $show_reached_points);
3734  }
3735  if ($count < count($_SESSION["show_user_results"]))
3736  {
3737  $template->touchBlock("break");
3738  }
3739  $template->setCurrentBlock("user_result");
3740  $template->setVariable("USER_RESULT", $results);
3741  $template->parseCurrentBlock();
3742  }
3743  $template->setVariable("BACK_TEXT", $this->lng->txt("back"));
3744  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "participants"));
3745  $template->setVariable("PRINT_TEXT", $this->lng->txt("print"));
3746  $template->setVariable("PRINT_URL", "javascript:window.print();");
3747 
3748  $this->tpl->setVariable("ADM_CONTENT", $template->get());
3749  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
3750  if ($this->object->getShowSolutionAnswersOnly())
3751  {
3752  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
3753  }
3754  }
3755 
3757  {
3758  if (is_array($_POST["chbUser"]))
3759  {
3760  foreach ($_POST["chbUser"] as $user_id)
3761  {
3762  $this->object->disinviteUser($user_id);
3763  }
3764  }
3765  else
3766  {
3767  ilUtil::sendInfo($this->lng->txt("select_one_user"), true);
3768  }
3769  $this->ctrl->redirect($this, "participants");
3770  }
3771 
3773  {
3774  if (is_array($_POST["chbUser"]))
3775  {
3776  foreach ($_POST["chbUser"] as $user_id)
3777  {
3778  $this->object->setClientIP($user_id, $_POST["clientip_".$user_id]);
3779  }
3780  }
3781  else
3782  {
3783  ilUtil::sendInfo($this->lng->txt("select_one_user"), true);
3784  }
3785  $this->ctrl->redirect($this, "participants");
3786  }
3787 
3795  function printobject()
3796  {
3797  global $ilAccess, $ilias;
3798  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
3799  {
3800  // allow only write access
3801  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3802  $this->ctrl->redirect($this, "infoScreen");
3803  }
3804  $this->getQuestionsSubTabs();
3805  $template = new ilTemplate("tpl.il_as_tst_print_test_confirm.html", TRUE, TRUE, "Modules/Test");
3806 
3807  include_once './Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
3808  if(ilRPCServerSettings::getInstance()->isEnabled())
3809  {
3810  $this->ctrl->setParameter($this, "pdf", "1");
3811  $template->setCurrentBlock("pdf_export");
3812  $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "print"));
3813  $this->ctrl->setParameter($this, "pdf", "");
3814  $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
3815  $template->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export"));
3816  $template->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")));
3817  $template->parseCurrentBlock();
3818  }
3819 
3820  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
3821 
3822  global $ilUser;
3823  $print_date = mktime(date("H"), date("i"), date("s"), date("m") , date("d"), date("Y"));
3824  $max_points= 0;
3825  $counter = 1;
3826 
3827  foreach ($this->object->questions as $question)
3828  {
3829  $template->setCurrentBlock("question");
3830  $question_gui = $this->object->createQuestionGUI("", $question);
3831  $template->setVariable("COUNTER_QUESTION", $counter.".");
3832  $template->setVariable("QUESTION_TITLE", ilUtil::prepareFormOutput($question_gui->object->getTitle()));
3833  if ($question_gui->object->getMaximumPoints() == 1)
3834  {
3835  $template->setVariable("QUESTION_POINTS", $question_gui->object->getMaximumPoints() . " " . $this->lng->txt("point"));
3836  }
3837  else
3838  {
3839  $template->setVariable("QUESTION_POINTS", $question_gui->object->getMaximumPoints() . " " . $this->lng->txt("points"));
3840  }
3841  $result_output = $question_gui->getSolutionOutput("", NULL, FALSE, TRUE, FALSE, $this->object->getShowSolutionFeedback());
3842  if (strlen($result_output) == 0) $result_output = $question_gui->getPreview(FALSE);
3843  $template->setVariable("SOLUTION_OUTPUT", $result_output);
3844  $template->parseCurrentBlock("question");
3845  $counter ++;
3846  $max_points += $question_gui->object->getMaximumPoints();
3847  }
3848 
3849  $template->setCurrentBlock("navigation_buttons");
3850  $template->setVariable("BUTTON_PRINT", $this->lng->txt("print"));
3851  $template->parseCurrentBlock();
3852 
3853  $template->setVariable("TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
3854  $template->setVariable("PRINT_TEST", ilUtil::prepareFormOutput($this->lng->txt("tst_print")));
3855  $template->setVariable("TXT_PRINT_DATE", ilUtil::prepareFormOutput($this->lng->txt("date")));
3856  $template->setVariable("VALUE_PRINT_DATE", ilUtil::prepareFormOutput(strftime("%c",$print_date)));
3857  $template->setVariable("TXT_MAXIMUM_POINTS", ilUtil::prepareFormOutput($this->lng->txt("tst_maximum_points")));
3858  $template->setVariable("VALUE_MAXIMUM_POINTS", ilUtil::prepareFormOutput($max_points));
3859 
3860  if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1))
3861  {
3862  $this->object->deliverPDFfromHTML($template->get(), $this->object->getTitle());
3863  }
3864  else
3865  {
3866  $this->tpl->setVariable("PRINT_CONTENT", $template->get());
3867  }
3868  }
3869 
3870  function addParticipantsObject($a_user_ids = array())
3871  {
3872  $countusers = 0;
3873  // add users
3874  if (is_array($a_user_ids))
3875  {
3876  $i = 0;
3877  foreach ($a_user_ids as $user_id)
3878  {
3879  $client_ip = $_POST["client_ip"][$i];
3880  $this->object->inviteUser($user_id, $client_ip);
3881  $countusers++;
3882  $i++;
3883  }
3884  }
3885  $message = "";
3886  if ($countusers)
3887  {
3888  $message = $this->lng->txt("tst_invited_selected_users");
3889  }
3890  if (strlen($message))
3891  {
3892  ilUtil::sendInfo($message, TRUE);
3893  }
3894  else
3895  {
3896  ilUtil::sendInfo($this->lng->txt("tst_invited_nobody"), TRUE);
3897  return false;
3898  }
3899 
3900  $this->ctrl->redirect($this, "participants");
3901  }
3902 
3908  function defaultsObject()
3909  {
3910  global $ilUser;
3911  global $ilAccess;
3912 
3913  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
3914  {
3915  // allow only write access
3916  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3917  $this->ctrl->redirect($this, "infoScreen");
3918  }
3919 
3920  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_defaults.html", "Modules/Test");
3921 
3922  $maxentries = $ilUser->getPref("hits_per_page");
3923  if ($maxentries < 1)
3924  {
3925  $maxentries = 9999;
3926  }
3927 
3928  $offset = $_GET["offset"] ? $_GET["offset"] : 0;
3929  $sortby = $_GET["sort_by"] ? $_GET["sort_by"] : "name";
3930  $sortorder = $_GET["sort_order"] ? $_GET["sort_order"] : "asc";
3931 
3932  $defaults =& $this->object->getAvailableDefaults($sortby, $sortorder);
3933  if (count($defaults) > 0)
3934  {
3935  $tablerows = array();
3936  foreach ($defaults as $row)
3937  {
3938  array_push($tablerows, array("checkbox" => "<input type=\"checkbox\" name=\"chb_defaults[]\" value=\"" . $row["test_defaults_id"] . "\"/>", "name" => $row["name"]));
3939  }
3940  $headervars = array("", "name");
3941 
3942  include_once "./Services/Table/classes/class.ilTableGUI.php";
3943  $tbl = new ilTableGUI(0, FALSE);
3944  $tbl->setTitle($this->lng->txt("tst_defaults_available"));
3945  $header_names = array(
3946  "",
3947  $this->lng->txt("title")
3948  );
3949  $tbl->setHeaderNames($header_names);
3950 
3951  $tbl->disable("sort");
3952  $tbl->disable("auto_sort");
3953  $tbl->enable("title");
3954  $tbl->enable("action");
3955  $tbl->enable("select_all");
3956  $tbl->setLimit($maxentries);
3957  $tbl->setOffset($offset);
3958  $tbl->setData($tablerows);
3959  $tbl->setMaxCount(count($tablerows));
3960  $tbl->setOrderDirection($sortorder);
3961  $tbl->setSelectAllCheckbox("chb_defaults");
3962  $tbl->setFormName("formDefaults");
3963  $tbl->addActionButton("deleteDefaults", $this->lng->txt("delete"));
3964  $tbl->addActionButton("applyDefaults", $this->lng->txt("apply"));
3965 
3966  $header_params = $this->ctrl->getParameterArray($this, "defaults");
3967  $tbl->setHeaderVars($headervars, $header_params);
3968 
3969  // footer
3970  $tbl->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
3971  // render table
3972  $tableoutput = $tbl->render();
3973  $this->tpl->setVariable("TEST_DEFAULTS_TABLE", $tableoutput);
3974  }
3975  else
3976  {
3977  $this->tpl->setVariable("TEST_DEFAULTS_TABLE", $this->lng->txt("tst_defaults_not_defined"));
3978  }
3979  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "addDefaults"));
3980  $this->tpl->setVariable("BUTTON_ADD", $this->lng->txt("add"));
3981  $this->tpl->setVariable("TEXT_DEFAULTS_OF_TEST", $this->lng->txt("tst_defaults_defaults_of_test"));
3982  }
3983 
3988  {
3989  if (count($_POST["chb_defaults"]))
3990  {
3991  foreach ($_POST["chb_defaults"] as $test_default_id)
3992  {
3993  $this->object->deleteDefaults($test_default_id);
3994  }
3995  }
3996  $this->defaultsObject();
3997  }
3998 
4003  {
4004  if (count($_POST["chb_defaults"]) == 1)
4005  {
4006  foreach ($_POST["chb_defaults"] as $test_default_id)
4007  {
4008  $result = $this->object->applyDefaults($test_default_id);
4009  if (!$result)
4010  {
4011  ilUtil::sendInfo($this->lng->txt("tst_defaults_apply_not_possible"));
4012  }
4013  else
4014  {
4015  ilUtil::sendSuccess($this->lng->txt("tst_defaults_applied"));
4016  }
4017  }
4018  }
4019  else
4020  {
4021  ilUtil::sendInfo($this->lng->txt("tst_defaults_apply_select_one"));
4022  }
4023  $this->defaultsObject();
4024  }
4025 
4030  {
4031  if (strlen($_POST["name"]) > 0)
4032  {
4033  $this->object->addDefaults($_POST['name']);
4034  }
4035  else
4036  {
4037  ilUtil::sendInfo($this->lng->txt("tst_defaults_enter_name"));
4038  }
4039  $this->defaultsObject();
4040  }
4041 
4047  function infoScreenObject()
4048  {
4049  $this->ctrl->setCmd("showSummary");
4050  $this->ctrl->setCmdClass("ilinfoscreengui");
4051  $this->infoScreen();
4052  }
4053 
4055  {
4056  $this->ctrl->setCmd("showSummary");
4057  $this->ctrl->setCmdClass("ilinfoscreengui");
4058  $this->infoScreen($_SESSION["lock"]);
4059  }
4060 
4064  function infoScreen($session_lock = "")
4065  {
4066  global $ilAccess;
4067  global $ilUser;
4068 
4069  // Disabled
4070  if ($_GET['crs_show_result'])
4071  {
4072  $this->object->hideCorrectAnsweredQuestions();
4073  }
4074  else
4075  {
4076  if ($this->object->getTestSequence()->hasHiddenQuestions())
4077  {
4078  $this->object->getTestSequence()->clearHiddenQuestions();
4079  $this->object->getTestSequence()->saveToDb();
4080  }
4081  }
4082 
4083  if ($_GET['createRandomSolutions'])
4084  {
4085  $this->object->createRandomSolutions($_GET['createRandomSolutions']);
4086  }
4087 
4088  if (!$ilAccess->checkAccess("visible", "", $this->ref_id))
4089  {
4090  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
4091  }
4092 
4093  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
4094  $info = new ilInfoScreenGUI($this);
4095 
4096  $seq = $this->object->getTestSession()->getLastSequence();
4097 
4098  include_once "./Modules/Test/classes/class.ilTestOutputGUI.php";
4099  $output_gui =& new ilTestOutputGUI($this->object);
4100  $this->ctrl->setParameter($output_gui, "sequence", $seq);
4101  $info->setFormAction($this->ctrl->getFormAction($output_gui));
4102  if (strlen($session_lock))
4103  {
4104  $info->addHiddenElement("lock", $session_lock);
4105  }
4106  else
4107  {
4108  $info->addHiddenElement("lock", md5($_COOKIE['PHPSESSID'] . time()));
4109  }
4110  $online_access = false;
4111  if ($this->object->getFixedParticipants())
4112  {
4113  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
4114  $online_access_result = ilObjTestAccess::_lookupOnlineTestAccess($this->object->getId(), $ilUser->getId());
4115  if ($online_access_result === true)
4116  {
4117  $online_access = true;
4118  }
4119  else
4120  {
4121  ilUtil::sendInfo($online_access_result);
4122  }
4123  }
4124  if( $this->object->isOnline() && $this->object->isComplete() )
4125  {
4126  if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id))
4127  {
4128  $executable = $this->object->isExecutable($ilUser->getId(), $allowPassIncrease = TRUE);
4129  if ($executable["executable"])
4130  {
4131  if ($this->object->getTestSession()->getActiveId() > 0)
4132  {
4133  // resume test
4134  $resume_text = $this->lng->txt("tst_resume_test");
4135  if (($seq < 1) || ($seq == $this->object->getTestSequence()->getFirstSequence()))
4136  {
4137  $resume_text = $this->object->getStartTestLabel($this->object->getTestSession()->getActiveId());
4138  }
4139  // Disabled
4140  #if(!$_GET['crs_show_result'] or $this->object->getTestSequence()->getFirstSequence())
4141  {
4142  //$info->addFormButton("resume", $resume_text);
4143  $big_button[] = array('resume', $resume_text);
4144  }
4145  }
4146  else
4147  {
4148  // start new test
4149  //$info->addFormButton("start", $this->object->getStartTestLabel($this->object->getTestSession()->getActiveId()));
4150  $big_button[] = array("start", $this->object->getStartTestLabel($this->object->getTestSession()->getActiveId()));
4151  }
4152  }
4153  else
4154  {
4155  ilUtil::sendInfo($executable["errormessage"]);
4156  }
4157  if ($this->object->getTestSession()->getActiveId() > 0)
4158  {
4159  // test results button
4160  if ($this->object->canShowTestResults($ilUser->getId()))
4161  {
4162  //$info->addFormButton("outUserResultsOverview", $this->lng->txt("tst_show_results"));
4163  $big_button[] = array("outUserResultsOverview", $this->lng->txt("tst_show_results"));
4164  }
4165  }
4166  }
4167  if ($this->object->getTestSession()->getActiveId() > 0)
4168  {
4169  if ($this->object->canShowSolutionPrintview($ilUser->getId()))
4170  {
4171  //$info->addFormButton("outUserListOfAnswerPasses", $this->lng->txt("tst_list_of_answers_show"));
4172  $big_button[] = array("outUserListOfAnswerPasses", $this->lng->txt("tst_list_of_answers_show"));
4173  }
4174  }
4175  }
4176 
4177  if( !$this->object->isOnline() )
4178  {
4179  $message = $this->lng->txt("test_is_offline");
4180 
4181  if($ilAccess->checkAccess("write", "", $this->ref_id))
4182  {
4183  $message .= "<br /><a href=\"".$this->ctrl->getLinkTarget($this, "properties")."\">".
4184  $this->lng->txt("test_edit_settings")."</a>";
4185  }
4186 
4187  ilUtil::sendInfo($message);
4188  }
4189 
4190  if ($this->object->getShowInfo())
4191  {
4192  $info->enablePrivateNotes();
4193  }
4194  /*
4195  if (strlen($this->object->getIntroduction()))
4196  {
4197  $info->addSection($this->lng->txt("tst_introduction"));
4198  $info->addProperty("", $this->object->prepareTextareaOutput($this->object->getIntroduction()));
4199  }
4200  * */
4201  if($big_button)
4202  {
4203  $out = '<div class="il_ButtonGroup" style="margin:25px; text-align:center; font-size:25px;">';
4204  foreach($big_button as $button) {
4205  $out .= '<input type="submit" class="submit" name="cmd['.$button[0].']" value="'.
4206  $button[1].'" style="padding:10px;" />';
4207  }
4208  $out .= '</div>';
4209  $big_button = $out;
4210  }
4211 
4212  if (strlen($this->object->getIntroduction()))
4213  {
4214  $introduction = $this->object->getIntroduction();
4215  $info->addSection($this->lng->txt("tst_introduction"));
4216  $info->addProperty("", $this->object->prepareTextareaOutput($this->object->getIntroduction()).
4217  $big_button."<br />".$info->getHiddenToggleButton());
4218  }
4219  else
4220  {
4221  $info->addSection("");
4222  $info->addProperty("", $big_button.$info->getHiddenToggleButton());
4223  }
4224 
4225  $info->hideFurtherSections(false);
4226 
4227  $info->addSection($this->lng->txt("tst_general_properties"));
4228  if ($this->object->getShowInfo())
4229  {
4230  $info->addProperty($this->lng->txt("author"), $this->object->getAuthor());
4231  $info->addProperty($this->lng->txt("title"), $this->object->getTitle());
4232  }
4233  if( $this->object->isOnline() && $this->object->isComplete() )
4234  {
4235  if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id))
4236  {
4237  if ($this->object->getShowInfo() || !$this->object->getForceJS())
4238  {
4239  // use javascript
4240  $checked_javascript = false;
4241  if ($this->object->getJavaScriptOutput())
4242  {
4243  $checked_javascript = true;
4244  }
4245  if ($this->object->getForceJS())
4246  {
4247  $info->addProperty($this->lng->txt("tst_test_output"), $this->lng->txt("tst_use_javascript"));
4248  }
4249  else
4250  {
4251  $info->addPropertyCheckbox($this->lng->txt("tst_test_output"), "chb_javascript", 1, $this->lng->txt("tst_use_javascript"), $checked_javascript);
4252  }
4253  }
4254  // hide previous results
4255  if( !$this->object->isRandomTest() )
4256  {
4257  if ($this->object->getNrOfTries() != 1)
4258  {
4259  if ($this->object->getUsePreviousAnswers() == 0)
4260  {
4261  if ($this->object->getShowInfo())
4262  {
4263  $info->addProperty($this->lng->txt("tst_use_previous_answers"), $this->lng->txt("tst_dont_use_previous_answers"));
4264  }
4265  }
4266  else
4267  {
4268  $use_previous_answers = FALSE;
4269  if ($ilUser->prefs["tst_use_previous_answers"])
4270  {
4271  $checked_previous_answers = TRUE;
4272  }
4273  $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);
4274  }
4275  }
4276  }
4277  if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
4278  {
4279  $info->addPropertyTextinput($this->lng->txt("enter_anonymous_code"), "anonymous_id", "", 8, "setAnonymousId", $this->lng->txt("submit"));
4280  }
4281  }
4282  }
4283 
4284  if ($this->object->getShowInfo())
4285  {
4286  $info->addSection($this->lng->txt("tst_sequence_properties"));
4287  $info->addProperty($this->lng->txt("tst_sequence"), $this->lng->txt(($this->object->getSequenceSettings() == TEST_FIXED_SEQUENCE)? "tst_sequence_fixed":"tst_sequence_postpone"));
4288 
4289  $info->addSection($this->lng->txt("tst_heading_scoring"));
4290  $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"));
4291  $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"));
4292  if ($this->object->isRandomTest())
4293  {
4294  $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"));
4295  }
4296 
4297  $info->addSection($this->lng->txt("tst_score_reporting"));
4298  $score_reporting_text = "";
4299  switch ($this->object->getScoreReporting())
4300  {
4301  case REPORT_AFTER_TEST:
4302  $score_reporting_text = $this->lng->txt("tst_report_after_test");
4303  break;
4304  case REPORT_ALWAYS:
4305  $score_reporting_text = $this->lng->txt("tst_report_after_first_question");
4306  break;
4307  case REPORT_AFTER_DATE:
4308  $score_reporting_text = $this->lng->txt("tst_report_after_date");
4309  break;
4310  case 4:
4311  $score_reporting_text = $this->lng->txt("tst_report_never");
4312  break;
4313  }
4314  $info->addProperty($this->lng->txt("tst_score_reporting"), $score_reporting_text);
4315  $reporting_date = $this->object->getReportingDate();
4316  if ($reporting_date)
4317  {
4318  #preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $reporting_date, $matches);
4319  #$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]));
4320  #$info->addProperty($this->lng->txt("tst_score_reporting_date"), $txt_reporting_date);
4321  $info->addProperty($this->lng->txt('tst_score_reporting_date'),
4323  }
4324 
4325  $info->addSection($this->lng->txt("tst_session_settings"));
4326  $info->addProperty($this->lng->txt("tst_nr_of_tries"), ($this->object->getNrOfTries() == 0)?$this->lng->txt("unlimited"):$this->object->getNrOfTries());
4327  if ($this->object->getNrOfTries() != 1)
4328  {
4329  $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());
4330  }
4331 
4332  if ($this->object->getEnableProcessingTime())
4333  {
4334  $info->addProperty($this->lng->txt("tst_processing_time"), $this->object->getProcessingTime());
4335  }
4336  if (strlen($this->object->getAllowedUsers()) && ($this->object->getAllowedUsersTimeGap()))
4337  {
4338  $info->addProperty($this->lng->txt("tst_allowed_users"), $this->object->getAllowedUsers());
4339  }
4340 
4341  $starting_time = $this->object->getStartingTime();
4342  if ($starting_time)
4343  {
4344  $info->addProperty($this->lng->txt("tst_starting_time"),
4346  }
4347  $ending_time = $this->object->getEndingTime();
4348  if ($ending_time)
4349  {
4350  $info->addProperty($this->lng->txt("tst_ending_time"),
4352  }
4353  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
4354  // forward the command
4355 
4356  if($_GET['crs_show_result'] and !$this->object->getTestSequence()->getFirstSequence())
4357  {
4358  #ilUtil::sendInfo($this->lng->txt('crs_all_questions_answered_successfully'));
4359  }
4360  }
4361 
4362  $this->ctrl->forwardCommand($info);
4363  }
4364 
4365  function addLocatorItems()
4366  {
4367  global $ilLocator;
4368  switch ($this->ctrl->getCmd())
4369  {
4370  case "run":
4371  case "infoScreen":
4372  case "redirectToInfoScreen":
4373  case "start":
4374  case "resume":
4375  case "previous":
4376  case "next":
4377  case "summary":
4378  case "finishTest":
4379  case "outCorrectSolution":
4380  case "passDetails":
4381  case "showAnswersOfUser":
4382  case "outUserResultsOverview":
4383  case "backFromSummary":
4384  case "show_answers":
4385  case "setsolved":
4386  case "resetsolved":
4387  case "outTestSummary":
4388  case "outQuestionSummary":
4389  case "gotoQuestion":
4390  case "selectImagemapRegion":
4391  case "confirmSubmitAnswers":
4392  case "finalSubmission":
4393  case "postpone":
4394  case "redirectQuestion":
4395  case "outUserPassDetails":
4396  case "checkPassword":
4397  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"), "", $_GET["ref_id"]);
4398  break;
4399  case "eval_stat":
4400  case "evalAllUsers":
4401  case "evalUserDetail":
4402  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "eval_stat"), "", $_GET["ref_id"]);
4403  break;
4404  case "create":
4405  case "save":
4406  case "cancel":
4407  case "importFile":
4408  case "cloneAll":
4409  case "importVerifiedFile":
4410  case "cancelImport":
4411  break;
4412  default:
4413  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
4414  break;
4415  }
4416  }
4417 
4418  function getBrowseForQuestionsTab(&$tabs_gui)
4419  {
4420  global $ilAccess;
4421  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4422  {
4423  $this->ctrl->saveParameterByClass($this->ctrl->getCmdClass(), 'q_id');
4424  // edit page
4425  $tabs_gui->setBackTarget($this->lng->txt("backtocallingtest"), $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), "questions"));
4426  $tabs_gui->addTarget("tst_browse_for_questions",
4427  $this->ctrl->getLinkTarget($this, "browseForQuestions"),
4428  array("browseForQuestions", "filter", "resetFilter", "resetTextFilter", "insertQuestions"),
4429  "", "", TRUE
4430  );
4431  }
4432  }
4433 
4434  function getRandomQuestionsTab(&$tabs_gui)
4435  {
4436  global $ilAccess;
4437  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4438  {
4439  // edit page
4440  $tabs_gui->setBackTarget($this->lng->txt("backtocallingtest"), $this->ctrl->getLinkTarget($this, "questions"));
4441  $tabs_gui->addTarget("random_selection",
4442  $this->ctrl->getLinkTarget($this, "randomQuestions"),
4443  array("randomQuestions"),
4444  "", ""
4445  );
4446  }
4447  }
4448 
4449  function statisticsObject()
4450  {
4451  }
4452 
4457  {
4458  include_once "./Services/Certificate/classes/class.ilCertificateGUI.php";
4459  include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
4460  $output_gui = new ilCertificateGUI(new ilTestCertificateAdapter($this->object));
4461  $output_gui->certificateEditor();
4462  }
4463 
4465  {
4466  global $ilTabs, $ilCtrl;
4467  $ilTabs->activateTab('assQuestions');
4468  $a_cmd = $ilCtrl->getCmd();
4469 
4470  if (!$this->object->isRandomTest())
4471  {
4472  #if (in_array($this->object->getEnabledViewMode(), array('both', 'express'))) {
4473  $questions_per_page = ($a_cmd == 'questions_per_page' || ($a_cmd == 'removeQuestions' && $_REQUEST['test_express_mode'])) ? true : false;
4474 
4475  $this->tabs_gui->addSubTabTarget(
4476  "questions_per_page_view",
4477  $this->ctrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'showPage'),
4478  "", "", "", $questions_per_page);
4479  #}
4480  }
4481  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
4482  $template = new ilSettingsTemplate($this->object->getTemplate(), ilObjAssessmentFolderGUI::getSettingsTemplateConfig());
4483 
4484  if (!in_array('questions', $template->getHiddenTabs())) {
4485  // questions subtab
4486  $ilTabs->addSubTabTarget("edit_test_questions",
4487  $this->ctrl->getLinkTarget($this,'questions'),
4488  array("questions", "browseForQuestions", "questionBrowser", "createQuestion",
4489  "randomselect", "filter", "resetFilter", "insertQuestions",
4490  "back", "createRandomSelection", "cancelRandomSelect",
4491  "insertRandomSelection", "removeQuestions", "moveQuestions",
4492  "insertQuestionsBefore", "insertQuestionsAfter", "confirmRemoveQuestions",
4493  "cancelRemoveQuestions", "executeCreateQuestion", "cancelCreateQuestion",
4494  "addQuestionpool", "saveRandomQuestions", "saveQuestionSelectionMode"),
4495  "");
4496 
4497  if (in_array($a_cmd, array('questions', 'createQuestion')) || ($a_cmd == 'removeQuestions' && !$_REQUEST['test_express_mode']))
4498  $this->tabs_gui->activateSubTab('edit_test_questions');
4499  }
4500  #}
4501 
4502  // print view subtab
4503  if (!$this->object->isRandomTest())
4504  {
4505  $ilTabs->addSubTabTarget("print_view",
4506  $this->ctrl->getLinkTarget($this,'print'),
4507  "print", "", "", $this->ctrl->getCmd() == 'print');
4508  }
4509 
4510  }
4511 
4513  {
4514  global $ilTabs;
4515 
4516  // user results subtab
4517  $ilTabs->addSubTabTarget("eval_all_users",
4518  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "outEvaluation"),
4519  array("outEvaluation", "detailedEvaluation", "exportEvaluation", "evalUserDetail", "passDetails",
4520  "outStatisticsResultsOverview", "statisticsPassDetails")
4521  , "");
4522 
4523  // aggregated results subtab
4524  $ilTabs->addSubTabTarget("tst_results_aggregated",
4525  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "eval_a"),
4526  array("eval_a"),
4527  "", "");
4528 
4529  // question export
4530  $ilTabs->addSubTabTarget("tst_single_results",
4531  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "singleResults"),
4532  array("singleResults"),
4533  "", "");
4534  }
4535 
4536  function getSettingsSubTabs($hiddenTabs = array())
4537  {
4538  global $ilTabs, $ilias;
4539 
4540  // general subtab
4541  $force_active = ($this->ctrl->getCmd() == "")
4542  ? true
4543  : false;
4544  $ilTabs->addSubTabTarget("general",
4545  $this->ctrl->getLinkTarget($this,'properties'),
4546  array("properties", "saveProperties", "cancelProperties"),
4547  array("", "ilobjtestgui", "ilcertificategui"),
4548  "", $force_active);
4549 
4550  if (!in_array('mark_schema', $hiddenTabs)) {
4551  // mark schema subtab
4552  $ilTabs->addSubTabTarget(
4553  "mark_schema",
4554  $this->ctrl->getLinkTarget($this,'marks'),
4555  array("marks", "addMarkStep", "deleteMarkSteps", "addSimpleMarkSchema",
4556  "saveMarks", "cancelMarks"),
4557  array("", "ilobjtestgui", "ilcertificategui")
4558  );
4559  }
4560 
4561  // scoring subtab
4562  $ilTabs->addSubTabTarget(
4563  "scoring",
4564  $this->ctrl->getLinkTarget($this,'scoring'),
4565  array("scoring"),
4566  array("", "ilobjtestgui", "ilcertificategui")
4567  );
4568 
4569  include_once './Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
4570  if(!in_array('certificate', $hiddenTabs) && ilRPCServerSettings::getInstance()->isEnabled())
4571  {
4572  // certificate subtab
4573  $ilTabs->addSubTabTarget(
4574  "certificate",
4575  $this->ctrl->getLinkTarget($this,'certificate'),
4576  array("certificate", "certificateEditor", "certificateRemoveBackground", "certificateSave",
4577  "certificatePreview", "certificateDelete", "certificateUpload", "certificateImport"),
4578  array("", "ilobjtestgui", "ilcertificategui")
4579  );
4580  }
4581 
4582  if (!in_array('defaults', $hiddenTabs)) {
4583  // defaults subtab
4584  $ilTabs->addSubTabTarget(
4585  "tst_default_settings",
4586  $this->ctrl->getLinkTarget($this, "defaults"),
4587  array("defaults", "deleteDefaults", "addDefaults", "applyDefaults"),
4588  array("", "ilobjtestgui", "ilcertificategui")
4589  );
4590  }
4591  }
4592 
4598  function getTabs(&$tabs_gui)
4599  {
4600  global $ilAccess,$ilUser;
4601 
4602  if (preg_match('/^ass(.*?)gui$/i', $this->ctrl->getNextClass($this))) {
4603  return;
4604  }
4605  else if ($this->ctrl->getNextClass($this) == 'ilpageobjectgui') {
4606  return;
4607  }
4608 
4609  $hidden_tabs = array();
4610 
4611  $template = $this->object->getTemplate();
4612  if($template)
4613  {
4614  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
4616 
4617  $hidden_tabs = $template->getHiddenTabs();
4618  }
4619 
4620  switch ($this->ctrl->getCmd())
4621  {
4622  case "resume":
4623  case "previous":
4624  case "next":
4625  case "summary":
4626  case "directfeedback":
4627  case "finishTest":
4628  case "outCorrectSolution":
4629  case "passDetails":
4630  case "showAnswersOfUser":
4631  case "outUserResultsOverview":
4632  case "backFromSummary":
4633  case "show_answers":
4634  case "setsolved":
4635  case "resetsolved":
4636  case "confirmFinish":
4637  case "outTestSummary":
4638  case "outQuestionSummary":
4639  case "gotoQuestion":
4640  case "selectImagemapRegion":
4641  case "confirmSubmitAnswers":
4642  case "finalSubmission":
4643  case "postpone":
4644  case "redirectQuestion":
4645  case "outUserPassDetails":
4646  case "checkPassword":
4647  case "exportCertificate":
4648  case "finishListOfAnswers":
4649  case "backConfirmFinish":
4650  case "showFinalStatement":
4651  return;
4652  break;
4653  case "browseForQuestions":
4654  case "filter":
4655  case "resetFilter":
4656  case "resetTextFilter":
4657  case "insertQuestions":
4658  // #8497: resetfilter is also used in lp
4659  if($this->ctrl->getNextClass($this) != "illearningprogressgui")
4660  {
4661  return $this->getBrowseForQuestionsTab($tabs_gui);
4662  }
4663  break;
4664  case "scoring":
4665  case "properties":
4666  case "marks":
4667  case "saveMarks":
4668  case "cancelMarks":
4669  case "addMarkStep":
4670  case "deleteMarkSteps":
4671  case "addSimpleMarkSchema":
4672  case "certificate":
4673  case "certificateservice":
4674  case "certificateImport":
4675  case "certificateUpload":
4676  case "certificateEditor":
4677  case "certificateDelete":
4678  case "certificateSave":
4679  case "defaults":
4680  case "deleteDefaults":
4681  case "addDefaults":
4682  case "applyDefaults":
4683  case "inviteParticipants":
4684  case "searchParticipants":
4685  case "":
4686  if (($ilAccess->checkAccess("write", "", $this->ref_id)) && ((strcmp($this->ctrl->getCmdClass(), "ilobjtestgui") == 0) || (strcmp($this->ctrl->getCmdClass(), "ilcertificategui") == 0) || (strlen($this->ctrl->getCmdClass()) == 0)))
4687  {
4688  $this->getSettingsSubTabs($hidden_tabs);
4689  }
4690  break;
4691  case "export":
4692  case "print":
4693  break;
4694  case "statistics":
4695  case "eval_a":
4696  case "detailedEvaluation":
4697  case "outEvaluation":
4698  case "singleResults":
4699  case "exportEvaluation":
4700  case "evalUserDetail":
4701  case "passDetails":
4702  case "outStatisticsResultsOverview":
4703  case "statisticsPassDetails":
4704  $this->getStatisticsSubTabs();
4705  break;
4706  }
4707 
4708  if (strcmp(strtolower(get_class($this->object)), "ilobjtest") == 0)
4709  {
4710  // questions tab
4711  if ($ilAccess->checkAccess("write", "", $this->ref_id) && !in_array('assQuestions', $hidden_tabs))
4712  {
4713  $force_active = ($_GET["up"] != "" || $_GET["down"] != "")
4714  ? true
4715  : false;
4716  if (!$force_active)
4717  {
4718  if ($_GET["browse"] == 1) $force_active = true;
4719  if (preg_match("/deleteqpl_\d+/", $this->ctrl->getCmd()))
4720  {
4721  $force_active = true;
4722  }
4723  }
4724 
4725  if ($this->object->isRandomTest()) {
4726  $target = $this->ctrl->getLinkTarget($this,'questions');
4727  }
4728  else {
4729  $target = $this->ctrl->getLinkTargetByClass('iltestexpresspageobjectgui','showPage');
4730  }
4731 
4732  $tabs_gui->addTarget("assQuestions",
4733  //$this->ctrl->getLinkTarget($this,'questions'),
4734  $target,
4735  array("questions", "browseForQuestions", "questionBrowser", "createQuestion",
4736  "randomselect", "filter", "resetFilter", "insertQuestions",
4737  "back", "createRandomSelection", "cancelRandomSelect",
4738  "insertRandomSelection", "removeQuestions", "moveQuestions",
4739  "insertQuestionsBefore", "insertQuestionsAfter", "confirmRemoveQuestions",
4740  "cancelRemoveQuestions", "executeCreateQuestion", "cancelCreateQuestion",
4741  "addQuestionpool", "saveRandomQuestions", "saveQuestionSelectionMode", "print",
4742  "addsource", "removesource", "randomQuestions"),
4743  "", "", $force_active);
4744  }
4745 
4746  // info tab
4747  if ($ilAccess->checkAccess("visible", "", $this->ref_id) && !in_array('info_short', $hidden_tabs))
4748  {
4749  $tabs_gui->addTarget("info_short",
4750  $this->ctrl->getLinkTarget($this,'infoScreen'),
4751  array("infoScreen", "outIntroductionPage", "showSummary",
4752  "setAnonymousId", "outUserListOfAnswerPasses", "redirectToInfoScreen"));
4753  }
4754 
4755  // settings tab
4756  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4757  {
4758  if (!in_array('settings', $hidden_tabs)) {
4759  $tabs_gui->addTarget("settings",
4760  $this->ctrl->getLinkTarget($this,'properties'),
4761  array("properties", "saveProperties", "cancelProperties",
4762  "marks", "addMarkStep", "deleteMarkSteps", "addSimpleMarkSchema",
4763  "saveMarks", "cancelMarks",
4764  "certificate", "certificateEditor", "certificateRemoveBackground",
4765  "certificateSave", "certificatePreview", "certificateDelete", "certificateUpload",
4766  "certificateImport", "scoring", "defaults", "addDefaults", "deleteDefaults", "applyDefaults",
4767  "inviteParticipants", "saveFixedParticipantsStatus", "searchParticipants", "addParticipants",
4768  ""
4769  ),
4770  array("", "ilobjtestgui", "ilcertificategui")
4771  );
4772  }
4773 
4774  if (!in_array('participants', $hidden_tabs)) {
4775  // participants
4776  $tabs_gui->addTarget("participants",
4777  $this->ctrl->getLinkTarget($this,'participants'),
4778  array("participants", "saveClientIP",
4779  "removeParticipant",
4780  "showParticipantAnswersForAuthor",
4781  "deleteAllUserResults",
4782  "cancelDeleteAllUserData", "deleteSingleUserResults",
4783  "outParticipantsResultsOverview", "outParticipantsPassDetails",
4784  "showPassOverview", "showUserAnswers", "participantsAction",
4785  "showDetailedResults"),
4786  "");
4787  }
4788  }
4789 
4790  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
4791  if(ilLearningProgressAccess::checkAccess($this->object->getRefId()) && !in_array('learning_progress', $hidden_tabs))
4792  {
4793  $tabs_gui->addTarget('learning_progress',
4794  $this->ctrl->getLinkTargetByClass(array('illearningprogressgui'),''),
4795  '',
4796  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui'));
4797  }
4798 
4799  if ($ilAccess->checkAccess("write", "", $this->ref_id) && !in_array('manscoring', $hidden_tabs))
4800  {
4801  include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
4803  if (count($scoring))
4804  {
4805  // scoring tab
4806  $tabs_gui->addTarget("manscoring",
4807  $this->ctrl->getLinkTargetByClass("iltestscoringgui", "manscoring"),
4808  array("manscoring", "scoringfilter", "scoringfilterreset", "setPointsManual", "setFeedbackManual", "setManscoringDone"),
4809  "");
4810  }
4811  }
4812 
4813  if ((($ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) || ($ilAccess->checkAccess("write", "", $this->ref_id))) && !in_array('statistics', $hidden_tabs))
4814  {
4815  // statistics tab
4816  $tabs_gui->addTarget("statistics",
4817  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "outEvaluation"),
4818  array("statistics", "outEvaluation", "exportEvaluation", "detailedEvaluation", "eval_a", "evalUserDetail",
4819  "passDetails", "outStatisticsResultsOverview", "statisticsPassDetails", "singleResults")
4820  , "");
4821  }
4822 
4823  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4824  {
4825  if (!in_array('history', $hidden_tabs)) {
4826 
4827  // history
4828  $tabs_gui->addTarget("history",
4829  $this->ctrl->getLinkTarget($this,'history'),
4830  "history", "");
4831  }
4832 
4833  if (!in_array('meta_data', $hidden_tabs)) {
4834  // meta data
4835  $tabs_gui->addTarget("meta_data",
4836  $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'),
4837  "", "ilmdeditorgui");
4838  }
4839 
4840  if (!in_array('export', $hidden_tabs)) {
4841  // export tab
4842  $tabs_gui->addTarget("export",
4843  $this->ctrl->getLinkTarget($this,'export'),
4844  array("export", "createExportFile", "confirmDeleteExportFile",
4845  "downloadExportFile", "deleteExportFile", "cancelDeleteExportFile"),
4846  "");
4847  }
4848  }
4849 
4850  if ($ilAccess->checkAccess("edit_permission", "", $this->ref_id)&& !in_array('permissions', $hidden_tabs))
4851  {
4852  $tabs_gui->addTarget("perm_settings",
4853  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
4854  }
4855  }
4856  }
4857 
4866  function _goto($a_target)
4867  {
4868  global $ilAccess, $ilErr, $lng;
4869 
4870  if ($ilAccess->checkAccess("visible", "", $a_target))
4871  {
4872  //include_once "./Services/Utilities/classes/class.ilUtil.php";
4873  $_GET["baseClass"] = "ilObjTestGUI";
4874  $_GET["cmd"] = "infoScreen";
4875  $_GET["ref_id"] = $a_target;
4876  include_once("ilias.php");
4877  exit;
4878  //ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=infoScreen&ref_id=$a_target");
4879  }
4880  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
4881  {
4882  $_GET["cmd"] = "frameset";
4883  $_GET["target"] = "";
4884  $_GET["ref_id"] = ROOT_FOLDER_ID;
4885  ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
4886  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
4887  include("repository.php");
4888  exit;
4889  }
4890 
4891  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
4892  }
4893 
4894 
4895 
4896 
4897 
4904  function buildPageViewToolbar($qid = 0)
4905  {
4906  if ($this->create_question_mode)
4907  return;
4908 
4909  global $ilToolbar, $ilCtrl, $lng;
4910 
4911  $this->getQuestionsSubTabs();
4912 
4913  $ilCtrl->saveParameter($this, 'q_mode');
4914 
4915  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'test_express_mode', 1);
4916  $ilCtrl->setParameter($this, 'test_express_mode', 1);
4917  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'q_id', $_REQUEST['q_id']);
4918  $ilCtrl->setParameter($this, 'q_id', $_REQUEST['q_id']);
4919  $ilToolbar->setFormAction($ilCtrl->getFormActionByClass('iltestexpresspageobjectgui', 'edit'));
4920 
4921  if ($this->object->evalTotalPersons() == 0) {
4922  /*
4923  include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
4924  $pool = new ilObjQuestionPool();
4925  $questionTypes = $pool->getQuestionTypes();$options = array();
4926  foreach($questionTypes as $label => $data) {
4927  $options[$data['question_type_id']] = $label;
4928  }
4929 
4930  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
4931  $si = new ilSelectInputGUI($lng->txt("test_add_new_question"), "qtype");
4932  $si->setOptions($options);
4933  $ilToolbar->addInputItem($si, true);
4934  /*
4935  // use pool
4936  if ($this->object->isExpressModeQuestionPoolAllowed()) {
4937  include_once("./Services/Form/classes/class.ilCheckboxInputGUI.php");
4938  $cb = new ilCheckboxInputGUI($lng->txt("test_use_pool"), "use_pool");
4939  $ilToolbar->addInputItem($cb, true);
4940  }
4941  */
4942  $ilToolbar->addFormButton($lng->txt("test_create_question"), "addQuestion");
4943 
4944  $ilToolbar->addSeparator();
4945 
4946  if ($this->object->getPoolUsage()) {
4947  $ilToolbar->addFormButton($lng->txt("tst_browse_for_questions"), "browseForQuestions");
4948 
4949  $show_separator = true;
4950  }
4951  }
4952 
4953  $questions = $this->object->getQuestionTitlesAndIndexes();
4954 
4955  // desc
4956  $options = array();
4957  foreach($questions as $id => $label) {
4958  $options[$id] = $label;
4959  }
4960 
4961  $optionKeys = array_keys($options);
4962 
4963  if (!$options) {
4964  $options[] = $lng->txt('none');
4965  }
4966  //else if (count($options) > 1) {
4967 // $addSeparator = false;
4968 // if ($optionKeys[0] != $qid) {
4969 // //$ilToolbar->addFormButton($lng->txt("test_prev_question"), "prevQuestion");
4970 // $ilToolbar->addLink($lng->txt("test_prev_question"), $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'prevQuestion'));
4971 // $addSeparator = true;
4972 // }
4973 // else {
4974 // $ilToolbar->addSpacer(45);
4975 // }
4976 //
4977 // if ($optionKeys[count($optionKeys)-1] != $qid) {
4978 // //$ilToolbar->addFormButton($lng->txt("test_next_question"), "nextQuestion");
4979 // $ilToolbar->addLink($lng->txt("test_next_question"), $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'nextQuestion'));
4980 // $addSeparator = true;
4981 // }
4982 // else {
4983 // $ilToolbar->addSpacer(45);
4984 // }
4985 //
4986 // //if ($addSeparator) {
4987 // $ilToolbar->addSeparator();
4988 // //}
4989 
4990  if (count($questions)) {
4991  if (isset($show_separator) && $show_separator) {
4992  $ilToolbar->addSeparator();
4993  }
4994 
4995  $ilToolbar->addLink($lng->txt("test_prev_question"), $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'prevQuestion'), !(count($options) > 1 && $optionKeys[0] != $qid));
4996  $ilToolbar->addLink($lng->txt("test_next_question"), $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'nextQuestion'), !(count($options) > 1 && $optionKeys[count($optionKeys)-1] != $qid));
4997  }
4998 
4999  if (count($questions) > 1) {
5000 
5001  $ilToolbar->addSeparator();
5002 
5003  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
5004  $si = new ilSelectInputGUI($lng->txt("test_jump_to"), "q_id");
5005  $si->addCustomAttribute("onChange=\"forms['ilToolbar'].submit();\"");
5006  $si->setOptions($options);
5007 
5008  if ($qid) {
5009  $si->setValue($qid);
5010  }
5011 
5012  $ilToolbar->addInputItem($si, true);
5013  }
5014 
5015  $total = $this->object->evalTotalPersons();
5016 
5017  /*if (count($options)) {
5018  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
5019  $si = new ilSelectInputGUI($lng->txt("test_jump_to"), "q_id");
5020  $si->addCustomAttribute("onChange=\"forms['ilToolbar'].submit();\"");
5021  $si->setOptions($options);
5022 
5023  if ($qid) {
5024  $si->setValue($qid);
5025  }
5026 
5027  $ilToolbar->addInputItem($si, true);
5028  }*/
5029 
5030  if (count($questions) && !$total) {
5031  $ilCtrl->setParameter($this, 'q_id', $_REQUEST['q_id']);
5032  $ilToolbar->addSeparator();
5033  $ilToolbar->addButton($lng->txt("test_delete_page"), $ilCtrl->getLinkTarget($this, "removeQuestions"));
5034  }
5035 
5036  if (count($questions) > 1 && !$total) {
5037  $ilToolbar->addSeparator();
5038  $ilToolbar->addButton($lng->txt("test_move_page"), $ilCtrl->getLinkTarget($this, "movePageForm"));
5039  }
5040 
5041  //$ilToolbar->addFormButton($lng->txt("go"), "showPage");
5042 
5043  }
5044 
5045  public function copyQuestionsToPoolObject($returnResult = false) {
5046  //var_dump($_REQUEST);
5047  include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
5048  $qpool = new ilObjQuestionPool($_REQUEST['sel_qpl'], true);
5049  $qpool->setOnline(ilObjQuestionPool::_lookupOnline($_REQUEST['sel_qpl'], true));
5050 
5051  $newIds = array();
5052  foreach($_REQUEST['q_id'] as $q_id) {
5053  $newId = $qpool->copyQuestion($q_id, $qpool->getId());
5054  $newIds[$q_id] = $newId;
5055  }
5056 
5057  $result = new stdClass();
5058  $result->ids = $newIds;
5059  $result->qpool = $qpool;
5060 
5061  if ($returnResult)
5062  return $result;
5063  else
5064  $this->backObject();
5065  }
5066 
5068  $result = $this->copyQuestionsToPoolObject(true);
5069 
5070  foreach($result->ids as $oldId => $newId) {
5071  $questionInstance = assQuestion::_instanciateQuestion($oldId);
5072  $questionInstance->setNewOriginalId($newId);
5073  $questionInstance->setObjId($result->qpool->getId());
5074  $questionInstance->saveToDb();
5075 
5076  }
5077 
5078  $this->backObject();
5079  }
5080 
5081  private function getQuestionpoolCreationForm() {
5082  global $lng;
5083  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
5084  $form = new ilPropertyFormGUI();
5085 
5086  $title = new ilTextInputGUI($lng->txt('title'), 'title');
5087  $title->setRequired(true);
5088  $form->addItem($title);
5089 
5090  $description = new ilTextAreaInputGUI($lng->txt('description'), 'description');
5091  $form->addItem($description);
5092 
5093  $form->addCommandButton('createQuestionPoolAndCopy', $lng->txt('create'));
5094 
5095  foreach($_REQUEST['q_id'] as $id) {
5096  $hidden = new ilHiddenInputGUI('q_id[]');
5097  $hidden->setValue($id);
5098  $form->addItem($hidden);
5099 
5100  }
5101 
5102  return $form;
5103  }
5104 
5105  public function copyToQuestionpoolObject() {
5106  $this->createQuestionpoolTargetObject('copyQuestionsToPool');
5107  }
5108 
5110  global $lng;
5111 
5112  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
5113 
5114  foreach($_REQUEST['q_id'] as $q_id) {
5115  $questionInstance = assQuestion::_instanciateQuestion($q_id);
5116  $type = ilObject::_lookupType($questionInstance->getObjId());
5117  if ($type !== 'tst') {
5118  ilUtil::sendFailure($lng->txt('tst_link_only_unassigned'), true);
5119  $this->backObject();
5120  return;
5121  }
5122  }
5123 
5124  $this->createQuestionpoolTargetObject('copyAndLinkQuestionsToPool');
5125  }
5126 
5128  $form = $this->getQuestionpoolCreationForm();
5129 
5130  if ($_REQUEST['title']) {
5131  $title = $_REQUEST['title'];
5132  }
5133  else {
5134  $title = $_REQUEST['txt_qpl'];
5135  }
5136 
5137  if (!$title) {
5138  ilUtil::sendInfo($this->lng->txt("questionpool_not_entered"));
5139  return $this->copyAndLinkToQuestionpoolObject();
5140  }
5141 
5142  $ref_id = $this->createQuestionPool($title, $_REQUEST['description']);
5143  $_REQUEST['sel_qpl'] = $ref_id;
5144 
5145  //if ($_REQUEST['link']) {
5147  //}
5148  //else {
5149  // $this->copyQuestionsToPoolObject();
5150  //}
5151  }
5152 
5160  {
5161  global $ilUser, $ilTabs;
5162  $this->getQuestionsSubTabs();
5163  $ilTabs->activateSubTab('edit_test_questions');
5164 
5165  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_qpl_select_copy.html", "Modules/Test");
5166  $questionpools =& $this->object->getAvailableQuestionpools(FALSE, FALSE, FALSE, TRUE, FALSE, "write");
5167  if (count($questionpools) == 0)
5168  {
5169  $this->tpl->setCurrentBlock("option");
5170  $this->tpl->setVariable("VALUE_QPL", "");
5171  $this->tpl->parseCurrentBlock();
5172  }
5173  else
5174  {
5175  foreach ($questionpools as $key => $value)
5176  {
5177  $this->tpl->setCurrentBlock("option");
5178  $this->tpl->setVariable("VALUE_OPTION", $key);
5179  $this->tpl->setVariable("TEXT_OPTION", $value["title"]);
5180  $this->tpl->parseCurrentBlock();
5181  }
5182  }
5183  foreach($_REQUEST['q_id'] as $id) {
5184  $this->tpl->setCurrentBlock("hidden");
5185  $this->tpl->setVariable("HIDDEN_NAME", "q_id[]");
5186  $this->tpl->setVariable("HIDDEN_VALUE", $id);
5187  $this->tpl->parseCurrentBlock();
5188  $this->tpl->setCurrentBlock("adm_content");
5189  }
5190  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
5191 
5192  if (count($questionpools) == 0)
5193  {
5194  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_enter_questionpool"));
5195  $cmd = 'createQuestionPoolAndCopy';
5196  }
5197  else
5198  {
5199  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_select_questionpool"));
5200  }
5201 
5202  $this->tpl->setVariable("CMD_SUBMIT", $cmd);
5203  $this->tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit"));
5204  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
5205 
5206  $createForm = $this->getQuestionpoolCreationForm();
5207  switch($cmd) {
5208  case 'copyAndLinkQuestionsToPool':
5209  $hidden = new ilHiddenInputGUI('link');
5210  $hidden->setValue(1);
5211  $createForm->addItem($hidden);
5212  break;
5213  case 'copyQuestionsToPool':
5214  break;
5215  }
5216  $createForm->setFormAction($this->ctrl->getFormAction($this));
5217  #$this->tpl->setVariable('CREATE_QPOOL_FORM', $createForm->getHTML());
5218 
5219  $this->tpl->parseCurrentBlock();
5220  }
5221 
5222  private function applyTemplate($templateData, $object) {
5223  // map formFieldName => setterName
5224  $simpleSetters = array(
5225  'anonymity' => 'setAnonymity',
5226  'random_test' => 'setRandomTest',
5227  'test_enabled_views' => 'setEnabledViewMode',
5228  //'express_allow_question_pool' => 'setExpressModeQuestionPoolAllowed',
5229  'introduction' => 'setIntroduction',
5230  'showinfo' => 'setShowInfo',
5231  'finalstatement' => 'setFinalStatement',
5232  'showfinalstatement' => 'setShowFinalStatement',
5233  'chb_shuffle_questions' => 'setShuffleQuestions',
5234  'list_of_questions' => 'setListOfQuestionsSettings',
5235  'chb_show_marker' => 'setShowMarker',
5236  'chb_show_cancel' => 'setShowCancel',
5237  'kiosk' => 'setKiosk',
5238  'nr_of_tries' => 'setNrOfTries',
5239  'chb_processing_time' => 'setEnableProcessingTime',
5240  'chb_use_previous_answers' => 'setUsePreviousAnswers',
5241  'forcejs' => 'setForceJS',
5242  'title_output' => 'setTitleOutput',
5243  'password' => 'setPassword',
5244  'fixedparticipants' => 'setFixedParticipants',
5245  'allowedUsers' => 'setAllowedUsers',
5246  'allowedUsersTimeGap' => 'setAllowedUsersTimeGap',
5247  'mailnotification' => 'setMailNotification',
5248  'mailnottype' => 'setMailNotificationType',
5249  //'' => '',
5250  'count_system' => 'setCountSystem',
5251  'mc_scoring' => 'setMCScoring',
5252  'score_cutting' => 'setScoreCutting',
5253  'pass_scoring' => 'setScoreReporting',
5254 
5255  'instant_feedback' => 'setScoringFeedbackOptionsByArray',
5256 
5257  'results_presentation' => 'setResultsPresentationOptionsByArray',
5258  'export_settings' => 'setExportSettings',
5259  );
5260 
5261  if (!$templateData['results_presentation']['value']) {
5262  $templateData['results_presentation']['value'] = array();
5263  }
5264 
5265  foreach($simpleSetters as $field => $setter) {
5266  if($templateData[$field]) {
5267  $object->$setter($templateData[$field]['value']);
5268  }
5269  }
5270  }
5271 
5272  private function formShowGeneralSection($templateData) {
5273  // alway show because of title and description
5274  return true;
5275  }
5276 
5277  private function formShowBeginningEndingInformation($templateData) {
5278  // show always because of statement text areas
5279  return true;
5280  }
5281 
5282  private function formShowPresentationSection($templateData) {
5283  // show always because of "previous answer" setting
5284  return true;
5285  }
5286 
5287  private function formShowSequenceSection($templateData) {
5288  // show always because of "list of question" and "shuffle"
5289  return true;
5290  }
5291 
5292  private function formShowKioskSection($templateData) {
5293  $fields = array(
5294  'kiosk',
5295  );
5296  return $this->formsectionHasVisibleFields($templateData, $fields);
5297  }
5298 
5299  private function formShowSessionSection($templateData) {
5300  // show always because of "nr_of_tries", "chb_processing_time", "chb_starting_time", "chb_ending_time"
5301  return true;
5302  }
5303 
5304  private function formShowParticipantSection($templateData) {
5305  $fields = array(
5306  'fixedparticipants',
5307  'allowedUsers',
5308  'allowedUsersTimeGap',
5309  );
5310  return $this->formsectionHasVisibleFields($templateData, $fields);
5311  }
5312 
5313  private function formShowNotificationSection($templateData) {
5314  $fields = array(
5315  'mailnotification',
5316  'mailnottype',
5317  );
5318  return $this->formsectionHasVisibleFields($templateData, $fields);
5319  }
5320 
5321  private function formsectionHasVisibleFields($templateData, $fields) {
5322  foreach($fields as $fld) {
5323  if (isset($templateData[$fld])) {
5324  if(!$templateData[$fld]['hide'])
5325  return true;
5326  }
5327  else {
5328  return true;
5329  }
5330  }
5331  return false;
5332  }
5333 
5338  {
5339  ilUtil::sendQuestion($this->lng->txt("test_confirm_template_reset"));
5340  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_tst_tst_confirm_resettemplate.html", "Modules/Test");
5341  $this->tpl->setCurrentBlock("adm_content");
5342  $this->tpl->setVariable("BTN_CONFIRM_REMOVE", $this->lng->txt("confirm"));
5343  $this->tpl->setVariable("BTN_CANCEL_REMOVE", $this->lng->txt("cancel"));
5344  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this, "resetTemplateObject"));
5345  $this->tpl->parseCurrentBlock();
5346  }
5347 
5352  {
5353  $this->object->setTemplate(null);
5354  $this->object->saveToDB();
5355 
5356  ilUtil::sendSuccess($this->lng->txt("test_template_reset"), true);
5357  $this->ctrl->redirect($this, "properties");
5358  }
5359 
5360  public function saveOrderObject() {
5361  global $ilAccess;
5362  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
5363  {
5364  // allow only write access
5365  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
5366  $this->ctrl->redirect($this, "infoScreen");
5367  }
5368 
5369  global $ilCtrl;
5370  $this->object->setQuestionOrder($_REQUEST['order']);
5371 
5372  $ilCtrl->redirect($this, 'questions');
5373  }
5374 
5378  protected function movePageFormObject()
5379  {
5380  global $lng, $ilCtrl, $tpl;
5381 
5382  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
5383  $form = new ilPropertyFormGUI();
5384  $form->setFormAction($ilCtrl->getFormAction($this, "movePage"));
5385  $form->setTitle($lng->txt("test_move_page"));
5386 
5387  $old_pos = new ilHiddenInputGUI("q_id");
5388  $old_pos->setValue($_REQUEST['q_id']);
5389  $form->addItem($old_pos);
5390 
5391  $questions = $this->object->getQuestionTitlesAndIndexes();
5392  if (!is_array($questions))
5393  $questions = array();
5394 
5395  foreach($questions as $k => $q) {
5396  if ($k == $_REQUEST['q_id']) {
5397  unset($questions[$k]);
5398  continue;
5399  }
5400  $questions[$k] = $lng->txt('behind') . ' '. $q;
5401  }
5402  #$questions['0'] = $lng->txt('first');
5403 
5404  $options = array(
5405  0 => $lng->txt('first')
5406  );
5407  foreach($questions as $k => $q) {
5408  $options[$k] = $q;
5409  }
5410 
5411  $pos = new ilSelectInputGUI($lng->txt("position"), "position_after");
5412  $pos->setOptions($options);
5413  $form->addItem($pos);
5414 
5415  $form->addCommandButton("movePage", $lng->txt("submit"));
5416  $form->addCommandButton("showPage", $lng->txt("cancel"));
5417 
5418  return $tpl->setContent($form->getHTML());
5419  }
5420 
5421  public function movePageObject() {
5422  global $ilAccess;
5423  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
5424  {
5425  // allow only write access
5426  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
5427  $this->ctrl->redirect($this, "infoScreen");
5428  }
5429 
5430  $this->object->moveQuestionAfter($_REQUEST['q_id'], $_REQUEST['position_after']);
5431  $this->showPageObject();
5432  }
5433 
5434  public function showPageObject() {
5435  global $ilCtrl;
5436 
5437  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'q_id', $_REQUEST['q_id']);
5438  $ilCtrl->redirectByClass('iltestexpresspageobjectgui', 'showPage');
5439  }
5440 
5441  public function copyQuestionObject() {
5442  global $ilAccess;
5443  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
5444  {
5445  // allow only write access
5446  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
5447  $this->ctrl->redirect($this, "infoScreen");
5448  }
5449 
5450  if ($_REQUEST['q_id'] && !is_array($_REQUEST['q_id']))
5451  $ids = array($_REQUEST['q_id']);
5452  else if ($_REQUEST['q_id'])
5453  $ids = $_REQUEST['q_id'];
5454  else
5455  {
5456  ilUtil::sendFailure( $this->lng->txt('copy_no_questions_selected'), true );
5457  $this->ctrl->redirect($this, 'questions');
5458  }
5459 
5460  $copy_count = 0;
5461 
5462  $questionTitles = $this->object->getQuestionTitles();
5463 
5464  foreach($ids as $id)
5465  {
5466  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
5467  $question = assQuestion::_instanciateQuestionGUI($id);
5468  if ($question)
5469  {
5470  $title = $question->object->getTitle();
5471  $i = 2;
5472  while( in_array( $title . ' (' . $i . ')', $questionTitles ))
5473  $i++;
5474 
5475  $title .= ' (' . $i . ')';
5476 
5477  $questionTitles[] = $title;
5478 
5479  $new_id = $question->object->duplicate(false, $title);
5480 
5481  $clone = assQuestion::_instanciateQuestionGUI($new_id);
5482  $clone->object->setObjId($this->object->getId());
5483  $clone->object->saveToDb();
5484 
5485  $this->object->insertQuestion($new_id, true);
5486 
5487  $copy_count++;
5488  }
5489  }
5490 
5491  ilUtil::sendSuccess($this->lng->txt('copy_questions_success'), true);
5492 
5493  $this->ctrl->redirect($this, 'questions');
5494  }
5495 } // END class.ilObjTestGUI
5496 ?>