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