ILIAS  eassessment Revision 61809
 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 
24 include_once "./classes/class.ilObjectGUI.php";
25 include_once "./Modules/Test/classes/inc.AssessmentConstants.php";
26 
28 {
33  function ilObjTestGUI()
34  {
35  global $lng, $ilCtrl;
36  $lng->loadLanguageModule("assessment");
37  $this->type = "tst";
38  $this->ctrl =& $ilCtrl;
39  $this->ctrl->saveParameter($this, "ref_id");
40  $this->ilObjectGUI("",$_GET["ref_id"], true, false);
41  $this->safe_commands = array("printTest","saveTest","resetTest","savePDF","showPaperVersion");
42  // Added parameter if called from crs_objectives
43  if((int) $_GET['crs_show_result'])
44  {
45  $this->ctrl->saveParameter($this,'crs_show_result',(int) $_GET['crs_show_result']);
46  }
47  }
48 
52  function executeCommand()
53  {
54  global $ilAccess, $ilNavigationHistory,$ilCtrl;
55 
56  if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"])) && (!$ilAccess->checkAccess("visible", "", $_GET["ref_id"])))
57  {
58  global $ilias;
59  $ilias->raiseError($this->lng->txt("permission_denied"), $ilias->error_obj->MESSAGE);
60  }
61  $cmd = $this->ctrl->getCmd("properties");
62  $GLOBALS['ilLog']->write(__METHOD__.': cmd = '.$cmd);
63  $next_class = $this->ctrl->getNextClass($this);
64  $this->ctrl->setReturn($this, "properties");
65  if (method_exists($this->object, "getTestStyleLocation")) $this->tpl->addCss($this->object->getTestStyleLocation("output"), "screen");
66 
67  // add entry to navigation history
68  if (!$this->getCreationMode() &&
69  $ilAccess->checkAccess("read", "", $_GET["ref_id"]))
70  {
71  $ilNavigationHistory->addItem($_GET["ref_id"],
72  "ilias.php?baseClass=ilObjTestGUI&cmd=infoScreen&ref_id=".$_GET["ref_id"], "tst");
73  }
74 
75  if(!$this->getCreationMode())
76  {
77  if(IS_PAYMENT_ENABLED)
78  {
79  include_once 'Services/Payment/classes/class.ilPaymentObject.php';
80  if(ilPaymentObject::_isBuyable($this->object->getRefId()) &&
81  !ilPaymentObject::_hasAccess($this->object->getRefId()))
82  {
83  $this->setLocator();
84  $this->tpl->getStandardTemplate();
85 
86  include_once 'Services/Payment/classes/class.ilShopPurchaseGUI.php';
87  $pp = new ilShopPurchaseGUI((int)$_GET['ref_id']);
88  $ret = $this->ctrl->forwardCommand($pp);
89  $this->tpl->show();
90  exit();
91  }
92  }
93  }
94 
95  switch($next_class)
96  {
97  case "ilinfoscreengui":
98  $this->prepareOutput();
99  $this->infoScreen(); // forwards command
100  break;
101  case 'ilmdeditorgui':
102  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
103 
104  $this->prepareOutput();
105  $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
106  $md_gui->addObserver($this->object,'MDUpdateListener','General');
107 
108  $this->ctrl->forwardCommand($md_gui);
109  break;
110  case "iltestoutputgui":
111  include_once "./Modules/Test/classes/class.ilTestOutputGUI.php";
112  if (!($this->object->getKioskMode() || KIOSK_MODE) || in_array($cmd,$this->safe_commands)) $this->prepareOutput(); //Change Sn
113  $output_gui =& new ilTestOutputGUI($this->object);
114  $this->ctrl->forwardCommand($output_gui);
115  break;
116 
117  case "iltestevaluationgui":
118  include_once "./Modules/Test/classes/class.ilTestEvaluationGUI.php";
119  $this->prepareOutput();
120  $evaluation_gui =& new ilTestEvaluationGUI($this->object);
121  $this->ctrl->forwardCommand($evaluation_gui);
122  break;
123 
124  case "iltestservicegui":
125  include_once "./Modules/Test/classes/class.ilTestServiceGUI.php";
126  $this->prepareOutput();
127  $serviceGUI =& new ilTestServiceGUI($this->object);
128  $this->ctrl->forwardCommand($serviceGUI);
129  break;
130 
131  case 'ilpermissiongui':
132  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
133  $this->prepareOutput();
134  $perm_gui =& new ilPermissionGUI($this);
135  $ret =& $this->ctrl->forwardCommand($perm_gui);
136  break;
137 
138  case "illearningprogressgui":
139  include_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
140 
141  $this->prepareOutput();
142  $new_gui =& new ilLearningProgressGUI(LP_MODE_REPOSITORY,$this->object->getRefId());
143  $this->ctrl->forwardCommand($new_gui);
144 
145  break;
146 
147  case "ilcertificategui":
148  include_once "./Services/Certificate/classes/class.ilCertificateGUI.php";
149  $this->prepareOutput();
150  include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
151  $output_gui = new ilCertificateGUI(new ilTestCertificateAdapter($this->object));
152  $this->ctrl->forwardCommand($output_gui);
153  break;
154 
155  case "iltestscoringgui":
156  include_once "./Modules/Test/classes/class.ilTestScoringGUI.php";
157  $this->prepareOutput();
158  $output_gui = new ilTestScoringGUI($this->object);
159  $this->ctrl->forwardCommand($output_gui);
160  break;
161 
162  case 'ilobjectcopygui':
163  $this->prepareOutput();
164  include_once './Services/Object/classes/class.ilObjectCopyGUI.php';
165  $cp = new ilObjectCopyGUI($this);
166  $cp->setType('tst');
167  $this->ctrl->forwardCommand($cp);
168  break;
169 
170  case 'ilrepositorysearchgui':
171  $this->prepareOutput();
172  include_once('./Services/Search/classes/class.ilRepositorySearchGUI.php');
173  $rep_search =& new ilRepositorySearchGUI();
174  $rep_search->setCallback($this,
175  'addParticipantsObject',
176  array(
177  )
178  );
179 
180  // Set tabs
181  $this->ctrl->setReturn($this,'participants');
182  $ret =& $this->ctrl->forwardCommand($rep_search);
183  $this->tabs_gui->setTabActive('participants');
184  break;
185 
186 ######### scoreQuestion ######
187  case "iltestnewscoringgui":
188  include_once "./Modules/Test/classes/class.ilTestNewScoringGUI.php";
189  $this->prepareOutput();
190  $output_gui = new ilTestNewScoringGUI($this->object);
191  $this->ctrl->forwardCommand($output_gui);
192  break;
193 #####
194 
195 
196  default:
197  $this->prepareOutput();
198  if (preg_match("/deleteqpl_\d+/", $cmd))
199  {
200  $cmd = "randomQuestions";
201  }
202  if ((strcmp($cmd, "properties") == 0) && ($_GET["browse"]))
203  {
204  $this->questionBrowser();
205  return;
206  }
207  if ((strcmp($cmd, "properties") == 0) && ($_GET["up"] || $_GET["down"]))
208  {
209  $this->questionsObject();
210  return;
211  }
212  $cmd.= "Object";
213  $ret =& $this->$cmd();
214  break;
215  }
216  if (strtolower($_GET["baseClass"]) != "iladministrationgui" &&
217  $this->getCreationMode() != true)
218  {
219  $this->tpl->show();
220  }
221  }
222 
223  function runObject()
224  {
225  $this->ctrl->redirect($this, "infoScreen");
226  }
227 
229  {
230  $this->ctrl->redirectByClass("iltestevaluationgui", "outEvaluation");
231  }
232 
236  function importFileObject()
237  {
238  if (strcmp($_FILES["xmldoc"]["tmp_name"], "") == 0)
239  {
240  ilUtil::sendInfo($this->lng->txt("tst_select_file_for_import"));
241  $this->createObject();
242  return;
243  }
244  $this->ctrl->setParameter($this, "new_type", $this->type);
245  $this->uploadTstObject();
246  }
247 
252  function saveObject()
253  {
254  global $rbacadmin;
255 
256  if (!strlen($_POST['Fobject']['title']))
257  {
258  ilUtil::sendFailure($this->lng->txt('title_required'), true);
259  $this->ctrl->setParameter($this, 'new_type', $_GET['new_type']);
260  $this->ctrl->redirect($this, 'create');
261  }
262  // create and insert forum in objecttree
263  $newObj = parent::saveObject();
264  if ($_POST["defaults"] > 0)
265  {
266  $newObj->applyDefaults($_POST["defaults"]);
267  }
268 
269  // always send a message
270  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
271  ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&ref_id=".$newObj->getRefId()."&cmd=properties");
272  }
273 
275  {
276  include_once "./Services/Utilities/classes/class.ilUtil.php";
277  $path = $this->tree->getPathFull($this->object->getRefID());
278  ilUtil::redirect($this->getReturnLocation("cancel","./repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
279  }
280 
282  {
283  include_once "./Services/Utilities/classes/class.ilUtil.php";
284  ilUtil::redirect($this->getReturnLocation("cancel","./repository.php?ref_id=".(int) $_GET['crs_show_result']));
285  }
286 
287  /*
288  * list all export files
289  */
290  function exportObject()
291  {
292  global $tree;
293  global $ilAccess;
294  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
295  {
296  // allow only write access
297  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
298  $this->ctrl->redirect($this, "infoScreen");
299  }
300 
301  $export_dir = $this->object->getExportDirectory();
302  $export_files = $this->object->getExportFiles($export_dir);
303  $data = array();
304  if(count($export_files) > 0)
305  {
306  foreach($export_files as $exp_file)
307  {
308  $file_arr = explode("__", $exp_file);
309  $date = new ilDateTime($file_arr[0], IL_CAL_UNIX);
310  array_push($data, array(
311  'file' => $exp_file,
312  'size' => filesize($export_dir."/".$exp_file),
313  'date' => $date->get(IL_CAL_DATETIME)
314  ));
315  }
316  }
317 
318  include_once "./Modules/Test/classes/tables/class.ilTestExportTableGUI.php";
319  $table_gui = new ilTestExportTableGUI($this, 'export');
320  $table_gui->setData($data);
321  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
322  }
323 
328  {
329  global $ilAccess;
330 
331  if ($ilAccess->checkAccess("write", "", $this->ref_id))
332  {
333  include_once("./Modules/Test/classes/class.ilTestExport.php");
334  $test_exp = new ilTestExport($this->object, 'xml');
335  $test_exp->buildExportFile();
336  }
337  else
338  {
339  ilUtil::sendInfo("cannot_export_test", TRUE);
340  }
341  $this->ctrl->redirect($this, "export");
342  }
343 
348  {
349  global $ilAccess;
350 
351  if ($ilAccess->checkAccess("write", "", $this->ref_id))
352  {
353  include_once("./Modules/Test/classes/class.ilTestExport.php");
354  $test_exp = new ilTestExport($this->object, 'results');
355  $test_exp->buildExportFile();
356  }
357  else
358  {
359  ilUtil::sendInfo("cannot_export_test", TRUE);
360  }
361  $this->ctrl->redirect($this, "export");
362  }
363 
364 
369  {
370  if(!isset($_POST["file"]))
371  {
372  ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
373  $this->ctrl->redirect($this, "export");
374  }
375 
376  if (count($_POST["file"]) > 1)
377  {
378  ilUtil::sendInfo($this->lng->txt("select_max_one_item"), true);
379  $this->ctrl->redirect($this, "export");
380  }
381 
382 
383  $export_dir = $this->object->getExportDirectory();
384  ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
385  $_POST["file"][0]);
386  }
387 
392  {
393  if (!isset($_POST["file"]))
394  {
395  ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
396  $this->ctrl->redirect($this, "export");
397  }
398 
399  ilUtil::sendQuestion($this->lng->txt("info_delete_sure"));
400 
401  $export_dir = $this->object->getExportDirectory();
402  $export_files = $this->object->getExportFiles($export_dir);
403  $data = array();
404  if (count($_POST["file"]) > 0)
405  {
406  foreach ($_POST["file"] as $exp_file)
407  {
408  $file_arr = explode("__", $exp_file);
409  $date = new ilDateTime($file_arr[0], IL_CAL_UNIX);
410  array_push($data, array(
411  'file' => $exp_file,
412  'size' => filesize($export_dir."/".$exp_file),
413  'date' => $date->get(IL_CAL_DATETIME)
414  ));
415  }
416  }
417 
418  include_once "./Modules/Test/classes/tables/class.ilTestExportTableGUI.php";
419  $table_gui = new ilTestExportTableGUI($this, 'export', true);
420  $table_gui->setData($data);
421  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
422  }
423 
429  function cancelObject($in_rep = false)
430  {
431  ilUtil::redirect("repository.php?cmd=frameset&ref_id=".$_GET["ref_id"]);
432  }
433 
438  {
439  ilUtil::sendInfo($this->lng->txt("msg_cancel"), true);
440  $this->ctrl->redirect($this, "export");
441  }
442 
443 
448  {
449  $export_dir = $this->object->getExportDirectory();
450  foreach ($_POST["file"] as $file)
451  {
452  $exp_file = $export_dir."/".$file;
453  $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
454  if (@is_file($exp_file))
455  {
456  unlink($exp_file);
457  }
458  if (@is_dir($exp_dir))
459  {
460  ilUtil::delDir($exp_dir);
461  }
462  }
463  ilUtil::sendSuccess($this->lng->txt('msg_deleted_export_files'), true);
464  $this->ctrl->redirect($this, "export");
465  }
466 
470  function uploadTstObject()
471  {
472  if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
473  {
474  ilUtil::sendFailure($this->lng->txt("error_upload"));
475  $this->createObject();
476  return;
477  }
478  include_once("./Modules/Test/classes/class.ilObjTest.php");
479  // create import directory
481 
482  // copy uploaded file to import directory
483  $file = pathinfo($_FILES["xmldoc"]["name"]);
484  $full_path = $basedir."/".$_FILES["xmldoc"]["name"];
485  ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path);
486 
487  // unzip file
488  ilUtil::unzip($full_path);
489 
490  // determine filenames of xml files
491  $subdir = basename($file["basename"],".".$file["extension"]);
492  ilObjTest::_setImportDirectory($basedir . '/' . $subdir);
493  $xml_file = ilObjTest::_getImportDirectory().'/'.$subdir.".xml";
494  $qti_file = ilObjTest::_getImportDirectory().'/'. preg_replace("/test|tst/", "qti", $subdir).".xml";
495  $results_file = ilObjTest::_getImportDirectory().'/'. preg_replace("/test|tst/", "results", $subdir).".xml";
496 
497  // start verification of QTI files
498  include_once "./Services/QTI/classes/class.ilQTIParser.php";
499  $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, "");
500  $result = $qtiParser->startParsing();
501  $founditems =& $qtiParser->getFoundItems();
502 
503  if (count($founditems) == 0)
504  {
505  // nothing found
506 
507  // delete import directory
509 
510  ilUtil::sendInfo($this->lng->txt("tst_import_no_items"));
511  $this->createObject();
512  return;
513  }
514 
515  $complete = 0;
516  $incomplete = 0;
517  foreach ($founditems as $item)
518  {
519  if (strlen($item["type"]))
520  {
521  $complete++;
522  }
523  else
524  {
525  $incomplete++;
526  }
527  }
528 
529  if ($complete == 0)
530  {
531  // delete import directory
533 
534  ilUtil::sendInfo($this->lng->txt("qpl_import_non_ilias_files"));
535  $this->createObject();
536  return;
537  }
538 
539  $_SESSION["tst_import_results_file"] = $results_file;
540  $_SESSION["tst_import_xml_file"] = $xml_file;
541  $_SESSION["tst_import_qti_file"] = $qti_file;
542  $_SESSION["tst_import_subdir"] = $subdir;
543  // display of found questions
544  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.tst_import_verification.html");
545  $row_class = array("tblrow1", "tblrow2");
546  $counter = 0;
547  foreach ($founditems as $item)
548  {
549  $this->tpl->setCurrentBlock("verification_row");
550  $this->tpl->setVariable("ROW_CLASS", $row_class[$counter++ % 2]);
551  $this->tpl->setVariable("QUESTION_TITLE", $item["title"]);
552  $this->tpl->setVariable("QUESTION_IDENT", $item["ident"]);
553  include_once "./Services/QTI/classes/class.ilQTIItem.php";
554  switch ($item["type"])
555  {
556  case "MULTIPLE CHOICE QUESTION":
558  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("qt_multiple_choice"));
559  break;
560  case "SINGLE CHOICE QUESTION":
562  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assSingleChoice"));
563  break;
564  case "NUMERIC QUESTION":
565  case QT_NUMERIC:
566  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assNumeric"));
567  break;
568  case "TEXTSUBSET QUESTION":
569  case QT_TEXTSUBSET:
570  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextSubset"));
571  break;
572  case "CLOZE QUESTION":
573  case QT_CLOZE:
574  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assClozeTest"));
575  break;
576  case "IMAGE MAP QUESTION":
577  case QT_IMAGEMAP:
578  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assImagemapQuestion"));
579  break;
580  case "JAVA APPLET QUESTION":
581  case QT_JAVAAPPLET:
582  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assJavaApplet"));
583  break;
584  case "MATCHING QUESTION":
585  case QT_MATCHING:
586  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assMatchingQuestion"));
587  break;
588  case "ORDERING QUESTION":
589  case QT_ORDERING:
590  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assOrderingQuestion"));
591  break;
592  case "TEXT QUESTION":
593  case QT_TEXT:
594  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextQuestion"));
595  break;
596  }
597  $this->tpl->parseCurrentBlock();
598  }
599  $this->tpl->setCurrentBlock("adm_content");
600  $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt("question_type"));
601  $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("question_title"));
602  $this->tpl->setVariable("FOUND_QUESTIONS_INTRODUCTION", $this->lng->txt("tst_import_verify_found_questions"));
603  $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_tst"));
604  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
605  $this->tpl->setVariable("ARROW", ilUtil::getImagePath("arrow_downright.gif"));
606  $this->tpl->setVariable("QUESTIONPOOL_ID", $_POST["qpl"]);
607  $this->tpl->setVariable("VALUE_IMPORT", $this->lng->txt("import"));
608  $this->tpl->setVariable("VALUE_CANCEL", $this->lng->txt("cancel"));
609  $this->tpl->parseCurrentBlock();
610  }
611 
616  {
617  include_once "./Modules/Test/classes/class.ilObjTest.php";
618  // create new questionpool object
619  $newObj = new ilObjTest(0, true);
620  // set type of questionpool object
621  $newObj->setType($_GET["new_type"]);
622  // set title of questionpool object to "dummy"
623  $newObj->setTitle("dummy");
624  // set description of questionpool object
625  $newObj->setDescription("test import");
626  // create the questionpool class in the ILIAS database (object_data table)
627  $newObj->create(true);
628  // create a reference for the questionpool object in the ILIAS database (object_reference table)
629  $newObj->createReference();
630  // put the questionpool object in the administration tree
631  $newObj->putInTree($_GET["ref_id"]);
632  // get default permissions and set the permissions for the questionpool object
633  $newObj->setPermissions($_GET["ref_id"]);
634  // notify the questionpool object and all its parent objects that a "new" object was created
635  $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
636  // empty mark schema
637  $newObj->mark_schema->flush();
638 
639  // start parsing of QTI files
640  include_once "./Services/QTI/classes/class.ilQTIParser.php";
641  $qtiParser = new ilQTIParser($_SESSION["tst_import_qti_file"], IL_MO_PARSE_QTI, $_POST["qpl_id"], $_POST["ident"]);
642  $qtiParser->setTestObject($newObj);
643  $result = $qtiParser->startParsing();
644  $newObj->saveToDb();
645 
646  // import page data
647  include_once ("./Modules/LearningModule/classes/class.ilContObjParser.php");
648  $contParser = new ilContObjParser($newObj, $_SESSION["tst_import_xml_file"], $_SESSION["tst_import_subdir"]);
649  $contParser->setQuestionMapping($qtiParser->getImportMapping());
650  $contParser->startParsing();
651 
652  // import test results
653  if (@file_exists($_SESSION["tst_import_results_file"]))
654  {
655  include_once ("./Modules/Test/classes/class.ilTestResultsImportParser.php");
656  $results = new ilTestResultsImportParser($_SESSION["tst_import_results_file"], $newObj);
657  $results->startParsing();
658  }
659 
660  // delete import directory
662  ilUtil::sendSuccess($this->lng->txt("object_imported"),true);
663  ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
664  "&baseClass=ilObjTestGUI");
665  }
666 
667  /* reinserted this to find out whether this fixes a bug
668  warkusm, 2010-12-20 */
669  function cancelImportObject()
670  {
671  $this->ctrl->redirect($this, "cancel");
672  // $this->backToRepositoryObject();
673  }
674 
681  function uploadObject($redirect = true)
682  {
683  $this->uploadTstObject();
684  }
685 
695  function confirmChangeProperties($direction = 0)
696  {
697  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_properties_save_confirmation.html", "Modules/Test");
698  $information = "";
699  switch ($direction)
700  {
701  case 0:
702  $information = $this->lng->txt("change_properties_from_random_to_standard");
703  break;
704  default:
705  $information = $this->lng->txt("change_properties_from_standard_to_random");
706  break;
707  }
708  foreach ($_POST as $key => $value)
709  {
710  if (strcmp($key, "cmd") != 0)
711  {
712  if (is_array($value))
713  {
714  foreach ($value as $k => $v)
715  {
716  $this->tpl->setCurrentBlock("hidden_variable");
717  $this->tpl->setVariable("HIDDEN_KEY", $key . "[" . $k . "]");
718  $this->tpl->setVariable("HIDDEN_VALUE", $v);
719  $this->tpl->parseCurrentBlock();
720  }
721  }
722  else
723  {
724  $this->tpl->setCurrentBlock("hidden_variable");
725  $this->tpl->setVariable("HIDDEN_KEY", $key);
726  $this->tpl->setVariable("HIDDEN_VALUE", $value);
727  $this->tpl->parseCurrentBlock();
728  }
729  }
730  }
731  $this->tpl->setCurrentBlock("hidden_variable");
732  $this->tpl->setVariable("HIDDEN_KEY", "tst_properties_confirmation");
733  $this->tpl->setVariable("HIDDEN_VALUE", "1");
734  $this->tpl->parseCurrentBlock();
735  $this->tpl->setCurrentBlock("adm_content");
736  $this->tpl->setVariable("TXT_CONFIRMATION", $this->lng->txt("confirmation"));
737  $this->tpl->setVariable("TXT_INFORMATION", $information);
738  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
739  $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
740  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
741  $this->tpl->parseCurrentBlock();
742  }
743 
749  function saveScoringObject()
750  {
751  $hasErrors = $this->scoringObject(true);
752  if (!$hasErrors)
753  {
754  $total = $this->object->evalTotalPersons();
755  // Check the values the user entered in the form
756  if (!$total)
757  {
758  $this->object->setCountSystem($_POST["count_system"]);
759  $this->object->setMCScoring($_POST["mc_scoring"]);
760  $this->object->setScoreCutting($_POST["score_cutting"]);
761  $this->object->setPassScoring($_POST["pass_scoring"]);
762  }
763 
764  $this->object->setAnswerFeedback((is_array($_POST['instant_feedback']) && in_array('instant_feedback_answer', $_POST['instant_feedback'])) ? 1 : 0);
765  $this->object->setAnswerFeedbackPoints((is_array($_POST['instant_feedback']) && in_array('instant_feedback_points', $_POST['instant_feedback'])) ? 1 : 0);
766  $this->object->setInstantFeedbackSolution((is_array($_POST['instant_feedback']) && in_array('instant_feedback_solution', $_POST['instant_feedback'])) ? 1 : 0);
767 
768  $this->object->setScoreReporting($_POST["results_access"]);
769  if ($this->object->getScoreReporting() == REPORT_AFTER_DATE)
770  {
771  $this->object->setReportingDate(sprintf("%04d%02d%02d%02d%02d%02d",
772  $_POST["reporting_date"]['date']["y"],
773  $_POST["reporting_date"]['date']["m"],
774  $_POST["reporting_date"]['date']["d"],
775  $_POST["reporting_date"]['time']["h"],
776  $_POST["reporting_date"]['time']["m"],
777  $_POST["reporting_date"]['time']["s"]
778  ));
779  }
780  else
781  {
782  $this->object->setReportingDate('');
783  }
784 
785  $this->object->setShowPassDetails((is_array($_POST['results_presentation']) && in_array('pass_details', $_POST['results_presentation'])) ? 1 : 0);
786  $this->object->setShowSolutionDetails((is_array($_POST['results_presentation']) && in_array('solution_details', $_POST['results_presentation'])) ? 1 : 0);
787  $this->object->setShowSolutionPrintview((is_array($_POST['results_presentation']) && in_array('solution_printview', $_POST['results_presentation'])) ? 1 : 0);
788  $this->object->setShowSolutionFeedback((is_array($_POST['results_presentation']) && in_array('solution_feedback', $_POST['results_presentation'])) ? 1 : 0);
789  $this->object->setShowSolutionAnswersOnly((is_array($_POST['results_presentation']) && in_array('solution_answers_only', $_POST['results_presentation'])) ? 1 : 0);
790  $this->object->setShowSolutionSignature((is_array($_POST['results_presentation']) && in_array('solution_signature', $_POST['results_presentation'])) ? 1 : 0);
791  $this->object->setShowSolutionSuggested((is_array($_POST['results_presentation']) && in_array('solution_suggested', $_POST['results_presentation'])) ? 1 : 0);
792  $this->object->setShowSolutionListComparison((is_array($_POST['results_presentation']) && in_array('solution_compare', $_POST['results_presentation'])) ? 1 : 0);
793  $this->object->setShowSolutionAnwersBeforeFinish((is_array($_POST['results_presentation']) && in_array('solution_answers_before_finish', $_POST['results_presentation'])) ? 1 : 0);
794 
795  $this->object->setExportSettingsSingleChoiceShort((is_array($_POST['export_settings']) && in_array('exp_sc_short', $_POST['export_settings'])) ? 1 : 0);
796  $this->object->setExportSettingsRespectShuffle((is_array($_POST['export_settings']) && in_array('exp_respect_shuffle', $_POST['export_settings'])) ? 1 : 0);
797 
798  $this->object->saveToDb(true);
799  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), TRUE);
800  $this->ctrl->redirect($this, "scoring");
801  }
802  }
803 
809  function scoringObject($checkonly = FALSE)
810  {
811  global $ilAccess;
812  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
813  {
814  // allow only write access
815  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
816  $this->ctrl->redirect($this, "infoScreen");
817  }
818 
819  $save = (strcmp($this->ctrl->getCmd(), "saveScoring") == 0) ? TRUE : FALSE;
820  $total = $this->object->evalTotalPersons();
821  $this->tpl->addJavascript("./Services/JavaScript/js/Basic.js");
822 
823  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
824  $form = new ilPropertyFormGUI();
825  $form->setFormAction($this->ctrl->getFormAction($this));
826  $form->setTableWidth("100%");
827  $form->setId("test_properties_scoring");
828 
829  // scoring properties
830  $header = new ilFormSectionHeaderGUI();
831  $header->setTitle($this->lng->txt("scoring"));
832  $form->addItem($header);
833 
834  // scoring system
835  $count_system = new ilRadioGroupInputGUI($this->lng->txt("tst_text_count_system"), "count_system");
836  $count_system->addOption(new ilRadioOption($this->lng->txt("tst_count_partial_solutions"), 0, ''));
837  $count_system->addOption(new ilRadioOption($this->lng->txt("tst_count_correct_solutions"), 1, ''));
838  $count_system->setValue($this->object->getCountSystem());
839  $count_system->setInfo($this->lng->txt("tst_count_system_description"));
840  if ($total)
841  {
842  $count_system->setDisabled(true);
843  }
844  $form->addItem($count_system);
845 
846  // mc questions
847  $mc_scoring = new ilRadioGroupInputGUI($this->lng->txt("tst_score_mcmr_questions"), "mc_scoring");
848  $mc_scoring->addOption(new ilRadioOption($this->lng->txt("tst_score_mcmr_zero_points_when_unanswered"), 0, ''));
849  $mc_scoring->addOption(new ilRadioOption($this->lng->txt("tst_score_mcmr_use_scoring_system"), 1, ''));
850  $mc_scoring->setValue($this->object->getMCScoring());
851  $mc_scoring->setInfo($this->lng->txt("tst_score_mcmr_questions_description"));
852  if ($total)
853  {
854  $mc_scoring->setDisabled(true);
855  }
856  $form->addItem($mc_scoring);
857 
858  // score cutting
859  $score_cutting = new ilRadioGroupInputGUI($this->lng->txt("tst_score_cutting"), "score_cutting");
860  $score_cutting->addOption(new ilRadioOption($this->lng->txt("tst_score_cut_question"), 0, ''));
861  $score_cutting->addOption(new ilRadioOption($this->lng->txt("tst_score_cut_test"), 1, ''));
862  $score_cutting->setValue($this->object->getScoreCutting());
863  $score_cutting->setInfo($this->lng->txt("tst_score_cutting_description"));
864  if ($total)
865  {
866  $score_cutting->setDisabled(true);
867  }
868  $form->addItem($score_cutting);
869 
870  // pass scoring
871  $pass_scoring = new ilRadioGroupInputGUI($this->lng->txt("tst_pass_scoring"), "pass_scoring");
872  $pass_scoring->addOption(new ilRadioOption($this->lng->txt("tst_pass_last_pass"), 0, ''));
873  $pass_scoring->addOption(new ilRadioOption($this->lng->txt("tst_pass_best_pass"), 1, ''));
874  $pass_scoring->setValue($this->object->getPassScoring());
875  $pass_scoring->setInfo($this->lng->txt("tst_pass_scoring_description"));
876  if ($total)
877  {
878  $pass_scoring->setDisabled(true);
879  }
880  $form->addItem($pass_scoring);
881 
882  // instant feedback
883  $instant_feedback = new ilCheckboxGroupInputGUI($this->lng->txt("tst_instant_feedback"), "instant_feedback");
884  $instant_feedback->addOption(new ilCheckboxOption($this->lng->txt("tst_instant_feedback_answer_specific"), 'instant_feedback_answer', ''));
885  $instant_feedback->addOption(new ilCheckboxOption($this->lng->txt("tst_instant_feedback_results"), 'instant_feedback_points', ''));
886  $instant_feedback->addOption(new ilCheckboxOption($this->lng->txt("tst_instant_feedback_solution"), 'instant_feedback_solution', ''));
887  $values = array();
888  if ($this->object->getAnswerFeedback()) array_push($values, 'instant_feedback_answer');
889  if ($this->object->getAnswerFeedbackPoints()) array_push($values, 'instant_feedback_points');
890  if ($this->object->getInstantFeedbackSolution()) array_push($values, 'instant_feedback_solution');
891  $instant_feedback->setValue($values);
892  $instant_feedback->setInfo($this->lng->txt("tst_instant_feedback_description"));
893  $form->addItem($instant_feedback);
894 
895  // access to test results
896  $results_access = new ilRadioGroupInputGUI($this->lng->txt("tst_results_access"), "results_access");
897  $results_access->addOption(new ilRadioOption($this->lng->txt("tst_results_access_finished"), 1, ''));
898  $results_access->addOption(new ilRadioOption($this->lng->txt("tst_results_access_always"), 2, ''));
899  $results_access->addOption(new ilRadioOption($this->lng->txt("tst_results_access_never"), 4, ''));
900  $results_access->addOption(new ilRadioOption($this->lng->txt("tst_results_access_date"), 3, ''));
901  $results_access->setValue($this->object->getScoreReporting());
902  $results_access->setInfo($this->lng->txt("tst_results_access_description"));
903 
904  // access date
905  $reporting_date = new ilDateTimeInputGUI('', 'reporting_date');
906  $reporting_date->setShowDate(true);
907  $reporting_date->setShowTime(true);
908  if (strlen($this->object->getReportingDate()))
909  {
910  $reporting_date->setDate(new ilDateTime($this->object->getReportingDate(), IL_CAL_TIMESTAMP));
911  }
912  else
913  {
914  $reporting_date->setDate(new ilDateTime(time(), IL_CAL_UNIX));
915  }
916  $results_access->addSubItem($reporting_date);
917  $form->addItem($results_access);
918 
919  // results presentation
920  $results_presentation = new ilCheckboxGroupInputGUI($this->lng->txt("tst_results_presentation"), "results_presentation");
921  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_pass_details"), 'pass_details', ''));
922  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_details"), 'solution_details', ''));
923  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_answers_before_finish"), 'solution_answers_before_finish', ''));
924  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_printview"), 'solution_printview', ''));
925  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_compare"), 'solution_compare', ''));
926  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_feedback"), 'solution_feedback', ''));
927  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_answers_only"), 'solution_answers_only', ''));
928  $signatureOption = new ilCheckboxOption($this->lng->txt("tst_show_solution_signature"), 'solution_signature', '');
929  $results_presentation->addOption($signatureOption);
930  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_suggested"), 'solution_suggested', ''));
931  $values = array();
932  if ($this->object->getShowPassDetails()) array_push($values, 'pass_details');
933  if ($this->object->getShowSolutionDetails()) array_push($values, 'solution_details');
934  if ($this->object->getShowSolutionPrintview()) array_push($values, 'solution_printview');
935  if ($this->object->getShowSolutionFeedback()) array_push($values, 'solution_feedback');
936  if ($this->object->getShowSolutionAnswersOnly()) array_push($values, 'solution_answers_only');
937  if ($this->object->getShowSolutionSignature()) array_push($values, 'solution_signature');
938  if ($this->object->getShowSolutionSuggested()) array_push($values, 'solution_suggested');
939  if ($this->object->getShowSolutionListComparison()) array_push($values, 'solution_compare');
940  if ($this->object->getShowSolutionAnwersBeforeFinish()) array_push($values, 'solution_answers_before_finish');
941  $results_presentation->setValue($values);
942  $results_presentation->setInfo($this->lng->txt("tst_results_presentation_description"));
943  if ($this->object->getAnonymity())
944  {
945  $signatureOption->setDisabled(true);
946  }
947  $form->addItem($results_presentation);
948 
949  // export settings
950  $export_settings = new ilCheckboxGroupInputGUI($this->lng->txt("tst_export_settings"), "export_settings");
951  $export_settings->addOption(new ilCheckboxOption($this->lng->txt("tst_exp_sc_short"), 'exp_sc_short', ''));
952 
953  $checkbox = new ilCheckboxOption($this->lng->txt("tst_exp_respect_shuffle"), 'exp_respect_shuffle', '');
954  $checkbox->setInfo($this->lng->txt("tst_exp_respect_shuffle_description"));
955  $export_settings->addOption($checkbox);
956 
957  $values = array();
958  if ($this->object->getExportSettingsSingleChoiceShort()) array_push($values, 'exp_sc_short');
959  if ($this->object->getExportSettingsRespectShuffle()) array_push($values, 'exp_respect_shuffle');
960  $export_settings->setValue($values);
961  $form->addItem($export_settings);
962 
963  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) $form->addCommandButton("saveScoring", $this->lng->txt("save"));
964  $errors = false;
965 
966  if ($save)
967  {
968  $errors = !$form->checkInput();
969  $form->setValuesByPost();
970  if ($errors) $checkonly = false;
971  }
972  if (!$checkonly) $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
973  return $errors;
974  }
975 
981  function propertiesObject($checkonly = FALSE)
982  {
983  global $ilAccess;
984  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
985  {
986  // allow only write access
987  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
988  $this->ctrl->redirect($this, "infoScreen");
989  }
990 
991  $save = (strcmp($this->ctrl->getCmd(), "saveProperties") == 0) ? TRUE : FALSE;
992  $total = $this->object->evalTotalPersons();
993  $this->tpl->addJavascript("./Services/JavaScript/js/Basic.js");
994 
995  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
996  $form = new ilPropertyFormGUI();
997  $form->setFormAction($this->ctrl->getFormAction($this));
998  $form->setTableWidth("100%");
999  $form->setId("test_properties");
1000 
1001  // general properties
1002  $header = new ilFormSectionHeaderGUI();
1003  $header->setTitle($this->lng->txt("tst_general_properties"));
1004  $form->addItem($header);
1005 
1006  // anonymity
1007  $anonymity = new ilCheckboxInputGUI($this->lng->txt("tst_anonymity"), "anonymity");
1008  $anonymity->setValue(1);
1009  if ($total) $anonymity->setDisabled(true);
1010  $anonymity->setChecked($this->object->getAnonymity());
1011  $anonymity->setInfo($this->lng->txt("tst_anonymity_description"));
1012  $form->addItem($anonymity);
1013 
1014  // random selection of questions
1015  $random = new ilCheckboxInputGUI($this->lng->txt("tst_random_selection"), "random_test");
1016  $random->setValue(1);
1017  if ($total) $random->setDisabled(true);
1018  $random->setChecked($this->object->isRandomTest());
1019  $random->setInfo($this->lng->txt("tst_random_test_description"));
1020  $form->addItem($random);
1021 
1022  // introduction
1023  $intro = new ilTextAreaInputGUI($this->lng->txt("tst_introduction"), "introduction");
1024  $intro->setValue($this->object->prepareTextareaOutput($this->object->getIntroduction()));
1025  $intro->setRows(10);
1026  $intro->setCols(80);
1027  $intro->setUseRte(TRUE);
1028  $intro->addPlugin("latex");
1029  $intro->addButton("latex");
1030  $intro->setRTESupport($this->object->getId(), "tst", "assessment");
1031  $intro->setRteTagSet('full');
1032  // showinfo
1033  $showinfo = new ilCheckboxInputGUI('', "showinfo");
1034  $showinfo->setValue(1);
1035  $showinfo->setChecked($this->object->getShowInfo());
1036  $showinfo->setOptionTitle($this->lng->txt("showinfo"));
1037  $showinfo->setInfo($this->lng->txt("showinfo_desc"));
1038  $intro->addSubItem($showinfo);
1039  $form->addItem($intro);
1040 
1041  // final statement
1042  $finalstatement = new ilTextAreaInputGUI($this->lng->txt("final_statement"), "finalstatement");
1043  $finalstatement->setValue($this->object->prepareTextareaOutput($this->object->getFinalStatement()));
1044  $finalstatement->setRows(10);
1045  $finalstatement->setCols(80);
1046  $finalstatement->setUseRte(TRUE);
1047  $finalstatement->addPlugin("latex");
1048  $finalstatement->addButton("latex");
1049  $finalstatement->setRTESupport($this->object->getId(), "tst", "assessment");
1050  $finalstatement->setRteTagSet('full');
1051  // show final statement
1052  $showfinal = new ilCheckboxInputGUI('', "showfinalstatement");
1053  $showfinal->setValue(1);
1054  $showfinal->setChecked($this->object->getShowFinalStatement());
1055  $showfinal->setOptionTitle($this->lng->txt("final_statement_show"));
1056  $showfinal->setInfo($this->lng->txt("final_statement_show_desc"));
1057  $finalstatement->addSubItem($showfinal);
1058  $form->addItem($finalstatement);
1059 
1060  /* Change Sn */
1061  // redirect after exam
1062  $redirect_after_exam = new ilTextInputGUI($this->lng->txt("redirect_after_exam"), "redirect_after_exam");
1063  $redirect_after_exam->setSize(100);
1064  $redirect_after_exam->setValue($this->object->getRedirectAfterExam());
1065  $redirect_after_exam->setInfo($this->lng->txt("info_redirect_after_exam"));
1066  $form->addItem($redirect_after_exam);
1067 
1068  // redirect only in kiosk mode
1069  $redirect_only_kiosk_mode = new ilCheckboxInputGUI($this->lng->txt("redirect_only_kiosk_mode"), "redirect_only_kiosk_mode");
1070  $redirect_only_kiosk_mode->setValue(1);
1071  $redirect_only_kiosk_mode->setChecked($this->object->getRedirectOnlyKioskMode());
1072  $redirect_only_kiosk_mode->setInfo($this->lng->txt("info_redirect_only_kiosk_mode"));
1073  $form->addItem($redirect_only_kiosk_mode);
1074 
1075  // redirect only in kiosk mode
1076  $exam_pdf = new ilCheckboxInputGUI($this->lng->txt("exam_pdf"), "exam_pdf");
1077  $exam_pdf->setValue(1);
1078  $exam_pdf->setChecked($this->object->getExamPdf());
1079  $exam_pdf->setInfo($this->lng->txt("info_exam_pdf"));
1080  $form->addItem($exam_pdf);
1081 
1082  /* Change Sn End */
1083  // sequence properties
1084  $seqheader = new ilFormSectionHeaderGUI();
1085  $seqheader->setTitle($this->lng->txt("tst_sequence_properties"));
1086  $form->addItem($seqheader);
1087 
1088  // postpone questions
1089  $postpone = new ilCheckboxInputGUI($this->lng->txt("tst_postpone"), "chb_postpone");
1090  $postpone->setValue(1);
1091  $postpone->setChecked($this->object->getSequenceSettings());
1092  $postpone->setInfo($this->lng->txt("tst_postpone_description"));
1093  $form->addItem($postpone);
1094 
1095  // shuffle questions
1096  $shuffle = new ilCheckboxInputGUI($this->lng->txt("tst_shuffle_questions"), "chb_shuffle_questions");
1097  $shuffle->setValue(1);
1098  $shuffle->setChecked($this->object->getShuffleQuestions());
1099  $shuffle->setInfo($this->lng->txt("tst_shuffle_questions_description"));
1100  $form->addItem($shuffle);
1101 
1102  // show list of questions
1103  $list_of_questions = new ilCheckboxInputGUI($this->lng->txt("tst_show_summary"), "list_of_questions");
1104  $list_of_questions->setOptionTitle($this->lng->txt("tst_show_summary"));
1105  $list_of_questions->setValue(1);
1106  $list_of_questions->setChecked($this->object->getListOfQuestions());
1107  $list_of_questions->setInfo($this->lng->txt("tst_show_summary_description"));
1108 
1109  $list_of_questions_options = new ilCheckboxGroupInputGUI('', "list_of_questions_options");
1110  $list_of_questions_options->addOption(new ilCheckboxOption($this->lng->txt("tst_list_of_questions_start"), 'chb_list_of_questions_start', ''));
1111  $list_of_questions_options->addOption(new ilCheckboxOption($this->lng->txt("tst_list_of_questions_end"), 'chb_list_of_questions_end', ''));
1112  $list_of_questions_options->addOption(new ilCheckboxOption($this->lng->txt("tst_list_of_questions_with_description"), 'chb_list_of_questions_with_description', ''));
1113  $values = array();
1114  if ($this->object->getListOfQuestionsStart()) array_push($values, 'chb_list_of_questions_start');
1115  if ($this->object->getListOfQuestionsEnd()) array_push($values, 'chb_list_of_questions_end');
1116  if ($this->object->getListOfQuestionsDescription()) array_push($values, 'chb_list_of_questions_with_description');
1117  $list_of_questions_options->setValue($values);
1118 
1119  $list_of_questions->addSubItem($list_of_questions_options);
1120  $form->addItem($list_of_questions);
1121 
1122  // show question marking
1123  $marking = new ilCheckboxInputGUI($this->lng->txt("question_marking"), "chb_show_marker");
1124  $marking->setValue(1);
1125  $marking->setChecked($this->object->getShowMarker());
1126  $marking->setInfo($this->lng->txt("question_marking_description"));
1127  $form->addItem($marking);
1128 
1129  // show suspend test
1130  $cancel = new ilCheckboxInputGUI($this->lng->txt("tst_show_cancel"), "chb_show_cancel");
1131  $cancel->setValue(1);
1132  $cancel->setChecked($this->object->getShowCancel());
1133  $cancel->setInfo($this->lng->txt("tst_show_cancel_description"));
1134  $form->addItem($cancel);
1135 
1136  // enable autosave
1137  $autosave = new ilCheckboxInputGUI($this->lng->txt("tst_autosave"), "chb_autosave");
1138  $autosave->setValue(1);
1139  $autosave->setChecked($this->object->getAutosave());
1140  $autosave->setInfo($this->lng->txt("tst_autosave_description"));
1141  $form->addItem($autosave);
1142 
1143  // kiosk mode properties
1144  $kioskheader = new ilFormSectionHeaderGUI();
1145  $kioskheader->setTitle($this->lng->txt("kiosk"));
1146  $form->addItem($kioskheader);
1147 
1148  // kiosk mode
1149  $kiosk = new ilCheckboxInputGUI($this->lng->txt("kiosk"), "kiosk");
1150  $kiosk->setValue(1);
1151  $kiosk->setChecked($this->object->getKioskMode());
1152  $kiosk->setInfo($this->lng->txt("kiosk_description"));
1153 
1154  // kiosk mode options
1155  $kiosktitle = new ilCheckboxGroupInputGUI($this->lng->txt("kiosk_options"), "kiosk_options");
1156  $kiosktitle->addOption(new ilCheckboxOption($this->lng->txt("kiosk_show_title"), 'kiosk_title', ''));
1157  $kiosktitle->addOption(new ilCheckboxOption($this->lng->txt("kiosk_show_participant"), 'kiosk_participant', ''));
1158  $values = array();
1159  if ($this->object->getShowKioskModeTitle()) array_push($values, 'kiosk_title');
1160  if ($this->object->getShowKioskModeParticipant()) array_push($values, 'kiosk_participant');
1161  $kiosktitle->setValue($values);
1162  $kiosktitle->setInfo($this->lng->txt("kiosk_options_desc"));
1163  $kiosk->addSubItem($kiosktitle);
1164 
1165  $form->addItem($kiosk);
1166 
1167  // session properties
1168  $sessionheader = new ilFormSectionHeaderGUI();
1169  $sessionheader->setTitle($this->lng->txt("tst_session_settings"));
1170  $form->addItem($sessionheader);
1171 
1172  // max. number of passes
1173  $nr_of_tries = new ilTextInputGUI($this->lng->txt("tst_nr_of_tries"), "nr_of_tries");
1174  $nr_of_tries->setSize(3);
1175  $nr_of_tries->setValue($this->object->getNrOfTries());
1176  $nr_of_tries->setRequired(true);
1177  $nr_of_tries->setSuffix($this->lng->txt("0_unlimited"));
1178  if ($total) $nr_of_tries->setDisabled(true);
1179  $form->addItem($nr_of_tries);
1180 
1181  // enable max. processing time
1182  $processing = new ilCheckboxInputGUI($this->lng->txt("tst_processing_time"), "chb_processing_time");
1183  $processing->setValue(1);
1184  $processing->setOptionTitle($this->lng->txt("enabled"));
1185  $processing->setChecked($this->object->getEnableProcessingTime());
1186 
1187  // max. processing time
1188  $processingtime = new ilDurationInputGUI('', 'processing_time');
1189  $ptime = $this->object->getProcessingTimeAsArray();
1190  $processingtime->setHours($ptime['hh']);
1191  $processingtime->setMinutes($ptime['mm']);
1192  $processingtime->setSeconds($ptime['ss']);
1193  $processingtime->setShowMonths(false);
1194  $processingtime->setShowDays(false);
1195  $processingtime->setShowHours(true);
1196  $processingtime->setShowMinutes(true);
1197  $processingtime->setShowSeconds(true);
1198  $processingtime->setInfo($this->lng->txt("tst_processing_time_desc"));
1199  $processing->addSubItem($processingtime);
1200 
1201  // reset max. processing time
1202  $resetprocessing = new ilCheckboxInputGUI('', "chb_reset_processing_time");
1203  $resetprocessing->setValue(1);
1204  $resetprocessing->setOptionTitle($this->lng->txt("tst_reset_processing_time"));
1205  $resetprocessing->setChecked($this->object->getResetProcessingTime());
1206  $resetprocessing->setInfo($this->lng->txt("tst_reset_processing_time_desc"));
1207  $processing->addSubItem($resetprocessing);
1208  $form->addItem($processing);
1209 
1210  // enable starting time
1211  $enablestartingtime = new ilCheckboxInputGUI($this->lng->txt("tst_starting_time"), "chb_starting_time");
1212  $enablestartingtime->setValue(1);
1213  $enablestartingtime->setOptionTitle($this->lng->txt("enabled"));
1214  $enablestartingtime->setChecked(strlen($this->object->getStartingTime()));
1215  // starting time
1216  $startingtime = new ilDateTimeInputGUI('', 'starting_time');
1217  $startingtime->setShowDate(true);
1218  $startingtime->setShowTime(true);
1219  if (strlen($this->object->getStartingTime()))
1220  {
1221  $startingtime->setDate(new ilDateTime($this->object->getStartingTime(), IL_CAL_TIMESTAMP));
1222  }
1223  else
1224  {
1225  $startingtime->setDate(new ilDateTime(time(), IL_CAL_UNIX));
1226  }
1227  $enablestartingtime->addSubItem($startingtime);
1228  if ($total) $enablestartingtime->setDisabled(true);
1229  if ($total) $startingtime->setDisabled(true);
1230  $form->addItem($enablestartingtime);
1231 
1232  // enable ending time
1233  $enableendingtime = new ilCheckboxInputGUI($this->lng->txt("tst_ending_time"), "chb_ending_time");
1234  $enableendingtime->setValue(1);
1235  $enableendingtime->setOptionTitle($this->lng->txt("enabled"));
1236  $enableendingtime->setChecked(strlen($this->object->getEndingTime()));
1237  // ending time
1238  $endingtime = new ilDateTimeInputGUI('', 'ending_time');
1239  $endingtime->setShowDate(true);
1240  $endingtime->setShowTime(true);
1241  if (strlen($this->object->getEndingTime()))
1242  {
1243  $endingtime->setDate(new ilDateTime($this->object->getEndingTime(), IL_CAL_TIMESTAMP));
1244  }
1245  else
1246  {
1247  $endingtime->setDate(new ilDateTime(time(), IL_CAL_UNIX));
1248  }
1249  $enableendingtime->addSubItem($endingtime);
1250  $form->addItem($enableendingtime);
1251 
1252  // use previous answers
1253  $prevanswers = new ilCheckboxInputGUI($this->lng->txt("tst_use_previous_answers"), "chb_use_previous_answers");
1254  $prevanswers->setValue(1);
1255  $prevanswers->setChecked($this->object->getUsePreviousAnswers());
1256  $prevanswers->setInfo($this->lng->txt("tst_use_previous_answers_description"));
1257  $form->addItem($prevanswers);
1258 
1259  // force js
1260  $forcejs = new ilCheckboxInputGUI($this->lng->txt("forcejs_short"), "forcejs");
1261  $forcejs->setValue(1);
1262  $forcejs->setChecked($this->object->getForceJS());
1263  $forcejs->setOptionTitle($this->lng->txt("forcejs"));
1264  $forcejs->setInfo($this->lng->txt("forcejs_desc"));
1265  $form->addItem($forcejs);
1266 
1267  // question title output
1268  $title_output = new ilRadioGroupInputGUI($this->lng->txt("tst_title_output"), "title_output");
1269  $title_output->addOption(new ilRadioOption($this->lng->txt("tst_title_output_full"), 0, ''));
1270  $title_output->addOption(new ilRadioOption($this->lng->txt("tst_title_output_hide_points"), 1, ''));
1271  $title_output->addOption(new ilRadioOption($this->lng->txt("tst_title_output_no_title"), 2, ''));
1272  $title_output->setValue($this->object->getTitleOutput());
1273  $title_output->setInfo($this->lng->txt("tst_title_output_description"));
1274  $form->addItem($title_output);
1275 
1276  // test password
1277  $password = new ilTextInputGUI($this->lng->txt("tst_password"), "password");
1278  $password->setSize(20);
1279  $password->setValue($this->object->getPassword());
1280  $password->setInfo($this->lng->txt("tst_password_details"));
1281  $form->addItem($password);
1282 
1283  // test serial
1284  $showserial = new ilCheckboxInputGUI($this->lng->txt("tst_serial"), "showserial");
1285  $showserial->setValue(1);
1286  $showserial->setChecked($this->object->getShowSerial());
1287  $showserial->setOptionTitle($this->lng->txt("tst_showserial"));
1288  $showserial->setInfo($this->lng->txt("tst_showserial_desc"));
1289  $form->addItem($showserial);
1290 
1291  // participants properties
1292  $restrictions = new ilFormSectionHeaderGUI();
1293  $restrictions->setTitle($this->lng->txt("tst_max_allowed_users"));
1294  $form->addItem($restrictions);
1295 
1296  $fixedparticipants = new ilCheckboxInputGUI($this->lng->txt('participants_invitation'), "fixedparticipants");
1297  $fixedparticipants->setValue(1);
1298  $fixedparticipants->setChecked($this->object->getFixedParticipants());
1299  $fixedparticipants->setOptionTitle($this->lng->txt("tst_allow_fixed_participants"));
1300  $fixedparticipants->setInfo($this->lng->txt("participants_invitation_description"));
1301  $invited_users = $this->object->getInvitedUsers();
1302  if ($total && (count($invited_users) == 0))
1303  {
1304  $fixedparticipants->setDisabled(true);
1305  }
1306  $form->addItem($fixedparticipants);
1307 
1308 
1309  // simultaneous users
1310  $simul = new ilTextInputGUI($this->lng->txt("tst_allowed_users"), "allowedUsers");
1311  $simul->setSize(3);
1312  $simul->setValue(($this->object->getAllowedUsers()) ? $this->object->getAllowedUsers() : '');
1313  $form->addItem($simul);
1314 
1315  // idle time
1316  $idle = new ilTextInputGUI($this->lng->txt("tst_allowed_users_time_gap"), "allowedUsersTimeGap");
1317  $idle->setSize(4);
1318  $idle->setSuffix($this->lng->txt("seconds"));
1319  $idle->setValue(($this->object->getAllowedUsersTimeGap()) ? $this->object->getAllowedUsersTimeGap() : '');
1320  $form->addItem($idle);
1321 
1322  // notifications
1323  $notifications = new ilFormSectionHeaderGUI();
1324  $notifications->setTitle($this->lng->txt("notifications"));
1325  $form->addItem($notifications);
1326 
1327  // mail notification
1328  $mailnotification = new ilRadioGroupInputGUI($this->lng->txt("tst_finish_notification"), "mailnotification");
1329  $mailnotification->addOption(new ilRadioOption($this->lng->txt("tst_finish_notification_no"), 0, ''));
1330  $mailnotification->addOption(new ilRadioOption($this->lng->txt("tst_finish_notification_simple"), 1, ''));
1331  $mailnotification->addOption(new ilRadioOption($this->lng->txt("tst_finish_notification_advanced"), 2, ''));
1332  $mailnotification->setValue($this->object->getMailNotification());
1333  $form->addItem($mailnotification);
1334 
1335  $mailnottype = new ilCheckboxInputGUI('', "mailnottype");
1336  $mailnottype->setValue(1);
1337  $mailnottype->setOptionTitle($this->lng->txt("mailnottype"));
1338  $mailnottype->setChecked($this->object->getMailNotificationType());
1339  $form->addItem($mailnottype);
1340 
1341  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) $form->addCommandButton("saveProperties", $this->lng->txt("save"));
1342  $errors = false;
1343 
1344  if ($save)
1345  {
1346  $errors = !$form->checkInput();
1347  $form->setValuesByPost();
1348  if ($errors) $checkonly = false;
1349  }
1350  if (!$checkonly) $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
1351  return $errors;
1352  }
1353 
1360  {
1361  if (!array_key_exists("tst_properties_confirmation", $_POST))
1362  {
1363  $hasErrors = $this->propertiesObject(true);
1364  }
1365  else
1366  {
1367  $hasErrors = false;
1368  }
1369  if (!$hasErrors)
1370  {
1371  $total = $this->object->evalTotalPersons();
1372  $randomtest_switch = false;
1373  // Check the values the user entered in the form
1374  if (!$total)
1375  {
1376  if (!array_key_exists("tst_properties_confirmation", $_POST))
1377  {
1378  if (($this->object->isRandomTest()) && (count($this->object->getRandomQuestionpools()) > 0))
1379  {
1380  if (!$_POST["random_test"])
1381  {
1382  // user tries to change from a random test with existing random question pools to a non random test
1383  $this->confirmChangeProperties(0);
1384  return;
1385  }
1386  }
1387  if ((!$this->object->isRandomTest()) && (count($this->object->questions) > 0))
1388  {
1389  if ($_POST["random_test"])
1390  {
1391  // user tries to change from a non random test with existing questions to a random test
1392  $this->confirmChangeProperties(1);
1393  return;
1394  }
1395  }
1396  }
1397 
1398  if (!strlen($_POST["random_test"]))
1399  {
1400  $random_test = 0;
1401  }
1402  else
1403  {
1404  $random_test = $_POST["random_test"];
1405  }
1406  }
1407  else
1408  {
1409  $random_test = $this->object->isRandomTest();
1410  }
1411  if ($random_test != $this->object->isRandomTest())
1412  {
1413  $randomtest_switch = true;
1414  }
1415 
1416  if (!$total)
1417  {
1418  $this->object->setAnonymity($_POST["anonymity"]);
1419  $this->object->setRandomTest($random_test);
1420  $this->object->setNrOfTries($_POST["nr_of_tries"]);
1421  if ($_POST['chb_starting_time'])
1422  {
1423  $this->object->setStartingTime(ilFormat::dateDB2timestamp($_POST['starting_time']['date'] . ' ' . $_POST['starting_time']['time']));
1424  }
1425  else
1426  {
1427  $this->object->setStartingTime('');
1428  }
1429  }
1430  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
1431  $this->object->setIntroduction($_POST["introduction"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment"));
1432  $this->object->setShowInfo(($_POST["showinfo"]) ? 1 : 0);
1433  $this->object->setFinalStatement($_POST["finalstatement"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment"));
1434  /* Change Sn */
1435  $this->object->setRedirectAfterExam($_POST["redirect_after_exam"]);
1436  $this->object->setRedirectOnlyKioskMode(($_POST["redirect_only_kiosk_mode"] ? 1 : 0));
1437  $this->object->setExamPdf(($_POST["exam_pdf"] ? 1 : 0));
1438 
1439  /* Change Sn End */
1440  $this->object->setShowFinalStatement(($_POST["showfinalstatement"]) ? 1 : 0);
1441  $this->object->setSequenceSettings(($_POST["chb_postpone"]) ? 1 : 0);
1442  $this->object->setShuffleQuestions(($_POST["chb_shuffle_questions"]) ? 1 : 0);
1443  $this->object->setListOfQuestions($_POST["list_of_questions"]);
1444  if (is_array($_POST["list_of_questions_options"]))
1445  {
1446  $this->object->setListOfQuestionsStart((in_array('chb_list_of_questions_start', $_POST["list_of_questions_options"])) ? 1 : 0);
1447  $this->object->setListOfQuestionsEnd((in_array('chb_list_of_questions_end', $_POST["list_of_questions_options"])) ? 1 : 0);
1448  $this->object->setListOfQuestionsDescription((in_array('chb_list_of_questions_with_description', $_POST["list_of_questions_options"])) ? 1 : 0);
1449  }
1450  else
1451  {
1452  $this->object->setListOfQuestionsStart(0);
1453  $this->object->setListOfQuestionsEnd(0);
1454  $this->object->setListOfQuestionsDescription(0);
1455  }
1456  $this->object->setMailNotification($_POST["mailnotification"]);
1457  $this->object->setMailNotificationType($_POST["mailnottype"]);
1458  $this->object->setShowMarker(($_POST["chb_show_marker"]) ? 1 : 0);
1459  $this->object->setShowCancel(($_POST["chb_show_cancel"]) ? 1 : 0);
1460  $this->object->setAutosave(($_POST["chb_autosave"]) ? 1 : 0);
1461  $this->object->setKioskMode(($_POST["kiosk"]) ? 1 : 0);
1462  $this->object->setShowKioskModeTitle((is_array($_POST["kiosk_options"]) && in_array('kiosk_title', $_POST["kiosk_options"])) ? 1 : 0);
1463  $this->object->setShowKioskModeParticipant((is_array($_POST["kiosk_options"]) && in_array('kiosk_participant', $_POST["kiosk_options"])) ? 1 : 0);
1464  $this->object->setEnableProcessingTime(($_POST["chb_processing_time"]) ? 1 : 0);
1465  if ($this->object->getEnableProcessingTime())
1466  {
1467  $this->object->setProcessingTime(sprintf("%02d:%02d:%02d",
1468  $_POST["processing_time"]["hh"],
1469  $_POST["processing_time"]["mm"],
1470  $_POST["processing_time"]["ss"]
1471  ));
1472  }
1473  else
1474  {
1475  $this->object->setProcessingTime('');
1476  }
1477  $this->object->setResetProcessingTime(($_POST["chb_reset_processing_time"]) ? 1 : 0);
1478  if ($_POST['chb_ending_time'])
1479  {
1480  $this->object->setEndingTime(ilFormat::dateDB2timestamp($_POST['ending_time']['date'] . ' ' . $_POST['ending_time']['time']));
1481  }
1482  else
1483  {
1484  $this->object->setEndingTime('');
1485  }
1486  $this->object->setUsePreviousAnswers(($_POST["chb_use_previous_answers"]) ? 1 : 0);
1487  $this->object->setForceJS(($_POST["forcejs"]) ? 1 : 0);
1488  $this->object->setShowSerial(($_POST["showserial"]) ? 1 : 0);
1489  $this->object->setTitleOutput($_POST["title_output"]);
1490  $this->object->setPassword($_POST["password"]);
1491  $this->object->setAllowedUsers($_POST["allowedUsers"]);
1492  $this->object->setAllowedUsersTimeGap($_POST["allowedUsersTimeGap"]);
1493 
1494  if ($this->object->isRandomTest())
1495  {
1496  $this->object->setUsePreviousAnswers(0);
1497  }
1498 
1499  $invited_users = $this->object->getInvitedUsers();
1500  if (!($total && (count($invited_users) == 0)))
1501  {
1502  $fixed_participants = 0;
1503  if (array_key_exists("fixedparticipants", $_POST))
1504  {
1505  if ($_POST["fixedparticipants"])
1506  {
1507  $fixed_participants = 1;
1508  }
1509  }
1510  $this->object->setFixedParticipants($fixed_participants);
1511  if (!$fixed_participants)
1512  {
1513  $invited_users = $this->object->getInvitedUsers();
1514  foreach ($invited_users as $user_object)
1515  {
1516  $this->object->disinviteUser($user_object["usr_id"]);
1517  }
1518  }
1519  }
1520 
1521  $this->object->saveToDb(true);
1522 
1523  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1524  if ($randomtest_switch)
1525  {
1526  if ($this->object->isRandomTest())
1527  {
1528  $this->object->removeNonRandomTestData();
1529  }
1530  else
1531  {
1532  $this->object->removeRandomTestData();
1533  }
1534  }
1535 
1536  $this->ctrl->redirect($this, 'properties');
1537  }
1538  }
1539 
1544  {
1545  $file = explode("_", $_GET["file_id"]);
1546  include_once("./Modules/File/classes/class.ilObjFile.php");
1547  $fileObj =& new ilObjFile($file[count($file) - 1], false);
1548  $fileObj->sendFile();
1549  exit;
1550  }
1551 
1555  function fullscreenObject()
1556  {
1557  include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
1558  //$page =& new ilPageObject("qpl", $_GET["pg_id"]);
1559  $page_gui =& new ilPageObjectGUI("qpl", $_GET["pg_id"]);
1560  $page_gui->showMediaFullscreen();
1561 
1562  }
1563 
1568  {
1569  include_once("./Services/COPage/classes/class.ilPageObject.php");
1570  $pg_obj =& new ilPageObject("qpl", $_GET["pg_id"]);
1571  $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
1572  exit;
1573  }
1574 
1582  function filterObject()
1583  {
1584  $this->questionBrowser();
1585  }
1586 
1595  {
1596  $this->questionBrowser();
1597  }
1598 
1606  function backObject()
1607  {
1608  $this->ctrl->redirect($this, "questions");
1609  }
1610 
1619  function createQuestionPool($name = "dummy")
1620  {
1621  global $tree;
1622  $parent_ref = $tree->getParentId($this->object->getRefId());
1623  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
1624  $qpl = new ilObjQuestionPool();
1625  $qpl->setType("qpl");
1626  $qpl->setTitle($name);
1627  $qpl->setDescription("");
1628  $qpl->create();
1629  $qpl->createReference();
1630  $qpl->putInTree($parent_ref);
1631  $qpl->setPermissions($parent_ref);
1632  $qpl->setOnline(1); // must be online to be available
1633  $qpl->saveToDb();
1634  return $qpl->getRefId();
1635  }
1636 
1640  public function randomselectObject()
1641  {
1642  global $ilUser;
1643  $this->getQuestionsSubTabs();
1644  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_random_select.html", "Modules/Test");
1645  $questionpools =& $this->object->getAvailableQuestionpools(FALSE, FALSE, FALSE, TRUE);
1646  $this->tpl->setCurrentBlock("option");
1647  $this->tpl->setVariable("VALUE_OPTION", "0");
1648  $this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("all_available_question_pools"));
1649  $this->tpl->parseCurrentBlock();
1650  foreach ($questionpools as $key => $value)
1651  {
1652  $this->tpl->setCurrentBlock("option");
1653  $this->tpl->setVariable("VALUE_OPTION", $key);
1654  $this->tpl->setVariable("TEXT_OPTION", $value["title"]);
1655  $this->tpl->parseCurrentBlock();
1656  }
1657  $this->tpl->setCurrentBlock("hidden");
1658  $this->tpl->setVariable("HIDDEN_NAME", "sel_question_types");
1659  $this->tpl->setVariable("HIDDEN_VALUE", $_POST["sel_question_types"]);
1660  $this->tpl->parseCurrentBlock();
1661  $this->tpl->setCurrentBlock("adm_content");
1662  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
1663  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_random_select_questionpool"));
1664  $this->tpl->setVariable("TXT_NR_OF_QUESTIONS", $this->lng->txt("tst_random_nr_of_questions"));
1665  $this->tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit"));
1666  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
1667  $this->tpl->parseCurrentBlock();
1668  }
1669 
1678  {
1679  $this->ctrl->redirect($this, "questions");
1680  }
1681 
1690  {
1691  $this->getQuestionsSubTabs();
1692  $question_array = $this->object->randomSelectQuestions($_POST["nr_of_questions"], $_POST["sel_qpl"]);
1693  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_random_question_offer.html", "Modules/Test");
1694  $color_class = array("tblrow1", "tblrow2");
1695  $counter = 0;
1696  $questionpools =& $this->object->getAvailableQuestionpools(true);
1697  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
1698  foreach ($question_array as $question_id)
1699  {
1700  $dataset = $this->object->getQuestionDataset($question_id);
1701  $this->tpl->setCurrentBlock("QTab");
1702  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
1703  $this->tpl->setVariable("QUESTION_TITLE", $dataset->title);
1704  $this->tpl->setVariable("QUESTION_COMMENT", $dataset->description);
1705  $this->tpl->setVariable("QUESTION_TYPE", assQuestion::_getQuestionTypeName($dataset->type_tag));
1706  $this->tpl->setVariable("QUESTION_AUTHOR", $dataset->author);
1707  $this->tpl->setVariable("QUESTION_POOL", $questionpools[$dataset->obj_fi]["title"]);
1708  $this->tpl->parseCurrentBlock();
1709  $counter++;
1710  }
1711  if (count($question_array) == 0)
1712  {
1713  $this->tpl->setCurrentBlock("Emptytable");
1714  $this->tpl->setVariable("TEXT_NO_QUESTIONS_AVAILABLE", $this->lng->txt("no_questions_available"));
1715  $this->tpl->parseCurrentBlock();
1716  }
1717  else
1718  {
1719  $this->tpl->setCurrentBlock("Selectionbuttons");
1720  $this->tpl->setVariable("BTN_YES", $this->lng->txt("random_accept_sample"));
1721  $this->tpl->setVariable("BTN_NO", $this->lng->txt("random_another_sample"));
1722  $this->tpl->parseCurrentBlock();
1723  }
1724  $chosen_questions = join($question_array, ",");
1725  $this->tpl->setCurrentBlock("adm_content");
1726  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
1727  $this->tpl->setVariable("QUESTION_TITLE", $this->lng->txt("tst_question_title"));
1728  $this->tpl->setVariable("QUESTION_COMMENT", $this->lng->txt("description"));
1729  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("tst_question_type"));
1730  $this->tpl->setVariable("QUESTION_AUTHOR", $this->lng->txt("author"));
1731  $this->tpl->setVariable("QUESTION_POOL", $this->lng->txt("qpl"));
1732  $this->tpl->setVariable("VALUE_CHOSEN_QUESTIONS", $chosen_questions);
1733  $this->tpl->setVariable("VALUE_QUESTIONPOOL_SELECTION", $_POST["sel_qpl"]);
1734  $this->tpl->setVariable("VALUE_NR_OF_QUESTIONS", $_POST["nr_of_questions"]);
1735  $this->tpl->setVariable("TEXT_QUESTION_OFFER", $this->lng->txt("tst_question_offer"));
1736  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
1737  $this->tpl->parseCurrentBlock();
1738  }
1739 
1748  {
1749  $selected_array = split(",", $_POST["chosen_questions"]);
1750  if (!count($selected_array))
1751  {
1752  ilUtil::sendInfo($this->lng->txt("tst_insert_missing_question"));
1753  }
1754  else
1755  {
1756  $total = $this->object->evalTotalPersons();
1757  if ($total)
1758  {
1759  // the test was executed previously
1760  ilUtil::sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total));
1761  }
1762  else
1763  {
1764  ilUtil::sendInfo($this->lng->txt("tst_insert_questions"));
1765  }
1766  foreach ($selected_array as $key => $value)
1767  {
1768  $this->object->insertQuestion($value);
1769  }
1770  $this->object->saveCompleteStatus();
1771  ilUtil::sendSuccess($this->lng->txt("tst_questions_inserted"), true);
1772  $this->ctrl->redirect($this, "questions");
1773  return;
1774  }
1775  }
1776 
1778  {
1779  $this->randomQuestionsObject();
1780  }
1781 
1788  function writeRandomQuestionInput($always = false)
1789  {
1790  $hasErrors = (!$always) ? $this->randomQuestionsObject(true) : false;
1791  if (!$hasErrors)
1792  {
1793  global $ilUser;
1794  $ilUser->setPref("tst_question_selection_mode_equal", ($_POST['chbQuestionSelectionMode']) ? 1 : 0);
1795  $ilUser->writePref("tst_question_selection_mode_equal", ($_POST['chbQuestionSelectionMode']) ? 1 : 0);
1796  $this->object->setRandomQuestionCount($_POST['total_questions']);
1797  if (is_array($_POST['source']['qpl']) && count(array_unique($_POST['source']['qpl'])) == count($_POST['source']['qpl']))
1798  {
1799  $data = array();
1800  include_once "./Modules/Test/classes/class.ilRandomTestData.php";
1801  foreach ($_POST['source']['qpl'] as $idx => $qpl)
1802  {
1803  array_push($data, new ilRandomTestData($_POST['source']['count'][$idx], $qpl));
1804  }
1805  $this->object->setRandomQuestionpoolData($data);
1806  }
1807  return 0;
1808  }
1809  return 1;
1810  }
1811 
1813  {
1814  if ($this->writeRandomQuestionInput() == 0)
1815  {
1816  $this->object->saveRandomQuestionCount($this->object->getRandomQuestionCount());
1817  $this->object->saveRandomQuestionpools();
1818  $this->object->saveCompleteStatus();
1819  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
1820  $this->ctrl->redirect($this, 'randomQuestions');
1821  }
1822  }
1823 
1824  function addsourceObject()
1825  {
1826  $this->writeRandomQuestionInput(true);
1827  $position = key($_POST['cmd']['addsource']);
1828  $this->object->addRandomQuestionpoolData(0, 0, $position+1);
1829  $this->randomQuestionsObject();
1830  }
1831 
1833  {
1834  $this->writeRandomQuestionInput(true);
1835  $position = key($_POST['cmd']['removesource']);
1836  $this->object->removeRandomQuestionpoolData($position);
1837  $this->randomQuestionsObject();
1838  }
1839 
1841  {
1842  global $ilUser;
1843 
1844  $total = $this->object->evalTotalPersons();
1845  $save = (strcmp($this->ctrl->getCmd(), "saveRandomQuestions") == 0) ? TRUE : FALSE;
1846 
1847  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1848  $form = new ilPropertyFormGUI();
1849  $form->setFormAction($this->ctrl->getFormAction($this, 'randomQuestions'));
1850  $form->setTitle($this->lng->txt('random_selection'));
1851  $form->setDescription($this->lng->txt('tst_select_random_questions'));
1852  $form->setMultipart(FALSE);
1853  $form->setTableWidth("100%");
1854  $form->setId("randomSelectionForm");
1855 
1856  // question selection
1857  $selection_mode = ($save) ? $_POST['chbQuestionSelectionMode'] : $ilUser->getPref("tst_question_selection_mode_equal");
1858  $question_selection = new ilCheckboxInputGUI($this->lng->txt("tst_question_selection"), "chbQuestionSelectionMode");
1859  $question_selection->setValue(1);
1860  $question_selection->setChecked($selection_mode);
1861  $question_selection->setOptionTitle($this->lng->txt('tst_question_selection_equal'));
1862  $question_selection->setInfo($this->lng->txt('tst_question_selection_description'));
1863  $question_selection->setRequired(false);
1864  $form->addItem($question_selection);
1865 
1866  // total amount of questions
1867  $total_questions = new ilNumberInputGUI($this->lng->txt('tst_total_questions'), 'total_questions');
1868  $total_questions->setValue($this->object->getRandomQuestionCount());
1869  $total_questions->setSize(3);
1870  $total_questions->setInfo($this->lng->txt('tst_total_questions_description'));
1871  $total_questions->setRequired(false);
1872  $form->addItem($total_questions);
1873 
1874  if ($total == 0)
1875  {
1876  $found_qpls = $this->object->getRandomQuestionpoolData();
1877  include_once "./Modules/Test/classes/class.ilRandomTestData.php";
1878  if (count($found_qpls) == 0)
1879  {
1880  array_push($found_qpls, new ilRandomTestData());
1881  }
1882  $available_qpl =& $this->object->getAvailableQuestionpools(TRUE, $selection_mode, FALSE, TRUE, TRUE);
1883  include_once './Modules/Test/classes/class.ilRandomTestInputGUI.php';
1884  $source = new ilRandomTestInputGUI($this->lng->txt('tst_random_questionpools'), 'source');
1885  $source->setUseEqualPointsOnly($selection_mode);
1886  $source->setRandomQuestionPools($available_qpl);
1887  $source->setUseQuestionCount((array_key_exists('total_questions', $_POST)) ? ($_POST['total_questions'] < 1) : ($this->object->getRandomQuestionCount() < 1));
1888  $source->setValues($found_qpls);
1889  $form->addItem($source);
1890  }
1891  else
1892  {
1893  $qpls = $this->object->getUsedRandomQuestionpools();
1894  include_once './Modules/Test/classes/class.ilRandomTestROInputGUI.php';
1895  $source = new ilRandomTestROInputGUI($this->lng->txt('tst_random_questionpools'), 'source');
1896  $source->setValues($qpls);
1897  $form->addItem($source);
1898  }
1899 
1900  if ($total == 0) $form->addCommandButton("saveRandomQuestions", $this->lng->txt("save"));
1901 
1902  $errors = false;
1903 
1904  if ($save)
1905  {
1906  $form->setValuesByPost();
1907  $errors = !$form->checkInput();
1908  if (!$errors)
1909  {
1910  // check total amount of questions
1911  if ($_POST['total_questions'] > 0)
1912  {
1913  $totalcount = 0;
1914  foreach ($_POST['source']['qpl'] as $idx => $qpl)
1915  {
1916  $totalcount += $available_qpl[$qpl]['count'];
1917  }
1918  if ($_POST['total_questions'] > $totalcount)
1919  {
1920  $total_questions->setAlert($this->lng->txt('msg_total_questions_too_high'));
1921  $errors = true;
1922  }
1923  }
1924  }
1925  if ($errors) $checkonly = false;
1926  }
1927 
1928  if (!$checkonly) $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
1929  return $errors;
1930  }
1931 
1933  {
1934  global $ilUser;
1935  if ($_POST["chbQuestionSelectionMode"])
1936  {
1937  $ilUser->setPref("tst_question_selection_mode_equal", 1);
1938  $ilUser->writePref("tst_question_selection_mode_equal", 1);
1939  }
1940  else
1941  {
1942  $ilUser->setPref("tst_question_selection_mode_equal", 0);
1943  $ilUser->writePref("tst_question_selection_mode_equal", 0);
1944  }
1945  $this->randomQuestionsObject();
1946  }
1947 
1949  {
1950  $this->questionBrowser();
1951  }
1952 
1961  {
1962  $qpl_ref_id = $_POST["sel_qpl"];
1963  if ((strcmp($_POST["txt_qpl"], "") == 0) && (strcmp($qpl_ref_id, "") == 0))
1964  {
1965  ilUtil::sendInfo($this->lng->txt("questionpool_not_entered"));
1966  $this->createQuestionObject();
1967  return;
1968  }
1969  else
1970  {
1971  $_SESSION["test_id"] = $this->object->getRefId();
1972  if (strcmp($_POST["txt_qpl"], "") != 0)
1973  {
1974  // create a new question pool and return the reference id
1975  $qpl_ref_id = $this->createQuestionPool($_POST["txt_qpl"]);
1976  }
1977  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPoolGUI.php";
1978  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"]);
1979  exit();
1980  }
1981  }
1982 
1991  {
1992  $this->ctrl->redirect($this, "questions");
1993  }
1994 
2003  {
2004  global $ilUser;
2005  $this->getQuestionsSubTabs();
2006  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_qpl_select.html", "Modules/Test");
2007  $questionpools =& $this->object->getAvailableQuestionpools(FALSE, FALSE, FALSE, TRUE, FALSE, "write");
2008  if (count($questionpools) == 0)
2009  {
2010  $this->tpl->setCurrentBlock("option");
2011  $this->tpl->setVariable("VALUE_QPL", "");
2012  $this->tpl->parseCurrentBlock();
2013  }
2014  else
2015  {
2016  foreach ($questionpools as $key => $value)
2017  {
2018  $this->tpl->setCurrentBlock("option");
2019  $this->tpl->setVariable("VALUE_OPTION", $key);
2020  $this->tpl->setVariable("TEXT_OPTION", $value["title"]);
2021  $this->tpl->parseCurrentBlock();
2022  }
2023  }
2024  $this->tpl->setCurrentBlock("hidden");
2025  $this->tpl->setVariable("HIDDEN_NAME", "sel_question_types");
2026  $this->tpl->setVariable("HIDDEN_VALUE", $_POST["sel_question_types"]);
2027  $this->tpl->parseCurrentBlock();
2028  $this->tpl->setCurrentBlock("adm_content");
2029  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
2030 
2031  if (count($questionpools) == 0)
2032  {
2033  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_enter_questionpool"));
2034  }
2035  else
2036  {
2037  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_select_questionpool"));
2038  }
2039  $this->tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit"));
2040  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
2041  $this->tpl->parseCurrentBlock();
2042  }
2043 
2052  {
2053  ilUtil::sendSuccess($this->lng->txt("tst_questions_removed"));
2054  $checked_questions = array();
2055  foreach ($_POST as $key => $value) {
2056  if (preg_match("/id_(\d+)/", $key, $matches)) {
2057  array_push($checked_questions, $matches[1]);
2058  }
2059  }
2060  foreach ($checked_questions as $key => $value) {
2061  $this->object->removeQuestion($value);
2062  }
2063  $this->object->saveCompleteStatus();
2064  $this->ctrl->redirect($this, "questions");
2065  }
2066 
2075  {
2076  $this->ctrl->redirect($this, "questions");
2077  }
2078 
2086  function removeQuestionsForm($checked_questions)
2087  {
2088  ilUtil::sendInfo();
2089  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_remove_questions.html", "Modules/Test");
2090  $removablequestions =& $this->object->getTestQuestions();
2091  $colors = array("tblrow1", "tblrow2");
2092  $counter = 0;
2093  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
2094  if (count($removablequestions))
2095  {
2096  foreach ($removablequestions as $data)
2097  {
2098  if (in_array($data["question_id"], $checked_questions))
2099  {
2100  $this->tpl->setCurrentBlock("row");
2101  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
2102  $this->tpl->setVariable("TXT_TITLE", $data["title"]);
2103  $this->tpl->setVariable("TXT_DESCRIPTION", $data["description"]);
2104  $this->tpl->setVariable("TXT_TYPE", assQuestion::_getQuestionTypeName($data["type_tag"]));
2105  $this->tpl->parseCurrentBlock();
2106  $counter++;
2107  }
2108  }
2109  }
2110  foreach ($checked_questions as $id)
2111  {
2112  $this->tpl->setCurrentBlock("hidden");
2113  $this->tpl->setVariable("HIDDEN_NAME", "id_$id");
2114  $this->tpl->setVariable("HIDDEN_VALUE", "1");
2115  $this->tpl->parseCurrentBlock();
2116  }
2117 
2118  $this->tpl->setCurrentBlock("adm_content");
2119  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("tst_question_title"));
2120  $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("description"));
2121  $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("tst_question_type"));
2122  $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
2123  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
2124  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
2125  $this->tpl->parseCurrentBlock();
2126  }
2127 
2136  {
2137  $this->getQuestionsSubTabs();
2138  $checked_questions = $_POST["q_id"];
2139  if (count($checked_questions) > 0)
2140  {
2141  $total = $this->object->evalTotalPersons();
2142  if ($total)
2143  {
2144  // the test was executed previously
2145  ilUtil::sendInfo(sprintf($this->lng->txt("tst_remove_questions_and_results"), $total));
2146  }
2147  else
2148  {
2149  ilUtil::sendInfo($this->lng->txt("tst_remove_questions"));
2150  }
2151  $this->removeQuestionsForm($checked_questions);
2152  return;
2153  }
2154  elseif (count($checked_questions) == 0)
2155  {
2156  ilUtil::sendInfo($this->lng->txt("tst_no_question_selected_for_removal"), true);
2157  $this->ctrl->redirect($this, "questions");
2158  }
2159  }
2160 
2165  {
2166  $_SESSION['tst_qst_move_' . $this->object->getTestId()] = $_POST['q_id'];
2167  ilUtil::sendSuccess($this->lng->txt("msg_selected_for_move"), true);
2168  $this->ctrl->redirect($this, 'questions');
2169  }
2170 
2175  {
2176  // get all questions to move
2177  $move_questions = $_SESSION['tst_qst_move_' . $this->object->getTestId()];
2178 
2179  if (count($_POST['q_id']) == 0)
2180  {
2181  ilUtil::sendFailure($this->lng->txt("no_target_selected_for_move"), true);
2182  $this->ctrl->redirect($this, 'questions');
2183  }
2184  if (count($_POST['q_id']) > 1)
2185  {
2186  ilUtil::sendFailure($this->lng->txt("too_many_targets_selected_for_move"), true);
2187  $this->ctrl->redirect($this, 'questions');
2188  }
2189  $insert_mode = 0;
2190  $this->object->moveQuestions($_SESSION['tst_qst_move_' . $this->object->getTestId()], $_POST['q_id'][0], $insert_mode);
2191  ilUtil::sendSuccess($this->lng->txt("msg_questions_moved"), true);
2192  unset($_SESSION['tst_qst_move_' . $this->object->getTestId()]);
2193  $this->ctrl->redirect($this, "questions");
2194  }
2195 
2199  public function insertQuestionsAfterObject()
2200  {
2201  // get all questions to move
2202  $move_questions = $_SESSION['tst_qst_move_' . $this->object->getTestId()];
2203  if (count($_POST['q_id']) == 0)
2204  {
2205  ilUtil::sendFailure($this->lng->txt("no_target_selected_for_move"), true);
2206  $this->ctrl->redirect($this, 'questions');
2207  }
2208  if (count($_POST['q_id']) > 1)
2209  {
2210  ilUtil::sendFailure($this->lng->txt("too_many_targets_selected_for_move"), true);
2211  $this->ctrl->redirect($this, 'questions');
2212  }
2213  $insert_mode = 1;
2214  $this->object->moveQuestions($_SESSION['tst_qst_move_' . $this->object->getTestId()], $_POST['q_id'][0], $insert_mode);
2215  ilUtil::sendSuccess($this->lng->txt("msg_questions_moved"), true);
2216  unset($_SESSION['tst_qst_move_' . $this->object->getTestId()]);
2217  $this->ctrl->redirect($this, "questions");
2218  }
2219 
2226  {
2227  $selected_array = (is_array($_POST['q_id'])) ? $_POST['q_id'] : array();
2228  if (!count($selected_array))
2229  {
2230  ilUtil::sendInfo($this->lng->txt("tst_insert_missing_question"), true);
2231  $this->ctrl->redirect($this, "browseForQuestions");
2232  }
2233  else
2234  {
2235  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
2236  $manscoring = FALSE;
2237  foreach ($selected_array as $key => $value)
2238  {
2239  $this->object->insertQuestion($value);
2240  if (!$manscoring)
2241  {
2242  $manscoring = $manscoring | assQuestion::_needsManualScoring($value);
2243  }
2244  }
2245  $this->object->saveCompleteStatus();
2246  if ($manscoring)
2247  {
2248  ilUtil::sendInfo($this->lng->txt("manscoring_hint"), TRUE);
2249  }
2250  else
2251  {
2252  ilUtil::sendSuccess($this->lng->txt("tst_questions_inserted"), TRUE);
2253  }
2254  $this->ctrl->redirect($this, "questions");
2255  return;
2256  }
2257  }
2258 
2260  {
2261  include_once "./Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php";
2262  $table_gui = new ilTestQuestionBrowserTableGUI($this, 'browseForQuestions');
2263  $table_gui->writeFilterToSession();
2264  $this->ctrl->redirect($this, "browseForQuestions");
2265  }
2266 
2268  {
2269  include_once "./Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php";
2270  $table_gui = new ilTestQuestionBrowserTableGUI($this, 'browseForQuestions');
2271  $table_gui->resetFilter();
2272  $this->ctrl->redirect($this, "browseForQuestions");
2273  }
2274 
2280  function questionBrowser()
2281  {
2282  global $ilAccess;
2283 
2284  $this->ctrl->setParameterByClass(get_class($this), "browse", "1");
2285 
2286  include_once "./Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php";
2287  $table_gui = new ilTestQuestionBrowserTableGUI($this, 'browseForQuestions', (($ilAccess->checkAccess("write", "", $this->ref_id) ? true : false)));
2288  $arrFilter = array();
2289  foreach ($table_gui->getFilterItems() as $item)
2290  {
2291  if ($item->getValue() !== false)
2292  {
2293  $arrFilter[$item->getPostVar()] = $item->getValue();
2294  }
2295  }
2296  $data = $this->object->getAvailableQuestions($arrFilter, 1);
2297  $table_gui->setData($data);
2298  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
2299  }
2300 
2301  function questionsObject()
2302  {
2303  global $ilAccess;
2304  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
2305  {
2306  // allow only write access
2307  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
2308  $this->ctrl->redirect($this, "infoScreen");
2309  }
2310  if ($_GET['browse'])
2311  {
2312  return $this->questionbrowser();
2313  }
2314 
2315  $this->getQuestionsSubTabs();
2316  if ($this->object->isRandomTest())
2317  {
2318  $this->randomQuestionsObject();
2319  return;
2320  }
2321 
2322  if ($_GET["eqid"] && $_GET["eqpl"])
2323  {
2324  ilUtil::redirect("ilias.php?baseClass=ilObjQuestionPoolGUI&ref_id=" . $_GET["eqpl"] . "&cmd=editQuestionForTest&calling_test=".$_GET["ref_id"]."&q_id=" . $_GET["eqid"]);
2325  }
2326 
2327  if ($_GET["up"] > 0)
2328  {
2329  $this->object->questionMoveUp($_GET["up"]);
2330  }
2331  if ($_GET["down"] > 0)
2332  {
2333  $this->object->questionMoveDown($_GET["down"]);
2334  }
2335 
2336  if ($_GET["add"])
2337  {
2338  $selected_array = array();
2339  array_push($selected_array, $_GET["add"]);
2340  $total = $this->object->evalTotalPersons();
2341  if ($total)
2342  {
2343  // the test was executed previously
2344  ilUtil::sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total));
2345  }
2346  else
2347  {
2348  ilUtil::sendInfo($this->lng->txt("tst_insert_questions"));
2349  }
2350  $this->insertQuestions($selected_array);
2351  return;
2352  }
2353 
2354  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_questions.html", "Modules/Test");
2355 
2356  $total = $this->object->evalTotalPersons();
2357  if (($ilAccess->checkAccess("write", "", $this->ref_id) and ($total == 0)))
2358  {
2359  global $ilUser;
2360  $lastquestiontype = $ilUser->getPref("tst_lastquestiontype");
2361  $this->tpl->setCurrentBlock("QTypes");
2362  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
2363  $question_types =& ilObjQuestionPool::_getQuestionTypes();
2364  foreach ($question_types as $trans => $data)
2365  {
2366  if ($data["type_tag"] == $lastquestiontype)
2367  {
2368  $this->tpl->setVariable("QUESTION_TYPE_SELECTED", " selected=\"selected\"");
2369  }
2370  $this->tpl->setVariable("QUESTION_TYPE_ID", $data["type_tag"]);
2371  $this->tpl->setVariable("QUESTION_TYPE", $trans);
2372  $this->tpl->parseCurrentBlock();
2373  }
2374  $this->tpl->parseCurrentBlock();
2375  }
2376 
2377  if (($ilAccess->checkAccess("write", "", $this->ref_id) and ($total == 0)))
2378  {
2379  $this->tpl->setVariable("BUTTON_INSERT_QUESTION", $this->lng->txt("tst_browse_for_questions"));
2380  $this->tpl->setVariable("TEXT_CREATE_NEW", " " . strtolower($this->lng->txt("or")) . " " . $this->lng->txt("create_new"));
2381  $this->tpl->setVariable("BUTTON_CREATE_QUESTION", $this->lng->txt("create"));
2382  $this->tpl->setVariable("TXT_OR", $this->lng->txt("or"));
2383  $this->tpl->setVariable("TEXT_RANDOM_SELECT", $this->lng->txt("random_selection"));
2384  }
2385 
2386  $this->tpl->setCurrentBlock("adm_content");
2387  include_once "./Modules/Test/classes/tables/class.ilTestQuestionsTableGUI.php";
2388  $checked_move = is_array($_SESSION['tst_qst_move_' . $this->object->getTestId()]) && (count($_SESSION['tst_qst_move_' . $this->object->getTestId()]));
2389  $table_gui = new ilTestQuestionsTableGUI($this, 'questions', (($ilAccess->checkAccess("write", "", $this->ref_id) ? true : false)), $checked_move, $total);
2390  $data = $this->object->getTestQuestions();
2391  $table_gui->setData($data);
2392  $this->tpl->setVariable('QUESTIONBROWSER', $table_gui->getHTML());
2393  $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this));
2394  $this->tpl->parseCurrentBlock();
2395  }
2396 
2397  function takenObject() {
2398  }
2399 
2408  {
2409  $this->saveMarkSchemaFormData();
2410  $this->object->mark_schema->addMarkStep();
2411  $this->marksObject();
2412  }
2413 
2422  {
2423  $this->object->mark_schema->flush();
2424  foreach ($_POST as $key => $value) {
2425  if (preg_match("/mark_short_(\d+)/", $key, $matches))
2426  {
2427  $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]"]));
2428  }
2429  }
2430  $this->object->ects_grades["A"] = $_POST["ects_grade_a"];
2431  $this->object->ects_grades["B"] = $_POST["ects_grade_b"];
2432  $this->object->ects_grades["C"] = $_POST["ects_grade_c"];
2433  $this->object->ects_grades["D"] = $_POST["ects_grade_d"];
2434  $this->object->ects_grades["E"] = $_POST["ects_grade_e"];
2435  if ($_POST["chbUseFX"])
2436  {
2437  $this->object->ects_fx = $_POST["percentFX"];
2438  }
2439  else
2440  {
2441  $this->object->ects_fx = "";
2442  }
2443  $this->object->ects_output = $_POST["chbECTS"];
2444  }
2445 
2454  {
2455  $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);
2456  $this->marksObject();
2457  }
2458 
2467  {
2468  $this->saveMarkSchemaFormData();
2469  $delete_mark_steps = array();
2470  foreach ($_POST as $key => $value) {
2471  if (preg_match("/cb_(\d+)/", $key, $matches)) {
2472  array_push($delete_mark_steps, $matches[1]);
2473  }
2474  }
2475  if (count($delete_mark_steps)) {
2476  $this->object->mark_schema->deleteMarkSteps($delete_mark_steps);
2477  } else {
2478  ilUtil::sendInfo($this->lng->txt("tst_delete_missing_mark"));
2479  }
2480  $this->marksObject();
2481  }
2482 
2491  {
2492  $this->ctrl->redirect($this, "marks");
2493  }
2494 
2502  function saveMarksObject()
2503  {
2504  $this->saveMarkSchemaFormData();
2505 
2506  $mark_check = $this->object->checkMarks();
2507  if ($mark_check !== true)
2508  {
2509  ilUtil::sendInfo($this->lng->txt($mark_check));
2510  }
2511  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)))
2512  {
2513  ilUtil::sendInfo($this->lng->txt("ects_fill_out_all_values"), true);
2514  }
2515  elseif (($_POST["ects_grade_a"] > 100) or ($_POST["ects_grade_a"] < 0))
2516  {
2517  ilUtil::sendInfo($this->lng->txt("ects_range_error_a"), true);
2518  }
2519  elseif (($_POST["ects_grade_b"] > 100) or ($_POST["ects_grade_b"] < 0))
2520  {
2521  ilUtil::sendInfo($this->lng->txt("ects_range_error_b"), true);
2522  }
2523  elseif (($_POST["ects_grade_c"] > 100) or ($_POST["ects_grade_c"] < 0))
2524  {
2525  ilUtil::sendInfo($this->lng->txt("ects_range_error_c"), true);
2526  }
2527  elseif (($_POST["ects_grade_d"] > 100) or ($_POST["ects_grade_d"] < 0))
2528  {
2529  ilUtil::sendInfo($this->lng->txt("ects_range_error_d"), true);
2530  }
2531  elseif (($_POST["ects_grade_e"] > 100) or ($_POST["ects_grade_e"] < 0))
2532  {
2533  ilUtil::sendInfo($this->lng->txt("ects_range_error_e"), true);
2534  }
2535  else
2536  {
2537  $this->object->mark_schema->saveToDb($this->object->getTestId());
2538  $this->object->saveCompleteStatus();
2539  if ($this->object->getReportingDate())
2540  {
2541  $fxpercent = "";
2542  if ($_POST["chbUseFX"])
2543  {
2544  $fxpercent = ilUtil::stripSlashes($_POST["percentFX"]);
2545  }
2546  $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"]));
2547  }
2548  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
2549  }
2550  $this->marksObject();
2551  }
2552 
2553  function marksObject()
2554  {
2555  global $ilAccess;
2556  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
2557  {
2558  // allow only write access
2559  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
2560  $this->ctrl->redirect($this, "infoScreen");
2561  }
2562 
2563  if (!$this->object->canEditMarks())
2564  {
2565  ilUtil::sendInfo($this->lng->txt("cannot_edit_marks"));
2566  }
2567 
2568  $this->object->mark_schema->sort();
2569 
2570  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_marks.html", "Modules/Test");
2571  $marks = $this->object->mark_schema->mark_steps;
2572  $rows = array("tblrow1", "tblrow2");
2573  $counter = 0;
2574  foreach ($marks as $key => $value) {
2575  $this->tpl->setCurrentBlock("markrow");
2576  $this->tpl->setVariable("MARK_SHORT", $value->getShortName());
2577  $this->tpl->setVariable("MARK_OFFICIAL", $value->getOfficialName());
2578  $this->tpl->setVariable("MARK_PERCENTAGE", sprintf("%.2f", $value->getMinimumLevel()));
2579  $this->tpl->setVariable("MARK_PASSED", strtolower($this->lng->txt("tst_mark_passed")));
2580  $this->tpl->setVariable("MARK_ID", "$key");
2581  $this->tpl->setVariable("ROW_CLASS", $rows[$counter % 2]);
2582  if ($value->getPassed()) {
2583  $this->tpl->setVariable("MARK_PASSED_CHECKED", " checked=\"checked\"");
2584  }
2585  $this->tpl->parseCurrentBlock();
2586  $counter++;
2587  }
2588  if (count($marks) == 0)
2589  {
2590  $this->tpl->setCurrentBlock("Emptyrow");
2591  $this->tpl->setVariable("EMPTY_ROW", $this->lng->txt("tst_no_marks_defined"));
2592  $this->tpl->setVariable("ROW_CLASS", $rows[$counter % 2]);
2593  $this->tpl->parseCurrentBlock();
2594  }
2595  else
2596  {
2597  if ($ilAccess->checkAccess("write", "", $this->ref_id) && $this->object->canEditMarks())
2598  {
2599  $this->tpl->setCurrentBlock("selectall");
2600  $counter++;
2601  $this->tpl->setVariable("ROW_CLASS", $rows[$counter % 2]);
2602  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
2603  $this->tpl->parseCurrentBlock();
2604  $this->tpl->setCurrentBlock("Footer");
2605  $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\"/>");
2606  $this->tpl->setVariable("BUTTON_EDIT", $this->lng->txt("edit"));
2607  $this->tpl->setVariable("BUTTON_DELETE", $this->lng->txt("delete"));
2608  $this->tpl->parseCurrentBlock();
2609  }
2610  }
2611 
2612  if ($this->object->getReportingDate())
2613  {
2614  $this->tpl->setCurrentBlock("ects");
2615  if ($this->object->ects_output)
2616  {
2617  $this->tpl->setVariable("CHECKED_ECTS", " checked=\"checked\"");
2618  }
2619  $this->tpl->setVariable("TEXT_OUTPUT_ECTS_GRADES", $this->lng->txt("ects_output_of_ects_grades"));
2620  $this->tpl->setVariable("TEXT_ALLOW_ECTS_GRADES", $this->lng->txt("ects_allow_ects_grades"));
2621  $this->tpl->setVariable("TEXT_USE_FX", $this->lng->txt("ects_use_fx_grade"));
2622  if (preg_match("/\d+/", $this->object->ects_fx))
2623  {
2624  $this->tpl->setVariable("CHECKED_FX", " checked=\"checked\"");
2625  $this->tpl->setVariable("VALUE_PERCENT_FX", sprintf("value=\"%s\" ", $this->object->ects_fx));
2626  }
2627  $this->tpl->setVariable("TEXT_PERCENT", $this->lng->txt("ects_use_fx_grade_part2"));
2628  $this->tpl->setVariable("ECTS_GRADE", $this->lng->txt("ects_grade"));
2629  $this->tpl->setVariable("PERCENTILE", $this->lng->txt("percentile"));
2630  $this->tpl->setVariable("ECTS_GRADE_A", "A - " . $this->lng->txt("ects_grade_a_short"));
2631  $this->tpl->setVariable("VALUE_GRADE_A", $this->object->ects_grades["A"]);
2632  $this->tpl->setVariable("ECTS_GRADE_B", "B - " . $this->lng->txt("ects_grade_b_short"));
2633  $this->tpl->setVariable("VALUE_GRADE_B", $this->object->ects_grades["B"]);
2634  $this->tpl->setVariable("ECTS_GRADE_C", "C - " . $this->lng->txt("ects_grade_c_short"));
2635  $this->tpl->setVariable("VALUE_GRADE_C", $this->object->ects_grades["C"]);
2636  $this->tpl->setVariable("ECTS_GRADE_D", "D - " . $this->lng->txt("ects_grade_d_short"));
2637  $this->tpl->setVariable("VALUE_GRADE_D", $this->object->ects_grades["D"]);
2638  $this->tpl->setVariable("ECTS_GRADE_E", "E - " . $this->lng->txt("ects_grade_e_short"));
2639  $this->tpl->setVariable("VALUE_GRADE_E", $this->object->ects_grades["E"]);
2640 
2641  $this->tpl->parseCurrentBlock();
2642  }
2643 
2644  $this->tpl->setCurrentBlock("adm_content");
2645  $this->tpl->setVariable("ACTION_MARKS", $this->ctrl->getFormAction($this));
2646  $this->tpl->setVariable("HEADER_SHORT", $this->lng->txt("tst_mark_short_form"));
2647  $this->tpl->setVariable("HEADER_OFFICIAL", $this->lng->txt("tst_mark_official_form"));
2648  $this->tpl->setVariable("HEADER_PERCENTAGE", $this->lng->txt("tst_mark_minimum_level"));
2649  $this->tpl->setVariable("HEADER_PASSED", $this->lng->txt("tst_mark_passed"));
2650  if ($ilAccess->checkAccess("write", "", $this->ref_id) && $this->object->canEditMarks())
2651  {
2652  $this->tpl->setVariable("BUTTON_NEW", $this->lng->txt("tst_mark_create_new_mark_step"));
2653  $this->tpl->setVariable("BUTTON_NEW_SIMPLE", $this->lng->txt("tst_mark_create_simple_mark_schema"));
2654  $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
2655  $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
2656  }
2657  $this->tpl->parseCurrentBlock();
2658  }
2659 
2668  {
2669  $this->object->removeAllTestEditings();
2670  ilUtil::sendSuccess($this->lng->txt("tst_all_user_data_deleted"), true);
2671  $this->ctrl->redirect($this, "participants");
2672  }
2673 
2682  {
2683  $active_ids = array();
2684  foreach ($_POST["chbUser"] as $active_id)
2685  {
2686  if ($this->object->getFixedParticipants())
2687  {
2688  array_push($active_ids, $this->object->getActiveIdOfUser($active_id));
2689  }
2690  else
2691  {
2692  array_push($active_ids, $active_id);
2693  }
2694  }
2695  $this->object->removeSelectedTestResults($active_ids);
2696  ilUtil::sendSuccess($this->lng->txt("tst_selected_user_data_deleted"), true);
2697  $this->ctrl->redirect($this, "participants");
2698  }
2699 
2708  {
2709  $this->ctrl->redirect($this, "participants");
2710  }
2711 
2720  {
2721  ilUtil::sendQuestion($this->lng->txt("confirm_delete_all_user_data"));
2722  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_maintenance.html", "Modules/Test");
2723 
2724  $this->tpl->setCurrentBlock("confirm_delete");
2725  $this->tpl->setVariable("BTN_CONFIRM_DELETE_ALL", $this->lng->txt("confirm"));
2726  $this->tpl->setVariable("BTN_CANCEL_DELETE_ALL", $this->lng->txt("cancel"));
2727  $this->tpl->parseCurrentBlock();
2728 
2729  $this->tpl->setCurrentBlock("adm_content");
2730  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
2731  $this->tpl->parseCurrentBlock();
2732  }
2733 
2737  public function deleteAllUserResultsObject()
2738  {
2739  ilUtil::sendQuestion($this->lng->txt("delete_all_user_data_confirmation"));
2740  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", "Modules/Test");
2741  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "participants"));
2742 
2743  // cancel/confirm button
2744  $buttons = array( "confirmDeleteAllUserResults" => $this->lng->txt("proceed"),
2745  "participants" => $this->lng->txt("cancel"));
2746  foreach ($buttons as $name => $value)
2747  {
2748  $this->tpl->setCurrentBlock("operation_btn");
2749  $this->tpl->setVariable("BTN_NAME",$name);
2750  $this->tpl->setVariable("BTN_VALUE",$value);
2751  $this->tpl->parseCurrentBlock();
2752  }
2753  }
2754 
2763  {
2764  if (count($_POST["chbUser"]) == 0)
2765  {
2766  ilUtil::sendInfo($this->lng->txt("select_one_user"), TRUE);
2767  $this->ctrl->redirect($this, "participants");
2768  }
2769  ilUtil::sendQuestion($this->lng->txt("confirm_delete_single_user_data"));
2770  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_maintenance.html", "Modules/Test");
2771 
2772  foreach ($_POST["chbUser"] as $key => $value)
2773  {
2774  $this->tpl->setCurrentBlock("hidden");
2775  $this->tpl->setVariable("USER_ID", $value);
2776  $this->tpl->parseCurrentBlock();
2777  }
2778 
2779  include_once './Services/User/classes/class.ilObjUser.php';
2780  $color_class = array("tblrow1", "tblrow2");
2781  $counter = 0;
2782  foreach ($_POST["chbUser"] as $key => $active_id)
2783  {
2784  if ($this->object->getFixedParticipants())
2785  {
2786  $user_id = $active_id;
2787  }
2788  else
2789  {
2790  $user_id = $this->object->_getUserIdFromActiveId($active_id);
2791  }
2792  $user = ilObjUser::_lookupName($user_id);
2793  $this->tpl->setCurrentBlock("row");
2794  $this->tpl->setVariable("USER_ICON", ilUtil::getImagePath("icon_usr.gif"));
2795  $this->tpl->setVariable("USER_ALT", $this->lng->txt("usr"));
2796  $this->tpl->setVariable("USER_TITLE", $this->lng->txt("usr"));
2797  if ($this->object->getAnonymity())
2798  {
2799  $this->tpl->setVariable("TXT_FIRSTNAME", "");
2800  $this->tpl->setVariable("TXT_LASTNAME", $this->lng->txt("unknown"));
2801  $this->tpl->setVariable("TXT_LOGIN", "");
2802  }
2803  else
2804  {
2805  $this->tpl->setVariable("TXT_FIRSTNAME", $user["firstname"]);
2806  if (strlen($user["lastname"]))
2807  {
2808  $this->tpl->setVariable("TXT_LASTNAME", $user["lastname"]);
2809  }
2810  else
2811  {
2812  $this->tpl->setVariable("TXT_LASTNAME", $this->lng->txt("deleted_user"));
2813  }
2814  $this->tpl->setVariable("TXT_LOGIN", ilObjUser::_lookupLogin($user_id));
2815  }
2816  $this->tpl->setVariable("ROW_CLASS", $color_class[$counter % 2]);
2817  $this->tpl->parseCurrentBlock();
2818  $counter++;
2819  }
2820  $this->tpl->setCurrentBlock("selectedusers");
2821  $this->tpl->setVariable("HEADER_TXT_FIRSTNAME", $this->lng->txt("firstname"));
2822  $this->tpl->setVariable("HEADER_TXT_LASTNAME", $this->lng->txt("lastname"));
2823  $this->tpl->setVariable("HEADER_TXT_LOGIN", $this->lng->txt("login"));
2824  $this->tpl->setVariable("BTN_CONFIRM_DELETE_SELECTED", $this->lng->txt("confirm"));
2825  $this->tpl->setVariable("BTN_CANCEL_DELETE_SELECTED", $this->lng->txt("cancel"));
2826  $this->tpl->parseCurrentBlock();
2827 
2828  $this->tpl->setCurrentBlock("adm_content");
2829  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
2830  $this->tpl->parseCurrentBlock();
2831  }
2832 
2840  function historyObject()
2841  {
2842  include_once "./Modules/Test/classes/tables/class.ilTestHistoryTableGUI.php";
2843  $table_gui = new ilTestHistoryTableGUI($this, 'history');
2844  $table_gui->setTestObject($this->object);
2845  include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
2846  $log =& ilObjAssessmentFolder::_getLog(0, time(), $this->object->getId(), TRUE);
2847  $table_gui->setData($log);
2848  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
2849  }
2850 
2854  function createObject()
2855  {
2856  global $rbacsystem;
2857  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
2858  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
2859  {
2860  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
2861  }
2862  else
2863  {
2864  $this->getTemplateFile("create", $new_type);
2865 
2866  include_once("./Modules/Test/classes/class.ilObjTest.php");
2867  $tst = new ilObjTest();
2868  $questionpools =& $tst->getAvailableQuestionpools(TRUE, FALSE, TRUE, TRUE);
2869  if (count($questionpools) == 0)
2870  {
2871  }
2872  else
2873  {
2874  foreach ($questionpools as $key => $value)
2875  {
2876  $this->tpl->setCurrentBlock("option_qpl");
2877  $this->tpl->setVariable("OPTION_VALUE", $key);
2878  $this->tpl->setVariable("TXT_OPTION", $value["title"]);
2879  if ($_POST["qpl"] == $key)
2880  {
2881  $this->tpl->setVariable("OPTION_SELECTED", " selected=\"selected\"");
2882  }
2883  $this->tpl->parseCurrentBlock();
2884  }
2885  }
2886 
2887  $defaults =& $tst->getAvailableDefaults();
2888  if (count($defaults))
2889  {
2890  foreach ($defaults as $row)
2891  {
2892  $this->tpl->setCurrentBlock("defaults_row");
2893  $this->tpl->setVariable("DEFAULTS_VALUE", $row["test_defaults_id"]);
2894  $this->tpl->setVariable("DEFAULTS_NAME", ilUtil::prepareFormOutput($row["name"]));
2895  $this->tpl->parseCurrentBlock();
2896  }
2897  $this->tpl->setCurrentBlock("defaults");
2898  $this->tpl->setVariable("TXT_DEFAULTS", $this->lng->txt("defaults"));
2899  $this->tpl->setVariable("TEXT_NO_DEFAULTS", $this->lng->txt("tst_defaults_dont_use"));
2900  $this->tpl->parseCurrentBlock();
2901  }
2902 
2903  $this->fillCloneTemplate('DUPLICATE','tst');
2904 
2905  $this->tpl->setCurrentBlock("adm_content");
2906 
2907  // fill in saved values in case of error
2908  $data = array();
2909  $data["fields"] = array();
2910  $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
2911  $data["fields"]["desc"] = $_SESSION["error_post_vars"]["Fobject"]["desc"];
2912  foreach ($data["fields"] as $key => $val)
2913  {
2914  $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
2915  $this->tpl->setVariable(strtoupper($key), $val);
2916 
2917  if ($this->prepare_output)
2918  {
2919  $this->tpl->parseCurrentBlock();
2920  }
2921  }
2922  $this->ctrl->setParameter($this, "new_type", $new_type);
2923  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, 'save'));
2924  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
2925  $this->tpl->setVariable("TXT_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool"));
2926  $this->tpl->setVariable("OPTION_SELECT_QUESTIONPOOL", $this->lng->txt("dont_use_questionpool"));
2927  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
2928  $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
2929  $this->tpl->setVariable("CMD_SUBMIT", "save");
2930  $this->tpl->setVariable("TARGET", ' target="'. ilFrameTargetInfo::_getFrame("MainContent").'" ');
2931  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
2932 
2933  $this->tpl->setVariable("TXT_IMPORT_TST", $this->lng->txt("import_tst"));
2934  $this->tpl->setVariable("TXT_TST_FILE", $this->lng->txt("tst_upload_file"));
2935  $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
2936 
2937  $this->tpl->setVariable("TYPE_IMG", ilUtil::getImagePath('icon_tst.gif'));
2938  $this->tpl->setVariable("ALT_IMG",$this->lng->txt("obj_tst"));
2939  $this->tpl->setVariable("TYPE_IMG2", ilUtil::getImagePath('icon_tst.gif'));
2940  $this->tpl->setVariable("ALT_IMG2",$this->lng->txt("obj_tst"));
2941  $this->tpl->setVariable("NEW_TYPE", $new_type);
2942  $this->tpl->parseCurrentBlock();
2943 
2944  }
2945  }
2946 
2953  {
2954  $command = $_POST["command"];
2955  if (strlen($command))
2956  {
2957  $method = $command . "Object";
2958  if (method_exists($this, $method))
2959  {
2960  $this->$method();
2961  return;
2962  }
2963  }
2964  $this->ctrl->redirect($this, "participants");
2965  }
2966 
2973  {
2974  global $ilAccess, $ilToolbar;
2975 
2976  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
2977  {
2978  // allow only write access
2979  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
2980  $this->ctrl->redirect($this, "infoScreen");
2981  }
2982 
2983  if ($this->object->getFixedParticipants())
2984  {
2985  // search button
2986  $ilToolbar->addButton($this->lng->txt("tst_search_users"),
2987  $this->ctrl->getLinkTargetByClass('ilRepositorySearchGUI','start'));
2988 
2989 
2990  $participants =& $this->object->getInvitedUsers();
2991  $rows = array();
2992  foreach ($participants as $data)
2993  {
2994  $maxpass = $this->object->_getMaxPass($data["active_id"]);
2995  if (!is_null($maxpass))
2996  {
2997  $maxpass += 1;
2998  }
2999  $access = "";
3000  if (strlen($data["active_id"]))
3001  {
3002  $last_access = $this->object->_getLastAccess($data["active_id"]);
3003  $access = ilDatePresentation::formatDate(new ilDateTime($last_access,IL_CAL_DATETIME));
3004  }
3005  $this->ctrl->setParameterByClass('iltestevaluationgui', 'active_id', $data['active_id']);
3006  array_push($rows, array(
3007  'usr_id' => $data["usr_id"],
3008  'active_id' => $data['active_id'],
3009  'login' => $data["login"],
3010  'clientip' => $data["clientip"],
3011  'name' => trim($data["lastname"] . ", " . $data["firstname"] . " " . $data["title"]),
3012  'firstname' => $data["firstname"],
3013  'lastname' => $data["lastname"],
3014  'started' => ($data["active_id"] > 0) ? 1 : 0,
3015  'finished' => ($data["test_finished"] == 1) ? 1 : 0,
3016  'access' => $access,
3017  'maxpass' => $maxpass,
3018  'result' => $this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'outParticipantsResultsOverview')
3019  ));
3020  }
3021  include_once "./Modules/Test/classes/tables/class.ilTestFixedParticipantsTableGUI.php";
3022  $table_gui = new ilTestFixedParticipantsTableGUI($this, 'participants', $this->object->getAnonymity(), count($rows));
3023  $table_gui->setData($rows);
3024  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
3025  }
3026  else
3027  {
3028  $participants =& $this->object->getTestParticipants();
3029  $rows = array();
3030  foreach ($participants as $data)
3031  {
3032  $maxpass = $this->object->_getMaxPass($data["active_id"]);
3033  if (!is_null($maxpass))
3034  {
3035  $maxpass += 1;
3036  }
3037  $access = "";
3038  if (strlen($data["active_id"]))
3039  {
3040  $last_access = $this->object->_getLastAccess($data["active_id"]);
3041  $access = ilDatePresentation::formatDate(new ilDateTime($last_access,IL_CAL_DATETIME));
3042  }
3043  $this->ctrl->setParameterByClass('iltestevaluationgui', 'active_id', $data['active_id']);
3044  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
3045  $fullname = ilObjTestAccess::_getParticipantData($data['active_id']);
3046  array_push($rows, array(
3047  'usr_id' => $data["active_id"],
3048  'active_id' => $data['active_id'],
3049  'login' => $data["login"],
3050  'name' => $fullname,
3051  'firstname' => $data["firstname"],
3052  'lastname' => $data["lastname"],
3053  'started' => ($data["active_id"] > 0) ? 1 : 0,
3054  'finished' => ($data["test_finished"] == 1) ? 1 : 0,
3055  'access' => $access,
3056  'maxpass' => $maxpass,
3057  'result' => $this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'outParticipantsResultsOverview')
3058  ));
3059  }
3060  include_once "./Modules/Test/classes/tables/class.ilTestParticipantsTableGUI.php";
3061  $table_gui = new ilTestParticipantsTableGUI($this, 'participants', $this->object->getAnonymity(), count($rows));
3062  $table_gui->setData($rows);
3063  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
3064  }
3065  }
3066 
3073  {
3074  if (count($_POST))
3075  {
3076  $_SESSION["show_user_results"] = $_POST["chbUser"];
3077  }
3078  $this->showUserResults($show_pass_details = TRUE, $show_answers = TRUE, $show_reached_points = TRUE);
3079  }
3080 
3087  {
3088  if (count($_POST))
3089  {
3090  $_SESSION["show_user_results"] = $_POST["chbUser"];
3091  }
3092  $this->showUserResults($show_pass_details = FALSE, $show_answers = TRUE);
3093  }
3094 
3101  {
3102  if (count($_POST))
3103  {
3104  $_SESSION["show_user_results"] = $_POST["chbUser"];
3105  }
3106  $this->showUserResults($show_pass_details = TRUE, $show_answers = FALSE);
3107  }
3108 
3114  function showUserResults($show_pass_details, $show_answers, $show_reached_points = FALSE)
3115  {
3116  $template = new ilTemplate("tpl.il_as_tst_participants_result_output.html", TRUE, TRUE, "Modules/Test");
3117 
3118  if (count($_SESSION["show_user_results"]) == 0)
3119  {
3120  ilUtil::sendInfo($this->lng->txt("select_one_user"), TRUE);
3121  $this->ctrl->redirect($this, "participants");
3122  }
3123 
3124  include_once "./Modules/Test/classes/class.ilTestServiceGUI.php";
3125  $serviceGUI =& new ilTestServiceGUI($this->object);
3126  $count = 0;
3127  foreach ($_SESSION["show_user_results"] as $key => $active_id)
3128  {
3129  $count++;
3130  $results = "";
3131  if ($this->object->getFixedParticipants())
3132  {
3133  $active_id = $this->object->getActiveIdOfUser($active_id);
3134  }
3135  if ($active_id > 0)
3136  {
3137  $results = $serviceGUI->getResultsOfUserOutput($active_id, $this->object->_getResultPass($active_id), $show_pass_details, $show_answers, FALSE, $show_reached_points);
3138  }
3139  if ($count < count($_SESSION["show_user_results"]))
3140  {
3141  $template->touchBlock("break");
3142  }
3143  $template->setCurrentBlock("user_result");
3144  $template->setVariable("USER_RESULT", $results);
3145  $template->parseCurrentBlock();
3146  }
3147  $template->setVariable("BACK_TEXT", $this->lng->txt("back"));
3148  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "participants"));
3149  $template->setVariable("PRINT_TEXT", $this->lng->txt("print"));
3150  $template->setVariable("PRINT_URL", "javascript:window.print();");
3151 
3152  $this->tpl->setVariable("ADM_CONTENT", $template->get());
3153  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
3154  if ($this->object->getShowSolutionAnswersOnly())
3155  {
3156  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
3157  }
3158  }
3159 
3168  {
3169  global $ilias, $ilAccess;
3170  include_once 'class.ilTestServiceGUI.php';
3171  include_once './Services/PDF/classes/class.ilHTMLToPDFTransformer.php';
3172  $serviceGUI = new ilTestServiceGUI($this->object);
3173 
3174  $htmlArray = array();
3175  $pdfHolder = array();
3176  $date = time();
3177  $this->inst_id = IL_INST_ID;
3178  $this->export_dir = $this->object->getExportDirectory();
3179 
3180  $subdir = $date."__".$this->inst_id."__"."test__PDF-Export__".$this->object->getId();
3181  include_once "./Services/Utilities/classes/class.ilUtil.php";
3182  ilUtil::makeDirParents($this->export_dir."/".$subdir);
3183 
3184 
3185  $allUsers = $this->getParticipants();
3186 
3187  if($allUsers != -1)
3188  {
3189  foreach ($allUsers as $user)
3190  {
3191 
3192  $pass = NULL;
3193  $result_array =& $this->object->getTestResult($user["active_id"], $pass);
3194  $overview = $serviceGUI->getPassDetailsOverview($result_array, $user["active_id"], $pass, "iltestevaluationgui", "outParticipantsPassDetails");
3195  $user_data = $serviceGUI->getResultsUserdata($user["active_id"], FALSE);
3196  $user_id = $this->object->_getUserIdFromActiveId($user["active_id"]);
3197 
3198  $template = new ilTemplate("tpl.il_as_tst_pass_details_overview_participants.html", TRUE, TRUE, "Modules/Test");
3199 
3200 
3201  include_once './Services/PDF/classes/class.ilHTMLToPDFTransformer.php';
3203  {
3204  $this->ctrl->setParameter($this, "pdf", "1");
3205  $template->setCurrentBlock("pdf_export");
3206  $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "outParticipantsPassDetails"));
3207  $this->ctrl->setParameter($this, "pdf", "");
3208  $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
3209  $template->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export"));
3210  $template->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")));
3211  $template->parseCurrentBlock();
3212  }
3213 
3214  if (array_key_exists("statistics", $_GET) && ($_GET["statistics"] == 1))
3215  {
3216  $template->setVariable("BACK_TEXT", $this->lng->txt("back"));
3217  $this->ctrl->setParameterByClass("ilTestEvaluationGUI", "active_id", $active_id);
3218  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilTestEvaluationGUI", "detailedEvaluation"));
3219  }
3220  else
3221  {
3222  if ($this->object->getNrOfTries() == 1)
3223  {
3224  $template->setVariable("BACK_TEXT", $this->lng->txt("back"));
3225  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "participants"));
3226  }
3227  else
3228  {
3229  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass(get_class($this), "outParticipantsResultsOverview"));
3230  $template->setVariable("BACK_TEXT", $this->lng->txt("tst_results_back_overview"));
3231  }
3232  }
3233 
3234  $template->setVariable("PRINT_TEXT", $this->lng->txt("print"));
3235  $template->setVariable("PRINT_URL", "javascript:window.print();");
3236 
3237  if ($this->object->getNrOfTries() == 1)
3238  {
3239  $statement = $this->object->getFinalStatement($user["active_id"]);
3240  $template->setVariable("USER_MARK", $statement["mark"]);
3241  if (strlen($statement["markects"]))
3242  {
3243  $template->setVariable("USER_MARK_ECTS", $statement["markects"]);
3244  }
3245  }
3246 
3247  $list_of_answers = $serviceGUI->getPassListOfAnswers($result_array, $user["active_id"], $pass, TRUE);
3248  $template->setVariable("LIST_OF_ANSWERS", $list_of_answers);
3249  $template->setVariable("TEXT_RESULTS", $this->lng->txt("tst_results"));
3250  $template->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
3251  $template->setVariable("PASS_DETAILS", $overview);
3252  $template->setVariable("USER_DETAILS", $user_data);
3253 
3254  $uname = ilObjUser::_lookupName($user_id);
3255  $unameShort = utf8_encode($this->object->userLookupFullName($user_id));
3256 
3257  if($uname['lastname']=="anonymous" && $uname['firstname']=="anonymous" && $uname['login']=="anonymous")
3258  {
3259  $uname=$unameShort;
3260  $pdfName=$uname."-".$user["active_id"]."-".$user["user_fi"]."-".$date;
3261  }
3262  else
3263  {
3264  $pdfName=iconv('UTF-8', 'UTF-8//TRANSLIT', $uname['lastname'])."_".iconv('UTF-8', 'UTF-8//TRANSLIT', $uname['firstname'])."_".$uname['login']."-".$this->object->getTitle()."-".$date;
3265  }
3266 
3267  $template->setVariable("USER_NAME", sprintf($this->lng->txt("tst_result_user_name_pass"), $pass + 1, $unameShort));
3268 
3269  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
3270  if ($this->object->getShowSolutionAnswersOnly())
3271  {
3272  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
3273  }
3274 
3275  $this->object->deliverPDFFromHTML($template->get(), $this->object->getTitle(), $this->export_dir."/".$subdir."/".$pdfName.".pdf");
3276 
3277  }
3278  ilUtil::zip($this->export_dir."/".$subdir,
3279  $this->export_dir."/".$subdir.".zip");
3280 
3281  //ilUtil::deliverFile($this->export_dir."/".$subdir.".zip", $subdir.".zip", "", true);
3282 
3283  $this->exportObject();
3284  }
3285  }
3286 
3287  //Funktion um die ID und active_id eines Teilnehmers zu beziehen
3288  function getParticipants()
3289  {
3290  global $ilDB;
3291  $participants = array();
3292 
3293  $result = $ilDB->queryF("SELECT * FROM tst_active WHERE test_fi = %s",
3294  array('integer'),
3295  array($this->object->test_id)
3296  );
3297 
3298  if ($result->numRows())
3299  {
3300  while ($row = $ilDB->fetchAssoc($result))
3301  {
3302  $user["active_id"] = $row["active_id"];
3303  $user["user_fi"] = $row["user_fi"];
3304  array_push($participants, $user);
3305  }
3306  return $participants;
3307  }
3308  else
3309  {
3310  return -1;
3311  }
3312  }
3313 
3314 
3315  //ENDE (09.02.2012)
3316 
3318  {
3319  if (is_array($_POST["chbUser"]))
3320  {
3321  foreach ($_POST["chbUser"] as $user_id)
3322  {
3323  $this->object->disinviteUser($user_id);
3324  }
3325  }
3326  else
3327  {
3328  ilUtil::sendInfo($this->lng->txt("select_one_user"), true);
3329  }
3330  $this->ctrl->redirect($this, "participants");
3331  }
3332 
3334  {
3335  if (is_array($_POST["chbUser"]))
3336  {
3337  foreach ($_POST["chbUser"] as $user_id)
3338  {
3339  $this->object->setClientIP($user_id, $_POST["clientip_".$user_id]);
3340  }
3341  }
3342  else
3343  {
3344  ilUtil::sendInfo($this->lng->txt("select_one_user"), true);
3345  }
3346  $this->ctrl->redirect($this, "participants");
3347  }
3348 
3356  function printobject()
3357  {
3358  global $ilAccess, $ilias;
3359  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
3360  {
3361  // allow only write access
3362  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3363  $this->ctrl->redirect($this, "infoScreen");
3364  }
3365  $this->getQuestionsSubTabs();
3366  $template = new ilTemplate("tpl.il_as_tst_print_test_confirm.html", TRUE, TRUE, "Modules/Test");
3367 
3368  include_once './Services/PDF/classes/class.ilHTMLToPDFTransformer.php';
3370  {
3371  $this->ctrl->setParameter($this, "pdf", "1");
3372  $template->setCurrentBlock("pdf_export");
3373  $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "print"));
3374  $this->ctrl->setParameter($this, "pdf", "");
3375  $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
3376  $template->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export"));
3377  $template->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")));
3378  $template->parseCurrentBlock();
3379  }
3380 
3381  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
3382 
3383  global $ilUser;
3384  $print_date = mktime(date("H"), date("i"), date("s"), date("m") , date("d"), date("Y"));
3385  $max_points= 0;
3386  $counter = 1;
3387 
3388  foreach ($this->object->questions as $question)
3389  {
3390  $template->setCurrentBlock("question");
3391  $question_gui = $this->object->createQuestionGUI("", $question);
3392  $template->setVariable("COUNTER_QUESTION", $counter.".");
3393  $template->setVariable("QUESTION_ID", $question_gui->object->getId());
3394  $template->setVariable("QUESTION_TITLE", ilUtil::prepareFormOutput($question_gui->object->getTitle()));
3395  if ($question_gui->object->getMaximumPoints() == 1)
3396  {
3397  $template->setVariable("QUESTION_POINTS", $question_gui->object->getMaximumPoints() . " " . $this->lng->txt("point"));
3398  }
3399  else
3400  {
3401  $template->setVariable("QUESTION_POINTS", $question_gui->object->getMaximumPoints() . " " . $this->lng->txt("points"));
3402  }
3403  $result_output = $question_gui->getSolutionOutput("", NULL, FALSE, TRUE, FALSE, $this->object->getShowSolutionFeedback());
3404  if (strlen($result_output) == 0) $result_output = $question_gui->getPreview(FALSE);
3405  $template->setVariable("SOLUTION_OUTPUT", $result_output);
3406  $template->parseCurrentBlock("question");
3407  $counter ++;
3408  $max_points += $question_gui->object->getMaximumPoints();
3409  }
3410 
3411  $template->setCurrentBlock("navigation_buttons");
3412  $template->setVariable("BUTTON_PRINT", $this->lng->txt("print"));
3413  $template->parseCurrentBlock();
3414 
3415  $template->setVariable("TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
3416  $template->setVariable("PRINT_TEST", ilUtil::prepareFormOutput($this->lng->txt("tst_print")));
3417  $template->setVariable("TXT_PRINT_DATE", ilUtil::prepareFormOutput($this->lng->txt("date")));
3418  $template->setVariable("VALUE_PRINT_DATE", ilUtil::prepareFormOutput(strftime("%c",$print_date)));
3419  $template->setVariable("TXT_MAXIMUM_POINTS", ilUtil::prepareFormOutput($this->lng->txt("tst_maximum_points")));
3420  $template->setVariable("VALUE_MAXIMUM_POINTS", ilUtil::prepareFormOutput($max_points));
3421 
3422  if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1))
3423  {
3424  $this->object->deliverPDFFromHTML($template->get(), $this->object->getTitle());
3425  }
3426  else
3427  {
3428  $this->tpl->setVariable("PRINT_CONTENT", $template->get());
3429  }
3430  }
3431 
3433  {
3434  $countusers = 0;
3435  // add users
3436  if (is_array($_POST["user"]))
3437  {
3438  $i = 0;
3439  foreach ($_POST["user"] as $user_id)
3440  {
3441  $client_ip = $_POST["client_ip"][$i];
3442  $this->object->inviteUser($user_id, $client_ip);
3443  $countusers++;
3444  $i++;
3445  }
3446  }
3447  $message = "";
3448  if ($countusers)
3449  {
3450  $message = $this->lng->txt("tst_invited_selected_users");
3451  }
3452  if (strlen($message))
3453  {
3454  ilUtil::sendInfo($message, TRUE);
3455  }
3456  else
3457  {
3458  ilUtil::sendInfo($this->lng->txt("tst_invited_nobody"), TRUE);
3459  }
3460 
3461  $this->ctrl->redirect($this, "participants");
3462  }
3463 
3469  function defaultsObject()
3470  {
3471  global $ilUser;
3472  global $ilAccess;
3473 
3474  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
3475  {
3476  // allow only write access
3477  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3478  $this->ctrl->redirect($this, "infoScreen");
3479  }
3480 
3481  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_defaults.html", "Modules/Test");
3482 
3483  $maxentries = $ilUser->getPref("hits_per_page");
3484  if ($maxentries < 1)
3485  {
3486  $maxentries = 9999;
3487  }
3488 
3489  $offset = $_GET["offset"] ? $_GET["offset"] : 0;
3490  $sortby = $_GET["sort_by"] ? $_GET["sort_by"] : "name";
3491  $sortorder = $_GET["sort_order"] ? $_GET["sort_order"] : "asc";
3492 
3493  $defaults =& $this->object->getAvailableDefaults($sortby, $sortorder);
3494  if (count($defaults) > 0)
3495  {
3496  $tablerows = array();
3497  foreach ($defaults as $row)
3498  {
3499  array_push($tablerows, array("checkbox" => "<input type=\"checkbox\" name=\"chb_defaults[]\" value=\"" . $row["test_defaults_id"] . "\"/>", "name" => $row["name"]));
3500  }
3501  $headervars = array("", "name");
3502 
3503  include_once "./Services/Table/classes/class.ilTableGUI.php";
3504  $tbl = new ilTableGUI(0, FALSE);
3505  $tbl->setTitle($this->lng->txt("tst_defaults_available"));
3506  $header_names = array(
3507  "",
3508  $this->lng->txt("title")
3509  );
3510  $tbl->setHeaderNames($header_names);
3511 
3512  $tbl->disable("sort");
3513  $tbl->disable("auto_sort");
3514  $tbl->enable("title");
3515  $tbl->enable("action");
3516  $tbl->enable("select_all");
3517  $tbl->setLimit($maxentries);
3518  $tbl->setOffset($offset);
3519  $tbl->setData($tablerows);
3520  $tbl->setMaxCount(count($tablerows));
3521  $tbl->setOrderDirection($sortorder);
3522  $tbl->setSelectAllCheckbox("chb_defaults");
3523  $tbl->setFormName("formDefaults");
3524  $tbl->addActionButton("deleteDefaults", $this->lng->txt("delete"));
3525  $tbl->addActionButton("applyDefaults", $this->lng->txt("apply"));
3526 
3527  $header_params = $this->ctrl->getParameterArray($this, "defaults");
3528  $tbl->setHeaderVars($headervars, $header_params);
3529 
3530  // footer
3531  $tbl->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
3532  // render table
3533  $tableoutput = $tbl->render();
3534  $this->tpl->setVariable("TEST_DEFAULTS_TABLE", $tableoutput);
3535  }
3536  else
3537  {
3538  $this->tpl->setVariable("TEST_DEFAULTS_TABLE", $this->lng->txt("tst_defaults_not_defined"));
3539  }
3540  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "addDefaults"));
3541  $this->tpl->setVariable("BUTTON_ADD", $this->lng->txt("add"));
3542  $this->tpl->setVariable("TEXT_DEFAULTS_OF_TEST", $this->lng->txt("tst_defaults_defaults_of_test"));
3543  }
3544 
3549  {
3550  if (count($_POST["chb_defaults"]))
3551  {
3552  foreach ($_POST["chb_defaults"] as $test_default_id)
3553  {
3554  $this->object->deleteDefaults($test_default_id);
3555  }
3556  }
3557  $this->defaultsObject();
3558  }
3559 
3564  {
3565  if (count($_POST["chb_defaults"]) == 1)
3566  {
3567  foreach ($_POST["chb_defaults"] as $test_default_id)
3568  {
3569  $result = $this->object->applyDefaults($test_default_id);
3570  if (!$result)
3571  {
3572  ilUtil::sendInfo($this->lng->txt("tst_defaults_apply_not_possible"));
3573  }
3574  else
3575  {
3576  ilUtil::sendSuccess($this->lng->txt("tst_defaults_applied"));
3577  }
3578  }
3579  }
3580  else
3581  {
3582  ilUtil::sendInfo($this->lng->txt("tst_defaults_apply_select_one"));
3583  }
3584  $this->defaultsObject();
3585  }
3586 
3591  {
3592  if (strlen($_POST["name"]) > 0)
3593  {
3594  $this->object->addDefaults($_POST['name']);
3595  }
3596  else
3597  {
3598  ilUtil::sendInfo($this->lng->txt("tst_defaults_enter_name"));
3599  }
3600  $this->defaultsObject();
3601  }
3602 
3608  function infoScreenObject()
3609  {
3610  $this->ctrl->setCmd("showSummary");
3611  $this->ctrl->setCmdClass("ilinfoscreengui");
3612  $this->infoScreen();
3613  }
3614 
3616  {
3617  $this->ctrl->setCmd("showSummary");
3618  $this->ctrl->setCmdClass("ilinfoscreengui");
3619  $this->infoScreen($_SESSION["lock"]);
3620  }
3621 
3625  function infoScreen($session_lock = "")
3626  {
3627  global $ilAccess;
3628  global $ilUser;
3629 
3630  // Disabled
3631  /*
3632  if ($_GET['crs_show_result'])
3633  {
3634  $this->object->hideCorrectAnsweredQuestions();
3635  }
3636  else
3637  {
3638  */
3639  if ($this->object->getTestSequence()->hasHiddenQuestions())
3640  {
3641  $this->object->getTestSequence()->clearHiddenQuestions();
3642  $this->object->getTestSequence()->saveToDb();
3643  }
3644  //}
3645 
3646  if (!$ilAccess->checkAccess("visible", "", $this->ref_id))
3647  {
3648  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
3649  }
3650 
3651  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
3652  $info = new ilInfoScreenGUI($this);
3653 
3654  $seq = $this->object->getTestSession()->getLastSequence();
3655 
3656  include_once "./Modules/Test/classes/class.ilTestOutputGUI.php";
3657  $output_gui =& new ilTestOutputGUI($this->object);
3658  $this->ctrl->setParameter($output_gui, "sequence", $seq);
3659  $info->setFormAction($this->ctrl->getFormAction($output_gui));
3660  if (strlen($session_lock))
3661  {
3662  $info->addHiddenElement("lock", $session_lock);
3663  }
3664  else
3665  {
3666  $info->addHiddenElement("lock", md5($_COOKIE['PHPSESSID'] . time()));
3667  }
3668  $online_access = false;
3669  if ($this->object->getFixedParticipants())
3670  {
3671  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
3672  $online_access_result = ilObjTestAccess::_lookupOnlineTestAccess($this->object->getId(), $ilUser->getId());
3673  if ($online_access_result === true)
3674  {
3675  $online_access = true;
3676  }
3677  else
3678  {
3679  ilUtil::sendInfo($online_access_result);
3680  }
3681  }
3682  if ($this->object->isComplete())
3683  {
3684  if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id))
3685  {
3686  $executable = $this->object->isExecutable($ilUser->getId(), $allowPassIncrease = TRUE);
3687  if ($executable["executable"])
3688  {
3689  if ($this->object->getTestSession()->getActiveId() > 0)
3690  {
3691  // resume test
3692  $resume_text = $this->lng->txt("tst_resume_test");
3693  if (($seq < 1) || ($seq == $this->object->getTestSequence()->getFirstSequence()))
3694  {
3695  $resume_text = $this->object->getStartTestLabel($this->object->getTestSession()->getActiveId());
3696  }
3697  // Disabled
3698  #if(!$_GET['crs_show_result'] or $this->object->getTestSequence()->getFirstSequence())
3699  {
3700  $info->addFormButton("resume", $resume_text);
3701  }
3702  }
3703  else
3704  {
3705  // start new test
3706  $info->addFormButton("start", $this->object->getStartTestLabel($this->object->getTestSession()->getActiveId()));
3707  }
3708  }
3709  else
3710  {
3711  ilUtil::sendInfo($executable["errormessage"]);
3712  }
3713  if ($this->object->getTestSession()->getActiveId() > 0)
3714  {
3715  // test results button
3716  if ($this->object->canShowTestResults($ilUser->getId()))
3717  {
3718  $info->addFormButton("outUserResultsOverview", $this->lng->txt("tst_show_results"));
3719  }
3720  }
3721  }
3722  if ($this->object->getTestSession()->getActiveId() > 0)
3723  {
3724  if ($this->object->getShowSolutionPrintview())
3725  {
3726  $info->addFormButton("outUserListOfAnswerPasses", $this->lng->txt("tst_list_of_answers_show"));
3727  }
3728  }
3729  }
3730 
3731  if ($this->object->getShowInfo())
3732  {
3733  $info->enablePrivateNotes();
3734 
3735  }
3736  if (strlen($this->object->getIntroduction()))
3737  {
3738  $info->addSection($this->lng->txt("tst_introduction"));
3739  $info->addProperty("", $this->object->prepareTextareaOutput($this->object->getIntroduction()));
3740  }
3741 
3742  $info->addSection($this->lng->txt("tst_general_properties"));
3743  if ($this->object->getShowInfo())
3744  {
3745  $info->addProperty($this->lng->txt("author"), $this->object->getAuthor());
3746  $info->addProperty($this->lng->txt("title"), $this->object->getTitle());
3747  }
3748  if ($this->object->isComplete())
3749  {
3750  if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id))
3751  {
3752  if ($this->object->getShowInfo() || !$this->object->getForceJS())
3753  {
3754  // use javascript
3755  $checked_javascript = false;
3756  if ($this->object->getJavaScriptOutput())
3757  {
3758  $checked_javascript = true;
3759  }
3760  if ($this->object->getForceJS())
3761  {
3762  $info->addProperty($this->lng->txt("tst_test_output"), $this->lng->txt("tst_use_javascript"));
3763  }
3764  else
3765  {
3766  $info->addPropertyCheckbox($this->lng->txt("tst_test_output"), "chb_javascript", 1, $this->lng->txt("tst_use_javascript"), $checked_javascript);
3767  }
3768  }
3769  // hide previous results
3770  if (!$this->object->isRandomTest())
3771  {
3772  if ($this->object->getNrOfTries() != 1)
3773  {
3774  if ($this->object->getUsePreviousAnswers() == 0)
3775  {
3776  if ($this->object->getShowInfo())
3777  {
3778  $info->addProperty($this->lng->txt("tst_use_previous_answers"), $this->lng->txt("tst_dont_use_previous_answers"));
3779  }
3780  }
3781  else
3782  {
3783  $use_previous_answers = FALSE;
3784  if ($ilUser->prefs["tst_use_previous_answers"])
3785  {
3786  $checked_previous_answers = TRUE;
3787  }
3788  $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);
3789  }
3790  }
3791  }
3792  if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
3793  {
3794  $info->addPropertyTextinput($this->lng->txt("enter_anonymous_code"), "anonymous_id", "", 8, "setAnonymousId", $this->lng->txt("submit"));
3795  }
3796  }
3797  }
3798 
3799  if ($this->object->getShowInfo())
3800  {
3801  $info->addSection($this->lng->txt("tst_sequence_properties"));
3802  $info->addProperty($this->lng->txt("tst_sequence"), $this->lng->txt(($this->object->getSequenceSettings() == TEST_FIXED_SEQUENCE)? "tst_sequence_fixed":"tst_sequence_postpone"));
3803 
3804  $info->addSection($this->lng->txt("tst_heading_scoring"));
3805  $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"));
3806  $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"));
3807  if ($this->object->isRandomTest())
3808  {
3809  $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"));
3810  }
3811 
3812  $info->addSection($this->lng->txt("tst_score_reporting"));
3813  $score_reporting_text = "";
3814  switch ($this->object->getScoreReporting())
3815  {
3816  case REPORT_AFTER_TEST:
3817  $score_reporting_text = $this->lng->txt("tst_report_after_test");
3818  break;
3819  case REPORT_ALWAYS:
3820  $score_reporting_text = $this->lng->txt("tst_report_after_first_question");
3821  break;
3822  case REPORT_AFTER_DATE:
3823  $score_reporting_text = $this->lng->txt("tst_report_after_date");
3824  break;
3825  case 4:
3826  $score_reporting_text = $this->lng->txt("tst_report_after_never");
3827  break;
3828  }
3829  $info->addProperty($this->lng->txt("tst_score_reporting"), $score_reporting_text);
3830  $reporting_date = $this->object->getReportingDate();
3831  if ($reporting_date)
3832  {
3833  #preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $reporting_date, $matches);
3834  #$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]));
3835  #$info->addProperty($this->lng->txt("tst_score_reporting_date"), $txt_reporting_date);
3836  $info->addProperty($this->lng->txt('tst_score_reporting_date'),
3838  }
3839 
3840  $info->addSection($this->lng->txt("tst_session_settings"));
3841  $info->addProperty($this->lng->txt("tst_nr_of_tries"), ($this->object->getNrOfTries() == 0)?$this->lng->txt("unlimited"):$this->object->getNrOfTries());
3842  if ($this->object->getNrOfTries() != 1)
3843  {
3844  $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());
3845  }
3846 
3847  if ($this->object->getEnableProcessingTime())
3848  {
3849  $info->addProperty($this->lng->txt("tst_processing_time"), $this->object->getProcessingTime());
3850  }
3851  if (strlen($this->object->getAllowedUsers()) && ($this->object->getAllowedUsersTimeGap()))
3852  {
3853  $info->addProperty($this->lng->txt("tst_allowed_users"), $this->object->getAllowedUsers());
3854  }
3855 
3856  $starting_time = $this->object->getStartingTime();
3857  if ($starting_time)
3858  {
3859  $info->addProperty($this->lng->txt("tst_starting_time"),
3861  }
3862  $ending_time = $this->object->getEndingTime();
3863  if ($ending_time)
3864  {
3865  $info->addProperty($this->lng->txt("tst_ending_time"),
3867  }
3868  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
3869  // forward the command
3870 
3871  if($_GET['crs_show_result'] and !$this->object->getTestSequence()->getFirstSequence())
3872  {
3873  #ilUtil::sendInfo($this->lng->txt('crs_all_questions_answered_successfully'));
3874  }
3875  }
3876 
3877  $this->ctrl->forwardCommand($info);
3878  }
3879 
3880  function addLocatorItems()
3881  {
3882  global $ilLocator;
3883  switch ($this->ctrl->getCmd())
3884  {
3885  case "run":
3886  case "infoScreen":
3887  case "redirectToInfoScreen":
3888  case "start":
3889  case "resume":
3890  case "previous":
3891  case "next":
3892  case "summary":
3893  case "finishTest":
3894  case "outCorrectSolution":
3895  case "passDetails":
3896  case "showAnswersOfUser":
3897  case "outUserResultsOverview":
3898  case "backFromSummary":
3899  case "show_answers":
3900  case "setsolved":
3901  case "resetsolved":
3902  case "outTestSummary":
3903  case "outQuestionSummary":
3904  case "gotoQuestion":
3905  case "selectImagemapRegion":
3906  case "confirmSubmitAnswers":
3907  case "finalSubmission":
3908  case "postpone":
3909  case "redirectQuestion":
3910  case "outUserPassDetails":
3911  case "checkPassword":
3912  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"), "", $_GET["ref_id"]);
3913  break;
3914  case "eval_stat":
3915  case "evalAllUsers":
3916  case "evalUserDetail":
3917  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "eval_stat"), "", $_GET["ref_id"]);
3918  break;
3919  case "create":
3920  case "save":
3921  case "cancel":
3922  case "importFile":
3923  case "cloneAll":
3924  case "importVerifiedFile":
3925  case "cancelImport":
3926  break;
3927  default:
3928  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
3929  break;
3930  }
3931  }
3932 
3933  function getBrowseForQuestionsTab(&$tabs_gui)
3934  {
3935  global $ilAccess;
3936  if ($ilAccess->checkAccess("write", "", $this->ref_id))
3937  {
3938  // edit page
3939  $tabs_gui->setBackTarget($this->lng->txt("backtocallingtest"), $this->ctrl->getLinkTarget($this, "questions"));
3940  $tabs_gui->addTarget("tst_browse_for_questions",
3941  $this->ctrl->getLinkTarget($this, "browseForQuestions"),
3942  array("browseForQuestions", "filter", "resetFilter", "resetTextFilter", "insertQuestions"),
3943  "", "", TRUE
3944  );
3945  }
3946  }
3947 
3948  function getRandomQuestionsTab(&$tabs_gui)
3949  {
3950  global $ilAccess;
3951  if ($ilAccess->checkAccess("write", "", $this->ref_id))
3952  {
3953  // edit page
3954  $tabs_gui->setBackTarget($this->lng->txt("backtocallingtest"), $this->ctrl->getLinkTarget($this, "questions"));
3955  $tabs_gui->addTarget("random_selection",
3956  $this->ctrl->getLinkTarget($this, "randomQuestions"),
3957  array("randomQuestions"),
3958  "", ""
3959  );
3960  }
3961  }
3962 
3963  function statisticsObject()
3964  {
3965  }
3966 
3971  {
3972  include_once "./Services/Certificate/classes/class.ilCertificateGUI.php";
3973  include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
3974  $output_gui = new ilCertificateGUI(new ilTestCertificateAdapter($this->object));
3975  $output_gui->certificateEditor();
3976  }
3977 
3979  {
3980  global $ilTabs;
3981 
3982  // questions subtab
3983  $ilTabs->addSubTabTarget("edit_test_questions",
3984  $this->ctrl->getLinkTarget($this,'questions'),
3985  array("questions", "browseForQuestions", "questionBrowser", "createQuestion",
3986  "randomselect", "filter", "resetFilter", "insertQuestions",
3987  "back", "createRandomSelection", "cancelRandomSelect",
3988  "insertRandomSelection", "removeQuestions", "moveQuestions",
3989  "insertQuestionsBefore", "insertQuestionsAfter", "confirmRemoveQuestions",
3990  "cancelRemoveQuestions", "executeCreateQuestion", "cancelCreateQuestion",
3991  "addQuestionpool", "saveRandomQuestions", "saveQuestionSelectionMode"),
3992  "");
3993 
3994  // print view subtab
3995  if (!$this->object->isRandomTest())
3996  {
3997  $ilTabs->addSubTabTarget("print_view",
3998  $this->ctrl->getLinkTarget($this,'print'),
3999  "print", "");
4000  }
4001 
4002  }
4003 
4005  {
4006  global $ilTabs;
4007 
4008  // user results subtab
4009  $ilTabs->addSubTabTarget("eval_all_users",
4010  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "outEvaluation"),
4011  array("outEvaluation", "detailedEvaluation", "exportEvaluation", "evalUserDetail", "passDetails",
4012  "outStatisticsResultsOverview", "statisticsPassDetails")
4013  , "");
4014 
4015  // aggregated results subtab
4016  $ilTabs->addSubTabTarget("tst_results_aggregated",
4017  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "eval_a"),
4018  array("eval_a"),
4019  "", "");
4020 
4021  // question export
4022  $ilTabs->addSubTabTarget("tst_single_results",
4023  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "singleResults"),
4024  array("singleResults"),
4025  "", "");
4026  }
4027 
4028  protected function getAdministrationSubTabs()
4029  {
4030  global $ilTabs, $ilias;
4031 
4032  ############ scoreQuestion ##############
4033  $ilTabs->addSubTabTarget("tst_regrade_questions",
4034  $this->ctrl->getLinkTargetByClass("iltestnewscoringgui", "scoreQuestion"),
4035  array("scoreQuestion"),
4036  "", "");
4037  #####
4038 
4039  $ilTabs->addSubTabTarget("timing",
4040  $this->ctrl->getLinkTarget($this,'timing'),
4041  array("timing"),
4042  "");
4043 
4044  $ilTabs->addSubTabTarget("recalculateResults",
4045  $this->ctrl->getLinkTarget($this,'recalculate'),
4046  array("recalculate"),
4047  "");
4048 
4049  $ilTabs->addSubTabTarget("randomfill",
4050  $this->ctrl->getLinkTarget($this,'randomfill'),
4051  array("randomfill"),
4052  "");
4053  }
4054 
4056  {
4057  global $ilTabs, $ilias;
4058 
4059  // general subtab
4060  $force_active = ($this->ctrl->getCmd() == "")
4061  ? true
4062  : false;
4063  $ilTabs->addSubTabTarget("general",
4064  $this->ctrl->getLinkTarget($this,'properties'),
4065  array("properties", "saveProperties", "cancelProperties"),
4066  array("", "ilobjtestgui", "ilcertificategui"),
4067  "", $force_active);
4068 
4069  // scoring subtab
4070  $ilTabs->addSubTabTarget(
4071  "scoring",
4072  $this->ctrl->getLinkTarget($this,'scoring'),
4073  array("scoring"),
4074  array("", "ilobjtestgui", "ilcertificategui")
4075  );
4076 
4077  // mark schema subtab
4078  $ilTabs->addSubTabTarget(
4079  "mark_schema",
4080  $this->ctrl->getLinkTarget($this,'marks'),
4081  array("marks", "addMarkStep", "deleteMarkSteps", "addSimpleMarkSchema",
4082  "saveMarks", "cancelMarks"),
4083  array("", "ilobjtestgui", "ilcertificategui")
4084  );
4085 
4086  include_once './Services/PDF/classes/class.ilHTMLToPDFTransformer.php';
4088  {
4089  // certificate subtab
4090  $ilTabs->addSubTabTarget(
4091  "certificate",
4092  $this->ctrl->getLinkTarget($this,'certificate'),
4093  array("certificate", "certificateEditor", "certificateRemoveBackground", "certificateSave",
4094  "certificatePreview", "certificateDelete", "certificateUpload", "certificateImport"),
4095  array("", "ilobjtestgui", "ilcertificategui")
4096  );
4097  }
4098 
4099  // defaults subtab
4100  $ilTabs->addSubTabTarget(
4101  "defaults",
4102  $this->ctrl->getLinkTarget($this, "defaults"),
4103  array("defaults", "deleteDefaults", "addDefaults", "applyDefaults"),
4104  array("", "ilobjtestgui", "ilcertificategui")
4105  );
4106  }
4107 
4108  private function formTiming()
4109  {
4110  global $ilAccess;
4111 
4112  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
4113  $form = new ilPropertyFormGUI();
4114  $form->setFormAction($this->ctrl->getFormAction($this));
4115  $form->setTableWidth("100%");
4116  $form->setId("tst_change_workingtime");
4117 
4118  // general properties
4119  $header = new ilFormSectionHeaderGUI();
4120  $header->setTitle($this->lng->txt("tst_change_workingtime"));
4121  $form->addItem($header);
4122 
4123  // test users
4124  $participantslist = new ilSelectInputGUI($this->lng->txt('participants'), "participant");
4125  $participants =& $this->object->getTestParticipants();
4126  $times = $this->object->getStartingTimeOfParticipants();
4127  $addons = $this->object->getTimeExtensionsOfParticipants();
4128  $options = array(
4129  '' => $this->lng->txt('please_select'),
4130  '0' => $this->lng->txt('all_participants')
4131  );
4132  foreach ($participants as $participant)
4133  {
4134  $started = "";
4135  if ($times[$participant['active_id']])
4136  {
4137  $started = ", ".$this->lng->txt('tst_started').': '.ilDatePresentation::formatDate(new ilDateTime($times[$participant['active_id']], IL_CAL_DATETIME));
4138  }
4139  if ($addons[$participant['active_id']] > 0) $started .= ", " . $this->lng->txt('extratime') . ': ' . $addons[$participant['active_id']] . ' ' . $this->lng->txt('minutes');
4140  $options[$participant['active_id']] = $participant['login'] . ' (' . $participant['lastname'] . ', ' . $participant['firstname'] . ')'.$started;
4141  }
4142  $participantslist->setRequired(true);
4143  $participantslist->setOptions($options);
4144  $form->addItem($participantslist);
4145 
4146  // extra time
4147  $extratime = new ilNumberInputGUI($this->lng->txt("extratime"), "extratime");
4148  $extratime->setRequired(true);
4149  $extratime->setMinValue(0);
4150  $extratime->setMinvalueShouldBeGreater(true);
4151  $extratime->setSuffix($this->lng->txt('minutes'));
4152  $extratime->setSize(5);
4153  $form->addItem($extratime);
4154 
4155  if (is_array($_POST) && strlen($_POST['cmd']['timing'])) $form->setValuesByArray($_POST);
4156 
4157  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) $form->addCommandButton("timing", $this->lng->txt("save"));
4158  return $form;
4159  }
4160 
4161  /*
4162  * list all export files
4163  */
4164  function timingObject()
4165  {
4166  global $tree;
4167  global $ilAccess;
4168  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
4169  {
4170  // allow only write access
4171  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
4172  $this->ctrl->redirect($this, "infoScreen");
4173  }
4174 
4175  if ($this->object->getProcessingTimeInSeconds() > 0 && $this->object->getNrOfTries() == 1)
4176  {
4177  $form = $this->formTiming();
4178  if (count($_POST) && $form->checkInput())
4179  {
4180  $res = $this->object->addExtraTime($form->getInput('participant'), $form->getInput('extratime'));
4181  ilUtil::sendSuccess(sprintf($this->lng->txt('tst_extratime_added'), $form->getInput('extratime')), true);
4182  }
4183  else
4184  {
4185  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
4186  }
4187  }
4188  else
4189  {
4190  ilUtil::sendInfo($this->lng->txt("tst_extratime_notavailable"));
4191  }
4192  }
4193 
4194  private function formRecalculate()
4195  {
4196  global $ilAccess;
4197 
4198  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
4199  $form = new ilPropertyFormGUI();
4200  $form->setFormAction($this->ctrl->getFormAction($this));
4201  $form->setTableWidth("100%");
4202  $form->setId("tst_recalculate");
4203 
4204  // scoring properties
4205  $header = new ilFormSectionHeaderGUI();
4206  $header->setTitle($this->lng->txt("scoring"));
4207  $form->addItem($header);
4208 
4209  // scoring system
4210  $count_system = new ilRadioGroupInputGUI($this->lng->txt("tst_text_count_system"), "count_system");
4211  $count_system->addOption(new ilRadioOption($this->lng->txt("tst_count_partial_solutions"), 0, ''));
4212  $count_system->addOption(new ilRadioOption($this->lng->txt("tst_count_correct_solutions"), 1, ''));
4213  $count_system->setValue($this->object->getCountSystem());
4214  $count_system->setInfo($this->lng->txt("tst_count_system_description"));
4215  if ($total)
4216  {
4217  $count_system->setDisabled(true);
4218  }
4219  $form->addItem($count_system);
4220 
4221  // mc questions
4222  $mc_scoring = new ilRadioGroupInputGUI($this->lng->txt("tst_score_mcmr_questions"), "mc_scoring");
4223  $mc_scoring->addOption(new ilRadioOption($this->lng->txt("tst_score_mcmr_zero_points_when_unanswered"), 0, ''));
4224  $mc_scoring->addOption(new ilRadioOption($this->lng->txt("tst_score_mcmr_use_scoring_system"), 1, ''));
4225  $mc_scoring->setValue($this->object->getMCScoring());
4226  $mc_scoring->setInfo($this->lng->txt("tst_score_mcmr_questions_description"));
4227  if ($total)
4228  {
4229  $mc_scoring->setDisabled(true);
4230  }
4231  $form->addItem($mc_scoring);
4232 
4233  // score cutting
4234  $score_cutting = new ilRadioGroupInputGUI($this->lng->txt("tst_score_cutting"), "score_cutting");
4235  $score_cutting->addOption(new ilRadioOption($this->lng->txt("tst_score_cut_question"), 0, ''));
4236  $score_cutting->addOption(new ilRadioOption($this->lng->txt("tst_score_cut_test"), 1, ''));
4237  $score_cutting->setValue($this->object->getScoreCutting());
4238  $score_cutting->setInfo($this->lng->txt("tst_score_cutting_description"));
4239  if ($total)
4240  {
4241  $score_cutting->setDisabled(true);
4242  }
4243  $form->addItem($score_cutting);
4244 
4245  // pass scoring
4246  $pass_scoring = new ilRadioGroupInputGUI($this->lng->txt("tst_pass_scoring"), "pass_scoring");
4247  $pass_scoring->addOption(new ilRadioOption($this->lng->txt("tst_pass_last_pass"), 0, ''));
4248  $pass_scoring->addOption(new ilRadioOption($this->lng->txt("tst_pass_best_pass"), 1, ''));
4249  $pass_scoring->setValue($this->object->getPassScoring());
4250  $pass_scoring->setInfo($this->lng->txt("tst_pass_scoring_description"));
4251  if ($total)
4252  {
4253  $pass_scoring->setDisabled(true);
4254  }
4255  $form->addItem($pass_scoring);
4256 
4257  if (is_array($_POST) && strlen($_POST['cmd']['recalculate'])) $form->setValuesByArray($_POST);
4258 
4259  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) $form->addCommandButton("recalculate", $this->lng->txt("recalculate"));
4260  return $form;
4261  }
4262 
4263  /*
4264  * Recalculate test results
4265  */
4267  {
4268  global $tree;
4269  global $ilAccess;
4270  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
4271  {
4272  // allow only write access
4273  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
4274  $this->ctrl->redirect($this, "infoScreen");
4275  }
4276 
4277  $form = $this->formRecalculate();
4278  if (count($_POST) && $form->checkInput())
4279  {
4280  $this->object->setCountSystem($_POST["count_system"]);
4281  $this->object->setMCScoring($_POST["mc_scoring"]);
4282  $this->object->setScoreCutting($_POST["score_cutting"]);
4283  $this->object->setPassScoring($_POST["pass_scoring"]);
4284  $this->object->saveToDb();
4285  $this->object->recalculateSolutions();
4286  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
4287  ilUtil::sendSuccess($this->lng->txt('tst_recalculated_solutions'));
4288  }
4289  else
4290  {
4291  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
4292  }
4293  }
4294 
4295  private function formRandomfill()
4296  {
4297  global $ilAccess;
4298 
4299  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
4300  $form = new ilPropertyFormGUI();
4301  $form->setFormAction($this->ctrl->getFormAction($this));
4302  $form->setTableWidth("100%");
4303  $form->setId("tst_randomfill");
4304 
4305  $header = new ilFormSectionHeaderGUI();
4306  $header->setTitle($this->lng->txt("randomfill"));
4307  $form->addItem($header);
4308 
4309  $randomfill = new ilNumberInputGUI($this->lng->txt("number_of_participants"), "participants");
4310  $randomfill->setRequired(true);
4311  $randomfill->setMinValue(0);
4312  $randomfill->setMinvalueShouldBeGreater(true);
4313  $randomfill->setSize(5);
4314  $randomfill->setInfo($this->lng->txt('number_of_participants_info'));
4315  $form->addItem($randomfill);
4316 
4317  if (is_array($_POST) && strlen($_POST['cmd']['randomfill'])) $form->setValuesByArray($_POST);
4318 
4319  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) $form->addCommandButton("randomfill", $this->lng->txt("fill_with_data"));
4320  return $form;
4321  }
4322 
4323  /*
4324  * Fill the test with random results
4325  */
4326  function randomfillObject()
4327  {
4328  global $tree;
4329  global $ilAccess;
4330  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
4331  {
4332  // allow only write access
4333  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
4334  $this->ctrl->redirect($this, "infoScreen");
4335  }
4336 
4337  $form = $this->formRandomfill();
4338  if (count($_POST) && $form->checkInput())
4339  {
4340  $this->object->createRandomSolutions($_POST['participants']);
4341  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
4342  ilUtil::sendSuccess($this->lng->txt('tst_randomfill_complete'));
4343  }
4344  else
4345  {
4346  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
4347  }
4348  }
4349 
4355  function getTabs(&$tabs_gui)
4356  {
4357  global $ilAccess,$ilUser;
4358 
4359  switch ($this->ctrl->getCmd())
4360  {
4361  case "resume":
4362  case "previous":
4363  case "next":
4364  case "summary":
4365  case "directfeedback":
4366  case "finishTest":
4367  case "outCorrectSolution":
4368  case "passDetails":
4369  case "showAnswersOfUser":
4370  case "outUserResultsOverview":
4371  case "backFromSummary":
4372  case "show_answers":
4373  case "setsolved":
4374  case "resetsolved":
4375  case "confirmFinish":
4376  case "outTestSummary":
4377  case "outQuestionSummary":
4378  case "gotoQuestion":
4379  case "selectImagemapRegion":
4380  case "confirmSubmitAnswers":
4381  case "finalSubmission":
4382  case "postpone":
4383  case "redirectQuestion":
4384  case "outUserPassDetails":
4385  case "checkPassword":
4386  case "exportCertificate":
4387  case "finishListOfAnswers":
4388  case "backConfirmFinish":
4389  case "showFinalStatement":
4390  return;
4391  break;
4392  case "browseForQuestions":
4393  case "filter":
4394  case "resetFilter":
4395  case "resetTextFilter":
4396  case "insertQuestions":
4397  return $this->getBrowseForQuestionsTab($tabs_gui);
4398  break;
4399  case "scoring":
4400  case "properties":
4401  case "marks":
4402  case "saveMarks":
4403  case "cancelMarks":
4404  case "addMarkStep":
4405  case "deleteMarkSteps":
4406  case "addSimpleMarkSchema":
4407  case "certificate":
4408  case "certificateservice":
4409  case "certificateImport":
4410  case "certificateUpload":
4411  case "certificateEditor":
4412  case "certificateDelete":
4413  case "certificateSave":
4414  case "defaults":
4415  case "deleteDefaults":
4416  case "addDefaults":
4417  case "applyDefaults":
4418  case "inviteParticipants":
4419  case "searchParticipants":
4420  case "":
4421  if (($ilAccess->checkAccess("write", "", $this->ref_id)) && ((strcmp($this->ctrl->getCmdClass(), "ilobjtestgui") == 0) || (strcmp($this->ctrl->getCmdClass(), "ilcertificategui") == 0) || (strlen($this->ctrl->getCmdClass()) == 0)))
4422  {
4423  $this->getSettingsSubTabs();
4424  }
4425  break;
4426  case "export":
4427  case "print":
4428  break;
4429  case "statistics":
4430  case "eval_a":
4431  case "detailedEvaluation":
4432  case "outEvaluation":
4433  case "singleResults":
4434  case "exportEvaluation":
4435  case "evalUserDetail":
4436  case "passDetails":
4437  case "outStatisticsResultsOverview":
4438  case "statisticsPassDetails":
4439  $this->getStatisticsSubTabs();
4440  break;
4441  case "timing":
4442  case "scoreQuestion":
4443  case "recalculate":
4444  case "randomfill":
4445  $this->getAdministrationSubTabs();
4446  break;
4447  }
4448 
4449  if (strcmp(strtolower(get_class($this->object)), "ilobjtest") == 0)
4450  {
4451  // questions tab
4452  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4453  {
4454  $force_active = ($_GET["up"] != "" || $_GET["down"] != "")
4455  ? true
4456  : false;
4457  if (!$force_active)
4458  {
4459  if ($_GET["browse"] == 1) $force_active = true;
4460  if (preg_match("/deleteqpl_\d+/", $this->ctrl->getCmd()))
4461  {
4462  $force_active = true;
4463  }
4464  }
4465  $tabs_gui->addTarget("assQuestions",
4466  $this->ctrl->getLinkTarget($this,'questions'),
4467  array("questions", "browseForQuestions", "questionBrowser", "createQuestion",
4468  "randomselect", "filter", "resetFilter", "insertQuestions",
4469  "back", "createRandomSelection", "cancelRandomSelect",
4470  "insertRandomSelection", "removeQuestions", "moveQuestions",
4471  "insertQuestionsBefore", "insertQuestionsAfter", "confirmRemoveQuestions",
4472  "cancelRemoveQuestions", "executeCreateQuestion", "cancelCreateQuestion",
4473  "addQuestionpool", "saveRandomQuestions", "saveQuestionSelectionMode", "print",
4474  "addsource", "removesource", "randomQuestions"),
4475  "", "", $force_active);
4476  }
4477 
4478  // info tab
4479  if ($ilAccess->checkAccess("visible", "", $this->ref_id))
4480  {
4481  $tabs_gui->addTarget("info_short",
4482  $this->ctrl->getLinkTarget($this,'infoScreen'),
4483  array("infoScreen", "outIntroductionPage", "showSummary",
4484  "setAnonymousId", "outUserListOfAnswerPasses", "redirectToInfoScreen"));
4485  }
4486 
4487  // settings tab
4488  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4489  {
4490  $tabs_gui->addTarget("settings",
4491  $this->ctrl->getLinkTarget($this,'properties'),
4492  array("properties", "saveProperties", "cancelProperties",
4493  "marks", "addMarkStep", "deleteMarkSteps", "addSimpleMarkSchema",
4494  "saveMarks", "cancelMarks",
4495  "certificate", "certificateEditor", "certificateRemoveBackground",
4496  "certificateSave", "certificatePreview", "certificateDelete", "certificateUpload",
4497  "certificateImport", "scoring", "defaults", "addDefaults", "deleteDefaults", "applyDefaults",
4498  "inviteParticipants", "saveFixedParticipantsStatus", "searchParticipants", "addParticipants",
4499  ""
4500  ),
4501  array("", "ilobjtestgui", "ilcertificategui")
4502  );
4503 
4504  // participants
4505  $tabs_gui->addTarget("participants",
4506  $this->ctrl->getLinkTarget($this,'participants'),
4507  array("participants", "saveClientIP",
4508  "removeParticipant",
4509  "showParticipantAnswersForAuthor",
4510  "deleteAllUserResults",
4511  "cancelDeleteAllUserData", "deleteSingleUserResults",
4512  "outParticipantsResultsOverview", "outParticipantsPassDetails",
4513  "showPassOverview", "showUserAnswers", "participantsAction",
4514  "showDetailedResults"),
4515  "");
4516  }
4517 
4518  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
4519  if(ilLearningProgressAccess::checkAccess($this->object->getRefId()))
4520  {
4521  $tabs_gui->addTarget('learning_progress',
4522  $this->ctrl->getLinkTargetByClass(array('illearningprogressgui'),''),
4523  '',
4524  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui'));
4525  }
4526 
4527  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4528  {
4529  include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
4531  if (count($scoring))
4532  {
4533  // scoring tab
4534  $tabs_gui->addTarget("manscoring",
4535  $this->ctrl->getLinkTargetByClass("iltestscoringgui", "manscoring"),
4536  array("manscoring", "scoringfilter", "scoringfilterreset", "setPointsManual", "setFeedbackManual", "setManscoringDone", 'selectQuestion', 'scoringParticipants'),
4537  "");
4538  }
4539  }
4540 
4541  if (($ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) || ($ilAccess->checkAccess("write", "", $this->ref_id)))
4542  {
4543  // statistics tab
4544  $tabs_gui->addTarget("statistics",
4545  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "outEvaluation"),
4546  array("statistics", "outEvaluation", "exportEvaluation", "detailedEvaluation", "eval_a", "evalUserDetail",
4547  "passDetails", "outStatisticsResultsOverview", "statisticsPassDetails", "singleResults")
4548  , "");
4549  }
4550 
4551  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4552  {
4553  // history
4554  $tabs_gui->addTarget("history",
4555  $this->ctrl->getLinkTarget($this,'history'),
4556  "history", "");
4557 
4558  // meta data
4559  $tabs_gui->addTarget("meta_data",
4560  $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'),
4561  "", "ilmdeditorgui");
4562 
4563  // export tab
4564  $tabs_gui->addTarget("export",
4565  $this->ctrl->getLinkTarget($this,'export'),
4566  array("export", "createExportFile", "confirmDeleteExportFile",
4567  "downloadExportFile", "deleteExportFile", "cancelDeleteExportFile"),
4568  "");
4569 
4570  // administration tab
4571  $tabs_gui->addTarget("administration",
4572  $this->ctrl->getLinkTargetByClass("iltestnewscoringgui", "scoreQuestion"),
4573  array("timing", "scoreQuestion", 'recalculate', 'randomfill'),
4574  "");
4575  }
4576 
4577  if ($ilAccess->checkAccess("edit_permission", "", $this->ref_id))
4578  {
4579  $tabs_gui->addTarget("perm_settings",
4580  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
4581  }
4582  }
4583  }
4584 
4593  function _goto($a_target)
4594  {
4595  global $ilAccess, $ilErr, $lng;
4596 
4597  if ($ilAccess->checkAccess("visible", "", $a_target))
4598  {
4599  //include_once "./Services/Utilities/classes/class.ilUtil.php";
4600  $_GET["baseClass"] = "ilObjTestGUI";
4601  $_GET["cmd"] = "infoScreen";
4602  $_GET["ref_id"] = $a_target;
4603  include_once("ilias.php");
4604  exit;
4605  //ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=infoScreen&ref_id=$a_target");
4606  }
4607  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
4608  {
4609  $_GET["cmd"] = "frameset";
4610  $_GET["target"] = "";
4611  $_GET["ref_id"] = ROOT_FOLDER_ID;
4612  ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
4613  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
4614  include("repository.php");
4615  exit;
4616  }
4617 
4618  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
4619  }
4620 
4621 } // END class.ilObjTestGUI
4622 ?>