ILIAS  Release_4_1_x_branch Revision 61804
 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 
23 include_once "./classes/class.ilObjectGUI.php";
24 include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
25 
27 {
32  function ilObjTestGUI()
33  {
34  global $lng, $ilCtrl;
35  $lng->loadLanguageModule("assessment");
36  $this->type = "tst";
37  $this->ctrl =& $ilCtrl;
38  $this->ctrl->saveParameter($this, "ref_id");
39  $this->ilObjectGUI("",$_GET["ref_id"], true, false);
40  // Added parameter if called from crs_objectives
41  if((int) $_GET['crs_show_result'])
42  {
43  $this->ctrl->saveParameter($this,'crs_show_result',(int) $_GET['crs_show_result']);
44  }
45  }
46 
50  function executeCommand()
51  {
52  global $ilAccess, $ilNavigationHistory,$ilCtrl;
53 
54  if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"])) && (!$ilAccess->checkAccess("visible", "", $_GET["ref_id"])))
55  {
56  global $ilias;
57  $ilias->raiseError($this->lng->txt("permission_denied"), $ilias->error_obj->MESSAGE);
58  }
59  $cmd = $this->ctrl->getCmd("properties");
60  $next_class = $this->ctrl->getNextClass($this);
61  $this->ctrl->setReturn($this, "properties");
62  if (method_exists($this->object, "getTestStyleLocation")) $this->tpl->addCss($this->object->getTestStyleLocation("output"), "screen");
63 
64  // add entry to navigation history
65  if (!$this->getCreationMode() &&
66  $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
67  {
68  $ilNavigationHistory->addItem($_GET["ref_id"],
69  "ilias.php?baseClass=ilObjTestGUI&cmd=infoScreen&ref_id=".$_GET["ref_id"], "tst");
70  }
71 
72  if(!$this->getCreationMode())
73  {
74  if(IS_PAYMENT_ENABLED)
75  {
76  include_once 'Services/Payment/classes/class.ilPaymentObject.php';
77  if(ilPaymentObject::_isBuyable($this->object->getRefId()) &&
78  !ilPaymentObject::_hasAccess($this->object->getRefId()))
79  {
80  $this->setLocator();
81  $this->tpl->getStandardTemplate();
82 
83  include_once 'Services/Payment/classes/class.ilShopPurchaseGUI.php';
84  $pp = new ilShopPurchaseGUI((int)$_GET['ref_id']);
85  $ret = $this->ctrl->forwardCommand($pp);
86  $this->tpl->show();
87  exit();
88  }
89  }
90  }
91 
92  switch($next_class)
93  {
94  case "ilinfoscreengui":
95  $this->prepareOutput();
96  $this->infoScreen(); // forwards command
97  break;
98  case 'ilmdeditorgui':
99  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
100 
101  $this->prepareOutput();
102  $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
103  $md_gui->addObserver($this->object,'MDUpdateListener','General');
104 
105  $this->ctrl->forwardCommand($md_gui);
106  break;
107  case "iltestoutputgui":
108  include_once "./Modules/Test/classes/class.ilTestOutputGUI.php";
109 
110  if (!$this->object->getKioskMode()) $this->prepareOutput();
111  $output_gui =& new ilTestOutputGUI($this->object);
112  $this->ctrl->forwardCommand($output_gui);
113  break;
114 
115  case "iltestevaluationgui":
116  include_once "./Modules/Test/classes/class.ilTestEvaluationGUI.php";
117  $this->prepareOutput();
118  $evaluation_gui =& new ilTestEvaluationGUI($this->object);
119  $this->ctrl->forwardCommand($evaluation_gui);
120  break;
121 
122  case "iltestservicegui":
123  include_once "./Modules/Test/classes/class.ilTestServiceGUI.php";
124  $this->prepareOutput();
125  $serviceGUI =& new ilTestServiceGUI($this->object);
126  $this->ctrl->forwardCommand($serviceGUI);
127  break;
128 
129  case 'ilpermissiongui':
130  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
131  $this->prepareOutput();
132  $perm_gui =& new ilPermissionGUI($this);
133  $ret =& $this->ctrl->forwardCommand($perm_gui);
134  break;
135 
136  case "illearningprogressgui":
137  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
138 
139  $this->prepareOutput();
140  $new_gui =& new ilLearningProgressGUI(LP_MODE_REPOSITORY,$this->object->getRefId());
141  $this->ctrl->forwardCommand($new_gui);
142 
143  break;
144 
145  case "ilcertificategui":
146  include_once "./Services/Certificate/classes/class.ilCertificateGUI.php";
147  $this->prepareOutput();
148  include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
149  $output_gui = new ilCertificateGUI(new ilTestCertificateAdapter($this->object));
150  $this->ctrl->forwardCommand($output_gui);
151  break;
152 
153  case "iltestscoringgui":
154  include_once "./Modules/Test/classes/class.ilTestScoringGUI.php";
155  $this->prepareOutput();
156  $output_gui = new ilTestScoringGUI($this->object);
157  $this->ctrl->forwardCommand($output_gui);
158  break;
159 
160  case 'ilobjectcopygui':
161  $this->prepareOutput();
162  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
163  $cp = new ilObjectCopyGUI($this);
164  $cp->setType('tst');
165  $this->ctrl->forwardCommand($cp);
166  break;
167 
168  case 'ilrepositorysearchgui':
169  $this->prepareOutput();
170  include_once('./Services/Search/classes/class.ilRepositorySearchGUI.php');
171  $rep_search =& new ilRepositorySearchGUI();
172  $rep_search->setCallback($this,
173  'addParticipantsObject',
174  array(
175  )
176  );
177 
178  // Set tabs
179  $this->ctrl->setReturn($this,'participants');
180  $ret =& $this->ctrl->forwardCommand($rep_search);
181  $this->tabs_gui->setTabActive('participants');
182  break;
183 
184  default:
185  $this->prepareOutput();
186  if (preg_match("/deleteqpl_\d+/", $cmd))
187  {
188  $cmd = "randomQuestions";
189  }
190  if ((strcmp($cmd, "properties") == 0) && ($_GET["browse"]))
191  {
192  $this->questionBrowser();
193  return;
194  }
195  if ((strcmp($cmd, "properties") == 0) && ($_GET["up"] || $_GET["down"]))
196  {
197  $this->questionsObject();
198  return;
199  }
200  $cmd.= "Object";
201  $ret =& $this->$cmd();
202  break;
203  }
204  if (strtolower($_GET["baseClass"]) != "iladministrationgui" &&
205  $this->getCreationMode() != true)
206  {
207  $this->tpl->show();
208  }
209  }
210 
211  function runObject()
212  {
213  $this->ctrl->redirect($this, "infoScreen");
214  }
215 
217  {
218  $this->ctrl->redirectByClass("iltestevaluationgui", "outEvaluation");
219  }
220 
224  function importFileObject()
225  {
226  if (strcmp($_FILES["xmldoc"]["tmp_name"], "") == 0)
227  {
228  ilUtil::sendInfo($this->lng->txt("tst_select_file_for_import"));
229  $this->createObject();
230  return;
231  }
232  $this->ctrl->setParameter($this, "new_type", $this->type);
233  $this->uploadTstObject();
234  }
235 
240  function saveObject()
241  {
242  global $rbacadmin;
243 
244  if (!strlen($_POST['Fobject']['title']))
245  {
246  ilUtil::sendFailure($this->lng->txt('title_required'), true);
247  $this->ctrl->setParameter($this, 'new_type', $_GET['new_type']);
248  $this->ctrl->redirect($this, 'create');
249  }
250  // create and insert forum in objecttree
251  $newObj = parent::saveObject();
252  if ($_POST["defaults"] > 0)
253  {
254  $newObj->applyDefaults($_POST["defaults"]);
255  }
256 
257  // always send a message
258  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
259  ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&ref_id=".$newObj->getRefId()."&cmd=properties");
260  }
261 
263  {
264  include_once "./Services/Utilities/classes/class.ilUtil.php";
265  $path = $this->tree->getPathFull($this->object->getRefID());
266  ilUtil::redirect($this->getReturnLocation("cancel","./repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
267  }
268 
270  {
271  include_once "./Services/Utilities/classes/class.ilUtil.php";
272  ilUtil::redirect($this->getReturnLocation("cancel","./repository.php?ref_id=".(int) $_GET['crs_show_result']));
273  }
274 
275  /*
276  * list all export files
277  */
278  function exportObject()
279  {
280  global $tree;
281  global $ilAccess;
282  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
283  {
284  // allow only write access
285  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
286  $this->ctrl->redirect($this, "infoScreen");
287  }
288 
289  $export_dir = $this->object->getExportDirectory();
290  $export_files = $this->object->getExportFiles($export_dir);
291  $data = array();
292  if(count($export_files) > 0)
293  {
294  foreach($export_files as $exp_file)
295  {
296  $file_arr = explode("__", $exp_file);
297  $date = new ilDateTime($file_arr[0], IL_CAL_UNIX);
298  array_push($data, array(
299  'file' => $exp_file,
300  'size' => filesize($export_dir."/".$exp_file),
301  'date' => $date->get(IL_CAL_DATETIME)
302  ));
303  }
304  }
305 
306  include_once "./Modules/Test/classes/tables/class.ilTestExportTableGUI.php";
307  $table_gui = new ilTestExportTableGUI($this, 'export');
308  $table_gui->setData($data);
309  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
310  }
311 
316  {
317  global $ilAccess;
318 
319  if ($ilAccess->checkAccess("write", "", $this->ref_id))
320  {
321  include_once("./Modules/Test/classes/class.ilTestExport.php");
322  $test_exp = new ilTestExport($this->object, 'xml');
323  $test_exp->buildExportFile();
324  }
325  else
326  {
327  ilUtil::sendInfo("cannot_export_test", TRUE);
328  }
329  $this->ctrl->redirect($this, "export");
330  }
331 
336  {
337  global $ilAccess;
338 
339  if ($ilAccess->checkAccess("write", "", $this->ref_id))
340  {
341  include_once("./Modules/Test/classes/class.ilTestExport.php");
342  $test_exp = new ilTestExport($this->object, 'results');
343  $test_exp->buildExportFile();
344  }
345  else
346  {
347  ilUtil::sendInfo("cannot_export_test", TRUE);
348  }
349  $this->ctrl->redirect($this, "export");
350  }
351 
352 
357  {
358  if(!isset($_POST["file"]))
359  {
360  ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
361  $this->ctrl->redirect($this, "export");
362  }
363 
364  if (count($_POST["file"]) > 1)
365  {
366  ilUtil::sendInfo($this->lng->txt("select_max_one_item"), true);
367  $this->ctrl->redirect($this, "export");
368  }
369 
370 
371  $export_dir = $this->object->getExportDirectory();
372  ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
373  $_POST["file"][0]);
374  }
375 
380  {
381  if (!isset($_POST["file"]))
382  {
383  ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
384  $this->ctrl->redirect($this, "export");
385  }
386 
387  ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
388 
389  $export_dir = $this->object->getExportDirectory();
390  $export_files = $this->object->getExportFiles($export_dir);
391  $data = array();
392  if (count($_POST["file"]) > 0)
393  {
394  foreach ($_POST["file"] as $exp_file)
395  {
396  $file_arr = explode("__", $exp_file);
397  $date = new ilDateTime($file_arr[0], IL_CAL_UNIX);
398  array_push($data, array(
399  'file' => $exp_file,
400  'size' => filesize($export_dir."/".$exp_file),
401  'date' => $date->get(IL_CAL_DATETIME)
402  ));
403  }
404  }
405 
406  include_once "./Modules/Test/classes/tables/class.ilTestExportTableGUI.php";
407  $table_gui = new ilTestExportTableGUI($this, 'export', true);
408  $table_gui->setData($data);
409  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
410  }
411 
417  function cancelObject($in_rep = false)
418  {
419  ilUtil::redirect("repository.php?cmd=frameset&ref_id=".$_GET["ref_id"]);
420  }
421 
426  {
427  ilUtil::sendInfo($this->lng->txt("msg_cancel"), true);
428  $this->ctrl->redirect($this, "export");
429  }
430 
431 
436  {
437  $export_dir = $this->object->getExportDirectory();
438  foreach ($_POST["file"] as $file)
439  {
440  $exp_file = $export_dir."/".$file;
441  $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
442  if (@is_file($exp_file))
443  {
444  unlink($exp_file);
445  }
446  if (@is_dir($exp_dir))
447  {
448  ilUtil::delDir($exp_dir);
449  }
450  }
451  ilUtil::sendSuccess($this->lng->txt('msg_deleted_export_files'), true);
452  $this->ctrl->redirect($this, "export");
453  }
454 
458  function uploadTstObject()
459  {
460  if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
461  {
462  ilUtil::sendFailure($this->lng->txt("error_upload"));
463  $this->createObject();
464  return;
465  }
466  include_once("./Modules/Test/classes/class.ilObjTest.php");
467  // create import directory
469 
470  // copy uploaded file to import directory
471  $file = pathinfo($_FILES["xmldoc"]["name"]);
472  $full_path = ilObjTest::_getImportDirectory()."/".$_FILES["xmldoc"]["name"];
473  ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path);
474 
475  // unzip file
476  ilUtil::unzip($full_path);
477 
478  // determine filenames of xml files
479  $subdir = basename($file["basename"],".".$file["extension"]);
480  $xml_file = ilObjTest::_getImportDirectory()."/".$subdir."/".$subdir.".xml";
481  $qti_file = ilObjTest::_getImportDirectory()."/".$subdir."/". str_replace("test", "qti", $subdir).".xml";
482  $results_file = ilObjTest::_getImportDirectory()."/".$subdir."/". str_replace("test", "results", $subdir).".xml";
483 
484  // start verification of QTI files
485  include_once "./Services/QTI/classes/class.ilQTIParser.php";
486  $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, "");
487  $result = $qtiParser->startParsing();
488  $founditems =& $qtiParser->getFoundItems();
489 
490  if (count($founditems) == 0)
491  {
492  // nothing found
493 
494  // delete import directory
496 
497  ilUtil::sendInfo($this->lng->txt("tst_import_no_items"));
498  $this->createObject();
499  return;
500  }
501 
502  $complete = 0;
503  $incomplete = 0;
504  foreach ($founditems as $item)
505  {
506  if (strlen($item["type"]))
507  {
508  $complete++;
509  }
510  else
511  {
512  $incomplete++;
513  }
514  }
515 
516  if ($complete == 0)
517  {
518  // delete import directory
520 
521  ilUtil::sendInfo($this->lng->txt("qpl_import_non_ilias_files"));
522  $this->createObject();
523  return;
524  }
525 
526  $_SESSION["tst_import_results_file"] = $results_file;
527  $_SESSION["tst_import_xml_file"] = $xml_file;
528  $_SESSION["tst_import_qti_file"] = $qti_file;
529  $_SESSION["tst_import_subdir"] = $subdir;
530  // display of found questions
531  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.tst_import_verification.html");
532  $row_class = array("tblrow1", "tblrow2");
533  $counter = 0;
534  foreach ($founditems as $item)
535  {
536  $this->tpl->setCurrentBlock("verification_row");
537  $this->tpl->setVariable("ROW_CLASS", $row_class[$counter++ % 2]);
538  $this->tpl->setVariable("QUESTION_TITLE", $item["title"]);
539  $this->tpl->setVariable("QUESTION_IDENT", $item["ident"]);
540  include_once "./Services/QTI/classes/class.ilQTIItem.php";
541  switch ($item["type"])
542  {
543  case "MULTIPLE CHOICE QUESTION":
545  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("qt_multiple_choice"));
546  break;
547  case "SINGLE CHOICE QUESTION":
549  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assSingleChoice"));
550  break;
551  case "NUMERIC QUESTION":
552  case QT_NUMERIC:
553  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assNumeric"));
554  break;
555  case "TEXTSUBSET QUESTION":
556  case QT_TEXTSUBSET:
557  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextSubset"));
558  break;
559  case "CLOZE QUESTION":
560  case QT_CLOZE:
561  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assClozeTest"));
562  break;
563  case "IMAGE MAP QUESTION":
564  case QT_IMAGEMAP:
565  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assImagemapQuestion"));
566  break;
567  case "JAVA APPLET QUESTION":
568  case QT_JAVAAPPLET:
569  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assJavaApplet"));
570  break;
571  case "MATCHING QUESTION":
572  case QT_MATCHING:
573  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assMatchingQuestion"));
574  break;
575  case "ORDERING QUESTION":
576  case QT_ORDERING:
577  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assOrderingQuestion"));
578  break;
579  case "TEXT QUESTION":
580  case QT_TEXT:
581  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextQuestion"));
582  break;
583  }
584  $this->tpl->parseCurrentBlock();
585  }
586  $this->tpl->setCurrentBlock("adm_content");
587  $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt("question_type"));
588  $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("question_title"));
589  $this->tpl->setVariable("FOUND_QUESTIONS_INTRODUCTION", $this->lng->txt("tst_import_verify_found_questions"));
590  $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_tst"));
591  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
592  $this->tpl->setVariable("ARROW", ilUtil::getImagePath("arrow_downright.gif"));
593  $this->tpl->setVariable("QUESTIONPOOL_ID", $_POST["qpl"]);
594  $this->tpl->setVariable("VALUE_IMPORT", $this->lng->txt("import"));
595  $this->tpl->setVariable("VALUE_CANCEL", $this->lng->txt("cancel"));
596  $this->tpl->parseCurrentBlock();
597  }
598 
603  {
604  include_once "./Modules/Test/classes/class.ilObjTest.php";
605  // create new questionpool object
606  $newObj = new ilObjTest(0, true);
607  // set type of questionpool object
608  $newObj->setType($_GET["new_type"]);
609  // set title of questionpool object to "dummy"
610  $newObj->setTitle("dummy");
611  // set description of questionpool object
612  $newObj->setDescription("test import");
613  // create the questionpool class in the ILIAS database (object_data table)
614  $newObj->create(true);
615  // create a reference for the questionpool object in the ILIAS database (object_reference table)
616  $newObj->createReference();
617  // put the questionpool object in the administration tree
618  $newObj->putInTree($_GET["ref_id"]);
619  // get default permissions and set the permissions for the questionpool object
620  $newObj->setPermissions($_GET["ref_id"]);
621  // notify the questionpool object and all its parent objects that a "new" object was created
622  $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
623  // empty mark schema
624  $newObj->mark_schema->flush();
625 
626  // start parsing of QTI files
627  include_once "./Services/QTI/classes/class.ilQTIParser.php";
628 
629  // Handle selection of "no questionpool" as qpl_id = -1 -> use test object id instead.
630  if ($_POST["qpl_id"] == "-1")
631  {
632  $qpl_id = $newObj->id;
633  }
634  else
635  {
636  $qpl_id = $_POST["qpl_id"];
637  }
638 
639  $qtiParser = new ilQTIParser($_SESSION["tst_import_qti_file"], IL_MO_PARSE_QTI, $qpl_id, $_POST["ident"]);
640 
641  #$qtiParser = new ilQTIParser($_SESSION["tst_import_qti_file"], IL_MO_PARSE_QTI, $_POST['qpl_id'], $_POST["ident"]);
642 
643  $qtiParser->setTestObject($newObj);
644 
645  $result = $qtiParser->startParsing();
646  $newObj->saveToDb();
647 
648  // import page data
649  include_once ("./Modules/LearningModule/classes/class.ilContObjParser.php");
650  $contParser = new ilContObjParser($newObj, $_SESSION["tst_import_xml_file"], $_SESSION["tst_import_subdir"]);
651  $contParser->setQuestionMapping($qtiParser->getImportMapping());
652  $contParser->startParsing();
653 
654  // import test results
655  if (@file_exists($_SESSION["tst_import_results_file"]))
656  {
657  include_once ("./Modules/Test/classes/class.ilTestResultsImportParser.php");
658  $results = new ilTestResultsImportParser($_SESSION["tst_import_results_file"], $newObj);
659  $results->startParsing();
660  }
661 
662  // delete import directory
664  ilUtil::sendSuccess($this->lng->txt("object_imported"),true);
665  ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
666  "&baseClass=ilObjTestGUI");
667  }
668 
675  function uploadObject($redirect = true)
676  {
677  $this->uploadTstObject();
678  }
679 
689  function confirmChangeProperties($direction = 0)
690  {
691  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_properties_save_confirmation.html", "Modules/Test");
692  $information = "";
693  switch ($direction)
694  {
695  case 0:
696  $information = $this->lng->txt("change_properties_from_random_to_standard");
697  break;
698  default:
699  $information = $this->lng->txt("change_properties_from_standard_to_random");
700  break;
701  }
702  foreach ($_POST as $key => $value)
703  {
704  if (strcmp($key, "cmd") != 0)
705  {
706  if (is_array($value))
707  {
708  foreach ($value as $k => $v)
709  {
710  $this->tpl->setCurrentBlock("hidden_variable");
711  $this->tpl->setVariable("HIDDEN_KEY", $key . "[" . $k . "]");
712  $this->tpl->setVariable("HIDDEN_VALUE", $v);
713  $this->tpl->parseCurrentBlock();
714  }
715  }
716  else
717  {
718  $this->tpl->setCurrentBlock("hidden_variable");
719  $this->tpl->setVariable("HIDDEN_KEY", $key);
720  $this->tpl->setVariable("HIDDEN_VALUE", $value);
721  $this->tpl->parseCurrentBlock();
722  }
723  }
724  }
725  $this->tpl->setCurrentBlock("hidden_variable");
726  $this->tpl->setVariable("HIDDEN_KEY", "tst_properties_confirmation");
727  $this->tpl->setVariable("HIDDEN_VALUE", "1");
728  $this->tpl->parseCurrentBlock();
729  $this->tpl->setCurrentBlock("adm_content");
730  $this->tpl->setVariable("TXT_CONFIRMATION", $this->lng->txt("confirmation"));
731  $this->tpl->setVariable("TXT_INFORMATION", $information);
732  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
733  $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
734  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
735  $this->tpl->parseCurrentBlock();
736  }
737 
743  function saveScoringObject()
744  {
745  $hasErrors = $this->scoringObject(true);
746  if (!$hasErrors)
747  {
748  $total = $this->object->evalTotalPersons();
749  // Check the values the user entered in the form
750  if (!$total)
751  {
752  $this->object->setCountSystem($_POST["count_system"]);
753  $this->object->setMCScoring($_POST["mc_scoring"]);
754  $this->object->setScoreCutting($_POST["score_cutting"]);
755  $this->object->setPassScoring($_POST["pass_scoring"]);
756  }
757 
758  $this->object->setAnswerFeedback((is_array($_POST['instant_feedback']) && in_array('instant_feedback_answer', $_POST['instant_feedback'])) ? 1 : 0);
759  $this->object->setAnswerFeedbackPoints((is_array($_POST['instant_feedback']) && in_array('instant_feedback_points', $_POST['instant_feedback'])) ? 1 : 0);
760  $this->object->setInstantFeedbackSolution((is_array($_POST['instant_feedback']) && in_array('instant_feedback_solution', $_POST['instant_feedback'])) ? 1 : 0);
761 
762  $this->object->setScoreReporting($_POST["results_access"]);
763  if ($this->object->getScoreReporting() == REPORT_AFTER_DATE)
764  {
765  $this->object->setReportingDate(sprintf("%04d%02d%02d%02d%02d%02d",
766  $_POST["reporting_date"]['date']["y"],
767  $_POST["reporting_date"]['date']["m"],
768  $_POST["reporting_date"]['date']["d"],
769  $_POST["reporting_date"]['time']["h"],
770  $_POST["reporting_date"]['time']["m"],
771  $_POST["reporting_date"]['time']["s"]
772  ));
773  }
774  else
775  {
776  $this->object->setReportingDate('');
777  }
778 
779  $this->object->setShowPassDetails((is_array($_POST['results_presentation']) && in_array('pass_details', $_POST['results_presentation'])) ? 1 : 0);
780  $this->object->setShowSolutionDetails((is_array($_POST['results_presentation']) && in_array('solution_details', $_POST['results_presentation'])) ? 1 : 0);
781  $this->object->setShowSolutionPrintview((is_array($_POST['results_presentation']) && in_array('solution_printview', $_POST['results_presentation'])) ? 1 : 0);
782  $this->object->setShowSolutionFeedback((is_array($_POST['results_presentation']) && in_array('solution_feedback', $_POST['results_presentation'])) ? 1 : 0);
783  $this->object->setShowSolutionAnswersOnly((is_array($_POST['results_presentation']) && in_array('solution_answers_only', $_POST['results_presentation'])) ? 1 : 0);
784  $this->object->setShowSolutionSignature((is_array($_POST['results_presentation']) && in_array('solution_signature', $_POST['results_presentation'])) ? 1 : 0);
785  $this->object->setShowSolutionSuggested((is_array($_POST['results_presentation']) && in_array('solution_suggested', $_POST['results_presentation'])) ? 1 : 0);
786 
787  $this->object->setExportSettingsSingleChoiceShort((is_array($_POST['export_settings']) && in_array('exp_sc_short', $_POST['export_settings'])) ? 1 : 0);
788 
789  $this->object->saveToDb(true);
790  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), TRUE);
791  $this->ctrl->redirect($this, "scoring");
792  }
793  }
794 
800  function scoringObject($checkonly = FALSE)
801  {
802  global $ilAccess;
803  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
804  {
805  // allow only write access
806  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
807  $this->ctrl->redirect($this, "infoScreen");
808  }
809 
810  $save = (strcmp($this->ctrl->getCmd(), "saveScoring") == 0) ? TRUE : FALSE;
811  $total = $this->object->evalTotalPersons();
812  $this->tpl->addJavascript("./Services/JavaScript/js/Basic.js");
813 
814  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
815  $form = new ilPropertyFormGUI();
816  $form->setFormAction($this->ctrl->getFormAction($this));
817  $form->setTableWidth("100%");
818  $form->setId("test_properties_scoring");
819 
820  // scoring properties
821  $header = new ilFormSectionHeaderGUI();
822  $header->setTitle($this->lng->txt("scoring"));
823  $form->addItem($header);
824 
825  // scoring system
826  $count_system = new ilRadioGroupInputGUI($this->lng->txt("tst_text_count_system"), "count_system");
827  $count_system->addOption(new ilRadioOption($this->lng->txt("tst_count_partial_solutions"), 0, ''));
828  $count_system->addOption(new ilRadioOption($this->lng->txt("tst_count_correct_solutions"), 1, ''));
829  $count_system->setValue($this->object->getCountSystem());
830  $count_system->setInfo($this->lng->txt("tst_count_system_description"));
831  if ($total)
832  {
833  $count_system->setDisabled(true);
834  }
835  $form->addItem($count_system);
836 
837  // mc questions
838  $mc_scoring = new ilRadioGroupInputGUI($this->lng->txt("tst_score_mcmr_questions"), "mc_scoring");
839  $mc_scoring->addOption(new ilRadioOption($this->lng->txt("tst_score_mcmr_zero_points_when_unanswered"), 0, ''));
840  $mc_scoring->addOption(new ilRadioOption($this->lng->txt("tst_score_mcmr_use_scoring_system"), 1, ''));
841  $mc_scoring->setValue($this->object->getMCScoring());
842  $mc_scoring->setInfo($this->lng->txt("tst_score_mcmr_questions_description"));
843  if ($total)
844  {
845  $mc_scoring->setDisabled(true);
846  }
847  $form->addItem($mc_scoring);
848 
849  // score cutting
850  $score_cutting = new ilRadioGroupInputGUI($this->lng->txt("tst_score_cutting"), "score_cutting");
851  $score_cutting->addOption(new ilRadioOption($this->lng->txt("tst_score_cut_question"), 0, ''));
852  $score_cutting->addOption(new ilRadioOption($this->lng->txt("tst_score_cut_test"), 1, ''));
853  $score_cutting->setValue($this->object->getScoreCutting());
854  $score_cutting->setInfo($this->lng->txt("tst_score_cutting_description"));
855  if ($total)
856  {
857  $score_cutting->setDisabled(true);
858  }
859  $form->addItem($score_cutting);
860 
861  // pass scoring
862  $pass_scoring = new ilRadioGroupInputGUI($this->lng->txt("tst_pass_scoring"), "pass_scoring");
863  $pass_scoring->addOption(new ilRadioOption($this->lng->txt("tst_pass_last_pass"), 0, ''));
864  $pass_scoring->addOption(new ilRadioOption($this->lng->txt("tst_pass_best_pass"), 1, ''));
865  $pass_scoring->setValue($this->object->getPassScoring());
866  $pass_scoring->setInfo($this->lng->txt("tst_pass_scoring_description"));
867  if ($total)
868  {
869  $pass_scoring->setDisabled(true);
870  }
871  $form->addItem($pass_scoring);
872 
873  // instant feedback
874  $instant_feedback = new ilCheckboxGroupInputGUI($this->lng->txt("tst_instant_feedback"), "instant_feedback");
875  $instant_feedback->addOption(new ilCheckboxOption($this->lng->txt("tst_instant_feedback_answer_specific"), 'instant_feedback_answer', ''));
876  $instant_feedback->addOption(new ilCheckboxOption($this->lng->txt("tst_instant_feedback_results"), 'instant_feedback_points', ''));
877  $instant_feedback->addOption(new ilCheckboxOption($this->lng->txt("tst_instant_feedback_solution"), 'instant_feedback_solution', ''));
878  $values = array();
879  if ($this->object->getAnswerFeedback()) array_push($values, 'instant_feedback_answer');
880  if ($this->object->getAnswerFeedbackPoints()) array_push($values, 'instant_feedback_points');
881  if ($this->object->getInstantFeedbackSolution()) array_push($values, 'instant_feedback_solution');
882  $instant_feedback->setValue($values);
883  $instant_feedback->setInfo($this->lng->txt("tst_instant_feedback_description"));
884  $form->addItem($instant_feedback);
885 
886  // access to test results
887  $results_access = new ilRadioGroupInputGUI($this->lng->txt("tst_results_access"), "results_access");
888  $results_access->addOption(new ilRadioOption($this->lng->txt("tst_results_access_finished"), 1, ''));
889  $results_access->addOption(new ilRadioOption($this->lng->txt("tst_results_access_always"), 2, ''));
890  $results_access->addOption(new ilRadioOption($this->lng->txt("tst_results_access_never"), 4, ''));
891  $results_access->addOption(new ilRadioOption($this->lng->txt("tst_results_access_date"), 3, ''));
892  $results_access->setValue($this->object->getScoreReporting());
893  $results_access->setInfo($this->lng->txt("tst_results_access_description"));
894 
895  // access date
896  $reporting_date = new ilDateTimeInputGUI('', 'reporting_date');
897  $reporting_date->setShowDate(true);
898  $reporting_date->setShowTime(true);
899  if (strlen($this->object->getReportingDate()))
900  {
901  $reporting_date->setDate(new ilDateTime($this->object->getReportingDate(), IL_CAL_TIMESTAMP));
902  }
903  else
904  {
905  $reporting_date->setDate(new ilDateTime(time(), IL_CAL_UNIX));
906  }
907  $results_access->addSubItem($reporting_date);
908  $form->addItem($results_access);
909 
910  // results presentation
911  $results_presentation = new ilCheckboxGroupInputGUI($this->lng->txt("tst_results_presentation"), "results_presentation");
912  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_pass_details"), 'pass_details', ''));
913  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_details"), 'solution_details', ''));
914  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_printview"), 'solution_printview', ''));
915  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_feedback"), 'solution_feedback', ''));
916  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_answers_only"), 'solution_answers_only', ''));
917  $signatureOption = new ilCheckboxOption($this->lng->txt("tst_show_solution_signature"), 'solution_signature', '');
918  $results_presentation->addOption($signatureOption);
919  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_suggested"), 'solution_suggested', ''));
920  $values = array();
921  if ($this->object->getShowPassDetails()) array_push($values, 'pass_details');
922  if ($this->object->getShowSolutionDetails()) array_push($values, 'solution_details');
923  if ($this->object->getShowSolutionPrintview()) array_push($values, 'solution_printview');
924  if ($this->object->getShowSolutionFeedback()) array_push($values, 'solution_feedback');
925  if ($this->object->getShowSolutionAnswersOnly()) array_push($values, 'solution_answers_only');
926  if ($this->object->getShowSolutionSignature()) array_push($values, 'solution_signature');
927  if ($this->object->getShowSolutionSuggested()) array_push($values, 'solution_suggested');
928  $results_presentation->setValue($values);
929  $results_presentation->setInfo($this->lng->txt("tst_results_presentation_description"));
930  if ($this->object->getAnonymity())
931  {
932  $signatureOption->setDisabled(true);
933  }
934  $form->addItem($results_presentation);
935 
936  // export settings
937  $export_settings = new ilCheckboxGroupInputGUI($this->lng->txt("tst_export_settings"), "export_settings");
938  $export_settings->addOption(new ilCheckboxOption($this->lng->txt("tst_exp_sc_short"), 'exp_sc_short', ''));
939  $values = array();
940  if ($this->object->getExportSettingsSingleChoiceShort()) array_push($values, 'exp_sc_short');
941  $export_settings->setValue($values);
942  $form->addItem($export_settings);
943 
944  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) $form->addCommandButton("saveScoring", $this->lng->txt("save"));
945  $errors = false;
946 
947  if ($save)
948  {
949  $errors = !$form->checkInput();
950  $form->setValuesByPost();
951  if ($errors) $checkonly = false;
952  }
953  if (!$checkonly) $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
954  return $errors;
955  }
956 
962  function propertiesObject($checkonly = FALSE)
963  {
964  global $ilAccess;
965  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
966  {
967  // allow only write access
968  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
969  $this->ctrl->redirect($this, "infoScreen");
970  }
971 
972  $save = (strcmp($this->ctrl->getCmd(), "saveProperties") == 0) ? TRUE : FALSE;
973  $total = $this->object->evalTotalPersons();
974  $this->tpl->addJavascript("./Services/JavaScript/js/Basic.js");
975 
976  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
977  $form = new ilPropertyFormGUI();
978  $form->setFormAction($this->ctrl->getFormAction($this));
979  $form->setTableWidth("100%");
980  $form->setId("test_properties");
981 
982  // general properties
983  $header = new ilFormSectionHeaderGUI();
984  $header->setTitle($this->lng->txt("tst_general_properties"));
985  $form->addItem($header);
986 
987  // anonymity
988  $anonymity = new ilCheckboxInputGUI($this->lng->txt("tst_anonymity"), "anonymity");
989  $anonymity->setValue(1);
990  if ($total) $anonymity->setDisabled(true);
991  $anonymity->setChecked($this->object->getAnonymity());
992  $anonymity->setInfo($this->lng->txt("tst_anonymity_description"));
993  $form->addItem($anonymity);
994 
995  // random selection of questions
996  $random = new ilCheckboxInputGUI($this->lng->txt("tst_random_selection"), "random_test");
997  $random->setValue(1);
998  if ($total) $random->setDisabled(true);
999  $random->setChecked($this->object->isRandomTest());
1000  $random->setInfo($this->lng->txt("tst_random_test_description"));
1001  $form->addItem($random);
1002 
1003  // introduction
1004  $intro = new ilTextAreaInputGUI($this->lng->txt("tst_introduction"), "introduction");
1005  $intro->setValue($this->object->prepareTextareaOutput($this->object->getIntroduction()));
1006  $intro->setRows(10);
1007  $intro->setCols(80);
1008  $intro->setUseRte(TRUE);
1009  $intro->addPlugin("latex");
1010  $intro->addButton("latex");
1011  $intro->setRTESupport($this->object->getId(), "tst", "assessment");
1012  $intro->setRteTagSet('full');
1013  // showinfo
1014  $showinfo = new ilCheckboxInputGUI('', "showinfo");
1015  $showinfo->setValue(1);
1016  $showinfo->setChecked($this->object->getShowInfo());
1017  $showinfo->setOptionTitle($this->lng->txt("showinfo"));
1018  $showinfo->setInfo($this->lng->txt("showinfo_desc"));
1019  $intro->addSubItem($showinfo);
1020  $form->addItem($intro);
1021 
1022  // final statement
1023  $finalstatement = new ilTextAreaInputGUI($this->lng->txt("final_statement"), "finalstatement");
1024  $finalstatement->setValue($this->object->prepareTextareaOutput($this->object->getFinalStatement()));
1025  $finalstatement->setRows(10);
1026  $finalstatement->setCols(80);
1027  $finalstatement->setUseRte(TRUE);
1028  $finalstatement->addPlugin("latex");
1029  $finalstatement->addButton("latex");
1030  $finalstatement->setRTESupport($this->object->getId(), "tst", "assessment");
1031  $finalstatement->setRteTagSet('full');
1032  // show final statement
1033  $showfinal = new ilCheckboxInputGUI('', "showfinalstatement");
1034  $showfinal->setValue(1);
1035  $showfinal->setChecked($this->object->getShowFinalStatement());
1036  $showfinal->setOptionTitle($this->lng->txt("final_statement_show"));
1037  $showfinal->setInfo($this->lng->txt("final_statement_show_desc"));
1038  $finalstatement->addSubItem($showfinal);
1039  $form->addItem($finalstatement);
1040 
1041  // sequence properties
1042  $seqheader = new ilFormSectionHeaderGUI();
1043  $seqheader->setTitle($this->lng->txt("tst_sequence_properties"));
1044  $form->addItem($seqheader);
1045 
1046  // postpone questions
1047  $postpone = new ilCheckboxInputGUI($this->lng->txt("tst_postpone"), "chb_postpone");
1048  $postpone->setValue(1);
1049  $postpone->setChecked($this->object->getSequenceSettings());
1050  $postpone->setInfo($this->lng->txt("tst_postpone_description"));
1051  $form->addItem($postpone);
1052 
1053  // shuffle questions
1054  $shuffle = new ilCheckboxInputGUI($this->lng->txt("tst_shuffle_questions"), "chb_shuffle_questions");
1055  $shuffle->setValue(1);
1056  $shuffle->setChecked($this->object->getShuffleQuestions());
1057  $shuffle->setInfo($this->lng->txt("tst_shuffle_questions_description"));
1058  $form->addItem($shuffle);
1059 
1060  // show list of questions
1061  $list_of_questions = new ilCheckboxInputGUI($this->lng->txt("tst_show_summary"), "list_of_questions");
1062  $list_of_questions->setOptionTitle($this->lng->txt("tst_show_summary"));
1063  $list_of_questions->setValue(1);
1064  $list_of_questions->setChecked($this->object->getListOfQuestions());
1065  $list_of_questions->setInfo($this->lng->txt("tst_show_summary_description"));
1066 
1067  $list_of_questions_options = new ilCheckboxGroupInputGUI('', "list_of_questions_options");
1068  $list_of_questions_options->addOption(new ilCheckboxOption($this->lng->txt("tst_list_of_questions_start"), 'chb_list_of_questions_start', ''));
1069  $list_of_questions_options->addOption(new ilCheckboxOption($this->lng->txt("tst_list_of_questions_end"), 'chb_list_of_questions_end', ''));
1070  $list_of_questions_options->addOption(new ilCheckboxOption($this->lng->txt("tst_list_of_questions_with_description"), 'chb_list_of_questions_with_description', ''));
1071  $values = array();
1072  if ($this->object->getListOfQuestionsStart()) array_push($values, 'chb_list_of_questions_start');
1073  if ($this->object->getListOfQuestionsEnd()) array_push($values, 'chb_list_of_questions_end');
1074  if ($this->object->getListOfQuestionsDescription()) array_push($values, 'chb_list_of_questions_with_description');
1075  $list_of_questions_options->setValue($values);
1076 
1077  $list_of_questions->addSubItem($list_of_questions_options);
1078  $form->addItem($list_of_questions);
1079 
1080  // show question marking
1081  $marking = new ilCheckboxInputGUI($this->lng->txt("question_marking"), "chb_show_marker");
1082  $marking->setValue(1);
1083  $marking->setChecked($this->object->getShowMarker());
1084  $marking->setInfo($this->lng->txt("question_marking_description"));
1085  $form->addItem($marking);
1086 
1087  // show suspend test
1088  $cancel = new ilCheckboxInputGUI($this->lng->txt("tst_show_cancel"), "chb_show_cancel");
1089  $cancel->setValue(1);
1090  $cancel->setChecked($this->object->getShowCancel());
1091  $cancel->setInfo($this->lng->txt("tst_show_cancel_description"));
1092  $form->addItem($cancel);
1093 
1094  // kiosk mode properties
1095  $kioskheader = new ilFormSectionHeaderGUI();
1096  $kioskheader->setTitle($this->lng->txt("kiosk"));
1097  $form->addItem($kioskheader);
1098 
1099  // kiosk mode
1100  $kiosk = new ilCheckboxInputGUI($this->lng->txt("kiosk"), "kiosk");
1101  $kiosk->setValue(1);
1102  $kiosk->setChecked($this->object->getKioskMode());
1103  $kiosk->setInfo($this->lng->txt("kiosk_description"));
1104 
1105  // kiosk mode options
1106  $kiosktitle = new ilCheckboxGroupInputGUI($this->lng->txt("kiosk_options"), "kiosk_options");
1107  $kiosktitle->addOption(new ilCheckboxOption($this->lng->txt("kiosk_show_title"), 'kiosk_title', ''));
1108  $kiosktitle->addOption(new ilCheckboxOption($this->lng->txt("kiosk_show_participant"), 'kiosk_participant', ''));
1109  $values = array();
1110  if ($this->object->getShowKioskModeTitle()) array_push($values, 'kiosk_title');
1111  if ($this->object->getShowKioskModeParticipant()) array_push($values, 'kiosk_participant');
1112  $kiosktitle->setValue($values);
1113  $kiosktitle->setInfo($this->lng->txt("kiosk_options_desc"));
1114  $kiosk->addSubItem($kiosktitle);
1115 
1116  $form->addItem($kiosk);
1117 
1118  // session properties
1119  $sessionheader = new ilFormSectionHeaderGUI();
1120  $sessionheader->setTitle($this->lng->txt("tst_session_settings"));
1121  $form->addItem($sessionheader);
1122 
1123  // max. number of passes
1124  $nr_of_tries = new ilTextInputGUI($this->lng->txt("tst_nr_of_tries"), "nr_of_tries");
1125  $nr_of_tries->setSize(3);
1126  $nr_of_tries->setValue($this->object->getNrOfTries());
1127  $nr_of_tries->setRequired(true);
1128  $nr_of_tries->setSuffix($this->lng->txt("0_unlimited"));
1129  if ($total) $nr_of_tries->setDisabled(true);
1130  $form->addItem($nr_of_tries);
1131 
1132  // enable max. processing time
1133  $processing = new ilCheckboxInputGUI($this->lng->txt("tst_processing_time"), "chb_processing_time");
1134  $processing->setValue(1);
1135  $processing->setOptionTitle($this->lng->txt("enabled"));
1136  $processing->setChecked($this->object->getEnableProcessingTime());
1137 
1138  // max. processing time
1139  $processingtime = new ilDurationInputGUI('', 'processing_time');
1140  $ptime = $this->object->getProcessingTimeAsArray();
1141  $processingtime->setHours($ptime['hh']);
1142  $processingtime->setMinutes($ptime['mm']);
1143  $processingtime->setSeconds($ptime['ss']);
1144  $processingtime->setShowMonths(false);
1145  $processingtime->setShowDays(false);
1146  $processingtime->setShowHours(true);
1147  $processingtime->setShowMinutes(true);
1148  $processingtime->setShowSeconds(true);
1149  $processingtime->setInfo($this->lng->txt("tst_processing_time_desc"));
1150  $processing->addSubItem($processingtime);
1151 
1152  // reset max. processing time
1153  $resetprocessing = new ilCheckboxInputGUI('', "chb_reset_processing_time");
1154  $resetprocessing->setValue(1);
1155  $resetprocessing->setOptionTitle($this->lng->txt("tst_reset_processing_time"));
1156  $resetprocessing->setChecked($this->object->getResetProcessingTime());
1157  $resetprocessing->setInfo($this->lng->txt("tst_reset_processing_time_desc"));
1158  $processing->addSubItem($resetprocessing);
1159  $form->addItem($processing);
1160 
1161  // enable starting time
1162  $enablestartingtime = new ilCheckboxInputGUI($this->lng->txt("tst_starting_time"), "chb_starting_time");
1163  $enablestartingtime->setValue(1);
1164  $enablestartingtime->setOptionTitle($this->lng->txt("enabled"));
1165  $enablestartingtime->setChecked(strlen($this->object->getStartingTime()));
1166  // starting time
1167  $startingtime = new ilDateTimeInputGUI('', 'starting_time');
1168  $startingtime->setShowDate(true);
1169  $startingtime->setShowTime(true);
1170  if (strlen($this->object->getStartingTime()))
1171  {
1172  $startingtime->setDate(new ilDateTime($this->object->getStartingTime(), IL_CAL_TIMESTAMP));
1173  }
1174  else
1175  {
1176  $startingtime->setDate(new ilDateTime(time(), IL_CAL_UNIX));
1177  }
1178  $enablestartingtime->addSubItem($startingtime);
1179  if ($total) $enablestartingtime->setDisabled(true);
1180  if ($total) $startingtime->setDisabled(true);
1181  $form->addItem($enablestartingtime);
1182 
1183  // enable ending time
1184  $enableendingtime = new ilCheckboxInputGUI($this->lng->txt("tst_ending_time"), "chb_ending_time");
1185  $enableendingtime->setValue(1);
1186  $enableendingtime->setOptionTitle($this->lng->txt("enabled"));
1187  $enableendingtime->setChecked(strlen($this->object->getEndingTime()));
1188  // ending time
1189  $endingtime = new ilDateTimeInputGUI('', 'ending_time');
1190  $endingtime->setShowDate(true);
1191  $endingtime->setShowTime(true);
1192  if (strlen($this->object->getEndingTime()))
1193  {
1194  $endingtime->setDate(new ilDateTime($this->object->getEndingTime(), IL_CAL_TIMESTAMP));
1195  }
1196  else
1197  {
1198  $endingtime->setDate(new ilDateTime(time(), IL_CAL_UNIX));
1199  }
1200  $enableendingtime->addSubItem($endingtime);
1201  $form->addItem($enableendingtime);
1202 
1203  // use previous answers
1204  $prevanswers = new ilCheckboxInputGUI($this->lng->txt("tst_use_previous_answers"), "chb_use_previous_answers");
1205  $prevanswers->setValue(1);
1206  $prevanswers->setChecked($this->object->getUsePreviousAnswers());
1207  $prevanswers->setInfo($this->lng->txt("tst_use_previous_answers_description"));
1208  $form->addItem($prevanswers);
1209 
1210  // force js
1211  $forcejs = new ilCheckboxInputGUI($this->lng->txt("forcejs_short"), "forcejs");
1212  $forcejs->setValue(1);
1213  $forcejs->setChecked($this->object->getForceJS());
1214  $forcejs->setOptionTitle($this->lng->txt("forcejs"));
1215  $forcejs->setInfo($this->lng->txt("forcejs_desc"));
1216  $form->addItem($forcejs);
1217 
1218  // question title output
1219  $title_output = new ilRadioGroupInputGUI($this->lng->txt("tst_title_output"), "title_output");
1220  $title_output->addOption(new ilRadioOption($this->lng->txt("tst_title_output_full"), 0, ''));
1221  $title_output->addOption(new ilRadioOption($this->lng->txt("tst_title_output_hide_points"), 1, ''));
1222  $title_output->addOption(new ilRadioOption($this->lng->txt("tst_title_output_no_title"), 2, ''));
1223  $title_output->setValue($this->object->getTitleOutput());
1224  $title_output->setInfo($this->lng->txt("tst_title_output_description"));
1225  $form->addItem($title_output);
1226 
1227  // test password
1228  $password = new ilTextInputGUI($this->lng->txt("tst_password"), "password");
1229  $password->setSize(20);
1230  $password->setValue($this->object->getPassword());
1231  $password->setInfo($this->lng->txt("tst_password_details"));
1232  $form->addItem($password);
1233 
1234  // participants properties
1235  $restrictions = new ilFormSectionHeaderGUI();
1236  $restrictions->setTitle($this->lng->txt("tst_max_allowed_users"));
1237  $form->addItem($restrictions);
1238 
1239  $fixedparticipants = new ilCheckboxInputGUI($this->lng->txt('participants_invitation'), "fixedparticipants");
1240  $fixedparticipants->setValue(1);
1241  $fixedparticipants->setChecked($this->object->getFixedParticipants());
1242  $fixedparticipants->setOptionTitle($this->lng->txt("tst_allow_fixed_participants"));
1243  $fixedparticipants->setInfo($this->lng->txt("participants_invitation_description"));
1244  $invited_users = $this->object->getInvitedUsers();
1245  if ($total && (count($invited_users) == 0))
1246  {
1247  $fixedparticipants->setDisabled(true);
1248  }
1249  $form->addItem($fixedparticipants);
1250 
1251 
1252  // simultaneous users
1253  $simul = new ilTextInputGUI($this->lng->txt("tst_allowed_users"), "allowedUsers");
1254  $simul->setSize(3);
1255  $simul->setValue(($this->object->getAllowedUsers()) ? $this->object->getAllowedUsers() : '');
1256  $form->addItem($simul);
1257 
1258  // idle time
1259  $idle = new ilTextInputGUI($this->lng->txt("tst_allowed_users_time_gap"), "allowedUsersTimeGap");
1260  $idle->setSize(4);
1261  $idle->setSuffix($this->lng->txt("seconds"));
1262  $idle->setValue(($this->object->getAllowedUsersTimeGap()) ? $this->object->getAllowedUsersTimeGap() : '');
1263  $form->addItem($idle);
1264 
1265  // notifications
1266  $notifications = new ilFormSectionHeaderGUI();
1267  $notifications->setTitle($this->lng->txt("notifications"));
1268  $form->addItem($notifications);
1269 
1270  // mail notification
1271  $mailnotification = new ilRadioGroupInputGUI($this->lng->txt("tst_finish_notification"), "mailnotification");
1272  $mailnotification->addOption(new ilRadioOption($this->lng->txt("tst_finish_notification_no"), 0, ''));
1273  $mailnotification->addOption(new ilRadioOption($this->lng->txt("tst_finish_notification_simple"), 1, ''));
1274  $mailnotification->addOption(new ilRadioOption($this->lng->txt("tst_finish_notification_advanced"), 2, ''));
1275  $mailnotification->setValue($this->object->getMailNotification());
1276  $form->addItem($mailnotification);
1277 
1278  $mailnottype = new ilCheckboxInputGUI('', "mailnottype");
1279  $mailnottype->setValue(1);
1280  $mailnottype->setOptionTitle($this->lng->txt("mailnottype"));
1281  $mailnottype->setChecked($this->object->getMailNotificationType());
1282  $form->addItem($mailnottype);
1283 
1284  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) $form->addCommandButton("saveProperties", $this->lng->txt("save"));
1285  $errors = false;
1286 
1287  if ($save)
1288  {
1289  $errors = !$form->checkInput();
1290  $form->setValuesByPost();
1291  if ($errors) $checkonly = false;
1292  }
1293  if (!$checkonly) $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
1294  return $errors;
1295  }
1296 
1303  {
1304  if (!array_key_exists("tst_properties_confirmation", $_POST))
1305  {
1306  $hasErrors = $this->propertiesObject(true);
1307  }
1308  else
1309  {
1310  $hasErrors = false;
1311  }
1312  if (!$hasErrors)
1313  {
1314  $total = $this->object->evalTotalPersons();
1315  $randomtest_switch = false;
1316  // Check the values the user entered in the form
1317  if (!$total)
1318  {
1319  if (!array_key_exists("tst_properties_confirmation", $_POST))
1320  {
1321  if (($this->object->isRandomTest()) && (count($this->object->getRandomQuestionpools()) > 0))
1322  {
1323  if (!$_POST["random_test"])
1324  {
1325  // user tries to change from a random test with existing random question pools to a non random test
1326  $this->confirmChangeProperties(0);
1327  return;
1328  }
1329  }
1330  if ((!$this->object->isRandomTest()) && (count($this->object->questions) > 0))
1331  {
1332  if ($_POST["random_test"])
1333  {
1334  // user tries to change from a non random test with existing questions to a random test
1335  $this->confirmChangeProperties(1);
1336  return;
1337  }
1338  }
1339  }
1340 
1341  if (!strlen($_POST["random_test"]))
1342  {
1343  $random_test = 0;
1344  }
1345  else
1346  {
1347  $random_test = $_POST["random_test"];
1348  }
1349  }
1350  else
1351  {
1352  $random_test = $this->object->isRandomTest();
1353  }
1354  if ($random_test != $this->object->isRandomTest())
1355  {
1356  $randomtest_switch = true;
1357  }
1358 
1359  if (!$total)
1360  {
1361  $this->object->setAnonymity($_POST["anonymity"]);
1362  $this->object->setRandomTest($random_test);
1363  $this->object->setNrOfTries($_POST["nr_of_tries"]);
1364  if ($_POST['chb_starting_time'])
1365  {
1366  $this->object->setStartingTime(ilFormat::dateDB2timestamp($_POST['starting_time']['date'] . ' ' . $_POST['starting_time']['time']));
1367  }
1368  else
1369  {
1370  $this->object->setStartingTime('');
1371  }
1372  }
1373  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
1374  $this->object->setIntroduction($_POST["introduction"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment"));
1375  $this->object->setShowInfo(($_POST["showinfo"]) ? 1 : 0);
1376  $this->object->setFinalStatement($_POST["finalstatement"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment"));
1377  $this->object->setShowFinalStatement(($_POST["showfinalstatement"]) ? 1 : 0);
1378  $this->object->setSequenceSettings(($_POST["chb_postpone"]) ? 1 : 0);
1379  $this->object->setShuffleQuestions(($_POST["chb_shuffle_questions"]) ? 1 : 0);
1380  $this->object->setListOfQuestions($_POST["list_of_questions"]);
1381  if (is_array($_POST["list_of_questions_options"]))
1382  {
1383  $this->object->setListOfQuestionsStart((in_array('chb_list_of_questions_start', $_POST["list_of_questions_options"])) ? 1 : 0);
1384  $this->object->setListOfQuestionsEnd((in_array('chb_list_of_questions_end', $_POST["list_of_questions_options"])) ? 1 : 0);
1385  $this->object->setListOfQuestionsDescription((in_array('chb_list_of_questions_with_description', $_POST["list_of_questions_options"])) ? 1 : 0);
1386  }
1387  else
1388  {
1389  $this->object->setListOfQuestionsStart(0);
1390  $this->object->setListOfQuestionsEnd(0);
1391  $this->object->setListOfQuestionsDescription(0);
1392  }
1393  $this->object->setMailNotification($_POST["mailnotification"]);
1394  $this->object->setMailNotificationType($_POST["mailnottype"]);
1395  $this->object->setShowMarker(($_POST["chb_show_marker"]) ? 1 : 0);
1396  $this->object->setShowCancel(($_POST["chb_show_cancel"]) ? 1 : 0);
1397  $this->object->setKioskMode(($_POST["kiosk"]) ? 1 : 0);
1398  $this->object->setShowKioskModeTitle((is_array($_POST["kiosk_options"]) && in_array('kiosk_title', $_POST["kiosk_options"])) ? 1 : 0);
1399  $this->object->setShowKioskModeParticipant((is_array($_POST["kiosk_options"]) && in_array('kiosk_participant', $_POST["kiosk_options"])) ? 1 : 0);
1400  $this->object->setEnableProcessingTime(($_POST["chb_processing_time"]) ? 1 : 0);
1401  if ($this->object->getEnableProcessingTime())
1402  {
1403  $this->object->setProcessingTime(sprintf("%02d:%02d:%02d",
1404  $_POST["processing_time"]["hh"],
1405  $_POST["processing_time"]["mm"],
1406  $_POST["processing_time"]["ss"]
1407  ));
1408  }
1409  else
1410  {
1411  $this->object->setProcessingTime('');
1412  }
1413  $this->object->setResetProcessingTime(($_POST["chb_reset_processing_time"]) ? 1 : 0);
1414  if ($_POST['chb_ending_time'])
1415  {
1416  $this->object->setEndingTime(ilFormat::dateDB2timestamp($_POST['ending_time']['date'] . ' ' . $_POST['ending_time']['time']));
1417  }
1418  else
1419  {
1420  $this->object->setEndingTime('');
1421  }
1422  $this->object->setUsePreviousAnswers(($_POST["chb_use_previous_answers"]) ? 1 : 0);
1423  $this->object->setForceJS(($_POST["forcejs"]) ? 1 : 0);
1424  $this->object->setTitleOutput($_POST["title_output"]);
1425  $this->object->setPassword($_POST["password"]);
1426  $this->object->setAllowedUsers($_POST["allowedUsers"]);
1427  $this->object->setAllowedUsersTimeGap($_POST["allowedUsersTimeGap"]);
1428 
1429  if ($this->object->isRandomTest())
1430  {
1431  $this->object->setUsePreviousAnswers(0);
1432  }
1433 
1434  $invited_users = $this->object->getInvitedUsers();
1435  if (!($total && (count($invited_users) == 0)))
1436  {
1437  $fixed_participants = 0;
1438  if (array_key_exists("fixedparticipants", $_POST))
1439  {
1440  if ($_POST["fixedparticipants"])
1441  {
1442  $fixed_participants = 1;
1443  }
1444  }
1445  $this->object->setFixedParticipants($fixed_participants);
1446  if (!$fixed_participants)
1447  {
1448  $invited_users = $this->object->getInvitedUsers();
1449  foreach ($invited_users as $user_object)
1450  {
1451  $this->object->disinviteUser($user_object["usr_id"]);
1452  }
1453  }
1454  }
1455 
1456  $this->object->saveToDb(true);
1457 
1458  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1459  if ($randomtest_switch)
1460  {
1461  if ($this->object->isRandomTest())
1462  {
1463  $this->object->removeNonRandomTestData();
1464  }
1465  else
1466  {
1467  $this->object->removeRandomTestData();
1468  }
1469  }
1470 
1471  $this->ctrl->redirect($this, 'properties');
1472  }
1473  }
1474 
1479  {
1480  $file = explode("_", $_GET["file_id"]);
1481  include_once("./Modules/File/classes/class.ilObjFile.php");
1482  $fileObj =& new ilObjFile($file[count($file) - 1], false);
1483  $fileObj->sendFile();
1484  exit;
1485  }
1486 
1490  function fullscreenObject()
1491  {
1492  include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
1493  //$page =& new ilPageObject("qpl", $_GET["pg_id"]);
1494  $page_gui =& new ilPageObjectGUI("qpl", $_GET["pg_id"]);
1495  $page_gui->showMediaFullscreen();
1496 
1497  }
1498 
1503  {
1504  include_once("./Services/COPage/classes/class.ilPageObject.php");
1505  $pg_obj =& new ilPageObject("qpl", $_GET["pg_id"]);
1506  $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
1507  exit;
1508  }
1509 
1517  function filterObject()
1518  {
1519  $this->questionBrowser();
1520  }
1521 
1530  {
1531  $this->questionBrowser();
1532  }
1533 
1541  function backObject()
1542  {
1543  $this->ctrl->redirect($this, "questions");
1544  }
1545 
1554  function createQuestionPool($name = "dummy")
1555  {
1556  global $tree;
1557  $parent_ref = $tree->getParentId($this->object->getRefId());
1558  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
1559  $qpl = new ilObjQuestionPool();
1560  $qpl->setType("qpl");
1561  $qpl->setTitle($name);
1562  $qpl->setDescription("");
1563  $qpl->create();
1564  $qpl->createReference();
1565  $qpl->putInTree($parent_ref);
1566  $qpl->setPermissions($parent_ref);
1567  $qpl->setOnline(1); // must be online to be available
1568  $qpl->saveToDb();
1569  return $qpl->getRefId();
1570  }
1571 
1575  public function randomselectObject()
1576  {
1577  global $ilUser;
1578  $this->getQuestionsSubTabs();
1579  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_random_select.html", "Modules/Test");
1580  $questionpools =& $this->object->getAvailableQuestionpools(FALSE, FALSE, FALSE, TRUE);
1581  $this->tpl->setCurrentBlock("option");
1582  $this->tpl->setVariable("VALUE_OPTION", "0");
1583  $this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("all_available_question_pools"));
1584  $this->tpl->parseCurrentBlock();
1585  foreach ($questionpools as $key => $value)
1586  {
1587  $this->tpl->setCurrentBlock("option");
1588  $this->tpl->setVariable("VALUE_OPTION", $key);
1589  $this->tpl->setVariable("TEXT_OPTION", $value["title"]);
1590  $this->tpl->parseCurrentBlock();
1591  }
1592  $this->tpl->setCurrentBlock("hidden");
1593  $this->tpl->setVariable("HIDDEN_NAME", "sel_question_types");
1594  $this->tpl->setVariable("HIDDEN_VALUE", $_POST["sel_question_types"]);
1595  $this->tpl->parseCurrentBlock();
1596  $this->tpl->setCurrentBlock("adm_content");
1597  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
1598  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_random_select_questionpool"));
1599  $this->tpl->setVariable("TXT_NR_OF_QUESTIONS", $this->lng->txt("tst_random_nr_of_questions"));
1600  $this->tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit"));
1601  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
1602  $this->tpl->parseCurrentBlock();
1603  }
1604 
1613  {
1614  $this->ctrl->redirect($this, "questions");
1615  }
1616 
1625  {
1626  $this->getQuestionsSubTabs();
1627  $question_array = $this->object->randomSelectQuestions($_POST["nr_of_questions"], $_POST["sel_qpl"]);
1628  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_random_question_offer.html", "Modules/Test");
1629  $color_class = array("tblrow1", "tblrow2");
1630  $counter = 0;
1631  $questionpools =& $this->object->getAvailableQuestionpools(true);
1632  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
1633  foreach ($question_array as $question_id)
1634  {
1635  $dataset = $this->object->getQuestionDataset($question_id);
1636  $this->tpl->setCurrentBlock("QTab");
1637  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
1638  $this->tpl->setVariable("QUESTION_TITLE", $dataset->title);
1639  $this->tpl->setVariable("QUESTION_COMMENT", $dataset->description);
1640  $this->tpl->setVariable("QUESTION_TYPE", assQuestion::_getQuestionTypeName($dataset->type_tag));
1641  $this->tpl->setVariable("QUESTION_AUTHOR", $dataset->author);
1642  $this->tpl->setVariable("QUESTION_POOL", $questionpools[$dataset->obj_fi]["title"]);
1643  $this->tpl->parseCurrentBlock();
1644  $counter++;
1645  }
1646  if (count($question_array) == 0)
1647  {
1648  $this->tpl->setCurrentBlock("Emptytable");
1649  $this->tpl->setVariable("TEXT_NO_QUESTIONS_AVAILABLE", $this->lng->txt("no_questions_available"));
1650  $this->tpl->parseCurrentBlock();
1651  }
1652  else
1653  {
1654  $this->tpl->setCurrentBlock("Selectionbuttons");
1655  $this->tpl->setVariable("BTN_YES", $this->lng->txt("random_accept_sample"));
1656  $this->tpl->setVariable("BTN_NO", $this->lng->txt("random_another_sample"));
1657  $this->tpl->parseCurrentBlock();
1658  }
1659  $chosen_questions = join($question_array, ",");
1660  $this->tpl->setCurrentBlock("adm_content");
1661  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
1662  $this->tpl->setVariable("QUESTION_TITLE", $this->lng->txt("tst_question_title"));
1663  $this->tpl->setVariable("QUESTION_COMMENT", $this->lng->txt("description"));
1664  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("tst_question_type"));
1665  $this->tpl->setVariable("QUESTION_AUTHOR", $this->lng->txt("author"));
1666  $this->tpl->setVariable("QUESTION_POOL", $this->lng->txt("qpl"));
1667  $this->tpl->setVariable("VALUE_CHOSEN_QUESTIONS", $chosen_questions);
1668  $this->tpl->setVariable("VALUE_QUESTIONPOOL_SELECTION", $_POST["sel_qpl"]);
1669  $this->tpl->setVariable("VALUE_NR_OF_QUESTIONS", $_POST["nr_of_questions"]);
1670  $this->tpl->setVariable("TEXT_QUESTION_OFFER", $this->lng->txt("tst_question_offer"));
1671  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
1672  $this->tpl->parseCurrentBlock();
1673  }
1674 
1683  {
1684  $selected_array = split(",", $_POST["chosen_questions"]);
1685  if (!count($selected_array))
1686  {
1687  ilUtil::sendInfo($this->lng->txt("tst_insert_missing_question"));
1688  }
1689  else
1690  {
1691  $total = $this->object->evalTotalPersons();
1692  if ($total)
1693  {
1694  // the test was executed previously
1695  ilUtil::sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total));
1696  }
1697  else
1698  {
1699  ilUtil::sendInfo($this->lng->txt("tst_insert_questions"));
1700  }
1701  foreach ($selected_array as $key => $value)
1702  {
1703  $this->object->insertQuestion($value);
1704  }
1705  $this->object->saveCompleteStatus();
1706  ilUtil::sendSuccess($this->lng->txt("tst_questions_inserted"), true);
1707  $this->ctrl->redirect($this, "questions");
1708  return;
1709  }
1710  }
1711 
1713  {
1714  $this->randomQuestionsObject();
1715  }
1716 
1723  function writeRandomQuestionInput($always = false)
1724  {
1725  $hasErrors = (!$always) ? $this->randomQuestionsObject(true) : false;
1726  if (!$hasErrors)
1727  {
1728  global $ilUser;
1729  $ilUser->setPref("tst_question_selection_mode_equal", ($_POST['chbQuestionSelectionMode']) ? 1 : 0);
1730  $ilUser->writePref("tst_question_selection_mode_equal", ($_POST['chbQuestionSelectionMode']) ? 1 : 0);
1731  $this->object->setRandomQuestionCount($_POST['total_questions']);
1732  if (is_array($_POST['source']['qpl']) && count(array_unique($_POST['source']['qpl'])) == count($_POST['source']['qpl']))
1733  {
1734  $data = array();
1735  include_once "./Modules/Test/classes/class.ilRandomTestData.php";
1736  foreach ($_POST['source']['qpl'] as $idx => $qpl)
1737  {
1738  array_push($data, new ilRandomTestData($_POST['source']['count'][$idx], $qpl));
1739  }
1740  $this->object->setRandomQuestionpoolData($data);
1741  }
1742  return 0;
1743  }
1744  return 1;
1745  }
1746 
1748  {
1749  if ($this->writeRandomQuestionInput() == 0)
1750  {
1751  $this->object->saveRandomQuestionCount($this->object->getRandomQuestionCount());
1752  $this->object->saveRandomQuestionpools();
1753  $this->object->saveCompleteStatus();
1754  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1755  $this->ctrl->redirect($this, 'randomQuestions');
1756  }
1757  }
1758 
1759  function addsourceObject()
1760  {
1761  $this->writeRandomQuestionInput(true);
1762  $position = key($_POST['cmd']['addsource']);
1763  $this->object->addRandomQuestionpoolData(0, 0, $position+1);
1764  $this->randomQuestionsObject();
1765  }
1766 
1768  {
1769  $this->writeRandomQuestionInput(true);
1770  $position = key($_POST['cmd']['removesource']);
1771  $this->object->removeRandomQuestionpoolData($position);
1772  $this->randomQuestionsObject();
1773  }
1774 
1776  {
1777  global $ilUser;
1778 
1779  $total = $this->object->evalTotalPersons();
1780  $save = (strcmp($this->ctrl->getCmd(), "saveRandomQuestions") == 0) ? TRUE : FALSE;
1781 
1782  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1783  $form = new ilPropertyFormGUI();
1784  $form->setFormAction($this->ctrl->getFormAction($this, 'randomQuestions'));
1785  $form->setTitle($this->lng->txt('random_selection'));
1786  $form->setDescription($this->lng->txt('tst_select_random_questions'));
1787  $form->setMultipart(FALSE);
1788  $form->setTableWidth("100%");
1789  $form->setId("randomSelectionForm");
1790 
1791  // question selection
1792  $selection_mode = ($save) ? $_POST['chbQuestionSelectionMode'] : $ilUser->getPref("tst_question_selection_mode_equal");
1793  $question_selection = new ilCheckboxInputGUI($this->lng->txt("tst_question_selection"), "chbQuestionSelectionMode");
1794  $question_selection->setValue(1);
1795  $question_selection->setChecked($selection_mode);
1796  $question_selection->setOptionTitle($this->lng->txt('tst_question_selection_equal'));
1797  $question_selection->setInfo($this->lng->txt('tst_question_selection_description'));
1798  $question_selection->setRequired(false);
1799  $form->addItem($question_selection);
1800 
1801  // total amount of questions
1802  $total_questions = new ilNumberInputGUI($this->lng->txt('tst_total_questions'), 'total_questions');
1803  $total_questions->setValue($this->object->getRandomQuestionCount());
1804  $total_questions->setSize(3);
1805  $total_questions->setInfo($this->lng->txt('tst_total_questions_description'));
1806  $total_questions->setRequired(false);
1807  $form->addItem($total_questions);
1808 
1809  if ($total == 0)
1810  {
1811  $found_qpls = $this->object->getRandomQuestionpoolData();
1812  include_once "./Modules/Test/classes/class.ilRandomTestData.php";
1813  if (count($found_qpls) == 0)
1814  {
1815  array_push($found_qpls, new ilRandomTestData());
1816  }
1817  $available_qpl =& $this->object->getAvailableQuestionpools(TRUE, $selection_mode, FALSE, TRUE, TRUE);
1818  include_once './Modules/Test/classes/class.ilRandomTestInputGUI.php';
1819  $source = new ilRandomTestInputGUI($this->lng->txt('tst_random_questionpools'), 'source');
1820  $source->setUseEqualPointsOnly($selection_mode);
1821  $source->setRandomQuestionPools($available_qpl);
1822  $source->setUseQuestionCount((array_key_exists('total_questions', $_POST)) ? ($_POST['total_questions'] < 1) : ($this->object->getRandomQuestionCount() < 1));
1823  $source->setValues($found_qpls);
1824  $form->addItem($source);
1825  }
1826  else
1827  {
1828  $qpls = $this->object->getUsedRandomQuestionpools();
1829  include_once './Modules/Test/classes/class.ilRandomTestROInputGUI.php';
1830  $source = new ilRandomTestROInputGUI($this->lng->txt('tst_random_questionpools'), 'source');
1831  $source->setValues($qpls);
1832  $form->addItem($source);
1833  }
1834 
1835  if ($total == 0) $form->addCommandButton("saveRandomQuestions", $this->lng->txt("save"));
1836 
1837  $errors = false;
1838 
1839  if ($save)
1840  {
1841  $form->setValuesByPost();
1842  $errors = !$form->checkInput();
1843  if (!$errors)
1844  {
1845  // check total amount of questions
1846  if ($_POST['total_questions'] > 0)
1847  {
1848  $totalcount = 0;
1849  foreach ($_POST['source']['qpl'] as $idx => $qpl)
1850  {
1851  $totalcount += $available_qpl[$qpl]['count'];
1852  }
1853  if ($_POST['total_questions'] > $totalcount)
1854  {
1855  $total_questions->setAlert($this->lng->txt('msg_total_questions_too_high'));
1856  $errors = true;
1857  }
1858  }
1859  }
1860  if ($errors) $checkonly = false;
1861  }
1862 
1863  if (!$checkonly) $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
1864  return $errors;
1865  }
1866 
1868  {
1869  global $ilUser;
1870  if ($_POST["chbQuestionSelectionMode"])
1871  {
1872  $ilUser->setPref("tst_question_selection_mode_equal", 1);
1873  $ilUser->writePref("tst_question_selection_mode_equal", 1);
1874  }
1875  else
1876  {
1877  $ilUser->setPref("tst_question_selection_mode_equal", 0);
1878  $ilUser->writePref("tst_question_selection_mode_equal", 0);
1879  }
1880  $this->randomQuestionsObject();
1881  }
1882 
1884  {
1885  $this->questionBrowser();
1886  }
1887 
1896  {
1897  $qpl_ref_id = $_POST["sel_qpl"];
1898  if ((strcmp($_POST["txt_qpl"], "") == 0) && (strcmp($qpl_ref_id, "") == 0))
1899  {
1900  ilUtil::sendInfo($this->lng->txt("questionpool_not_entered"));
1901  $this->createQuestionObject();
1902  return;
1903  }
1904  else
1905  {
1906  $_SESSION["test_id"] = $this->object->getRefId();
1907  if (strcmp($_POST["txt_qpl"], "") != 0)
1908  {
1909  // create a new question pool and return the reference id
1910  $qpl_ref_id = $this->createQuestionPool($_POST["txt_qpl"]);
1911  }
1912  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPoolGUI.php";
1913  ilUtil::redirect("ilias.php?baseClass=ilObjQuestionPoolGUI&ref_id=" . $qpl_ref_id . "&cmd=createQuestionForTest&test_ref_id=".$_GET["ref_id"]."&sel_question_types=" . $_POST["sel_question_types"]);
1914  exit();
1915  }
1916  }
1917 
1926  {
1927  $this->ctrl->redirect($this, "questions");
1928  }
1929 
1938  {
1939  global $ilUser;
1940  $this->getQuestionsSubTabs();
1941  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_qpl_select.html", "Modules/Test");
1942  $questionpools =& $this->object->getAvailableQuestionpools(FALSE, FALSE, FALSE, TRUE, FALSE, "write");
1943  if (count($questionpools) == 0)
1944  {
1945  $this->tpl->setCurrentBlock("option");
1946  $this->tpl->setVariable("VALUE_QPL", "");
1947  $this->tpl->parseCurrentBlock();
1948  }
1949  else
1950  {
1951  foreach ($questionpools as $key => $value)
1952  {
1953  $this->tpl->setCurrentBlock("option");
1954  $this->tpl->setVariable("VALUE_OPTION", $key);
1955  $this->tpl->setVariable("TEXT_OPTION", $value["title"]);
1956  $this->tpl->parseCurrentBlock();
1957  }
1958  }
1959  $this->tpl->setCurrentBlock("hidden");
1960  $this->tpl->setVariable("HIDDEN_NAME", "sel_question_types");
1961  $this->tpl->setVariable("HIDDEN_VALUE", $_POST["sel_question_types"]);
1962  $this->tpl->parseCurrentBlock();
1963  $this->tpl->setCurrentBlock("adm_content");
1964  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
1965 
1966  if (count($questionpools) == 0)
1967  {
1968  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_enter_questionpool"));
1969  }
1970  else
1971  {
1972  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_select_questionpool"));
1973  }
1974  $this->tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit"));
1975  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
1976  $this->tpl->parseCurrentBlock();
1977  }
1978 
1987  {
1988  ilUtil::sendSuccess($this->lng->txt("tst_questions_removed"));
1989  $checked_questions = array();
1990  foreach ($_POST as $key => $value) {
1991  if (preg_match("/id_(\d+)/", $key, $matches)) {
1992  array_push($checked_questions, $matches[1]);
1993  }
1994  }
1995  foreach ($checked_questions as $key => $value) {
1996  $this->object->removeQuestion($value);
1997  }
1998  $this->object->saveCompleteStatus();
1999  $this->ctrl->redirect($this, "questions");
2000  }
2001 
2010  {
2011  $this->ctrl->redirect($this, "questions");
2012  }
2013 
2021  function removeQuestionsForm($checked_questions)
2022  {
2023  ilUtil::sendInfo();
2024  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_remove_questions.html", "Modules/Test");
2025  $removablequestions =& $this->object->getTestQuestions();
2026  $colors = array("tblrow1", "tblrow2");
2027  $counter = 0;
2028  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
2029  if (count($removablequestions))
2030  {
2031  foreach ($removablequestions as $data)
2032  {
2033  if (in_array($data["question_id"], $checked_questions))
2034  {
2035  $this->tpl->setCurrentBlock("row");
2036  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
2037  $this->tpl->setVariable("TXT_TITLE", $data["title"]);
2038  $this->tpl->setVariable("TXT_DESCRIPTION", $data["description"]);
2039  $this->tpl->setVariable("TXT_TYPE", assQuestion::_getQuestionTypeName($data["type_tag"]));
2040  $this->tpl->parseCurrentBlock();
2041  $counter++;
2042  }
2043  }
2044  }
2045  foreach ($checked_questions as $id)
2046  {
2047  $this->tpl->setCurrentBlock("hidden");
2048  $this->tpl->setVariable("HIDDEN_NAME", "id_$id");
2049  $this->tpl->setVariable("HIDDEN_VALUE", "1");
2050  $this->tpl->parseCurrentBlock();
2051  }
2052 
2053  $this->tpl->setCurrentBlock("adm_content");
2054  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("tst_question_title"));
2055  $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("description"));
2056  $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("tst_question_type"));
2057  $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
2058  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
2059  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
2060  $this->tpl->parseCurrentBlock();
2061  }
2062 
2071  {
2072  $this->getQuestionsSubTabs();
2073  $checked_questions = $_POST["q_id"];
2074  if (count($checked_questions) > 0)
2075  {
2076  $total = $this->object->evalTotalPersons();
2077  if ($total)
2078  {
2079  // the test was executed previously
2080  ilUtil::sendInfo(sprintf($this->lng->txt("tst_remove_questions_and_results"), $total));
2081  }
2082  else
2083  {
2084  ilUtil::sendInfo($this->lng->txt("tst_remove_questions"));
2085  }
2086  $this->removeQuestionsForm($checked_questions);
2087  return;
2088  }
2089  elseif (count($checked_questions) == 0)
2090  {
2091  ilUtil::sendInfo($this->lng->txt("tst_no_question_selected_for_removal"), true);
2092  $this->ctrl->redirect($this, "questions");
2093  }
2094  }
2095 
2100  {
2101  $_SESSION['tst_qst_move_' . $this->object->getTestId()] = $_POST['q_id'];
2102  ilUtil::sendSuccess($this->lng->txt("msg_selected_for_move"), true);
2103  $this->ctrl->redirect($this, 'questions');
2104  }
2105 
2110  {
2111  // get all questions to move
2112  $move_questions = $_SESSION['tst_qst_move_' . $this->object->getTestId()];
2113 
2114  if (count($_POST['q_id']) == 0)
2115  {
2116  ilUtil::sendFailure($this->lng->txt("no_target_selected_for_move"), true);
2117  $this->ctrl->redirect($this, 'questions');
2118  }
2119  if (count($_POST['q_id']) > 1)
2120  {
2121  ilUtil::sendFailure($this->lng->txt("too_many_targets_selected_for_move"), true);
2122  $this->ctrl->redirect($this, 'questions');
2123  }
2124  $insert_mode = 0;
2125  $this->object->moveQuestions($_SESSION['tst_qst_move_' . $this->object->getTestId()], $_POST['q_id'][0], $insert_mode);
2126  ilUtil::sendSuccess($this->lng->txt("msg_questions_moved"), true);
2127  unset($_SESSION['tst_qst_move_' . $this->object->getTestId()]);
2128  $this->ctrl->redirect($this, "questions");
2129  }
2130 
2134  public function insertQuestionsAfterObject()
2135  {
2136  // get all questions to move
2137  $move_questions = $_SESSION['tst_qst_move_' . $this->object->getTestId()];
2138  if (count($_POST['q_id']) == 0)
2139  {
2140  ilUtil::sendFailure($this->lng->txt("no_target_selected_for_move"), true);
2141  $this->ctrl->redirect($this, 'questions');
2142  }
2143  if (count($_POST['q_id']) > 1)
2144  {
2145  ilUtil::sendFailure($this->lng->txt("too_many_targets_selected_for_move"), true);
2146  $this->ctrl->redirect($this, 'questions');
2147  }
2148  $insert_mode = 1;
2149  $this->object->moveQuestions($_SESSION['tst_qst_move_' . $this->object->getTestId()], $_POST['q_id'][0], $insert_mode);
2150  ilUtil::sendSuccess($this->lng->txt("msg_questions_moved"), true);
2151  unset($_SESSION['tst_qst_move_' . $this->object->getTestId()]);
2152  $this->ctrl->redirect($this, "questions");
2153  }
2154 
2161  {
2162  $selected_array = (is_array($_POST['q_id'])) ? $_POST['q_id'] : array();
2163  if (!count($selected_array))
2164  {
2165  ilUtil::sendInfo($this->lng->txt("tst_insert_missing_question"), true);
2166  $this->ctrl->redirect($this, "browseForQuestions");
2167  }
2168  else
2169  {
2170  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
2171  $manscoring = FALSE;
2172  foreach ($selected_array as $key => $value)
2173  {
2174  $this->object->insertQuestion($value);
2175  if (!$manscoring)
2176  {
2177  $manscoring = $manscoring | assQuestion::_needsManualScoring($value);
2178  }
2179  }
2180  $this->object->saveCompleteStatus();
2181  if ($manscoring)
2182  {
2183  ilUtil::sendInfo($this->lng->txt("manscoring_hint"), TRUE);
2184  }
2185  else
2186  {
2187  ilUtil::sendSuccess($this->lng->txt("tst_questions_inserted"), TRUE);
2188  }
2189  $this->ctrl->redirect($this, "questions");
2190  return;
2191  }
2192  }
2193 
2195  {
2196  include_once "./Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php";
2197  $table_gui = new ilTestQuestionBrowserTableGUI($this, 'browseForQuestions');
2198  $table_gui->writeFilterToSession();
2199  $this->ctrl->redirect($this, "browseForQuestions");
2200  }
2201 
2203  {
2204  include_once "./Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php";
2205  $table_gui = new ilTestQuestionBrowserTableGUI($this, 'browseForQuestions');
2206  $table_gui->resetFilter();
2207  $this->ctrl->redirect($this, "browseForQuestions");
2208  }
2209 
2215  function questionBrowser()
2216  {
2217  global $ilAccess;
2218 
2219  $this->ctrl->setParameterByClass(get_class($this), "browse", "1");
2220 
2221  include_once "./Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php";
2222  $table_gui = new ilTestQuestionBrowserTableGUI($this, 'browseForQuestions', (($ilAccess->checkAccess("write", "", $this->ref_id) ? true : false)));
2223  $arrFilter = array();
2224  foreach ($table_gui->getFilterItems() as $item)
2225  {
2226  if ($item->getValue() !== false)
2227  {
2228  $arrFilter[$item->getPostVar()] = $item->getValue();
2229  }
2230  }
2231  $data = $this->object->getAvailableQuestions($arrFilter, 1);
2232  $table_gui->setData($data);
2233  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
2234  }
2235 
2236  function questionsObject()
2237  {
2238  global $ilAccess;
2239  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
2240  {
2241  // allow only write access
2242  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
2243  $this->ctrl->redirect($this, "infoScreen");
2244  }
2245  if ($_GET['browse'])
2246  {
2247  return $this->questionbrowser();
2248  }
2249 
2250  $this->getQuestionsSubTabs();
2251  if ($this->object->isRandomTest())
2252  {
2253  $this->randomQuestionsObject();
2254  return;
2255  }
2256 
2257  if ($_GET["eqid"] && $_GET["eqpl"])
2258  {
2259  ilUtil::redirect("ilias.php?baseClass=ilObjQuestionPoolGUI&ref_id=" . $_GET["eqpl"] . "&cmd=editQuestionForTest&calling_test=".$_GET["ref_id"]."&q_id=" . $_GET["eqid"]);
2260  }
2261 
2262  if ($_GET["up"] > 0)
2263  {
2264  $this->object->questionMoveUp($_GET["up"]);
2265  }
2266  if ($_GET["down"] > 0)
2267  {
2268  $this->object->questionMoveDown($_GET["down"]);
2269  }
2270 
2271  if ($_GET["add"])
2272  {
2273  $selected_array = array();
2274  array_push($selected_array, $_GET["add"]);
2275  $total = $this->object->evalTotalPersons();
2276  if ($total)
2277  {
2278  // the test was executed previously
2279  ilUtil::sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total));
2280  }
2281  else
2282  {
2283  ilUtil::sendInfo($this->lng->txt("tst_insert_questions"));
2284  }
2285  $this->insertQuestions($selected_array);
2286  return;
2287  }
2288 
2289  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_questions.html", "Modules/Test");
2290 
2291  $total = $this->object->evalTotalPersons();
2292  if (($ilAccess->checkAccess("write", "", $this->ref_id) and ($total == 0)))
2293  {
2294  global $ilUser;
2295  $lastquestiontype = $ilUser->getPref("tst_lastquestiontype");
2296  $this->tpl->setCurrentBlock("QTypes");
2297  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
2298  $question_types =& ilObjQuestionPool::_getQuestionTypes();
2299  foreach ($question_types as $trans => $data)
2300  {
2301  if ($data["type_tag"] == $lastquestiontype)
2302  {
2303  $this->tpl->setVariable("QUESTION_TYPE_SELECTED", " selected=\"selected\"");
2304  }
2305  $this->tpl->setVariable("QUESTION_TYPE_ID", $data["type_tag"]);
2306  $this->tpl->setVariable("QUESTION_TYPE", $trans);
2307  $this->tpl->parseCurrentBlock();
2308  }
2309  $this->tpl->parseCurrentBlock();
2310  }
2311 
2312  if (($ilAccess->checkAccess("write", "", $this->ref_id) and ($total == 0)))
2313  {
2314  $this->tpl->setVariable("BUTTON_INSERT_QUESTION", $this->lng->txt("tst_browse_for_questions"));
2315  $this->tpl->setVariable("TEXT_CREATE_NEW", " " . strtolower($this->lng->txt("or")) . " " . $this->lng->txt("create_new"));
2316  $this->tpl->setVariable("BUTTON_CREATE_QUESTION", $this->lng->txt("create"));
2317  $this->tpl->setVariable("TXT_OR", $this->lng->txt("or"));
2318  $this->tpl->setVariable("TEXT_RANDOM_SELECT", $this->lng->txt("random_selection"));
2319  }
2320 
2321  $this->tpl->setCurrentBlock("adm_content");
2322  include_once "./Modules/Test/classes/tables/class.ilTestQuestionsTableGUI.php";
2323  $checked_move = is_array($_SESSION['tst_qst_move_' . $this->object->getTestId()]) && (count($_SESSION['tst_qst_move_' . $this->object->getTestId()]));
2324  $table_gui = new ilTestQuestionsTableGUI($this, 'questions', (($ilAccess->checkAccess("write", "", $this->ref_id) ? true : false)), $checked_move, $total);
2325  $data = $this->object->getTestQuestions();
2326  $table_gui->setData($data);
2327  $this->tpl->setVariable('QUESTIONBROWSER', $table_gui->getHTML());
2328  $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this));
2329  $this->tpl->parseCurrentBlock();
2330  }
2331 
2332  function takenObject() {
2333  }
2334 
2343  {
2344  $this->saveMarkSchemaFormData();
2345  $this->object->mark_schema->addMarkStep();
2346  $this->marksObject();
2347  }
2348 
2357  {
2358  $this->object->mark_schema->flush();
2359  foreach ($_POST as $key => $value) {
2360  if (preg_match("/mark_short_(\d+)/", $key, $matches))
2361  {
2362  $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]"]));
2363  }
2364  }
2365  $this->object->ects_grades["A"] = $_POST["ects_grade_a"];
2366  $this->object->ects_grades["B"] = $_POST["ects_grade_b"];
2367  $this->object->ects_grades["C"] = $_POST["ects_grade_c"];
2368  $this->object->ects_grades["D"] = $_POST["ects_grade_d"];
2369  $this->object->ects_grades["E"] = $_POST["ects_grade_e"];
2370  if ($_POST["chbUseFX"])
2371  {
2372  $this->object->ects_fx = $_POST["percentFX"];
2373  }
2374  else
2375  {
2376  $this->object->ects_fx = "";
2377  }
2378  $this->object->ects_output = $_POST["chbECTS"];
2379  }
2380 
2389  {
2390  $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);
2391  $this->marksObject();
2392  }
2393 
2402  {
2403  $this->saveMarkSchemaFormData();
2404  $delete_mark_steps = array();
2405  foreach ($_POST as $key => $value) {
2406  if (preg_match("/cb_(\d+)/", $key, $matches)) {
2407  array_push($delete_mark_steps, $matches[1]);
2408  }
2409  }
2410  if (count($delete_mark_steps)) {
2411  $this->object->mark_schema->deleteMarkSteps($delete_mark_steps);
2412  } else {
2413  ilUtil::sendInfo($this->lng->txt("tst_delete_missing_mark"));
2414  }
2415  $this->marksObject();
2416  }
2417 
2426  {
2427  $this->ctrl->redirect($this, "marks");
2428  }
2429 
2437  function saveMarksObject()
2438  {
2439  try
2440  {
2441  $this->saveMarkSchemaFormData();
2442  $mark_check = $this->object->checkMarks();
2443  }
2444  catch (Exception $ex)
2445  {
2446  $mark_check = $this->lng->txt('mark_schema_invalid');
2447  }
2448 
2449  if ($mark_check !== true)
2450  {
2451  ilUtil::sendFailure($mark_check);
2452  }
2453  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)))
2454  {
2455  ilUtil::sendInfo($this->lng->txt("ects_fill_out_all_values"), true);
2456  }
2457  elseif (($_POST["ects_grade_a"] > 100) or ($_POST["ects_grade_a"] < 0))
2458  {
2459  ilUtil::sendInfo($this->lng->txt("ects_range_error_a"), true);
2460  }
2461  elseif (($_POST["ects_grade_b"] > 100) or ($_POST["ects_grade_b"] < 0))
2462  {
2463  ilUtil::sendInfo($this->lng->txt("ects_range_error_b"), true);
2464  }
2465  elseif (($_POST["ects_grade_c"] > 100) or ($_POST["ects_grade_c"] < 0))
2466  {
2467  ilUtil::sendInfo($this->lng->txt("ects_range_error_c"), true);
2468  }
2469  elseif (($_POST["ects_grade_d"] > 100) or ($_POST["ects_grade_d"] < 0))
2470  {
2471  ilUtil::sendInfo($this->lng->txt("ects_range_error_d"), true);
2472  }
2473  elseif (($_POST["ects_grade_e"] > 100) or ($_POST["ects_grade_e"] < 0))
2474  {
2475  ilUtil::sendInfo($this->lng->txt("ects_range_error_e"), true);
2476  }
2477  else
2478  {
2479  $this->object->mark_schema->saveToDb($this->object->getTestId());
2480  $this->object->saveCompleteStatus();
2481  if ($this->object->getReportingDate())
2482  {
2483  $fxpercent = "";
2484  if ($_POST["chbUseFX"])
2485  {
2486  $fxpercent = ilUtil::stripSlashes($_POST["percentFX"]);
2487  }
2488  $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"]));
2489  }
2490  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
2491  }
2492  $this->marksObject();
2493  }
2494 
2495  function marksObject()
2496  {
2497  global $ilAccess;
2498  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
2499  {
2500  // allow only write access
2501  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
2502  $this->ctrl->redirect($this, "infoScreen");
2503  }
2504 
2505  if (!$this->object->canEditMarks())
2506  {
2507  ilUtil::sendInfo($this->lng->txt("cannot_edit_marks"));
2508  }
2509 
2510  $this->object->mark_schema->sort();
2511 
2512  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_marks.html", "Modules/Test");
2513  $marks = $this->object->mark_schema->mark_steps;
2514  $rows = array("tblrow1", "tblrow2");
2515  $counter = 0;
2516  foreach ($marks as $key => $value) {
2517  $this->tpl->setCurrentBlock("markrow");
2518  $this->tpl->setVariable("MARK_SHORT", $value->getShortName());
2519  $this->tpl->setVariable("MARK_OFFICIAL", $value->getOfficialName());
2520  $this->tpl->setVariable("MARK_PERCENTAGE", sprintf("%.2f", $value->getMinimumLevel()));
2521  $this->tpl->setVariable("MARK_PASSED", strtolower($this->lng->txt("tst_mark_passed")));
2522  $this->tpl->setVariable("MARK_ID", "$key");
2523  $this->tpl->setVariable("ROW_CLASS", $rows[$counter % 2]);
2524  if ($value->getPassed()) {
2525  $this->tpl->setVariable("MARK_PASSED_CHECKED", " checked=\"checked\"");
2526  }
2527  $this->tpl->parseCurrentBlock();
2528  $counter++;
2529  }
2530  if (count($marks) == 0)
2531  {
2532  $this->tpl->setCurrentBlock("Emptyrow");
2533  $this->tpl->setVariable("EMPTY_ROW", $this->lng->txt("tst_no_marks_defined"));
2534  $this->tpl->setVariable("ROW_CLASS", $rows[$counter % 2]);
2535  $this->tpl->parseCurrentBlock();
2536  }
2537  else
2538  {
2539  if ($ilAccess->checkAccess("write", "", $this->ref_id) && $this->object->canEditMarks())
2540  {
2541  $this->tpl->setCurrentBlock("selectall");
2542  $counter++;
2543  $this->tpl->setVariable("ROW_CLASS", $rows[$counter % 2]);
2544  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
2545  $this->tpl->parseCurrentBlock();
2546  $this->tpl->setCurrentBlock("Footer");
2547  $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\"/>");
2548  $this->tpl->setVariable("BUTTON_EDIT", $this->lng->txt("edit"));
2549  $this->tpl->setVariable("BUTTON_DELETE", $this->lng->txt("delete"));
2550  $this->tpl->parseCurrentBlock();
2551  }
2552  }
2553 
2554  if ($this->object->getReportingDate())
2555  {
2556  $this->tpl->setCurrentBlock("ects");
2557  if ($this->object->ects_output)
2558  {
2559  $this->tpl->setVariable("CHECKED_ECTS", " checked=\"checked\"");
2560  }
2561  $this->tpl->setVariable("TEXT_OUTPUT_ECTS_GRADES", $this->lng->txt("ects_output_of_ects_grades"));
2562  $this->tpl->setVariable("TEXT_ALLOW_ECTS_GRADES", $this->lng->txt("ects_allow_ects_grades"));
2563  $this->tpl->setVariable("TEXT_USE_FX", $this->lng->txt("ects_use_fx_grade"));
2564  if (preg_match("/\d+/", $this->object->ects_fx))
2565  {
2566  $this->tpl->setVariable("CHECKED_FX", " checked=\"checked\"");
2567  $this->tpl->setVariable("VALUE_PERCENT_FX", sprintf("value=\"%s\" ", $this->object->ects_fx));
2568  }
2569  $this->tpl->setVariable("TEXT_PERCENT", $this->lng->txt("ects_use_fx_grade_part2"));
2570  $this->tpl->setVariable("ECTS_GRADE", $this->lng->txt("ects_grade"));
2571  $this->tpl->setVariable("PERCENTILE", $this->lng->txt("percentile"));
2572  $this->tpl->setVariable("ECTS_GRADE_A", "A - " . $this->lng->txt("ects_grade_a_short"));
2573  $this->tpl->setVariable("VALUE_GRADE_A", $this->object->ects_grades["A"]);
2574  $this->tpl->setVariable("ECTS_GRADE_B", "B - " . $this->lng->txt("ects_grade_b_short"));
2575  $this->tpl->setVariable("VALUE_GRADE_B", $this->object->ects_grades["B"]);
2576  $this->tpl->setVariable("ECTS_GRADE_C", "C - " . $this->lng->txt("ects_grade_c_short"));
2577  $this->tpl->setVariable("VALUE_GRADE_C", $this->object->ects_grades["C"]);
2578  $this->tpl->setVariable("ECTS_GRADE_D", "D - " . $this->lng->txt("ects_grade_d_short"));
2579  $this->tpl->setVariable("VALUE_GRADE_D", $this->object->ects_grades["D"]);
2580  $this->tpl->setVariable("ECTS_GRADE_E", "E - " . $this->lng->txt("ects_grade_e_short"));
2581  $this->tpl->setVariable("VALUE_GRADE_E", $this->object->ects_grades["E"]);
2582 
2583  $this->tpl->parseCurrentBlock();
2584  }
2585 
2586  $this->tpl->setCurrentBlock("adm_content");
2587  $this->tpl->setVariable("ACTION_MARKS", $this->ctrl->getFormAction($this));
2588  $this->tpl->setVariable("HEADER_SHORT", $this->lng->txt("tst_mark_short_form"));
2589  $this->tpl->setVariable("HEADER_OFFICIAL", $this->lng->txt("tst_mark_official_form"));
2590  $this->tpl->setVariable("HEADER_PERCENTAGE", $this->lng->txt("tst_mark_minimum_level"));
2591  $this->tpl->setVariable("HEADER_PASSED", $this->lng->txt("tst_mark_passed"));
2592  if ($ilAccess->checkAccess("write", "", $this->ref_id) && $this->object->canEditMarks())
2593  {
2594  $this->tpl->setVariable("BUTTON_NEW", $this->lng->txt("tst_mark_create_new_mark_step"));
2595  $this->tpl->setVariable("BUTTON_NEW_SIMPLE", $this->lng->txt("tst_mark_create_simple_mark_schema"));
2596  $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
2597  $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
2598  }
2599  $this->tpl->parseCurrentBlock();
2600  }
2601 
2610  {
2611  $this->object->removeAllTestEditings();
2612  ilUtil::sendSuccess($this->lng->txt("tst_all_user_data_deleted"), true);
2613  $this->ctrl->redirect($this, "participants");
2614  }
2615 
2624  {
2625  $active_ids = array();
2626  foreach ($_POST["chbUser"] as $active_id)
2627  {
2628  if ($this->object->getFixedParticipants())
2629  {
2630  array_push($active_ids, $this->object->getActiveIdOfUser($active_id));
2631  }
2632  else
2633  {
2634  array_push($active_ids, $active_id);
2635  }
2636  }
2637  $this->object->removeSelectedTestResults($active_ids);
2638  ilUtil::sendSuccess($this->lng->txt("tst_selected_user_data_deleted"), true);
2639  $this->ctrl->redirect($this, "participants");
2640  }
2641 
2650  {
2651  $this->ctrl->redirect($this, "participants");
2652  }
2653 
2662  {
2663  ilUtil::sendQuestion($this->lng->txt("confirm_delete_all_user_data"));
2664  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_maintenance.html", "Modules/Test");
2665 
2666  $this->tpl->setCurrentBlock("confirm_delete");
2667  $this->tpl->setVariable("BTN_CONFIRM_DELETE_ALL", $this->lng->txt("confirm"));
2668  $this->tpl->setVariable("BTN_CANCEL_DELETE_ALL", $this->lng->txt("cancel"));
2669  $this->tpl->parseCurrentBlock();
2670 
2671  $this->tpl->setCurrentBlock("adm_content");
2672  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
2673  $this->tpl->parseCurrentBlock();
2674  }
2675 
2679  public function deleteAllUserResultsObject()
2680  {
2681  ilUtil::sendQuestion($this->lng->txt("delete_all_user_data_confirmation"));
2682  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", "Modules/Test");
2683  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "participants"));
2684 
2685  // cancel/confirm button
2686  $buttons = array( "confirmDeleteAllUserResults" => $this->lng->txt("proceed"),
2687  "participants" => $this->lng->txt("cancel"));
2688  foreach ($buttons as $name => $value)
2689  {
2690  $this->tpl->setCurrentBlock("operation_btn");
2691  $this->tpl->setVariable("BTN_NAME",$name);
2692  $this->tpl->setVariable("BTN_VALUE",$value);
2693  $this->tpl->parseCurrentBlock();
2694  }
2695  }
2696 
2705  {
2706  if (count($_POST["chbUser"]) == 0)
2707  {
2708  ilUtil::sendInfo($this->lng->txt("select_one_user"), TRUE);
2709  $this->ctrl->redirect($this, "participants");
2710  }
2711  ilUtil::sendQuestion($this->lng->txt("confirm_delete_single_user_data"));
2712  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_maintenance.html", "Modules/Test");
2713 
2714  foreach ($_POST["chbUser"] as $key => $value)
2715  {
2716  $this->tpl->setCurrentBlock("hidden");
2717  $this->tpl->setVariable("USER_ID", $value);
2718  $this->tpl->parseCurrentBlock();
2719  }
2720 
2721  include_once './Services/User/classes/class.ilObjUser.php';
2722  $color_class = array("tblrow1", "tblrow2");
2723  $counter = 0;
2724  foreach ($_POST["chbUser"] as $key => $active_id)
2725  {
2726  if ($this->object->getFixedParticipants())
2727  {
2728  $user_id = $active_id;
2729  }
2730  else
2731  {
2732  $user_id = $this->object->_getUserIdFromActiveId($active_id);
2733  }
2734  $user = ilObjUser::_lookupName($user_id);
2735  $this->tpl->setCurrentBlock("row");
2736  $this->tpl->setVariable("USER_ICON", ilUtil::getImagePath("icon_usr.gif"));
2737  $this->tpl->setVariable("USER_ALT", $this->lng->txt("usr"));
2738  $this->tpl->setVariable("USER_TITLE", $this->lng->txt("usr"));
2739  if ($this->object->getAnonymity())
2740  {
2741  $name = $this->lng->txt("anonymous");
2742  }
2743  else
2744  {
2745  $this->tpl->setVariable("TXT_FIRSTNAME", $user["firstname"]);
2746  if (strlen($user["lastname"]))
2747  {
2748  $this->tpl->setVariable("TXT_LASTNAME", $user["lastname"]);
2749  }
2750  else
2751  {
2752  $this->tpl->setVariable("TXT_LASTNAME", $this->lng->txt("deleted_user"));
2753  }
2754  $this->tpl->setVariable("TXT_LOGIN", ilObjUser::_lookupLogin($user_id));
2755  }
2756  $this->tpl->setVariable("ROW_CLASS", $color_class[$counter % 2]);
2757  $this->tpl->parseCurrentBlock();
2758  $counter++;
2759  }
2760  $this->tpl->setCurrentBlock("selectedusers");
2761  $this->tpl->setVariable("HEADER_TXT_FIRSTNAME", $this->lng->txt("firstname"));
2762  $this->tpl->setVariable("HEADER_TXT_LASTNAME", $this->lng->txt("lastname"));
2763  $this->tpl->setVariable("HEADER_TXT_LOGIN", $this->lng->txt("login"));
2764  $this->tpl->setVariable("BTN_CONFIRM_DELETE_SELECTED", $this->lng->txt("confirm"));
2765  $this->tpl->setVariable("BTN_CANCEL_DELETE_SELECTED", $this->lng->txt("cancel"));
2766  $this->tpl->parseCurrentBlock();
2767 
2768  $this->tpl->setCurrentBlock("adm_content");
2769  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
2770  $this->tpl->parseCurrentBlock();
2771  }
2772 
2780  function historyObject()
2781  {
2782  include_once "./Modules/Test/classes/tables/class.ilTestHistoryTableGUI.php";
2783  $table_gui = new ilTestHistoryTableGUI($this, 'history');
2784  $table_gui->setTestObject($this->object);
2785  include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
2786  $log =& ilObjAssessmentFolder::_getLog(0, time(), $this->object->getId(), TRUE);
2787  $table_gui->setData($log);
2788  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
2789  }
2790 
2794  function createObject()
2795  {
2796  global $rbacsystem;
2797  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
2798  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
2799  {
2800  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
2801  }
2802  else
2803  {
2804  $this->getTemplateFile("create", $new_type);
2805 
2806  include_once("./Modules/Test/classes/class.ilObjTest.php");
2807  $tst = new ilObjTest();
2808  $questionpools =& $tst->getAvailableQuestionpools(TRUE, FALSE, TRUE, TRUE);
2809  if (count($questionpools) == 0)
2810  {
2811  }
2812  else
2813  {
2814  foreach ($questionpools as $key => $value)
2815  {
2816  $this->tpl->setCurrentBlock("option_qpl");
2817  $this->tpl->setVariable("OPTION_VALUE", $key);
2818  $this->tpl->setVariable("TXT_OPTION", $value["title"]);
2819  if ($_POST["qpl"] == $key)
2820  {
2821  $this->tpl->setVariable("OPTION_SELECTED", " selected=\"selected\"");
2822  }
2823  $this->tpl->parseCurrentBlock();
2824  }
2825  }
2826 
2827  $defaults =& $tst->getAvailableDefaults();
2828  if (count($defaults))
2829  {
2830  foreach ($defaults as $row)
2831  {
2832  $this->tpl->setCurrentBlock("defaults_row");
2833  $this->tpl->setVariable("DEFAULTS_VALUE", $row["test_defaults_id"]);
2834  $this->tpl->setVariable("DEFAULTS_NAME", ilUtil::prepareFormOutput($row["name"]));
2835  $this->tpl->parseCurrentBlock();
2836  }
2837  $this->tpl->setCurrentBlock("defaults");
2838  $this->tpl->setVariable("TXT_DEFAULTS", $this->lng->txt("defaults"));
2839  $this->tpl->setVariable("TEXT_NO_DEFAULTS", $this->lng->txt("tst_defaults_dont_use"));
2840  $this->tpl->parseCurrentBlock();
2841  }
2842 
2843  $this->fillCloneTemplate('DUPLICATE','tst');
2844 
2845  $this->tpl->setCurrentBlock("adm_content");
2846 
2847  // fill in saved values in case of error
2848  $data = array();
2849  $data["fields"] = array();
2850  $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
2851  $data["fields"]["desc"] = $_SESSION["error_post_vars"]["Fobject"]["desc"];
2852  foreach ($data["fields"] as $key => $val)
2853  {
2854  $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
2855  $this->tpl->setVariable(strtoupper($key), $val);
2856 
2857  if ($this->prepare_output)
2858  {
2859  $this->tpl->parseCurrentBlock();
2860  }
2861  }
2862  $this->ctrl->setParameter($this, "new_type", $new_type);
2863  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, 'save'));
2864  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
2865  $this->tpl->setVariable("TXT_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool"));
2866  $this->tpl->setVariable("OPTION_SELECT_QUESTIONPOOL", $this->lng->txt("dont_use_questionpool"));
2867  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
2868  $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
2869  $this->tpl->setVariable("CMD_SUBMIT", "save");
2870  $this->tpl->setVariable("TARGET", ' target="'. ilFrameTargetInfo::_getFrame("MainContent").'" ');
2871  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
2872 
2873  $this->tpl->setVariable("TXT_IMPORT_TST", $this->lng->txt("import_tst"));
2874  $this->tpl->setVariable("TXT_TST_FILE", $this->lng->txt("tst_upload_file"));
2875  $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
2876 
2877  $this->tpl->setVariable("TYPE_IMG", ilUtil::getImagePath('icon_tst.gif'));
2878  $this->tpl->setVariable("ALT_IMG",$this->lng->txt("obj_tst"));
2879  $this->tpl->setVariable("TYPE_IMG2", ilUtil::getImagePath('icon_tst.gif'));
2880  $this->tpl->setVariable("ALT_IMG2",$this->lng->txt("obj_tst"));
2881  $this->tpl->setVariable("NEW_TYPE", $new_type);
2882  $this->tpl->parseCurrentBlock();
2883 
2884  }
2885  }
2886 
2893  {
2894  $command = $_POST["command"];
2895  if (strlen($command))
2896  {
2897  $method = $command . "Object";
2898  if (method_exists($this, $method))
2899  {
2900  $this->$method();
2901  return;
2902  }
2903  }
2904  $this->ctrl->redirect($this, "participants");
2905  }
2906 
2913  {
2914  global $ilAccess, $ilToolbar, $lng;
2915 
2916  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
2917  {
2918  // allow only write access
2919  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
2920  $this->ctrl->redirect($this, "infoScreen");
2921  }
2922 
2923  if ($this->object->getFixedParticipants())
2924  {
2925  // search button
2926  $ilToolbar->addButton($this->lng->txt("tst_search_users"),
2927  $this->ctrl->getLinkTargetByClass('ilRepositorySearchGUI','start'));
2928 
2929 
2930  $participants =& $this->object->getInvitedUsers();
2931  $rows = array();
2932  foreach ($participants as $data)
2933  {
2934  $maxpass = $this->object->_getMaxPass($data["active_id"]);
2935  if (!is_null($maxpass))
2936  {
2937  $maxpass += 1;
2938  }
2939  $access = "";
2940  if (strlen($data["active_id"]))
2941  {
2942  $last_access = $this->object->_getLastAccess($data["active_id"]);
2943  $access = ilDatePresentation::formatDate(new ilDateTime($last_access,IL_CAL_DATETIME));
2944  }
2945  $this->ctrl->setParameterByClass('iltestevaluationgui', 'active_id', $data['active_id']);
2946 
2947  if ($data['active_id'] == null) // if no active id is set, user is invitee not participant...
2948  {
2949  if ( strlen($data["firstname"].$data["lastname"]) == 0 )
2950  {
2951  $fullname = $lng->txt("deleted_user");
2952  }
2953  else
2954  {
2955  $fullname = trim($data["lastname"] . ", " . $data["firstname"] . " " . $data["title"]);
2956  }
2957  } else {
2958  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
2959  $fullname = ilObjTestAccess::_getParticipantData($data['active_id']);
2960  }
2961 
2962  array_push($rows, array(
2963  'usr_id' => $data["usr_id"],
2964  'active_id' => $data['active_id'],
2965  'login' => $data["login"],
2966  'clientip' => $data["clientip"],
2967  'firstname' => $data["firstname"],
2968  'lastname' => $data["lastname"],
2969  'name' => $fullname,
2970  'started' => ($data["active_id"] > 0) ? 1 : 0,
2971  'finished' => ($data["test_finished"] == 1) ? 1 : 0,
2972  'access' => $access,
2973  'maxpass' => $maxpass,
2974  'result' => $this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'outParticipantsResultsOverview')
2975  ));
2976  }
2977  include_once "./Modules/Test/classes/tables/class.ilTestFixedParticipantsTableGUI.php";
2978  $table_gui = new ilTestFixedParticipantsTableGUI($this, 'participants', $this->object->getAnonymity(), count($rows));
2979  $table_gui->setData($rows);
2980  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
2981  }
2982  else
2983  {
2984  $participants =& $this->object->getTestParticipants();
2985  $rows = array();
2986  foreach ($participants as $data)
2987  {
2988  $maxpass = $this->object->_getMaxPass($data["active_id"]);
2989  if (!is_null($maxpass))
2990  {
2991  $maxpass += 1;
2992  }
2993  $access = "";
2994  if (strlen($data["active_id"]))
2995  {
2996  $last_access = $this->object->_getLastAccess($data["active_id"]);
2997  $access = ilDatePresentation::formatDate(new ilDateTime($last_access,IL_CAL_DATETIME));
2998  }
2999  $this->ctrl->setParameterByClass('iltestevaluationgui', 'active_id', $data['active_id']);
3000  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
3001  $fullname = ilObjTestAccess::_getParticipantData($data['active_id']);
3002  array_push($rows, array(
3003  'usr_id' => $data["active_id"],
3004  'active_id' => $data['active_id'],
3005  'login' => $data["login"],
3006  'name' => $fullname,
3007  'firstname' => $data["firstname"],
3008  'lastname' => $data["lastname"],
3009  'started' => ($data["active_id"] > 0) ? 1 : 0,
3010  'finished' => ($data["test_finished"] == 1) ? 1 : 0,
3011  'access' => $access,
3012  'maxpass' => $maxpass,
3013  'result' => $this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'outParticipantsResultsOverview')
3014  ));
3015  }
3016  include_once "./Modules/Test/classes/tables/class.ilTestParticipantsTableGUI.php";
3017  $table_gui = new ilTestParticipantsTableGUI($this, 'participants', $this->object->getAnonymity(), count($rows));
3018  $table_gui->setData($rows);
3019  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
3020  }
3021  }
3022 
3029  {
3030  if (count($_POST))
3031  {
3032  $_SESSION["show_user_results"] = $_POST["chbUser"];
3033  }
3034  $this->showUserResults($show_pass_details = TRUE, $show_answers = TRUE, $show_reached_points = TRUE);
3035  }
3036 
3043  {
3044  if (count($_POST))
3045  {
3046  $_SESSION["show_user_results"] = $_POST["chbUser"];
3047  }
3048  $this->showUserResults($show_pass_details = FALSE, $show_answers = TRUE);
3049  }
3050 
3057  {
3058  if (count($_POST))
3059  {
3060  $_SESSION["show_user_results"] = $_POST["chbUser"];
3061  }
3062  $this->showUserResults($show_pass_details = TRUE, $show_answers = FALSE);
3063  }
3064 
3070  function showUserResults($show_pass_details, $show_answers, $show_reached_points = FALSE)
3071  {
3072  $template = new ilTemplate("tpl.il_as_tst_participants_result_output.html", TRUE, TRUE, "Modules/Test");
3073 
3074  if (count($_SESSION["show_user_results"]) == 0)
3075  {
3076  ilUtil::sendInfo($this->lng->txt("select_one_user"), TRUE);
3077  $this->ctrl->redirect($this, "participants");
3078  }
3079 
3080  include_once "./Modules/Test/classes/class.ilTestServiceGUI.php";
3081  $serviceGUI =& new ilTestServiceGUI($this->object);
3082  $count = 0;
3083  foreach ($_SESSION["show_user_results"] as $key => $active_id)
3084  {
3085  $count++;
3086  $results = "";
3087  if ($this->object->getFixedParticipants())
3088  {
3089  $active_id = $this->object->getActiveIdOfUser($active_id);
3090  }
3091  if ($active_id > 0)
3092  {
3093  $results = $serviceGUI->getResultsOfUserOutput($active_id, $this->object->_getResultPass($active_id), $show_pass_details, $show_answers, FALSE, $show_reached_points);
3094  }
3095  if ($count < count($_SESSION["show_user_results"]))
3096  {
3097  $template->touchBlock("break");
3098  }
3099  $template->setCurrentBlock("user_result");
3100  $template->setVariable("USER_RESULT", $results);
3101  $template->parseCurrentBlock();
3102  }
3103  $template->setVariable("BACK_TEXT", $this->lng->txt("back"));
3104  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "participants"));
3105  $template->setVariable("PRINT_TEXT", $this->lng->txt("print"));
3106  $template->setVariable("PRINT_URL", "javascript:window.print();");
3107 
3108  $this->tpl->setVariable("ADM_CONTENT", $template->get());
3109  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
3110  if ($this->object->getShowSolutionAnswersOnly())
3111  {
3112  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
3113  }
3114  }
3115 
3117  {
3118  if (is_array($_POST["chbUser"]))
3119  {
3120  foreach ($_POST["chbUser"] as $user_id)
3121  {
3122  $this->object->disinviteUser($user_id);
3123  }
3124  }
3125  else
3126  {
3127  ilUtil::sendInfo($this->lng->txt("select_one_user"), true);
3128  }
3129  $this->ctrl->redirect($this, "participants");
3130  }
3131 
3133  {
3134  if (is_array($_POST["chbUser"]))
3135  {
3136  foreach ($_POST["chbUser"] as $user_id)
3137  {
3138  $this->object->setClientIP($user_id, $_POST["clientip_".$user_id]);
3139  }
3140  }
3141  else
3142  {
3143  ilUtil::sendInfo($this->lng->txt("select_one_user"), true);
3144  }
3145  $this->ctrl->redirect($this, "participants");
3146  }
3147 
3155  function printobject()
3156  {
3157  global $ilAccess, $ilias;
3158  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
3159  {
3160  // allow only write access
3161  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3162  $this->ctrl->redirect($this, "infoScreen");
3163  }
3164  $this->getQuestionsSubTabs();
3165  $template = new ilTemplate("tpl.il_as_tst_print_test_confirm.html", TRUE, TRUE, "Modules/Test");
3166 
3167  include_once './Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
3168  if(ilRPCServerSettings::getInstance()->isEnabled())
3169  {
3170  $this->ctrl->setParameter($this, "pdf", "1");
3171  $template->setCurrentBlock("pdf_export");
3172  $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "print"));
3173  $this->ctrl->setParameter($this, "pdf", "");
3174  $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
3175  $template->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export"));
3176  $template->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")));
3177  $template->parseCurrentBlock();
3178  }
3179 
3180  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
3181 
3182  global $ilUser;
3183  $print_date = mktime(date("H"), date("i"), date("s"), date("m") , date("d"), date("Y"));
3184  $max_points= 0;
3185  $counter = 1;
3186 
3187  foreach ($this->object->questions as $question)
3188  {
3189  $template->setCurrentBlock("question");
3190  $question_gui = $this->object->createQuestionGUI("", $question);
3191  $template->setVariable("COUNTER_QUESTION", $counter.".");
3192  $template->setVariable("QUESTION_TITLE", ilUtil::prepareFormOutput($question_gui->object->getTitle()));
3193  if ($question_gui->object->getMaximumPoints() == 1)
3194  {
3195  $template->setVariable("QUESTION_POINTS", $question_gui->object->getMaximumPoints() . " " . $this->lng->txt("point"));
3196  }
3197  else
3198  {
3199  $template->setVariable("QUESTION_POINTS", $question_gui->object->getMaximumPoints() . " " . $this->lng->txt("points"));
3200  }
3201  $result_output = $question_gui->getSolutionOutput("", NULL, FALSE, TRUE, FALSE, $this->object->getShowSolutionFeedback());
3202  if (strlen($result_output) == 0) $result_output = $question_gui->getPreview(FALSE);
3203  $template->setVariable("SOLUTION_OUTPUT", $result_output);
3204  $template->parseCurrentBlock("question");
3205  $counter ++;
3206  $max_points += $question_gui->object->getMaximumPoints();
3207  }
3208 
3209  $template->setCurrentBlock("navigation_buttons");
3210  $template->setVariable("BUTTON_PRINT", $this->lng->txt("print"));
3211  $template->parseCurrentBlock();
3212 
3213  $template->setVariable("TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
3214  $template->setVariable("PRINT_TEST", ilUtil::prepareFormOutput($this->lng->txt("tst_print")));
3215  $template->setVariable("TXT_PRINT_DATE", ilUtil::prepareFormOutput($this->lng->txt("date")));
3216  $template->setVariable("VALUE_PRINT_DATE", ilUtil::prepareFormOutput(strftime("%c",$print_date)));
3217  $template->setVariable("TXT_MAXIMUM_POINTS", ilUtil::prepareFormOutput($this->lng->txt("tst_maximum_points")));
3218  $template->setVariable("VALUE_MAXIMUM_POINTS", ilUtil::prepareFormOutput($max_points));
3219 
3220  if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1))
3221  {
3222  $this->object->deliverPDFfromHTML($template->get(), $this->object->getTitle());
3223  }
3224  else
3225  {
3226  $this->tpl->setVariable("PRINT_CONTENT", $template->get());
3227  }
3228  }
3229 
3231  {
3232  $countusers = 0;
3233  // add users
3234  if (is_array($_POST["user"]))
3235  {
3236  $i = 0;
3237  foreach ($_POST["user"] as $user_id)
3238  {
3239  $client_ip = $_POST["client_ip"][$i];
3240  $this->object->inviteUser($user_id, $client_ip);
3241  $countusers++;
3242  $i++;
3243  }
3244  }
3245  $message = "";
3246  if ($countusers)
3247  {
3248  $message = $this->lng->txt("tst_invited_selected_users");
3249  }
3250  if (strlen($message))
3251  {
3252  ilUtil::sendInfo($message, TRUE);
3253  }
3254  else
3255  {
3256  ilUtil::sendInfo($this->lng->txt("tst_invited_nobody"), TRUE);
3257  }
3258 
3259  $this->ctrl->redirect($this, "participants");
3260  }
3261 
3267  function defaultsObject()
3268  {
3269  global $ilUser;
3270  global $ilAccess;
3271 
3272  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
3273  {
3274  // allow only write access
3275  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3276  $this->ctrl->redirect($this, "infoScreen");
3277  }
3278 
3279  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_defaults.html", "Modules/Test");
3280 
3281  $maxentries = $ilUser->getPref("hits_per_page");
3282  if ($maxentries < 1)
3283  {
3284  $maxentries = 9999;
3285  }
3286 
3287  $offset = $_GET["offset"] ? $_GET["offset"] : 0;
3288  $sortby = $_GET["sort_by"] ? $_GET["sort_by"] : "name";
3289  $sortorder = $_GET["sort_order"] ? $_GET["sort_order"] : "asc";
3290 
3291  $defaults =& $this->object->getAvailableDefaults($sortby, $sortorder);
3292  if (count($defaults) > 0)
3293  {
3294  $tablerows = array();
3295  foreach ($defaults as $row)
3296  {
3297  array_push($tablerows, array("checkbox" => "<input type=\"checkbox\" name=\"chb_defaults[]\" value=\"" . $row["test_defaults_id"] . "\"/>", "name" => $row["name"]));
3298  }
3299  $headervars = array("", "name");
3300 
3301  include_once "./Services/Table/classes/class.ilTableGUI.php";
3302  $tbl = new ilTableGUI(0, FALSE);
3303  $tbl->setTitle($this->lng->txt("tst_defaults_available"));
3304  $header_names = array(
3305  "",
3306  $this->lng->txt("title")
3307  );
3308  $tbl->setHeaderNames($header_names);
3309 
3310  $tbl->disable("sort");
3311  $tbl->disable("auto_sort");
3312  $tbl->enable("title");
3313  $tbl->enable("action");
3314  $tbl->enable("select_all");
3315  $tbl->setLimit($maxentries);
3316  $tbl->setOffset($offset);
3317  $tbl->setData($tablerows);
3318  $tbl->setMaxCount(count($tablerows));
3319  $tbl->setOrderDirection($sortorder);
3320  $tbl->setSelectAllCheckbox("chb_defaults");
3321  $tbl->setFormName("formDefaults");
3322  $tbl->addActionButton("deleteDefaults", $this->lng->txt("delete"));
3323  $tbl->addActionButton("applyDefaults", $this->lng->txt("apply"));
3324 
3325  $header_params = $this->ctrl->getParameterArray($this, "defaults");
3326  $tbl->setHeaderVars($headervars, $header_params);
3327 
3328  // footer
3329  $tbl->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
3330  // render table
3331  $tableoutput = $tbl->render();
3332  $this->tpl->setVariable("TEST_DEFAULTS_TABLE", $tableoutput);
3333  }
3334  else
3335  {
3336  $this->tpl->setVariable("TEST_DEFAULTS_TABLE", $this->lng->txt("tst_defaults_not_defined"));
3337  }
3338  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "addDefaults"));
3339  $this->tpl->setVariable("BUTTON_ADD", $this->lng->txt("add"));
3340  $this->tpl->setVariable("TEXT_DEFAULTS_OF_TEST", $this->lng->txt("tst_defaults_defaults_of_test"));
3341  }
3342 
3347  {
3348  if (count($_POST["chb_defaults"]))
3349  {
3350  foreach ($_POST["chb_defaults"] as $test_default_id)
3351  {
3352  $this->object->deleteDefaults($test_default_id);
3353  }
3354  }
3355  $this->defaultsObject();
3356  }
3357 
3362  {
3363  if (count($_POST["chb_defaults"]) == 1)
3364  {
3365  foreach ($_POST["chb_defaults"] as $test_default_id)
3366  {
3367  $result = $this->object->applyDefaults($test_default_id);
3368  if (!$result)
3369  {
3370  ilUtil::sendInfo($this->lng->txt("tst_defaults_apply_not_possible"));
3371  }
3372  else
3373  {
3374  ilUtil::sendSuccess($this->lng->txt("tst_defaults_applied"));
3375  }
3376  }
3377  }
3378  else
3379  {
3380  ilUtil::sendInfo($this->lng->txt("tst_defaults_apply_select_one"));
3381  }
3382  $this->defaultsObject();
3383  }
3384 
3389  {
3390  if (strlen($_POST["name"]) > 0)
3391  {
3392  $this->object->addDefaults($_POST['name']);
3393  }
3394  else
3395  {
3396  ilUtil::sendInfo($this->lng->txt("tst_defaults_enter_name"));
3397  }
3398  $this->defaultsObject();
3399  }
3400 
3406  function infoScreenObject()
3407  {
3408  $this->ctrl->setCmd("showSummary");
3409  $this->ctrl->setCmdClass("ilinfoscreengui");
3410  $this->infoScreen();
3411  }
3412 
3414  {
3415  $this->ctrl->setCmd("showSummary");
3416  $this->ctrl->setCmdClass("ilinfoscreengui");
3417  $this->infoScreen($_SESSION["lock"]);
3418  }
3419 
3423  function infoScreen($session_lock = "")
3424  {
3425  global $ilAccess;
3426  global $ilUser;
3427 
3428  // Disabled
3429  /*
3430  if ($_GET['crs_show_result'])
3431  {
3432  $this->object->hideCorrectAnsweredQuestions();
3433  }
3434  else
3435  {
3436  */
3437  if ($this->object->getTestSequence()->hasHiddenQuestions())
3438  {
3439  $this->object->getTestSequence()->clearHiddenQuestions();
3440  $this->object->getTestSequence()->saveToDb();
3441  }
3442  //}
3443 
3444  if ($_GET['createRandomSolutions'])
3445  {
3446  $this->object->createRandomSolutions($_GET['createRandomSolutions']);
3447  }
3448 
3449  if (!$ilAccess->checkAccess("visible", "", $this->ref_id))
3450  {
3451  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
3452  }
3453 
3454  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
3455  $info = new ilInfoScreenGUI($this);
3456 
3457  $seq = $this->object->getTestSession()->getLastSequence();
3458 
3459  include_once "./Modules/Test/classes/class.ilTestOutputGUI.php";
3460  $output_gui =& new ilTestOutputGUI($this->object);
3461  $this->ctrl->setParameter($output_gui, "sequence", $seq);
3462  $info->setFormAction($this->ctrl->getFormAction($output_gui));
3463  if (strlen($session_lock))
3464  {
3465  $info->addHiddenElement("lock", $session_lock);
3466  }
3467  else
3468  {
3469  $info->addHiddenElement("lock", md5($_COOKIE['PHPSESSID'] . time()));
3470  }
3471  $online_access = false;
3472  if ($this->object->getFixedParticipants())
3473  {
3474  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
3475  $online_access_result = ilObjTestAccess::_lookupOnlineTestAccess($this->object->getId(), $ilUser->getId());
3476  if ($online_access_result === true)
3477  {
3478  $online_access = true;
3479  }
3480  else
3481  {
3482  ilUtil::sendInfo($online_access_result);
3483  }
3484  }
3485  if ($this->object->isComplete())
3486  {
3487  if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id))
3488  {
3489  $executable = $this->object->isExecutable($ilUser->getId(), $allowPassIncrease = TRUE);
3490  if ($executable["executable"])
3491  {
3492  if ($this->object->getTestSession()->getActiveId() > 0)
3493  {
3494  // resume test
3495  $resume_text = $this->lng->txt("tst_resume_test");
3496  if (($seq < 1) || ($seq == $this->object->getTestSequence()->getFirstSequence()))
3497  {
3498  $resume_text = $this->object->getStartTestLabel($this->object->getTestSession()->getActiveId());
3499  }
3500  // Disabled
3501  #if(!$_GET['crs_show_result'] or $this->object->getTestSequence()->getFirstSequence())
3502  {
3503  $info->addFormButton("resume", $resume_text);
3504  }
3505  }
3506  else
3507  {
3508  // start new test
3509  $info->addFormButton("start", $this->object->getStartTestLabel($this->object->getTestSession()->getActiveId()));
3510  }
3511  }
3512  else
3513  {
3514  ilUtil::sendInfo($executable["errormessage"]);
3515  }
3516  if ($this->object->getTestSession()->getActiveId() > 0)
3517  {
3518  // test results button
3519  if ($this->object->canShowTestResults($ilUser->getId()))
3520  {
3521  $info->addFormButton("outUserResultsOverview", $this->lng->txt("tst_show_results"));
3522  }
3523  }
3524  }
3525  if ($this->object->getTestSession()->getActiveId() > 0)
3526  {
3527  if ($this->object->canShowSolutionPrintview($ilUser->getId()))
3528  {
3529  $info->addFormButton("outUserListOfAnswerPasses", $this->lng->txt("tst_list_of_answers_show"));
3530  }
3531  }
3532  }
3533 
3534  if ($this->object->getShowInfo())
3535  {
3536  $info->enablePrivateNotes();
3537 
3538  }
3539  if (strlen($this->object->getIntroduction()))
3540  {
3541  $info->addSection($this->lng->txt("tst_introduction"));
3542  $info->addProperty("", $this->object->prepareTextareaOutput($this->object->getIntroduction()));
3543  }
3544 
3545  $info->addSection($this->lng->txt("tst_general_properties"));
3546  if ($this->object->getShowInfo())
3547  {
3548  $info->addProperty($this->lng->txt("author"), $this->object->getAuthor());
3549  $info->addProperty($this->lng->txt("title"), $this->object->getTitle());
3550  }
3551  if ($this->object->isComplete())
3552  {
3553  if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id))
3554  {
3555  if ($this->object->getShowInfo() || !$this->object->getForceJS())
3556  {
3557  // use javascript
3558  $checked_javascript = false;
3559  if ($this->object->getJavaScriptOutput())
3560  {
3561  $checked_javascript = true;
3562  }
3563  if ($this->object->getForceJS())
3564  {
3565  $info->addProperty($this->lng->txt("tst_test_output"), $this->lng->txt("tst_use_javascript"));
3566  }
3567  else
3568  {
3569  $info->addPropertyCheckbox($this->lng->txt("tst_test_output"), "chb_javascript", 1, $this->lng->txt("tst_use_javascript"), $checked_javascript);
3570  }
3571  }
3572  // hide previous results
3573  if (!$this->object->isRandomTest())
3574  {
3575  if ($this->object->getNrOfTries() != 1)
3576  {
3577  if ($this->object->getUsePreviousAnswers() == 0)
3578  {
3579  if ($this->object->getShowInfo())
3580  {
3581  $info->addProperty($this->lng->txt("tst_use_previous_answers"), $this->lng->txt("tst_dont_use_previous_answers"));
3582  }
3583  }
3584  else
3585  {
3586  $use_previous_answers = FALSE;
3587  if ($ilUser->prefs["tst_use_previous_answers"])
3588  {
3589  $checked_previous_answers = TRUE;
3590  }
3591  $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);
3592  }
3593  }
3594  }
3595  if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
3596  {
3597  $info->addPropertyTextinput($this->lng->txt("enter_anonymous_code"), "anonymous_id", "", 8, "setAnonymousId", $this->lng->txt("submit"));
3598  }
3599  }
3600  }
3601 
3602  if ($this->object->getShowInfo())
3603  {
3604  $info->addSection($this->lng->txt("tst_sequence_properties"));
3605  $info->addProperty($this->lng->txt("tst_sequence"), $this->lng->txt(($this->object->getSequenceSettings() == TEST_FIXED_SEQUENCE)? "tst_sequence_fixed":"tst_sequence_postpone"));
3606 
3607  $info->addSection($this->lng->txt("tst_heading_scoring"));
3608  $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"));
3609  $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"));
3610  if ($this->object->isRandomTest())
3611  {
3612  $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"));
3613  }
3614 
3615  $info->addSection($this->lng->txt("tst_score_reporting"));
3616  $score_reporting_text = "";
3617  switch ($this->object->getScoreReporting())
3618  {
3619  case REPORT_AFTER_TEST:
3620  $score_reporting_text = $this->lng->txt("tst_report_after_test");
3621  break;
3622  case REPORT_ALWAYS:
3623  $score_reporting_text = $this->lng->txt("tst_report_after_first_question");
3624  break;
3625  case REPORT_AFTER_DATE:
3626  $score_reporting_text = $this->lng->txt("tst_report_after_date");
3627  break;
3628  case 4:
3629  $score_reporting_text = $this->lng->txt("tst_report_after_never");
3630  break;
3631  }
3632  $info->addProperty($this->lng->txt("tst_score_reporting"), $score_reporting_text);
3633  $reporting_date = $this->object->getReportingDate();
3634  if ($reporting_date)
3635  {
3636  #preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $reporting_date, $matches);
3637  #$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]));
3638  #$info->addProperty($this->lng->txt("tst_score_reporting_date"), $txt_reporting_date);
3639  $info->addProperty($this->lng->txt('tst_score_reporting_date'),
3641  }
3642 
3643  $info->addSection($this->lng->txt("tst_session_settings"));
3644  $info->addProperty($this->lng->txt("tst_nr_of_tries"), ($this->object->getNrOfTries() == 0)?$this->lng->txt("unlimited"):$this->object->getNrOfTries());
3645  if ($this->object->getNrOfTries() != 1)
3646  {
3647  $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());
3648  }
3649 
3650  if ($this->object->getEnableProcessingTime())
3651  {
3652  $info->addProperty($this->lng->txt("tst_processing_time"), $this->object->getProcessingTime());
3653  }
3654  if (strlen($this->object->getAllowedUsers()) && ($this->object->getAllowedUsersTimeGap()))
3655  {
3656  $info->addProperty($this->lng->txt("tst_allowed_users"), $this->object->getAllowedUsers());
3657  }
3658 
3659  $starting_time = $this->object->getStartingTime();
3660  if ($starting_time)
3661  {
3662  $info->addProperty($this->lng->txt("tst_starting_time"),
3664  }
3665  $ending_time = $this->object->getEndingTime();
3666  if ($ending_time)
3667  {
3668  $info->addProperty($this->lng->txt("tst_ending_time"),
3670  }
3671  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
3672  // forward the command
3673 
3674  if($_GET['crs_show_result'] and !$this->object->getTestSequence()->getFirstSequence())
3675  {
3676  #ilUtil::sendInfo($this->lng->txt('crs_all_questions_answered_successfully'));
3677  }
3678  }
3679 
3680  $this->ctrl->forwardCommand($info);
3681  }
3682 
3683  function addLocatorItems()
3684  {
3685  global $ilLocator;
3686  switch ($this->ctrl->getCmd())
3687  {
3688  case "run":
3689  case "infoScreen":
3690  case "redirectToInfoScreen":
3691  case "start":
3692  case "resume":
3693  case "previous":
3694  case "next":
3695  case "summary":
3696  case "finishTest":
3697  case "outCorrectSolution":
3698  case "passDetails":
3699  case "showAnswersOfUser":
3700  case "outUserResultsOverview":
3701  case "backFromSummary":
3702  case "show_answers":
3703  case "setsolved":
3704  case "resetsolved":
3705  case "outTestSummary":
3706  case "outQuestionSummary":
3707  case "gotoQuestion":
3708  case "selectImagemapRegion":
3709  case "confirmSubmitAnswers":
3710  case "finalSubmission":
3711  case "postpone":
3712  case "redirectQuestion":
3713  case "outUserPassDetails":
3714  case "checkPassword":
3715  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"), "", $_GET["ref_id"]);
3716  break;
3717  case "eval_stat":
3718  case "evalAllUsers":
3719  case "evalUserDetail":
3720  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "eval_stat"), "", $_GET["ref_id"]);
3721  break;
3722  case "create":
3723  case "save":
3724  case "cancel":
3725  case "importFile":
3726  case "cloneAll":
3727  case "importVerifiedFile":
3728  case "cancelImport":
3729  break;
3730  default:
3731  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
3732  break;
3733  }
3734  }
3735 
3736  function getBrowseForQuestionsTab(&$tabs_gui)
3737  {
3738  global $ilAccess;
3739  if ($ilAccess->checkAccess("write", "", $this->ref_id))
3740  {
3741  // edit page
3742  $tabs_gui->setBackTarget($this->lng->txt("backtocallingtest"), $this->ctrl->getLinkTarget($this, "questions"));
3743  $tabs_gui->addTarget("tst_browse_for_questions",
3744  $this->ctrl->getLinkTarget($this, "browseForQuestions"),
3745  array("browseForQuestions", "filter", "resetFilter", "resetTextFilter", "insertQuestions"),
3746  "", "", TRUE
3747  );
3748  }
3749  }
3750 
3751  function getRandomQuestionsTab(&$tabs_gui)
3752  {
3753  global $ilAccess;
3754  if ($ilAccess->checkAccess("write", "", $this->ref_id))
3755  {
3756  // edit page
3757  $tabs_gui->setBackTarget($this->lng->txt("backtocallingtest"), $this->ctrl->getLinkTarget($this, "questions"));
3758  $tabs_gui->addTarget("random_selection",
3759  $this->ctrl->getLinkTarget($this, "randomQuestions"),
3760  array("randomQuestions"),
3761  "", ""
3762  );
3763  }
3764  }
3765 
3766  function statisticsObject()
3767  {
3768  }
3769 
3774  {
3775  include_once "./Services/Certificate/classes/class.ilCertificateGUI.php";
3776  include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
3777  $output_gui = new ilCertificateGUI(new ilTestCertificateAdapter($this->object));
3778  $output_gui->certificateEditor();
3779  }
3780 
3782  {
3783  global $ilTabs;
3784 
3785  // questions subtab
3786  $ilTabs->addSubTabTarget("edit_test_questions",
3787  $this->ctrl->getLinkTarget($this,'questions'),
3788  array("questions", "browseForQuestions", "questionBrowser", "createQuestion",
3789  "randomselect", "filter", "resetFilter", "insertQuestions",
3790  "back", "createRandomSelection", "cancelRandomSelect",
3791  "insertRandomSelection", "removeQuestions", "moveQuestions",
3792  "insertQuestionsBefore", "insertQuestionsAfter", "confirmRemoveQuestions",
3793  "cancelRemoveQuestions", "executeCreateQuestion", "cancelCreateQuestion",
3794  "addQuestionpool", "saveRandomQuestions", "saveQuestionSelectionMode"),
3795  "");
3796 
3797  // print view subtab
3798  if (!$this->object->isRandomTest())
3799  {
3800  $ilTabs->addSubTabTarget("print_view",
3801  $this->ctrl->getLinkTarget($this,'print'),
3802  "print", "");
3803  }
3804 
3805  }
3806 
3808  {
3809  global $ilTabs;
3810 
3811  // user results subtab
3812  $ilTabs->addSubTabTarget("eval_all_users",
3813  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "outEvaluation"),
3814  array("outEvaluation", "detailedEvaluation", "exportEvaluation", "evalUserDetail", "passDetails",
3815  "outStatisticsResultsOverview", "statisticsPassDetails")
3816  , "");
3817 
3818  // aggregated results subtab
3819  $ilTabs->addSubTabTarget("tst_results_aggregated",
3820  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "eval_a"),
3821  array("eval_a"),
3822  "", "");
3823 
3824  // question export
3825  $ilTabs->addSubTabTarget("tst_single_results",
3826  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "singleResults"),
3827  array("singleResults"),
3828  "", "");
3829  }
3830 
3832  {
3833  global $ilTabs, $ilias;
3834 
3835  // general subtab
3836  $force_active = ($this->ctrl->getCmd() == "")
3837  ? true
3838  : false;
3839  $ilTabs->addSubTabTarget("general",
3840  $this->ctrl->getLinkTarget($this,'properties'),
3841  array("properties", "saveProperties", "cancelProperties"),
3842  array("", "ilobjtestgui", "ilcertificategui"),
3843  "", $force_active);
3844 
3845  // scoring subtab
3846  $ilTabs->addSubTabTarget(
3847  "scoring",
3848  $this->ctrl->getLinkTarget($this,'scoring'),
3849  array("scoring"),
3850  array("", "ilobjtestgui", "ilcertificategui")
3851  );
3852 
3853  // mark schema subtab
3854  $ilTabs->addSubTabTarget(
3855  "mark_schema",
3856  $this->ctrl->getLinkTarget($this,'marks'),
3857  array("marks", "addMarkStep", "deleteMarkSteps", "addSimpleMarkSchema",
3858  "saveMarks", "cancelMarks"),
3859  array("", "ilobjtestgui", "ilcertificategui")
3860  );
3861 
3862  include_once './Services/WebServices/RPC/classes/class.ilRPCServerSettings.php';
3863  if(ilRPCServerSettings::getInstance()->isEnabled())
3864  {
3865  // certificate subtab
3866  $ilTabs->addSubTabTarget(
3867  "certificate",
3868  $this->ctrl->getLinkTarget($this,'certificate'),
3869  array("certificate", "certificateEditor", "certificateRemoveBackground", "certificateSave",
3870  "certificatePreview", "certificateDelete", "certificateUpload", "certificateImport"),
3871  array("", "ilobjtestgui", "ilcertificategui")
3872  );
3873  }
3874 
3875  // defaults subtab
3876  $ilTabs->addSubTabTarget(
3877  "defaults",
3878  $this->ctrl->getLinkTarget($this, "defaults"),
3879  array("defaults", "deleteDefaults", "addDefaults", "applyDefaults"),
3880  array("", "ilobjtestgui", "ilcertificategui")
3881  );
3882  }
3883 
3889  function getTabs(&$tabs_gui)
3890  {
3891  global $ilAccess,$ilUser;
3892 
3893  switch ($this->ctrl->getCmd())
3894  {
3895  case "resume":
3896  case "previous":
3897  case "next":
3898  case "summary":
3899  case "directfeedback":
3900  case "finishTest":
3901  case "outCorrectSolution":
3902  case "passDetails":
3903  case "showAnswersOfUser":
3904  case "outUserResultsOverview":
3905  case "backFromSummary":
3906  case "show_answers":
3907  case "setsolved":
3908  case "resetsolved":
3909  case "confirmFinish":
3910  case "outTestSummary":
3911  case "outQuestionSummary":
3912  case "gotoQuestion":
3913  case "selectImagemapRegion":
3914  case "confirmSubmitAnswers":
3915  case "finalSubmission":
3916  case "postpone":
3917  case "redirectQuestion":
3918  case "outUserPassDetails":
3919  case "checkPassword":
3920  case "exportCertificate":
3921  case "finishListOfAnswers":
3922  case "backConfirmFinish":
3923  case "showFinalStatement":
3924  return;
3925  break;
3926  case "browseForQuestions":
3927  case "filter":
3928  case "resetFilter":
3929  case "resetTextFilter":
3930  case "insertQuestions":
3931  return $this->getBrowseForQuestionsTab($tabs_gui);
3932  break;
3933  case "scoring":
3934  case "properties":
3935  case "marks":
3936  case "saveMarks":
3937  case "cancelMarks":
3938  case "addMarkStep":
3939  case "deleteMarkSteps":
3940  case "addSimpleMarkSchema":
3941  case "certificate":
3942  case "certificateservice":
3943  case "certificateImport":
3944  case "certificateUpload":
3945  case "certificateEditor":
3946  case "certificateDelete":
3947  case "certificateSave":
3948  case "defaults":
3949  case "deleteDefaults":
3950  case "addDefaults":
3951  case "applyDefaults":
3952  case "inviteParticipants":
3953  case "searchParticipants":
3954  case "":
3955  if (($ilAccess->checkAccess("write", "", $this->ref_id)) && ((strcmp($this->ctrl->getCmdClass(), "ilobjtestgui") == 0) || (strcmp($this->ctrl->getCmdClass(), "ilcertificategui") == 0) || (strlen($this->ctrl->getCmdClass()) == 0)))
3956  {
3957  $this->getSettingsSubTabs();
3958  }
3959  break;
3960  case "export":
3961  case "print":
3962  break;
3963  case "statistics":
3964  case "eval_a":
3965  case "detailedEvaluation":
3966  case "outEvaluation":
3967  case "singleResults":
3968  case "exportEvaluation":
3969  case "evalUserDetail":
3970  case "passDetails":
3971  case "outStatisticsResultsOverview":
3972  case "statisticsPassDetails":
3973  $this->getStatisticsSubTabs();
3974  break;
3975  }
3976 
3977  if (strcmp(strtolower(get_class($this->object)), "ilobjtest") == 0)
3978  {
3979  // questions tab
3980  if ($ilAccess->checkAccess("write", "", $this->ref_id))
3981  {
3982  $force_active = ($_GET["up"] != "" || $_GET["down"] != "")
3983  ? true
3984  : false;
3985  if (!$force_active)
3986  {
3987  if ($_GET["browse"] == 1) $force_active = true;
3988  if (preg_match("/deleteqpl_\d+/", $this->ctrl->getCmd()))
3989  {
3990  $force_active = true;
3991  }
3992  }
3993  $tabs_gui->addTarget("assQuestions",
3994  $this->ctrl->getLinkTarget($this,'questions'),
3995  array("questions", "browseForQuestions", "questionBrowser", "createQuestion",
3996  "randomselect", "filter", "resetFilter", "insertQuestions",
3997  "back", "createRandomSelection", "cancelRandomSelect",
3998  "insertRandomSelection", "removeQuestions", "moveQuestions",
3999  "insertQuestionsBefore", "insertQuestionsAfter", "confirmRemoveQuestions",
4000  "cancelRemoveQuestions", "executeCreateQuestion", "cancelCreateQuestion",
4001  "addQuestionpool", "saveRandomQuestions", "saveQuestionSelectionMode", "print",
4002  "addsource", "removesource", "randomQuestions"),
4003  "", "", $force_active);
4004  }
4005 
4006  // info tab
4007  if ($ilAccess->checkAccess("visible", "", $this->ref_id))
4008  {
4009  $tabs_gui->addTarget("info_short",
4010  $this->ctrl->getLinkTarget($this,'infoScreen'),
4011  array("infoScreen", "outIntroductionPage", "showSummary",
4012  "setAnonymousId", "outUserListOfAnswerPasses", "redirectToInfoScreen"));
4013  }
4014 
4015  // settings tab
4016  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4017  {
4018  $tabs_gui->addTarget("settings",
4019  $this->ctrl->getLinkTarget($this,'properties'),
4020  array("properties", "saveProperties", "cancelProperties",
4021  "marks", "addMarkStep", "deleteMarkSteps", "addSimpleMarkSchema",
4022  "saveMarks", "cancelMarks",
4023  "certificate", "certificateEditor", "certificateRemoveBackground",
4024  "certificateSave", "certificatePreview", "certificateDelete", "certificateUpload",
4025  "certificateImport", "scoring", "defaults", "addDefaults", "deleteDefaults", "applyDefaults",
4026  "inviteParticipants", "saveFixedParticipantsStatus", "searchParticipants", "addParticipants",
4027  ""
4028  ),
4029  array("", "ilobjtestgui", "ilcertificategui")
4030  );
4031 
4032  // participants
4033  $tabs_gui->addTarget("participants",
4034  $this->ctrl->getLinkTarget($this,'participants'),
4035  array("participants", "saveClientIP",
4036  "removeParticipant",
4037  "showParticipantAnswersForAuthor",
4038  "deleteAllUserResults",
4039  "cancelDeleteAllUserData", "deleteSingleUserResults",
4040  "outParticipantsResultsOverview", "outParticipantsPassDetails",
4041  "showPassOverview", "showUserAnswers", "participantsAction",
4042  "showDetailedResults"),
4043  "");
4044  }
4045 
4046  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
4047  if(ilLearningProgressAccess::checkAccess($this->object->getRefId()))
4048  {
4049  $tabs_gui->addTarget('learning_progress',
4050  $this->ctrl->getLinkTargetByClass(array('illearningprogressgui'),''),
4051  '',
4052  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui'));
4053  }
4054 
4055  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4056  {
4057  include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
4059  if (count($scoring))
4060  {
4061  // scoring tab
4062  $tabs_gui->addTarget("manscoring",
4063  $this->ctrl->getLinkTargetByClass("iltestscoringgui", "manscoring"),
4064  array("manscoring", "scoringfilter", "scoringfilterreset", "setPointsManual", "setFeedbackManual", "setManscoringDone"),
4065  "");
4066  }
4067  }
4068 
4069  if (($ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) || ($ilAccess->checkAccess("write", "", $this->ref_id)))
4070  {
4071  // statistics tab
4072  $tabs_gui->addTarget("statistics",
4073  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "outEvaluation"),
4074  array("statistics", "outEvaluation", "exportEvaluation", "detailedEvaluation", "eval_a", "evalUserDetail",
4075  "passDetails", "outStatisticsResultsOverview", "statisticsPassDetails", "singleResults")
4076  , "");
4077  }
4078 
4079  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4080  {
4081  // history
4082  $tabs_gui->addTarget("history",
4083  $this->ctrl->getLinkTarget($this,'history'),
4084  "history", "");
4085 
4086  // meta data
4087  $tabs_gui->addTarget("meta_data",
4088  $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'),
4089  "", "ilmdeditorgui");
4090 
4091  // export tab
4092  $tabs_gui->addTarget("export",
4093  $this->ctrl->getLinkTarget($this,'export'),
4094  array("export", "createExportFile", "confirmDeleteExportFile",
4095  "downloadExportFile", "deleteExportFile", "cancelDeleteExportFile"),
4096  "");
4097  }
4098 
4099  if ($ilAccess->checkAccess("edit_permission", "", $this->ref_id))
4100  {
4101  $tabs_gui->addTarget("perm_settings",
4102  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
4103  }
4104  }
4105  }
4106 
4115  function _goto($a_target)
4116  {
4117  global $ilAccess, $ilErr, $lng;
4118 
4119  if ($ilAccess->checkAccess("visible", "", $a_target))
4120  {
4121  //include_once "./Services/Utilities/classes/class.ilUtil.php";
4122  $_GET["baseClass"] = "ilObjTestGUI";
4123  $_GET["cmd"] = "infoScreen";
4124  $_GET["ref_id"] = $a_target;
4125  include_once("ilias.php");
4126  exit;
4127  //ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=infoScreen&ref_id=$a_target");
4128  }
4129  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
4130  {
4131  $_GET["cmd"] = "frameset";
4132  $_GET["target"] = "";
4133  $_GET["ref_id"] = ROOT_FOLDER_ID;
4134  ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
4135  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
4136  include("repository.php");
4137  exit;
4138  }
4139 
4140  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
4141  }
4142 
4143 } // END class.ilObjTestGUI
4144 ?>