ILIAS  Release_3_10_x_branch Revision 61812
 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;
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("./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 "iltestcertificategui":
161  include_once "./Modules/Test/classes/class.ilTestCertificateGUI.php";
162  $this->prepareOutput();
163  $output_gui = new ilTestCertificateGUI($this->object);
164  $this->ctrl->forwardCommand($output_gui);
165  break;
166 
167  case "iltestscoringgui":
168  include_once "./Modules/Test/classes/class.ilTestScoringGUI.php";
169  $this->prepareOutput();
170  $output_gui = new ilTestScoringGUI($this->object);
171  $this->ctrl->forwardCommand($output_gui);
172  break;
173 
174  default:
175  $this->prepareOutput();
176  if (preg_match("/deleteqpl_\d+/", $cmd))
177  {
178  $cmd = "randomQuestions";
179  }
180  if ((strcmp($cmd, "properties") == 0) && ($_GET["browse"]))
181  {
182  $this->questionBrowser();
183  return;
184  }
185  if ((strcmp($cmd, "properties") == 0) && ($_GET["up"] || $_GET["down"]))
186  {
187  $this->questionsObject();
188  return;
189  }
190  $cmd.= "Object";
191  $ret =& $this->$cmd();
192  break;
193  }
194  if (strtolower($_GET["baseClass"]) != "iladministrationgui" &&
195  $this->getCreationMode() != true)
196  {
197  $this->tpl->show();
198  }
199  }
200 
201  function runObject()
202  {
203  $this->ctrl->redirect($this, "infoScreen");
204  }
205 
207  {
208  $this->ctrl->redirectByClass("iltestevaluationgui", "outEvaluation");
209  }
210 
214  function importFileObject()
215  {
216  if ($_POST["qpl"] < 1)
217  {
218  ilUtil::sendInfo($this->lng->txt("tst_select_questionpools"));
219  $this->createObject();
220  return;
221  }
222  if (strcmp($_FILES["xmldoc"]["tmp_name"], "") == 0)
223  {
224  ilUtil::sendInfo($this->lng->txt("tst_select_file_for_import"));
225  $this->createObject();
226  return;
227  }
228  $this->ctrl->setParameter($this, "new_type", $this->type);
229  $this->uploadTstObject();
230  }
231 
236  function saveObject()
237  {
238  global $rbacadmin;
239 
240  // create and insert forum in objecttree
241  $newObj = parent::saveObject();
242  if ($_POST["defaults"] > 0)
243  {
244  $newObj->applyDefaults($_POST["defaults"]);
245  }
246 
247  // always send a message
248  ilUtil::sendInfo($this->lng->txt("object_added"),true);
249  ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&ref_id=".$newObj->getRefId()."&cmd=properties");
250  }
251 
253  {
254  include_once "./Services/Utilities/classes/class.ilUtil.php";
255  $path = $this->tree->getPathFull($this->object->getRefID());
256  ilUtil::redirect($this->getReturnLocation("cancel","./repository.php?cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
257  }
258 
260  {
261  include_once "./Services/Utilities/classes/class.ilUtil.php";
262  ilUtil::redirect($this->getReturnLocation("cancel","./repository.php?ref_id=".(int) $_GET['crs_show_result']));
263  }
264 
265  /*
266  * list all export files
267  */
268  function exportObject()
269  {
270  global $tree;
271  global $ilAccess;
272  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
273  {
274  // allow only write access
275  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
276  $this->ctrl->redirect($this, "infoScreen");
277  }
278 
279  //add template for view button
280  $this->tpl->addBlockfile("BUTTONS", "buttons", "tpl.buttons.html");
281 
282  if ($this->object->isRandomTest())
283  {
284  ilUtil::sendInfo($this->lng->txt("tst_no_export_randomtest"));
285  }
286  else
287  {
288  // create export file button
289  $this->tpl->setCurrentBlock("btn_cell");
290  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "createExportFile")."&mode=xml");
291  $this->tpl->setVariable("BTN_TXT", $this->lng->txt("ass_create_export_file"));
292  $this->tpl->parseCurrentBlock();
293  }
294 
295  // create export test results button
296  $this->tpl->setCurrentBlock("btn_cell");
297  $this->tpl->setVariable("BTN_LINK", $this->ctrl->getLinkTarget($this, "createExportfile")."&mode=results");
298  $this->tpl->setVariable("BTN_TXT", $this->lng->txt("ass_create_export_test_results"));
299  $this->tpl->parseCurrentBlock();
300 
301  $export_dir = $this->object->getExportDirectory();
302 
303  $export_files = $this->object->getExportFiles($export_dir);
304 
305  // create table
306  include_once("./Services/Table/classes/class.ilTableGUI.php");
307  $tbl = new ilTableGUI();
308 
309  // load files templates
310  $this->tpl->addBlockfile("ADM_CONTENT", "adm_content", "tpl.table.html");
311 
312  // load template for table content data
313  $this->tpl->addBlockfile("TBL_CONTENT", "tbl_content", "tpl.export_file_row.html", "Modules/Test");
314 
315  $num = 0;
316 
317  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
318 
319  $tbl->setTitle($this->lng->txt("ass_export_files"));
320 
321  $tbl->setHeaderNames(array("", $this->lng->txt("ass_file"),
322  $this->lng->txt("ass_size"), $this->lng->txt("date") ));
323 
324  $tbl->enabled["sort"] = false;
325  $tbl->setColumnWidth(array("1%", "49%", "25%", "25%"));
326 
327  // control
328  $tbl->setOrderColumn($_GET["sort_by"]);
329  $tbl->setOrderDirection($_GET["sort_order"]);
330  $tbl->setLimit($_GET["limit"]);
331  $tbl->setOffset($_GET["offset"]);
332  $tbl->setMaxCount($this->maxcount); // ???
333  $header_params = $this->ctrl->getParameterArray($this, "export");
334  $tbl->setHeaderVars(array("", "file", "size", "date"), $header_params);
335 
336 
337  // footer
338  $tbl->setFooter("tblfooter",$this->lng->txt("previous"),$this->lng->txt("next"));
339  //$tbl->disable("footer");
340 
341  $tbl->setMaxCount(count($export_files));
342  $export_files = array_slice($export_files, $_GET["offset"], $_GET["limit"]);
343 
344  $tbl->render();
345  if(count($export_files) > 0)
346  {
347  $this->tpl->setVariable("COLUMN_COUNTS", 4);
348 
349  $i=0;
350  foreach($export_files as $exp_file)
351  {
352  $this->tpl->setCurrentBlock("tbl_content");
353  $this->tpl->setVariable("TXT_FILENAME", $exp_file);
354 
355  $css_row = ilUtil::switchColor($i++, "tblrow1", "tblrow2");
356  $this->tpl->setVariable("CSS_ROW", $css_row);
357 
358  $this->tpl->setVariable("TXT_SIZE", filesize($export_dir."/".$exp_file));
359  $this->tpl->setVariable("CHECKBOX_ID", $exp_file);
360 
361  $file_arr = explode("__", $exp_file);
362  $this->tpl->setVariable("TXT_DATE", date("Y-m-d H:i:s",$file_arr[0]));
363 
364  $this->tpl->parseCurrentBlock();
365  }
366  $this->tpl->setCurrentBlock("selectall");
367  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
368  $this->tpl->setVariable("CSS_ROW", $css_row);
369  $this->tpl->parseCurrentBlock();
370  // delete button
371  $this->tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
372  $this->tpl->setCurrentBlock("tbl_action_btn");
373  $this->tpl->setVariable("BTN_NAME", "confirmDeleteExportFile");
374  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("delete"));
375  $this->tpl->parseCurrentBlock();
376 
377  $this->tpl->setCurrentBlock("tbl_action_btn");
378  $this->tpl->setVariable("BTN_NAME", "downloadExportFile");
379  $this->tpl->setVariable("BTN_VALUE", $this->lng->txt("download"));
380  $this->tpl->parseCurrentBlock();
381  } //if is_array
382  else
383  {
384  $this->tpl->setCurrentBlock("notfound");
385  $this->tpl->setVariable("TXT_OBJECT_NOT_FOUND", $this->lng->txt("obj_not_found"));
386  $this->tpl->setVariable("NUM_COLS", 3);
387  $this->tpl->parseCurrentBlock();
388  }
389 
390  $this->tpl->parseCurrentBlock();
391  }
392 
393 
398  {
399  global $ilAccess;
400 
401  if ($ilAccess->checkAccess("write", "", $this->ref_id))
402  {
403  include_once("./Modules/Test/classes/class.ilTestExport.php");
404  $test_exp = new ilTestExport($this->object, $_GET["mode"]);
405  $test_exp->buildExportFile();
406  }
407  else
408  {
409  ilUtil::sendInfo("cannot_export_test", TRUE);
410  }
411  $this->ctrl->redirect($this, "export");
412  }
413 
414 
419  {
420  if(!isset($_POST["file"]))
421  {
422  ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
423  $this->ctrl->redirect($this, "export");
424  }
425 
426  if (count($_POST["file"]) > 1)
427  {
428  ilUtil::sendInfo($this->lng->txt("select_max_one_item"), true);
429  $this->ctrl->redirect($this, "export");
430  }
431 
432 
433  $export_dir = $this->object->getExportDirectory();
434  ilUtil::deliverFile($export_dir."/".$_POST["file"][0],
435  $_POST["file"][0]);
436  }
437 
442  {
443  if(!isset($_POST["file"]))
444  {
445  ilUtil::sendInfo($this->lng->txt("no_checkbox"), true);
446  $this->ctrl->redirect($this, "export");
447  }
448 
449  // SAVE POST VALUES
450  $_SESSION["ilExportFiles"] = $_POST["file"];
451 
452  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", "Modules/Test");
453 
454  ilUtil::sendInfo($this->lng->txt("info_delete_sure"));
455 
456  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
457 
458  // BEGIN TABLE HEADER
459  $this->tpl->setCurrentBlock("table_header");
460  $this->tpl->setVariable("TEXT",$this->lng->txt("objects"));
461  $this->tpl->parseCurrentBlock();
462 
463  // BEGIN TABLE DATA
464  $counter = 0;
465  foreach($_POST["file"] as $file)
466  {
467  $this->tpl->setCurrentBlock("table_row");
468  $this->tpl->setVariable("CSS_ROW",ilUtil::switchColor(++$counter,"tblrow1","tblrow2"));
469  $this->tpl->setVariable("TEXT_CONTENT", $file);
470  $this->tpl->parseCurrentBlock();
471  }
472 
473  // cancel/confirm button
474  $this->tpl->setVariable("IMG_ARROW",ilUtil::getImagePath("arrow_downright.gif"));
475  $buttons = array( "cancelDeleteExportFile" => $this->lng->txt("cancel"),
476  "deleteExportFile" => $this->lng->txt("confirm"));
477  foreach ($buttons as $name => $value)
478  {
479  $this->tpl->setCurrentBlock("operation_btn");
480  $this->tpl->setVariable("BTN_NAME",$name);
481  $this->tpl->setVariable("BTN_VALUE",$value);
482  $this->tpl->parseCurrentBlock();
483  }
484  }
485 
491  function cancelObject($in_rep = false)
492  {
493  ilUtil::sendInfo($this->lng->txt("msg_cancel"),true);
494  ilUtil::redirect("repository.php?cmd=frameset&ref_id=".$_GET["ref_id"]);
495  }
496 
501  {
502  session_unregister("ilExportFiles");
503  $this->ctrl->redirect($this, "export");
504  }
505 
506 
511  {
512  $export_dir = $this->object->getExportDirectory();
513  foreach($_SESSION["ilExportFiles"] as $file)
514  {
515  $exp_file = $export_dir."/".$file;
516  $exp_dir = $export_dir."/".substr($file, 0, strlen($file) - 4);
517  if (@is_file($exp_file))
518  {
519  unlink($exp_file);
520  }
521  if (@is_dir($exp_dir))
522  {
523  ilUtil::delDir($exp_dir);
524  }
525  }
526  $this->ctrl->redirect($this, "export");
527  }
528 
534  function importObject()
535  {
536  $this->getTemplateFile("import", "tst");
537  $this->tpl->setCurrentBlock("option_qpl");
538  include_once("./Modules/Test/classes/class.ilObjTest.php");
539  $tst = new ilObjTest();
540  $questionpools =& $tst->getAvailableQuestionpools(TRUE, FALSE, FALSE, TRUE);
541  if (count($questionpools) == 0)
542  {
543  }
544  else
545  {
546  foreach ($questionpools as $key => $value)
547  {
548  $this->tpl->setCurrentBlock("option_qpl");
549  $this->tpl->setVariable("OPTION_VALUE", $key);
550  $this->tpl->setVariable("TXT_OPTION", $value["title"]);
551  $this->tpl->parseCurrentBlock();
552  }
553  }
554  $this->tpl->setVariable("TXT_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool"));
555  $this->tpl->setVariable("OPTION_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool_option"));
556  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
557  $this->tpl->setVariable("BTN_NAME", "uploadTst");
558  $this->tpl->setVariable("TXT_UPLOAD", $this->lng->txt("upload"));
559  $this->tpl->setVariable("NEW_TYPE", $this->type);
560  $this->tpl->setVariable("TXT_IMPORT_TST", $this->lng->txt("import_tst"));
561  $this->tpl->setVariable("TXT_SELECT_MODE", $this->lng->txt("select_mode"));
562  $this->tpl->setVariable("TXT_SELECT_FILE", $this->lng->txt("select_file"));
563 
564  }
565 
569  function uploadTstObject()
570  {
571  if ($_POST["qpl"] < 1)
572  {
573  ilUtil::sendInfo($this->lng->txt("tst_select_questionpools"));
574  $this->importObject();
575  return;
576  }
577 
578  if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
579  {
580  ilUtil::sendInfo($this->lng->txt("error_upload"));
581  $this->importObject();
582  return;
583  }
584  include_once("./Modules/Test/classes/class.ilObjTest.php");
585  // create import directory
587 
588  // copy uploaded file to import directory
589  $file = pathinfo($_FILES["xmldoc"]["name"]);
590  $full_path = ilObjTest::_getImportDirectory()."/".$_FILES["xmldoc"]["name"];
591  ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path);
592 
593  // unzip file
594  ilUtil::unzip($full_path);
595 
596  // determine filenames of xml files
597  $subdir = basename($file["basename"],".".$file["extension"]);
598  $xml_file = ilObjTest::_getImportDirectory()."/".$subdir."/".$subdir.".xml";
599  $qti_file = ilObjTest::_getImportDirectory()."/".$subdir."/". str_replace("test", "qti", $subdir).".xml";
600  // start verification of QTI files
601  include_once "./Services/QTI/classes/class.ilQTIParser.php";
602  $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, "");
603  $result = $qtiParser->startParsing();
604  $founditems =& $qtiParser->getFoundItems();
605 
606  if (count($founditems) == 0)
607  {
608  // nothing found
609 
610  // delete import directory
612 
613  ilUtil::sendInfo($this->lng->txt("tst_import_no_items"));
614  $this->importObject();
615  return;
616  }
617 
618  $complete = 0;
619  $incomplete = 0;
620  foreach ($founditems as $item)
621  {
622  if (strlen($item["type"]))
623  {
624  $complete++;
625  }
626  else
627  {
628  $incomplete++;
629  }
630  }
631 
632  if ($complete == 0)
633  {
634  // delete import directory
636 
637  ilUtil::sendInfo($this->lng->txt("qpl_import_non_ilias_files"));
638  $this->importObject();
639  return;
640  }
641 
642  $_SESSION["tst_import_xml_file"] = $xml_file;
643  $_SESSION["tst_import_qti_file"] = $qti_file;
644  $_SESSION["tst_import_subdir"] = $subdir;
645  // display of found questions
646  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.tst_import_verification.html");
647  $row_class = array("tblrow1", "tblrow2");
648  $counter = 0;
649  foreach ($founditems as $item)
650  {
651  $this->tpl->setCurrentBlock("verification_row");
652  $this->tpl->setVariable("ROW_CLASS", $row_class[$counter++ % 2]);
653  $this->tpl->setVariable("QUESTION_TITLE", $item["title"]);
654  $this->tpl->setVariable("QUESTION_IDENT", $item["ident"]);
655  include_once "./Services/QTI/classes/class.ilQTIItem.php";
656  switch ($item["type"])
657  {
658  case "MULTIPLE CHOICE QUESTION":
660  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("qt_multiple_choice"));
661  break;
662  case "SINGLE CHOICE QUESTION":
664  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assSingleChoice"));
665  break;
666  case "NUMERIC QUESTION":
667  case QT_NUMERIC:
668  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assNumeric"));
669  break;
670  case "TEXTSUBSET QUESTION":
671  case QT_TEXTSUBSET:
672  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextSubset"));
673  break;
674  case "CLOZE QUESTION":
675  case QT_CLOZE:
676  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assClozeTest"));
677  break;
678  case "IMAGE MAP QUESTION":
679  case QT_IMAGEMAP:
680  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assImagemapQuestion"));
681  break;
682  case "JAVA APPLET QUESTION":
683  case QT_JAVAAPPLET:
684  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assJavaApplet"));
685  break;
686  case "MATCHING QUESTION":
687  case QT_MATCHING:
688  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assMatchingQuestion"));
689  break;
690  case "ORDERING QUESTION":
691  case QT_ORDERING:
692  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assOrderingQuestion"));
693  break;
694  case "TEXT QUESTION":
695  case QT_TEXT:
696  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextQuestion"));
697  break;
698  }
699  $this->tpl->parseCurrentBlock();
700  }
701  $this->tpl->setCurrentBlock("adm_content");
702  $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt("question_type"));
703  $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("question_title"));
704  $this->tpl->setVariable("FOUND_QUESTIONS_INTRODUCTION", $this->lng->txt("tst_import_verify_found_questions"));
705  $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_tst"));
706  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
707  $this->tpl->setVariable("ARROW", ilUtil::getImagePath("arrow_downright.gif"));
708  $this->tpl->setVariable("QUESTIONPOOL_ID", $_POST["qpl"]);
709  $this->tpl->setVariable("VALUE_IMPORT", $this->lng->txt("import"));
710  $this->tpl->setVariable("VALUE_CANCEL", $this->lng->txt("cancel"));
711  $this->tpl->parseCurrentBlock();
712  }
713 
718  {
719  include_once "./Modules/Test/classes/class.ilObjTest.php";
720  // create new questionpool object
721  $newObj = new ilObjTest(0, true);
722  // set type of questionpool object
723  $newObj->setType($_GET["new_type"]);
724  // set title of questionpool object to "dummy"
725  $newObj->setTitle("dummy");
726  // set description of questionpool object
727  $newObj->setDescription("test import");
728  // create the questionpool class in the ILIAS database (object_data table)
729  $newObj->create(true);
730  // create a reference for the questionpool object in the ILIAS database (object_reference table)
731  $newObj->createReference();
732  // put the questionpool object in the administration tree
733  $newObj->putInTree($_GET["ref_id"]);
734  // get default permissions and set the permissions for the questionpool object
735  $newObj->setPermissions($_GET["ref_id"]);
736  // notify the questionpool object and all its parent objects that a "new" object was created
737  $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
738  // empty mark schema
739  $newObj->mark_schema->flush();
740 
741  // start parsing of QTI files
742  include_once "./Services/QTI/classes/class.ilQTIParser.php";
743  $qtiParser = new ilQTIParser($_SESSION["tst_import_qti_file"], IL_MO_PARSE_QTI, $_POST["qpl_id"], $_POST["ident"]);
744  $qtiParser->setTestObject($newObj);
745  $result = $qtiParser->startParsing();
746  $newObj->saveToDb();
747 
748 
749 
750  // import page data
751  include_once ("./Modules/LearningModule/classes/class.ilContObjParser.php");
752  $contParser = new ilContObjParser($newObj, $_SESSION["tst_import_xml_file"], $_SESSION["tst_import_subdir"]);
753  $contParser->setQuestionMapping($qtiParser->getImportMapping());
754  $contParser->startParsing();
755 
756  // delete import directory
758  ilUtil::sendInfo($this->lng->txt("object_imported"),true);
759  ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
760  "&baseClass=ilObjTestGUI");
761  }
762 
764  {
765  $this->ctrl->redirect($this, "cancel");
766 // $this->backToRepositoryObject();
767  }
768 
769 
776  function uploadObject($redirect = true)
777  {
778  $this->uploadTstObject();
779  }
780 
790  function confirmChangeProperties($direction = 0)
791  {
792  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_properties_save_confirmation.html", "Modules/Test");
793  $information = "";
794  switch ($direction)
795  {
796  case 0:
797  $information = $this->lng->txt("change_properties_from_random_to_standard");
798  break;
799  default:
800  $information = $this->lng->txt("change_properties_from_standard_to_random");
801  break;
802  }
803  foreach ($_POST as $key => $value)
804  {
805  if (strcmp($key, "cmd") != 0)
806  {
807  if (is_array($value))
808  {
809  foreach ($value as $k => $v)
810  {
811  $this->tpl->setCurrentBlock("hidden_variable");
812  $this->tpl->setVariable("HIDDEN_KEY", $key . "[" . $k . "]");
813  $this->tpl->setVariable("HIDDEN_VALUE", $v);
814  $this->tpl->parseCurrentBlock();
815  }
816  }
817  else
818  {
819  $this->tpl->setCurrentBlock("hidden_variable");
820  $this->tpl->setVariable("HIDDEN_KEY", $key);
821  $this->tpl->setVariable("HIDDEN_VALUE", $value);
822  $this->tpl->parseCurrentBlock();
823  }
824  }
825  }
826  $this->tpl->setCurrentBlock("hidden_variable");
827  $this->tpl->setVariable("HIDDEN_KEY", "tst_properties_confirmation");
828  $this->tpl->setVariable("HIDDEN_VALUE", "1");
829  $this->tpl->parseCurrentBlock();
830  $this->tpl->setCurrentBlock("adm_content");
831  $this->tpl->setVariable("TXT_CONFIRMATION", $this->lng->txt("confirmation"));
832  $this->tpl->setVariable("TXT_INFORMATION", $information);
833  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
834  $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
835  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
836  $this->tpl->parseCurrentBlock();
837  }
838 
847  {
848  $total = $this->object->evalTotalPersons();
849  $randomtest_switch = false;
850  // Check the values the user entered in the form
851  if (!$total)
852  {
853  if (!array_key_exists("tst_properties_confirmation", $_POST))
854  {
855  if (($this->object->isRandomTest()) && (count($this->object->getRandomQuestionpools()) > 0))
856  {
857  if (!$_POST["chb_random"])
858  {
859  // user tries to change from a random test with existing random question pools to a non random test
860  $this->confirmChangeProperties(0);
861  return;
862  }
863  }
864  if ((!$this->object->isRandomTest()) && (count($this->object->questions) > 0))
865  {
866  if ($_POST["chb_random"])
867  {
868  // user tries to change from a non random test with existing questions to a random test
869  $this->confirmChangeProperties(1);
870  return;
871  }
872  }
873  }
874 
875  if (!strlen($_POST["chb_random"]))
876  {
877  $data["random_test"] = 0;
878  }
879  else
880  {
881  $data["random_test"] = ilUtil::stripSlashes($_POST["chb_random"]);
882  }
883  }
884  else
885  {
886  $data["random_test"] = $this->object->random_test;
887  }
888  if ($data["random_test"] != $this->object->random_test)
889  {
890  $randomtest_switch = true;
891  }
892  $data["anonymity"] = $_POST["anonymity"];
893  if ($total)
894  {
895  $data["anonymity"] = $this->object->getAnonymity();
896  }
897  $data["show_cancel"] = $_POST["show_cancel"];
898  $data["password"] = $_POST["password"];
899  $data["allowedUsers"] = $_POST["allowedUsers"];
900  $data["show_cancel"] = $_POST["chb_show_cancel"];
901  $data["show_marker"] = ($_POST["chb_show_marker"] ? 1 : 0);
902  $data["allowedUsersTimeGap"] = $_POST["allowedUsersTimeGap"];
903  include_once "./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
904  $introduction = ilUtil::stripSlashes($_POST["introduction"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment"));
905  $data["introduction"] = $introduction;
906  $finalstatement = ilUtil::stripSlashes($_POST["finalstatement"], false, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("assessment"));
907  $data["finalstatement"] = $finalstatement;
908  $data["showfinalstatement"] = ($_POST["showfinalstatement"]) ? 1 : 0;
909  $data["showinfo"] = ($_POST["showinfo"]) ? 1 : 0;
910  $data["forcejs"] = ($_POST["forcejs"]) ? 1 : 0;
911  $data["customstyle"] = (strcmp($_POST["customstyle"], "0") == 0) ? "" : $_POST["customstyle"];
912  $data["sequence_settings"] = ilUtil::stripSlashes($_POST["chb_postpone"]);
913  $data["shuffle_questions"] = 0;
914  if ($_POST["chb_shuffle_questions"])
915  {
916  $data["shuffle_questions"] = $_POST["chb_shuffle_questions"];
917  }
918  $data["list_of_questions"] = 0;
919  if ($_POST["list_of_questions"] == 1)
920  {
921  $data["list_of_questions"] = 1;
922  }
923  $data["list_of_questions_start"] = 0;
924  if ($_POST["chb_list_of_questions_start"] == 1)
925  {
926  $data["list_of_questions_start"] = 1;
927  }
928  $data["list_of_questions_end"] = 0;
929  if ($_POST["chb_list_of_questions_end"] == 1)
930  {
931  $data["list_of_questions_end"] = 1;
932  }
933  $data["list_of_questions_with_description"] = 0;
934  if ($_POST["chb_list_of_questions_with_description"] == 1)
935  {
936  $data["list_of_questions_with_description"] = 1;
937  }
938  $data["nr_of_tries"] = ilUtil::stripSlashes($_POST["nr_of_tries"]);
939  $data["kiosk"] = ilUtil::stripSlashes($_POST["kiosk"]);
940  $data["kiosk_title"] = ilUtil::stripSlashes($_POST["kiosk_title"]);
941  $data["kiosk_participant"] = ilUtil::stripSlashes($_POST["kiosk_participant"]);
942  $data["processing_time"] = ilUtil::stripSlashes($_POST["processing_time"]);
943  if (!$_POST["chb_starting_time"])
944  {
945  $data["starting_time"] = "";
946  }
947  else
948  {
949  $data["starting_time"] = sprintf("%04d%02d%02d%02d%02d%02d",
950  $_POST["starting_date"]["y"],
951  $_POST["starting_date"]["m"],
952  $_POST["starting_date"]["d"],
953  $_POST["starting_time"]["h"],
954  $_POST["starting_time"]["m"],
955  0
956  );
957  }
958  if (!$_POST["chb_ending_time"])
959  {
960  $data["ending_time"] = "";
961  }
962  else
963  {
964  $data["ending_time"] = sprintf("%04d%02d%02d%02d%02d%02d",
965  $_POST["ending_date"]["y"],
966  $_POST["ending_date"]["m"],
967  $_POST["ending_date"]["d"],
968  $_POST["ending_time"]["h"],
969  $_POST["ending_time"]["m"],
970  0
971  );
972  }
973 
974  if ($_POST["chb_processing_time"])
975  {
976  $data["enable_processing_time"] = "1";
977  }
978  else
979  {
980  $data["enable_processing_time"] = "0";
981  }
982  $data["reset_processing_time"] = "0";
983  if ($_POST["chb_processing_time"])
984  {
985  if ($_POST["chb_reset_processing_time"])
986  {
987  $data["reset_processing_time"] = "1";
988  }
989  }
990  if ($_POST["chb_use_previous_answers"])
991  {
992  $data["use_previous_answers"] = "1";
993  }
994  else
995  {
996  $data["use_previous_answers"] = "0";
997  }
998 
999  $data["title_output"] = $_POST["title_output"];
1000 
1001  if ($data["enable_processing_time"])
1002  {
1003  $data["processing_time"] = sprintf("%02d:%02d:%02d",
1004  $_POST["processing_time"]["h"],
1005  $_POST["processing_time"]["m"],
1006  $_POST["processing_time"]["s"]
1007  );
1008  }
1009  else
1010  {
1011  $proc_time = $this->object->getEstimatedWorkingTime();
1012  $data["processing_time"] = sprintf("%02d:%02d:%02d",
1013  $proc_time["h"],
1014  $proc_time["m"],
1015  $proc_time["s"]
1016  );
1017  }
1018 
1019  if ($data["nr_of_tries"] == 1)
1020  {
1021  $data["pass_scoring"] = SCORE_LAST_PASS;
1022  }
1023  $this->object->setIntroduction($data["introduction"]);
1024  $this->object->setFinalStatement($data["finalstatement"]);
1025  $this->object->setShowFinalStatement($data["showfinalstatement"]);
1026  $this->object->setShowInfo($data["showinfo"]);
1027  $this->object->setForceJS($data["forcejs"]);
1028  $this->object->setCustomStyle($data["customstyle"]);
1029  $this->object->setSequenceSettings($data["sequence_settings"]);
1030  $this->object->setAnonymity($data["anonymity"]);
1031  $this->object->setShowCancel($data["show_cancel"]);
1032  $this->object->setShowMarker($data["show_marker"]);
1033  $this->object->setPassword($data["password"]);
1034  $this->object->setAllowedUsers($data["allowedUsers"]);
1035  $this->object->setAllowedUsersTimeGap($data["allowedUsersTimeGap"]);
1036  $this->object->setKioskMode($data["kiosk"]);
1037  $this->object->setShowKioskModeTitle($data["kiosk_title"]);
1038  $this->object->setShowKioskModeParticipant($data["kiosk_participant"]);
1039  $this->object->setNrOfTries($data["nr_of_tries"]);
1040  $this->object->setStartingTime($data["starting_time"]);
1041  $this->object->setEndingTime($data["ending_time"]);
1042  $this->object->setProcessingTime($data["processing_time"]);
1043  $this->object->setRandomTest($data["random_test"]);
1044  $this->object->setEnableProcessingTime($data["enable_processing_time"]);
1045  $this->object->setResetProcessingTime($data["reset_processing_time"]);
1046  $this->object->setUsePreviousAnswers($data["use_previous_answers"]);
1047  $this->object->setTitleOutput($data["title_output"]);
1048 
1049  if ($this->object->isRandomTest())
1050  {
1051  $this->object->setUsePreviousAnswers(0);
1052  $this->object->setRandomTest(1);
1053  }
1054  if ($data["shuffle_questions"])
1055  {
1056  $this->object->setShuffleQuestions(TRUE);
1057  }
1058  else
1059  {
1060  $this->object->setShuffleQuestions(FALSE);
1061  }
1062  $this->object->setListOfQuestions($data["list_of_questions"]);
1063  $this->object->setListOfQuestionsStart($data["list_of_questions_start"]);
1064  $this->object->setListOfQuestionsEnd($data["list_of_questions_end"]);
1065  $this->object->setListOfQuestionsDescription($data["list_of_questions_with_description"]);
1066 
1067  $this->object->saveToDb(true);
1068 
1069  ilUtil::sendInfo($this->lng->txt("msg_obj_modified"));
1070  if ($randomtest_switch)
1071  {
1072  if ($this->object->isRandomTest())
1073  {
1074  $this->object->removeNonRandomTestData();
1075  }
1076  else
1077  {
1078  $this->object->removeRandomTestData();
1079  }
1080  }
1081  $this->ctrl->redirect($this, "properties");
1082  }
1083 
1092  {
1093  $total = $this->object->evalTotalPersons();
1094  // Check the values the user entered in the form
1095  if (!$total)
1096  {
1097  $data["count_system"] = $_POST["count_system"];
1098  $data["mc_scoring"] = $_POST["mc_scoring"];
1099  $data["score_cutting"] = $_POST["score_cutting"];
1100  $data["pass_scoring"] = $_POST["pass_scoring"];
1101  }
1102  else
1103  {
1104  $data["count_system"] = $this->object->getCountSystem();
1105  $data["mc_scoring"] = $this->object->getMCScoring();
1106  $data["score_cutting"] = $this->object->getScoreCutting();
1107  $data["pass_scoring"] = $this->object->getPassScoring();
1108  }
1109 
1110  $data["instant_feedback_solution"] = $_POST["chb_instant_feedback_solution"];
1111  $data["answer_feedback"] = ($_POST["chb_instant_feedback_answer"]) ? 1 : 0;
1112  $data["answer_feedback_points"] = ($_POST["chb_instant_feedback_results"]) ? 1 : 0;
1113 
1114  $data["show_solution_printview"] = ($_POST["chb_show_solution_printview"] == 1) ? 1 : 0;
1115  $data["show_solution_feedback"] = ($_POST["chb_show_solution_feedback"] == 1) ? 1 : 0;
1116  $data["show_solution_details"] = $_POST["chb_show_solution_details"];
1117  $data["show_solution_answers_only"] = $_POST["chb_show_solution_answers_only"];
1118  $data["show_solution_signature"] = $_POST["chb_show_solution_signature"];
1119  $data["show_pass_details"] = $_POST["chb_show_pass_details"];
1120  $data["results_access"] = $_POST["results_access"];
1121 
1122  $this->object->setCountSystem($data["count_system"]);
1123  $this->object->setMCScoring($data["mc_scoring"]);
1124  $this->object->setScoreCutting($data["score_cutting"]);
1125  $this->object->setPassScoring($data["pass_scoring"]);
1126  $this->object->setInstantFeedbackSolution($data["instant_feedback_solution"]);
1127  $this->object->setAnswerFeedback($data["answer_feedback"]);
1128  $this->object->setAnswerFeedbackPoints($data["answer_feedback_points"]);
1129  $this->object->setShowSolutionDetails($data["show_solution_details"]);
1130  $this->object->setShowSolutionAnswersOnly($data["show_solution_answers_only"]);
1131  $this->object->setShowSolutionSignature($data["show_solution_signature"]);
1132  $this->object->setShowPassDetails($data["show_pass_details"]);
1133  $this->object->setScoreReporting($data["results_access"]);
1134  $this->object->setShowSolutionPrintview($data["show_solution_printview"]);
1135  $this->object->setShowSolutionFeedback($data["show_solution_feedback"]);
1136  if ($data["results_access"] == REPORT_AFTER_DATE)
1137  {
1138  $data["reporting_date"] = sprintf("%04d%02d%02d%02d%02d%02d",
1139  $_POST["reporting_date"]["y"],
1140  $_POST["reporting_date"]["m"],
1141  $_POST["reporting_date"]["d"],
1142  $_POST["reporting_time"]["h"],
1143  $_POST["reporting_time"]["m"],
1144  0
1145  );
1146  $this->object->setReportingDate($data["reporting_date"]);
1147  }
1148  else
1149  {
1150  $this->object->setReportingDate("");
1151  }
1152  $this->object->saveToDb(true);
1153  ilUtil::sendInfo($this->lng->txt("msg_obj_modified"), TRUE);
1154 
1155  $this->ctrl->redirect($this, "scoring");
1156  }
1157 
1165  function scoringObject()
1166  {
1167  global $ilAccess;
1168  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
1169  {
1170  // allow only write access
1171  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
1172  $this->ctrl->redirect($this, "infoScreen");
1173  }
1174 
1175  $data["count_system"] = $this->object->getCountSystem();
1176  $data["mc_scoring"] = $this->object->getMCScoring();
1177  $data["score_cutting"] = $this->object->getScoreCutting();
1178  $data["pass_scoring"] = $this->object->getPassScoring();
1179  $data["instant_feedback_solution"] = $this->object->getInstantFeedbackSolution();
1180  $data["answer_feedback"] = $this->object->getAnswerFeedback();
1181  $data["answer_feedback_points"] = $this->object->getAnswerFeedbackPoints();
1182  $data["show_solution_printview"] = $this->object->getShowSolutionPrintview();
1183  $data["show_solution_feedback"] = $this->object->getShowSolutionFeedback();
1184  $data["show_solution_details"] = $this->object->getShowSolutionDetails();
1185  $data["show_solution_answers_only"] = $this->object->getShowSolutionAnswersOnly();
1186  $data["show_solution_signature"] = $this->object->getShowSolutionSignature();
1187  $data["show_pass_details"] = $this->object->getShowPassDetails();
1188  $data["results_access"] = $this->object->getScoreReporting();
1189 
1190  $total = $this->object->evalTotalPersons();
1191 
1192  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_scoring.html", "Modules/Test");
1193 
1194  $this->lng->loadLanguageModule("jscalendar");
1195  $this->tpl->addBlockFile("CALENDAR_LANG_JAVASCRIPT", "calendar_javascript", "tpl.calendar.html");
1196  $this->tpl->setCurrentBlock("calendar_javascript");
1197  $this->tpl->setVariable("FULL_SUNDAY", $this->lng->txt("l_su"));
1198  $this->tpl->setVariable("FULL_MONDAY", $this->lng->txt("l_mo"));
1199  $this->tpl->setVariable("FULL_TUESDAY", $this->lng->txt("l_tu"));
1200  $this->tpl->setVariable("FULL_WEDNESDAY", $this->lng->txt("l_we"));
1201  $this->tpl->setVariable("FULL_THURSDAY", $this->lng->txt("l_th"));
1202  $this->tpl->setVariable("FULL_FRIDAY", $this->lng->txt("l_fr"));
1203  $this->tpl->setVariable("FULL_SATURDAY", $this->lng->txt("l_sa"));
1204  $this->tpl->setVariable("SHORT_SUNDAY", $this->lng->txt("s_su"));
1205  $this->tpl->setVariable("SHORT_MONDAY", $this->lng->txt("s_mo"));
1206  $this->tpl->setVariable("SHORT_TUESDAY", $this->lng->txt("s_tu"));
1207  $this->tpl->setVariable("SHORT_WEDNESDAY", $this->lng->txt("s_we"));
1208  $this->tpl->setVariable("SHORT_THURSDAY", $this->lng->txt("s_th"));
1209  $this->tpl->setVariable("SHORT_FRIDAY", $this->lng->txt("s_fr"));
1210  $this->tpl->setVariable("SHORT_SATURDAY", $this->lng->txt("s_sa"));
1211  $this->tpl->setVariable("FULL_JANUARY", $this->lng->txt("l_01"));
1212  $this->tpl->setVariable("FULL_FEBRUARY", $this->lng->txt("l_02"));
1213  $this->tpl->setVariable("FULL_MARCH", $this->lng->txt("l_03"));
1214  $this->tpl->setVariable("FULL_APRIL", $this->lng->txt("l_04"));
1215  $this->tpl->setVariable("FULL_MAY", $this->lng->txt("l_05"));
1216  $this->tpl->setVariable("FULL_JUNE", $this->lng->txt("l_06"));
1217  $this->tpl->setVariable("FULL_JULY", $this->lng->txt("l_07"));
1218  $this->tpl->setVariable("FULL_AUGUST", $this->lng->txt("l_08"));
1219  $this->tpl->setVariable("FULL_SEPTEMBER", $this->lng->txt("l_09"));
1220  $this->tpl->setVariable("FULL_OCTOBER", $this->lng->txt("l_10"));
1221  $this->tpl->setVariable("FULL_NOVEMBER", $this->lng->txt("l_11"));
1222  $this->tpl->setVariable("FULL_DECEMBER", $this->lng->txt("l_12"));
1223  $this->tpl->setVariable("SHORT_JANUARY", $this->lng->txt("s_01"));
1224  $this->tpl->setVariable("SHORT_FEBRUARY", $this->lng->txt("s_02"));
1225  $this->tpl->setVariable("SHORT_MARCH", $this->lng->txt("s_03"));
1226  $this->tpl->setVariable("SHORT_APRIL", $this->lng->txt("s_04"));
1227  $this->tpl->setVariable("SHORT_MAY", $this->lng->txt("s_05"));
1228  $this->tpl->setVariable("SHORT_JUNE", $this->lng->txt("s_06"));
1229  $this->tpl->setVariable("SHORT_JULY", $this->lng->txt("s_07"));
1230  $this->tpl->setVariable("SHORT_AUGUST", $this->lng->txt("s_08"));
1231  $this->tpl->setVariable("SHORT_SEPTEMBER", $this->lng->txt("s_09"));
1232  $this->tpl->setVariable("SHORT_OCTOBER", $this->lng->txt("s_10"));
1233  $this->tpl->setVariable("SHORT_NOVEMBER", $this->lng->txt("s_11"));
1234  $this->tpl->setVariable("SHORT_DECEMBER", $this->lng->txt("s_12"));
1235  $this->tpl->setVariable("ABOUT_CALENDAR", $this->lng->txt("about_calendar"));
1236  $this->tpl->setVariable("ABOUT_CALENDAR_LONG", $this->lng->txt("about_calendar_long"));
1237  $this->tpl->setVariable("ABOUT_TIME_LONG", $this->lng->txt("about_time"));
1238  $this->tpl->setVariable("PREV_YEAR", $this->lng->txt("prev_year"));
1239  $this->tpl->setVariable("PREV_MONTH", $this->lng->txt("prev_month"));
1240  $this->tpl->setVariable("GO_TODAY", $this->lng->txt("go_today"));
1241  $this->tpl->setVariable("NEXT_MONTH", $this->lng->txt("next_month"));
1242  $this->tpl->setVariable("NEXT_YEAR", $this->lng->txt("next_year"));
1243  $this->tpl->setVariable("SEL_DATE", $this->lng->txt("select_date"));
1244  $this->tpl->setVariable("DRAG_TO_MOVE", $this->lng->txt("drag_to_move"));
1245  $this->tpl->setVariable("PART_TODAY", $this->lng->txt("part_today"));
1246  $this->tpl->setVariable("DAY_FIRST", $this->lng->txt("day_first"));
1247  $this->tpl->setVariable("CLOSE", $this->lng->txt("close"));
1248  $this->tpl->setVariable("TODAY", $this->lng->txt("today"));
1249  $this->tpl->setVariable("TIME_PART", $this->lng->txt("time_part"));
1250  $this->tpl->setVariable("DEF_DATE_FORMAT", $this->lng->txt("def_date_format"));
1251  $this->tpl->setVariable("TT_DATE_FORMAT", $this->lng->txt("tt_date_format"));
1252  $this->tpl->setVariable("WK", $this->lng->txt("wk"));
1253  $this->tpl->setVariable("TIME", $this->lng->txt("time"));
1254  $this->tpl->parseCurrentBlock();
1255  $this->tpl->setCurrentBlock("CalendarJS");
1256  $this->tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR", "./Modules/Test/js/calendar/calendar.js");
1257  $this->tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR_SETUP", "./Modules/Test/js/calendar/calendar-setup.js");
1258  $this->tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR_STYLESHEET", "./Modules/Test/js/calendar/calendar.css");
1259  $this->tpl->parseCurrentBlock();
1260  $this->tpl->setCurrentBlock("javascript_call_calendar");
1261  $this->tpl->setVariable("INPUT_FIELDS_REPORTING_DATE", "reporting_date");
1262  $this->tpl->parseCurrentBlock();
1263 
1264  $this->tpl->setVariable("HEADING_SCORING_AND_RESULTS", $this->lng->txt("scoring"));
1265  $this->tpl->setVariable("DEFAULT", "(" . $this->lng->txt("default") . ")");
1266  $this->tpl->setVariable("TEXT_COUNT_SYSTEM", $this->lng->txt("tst_text_count_system"));
1267  $this->tpl->setVariable("COUNT_PARTIAL_SOLUTIONS", $this->lng->txt("tst_count_partial_solutions"));
1268  $this->tpl->setVariable("COUNT_CORRECT_SOLUTIONS", $this->lng->txt("tst_count_correct_solutions"));
1269  $this->tpl->setVariable("COUNT_SYSTEM_DESCRIPTION", $this->lng->txt("tst_count_system_description"));
1270  switch ($data["count_system"])
1271  {
1273  $this->tpl->setVariable("CHECKED_COUNT_CORRECT_SOLUTIONS", " checked=\"checked\"");
1274  break;
1276  default:
1277  $this->tpl->setVariable("CHECKED_COUNT_PARTIAL_SOLUTIONS", " checked=\"checked\"");
1278  break;
1279  }
1280  if ($total)
1281  {
1282  $this->tpl->setVariable("DISABLED_COUNT_CORRECT_SOLUTIONS", " disabled=\"disabled\"");
1283  $this->tpl->setVariable("DISABLED_COUNT_PARTIAL_SOLUTIONS", " disabled=\"disabled\"");
1284  }
1285 
1286  $this->tpl->setVariable("TEXT_SCORE_MCMR", $this->lng->txt("tst_score_mcmr_questions"));
1287  $this->tpl->setVariable("ZERO_POINTS_WHEN_UNANSWERED", $this->lng->txt("tst_score_mcmr_zero_points_when_unanswered"));
1288  $this->tpl->setVariable("USE_SCORING_SYSTEM", $this->lng->txt("tst_score_mcmr_use_scoring_system"));
1289  $this->tpl->setVariable("TEXT_SCORE_MCMR_DESCRIPTION", $this->lng->txt("tst_score_mcmr_questions_description"));
1290  switch ($data["mc_scoring"])
1291  {
1293  $this->tpl->setVariable("CHECKED_ZERO_POINTS_WHEN_UNANSWERED", " checked=\"checked\"");
1294  break;
1296  default:
1297  $this->tpl->setVariable("CHECKED_USE_SCORING_SYSTEM", " checked=\"checked\"");
1298  break;
1299  }
1300  if ($total)
1301  {
1302  $this->tpl->setVariable("DISABLED_ZERO_POINTS_WHEN_UNANSWERED", " disabled=\"disabled\"");
1303  $this->tpl->setVariable("DISABLED_USE_SCORING_SYSTEM", " disabled=\"disabled\"");
1304  }
1305 
1306  $this->tpl->setVariable("TEXT_SCORE_CUTTING", $this->lng->txt("tst_score_cutting"));
1307  $this->tpl->setVariable("TEXT_CUT_QUESTION", $this->lng->txt("tst_score_cut_question"));
1308  $this->tpl->setVariable("TEXT_CUT_TEST", $this->lng->txt("tst_score_cut_test"));
1309  $this->tpl->setVariable("TEXT_SCORE_CUTTING_DESCRIPTION", $this->lng->txt("tst_score_cutting_description"));
1310  switch ($data["score_cutting"])
1311  {
1312  case SCORE_CUT_QUESTION:
1313  $this->tpl->setVariable("CHECKED_CUT_QUESTION", " checked=\"checked\"");
1314  break;
1315  case SCORE_CUT_TEST:
1316  default:
1317  $this->tpl->setVariable("CHECKED_CUT_TEST", " checked=\"checked\"");
1318  break;
1319  }
1320  if ($total)
1321  {
1322  $this->tpl->setVariable("DISABLED_CUT_QUESTION", " disabled=\"disabled\"");
1323  $this->tpl->setVariable("DISABLED_CUT_TEST", " disabled=\"disabled\"");
1324  }
1325 
1326  $this->tpl->setVariable("TEXT_PASS_SCORING", $this->lng->txt("tst_pass_scoring"));
1327  $this->tpl->setVariable("TEXT_LASTPASS", $this->lng->txt("tst_pass_last_pass"));
1328  $this->tpl->setVariable("TEXT_BESTPASS", $this->lng->txt("tst_pass_best_pass"));
1329  $this->tpl->setVariable("TEXT_PASS_SCORING_DESCRIPTION", $this->lng->txt("tst_pass_scoring_description"));
1330  switch ($data["pass_scoring"])
1331  {
1332  case SCORE_BEST_PASS:
1333  $this->tpl->setVariable("CHECKED_BESTPASS", " checked=\"checked\"");
1334  break;
1335  case SCORE_LAST_PASS:
1336  default:
1337  $this->tpl->setVariable("CHECKED_LASTPASS", " checked=\"checked\"");
1338  break;
1339  }
1340  if ($total)
1341  {
1342  $this->tpl->setVariable("DISABLED_BESTPASS", " disabled=\"disabled\"");
1343  $this->tpl->setVariable("DISABLED_LASTPASS", " disabled=\"disabled\"");
1344  }
1345 
1346  $this->tpl->setVariable("TEXT_INSTANT_FEEDBACK", $this->lng->txt("tst_instant_feedback"));
1347  $this->tpl->setVariable("TEXT_ANSWER_SPECIFIC_FEEDBACK", $this->lng->txt("tst_instant_feedback_answer_specific"));
1348  $this->tpl->setVariable("TEXT_SHOW_RESULTS", $this->lng->txt("tst_instant_feedback_results"));
1349  if ($data["answer_feedback_points"])
1350  {
1351  $this->tpl->setVariable("CHECKED_SHOW_RESULTS", " checked=\"checked\"");
1352  }
1353  $this->tpl->setVariable("TEXT_SHOW_SOLUTION", $this->lng->txt("tst_instant_feedback_solution"));
1354  $this->tpl->setVariable("TEXT_INSTANT_FEEDBACK_DESCRIPTION", $this->lng->txt("tst_instant_feedback_description"));
1355  if ($data["instant_feedback_solution"])
1356  {
1357  $this->tpl->setVariable("CHECKED_SHOW_SOLUTION", " checked=\"checked\"");
1358  }
1359  if ($data["answer_feedback"])
1360  {
1361  $this->tpl->setVariable("CHECKED_ANSWER_SPECIFIC_FEEDBACK", " checked=\"checked\"");
1362  }
1363  $this->tpl->setVariable("TEXT_RESULTS_PRESENTATION", $this->lng->txt("tst_results_presentation"));
1364  $this->tpl->setVariable("TEXT_SHOW_PASS_DETAILS", $this->lng->txt("tst_show_pass_details"));
1365  if ($data["show_pass_details"])
1366  {
1367  $this->tpl->setVariable("CHECKED_SHOW_PASS_DETAILS", " checked=\"checked\"");
1368  }
1369  $this->tpl->setVariable("TEXT_SHOW_SOLUTION_DETAILS", $this->lng->txt("tst_show_solution_details"));
1370  if ($data["show_solution_details"])
1371  {
1372  $this->tpl->setVariable("CHECKED_SHOW_SOLUTION_DETAILS", " checked=\"checked\"");
1373  }
1374  $this->tpl->setVariable("TEXT_SHOW_SOLUTION_ANSWERS_ONLY", $this->lng->txt("tst_show_solution_answers_only"));
1375  if ($data["show_solution_answers_only"])
1376  {
1377  $this->tpl->setVariable("CHECKED_SHOW_SOLUTION_ANSWERS_ONLY", " checked=\"checked\"");
1378  }
1379  $this->tpl->setVariable("TEXT_SHOW_SOLUTION_SIGNATURE", $this->lng->txt("tst_show_solution_signature"));
1380  if ($this->object->getAnonymity())
1381  {
1382  $this->tpl->setVariable("DISABLED_SHOW_SOLUTION_SIGNATURE", " disabled=\"disabled\"");
1383  }
1384  else
1385  {
1386  if ($data["show_solution_signature"])
1387  {
1388  $this->tpl->setVariable("CHECKED_SHOW_SOLUTION_SIGNATURE", " checked=\"checked\"");
1389  }
1390  }
1391 
1392  $this->tpl->setVariable("TEXT_SHOW_SOLUTION_FEEDBACK", $this->lng->txt("tst_show_solution_feedback"));
1393  if ($data["show_solution_feedback"])
1394  {
1395  $this->tpl->setVariable("CHECKED_SHOW_SOLUTION_FEEDBACK", " checked=\"checked\"");
1396  }
1397 
1398  $this->tpl->setVariable("TEXT_SHOW_SOLUTION_PRINTVIEW", $this->lng->txt("tst_show_solution_printview"));
1399  $this->tpl->setVariable("TEXT_RESULTS_PRESENTATION_DESCRIPTION", $this->lng->txt("tst_results_presentation_description"));
1400  if ($data["show_solution_printview"])
1401  {
1402  $this->tpl->setVariable("CHECKED_SHOW_SOLUTION_PRINTVIEW", " checked=\"checked\"");
1403  }
1404 
1405  $this->tpl->setVariable("TEXT_RESULTS_ACCESS", $this->lng->txt("tst_results_access"));
1406  $this->tpl->setVariable("TEXT_RESULTS_FINISHED", $this->lng->txt("tst_results_access_finished"));
1407  $this->tpl->setVariable("TEXT_RESULTS_DATE", $this->lng->txt("tst_results_access_date"));
1408  if ($data["results_access"] != REPORT_AFTER_DATE)
1409  {
1410  $report = getdate(time()+60*60*24*7);
1411  $date_input = ilUtil::makeDateSelect("reporting_date", $report["year"], $report["mon"], $report["mday"]);
1412  $time_input = ilUtil::makeTimeSelect("reporting_time", true, "12", "0", "0");
1413  } else {
1414  preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $this->object->getReportingDate(), $matches);
1415  $date_input = ilUtil::makeDateSelect("reporting_date", $matches[1], sprintf("%d", $matches[2]), sprintf("%d", $matches[3]));
1416  $time_input = ilUtil::makeTimeSelect("reporting_time", true, sprintf("%d", $matches[4]), sprintf("%d", $matches[5]), sprintf("%d", $matches[6]));
1417  }
1418  switch ($data["results_access"])
1419  {
1420  case REPORT_ALWAYS:
1421  $this->tpl->setVariable("CHECKED_RESULTS_ALWAYS", " checked=\"checked\"");
1422  break;
1423  case REPORT_AFTER_DATE:
1424  $this->tpl->setVariable("CHECKED_RESULTS_DATE", " checked=\"checked\"");
1425  break;
1426  case REPORT_AFTER_TEST:
1427  default:
1428  $this->tpl->setVariable("CHECKED_RESULTS_FINISHED", " checked=\"checked\"");
1429  break;
1430  }
1431  $this->tpl->setVariable("INPUT_REPORTING_DATE", $this->lng->txt("date") . ": " . $date_input . $this->lng->txt("time") . ": " . $time_input);
1432  $this->tpl->setVariable("IMG_REPORTING_DATE_CALENDAR", ilUtil::getImagePath("calendar.png"));
1433  $this->tpl->setVariable("TXT_REPORTING_DATE_CALENDAR", $this->lng->txt("open_calendar"));
1434  $this->tpl->setVariable("TEXT_RESULTS_ALWAYS", $this->lng->txt("tst_results_access_always"));
1435  $this->tpl->setVariable("TEXT_RESULTS_ACCESS_DESCRIPTION", $this->lng->txt("tst_results_access_description"));
1436 
1437  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1438  if ($ilAccess->checkAccess("write", "", $this->ref_id))
1439  {
1440  $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
1441  }
1442 
1443  $this->tpl->parseCurrentBlock();
1444  }
1445 
1453  function propertiesObject()
1454  {
1455  global $ilAccess;
1456  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
1457  {
1458  // allow only write access
1459  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
1460  $this->ctrl->redirect($this, "infoScreen");
1461  }
1462  // to set the command class for the default command after object creation to make the RTE editor switch work
1463  if (strlen($this->ctrl->getCmdClass()) == 0) $this->ctrl->setCmdClass("ilobjtestgui");
1464  include_once "./Services/RTE/classes/class.ilRTE.php";
1465  $rtestring = ilRTE::_getRTEClassname();
1466  include_once "./Services/RTE/classes/class.$rtestring.php";
1467  $rte = new $rtestring();
1468  include_once "./classes/class.ilObject.php";
1470  $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
1471  $rte->addRTESupport($obj_id, $obj_type, "assessment");
1472 
1473  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_properties.html", "Modules/Test");
1474  $this->lng->loadLanguageModule("jscalendar");
1475  $this->tpl->addBlockFile("CALENDAR_LANG_JAVASCRIPT", "calendar_javascript", "tpl.calendar.html");
1476  $this->tpl->setCurrentBlock("calendar_javascript");
1477  $this->tpl->setVariable("FULL_SUNDAY", $this->lng->txt("l_su"));
1478  $this->tpl->setVariable("FULL_MONDAY", $this->lng->txt("l_mo"));
1479  $this->tpl->setVariable("FULL_TUESDAY", $this->lng->txt("l_tu"));
1480  $this->tpl->setVariable("FULL_WEDNESDAY", $this->lng->txt("l_we"));
1481  $this->tpl->setVariable("FULL_THURSDAY", $this->lng->txt("l_th"));
1482  $this->tpl->setVariable("FULL_FRIDAY", $this->lng->txt("l_fr"));
1483  $this->tpl->setVariable("FULL_SATURDAY", $this->lng->txt("l_sa"));
1484  $this->tpl->setVariable("SHORT_SUNDAY", $this->lng->txt("s_su"));
1485  $this->tpl->setVariable("SHORT_MONDAY", $this->lng->txt("s_mo"));
1486  $this->tpl->setVariable("SHORT_TUESDAY", $this->lng->txt("s_tu"));
1487  $this->tpl->setVariable("SHORT_WEDNESDAY", $this->lng->txt("s_we"));
1488  $this->tpl->setVariable("SHORT_THURSDAY", $this->lng->txt("s_th"));
1489  $this->tpl->setVariable("SHORT_FRIDAY", $this->lng->txt("s_fr"));
1490  $this->tpl->setVariable("SHORT_SATURDAY", $this->lng->txt("s_sa"));
1491  $this->tpl->setVariable("FULL_JANUARY", $this->lng->txt("l_01"));
1492  $this->tpl->setVariable("FULL_FEBRUARY", $this->lng->txt("l_02"));
1493  $this->tpl->setVariable("FULL_MARCH", $this->lng->txt("l_03"));
1494  $this->tpl->setVariable("FULL_APRIL", $this->lng->txt("l_04"));
1495  $this->tpl->setVariable("FULL_MAY", $this->lng->txt("l_05"));
1496  $this->tpl->setVariable("FULL_JUNE", $this->lng->txt("l_06"));
1497  $this->tpl->setVariable("FULL_JULY", $this->lng->txt("l_07"));
1498  $this->tpl->setVariable("FULL_AUGUST", $this->lng->txt("l_08"));
1499  $this->tpl->setVariable("FULL_SEPTEMBER", $this->lng->txt("l_09"));
1500  $this->tpl->setVariable("FULL_OCTOBER", $this->lng->txt("l_10"));
1501  $this->tpl->setVariable("FULL_NOVEMBER", $this->lng->txt("l_11"));
1502  $this->tpl->setVariable("FULL_DECEMBER", $this->lng->txt("l_12"));
1503  $this->tpl->setVariable("SHORT_JANUARY", $this->lng->txt("s_01"));
1504  $this->tpl->setVariable("SHORT_FEBRUARY", $this->lng->txt("s_02"));
1505  $this->tpl->setVariable("SHORT_MARCH", $this->lng->txt("s_03"));
1506  $this->tpl->setVariable("SHORT_APRIL", $this->lng->txt("s_04"));
1507  $this->tpl->setVariable("SHORT_MAY", $this->lng->txt("s_05"));
1508  $this->tpl->setVariable("SHORT_JUNE", $this->lng->txt("s_06"));
1509  $this->tpl->setVariable("SHORT_JULY", $this->lng->txt("s_07"));
1510  $this->tpl->setVariable("SHORT_AUGUST", $this->lng->txt("s_08"));
1511  $this->tpl->setVariable("SHORT_SEPTEMBER", $this->lng->txt("s_09"));
1512  $this->tpl->setVariable("SHORT_OCTOBER", $this->lng->txt("s_10"));
1513  $this->tpl->setVariable("SHORT_NOVEMBER", $this->lng->txt("s_11"));
1514  $this->tpl->setVariable("SHORT_DECEMBER", $this->lng->txt("s_12"));
1515  $this->tpl->setVariable("ABOUT_CALENDAR", $this->lng->txt("about_calendar"));
1516  $this->tpl->setVariable("ABOUT_CALENDAR_LONG", $this->lng->txt("about_calendar_long"));
1517  $this->tpl->setVariable("ABOUT_TIME_LONG", $this->lng->txt("about_time"));
1518  $this->tpl->setVariable("PREV_YEAR", $this->lng->txt("prev_year"));
1519  $this->tpl->setVariable("PREV_MONTH", $this->lng->txt("prev_month"));
1520  $this->tpl->setVariable("GO_TODAY", $this->lng->txt("go_today"));
1521  $this->tpl->setVariable("NEXT_MONTH", $this->lng->txt("next_month"));
1522  $this->tpl->setVariable("NEXT_YEAR", $this->lng->txt("next_year"));
1523  $this->tpl->setVariable("SEL_DATE", $this->lng->txt("select_date"));
1524  $this->tpl->setVariable("DRAG_TO_MOVE", $this->lng->txt("drag_to_move"));
1525  $this->tpl->setVariable("PART_TODAY", $this->lng->txt("part_today"));
1526  $this->tpl->setVariable("DAY_FIRST", $this->lng->txt("day_first"));
1527  $this->tpl->setVariable("CLOSE", $this->lng->txt("close"));
1528  $this->tpl->setVariable("TODAY", $this->lng->txt("today"));
1529  $this->tpl->setVariable("TIME_PART", $this->lng->txt("time_part"));
1530  $this->tpl->setVariable("DEF_DATE_FORMAT", $this->lng->txt("def_date_format"));
1531  $this->tpl->setVariable("TT_DATE_FORMAT", $this->lng->txt("tt_date_format"));
1532  $this->tpl->setVariable("WK", $this->lng->txt("wk"));
1533  $this->tpl->setVariable("TIME", $this->lng->txt("time"));
1534  $this->tpl->parseCurrentBlock();
1535  $this->tpl->setCurrentBlock("CalendarJS");
1536  $this->tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR", "./Modules/Test/js/calendar/calendar.js");
1537  $this->tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR_SETUP", "./Modules/Test/js/calendar/calendar-setup.js");
1538  $this->tpl->setVariable("LOCATION_JAVASCRIPT_CALENDAR_STYLESHEET", "./Modules/Test/js/calendar/calendar.css");
1539  $this->tpl->parseCurrentBlock();
1540  $this->tpl->setCurrentBlock("javascript_call_calendar");
1541  $this->tpl->setVariable("INPUT_FIELDS_STARTING_DATE", "starting_date");
1542  $this->tpl->setVariable("INPUT_FIELDS_ENDING_DATE", "ending_date");
1543  $this->tpl->parseCurrentBlock();
1544 
1545  $customstyles = $this->object->getCustomStyles();
1546  if (is_array($customstyles) && count($customstyles) > 0)
1547  {
1548  foreach ($customstyles as $customstyle)
1549  {
1550  $this->tpl->setCurrentBlock("customstyle_option");
1551  $this->tpl->setVariable("VALUE_OPTION_CUSTOMSTYLE", $customstyle);
1552  $this->tpl->setVariable("TEXT_OPTION_CUSTOMSTYLE", $customstyle);
1553  if (strcmp($this->object->getCustomStyle(), $customstyle) == 0)
1554  {
1555  $this->tpl->setVariable("SELECTION_OPTION_CUSTOMSTYLE", " selected=\"selected\"");
1556  }
1557  $this->tpl->parseCurrentBlock();
1558  }
1559  $this->tpl->setCurrentBlock("customtyle");
1560  $this->tpl->setVariable("TEXT_CUSTOMSTYLE", $this->lng->txt("customstyle"));
1561  $this->tpl->setVariable("TEXT_NO_CUSTOMSTYLE", $this->lng->txt("no_selection"));
1562  $this->tpl->setVariable("TEXT_DESCRIPTION_CUSTOMSTYLE", $this->lng->txt("customstyle_description"));
1563  $this->tpl->parseCurrentBlock();
1564  }
1565 
1566  $total = $this->object->evalTotalPersons();
1567  $data["anonymity"] = $this->object->getAnonymity();
1568  $data["show_cancel"] = $this->object->getShowCancel();
1569  $data["show_marker"] = $this->object->getShowMarker();
1570  $data["introduction"] = $this->object->getIntroduction();
1571  $data["sequence_settings"] = $this->object->getSequenceSettings();
1572  $data["nr_of_tries"] = $this->object->getNrOfTries();
1573  $data["kiosk"] = $this->object->getKioskMode();
1574  $data["kiosk_title"] = $this->object->getShowKioskModeTitle();
1575  $data["kiosk_participant"] = $this->object->getShowKioskModeParticipant();
1576  $data["use_previous_answers"] = $this->object->getUsePreviousAnswers();
1577  $data["title_output"] = $this->object->getTitleOutput();
1578  $data["enable_processing_time"] = $this->object->getEnableProcessingTime();
1579  $data["reset_processing_time"] = $this->object->getResetProcessingTime();
1580  $data["processing_time"] = $this->object->getProcessingTime();
1581  $data["random_test"] = $this->object->isRandomTest();
1582  $data["password"] = $this->object->getPassword();
1583  $data["allowedUsers"] = $this->object->getAllowedUsers();
1584  $data["allowedUsersTimeGap"] = $this->object->getAllowedUsersTimeGap();
1585  if (!$this->object->getEnableProcessingTime())
1586  {
1587  $proc_time = $this->object->getEstimatedWorkingTime();
1588  $data["processing_time"] = sprintf("%02d:%02d:%02d",
1589  $proc_time["h"],
1590  $proc_time["m"],
1591  $proc_time["s"]
1592  );
1593  }
1594  $data["starting_time"] = $this->object->getStartingTime();
1595  $data["ending_time"] = $this->object->getEndingTime();
1596 
1597  $this->tpl->setCurrentBlock("starting_time");
1598  $this->tpl->setVariable("TEXT_STARTING_TIME", $this->lng->txt("tst_starting_time"));
1599  if (!$data["starting_time"])
1600  {
1601  $date_input = ilUtil::makeDateSelect("starting_date");
1602  $time_input = ilUtil::makeTimeSelect("starting_time");
1603  }
1604  else
1605  {
1606  preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $data["starting_time"], $matches);
1607  $date_input = ilUtil::makeDateSelect("starting_date", $matches[1], sprintf("%d", $matches[2]), sprintf("%d", $matches[3]));
1608  $time_input = ilUtil::makeTimeSelect("starting_time", true, sprintf("%d", $matches[4]), sprintf("%d", $matches[5]), sprintf("%d", $matches[6]));
1609  }
1610  $this->tpl->setVariable("IMG_STARTING_TIME_CALENDAR", ilUtil::getImagePath("calendar.png"));
1611  $this->tpl->setVariable("TXT_STARTING_TIME_CALENDAR", $this->lng->txt("open_calendar"));
1612  $this->tpl->setVariable("TXT_ENABLED", $this->lng->txt("enabled"));
1613  if ($data["starting_time"])
1614  {
1615  $this->tpl->setVariable("CHECKED_STARTING_TIME", " checked=\"checked\"");
1616  }
1617  $this->tpl->setVariable("INPUT_STARTING_TIME", $this->lng->txt("date") . ": " . $date_input . $this->lng->txt("time") . ": " . $time_input);
1618  $this->tpl->parseCurrentBlock();
1619 
1620  $this->tpl->setCurrentBlock("ending_time");
1621  $this->tpl->setVariable("TEXT_ENDING_TIME", $this->lng->txt("tst_ending_time"));
1622  if (!$data["ending_time"])
1623  {
1624  $date_input = ilUtil::makeDateSelect("ending_date");
1625  $time_input = ilUtil::makeTimeSelect("ending_time");
1626  }
1627  else
1628  {
1629  preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $data["ending_time"], $matches);
1630  $date_input = ilUtil::makeDateSelect("ending_date", $matches[1], sprintf("%d", $matches[2]), sprintf("%d", $matches[3]));
1631  $time_input = ilUtil::makeTimeSelect("ending_time", true, sprintf("%d", $matches[4]), sprintf("%d", $matches[5]), sprintf("%d", $matches[6]));
1632  }
1633  $this->tpl->setVariable("IMG_ENDING_TIME_CALENDAR", ilUtil::getImagePath("calendar.png"));
1634  $this->tpl->setVariable("TXT_ENDING_TIME_CALENDAR", $this->lng->txt("open_calendar"));
1635  $this->tpl->setVariable("TXT_ENABLED", $this->lng->txt("enabled"));
1636  if ($data["ending_time"])
1637  {
1638  $this->tpl->setVariable("CHECKED_ENDING_TIME", " checked=\"checked\"");
1639  }
1640  $this->tpl->setVariable("INPUT_ENDING_TIME", $this->lng->txt("date") . ": " . $date_input . $this->lng->txt("time") . ": " . $time_input);
1641  $this->tpl->parseCurrentBlock();
1642 
1643  $this->tpl->setCurrentBlock("adm_content");
1644  $this->tpl->setVariable("ACTION_PROPERTIES", $this->ctrl->getFormAction($this));
1645  if ($ilAccess->checkAccess("write", "", $this->ref_id))
1646  {
1647  $this->tpl->setVariable("SUBMIT_TYPE", $this->lng->txt("change"));
1648  }
1649  $this->tpl->setVariable("HEADING_GENERAL", $this->lng->txt("tst_general_properties"));
1650  $this->tpl->setVariable("TEXT_ANONYMITY", $this->lng->txt("tst_anonymity"));
1651  $this->tpl->setVariable("DESCRIPTION_ANONYMITY", $this->lng->txt("tst_anonymity_description"));
1652  if ($data["anonymity"])
1653  {
1654  $this->tpl->setVariable("CHECKED_ANONYMITY", " checked=\"checked\"");
1655  }
1656  if ($total)
1657  {
1658  $this->tpl->setVariable("DISABLED_ANONYMITY", " disabled=\"disabled\"");
1659  }
1660 
1661  $this->tpl->setVariable("TEXT_SHOW_MARKER", $this->lng->txt("question_marking"));
1662  $this->tpl->setVariable("TEXT_SHOW_MARKER_DESCRIPTION", $this->lng->txt("question_marking_description"));
1663  if ($data["show_marker"])
1664  {
1665  $this->tpl->setVariable("CHECKED_SHOW_MARKER", " checked=\"checked\"");
1666  }
1667 
1668  $this->tpl->setVariable("TEXT_SHOW_CANCEL", $this->lng->txt("tst_show_cancel"));
1669  $this->tpl->setVariable("TEXT_SHOW_CANCEL_DESCRIPTION", $this->lng->txt("tst_show_cancel_description"));
1670  if ($data["show_cancel"])
1671  {
1672  $this->tpl->setVariable("CHECKED_SHOW_CANCEL", " checked=\"checked\"");
1673  }
1674  $this->tpl->setVariable("TEXT_INTRODUCTION", $this->lng->txt("tst_introduction"));
1675  $this->tpl->setVariable("VALUE_INTRODUCTION", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($data["introduction"])));
1676  $this->tpl->setVariable("SHOWINFO", $this->lng->txt("showinfo"));
1677  $this->tpl->setVariable("SHOWINFO_DESC", $this->lng->txt("showinfo_desc"));
1678  if ($this->object->getShowInfo())
1679  {
1680  $this->tpl->setVariable("CHECKED_SHOWINFO", " checked=\"checked\"");
1681  }
1682  $this->tpl->setVariable("FINAL_STATEMENT", $this->lng->txt("final_statement"));
1683  $this->tpl->setVariable("VALUE_FINAL_STATEMENT", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($this->object->getFinalStatement())));
1684  $this->tpl->setVariable("FINAL_STATEMENT_SHOW", $this->lng->txt("final_statement_show"));
1685  $this->tpl->setVariable("FINAL_STATEMENT_SHOW_DESC", $this->lng->txt("final_statement_show_desc"));
1686  if ($this->object->getShowFinalStatement())
1687  {
1688  $this->tpl->setVariable("CHECKED_FINAL_STATEMENT_SHOW", " checked=\"checked\"");
1689  }
1690  $this->tpl->setVariable("HEADING_SEQUENCE", $this->lng->txt("tst_sequence_properties"));
1691  $this->tpl->setVariable("TEXT_POSTPONE", $this->lng->txt("tst_postpone"));
1692  $this->tpl->setVariable("TEXT_POSTPONE_DESCRIPTION", $this->lng->txt("tst_postpone_description"));
1693  if ($data["sequence_settings"] == 1)
1694  {
1695  $this->tpl->setVariable("CHECKED_POSTPONE", " checked=\"checked\"");
1696  }
1697  $this->tpl->setVariable("TEXT_SHUFFLE_QUESTIONS", $this->lng->txt("tst_shuffle_questions"));
1698  $this->tpl->setVariable("TEXT_SHUFFLE_QUESTIONS_DESCRIPTION", $this->lng->txt("tst_shuffle_questions_description"));
1699  if ($this->object->getShuffleQuestions())
1700  {
1701  $this->tpl->setVariable("CHECKED_SHUFFLE_QUESTIONS", " checked=\"checked\"");
1702  }
1703 
1704  $this->tpl->setVariable("TEXT_SHOW_SUMMARY", $this->lng->txt("tst_show_summary"));
1705  $this->tpl->setVariable("TEXT_SHOW_SUMMARY_DESCRIPTION", $this->lng->txt("tst_show_summary_description"));
1706  $this->tpl->setVariable("TEXT_NO", $this->lng->txt("no"));
1707  $this->tpl->setVariable("TEXT_YES", $this->lng->txt("tst_list_of_questions_yes"));
1708  $this->tpl->setVariable("TEXT_LIST_OF_QUESTIONS_START", $this->lng->txt("tst_list_of_questions_start"));
1709  $this->tpl->setVariable("TEXT_LIST_OF_QUESTIONS_END", $this->lng->txt("tst_list_of_questions_end"));
1710  $this->tpl->setVariable("TEXT_LIST_OF_QUESTIONS_WITH_DESCRIPTION", $this->lng->txt("tst_list_of_questions_with_description"));
1711  if ($this->object->getListOfQuestions())
1712  {
1713  $this->tpl->setVariable("CHECKED_LIST_OF_QUESTIONS_YES", " checked=\"checked\"");
1714  if ($this->object->getListOfQuestionsStart())
1715  {
1716  $this->tpl->setVariable("CHECKED_LIST_OF_QUESTIONS_START", " checked=\"checked\"");
1717  }
1718  if ($this->object->getListOfQuestionsEnd())
1719  {
1720  $this->tpl->setVariable("CHECKED_LIST_OF_QUESTIONS_END", " checked=\"checked\"");
1721  }
1722  if ($this->object->getListOfQuestionsDescription())
1723  {
1724  $this->tpl->setVariable("CHECKED_LIST_OF_QUESTIONS_WITH_DESCRIPTION", " checked=\"checked\"");
1725  }
1726  }
1727  else
1728  {
1729  $this->tpl->setVariable("CHECKED_LIST_OF_QUESTIONS_NO", " checked=\"checked\"");
1730  }
1731 
1732  $this->tpl->setVariable("TEXT_USE_PREVIOUS_ANSWERS", $this->lng->txt("tst_use_previous_answers"));
1733  $this->tpl->setVariable("TEXT_USE_PREVIOUS_ANSWERS_DESCRIPTION", $this->lng->txt("tst_use_previous_answers_description"));
1734 
1735  $this->tpl->setVariable("FORCEJS", $this->lng->txt("forcejs"));
1736  $this->tpl->setVariable("FORCEJS_SHORT", $this->lng->txt("forcejs_short"));
1737  $this->tpl->setVariable("FORCEJS_DESC", $this->lng->txt("forcejs_desc"));
1738  if ($this->object->getForceJS())
1739  {
1740  $this->tpl->setVariable("CHECKED_FORCEJS", " checked=\"checked\"");
1741  }
1742  $this->tpl->setVariable("TEXT_TITLE_OUTPUT", $this->lng->txt("tst_title_output"));
1743  $this->tpl->setVariable("TEXT_TITLE_OUTPUT_FULL", $this->lng->txt("tst_title_output_full"));
1744  $this->tpl->setVariable("TEXT_TITLE_OUTPUT_HIDE_POINTS", $this->lng->txt("tst_title_output_hide_points"));
1745  $this->tpl->setVariable("TEXT_TITLE_OUTPUT_NO_TITLE", $this->lng->txt("tst_title_output_no_title"));
1746  $this->tpl->setVariable("TEXT_TITLE_OUTPUT_DESCRIPTION", $this->lng->txt("tst_title_output_description"));
1747  switch ($data["title_output"])
1748  {
1749  case 1:
1750  $this->tpl->setVariable("CHECKED_TITLE_OUTPUT_HIDE_POINTS", " checked=\"checked\"");
1751  break;
1752  case 2:
1753  $this->tpl->setVariable("CHECKED_TITLE_OUTPUT_NO_TITLE", " checked=\"checked\"");
1754  break;
1755  case 0:
1756  default:
1757  $this->tpl->setVariable("CHECKED_TITLE_OUTPUT_FULL", " checked=\"checked\"");
1758  break;
1759  }
1760  if ($data["random_test"])
1761  {
1762  $data["use_previous_answers"] = 0;
1763  }
1764  if ($data["use_previous_answers"])
1765  {
1766  $this->tpl->setVariable("CHECKED_USE_PREVIOUS_ANSWERS", " checked=\"checked\"");
1767  }
1768  if ($data["random_test"])
1769  {
1770  $this->tpl->setVariable("DISABLE_USE_PREVIOUS_ANSWERS", " disabled=\"disabled\"");
1771  }
1772  $this->tpl->setVariable("HEADING_KIOSK", $this->lng->txt("kiosk"));
1773  $this->tpl->setVariable("TEXT_KIOSK", $this->lng->txt("kiosk"));
1774  if ($data["kiosk"])
1775  {
1776  $this->tpl->setVariable("CHECKED_KIOSK", " checked=\"checked\"");
1777  }
1778  $this->tpl->setVariable("TEXT_KIOSK_DESCRIPTION", $this->lng->txt("kiosk_description"));
1779  $this->tpl->setVariable("TEXT_KIOSK_OPTIONS", $this->lng->txt("kiosk_options"));
1780  $this->tpl->setVariable("TEXT_KIOSK_OPTIONS_DESCRIPTION", $this->lng->txt("kiosk_options_desc"));
1781  $this->tpl->setVariable("TEXT_KIOSK_TITLE", $this->lng->txt("kiosk_show_title"));
1782  if ($data["kiosk_title"])
1783  {
1784  $this->tpl->setVariable("CHECKED_KIOSK_TITLE", " checked=\"checked\"");
1785  }
1786  $this->tpl->setVariable("TEXT_KIOSK_PARTICIPANT", $this->lng->txt("kiosk_show_participant"));
1787  if ($data["kiosk_participant"])
1788  {
1789  $this->tpl->setVariable("CHECKED_KIOSK_PARTICIPANT", " checked=\"checked\"");
1790  }
1791  $this->tpl->setVariable("HEADING_SESSION", $this->lng->txt("tst_session_settings"));
1792  $this->tpl->setVariable("TEXT_NR_OF_TRIES", $this->lng->txt("tst_nr_of_tries"));
1793  $this->tpl->setVariable("VALUE_NR_OF_TRIES", $data["nr_of_tries"]);
1794  $this->tpl->setVariable("COMMENT_NR_OF_TRIES", $this->lng->txt("0_unlimited"));
1795  $this->tpl->setVariable("TXT_ENABLED", $this->lng->txt("enabled"));
1796  $this->tpl->setVariable("TXT_RESET_PROCESSING_TIME", $this->lng->txt("tst_reset_processing_time"));
1797  $this->tpl->setVariable("TEXT_RESET_PROCESSING_TIME_DESC", $this->lng->txt("tst_reset_processing_time_desc"));
1798  $this->tpl->setVariable("TEXT_PROCESSING_TIME", $this->lng->txt("tst_processing_time"));
1799  $this->tpl->setVariable("TEXT_PROCESSING_TIME_DESC", $this->lng->txt("tst_processing_time_desc"));
1800  $time_input = ilUtil::makeTimeSelect("processing_time", false, substr($data["processing_time"], 0, 2), substr($data["processing_time"], 3, 2), substr($data["processing_time"], 6, 2));
1801  $this->tpl->setVariable("MAX_PROCESSING_TIME", $time_input . " (hh:mm:ss)");
1802  if ($data["enable_processing_time"]) {
1803  $this->tpl->setVariable("CHECKED_PROCESSING_TIME", " checked=\"checked\"");
1804  }
1805  if ($data["reset_processing_time"])
1806  {
1807  $this->tpl->setVariable("CHECKED_RESET_PROCESSING_TIME", " checked=\"checked\"");
1808  }
1809  $this->tpl->setVariable("TEXT_RANDOM_TEST", $this->lng->txt("tst_random_selection"));
1810  $this->tpl->setVariable("TEXT_RANDOM_TEST_DESCRIPTION", $this->lng->txt("tst_random_test_description"));
1811  if ($data["random_test"])
1812  {
1813  $this->tpl->setVariable("CHECKED_RANDOM_TEST", " checked=\"checked\"");
1814  }
1815 
1816  $this->tpl->setVariable("TEXT_MAX_ALLOWED_USERS", $this->lng->txt("tst_max_allowed_users"));
1817  $this->tpl->setVariable("TEXT_ALLOWED_USERS", $this->lng->txt("tst_allowed_users"));
1818  $this->tpl->setVariable("TEXT_ALLOWED_USERS_TIME_GAP", $this->lng->txt("tst_allowed_users_time_gap"));
1819  if ($data["allowedUsers"] > 0)
1820  {
1821  $this->tpl->setVariable("VALUE_ALLOWED_USERS", " value=\"" . $data["allowedUsers"] . "\"");
1822  }
1823  $this->tpl->setVariable("TEXT_ALLOWED_USERS_TIME_GAP", $this->lng->txt("tst_allowed_users_time_gap"));
1824  if ($data["allowedUsersTimeGap"] > 0)
1825  {
1826  $this->tpl->setVariable("VALUE_ALLOWED_USERS_TIME_GAP", " value=\"" . $data["allowedUsersTimeGap"] . "\"");
1827  }
1828  $this->tpl->setVariable("SECONDS", $this->lng->txt("seconds"));
1829  $this->tpl->setVariable("TEXT_PASSWORD", $this->lng->txt("tst_password"));
1830  $this->tpl->setVariable("TEXT_PASSWORD_DETAILS", $this->lng->txt("tst_password_details"));
1831  if (strlen($data["password"]))
1832  {
1833  $this->tpl->setVariable("VALUE_PASSWORD", " value=\"". ilUtil::prepareFormOutput($data["password"])."\"");
1834  }
1835  if ($ilAccess->checkAccess("write", "", $this->ref_id))
1836  {
1837  $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
1838  }
1839  if ($total > 0)
1840  {
1841  $this->tpl->setVariable("ENABLED_RANDOM_TEST", " disabled=\"disabled\"");
1842  }
1843  $this->tpl->parseCurrentBlock();
1844  }
1845 
1850  {
1851  $file = explode("_", $_GET["file_id"]);
1852  include_once("./Modules/File/classes/class.ilObjFile.php");
1853  $fileObj =& new ilObjFile($file[count($file) - 1], false);
1854  $fileObj->sendFile();
1855  exit;
1856  }
1857 
1861  function fullscreenObject()
1862  {
1863  include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
1864  //$page =& new ilPageObject("qpl", $_GET["pg_id"]);
1865  $page_gui =& new ilPageObjectGUI("qpl", $_GET["pg_id"]);
1866  $page_gui->showMediaFullscreen();
1867 
1868  }
1869 
1874  {
1875  include_once("./Services/COPage/classes/class.ilPageObject.php");
1876  $pg_obj =& new ilPageObject("qpl", $_GET["pg_id"]);
1877  $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
1878  exit;
1879  }
1880 
1888  function filterObject()
1889  {
1890  $this->questionBrowser();
1891  }
1892 
1901  {
1902  $this->questionBrowser();
1903  }
1904 
1912  function backObject()
1913  {
1914  $this->ctrl->redirect($this, "questions");
1915  }
1916 
1925  {
1926  // insert selected questions into test
1927  $selected_array = array();
1928  foreach ($_POST as $key => $value)
1929  {
1930  if (preg_match("/cb_(\d+)/", $key, $matches))
1931  {
1932  array_push($selected_array, $matches[1]);
1933  }
1934  }
1935  if (!count($selected_array))
1936  {
1937  ilUtil::sendInfo($this->lng->txt("tst_insert_missing_question"), true);
1938  $this->ctrl->setParameterByClass(get_class($this), "sel_filter_type", $_POST["sel_filter_type"]);
1939  $this->ctrl->setParameterByClass(get_class($this), "sel_question_type", $_POST["sel_question_type"]);
1940  $this->ctrl->setParameterByClass(get_class($this), "sel_questionpool", $_POST["sel_questionpool"]);
1941  $this->ctrl->setParameterByClass(get_class($this), "filter_text", $_POST["filter_text"]);
1942  $this->ctrl->redirect($this, "browseForQuestions");
1943  }
1944  else
1945  {
1946  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
1947  $manscoring = FALSE;
1948  foreach ($selected_array as $key => $value)
1949  {
1950  $this->object->insertQuestion($value);
1951  if (!$manscoring)
1952  {
1953  $manscoring = $manscoring | assQuestion::_needsManualScoring($value);
1954  }
1955  }
1956  $this->object->saveCompleteStatus();
1957  if ($manscoring)
1958  {
1959  ilUtil::sendInfo($this->lng->txt("manscoring_hint"), TRUE);
1960  }
1961  else
1962  {
1963  ilUtil::sendInfo($this->lng->txt("tst_questions_inserted"), TRUE);
1964  }
1965  $this->ctrl->redirect($this, "questions");
1966  return;
1967  }
1968  }
1969 
1977  function questionBrowser()
1978  {
1979  global $ilAccess;
1980 
1981  $this->ctrl->setParameterByClass(get_class($this), "browse", "1");
1982  $textfilters = array();
1983  if (strcmp($this->ctrl->getCmd(), "resetFilter") == 0)
1984  {
1985  $filter_type = "";
1986  $filter_question_type = "";
1987  $filter_questionpool = "";
1988  $filter_text = "";
1989  }
1990  else
1991  {
1992  $filter_question_type = (array_key_exists("sel_question_type", $_POST)) ? $_POST["sel_question_type"] : $_GET["sel_question_type"];
1993  $filter_type = (array_key_exists("sel_filter_type", $_POST)) ? $_POST["sel_filter_type"] : $_GET["sel_filter_type"];
1994  $filter_questionpool = (array_key_exists("sel_questionpool", $_POST)) ? $_POST["sel_questionpool"] : $_GET["sel_questionpool"];
1995  $filter_text = (array_key_exists("filter_text", $_POST)) ? $_POST["filter_text"] : $_GET["filter_text"];
1996  }
1997 
1998  $filter_title = (array_key_exists("filter_title", $_POST)) ? $_POST["filter_title"] : $_GET["filter_title"];
1999  if (strlen($filter_title)) $textfilters["title"] = $filter_title;
2000  $filter_qpl = (array_key_exists("filter_qpl", $_POST)) ? $_POST["filter_qpl"] : $_GET["filter_qpl"];
2001  if (strlen($filter_qpl)) $textfilters["qpl"] = $filter_qpl;
2002  $filter_comment = (array_key_exists("filter_comment", $_POST)) ? $_POST["filter_comment"] : $_GET["filter_comment"];
2003  if (strlen($filter_comment)) $textfilters["comment"] = $filter_comment;
2004  $filter_author = (array_key_exists("filter_author", $_POST)) ? $_POST["filter_author"] : $_GET["filter_author"];
2005  if (strlen($filter_author)) $textfilters["author"] = $filter_author;
2006 
2007  $this->ctrl->setParameterByClass(get_class($this), "sel_filter_type", $filter_type);
2008  $this->ctrl->setParameterByClass(get_class($this), "sel_question_type", $filter_question_type);
2009  $this->ctrl->setParameterByClass(get_class($this), "sel_questionpool", $filter_questionpool);
2010  $this->ctrl->setParameterByClass(get_class($this), "filter_text", $filter_text);
2011  $this->ctrl->setParameterByClass(get_class($this), "filter_title", $filter_title);
2012  $this->ctrl->setParameterByClass(get_class($this), "filter_qpl", $filter_qpl);
2013  $this->ctrl->setParameterByClass(get_class($this), "filter_comment", $filter_comment);
2014  $this->ctrl->setParameterByClass(get_class($this), "filter_author", $filter_author);
2015 
2016  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_questionbrowser.html", "Modules/Test");
2017  $this->tpl->addBlockFile("A_BUTTONS", "a_buttons", "tpl.il_as_qpl_action_buttons.html", "Modules/Test");
2018  $this->tpl->addBlockFile("FILTER_QUESTION_MANAGER", "filter_questions", "tpl.il_as_tst_filter_questions.html", "Modules/Test");
2019 
2020  $questionpools =& $this->object->getAvailableQuestionpools(true);
2021  $filter_fields = array(
2022  "title" => $this->lng->txt("title"),
2023  "comment" => $this->lng->txt("description"),
2024  "author" => $this->lng->txt("author"),
2025  );
2026  $this->tpl->setCurrentBlock("filterrow");
2027  foreach ($filter_fields as $key => $value) {
2028  $this->tpl->setVariable("VALUE_FILTER_TYPE", "$key");
2029  $this->tpl->setVariable("NAME_FILTER_TYPE", "$value");
2030  if (strcmp($this->ctrl->getCmd(), "resetFilter") != 0)
2031  {
2032  if (strcmp($filter_type, $key) == 0)
2033  {
2034  $this->tpl->setVariable("VALUE_FILTER_SELECTED", " selected=\"selected\"");
2035  }
2036  }
2037  $this->tpl->parseCurrentBlock();
2038  }
2039 
2040  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
2041  $questiontypes =& ilObjQuestionPool::_getQuestionTypes();
2042  foreach ($questiontypes as $key => $value)
2043  {
2044  $this->tpl->setCurrentBlock("questiontype_row");
2045  $this->tpl->setVariable("VALUE_QUESTION_TYPE", $value["type_tag"]);
2046  $this->tpl->setVariable("TEXT_QUESTION_TYPE", $key);
2047  if (strcmp($filter_question_type, $value["type_tag"]) == 0)
2048  {
2049  $this->tpl->setVariable("SELECTED_QUESTION_TYPE", " selected=\"selected\"");
2050  }
2051  $this->tpl->parseCurrentBlock();
2052  }
2053 
2054  foreach ($questionpools as $key => $value)
2055  {
2056  $this->tpl->setCurrentBlock("questionpool_row");
2057  $this->tpl->setVariable("VALUE_QUESTIONPOOL", $key);
2058  $this->tpl->setVariable("TEXT_QUESTIONPOOL", $value["title"]);
2059  if (strcmp($filter_questionpool, $key) == 0)
2060  {
2061  $this->tpl->setVariable("SELECTED_QUESTIONPOOL", " selected=\"selected\"");
2062  }
2063  $this->tpl->parseCurrentBlock();
2064  }
2065 
2066  $this->tpl->setCurrentBlock("filter_questions");
2067  $this->tpl->setVariable("SHOW_QUESTION_TYPES", $this->lng->txt("filter_show_question_types"));
2068  $this->tpl->setVariable("TEXT_ALL_QUESTION_TYPES", $this->lng->txt("filter_all_question_types"));
2069  $this->tpl->setVariable("SHOW_QUESTIONPOOLS", $this->lng->txt("filter_show_questionpools"));
2070  $this->tpl->setVariable("TEXT_ALL_QUESTIONPOOLS", $this->lng->txt("filter_all_questionpools"));
2071  $this->tpl->setVariable("FILTER_TEXT", $this->lng->txt("filter"));
2072  $this->tpl->setVariable("TEXT_FILTER_BY", $this->lng->txt("by"));
2073  if (strcmp($this->ctrl->getCmd(), "resetFilter") != 0)
2074  {
2075  $this->tpl->setVariable("VALUE_FILTER_TEXT", $filter_text);
2076  }
2077  $this->tpl->setVariable("VALUE_SUBMIT_FILTER", $this->lng->txt("set_filter"));
2078  $this->tpl->setVariable("VALUE_RESET_FILTER", $this->lng->txt("reset_filter"));
2079  $this->tpl->parseCurrentBlock();
2080 
2081  $startrow = 0;
2082  if ($_GET["prevrow"])
2083  {
2084  $startrow = $_GET["prevrow"];
2085  }
2086  if ($_GET["nextrow"])
2087  {
2088  $startrow = $_GET["nextrow"];
2089  }
2090  if ($_GET["startrow"])
2091  {
2092  $startrow = $_GET["startrow"];
2093  }
2094  $sort = ($_GET["sort"]) ? $_GET["sort"] : "title";
2095  $sortorder = ($_GET["sortorder"]) ? $_GET["sortorder"] : "ASC";
2096  $this->ctrl->setParameter($this, "sort", $sort);
2097  $this->ctrl->setParameter($this, "sortorder", $sortorder);
2098  if (strlen($filter_text) && strlen($filter_type)) $textfilters[$filter_type] = $filter_text;
2099  $table = $this->object->getQuestionsTable($sort, $sortorder, $textfilters, $startrow, 1, $filter_question_type, $filter_questionpool);
2100  // display all questions in accessable question pools
2101  $colors = array("tblrow1", "tblrow2");
2102  $counter = 0;
2103  $existing_questions =& $this->object->getExistingQuestions();
2104  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
2105  if ((is_array($table["rows"])) && (count($table["rows"])))
2106  {
2107  foreach ($table["rows"] as $data)
2108  {
2109  if (!in_array($data["question_id"], $existing_questions))
2110  {
2111  if ($data["complete"])
2112  {
2113  // make only complete questions selectable
2114  $this->tpl->setCurrentBlock("checkable");
2115  $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
2116  $this->tpl->parseCurrentBlock();
2117  }
2118  $this->tpl->setCurrentBlock("QTab");
2119  $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
2120  $this->tpl->setVariable("QUESTION_TITLE", "<strong>" . $data["title"] . "</strong>");
2121  $this->tpl->setVariable("PREVIEW", "[<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&preview=" . $data["question_id"] . "\">" . $this->lng->txt("preview") . "</a>]");
2122  $this->tpl->setVariable("QUESTION_COMMENT", $data["comment"]);
2123  $this->tpl->setVariable("QUESTION_TYPE", assQuestion::_getQuestionTypeName($data["type_tag"]));
2124  $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
2125  $this->tpl->setVariable("QUESTION_CREATED", ilDatePresentation::formatDate(new ilDate($data['created'],IL_CAL_TIMESTAMP)));
2126  $this->tpl->setVariable("QUESTION_UPDATED", ilDatePresentation::formatDate(new ilDate($data['timestamp14'],IL_CAL_TIMESTAMP)));
2127  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
2128  $this->tpl->setVariable("QUESTION_POOL", $questionpools[$data["obj_fi"]]["title"]);
2129  $this->tpl->parseCurrentBlock();
2130  $counter++;
2131  }
2132  }
2133 
2134  if ($table["rowcount"] > count($table["rows"]))
2135  {
2136  $nextstep = $table["nextrow"] + $table["step"];
2137  if ($nextstep > $table["rowcount"])
2138  {
2139  $nextstep = $table["rowcount"];
2140  }
2141  $counter = 1;
2142  for ($i = 0; $i < $table["rowcount"]; $i += $table["step"])
2143  {
2144  $this->tpl->setCurrentBlock("pages");
2145  if ($table["startrow"] == $i)
2146  {
2147  $this->tpl->setVariable("PAGE_NUMBER", "<span class=\"inactivepage\">$counter</span>");
2148  }
2149  else
2150  {
2151  $this->tpl->setVariable("PAGE_NUMBER", "<a href=\"" . $this->ctrl->getLinkTarget($this, "browseForQuestions") . "&nextrow=$i" . "\">$counter</a>");
2152  }
2153  $this->tpl->parseCurrentBlock();
2154  $counter++;
2155  }
2156  $this->tpl->setCurrentBlock("navigation_bottom");
2157  $this->tpl->setVariable("TEXT_ITEM", $this->lng->txt("item"));
2158  $this->tpl->setVariable("TEXT_ITEM_START", $table["startrow"] + 1);
2159  $end = $table["startrow"] + $table["step"];
2160  if ($end > $table["rowcount"])
2161  {
2162  $end = $table["rowcount"];
2163  }
2164  $this->tpl->setVariable("TEXT_ITEM_END", $end);
2165  $this->tpl->setVariable("TEXT_OF", strtolower($this->lng->txt("of")));
2166  $this->tpl->setVariable("TEXT_ITEM_COUNT", $table["rowcount"]);
2167  $this->tpl->setVariable("TEXT_PREVIOUS", $this->lng->txt("previous"));
2168  $this->tpl->setVariable("TEXT_NEXT", $this->lng->txt("next"));
2169  $this->tpl->setVariable("HREF_PREV_ROWS", $this->ctrl->getLinkTarget($this, "browseForQuestions") . "&prevrow=" . $table["prevrow"]);
2170  $this->tpl->setVariable("HREF_NEXT_ROWS", $this->ctrl->getLinkTarget($this, "browseForQuestions") . "&nextrow=" . $table["nextrow"]);
2171  $this->tpl->parseCurrentBlock();
2172  }
2173  }
2174 
2175  // if there are no questions, display a message
2176  if (!((is_array($table["rows"])) && (count($table["rows"]))))
2177  {
2178  $this->tpl->setCurrentBlock("Emptytable");
2179  $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("no_questions_available"));
2180  $this->tpl->parseCurrentBlock();
2181  }
2182  else
2183  {
2184  // create edit buttons & table footer
2185  $this->tpl->setCurrentBlock("selection");
2186  $this->tpl->setVariable("INSERT", $this->lng->txt("insert"));
2187  $this->tpl->parseCurrentBlock();
2188 
2189  $this->tpl->setCurrentBlock("selectall");
2190  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
2191  $counter++;
2192  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
2193  $this->tpl->parseCurrentBlock();
2194 
2195  $this->tpl->setCurrentBlock("Footer");
2196  $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\"/>");
2197  $this->tpl->parseCurrentBlock();
2198  }
2199  // define the sort column parameters
2200  $sortarray = array(
2201  "title" => (strcmp($sort, "title") == 0) ? $sortorder : "",
2202  "comment" => (strcmp($sort, "comment") == 0) ? $sortorder : "",
2203  "type" => (strcmp($sort, "type") == 0) ? $sortorder : "",
2204  "author" => (strcmp($sort, "author") == 0) ? $sortorder : "",
2205  "created" => (strcmp($sort, "created") == 0) ? $sortorder : "",
2206  "updated" => (strcmp($sort, "updated") == 0) ? $sortorder : "",
2207  "qpl" => (strcmp($sort, "qpl") == 0) ? $sortorder : ""
2208  );
2209  foreach ($sortarray as $key => $value)
2210  {
2211  if (strcmp($value, "ASC") == 0)
2212  {
2213  $sortarray[$key] = "DESC";
2214  }
2215  else
2216  {
2217  $sortarray[$key] = "ASC";
2218  }
2219  }
2220 
2221  // add imports for YUI menu
2222  include_once "./Services/YUI/classes/class.ilYuiUtil.php";
2224  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "tpl.text_filter.css", "Modules/TestQuestionPool"));
2225 
2226  // add title text filter
2227  $titlefilter = new ilTemplate("tpl.text_filter.js", TRUE, TRUE, "Modules/TestQuestionPool");
2228  $titlefilter->setVariable("FILTERELEMENTID", "titlefilter");
2229  $titlefilter->setVariable("OVERLAY_WIDTH", "500px");
2230  $titlefilter->setVariable("OVERLAY_HEIGHT", "5em");
2231  $titlefilter->setVariable("TEXTFIELD_NAME", "filter_title");
2232  $titlefilter->setVariable("IMAGE_CLOSE", ilUtil::getImagePath("icon_close2_s.gif"));
2233  $titlefilter->setVariable("ALT_CLOSE", $this->lng->txt("close"));
2234  $titlefilter->setVariable("TITLE_CLOSE", $this->lng->txt("close"));
2235  $titlefilter->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "filter"));
2236  $titlefilter->setVariable("VALUE_FILTER_TEXT", $filter_title);
2237  $titlefilter->setVariable("VALUE_SUBMIT_FILTER", $this->lng->txt("set_filter"));
2238  $titlefilter->setVariable("VALUE_RESET_FILTER", $this->lng->txt("reset_filter"));
2239  $this->tpl->setCurrentBlock("HeadContent");
2240  $this->tpl->setVariable("CONTENT_BLOCK", $titlefilter->get());
2241  $this->tpl->parseCurrentBlock();
2242 
2243  // add questiontype filter
2244  $filtermenu = new ilTemplate("tpl.question_type_menu.js", TRUE, TRUE, "Modules/TestQuestionPool");
2245  if (strcmp($filter_question_type, "") == 0)
2246  {
2247  $filtermenu->setCurrentBlock("selected");
2248  $filtermenu->touchBlock("selected");
2249  $filtermenu->parseCurrentBlock();
2250  }
2251  $filtermenu->setCurrentBlock("menuitem");
2252  $filtermenu->setVariable("ITEM_TEXT", $this->lng->txt("filter_all_question_types"));
2253  $this->ctrl->setParameter($this, "sel_question_type", "");
2254  $this->ctrl->setParameter($this, "sort", $sort);
2255  $this->ctrl->setParameter($this, "sortorder", $sortorder);
2256  $filtermenu->setVariable("ITEM_URL", $this->ctrl->getLinkTarget($this, "browseForQuestions"));
2257  $filtermenu->parseCurrentBlock();
2258  foreach ($questiontypes as $key => $value)
2259  {
2260  if (strcmp($filter_question_type, $value["type_tag"]) == 0)
2261  {
2262  $filtermenu->setCurrentBlock("selected");
2263  $filtermenu->touchBlock("selected");
2264  $filtermenu->parseCurrentBlock();
2265  }
2266  $filtermenu->setCurrentBlock("menuitem");
2267  $filtermenu->setVariable("VALUE_QUESTION_TYPE", $value["type_tag"]);
2268  $filtermenu->setVariable("ITEM_TEXT", $key);
2269  $this->ctrl->setParameter($this, "sel_question_type", $value["type_tag"]);
2270  $filtermenu->setVariable("ITEM_URL", $this->ctrl->getLinkTarget($this, "browseForQuestions"));
2271  $filtermenu->parseCurrentBlock();
2272  }
2273  $this->ctrl->setParameter($this, "sel_question_type", $filter_question_type);
2274  $this->tpl->setCurrentBlock("HeadContent");
2275  $this->tpl->setVariable("CONTENT_BLOCK", $filtermenu->get());
2276  $this->tpl->parseCurrentBlock();
2277 
2278  // add description text filter
2279  $commenttextfilter = new ilTemplate("tpl.text_filter.js", TRUE, TRUE, "Modules/TestQuestionPool");
2280  $commenttextfilter->setVariable("FILTERELEMENTID", "commenttextfilter");
2281  $commenttextfilter->setVariable("OVERLAY_WIDTH", "500px");
2282  $commenttextfilter->setVariable("OVERLAY_HEIGHT", "8em");
2283  $commenttextfilter->setVariable("TEXTFIELD_NAME", "filter_comment");
2284  $commenttextfilter->setVariable("IMAGE_CLOSE", ilUtil::getImagePath("icon_close2_s.gif"));
2285  $commenttextfilter->setVariable("ALT_CLOSE", $this->lng->txt("close"));
2286  $commenttextfilter->setVariable("TITLE_CLOSE", $this->lng->txt("close"));
2287  $commenttextfilter->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "filter"));
2288  $commenttextfilter->setVariable("VALUE_FILTER_TEXT", $filter_comment);
2289  $commenttextfilter->setVariable("VALUE_SUBMIT_FILTER", $this->lng->txt("set_filter"));
2290  $commenttextfilter->setVariable("VALUE_RESET_FILTER", $this->lng->txt("reset_filter"));
2291  $this->tpl->setCurrentBlock("HeadContent");
2292  $this->tpl->setVariable("CONTENT_BLOCK", $commenttextfilter->get());
2293  $this->tpl->parseCurrentBlock();
2294 
2295  // add author text filter
2296  $authortextfilter = new ilTemplate("tpl.text_filter.js", TRUE, TRUE, "Modules/TestQuestionPool");
2297  $authortextfilter->setVariable("FILTERELEMENTID", "authortextfilter");
2298  $authortextfilter->setVariable("OVERLAY_WIDTH", "500px");
2299  $authortextfilter->setVariable("OVERLAY_HEIGHT", "5em");
2300  $authortextfilter->setVariable("TEXTFIELD_NAME", "filter_author");
2301  $authortextfilter->setVariable("IMAGE_CLOSE", ilUtil::getImagePath("icon_close2_s.gif"));
2302  $authortextfilter->setVariable("ALT_CLOSE", $this->lng->txt("close"));
2303  $authortextfilter->setVariable("TITLE_CLOSE", $this->lng->txt("close"));
2304  $authortextfilter->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "filter"));
2305  $authortextfilter->setVariable("VALUE_FILTER_TEXT", $filter_author);
2306  $authortextfilter->setVariable("VALUE_SUBMIT_FILTER", $this->lng->txt("set_filter"));
2307  $authortextfilter->setVariable("VALUE_RESET_FILTER", $this->lng->txt("reset_filter"));
2308  $this->tpl->setCurrentBlock("HeadContent");
2309  $this->tpl->setVariable("CONTENT_BLOCK", $authortextfilter->get());
2310  $this->tpl->parseCurrentBlock();
2311 
2312  // add question pool text filter
2313  $qpltextfilter = new ilTemplate("tpl.text_filter.js", TRUE, TRUE, "Modules/TestQuestionPool");
2314  $qpltextfilter->setVariable("FILTERELEMENTID", "qpltextfilter");
2315  $qpltextfilter->setVariable("OVERLAY_WIDTH", "500px");
2316  $qpltextfilter->setVariable("OVERLAY_HEIGHT", "5em");
2317  $qpltextfilter->setVariable("TEXTFIELD_NAME", "filter_qpl");
2318  $qpltextfilter->setVariable("IMAGE_CLOSE", ilUtil::getImagePath("icon_close2_s.gif"));
2319  $qpltextfilter->setVariable("ALT_CLOSE", $this->lng->txt("close"));
2320  $qpltextfilter->setVariable("TITLE_CLOSE", $this->lng->txt("close"));
2321  $qpltextfilter->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "filter"));
2322  $qpltextfilter->setVariable("VALUE_FILTER_TEXT", $filter_qpl);
2323  $qpltextfilter->setVariable("VALUE_SUBMIT_FILTER", $this->lng->txt("set_filter"));
2324  $qpltextfilter->setVariable("VALUE_RESET_FILTER", $this->lng->txt("reset_filter"));
2325  $this->tpl->setCurrentBlock("HeadContent");
2326  $this->tpl->setVariable("CONTENT_BLOCK", $qpltextfilter->get());
2327  $this->tpl->parseCurrentBlock();
2328 
2329  $this->tpl->setCurrentBlock("adm_content");
2330  $this->ctrl->setCmd("questionBrowser");
2331  $this->ctrl->setParameterByClass(get_class($this), "startrow", $table["startrow"]);
2332  $template = new ilTemplate("tpl.image.html", true, true);
2333  if (strlen($filter_title))
2334  {
2335  $template->setVariable("IMAGE_SOURCE", ilUtil::getImagePath("search-filter-locked.png"));
2336  }
2337  else
2338  {
2339  $template->setVariable("IMAGE_SOURCE", ilUtil::getImagePath("search-filter.png"));
2340  }
2341  $template->setVariable("IMAGE_TITLE", $this->lng->txt("filter"));
2342  $template->setVariable("IMAGE_ALT", $this->lng->txt("filter"));
2343  $template->setVariable("ID", "titlefilter");
2344  $template->setVariable("STYLE", "visibility: hidden; cursor: pointer");
2345  $this->ctrl->setParameter($this, "sort", "title");
2346  $this->ctrl->setParameter($this, "sortorder", $sortarray["title"]);
2347  $questiontitle = "<a href=\"" . $this->ctrl->getLinkTarget($this, "browseForQuestions") . "\">" . $this->lng->txt("title") . "</a>";
2348  $questiontitle .= $template->get();
2349  $questiontitle .= $table["images"]["title"];
2350  $this->tpl->setVariable("QUESTION_TITLE", $questiontitle);
2351  $this->ctrl->setParameter($this, "sort", "comment");
2352  $this->ctrl->setParameter($this, "sortorder", $sortarray["comment"]);
2353  $template = new ilTemplate("tpl.image.html", true, true);
2354  if (strlen($filter_comment))
2355  {
2356  $template->setVariable("IMAGE_SOURCE", ilUtil::getImagePath("search-filter-locked.png"));
2357  }
2358  else
2359  {
2360  $template->setVariable("IMAGE_SOURCE", ilUtil::getImagePath("search-filter.png"));
2361  }
2362  $template->setVariable("IMAGE_TITLE", $this->lng->txt("filter"));
2363  $template->setVariable("IMAGE_ALT", $this->lng->txt("filter"));
2364  $template->setVariable("ID", "commenttextfilter");
2365  $template->setVariable("STYLE", "visibility: hidden; cursor: pointer");
2366  $this->ctrl->setParameter($this, "sort", "comment");
2367  $this->ctrl->setParameter($this, "sortorder", $sortarray["comment"]);
2368  $questiontype = "<a href=\"" . $this->ctrl->getLinkTarget($this, "browseForQuestions") . "\">" . $this->lng->txt("description") . "</a>";
2369  $questiontype .= $template->get();
2370  $questiontype .= $table["images"]["comment"];
2371  $this->tpl->setVariable("QUESTION_COMMENT", $questiontype);
2372  $template = new ilTemplate("tpl.image.html", true, true);
2373  if (strlen($filter_question_type))
2374  {
2375  $template->setVariable("IMAGE_SOURCE", ilUtil::getImagePath("search-filter-locked.png"));
2376  }
2377  else
2378  {
2379  $template->setVariable("IMAGE_SOURCE", ilUtil::getImagePath("search-filter.png"));
2380  }
2381  $template->setVariable("IMAGE_TITLE", $this->lng->txt("filter"));
2382  $template->setVariable("IMAGE_ALT", $this->lng->txt("filter"));
2383  $template->setVariable("ID", "filter");
2384  $template->setVariable("STYLE", "visibility: hidden; cursor: pointer");
2385  $this->ctrl->setParameter($this, "sort", "type");
2386  $this->ctrl->setParameter($this, "sortorder", $sortarray["type"]);
2387  $questiontype = "<a href=\"" . $this->ctrl->getLinkTarget($this, "browseForQuestions") . "\">" . $this->lng->txt("question_type") . "</a>";
2388  $questiontype .= $template->get();
2389  $questiontype .= $table["images"]["type"];
2390  $this->tpl->setVariable("QUESTION_TYPE", $questiontype);
2391  $template = new ilTemplate("tpl.image.html", true, true);
2392  if (strlen($filter_author))
2393  {
2394  $template->setVariable("IMAGE_SOURCE", ilUtil::getImagePath("search-filter-locked.png"));
2395  }
2396  else
2397  {
2398  $template->setVariable("IMAGE_SOURCE", ilUtil::getImagePath("search-filter.png"));
2399  }
2400  $template->setVariable("IMAGE_TITLE", $this->lng->txt("filter"));
2401  $template->setVariable("IMAGE_ALT", $this->lng->txt("filter"));
2402  $template->setVariable("ID", "authortextfilter");
2403  $template->setVariable("STYLE", "visibility: hidden; cursor: pointer;");
2404  $this->ctrl->setParameter($this, "sort", "author");
2405  $this->ctrl->setParameter($this, "sortorder", $sortarray["author"]);
2406  $questiontype = "<a href=\"" . $this->ctrl->getLinkTarget($this, "browseForQuestions") . "\">" . $this->lng->txt("author") . "</a>";
2407  $questiontype .= $template->get();
2408  $questiontype .= $table["images"]["author"];
2409  $this->tpl->setVariable("QUESTION_AUTHOR", $questiontype);
2410  $this->ctrl->setParameter($this, "sort", "created");
2411  $this->ctrl->setParameter($this, "sortorder", $sortarray["created"]);
2412  $this->tpl->setVariable("QUESTION_CREATED", "<a href=\"" . $this->ctrl->getLinkTarget($this, "browseForQuestions") . "\">" . $this->lng->txt("create_date") . "</a>" . $table["images"]["created"]);
2413  $this->ctrl->setParameter($this, "sort", "updated");
2414  $this->ctrl->setParameter($this, "sortorder", $sortarray["updated"]);
2415  $this->tpl->setVariable("QUESTION_UPDATED", "<a href=\"" . $this->ctrl->getLinkTarget($this, "browseForQuestions") . "\">" . $this->lng->txt("last_update") . "</a>" . $table["images"]["updated"]);
2416  $template = new ilTemplate("tpl.image.html", true, true);
2417  if (strlen($filter_qpl))
2418  {
2419  $template->setVariable("IMAGE_SOURCE", ilUtil::getImagePath("search-filter-locked.png"));
2420  }
2421  else
2422  {
2423  $template->setVariable("IMAGE_SOURCE", ilUtil::getImagePath("search-filter.png"));
2424  }
2425  $template->setVariable("IMAGE_TITLE", $this->lng->txt("filter"));
2426  $template->setVariable("IMAGE_ALT", $this->lng->txt("filter"));
2427  $template->setVariable("ID", "qpltextfilter");
2428  $template->setVariable("STYLE", "visibility: hidden; cursor: pointer");
2429  $this->ctrl->setParameter($this, "sort", "qpl");
2430  $this->ctrl->setParameter($this, "sortorder", $sortarray["qpl"]);
2431  $qpfilter = "<a href=\"" . $this->ctrl->getLinkTarget($this, "browseForQuestions") . "\">" . $this->lng->txt("obj_qpl") . "</a>";
2432  $qpfilter .= $template->get();
2433  $qpfilter .= $table["images"]["qpl"];
2434  $this->tpl->setVariable("QUESTION_POOL", $qpfilter);
2435  $this->tpl->setVariable("BUTTON_BACK", $this->lng->txt("back"));
2436  $this->ctrl->setParameter($this, "sort", $sort);
2437  $this->ctrl->setParameter($this, "sortorder", $sortorder);
2438  $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this));
2439  $this->tpl->parseCurrentBlock();
2440  }
2441 
2450  function createQuestionPool($name = "dummy")
2451  {
2452  global $tree;
2453  $parent_ref = $tree->getParentId($this->object->getRefId());
2454  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
2455  $qpl = new ilObjQuestionPool();
2456  $qpl->setType("qpl");
2457  $qpl->setTitle($name);
2458  $qpl->setDescription("");
2459  $qpl->create();
2460  $qpl->createReference();
2461  $qpl->putInTree($parent_ref);
2462  $qpl->setPermissions($parent_ref);
2463  $qpl->setOnline(1); // must be online to be available
2464  $qpl->saveToDb();
2465  return $qpl->getRefId();
2466  }
2467 
2476  {
2477  global $ilUser;
2478  $this->getQuestionsSubTabs();
2479  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_random_select.html", "Modules/Test");
2480  $questionpools =& $this->object->getAvailableQuestionpools(FALSE, FALSE, FALSE, TRUE);
2481  $this->tpl->setCurrentBlock("option");
2482  $this->tpl->setVariable("VALUE_OPTION", "0");
2483  $this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("all_available_question_pools"));
2484  $this->tpl->parseCurrentBlock();
2485  foreach ($questionpools as $key => $value)
2486  {
2487  $this->tpl->setCurrentBlock("option");
2488  $this->tpl->setVariable("VALUE_OPTION", $key);
2489  $this->tpl->setVariable("TEXT_OPTION", $value["title"]);
2490  $this->tpl->parseCurrentBlock();
2491  }
2492  $this->tpl->setCurrentBlock("hidden");
2493  $this->tpl->setVariable("HIDDEN_NAME", "sel_question_types");
2494  $this->tpl->setVariable("HIDDEN_VALUE", $_POST["sel_question_types"]);
2495  $this->tpl->parseCurrentBlock();
2496  $this->tpl->setCurrentBlock("adm_content");
2497  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
2498  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_random_select_questionpool"));
2499  $this->tpl->setVariable("TXT_NR_OF_QUESTIONS", $this->lng->txt("tst_random_nr_of_questions"));
2500  $this->tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit"));
2501  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
2502  $this->tpl->parseCurrentBlock();
2503  }
2504 
2513  {
2514  $this->ctrl->redirect($this, "questions");
2515  }
2516 
2525  {
2526  $this->getQuestionsSubTabs();
2527  $question_array = $this->object->randomSelectQuestions($_POST["nr_of_questions"], $_POST["sel_qpl"]);
2528  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_random_question_offer.html", "Modules/Test");
2529  $color_class = array("tblrow1", "tblrow2");
2530  $counter = 0;
2531  $questionpools =& $this->object->getAvailableQuestionpools(true);
2532  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
2533  foreach ($question_array as $question_id)
2534  {
2535  $dataset = $this->object->getQuestionDataset($question_id);
2536  $this->tpl->setCurrentBlock("QTab");
2537  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
2538  $this->tpl->setVariable("QUESTION_TITLE", $dataset->title);
2539  $this->tpl->setVariable("QUESTION_COMMENT", $dataset->comment);
2540  $this->tpl->setVariable("QUESTION_TYPE", assQuestion::_getQuestionTypeName($dataset->type_tag));
2541  $this->tpl->setVariable("QUESTION_AUTHOR", $dataset->author);
2542  $this->tpl->setVariable("QUESTION_POOL", $questionpools[$dataset->obj_fi]["title"]);
2543  $this->tpl->parseCurrentBlock();
2544  $counter++;
2545  }
2546  if (count($question_array) == 0)
2547  {
2548  $this->tpl->setCurrentBlock("Emptytable");
2549  $this->tpl->setVariable("TEXT_NO_QUESTIONS_AVAILABLE", $this->lng->txt("no_questions_available"));
2550  $this->tpl->parseCurrentBlock();
2551  }
2552  else
2553  {
2554  $this->tpl->setCurrentBlock("Selectionbuttons");
2555  $this->tpl->setVariable("BTN_YES", $this->lng->txt("random_accept_sample"));
2556  $this->tpl->setVariable("BTN_NO", $this->lng->txt("random_another_sample"));
2557  $this->tpl->parseCurrentBlock();
2558  }
2559  $chosen_questions = join($question_array, ",");
2560  $this->tpl->setCurrentBlock("adm_content");
2561  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
2562  $this->tpl->setVariable("QUESTION_TITLE", $this->lng->txt("tst_question_title"));
2563  $this->tpl->setVariable("QUESTION_COMMENT", $this->lng->txt("description"));
2564  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("tst_question_type"));
2565  $this->tpl->setVariable("QUESTION_AUTHOR", $this->lng->txt("author"));
2566  $this->tpl->setVariable("QUESTION_POOL", $this->lng->txt("qpl"));
2567  $this->tpl->setVariable("VALUE_CHOSEN_QUESTIONS", $chosen_questions);
2568  $this->tpl->setVariable("VALUE_QUESTIONPOOL_SELECTION", $_POST["sel_qpl"]);
2569  $this->tpl->setVariable("VALUE_NR_OF_QUESTIONS", $_POST["nr_of_questions"]);
2570  $this->tpl->setVariable("TEXT_QUESTION_OFFER", $this->lng->txt("tst_question_offer"));
2571  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
2572  $this->tpl->parseCurrentBlock();
2573  }
2574 
2583  {
2584  $selected_array = split(",", $_POST["chosen_questions"]);
2585  if (!count($selected_array))
2586  {
2587  ilUtil::sendInfo($this->lng->txt("tst_insert_missing_question"));
2588  }
2589  else
2590  {
2591  $total = $this->object->evalTotalPersons();
2592  if ($total)
2593  {
2594  // the test was executed previously
2595  ilUtil::sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total));
2596  }
2597  else
2598  {
2599  ilUtil::sendInfo($this->lng->txt("tst_insert_questions"));
2600  }
2601  foreach ($selected_array as $key => $value)
2602  {
2603  $this->object->insertQuestion($value);
2604  }
2605  $this->object->saveCompleteStatus();
2606  ilUtil::sendInfo($this->lng->txt("tst_questions_inserted"), true);
2607  $this->ctrl->redirect($this, "questions");
2608  return;
2609  }
2610  }
2611 
2613  {
2614  $this->randomQuestionsObject();
2615  }
2616 
2618  {
2619  $this->randomQuestionsObject();
2620  }
2621 
2623  {
2624  global $ilUser;
2625  $selection_mode = $ilUser->getPref("tst_question_selection_mode_equal");
2626  $total = $this->object->evalTotalPersons();
2627  $available_qpl =& $this->object->getAvailableQuestionpools(TRUE, $selection_mode, FALSE, TRUE, TRUE);
2628  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
2629  $qpl_question_count = array();
2630  foreach ($available_qpl as $key => $value)
2631  {
2632  if ($value["count"] > 0)
2633  {
2634  $qpl_question_count[$key] = $value["count"];
2635  }
2636  else
2637  {
2638  unset($available_qpl[$key]);
2639  }
2640  }
2641  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_random_questions.html", "Modules/Test");
2642  $found_qpls = array();
2643  if (count($_POST) == 0)
2644  {
2645  $found_qpls = $this->object->getRandomQuestionpools();
2646  }
2647  $qpl_unselected = 0;
2648  foreach ($_POST as $key => $value)
2649  {
2650  if (preg_match("/countqpl_(\d+)/", $key, $matches))
2651  {
2652  $questioncount = $qpl_question_count[$_POST["qpl_" . $matches[1]]];
2653  if ((strlen($questioncount) > 0) && ($value > $questioncount))
2654  {
2655  $value = $questioncount;
2656  ilUtil::sendInfo($this->lng->txt("tst_random_selection_question_count_too_high"));
2657  }
2658  $found_qpls[$matches[1]] = array(
2659  "index" => $matches[1],
2660  "count" => sprintf("%d", $value),
2661  "qpl" => $_POST["qpl_" . $matches[1]],
2662  "title" => $available_qpl[$_POST["qpl_" . $matches[1]]]["title"]
2663  );
2664  if ($_POST["qpl_" . $matches[1]] == -1)
2665  {
2666  $qpl_unselected = 1;
2667  }
2668  }
2669  }
2670  $commands = $_POST["cmd"];
2671  if (is_array($commands))
2672  {
2673  foreach ($commands as $key => $value)
2674  {
2675  if (preg_match("/deleteqpl_(\d+)/", $key, $matches))
2676  {
2677  unset($found_qpls[$matches[1]]);
2678  }
2679  }
2680  }
2681  sort($found_qpls);
2682  $found_qpls = array_values($found_qpls);
2683  if (count($found_qpls) == 0)
2684  {
2685  foreach ($available_qpl as $key => $value)
2686  {
2687  $this->tpl->setCurrentBlock("qpl_value");
2688  $this->tpl->setVariable("QPL_ID", $key);
2689  $this->tpl->setVariable("QPL_TEXT", $value["title"]);
2690  $this->tpl->parseCurrentBlock();
2691  }
2692  $this->tpl->setCurrentBlock("questionpool_row");
2693  $this->tpl->setVariable("COUNTQPL", "0");
2694  $this->tpl->setVariable("VALUE_COUNTQPL", $_POST["countqpl_0"]);
2695  $this->tpl->setVariable("TEXT_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool_option"));
2696  $this->tpl->setVariable("TEXT_QUESTIONS_FROM", $this->lng->txt("questions_from"));
2697  $this->tpl->setVariable("BTNCOUNTQPL", 0);
2698  $this->tpl->setVariable("BTN_DELETE", $this->lng->txt("delete"));
2699  $this->tpl->parseCurrentBlock();
2700  }
2701  $counter = 0;
2702  foreach ($found_qpls as $key => $value)
2703  {
2704  $pools = $available_qpl;
2705  foreach ($found_qpls as $pkey => $pvalue)
2706  {
2707  if ($pvalue["qpl"] != $value["qpl"])
2708  {
2709  unset($pools[$pvalue["qpl"]]);
2710  }
2711  }
2712  // create first questionpool row automatically
2713  foreach ($pools as $pkey => $pvalue)
2714  {
2715  $this->tpl->setCurrentBlock("qpl_value");
2716  $this->tpl->setVariable("QPL_ID", $pkey);
2717  $this->tpl->setVariable("QPL_TEXT", $pvalue["title"]);
2718  if ($pkey == $value["qpl"])
2719  {
2720  $this->tpl->setVariable("SELECTED_QPL", " selected=\"selected\"");
2721  }
2722  $this->tpl->parseCurrentBlock();
2723  }
2724  $this->tpl->setCurrentBlock("questionpool_row");
2725  $this->tpl->setVariable("COUNTQPL", $counter);
2726  $this->tpl->setVariable("VALUE_COUNTQPL", $value["count"]);
2727  $this->tpl->setVariable("TEXT_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool_option"));
2728  $this->tpl->setVariable("TEXT_QUESTIONS_FROM", $this->lng->txt("questions_from"));
2729  $this->tpl->setVariable("BTNCOUNTQPL", $counter);
2730  $this->tpl->setVariable("BTN_DELETE", $this->lng->txt("delete"));
2731  $this->tpl->parseCurrentBlock();
2732  $counter++;
2733  }
2734  if ($_POST["cmd"]["addQuestionpool"])
2735  {
2736  if ($qpl_unselected)
2737  {
2738  ilUtil::sendInfo($this->lng->txt("tst_random_qpl_unselected"));
2739  }
2740  else
2741  {
2742  $pools = $available_qpl;
2743  foreach ($found_qpls as $pkey => $pvalue)
2744  {
2745  unset($pools[$pvalue["qpl"]]);
2746  }
2747  if (count($pools) == 0)
2748  {
2749  ilUtil::sendInfo($this->lng->txt("tst_no_more_available_questionpools"));
2750  }
2751  else
2752  {
2753  foreach ($pools as $key => $value)
2754  {
2755  $this->tpl->setCurrentBlock("qpl_value");
2756  $this->tpl->setVariable("QPL_ID", $key);
2757  $this->tpl->setVariable("QPL_TEXT", $value["title"]);
2758  $this->tpl->parseCurrentBlock();
2759  }
2760  $this->tpl->setCurrentBlock("questionpool_row");
2761  $this->tpl->setVariable("COUNTQPL", "$counter");
2762  $this->tpl->setVariable("TEXT_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool_option"));
2763  $this->tpl->setVariable("TEXT_QUESTIONS_FROM", $this->lng->txt("questions_from"));
2764  $this->tpl->setVariable("BTNCOUNTQPL", $counter);
2765  $this->tpl->setVariable("BTN_DELETE", $this->lng->txt("delete"));
2766  $this->tpl->parseCurrentBlock();
2767  }
2768  }
2769  }
2770  if ($_POST["cmd"]["saveRandomQuestions"])
2771  {
2772  $this->object->saveRandomQuestionCount($_POST["total_questions"]);
2773  $this->object->saveRandomQuestionpools($found_qpls);
2774  $this->object->saveCompleteStatus();
2775  }
2776  $this->tpl->setCurrentBlock("adm_content");
2777  $this->tpl->setVariable("TEXT_SELECT_RANDOM_QUESTIONS", $this->lng->txt("tst_select_random_questions"));
2778  $this->tpl->setVariable("TEXT_TOTAL_QUESTIONS", $this->lng->txt("tst_total_questions"));
2779  $this->tpl->setVariable("TEXT_TOTAL_QUESTIONS_DESCRIPTION", $this->lng->txt("tst_total_questions_description"));
2780  $total_questions = $this->object->getRandomQuestionCount();
2781  if (array_key_exists("total_questions", $_POST))
2782  {
2783  $total_questions = $_POST["total_questions"];
2784  }
2785  if ($total_questions > 0)
2786  {
2787  $sum = 0;
2788  foreach ($found_qpls as $key => $value)
2789  {
2790  $sum += $qpl_question_count[$value["qpl"]];
2791  }
2792  if ($total_questions > $sum)
2793  {
2794  $total_questions = $sum;
2795  if ($_POST["cmd"]["saveRandomQuestions"])
2796  {
2797  $this->object->saveRandomQuestionCount($total_questions);
2798  }
2799  ilUtil::sendInfo($this->lng->txt("tst_random_selection_question_total_count_too_high"));
2800  }
2801  }
2802  $this->tpl->setVariable("VALUE_TOTAL_QUESTIONS", $total_questions);
2803  $this->tpl->setVariable("TEXT_QUESTIONPOOLS", $this->lng->txt("tst_random_questionpools"));
2804  if (!$total)
2805  {
2806  $this->tpl->setVariable("BTN_SAVE", $this->lng->txt("save"));
2807  $this->tpl->setVariable("BTN_ADD_QUESTIONPOOL", $this->lng->txt("add_questionpool"));
2808  }
2809  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
2810 
2811  $this->tpl->setVariable("TEXT_QUESTION_SELECTION", $this->lng->txt("tst_question_selection"));
2812  $this->tpl->setVariable("VALUE_QUESTION_SELECTION", $this->lng->txt("tst_question_selection_equal"));
2813  $this->tpl->setVariable("CMD_QUESTION_SELECTION", "setEqualQplSelection");
2814  $this->tpl->setVariable("TEXT_QUESTION_SELECTION_DESCRIPTION", $this->lng->txt("tst_question_selection_description"));
2815  $this->tpl->setVariable("BUTTON_SAVE", $this->lng->txt("change"));
2816  if ($selection_mode == 1)
2817  {
2818  $this->tpl->setVariable("CHECKED_QUESTION_SELECTION_MODE", " checked=\"checked\"");
2819  }
2820  $this->tpl->parseCurrentBlock();
2821  }
2822 
2824  {
2825  global $ilUser;
2826  if ($_POST["chbQuestionSelectionMode"])
2827  {
2828  $ilUser->setPref("tst_question_selection_mode_equal", 1);
2829  $ilUser->writePref("tst_question_selection_mode_equal", 1);
2830  }
2831  else
2832  {
2833  $ilUser->setPref("tst_question_selection_mode_equal", 0);
2834  $ilUser->writePref("tst_question_selection_mode_equal", 0);
2835  }
2836  $this->randomQuestionsObject();
2837  }
2838 
2840  {
2841  $this->questionBrowser();
2842  }
2843 
2852  {
2853  $qpl_ref_id = $_POST["sel_qpl"];
2854  if ((strcmp($_POST["txt_qpl"], "") == 0) && (strcmp($qpl_ref_id, "") == 0))
2855  {
2856  ilUtil::sendInfo($this->lng->txt("questionpool_not_entered"));
2857  $this->createQuestionObject();
2858  return;
2859  }
2860  else
2861  {
2862  $_SESSION["test_id"] = $this->object->getRefId();
2863  if (strcmp($_POST["txt_qpl"], "") != 0)
2864  {
2865  // create a new question pool and return the reference id
2866  $qpl_ref_id = $this->createQuestionPool($_POST["txt_qpl"]);
2867  }
2868  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPoolGUI.php";
2869  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"]);
2870  exit();
2871  }
2872  }
2873 
2882  {
2883  $this->ctrl->redirect($this, "questions");
2884  }
2885 
2894  {
2895  global $ilUser;
2896  $this->getQuestionsSubTabs();
2897  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_qpl_select.html", "Modules/Test");
2898  $questionpools =& $this->object->getAvailableQuestionpools(FALSE, FALSE, FALSE, TRUE, FALSE, "write");
2899  if (count($questionpools) == 0)
2900  {
2901  $this->tpl->setCurrentBlock("option");
2902  $this->tpl->setVariable("VALUE_QPL", "");
2903  $this->tpl->parseCurrentBlock();
2904  }
2905  else
2906  {
2907  foreach ($questionpools as $key => $value)
2908  {
2909  $this->tpl->setCurrentBlock("option");
2910  $this->tpl->setVariable("VALUE_OPTION", $key);
2911  $this->tpl->setVariable("TEXT_OPTION", $value["title"]);
2912  $this->tpl->parseCurrentBlock();
2913  }
2914  }
2915  $this->tpl->setCurrentBlock("hidden");
2916  $this->tpl->setVariable("HIDDEN_NAME", "sel_question_types");
2917  $this->tpl->setVariable("HIDDEN_VALUE", $_POST["sel_question_types"]);
2918  $this->tpl->parseCurrentBlock();
2919  $this->tpl->setCurrentBlock("adm_content");
2920  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
2921 
2922  if (count($questionpools) == 0)
2923  {
2924  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_enter_questionpool"));
2925  }
2926  else
2927  {
2928  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_select_questionpool"));
2929  }
2930  $this->tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit"));
2931  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
2932  $this->tpl->parseCurrentBlock();
2933  }
2934 
2943  {
2944  ilUtil::sendInfo($this->lng->txt("tst_questions_removed"));
2945  $checked_questions = array();
2946  foreach ($_POST as $key => $value) {
2947  if (preg_match("/id_(\d+)/", $key, $matches)) {
2948  array_push($checked_questions, $matches[1]);
2949  }
2950  }
2951  foreach ($checked_questions as $key => $value) {
2952  $this->object->removeQuestion($value);
2953  }
2954  $this->object->saveCompleteStatus();
2955  $this->ctrl->redirect($this, "questions");
2956  }
2957 
2966  {
2967  $this->ctrl->redirect($this, "questions");
2968  }
2969 
2977  function removeQuestionsForm($checked_questions)
2978  {
2979  ilUtil::sendInfo();
2980  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_remove_questions.html", "Modules/Test");
2981  $removablequestions =& $this->object->getTestQuestions();
2982  $colors = array("tblrow1", "tblrow2");
2983  $counter = 0;
2984  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
2985  if (count($removablequestions))
2986  {
2987  foreach ($removablequestions as $data)
2988  {
2989  if (in_array($data["question_id"], $checked_questions))
2990  {
2991  $this->tpl->setCurrentBlock("row");
2992  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
2993  $this->tpl->setVariable("TXT_TITLE", $data["title"]);
2994  $this->tpl->setVariable("TXT_DESCRIPTION", $data["comment"]);
2995  $this->tpl->setVariable("TXT_TYPE", assQuestion::_getQuestionTypeName($data["type_tag"]));
2996  $this->tpl->parseCurrentBlock();
2997  $counter++;
2998  }
2999  }
3000  }
3001  foreach ($checked_questions as $id)
3002  {
3003  $this->tpl->setCurrentBlock("hidden");
3004  $this->tpl->setVariable("HIDDEN_NAME", "id_$id");
3005  $this->tpl->setVariable("HIDDEN_VALUE", "1");
3006  $this->tpl->parseCurrentBlock();
3007  }
3008 
3009  $this->tpl->setCurrentBlock("adm_content");
3010  $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("tst_question_title"));
3011  $this->tpl->setVariable("TXT_DESCRIPTION", $this->lng->txt("description"));
3012  $this->tpl->setVariable("TXT_TYPE", $this->lng->txt("tst_question_type"));
3013  $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
3014  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
3015  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
3016  $this->tpl->parseCurrentBlock();
3017  }
3018 
3027  {
3028  $this->getQuestionsSubTabs();
3029  $checked_questions = array();
3030  foreach ($_POST as $key => $value) {
3031  if (preg_match("/cb_(\d+)/", $key, $matches)) {
3032  array_push($checked_questions, $matches[1]);
3033  }
3034  }
3035  if (count($checked_questions) > 0) {
3036  $total = $this->object->evalTotalPersons();
3037  if ($total) {
3038  // the test was executed previously
3039  ilUtil::sendInfo(sprintf($this->lng->txt("tst_remove_questions_and_results"), $total));
3040  } else {
3041  ilUtil::sendInfo($this->lng->txt("tst_remove_questions"));
3042  }
3043  $this->removeQuestionsForm($checked_questions);
3044  return;
3045  } elseif (count($checked_questions) == 0) {
3046  ilUtil::sendInfo($this->lng->txt("tst_no_question_selected_for_removal"), true);
3047  $this->ctrl->redirect($this, "questions");
3048  }
3049  }
3050 
3059  {
3060  $this->questionsObject();
3061  }
3062 
3071  {
3072  // get all questions to move
3073  $move_questions = array();
3074  foreach ($_POST as $key => $value)
3075  {
3076  if (preg_match("/^move_(\d+)$/", $key, $matches))
3077  {
3078  array_push($move_questions, $value);
3079  }
3080  }
3081  // get insert point
3082  $insert_id = -1;
3083  foreach ($_POST as $key => $value)
3084  {
3085  if (preg_match("/^cb_(\d+)$/", $key, $matches))
3086  {
3087  if ($insert_id < 0)
3088  {
3089  $insert_id = $matches[1];
3090  }
3091  }
3092  }
3093  if ($insert_id <= 0)
3094  {
3095  ilUtil::sendInfo($this->lng->txt("no_target_selected_for_move"), true);
3096  }
3097  else
3098  {
3099  $insert_mode = 0;
3100  $this->object->moveQuestions($move_questions, $insert_id, $insert_mode);
3101  }
3102  $this->ctrl->redirect($this, "questions");
3103  }
3104 
3113  {
3114  // get all questions to move
3115  $move_questions = array();
3116  foreach ($_POST as $key => $value)
3117  {
3118  if (preg_match("/^move_(\d+)$/", $key, $matches))
3119  {
3120  array_push($move_questions, $value);
3121  }
3122  }
3123  // get insert point
3124  $insert_id = -1;
3125  foreach ($_POST as $key => $value)
3126  {
3127  if (preg_match("/^cb_(\d+)$/", $key, $matches))
3128  {
3129  if ($insert_id < 0)
3130  {
3131  $insert_id = $matches[1];
3132  }
3133  }
3134  }
3135  if ($insert_id <= 0)
3136  {
3137  ilUtil::sendInfo($this->lng->txt("no_target_selected_for_move"), true);
3138  }
3139  else
3140  {
3141  $insert_mode = 1;
3142  $this->object->moveQuestions($move_questions, $insert_id, $insert_mode);
3143  }
3144  $this->ctrl->redirect($this, "questions");
3145  }
3146 
3147  function questionsObject()
3148  {
3149  global $ilAccess;
3150  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
3151  {
3152  // allow only write access
3153  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3154  $this->ctrl->redirect($this, "infoScreen");
3155  }
3156 
3157  $this->getQuestionsSubTabs();
3158  if ($this->object->isRandomTest())
3159  {
3160  $this->randomQuestionsObject();
3161  return;
3162  }
3163 
3164  if ($_GET["eqid"] and $_GET["eqpl"])
3165  {
3166  ilUtil::redirect("ilias.php?baseClass=ilObjQuestionPoolGUI&ref_id=" . $_GET["eqpl"] . "&cmd=editQuestionForTest&calling_test=".$_GET["ref_id"]."&q_id=" . $_GET["eqid"]);
3167  }
3168 
3169  if ($_GET["up"] > 0)
3170  {
3171  $this->object->questionMoveUp($_GET["up"]);
3172  }
3173  if ($_GET["down"] > 0)
3174  {
3175  $this->object->questionMoveDown($_GET["down"]);
3176  }
3177 
3178  if ($_GET["add"])
3179  {
3180  $selected_array = array();
3181  array_push($selected_array, $_GET["add"]);
3182  $total = $this->object->evalTotalPersons();
3183  if ($total)
3184  {
3185  // the test was executed previously
3186  ilUtil::sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total));
3187  }
3188  else
3189  {
3190  ilUtil::sendInfo($this->lng->txt("tst_insert_questions"));
3191  }
3192  $this->insertQuestions($selected_array);
3193  return;
3194  }
3195 
3196  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_questions.html", "Modules/Test");
3197  $this->tpl->addBlockFile("A_BUTTONS", "question_buttons", "tpl.il_as_tst_question_buttons.html", "Modules/Test");
3198 
3199  if (strcmp($this->ctrl->getCmd(), "moveQuestions") == 0)
3200  {
3201  $checked_move = 0;
3202  foreach ($_POST as $key => $value)
3203  {
3204  if (preg_match("/cb_(\d+)/", $key, $matches))
3205  {
3206  $checked_move++;
3207  $this->tpl->setCurrentBlock("move");
3208  $this->tpl->setVariable("MOVE_COUNTER", $matches[1]);
3209  $this->tpl->setVariable("MOVE_VALUE", $matches[1]);
3210  $this->tpl->parseCurrentBlock();
3211  }
3212  }
3213  if ($checked_move)
3214  {
3215  ilUtil::sendInfo($this->lng->txt("select_target_position_for_move_question"));
3216  $this->tpl->setCurrentBlock("move_buttons");
3217  $this->tpl->setVariable("INSERT_BEFORE", $this->lng->txt("insert_before"));
3218  $this->tpl->setVariable("INSERT_AFTER", $this->lng->txt("insert_after"));
3219  $this->tpl->parseCurrentBlock();
3220  }
3221  else
3222  {
3223  ilUtil::sendInfo($this->lng->txt("no_question_selected_for_move"));
3224  }
3225  }
3226 
3227  $testquestions =& $this->object->getTestQuestions();
3228  $colors = array("tblrow1", "tblrow2");
3229  $counter = 0;
3230  $questionpools = array();
3231  $total_points = 0;
3232  $total = $this->object->evalTotalPersons();
3233  if (count($testquestions) > 0)
3234  {
3235  foreach ($testquestions as $data)
3236  {
3237  if (!array_key_exists($data->obj_fi, $questionpools))
3238  {
3239  $pooltitle = $this->object->_lookupTitle($data["obj_fi"]);
3240  $questionpools[$data["obj_fi"]] = $pooltitle;
3241  }
3242  $this->tpl->setCurrentBlock("QTab");
3243  $this->tpl->setVariable("QUESTION_ID", $data["question_id"]);
3244  if (($ilAccess->checkAccess("write", "", $this->ref_id) and ($total == 0)))
3245  {
3246  $q_id = $data["question_id"];
3247  $qpl_ref_id = $this->object->_getRefIdFromObjId($data["obj_fi"]);
3248  $this->tpl->setVariable("QUESTION_TITLE", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&eqid=$q_id&eqpl=$qpl_ref_id" . "\">" . $data["title"] . "</a>");
3249  } else {
3250  $this->tpl->setVariable("QUESTION_TITLE", $data["title"]);
3251  }
3252  $this->tpl->setVariable("QUESTION_SEQUENCE", $this->lng->txt("tst_sequence"));
3253 
3254  if (($ilAccess->checkAccess("write", "", $this->ref_id) and ($total == 0)))
3255  {
3256  if ($data["question_id"] != $this->object->questions[1])
3257  {
3258  $this->tpl->setVariable("BUTTON_UP", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&up=".$data["question_id"]."\"><img src=\"" . ilUtil::getImagePath("a_up.gif") . "\" alt=\"" . $this->lng->txt("up") . "\" border=\"0\" /></a>");
3259  }
3260  if ($data["question_id"] != $this->object->questions[count($this->object->questions)])
3261  {
3262  $this->tpl->setVariable("BUTTON_DOWN", "<a href=\"" . $this->ctrl->getLinkTarget($this, "questions") . "&down=".$data["question_id"]."\"><img src=\"" . ilUtil::getImagePath("a_down.gif") . "\" alt=\"" . $this->lng->txt("down") . "\" border=\"0\" /></a>");
3263  }
3264  }
3265  $this->tpl->setVariable("QUESTION_COMMENT", $data["comment"]);
3266  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
3267  $this->tpl->setVariable("QUESTION_TYPE", assQuestion::_getQuestionTypeName($data["type_tag"]));
3268  $this->tpl->setVariable("QUESTION_POINTS", $data["points"]);
3269  $total_points += $data["points"];
3270  $this->tpl->setVariable("QUESTION_AUTHOR", $data["author"]);
3271  $this->tpl->setVariable("QUESTION_POOL", $questionpools[$data["obj_fi"]]);
3272  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
3273  $this->tpl->parseCurrentBlock();
3274  $counter++;
3275  }
3276  }
3277  if ($counter == 0)
3278  {
3279  $this->tpl->setCurrentBlock("Emptytable");
3280  $this->tpl->setVariable("TEXT_EMPTYTABLE", $this->lng->txt("tst_no_questions_available"));
3281  $this->tpl->parseCurrentBlock();
3282  }
3283  else
3284  {
3285  if (($ilAccess->checkAccess("write", "", $this->ref_id) and ($total == 0)))
3286  {
3287  $this->tpl->setCurrentBlock("selectall");
3288  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
3289  $counter++;
3290  $this->tpl->setVariable("COLOR_CLASS", $colors[$counter % 2]);
3291  $this->tpl->setVariable("TOTAL_POINTS", $total_points);
3292  $this->tpl->parseCurrentBlock();
3293  $this->tpl->setCurrentBlock("QFooter");
3294  $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\"/>");
3295  $this->tpl->setVariable("REMOVE", $this->lng->txt("remove_question"));
3296  $this->tpl->setVariable("MOVE", $this->lng->txt("move"));
3297  $this->tpl->parseCurrentBlock();
3298  }
3299  }
3300 
3301  if (($ilAccess->checkAccess("write", "", $this->ref_id) and ($total == 0)))
3302  {
3303  global $ilUser;
3304  $lastquestiontype = $ilUser->getPref("tst_lastquestiontype");
3305  $this->tpl->setCurrentBlock("QTypes");
3306  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
3307  $question_types =& ilObjQuestionPool::_getQuestionTypes();
3308  foreach ($question_types as $trans => $data)
3309  {
3310  if ($data["type_tag"] == $lastquestiontype)
3311  {
3312  $this->tpl->setVariable("QUESTION_TYPE_SELECTED", " selected=\"selected\"");
3313  }
3314  $this->tpl->setVariable("QUESTION_TYPE_ID", $data["type_tag"]);
3315  $this->tpl->setVariable("QUESTION_TYPE", $trans);
3316  $this->tpl->parseCurrentBlock();
3317  }
3318  $this->tpl->parseCurrentBlock();
3319  }
3320  $this->tpl->setCurrentBlock("adm_content");
3321  $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this));
3322  $this->tpl->setVariable("QUESTION_TITLE", $this->lng->txt("tst_question_title"));
3323  $this->tpl->setVariable("QUESTION_COMMENT", $this->lng->txt("description"));
3324  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("tst_question_type"));
3325  $this->tpl->setVariable("QUESTION_POINTS", $this->lng->txt("points"));
3326  $this->tpl->setVariable("QUESTION_AUTHOR", $this->lng->txt("author"));
3327  $this->tpl->setVariable("QUESTION_POOL", $this->lng->txt("qpl"));
3328 
3329  if (($ilAccess->checkAccess("write", "", $this->ref_id) and ($total == 0)))
3330  {
3331  $this->tpl->setVariable("BUTTON_INSERT_QUESTION", $this->lng->txt("tst_browse_for_questions"));
3332  $this->tpl->setVariable("TEXT_CREATE_NEW", " " . strtolower($this->lng->txt("or")) . " " . $this->lng->txt("create_new"));
3333  $this->tpl->setVariable("BUTTON_CREATE_QUESTION", $this->lng->txt("create"));
3334  $this->tpl->setVariable("TXT_OR", $this->lng->txt("or"));
3335  $this->tpl->setVariable("TEXT_RANDOM_SELECT", $this->lng->txt("random_selection"));
3336  }
3337 
3338  $this->tpl->parseCurrentBlock();
3339  }
3340 
3341  function takenObject() {
3342  }
3343 
3352  {
3353  $this->saveMarkSchemaFormData();
3354  $this->object->mark_schema->addMarkStep();
3355  $this->marksObject();
3356  }
3357 
3366  {
3367  $this->object->mark_schema->flush();
3368  foreach ($_POST as $key => $value) {
3369  if (preg_match("/mark_short_(\d+)/", $key, $matches))
3370  {
3371  $this->object->mark_schema->addMarkStep($_POST["mark_short_$matches[1]"], $_POST["mark_official_$matches[1]"], $_POST["mark_percentage_$matches[1]"], $_POST["passed_$matches[1]"]);
3372  }
3373  }
3374  $this->object->ects_grades["A"] = $_POST["ects_grade_a"];
3375  $this->object->ects_grades["B"] = $_POST["ects_grade_b"];
3376  $this->object->ects_grades["C"] = $_POST["ects_grade_c"];
3377  $this->object->ects_grades["D"] = $_POST["ects_grade_d"];
3378  $this->object->ects_grades["E"] = $_POST["ects_grade_e"];
3379  if ($_POST["chbUseFX"])
3380  {
3381  $this->object->ects_fx = $_POST["percentFX"];
3382  }
3383  else
3384  {
3385  $this->object->ects_fx = "";
3386  }
3387  $this->object->ects_output = $_POST["chbECTS"];
3388  }
3389 
3398  {
3399  $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);
3400  $this->marksObject();
3401  }
3402 
3411  {
3412  $this->saveMarkSchemaFormData();
3413  $delete_mark_steps = array();
3414  foreach ($_POST as $key => $value) {
3415  if (preg_match("/cb_(\d+)/", $key, $matches)) {
3416  array_push($delete_mark_steps, $matches[1]);
3417  }
3418  }
3419  if (count($delete_mark_steps)) {
3420  $this->object->mark_schema->deleteMarkSteps($delete_mark_steps);
3421  } else {
3422  ilUtil::sendInfo($this->lng->txt("tst_delete_missing_mark"));
3423  }
3424  $this->marksObject();
3425  }
3426 
3435  {
3436  ilUtil::sendInfo($this->lng->txt("msg_cancel"), true);
3437  $this->ctrl->redirect($this, "marks");
3438  }
3439 
3447  function saveMarksObject()
3448  {
3449  $this->saveMarkSchemaFormData();
3450 
3451  $mark_check = $this->object->checkMarks();
3452  if ($mark_check !== true)
3453  {
3454  ilUtil::sendInfo($this->lng->txt($mark_check));
3455  }
3456  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)))
3457  {
3458  ilUtil::sendInfo($this->lng->txt("ects_fill_out_all_values"), true);
3459  }
3460  elseif (($_POST["ects_grade_a"] > 100) or ($_POST["ects_grade_a"] < 0))
3461  {
3462  ilUtil::sendInfo($this->lng->txt("ects_range_error_a"), true);
3463  }
3464  elseif (($_POST["ects_grade_b"] > 100) or ($_POST["ects_grade_b"] < 0))
3465  {
3466  ilUtil::sendInfo($this->lng->txt("ects_range_error_b"), true);
3467  }
3468  elseif (($_POST["ects_grade_c"] > 100) or ($_POST["ects_grade_c"] < 0))
3469  {
3470  ilUtil::sendInfo($this->lng->txt("ects_range_error_c"), true);
3471  }
3472  elseif (($_POST["ects_grade_d"] > 100) or ($_POST["ects_grade_d"] < 0))
3473  {
3474  ilUtil::sendInfo($this->lng->txt("ects_range_error_d"), true);
3475  }
3476  elseif (($_POST["ects_grade_e"] > 100) or ($_POST["ects_grade_e"] < 0))
3477  {
3478  ilUtil::sendInfo($this->lng->txt("ects_range_error_e"), true);
3479  }
3480  else
3481  {
3482  $this->object->mark_schema->saveToDb($this->object->getTestId());
3483  $this->object->saveCompleteStatus();
3484  if ($this->object->getReportingDate())
3485  {
3486  $fxpercent = "";
3487  if ($_POST["chbUseFX"])
3488  {
3489  $fxpercent = ilUtil::stripSlashes($_POST["percentFX"]);
3490  }
3491  $this->object->saveECTSStatus($_POST["chbECTS"], $fxpercent, $this->object->ects_grades["A"], $this->object->ects_grades["B"], $this->object->ects_grades["C"], $this->object->ects_grades["D"], $this->object->ects_grades["E"]);
3492  }
3493  ilUtil::sendInfo($this->lng->txt("msg_obj_modified"), true);
3494  }
3495  $this->marksObject();
3496  }
3497 
3498  function marksObject()
3499  {
3500  global $ilAccess;
3501  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
3502  {
3503  // allow only write access
3504  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3505  $this->ctrl->redirect($this, "infoScreen");
3506  }
3507 
3508  if (!$this->object->canEditMarks())
3509  {
3510  ilUtil::sendInfo($this->lng->txt("cannot_edit_marks"));
3511  }
3512 
3513  $this->object->mark_schema->sort();
3514 
3515  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_marks.html", "Modules/Test");
3516  $marks = $this->object->mark_schema->mark_steps;
3517  $rows = array("tblrow1", "tblrow2");
3518  $counter = 0;
3519  foreach ($marks as $key => $value) {
3520  $this->tpl->setCurrentBlock("markrow");
3521  $this->tpl->setVariable("MARK_SHORT", $value->getShortName());
3522  $this->tpl->setVariable("MARK_OFFICIAL", $value->getOfficialName());
3523  $this->tpl->setVariable("MARK_PERCENTAGE", sprintf("%.2f", $value->getMinimumLevel()));
3524  $this->tpl->setVariable("MARK_PASSED", strtolower($this->lng->txt("tst_mark_passed")));
3525  $this->tpl->setVariable("MARK_ID", "$key");
3526  $this->tpl->setVariable("ROW_CLASS", $rows[$counter % 2]);
3527  if ($value->getPassed()) {
3528  $this->tpl->setVariable("MARK_PASSED_CHECKED", " checked=\"checked\"");
3529  }
3530  $this->tpl->parseCurrentBlock();
3531  $counter++;
3532  }
3533  if (count($marks) == 0)
3534  {
3535  $this->tpl->setCurrentBlock("Emptyrow");
3536  $this->tpl->setVariable("EMPTY_ROW", $this->lng->txt("tst_no_marks_defined"));
3537  $this->tpl->setVariable("ROW_CLASS", $rows[$counter % 2]);
3538  $this->tpl->parseCurrentBlock();
3539  }
3540  else
3541  {
3542  if ($ilAccess->checkAccess("write", "", $this->ref_id) && $this->object->canEditMarks())
3543  {
3544  $this->tpl->setCurrentBlock("selectall");
3545  $counter++;
3546  $this->tpl->setVariable("ROW_CLASS", $rows[$counter % 2]);
3547  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
3548  $this->tpl->parseCurrentBlock();
3549  $this->tpl->setCurrentBlock("Footer");
3550  $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\"/>");
3551  $this->tpl->setVariable("BUTTON_EDIT", $this->lng->txt("edit"));
3552  $this->tpl->setVariable("BUTTON_DELETE", $this->lng->txt("delete"));
3553  $this->tpl->parseCurrentBlock();
3554  }
3555  }
3556 
3557  if ($this->object->getReportingDate())
3558  {
3559  $this->tpl->setCurrentBlock("ects");
3560  if ($this->object->ects_output)
3561  {
3562  $this->tpl->setVariable("CHECKED_ECTS", " checked=\"checked\"");
3563  }
3564  $this->tpl->setVariable("TEXT_OUTPUT_ECTS_GRADES", $this->lng->txt("ects_output_of_ects_grades"));
3565  $this->tpl->setVariable("TEXT_ALLOW_ECTS_GRADES", $this->lng->txt("ects_allow_ects_grades"));
3566  $this->tpl->setVariable("TEXT_USE_FX", $this->lng->txt("ects_use_fx_grade"));
3567  if (preg_match("/\d+/", $this->object->ects_fx))
3568  {
3569  $this->tpl->setVariable("CHECKED_FX", " checked=\"checked\"");
3570  $this->tpl->setVariable("VALUE_PERCENT_FX", sprintf("value=\"%s\" ", $this->object->ects_fx));
3571  }
3572  $this->tpl->setVariable("TEXT_PERCENT", $this->lng->txt("ects_use_fx_grade_part2"));
3573  $this->tpl->setVariable("ECTS_GRADE", $this->lng->txt("ects_grade"));
3574  $this->tpl->setVariable("PERCENTILE", $this->lng->txt("percentile"));
3575  $this->tpl->setVariable("ECTS_GRADE_A", "A - " . $this->lng->txt("ects_grade_a_short"));
3576  $this->tpl->setVariable("VALUE_GRADE_A", $this->object->ects_grades["A"]);
3577  $this->tpl->setVariable("ECTS_GRADE_B", "B - " . $this->lng->txt("ects_grade_b_short"));
3578  $this->tpl->setVariable("VALUE_GRADE_B", $this->object->ects_grades["B"]);
3579  $this->tpl->setVariable("ECTS_GRADE_C", "C - " . $this->lng->txt("ects_grade_c_short"));
3580  $this->tpl->setVariable("VALUE_GRADE_C", $this->object->ects_grades["C"]);
3581  $this->tpl->setVariable("ECTS_GRADE_D", "D - " . $this->lng->txt("ects_grade_d_short"));
3582  $this->tpl->setVariable("VALUE_GRADE_D", $this->object->ects_grades["D"]);
3583  $this->tpl->setVariable("ECTS_GRADE_E", "E - " . $this->lng->txt("ects_grade_e_short"));
3584  $this->tpl->setVariable("VALUE_GRADE_E", $this->object->ects_grades["E"]);
3585 
3586  $this->tpl->parseCurrentBlock();
3587  }
3588 
3589  $this->tpl->setCurrentBlock("adm_content");
3590  $this->tpl->setVariable("ACTION_MARKS", $this->ctrl->getFormAction($this));
3591  $this->tpl->setVariable("HEADER_SHORT", $this->lng->txt("tst_mark_short_form"));
3592  $this->tpl->setVariable("HEADER_OFFICIAL", $this->lng->txt("tst_mark_official_form"));
3593  $this->tpl->setVariable("HEADER_PERCENTAGE", $this->lng->txt("tst_mark_minimum_level"));
3594  $this->tpl->setVariable("HEADER_PASSED", $this->lng->txt("tst_mark_passed"));
3595  if ($ilAccess->checkAccess("write", "", $this->ref_id) && $this->object->canEditMarks())
3596  {
3597  $this->tpl->setVariable("BUTTON_NEW", $this->lng->txt("tst_mark_create_new_mark_step"));
3598  $this->tpl->setVariable("BUTTON_NEW_SIMPLE", $this->lng->txt("tst_mark_create_simple_mark_schema"));
3599  $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
3600  $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
3601  }
3602  $this->tpl->parseCurrentBlock();
3603  }
3604 
3613  {
3614  $this->object->removeAllTestEditings();
3615  ilUtil::sendInfo($this->lng->txt("tst_all_user_data_deleted"), true);
3616  $this->ctrl->redirect($this, "participants");
3617  }
3618 
3627  {
3628  $active_ids = array();
3629  foreach ($_POST["chbUser"] as $active_id)
3630  {
3631  if ($this->object->getFixedParticipants())
3632  {
3633  array_push($active_ids, $this->object->getActiveIdOfUser($active_id));
3634  }
3635  else
3636  {
3637  array_push($active_ids, $active_id);
3638  }
3639  }
3640  $this->object->removeSelectedTestResults($active_ids);
3641  ilUtil::sendInfo($this->lng->txt("tst_selected_user_data_deleted"), true);
3642  $this->ctrl->redirect($this, "participants");
3643  }
3644 
3653  {
3654  $this->ctrl->redirect($this, "participants");
3655  }
3656 
3665  {
3666  ilUtil::sendInfo($this->lng->txt("confirm_delete_all_user_data"));
3667  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_maintenance.html", "Modules/Test");
3668 
3669  $this->tpl->setCurrentBlock("confirm_delete");
3670  $this->tpl->setVariable("BTN_CONFIRM_DELETE_ALL", $this->lng->txt("confirm"));
3671  $this->tpl->setVariable("BTN_CANCEL_DELETE_ALL", $this->lng->txt("cancel"));
3672  $this->tpl->parseCurrentBlock();
3673 
3674  $this->tpl->setCurrentBlock("adm_content");
3675  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
3676  $this->tpl->parseCurrentBlock();
3677  }
3678 
3687  {
3688  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", "Modules/Test");
3689  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "participants"));
3690  $this->tpl->setCurrentBlock("table_header");
3691  $this->tpl->setVariable("TEXT", $this->lng->txt("delete_all_user_data"));
3692  $this->tpl->parseCurrentBlock();
3693 
3694  $this->tpl->setCurrentBlock("table_row");
3695  $this->tpl->setVariable("CSS_ROW", "tblrow1");
3696  $this->tpl->setVariable("TEXT_CONTENT", $this->lng->txt("delete_all_user_data_confirmation"));
3697  $this->tpl->parseCurrentBlock();
3698 
3699  // cancel/confirm button
3700  $buttons = array( "confirmDeleteAllUserResults" => $this->lng->txt("proceed"),
3701  "participants" => $this->lng->txt("cancel"));
3702  foreach ($buttons as $name => $value)
3703  {
3704  $this->tpl->setCurrentBlock("operation_btn");
3705  $this->tpl->setVariable("BTN_NAME",$name);
3706  $this->tpl->setVariable("BTN_VALUE",$value);
3707  $this->tpl->parseCurrentBlock();
3708  }
3709  }
3710 
3719  {
3720  if (count($_POST["chbUser"]) == 0)
3721  {
3722  ilUtil::sendInfo($this->lng->txt("select_one_user"), TRUE);
3723  $this->ctrl->redirect($this, "participants");
3724  }
3725  ilUtil::sendInfo($this->lng->txt("confirm_delete_single_user_data"));
3726  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_maintenance.html", "Modules/Test");
3727 
3728  foreach ($_POST["chbUser"] as $key => $value)
3729  {
3730  $this->tpl->setCurrentBlock("hidden");
3731  $this->tpl->setVariable("USER_ID", $value);
3732  $this->tpl->parseCurrentBlock();
3733  }
3734 
3735  include_once './Services/User/classes/class.ilObjUser.php';
3736  $color_class = array("tblrow1", "tblrow2");
3737  $counter = 0;
3738  foreach ($_POST["chbUser"] as $key => $active_id)
3739  {
3740  if ($this->object->getFixedParticipants())
3741  {
3742  $user_id = $active_id;
3743  }
3744  else
3745  {
3746  $user_id = $this->object->_getUserIdFromActiveId($active_id);
3747  }
3748  $user = ilObjUser::_lookupName($user_id);
3749  $this->tpl->setCurrentBlock("row");
3750  $this->tpl->setVariable("USER_ICON", ilUtil::getImagePath("icon_usr.gif"));
3751  $this->tpl->setVariable("USER_ALT", $this->lng->txt("usr"));
3752  $this->tpl->setVariable("USER_TITLE", $this->lng->txt("usr"));
3753  if ($this->object->getAnonymity())
3754  {
3755  $this->tpl->setVariable("TXT_FIRSTNAME", "");
3756  $this->tpl->setVariable("TXT_LASTNAME", $this->lng->txt("unknown"));
3757  $this->tpl->setVariable("TXT_LOGIN", "");
3758  }
3759  else
3760  {
3761  $this->tpl->setVariable("TXT_FIRSTNAME", $user["firstname"]);
3762  if (strlen($user["lastname"]))
3763  {
3764  $this->tpl->setVariable("TXT_LASTNAME", $user["lastname"]);
3765  }
3766  else
3767  {
3768  $this->tpl->setVariable("TXT_LASTNAME", $this->lng->txt("deleted_user"));
3769  }
3770  $this->tpl->setVariable("TXT_LOGIN", ilObjUser::_lookupLogin($user_id));
3771  }
3772  $this->tpl->setVariable("ROW_CLASS", $color_class[$counter % 2]);
3773  $this->tpl->parseCurrentBlock();
3774  $counter++;
3775  }
3776  $this->tpl->setCurrentBlock("selectedusers");
3777  $this->tpl->setVariable("HEADER_TXT_FIRSTNAME", $this->lng->txt("firstname"));
3778  $this->tpl->setVariable("HEADER_TXT_LASTNAME", $this->lng->txt("lastname"));
3779  $this->tpl->setVariable("HEADER_TXT_LOGIN", $this->lng->txt("login"));
3780  $this->tpl->setVariable("BTN_CONFIRM_DELETE_SELECTED", $this->lng->txt("confirm"));
3781  $this->tpl->setVariable("BTN_CANCEL_DELETE_SELECTED", $this->lng->txt("cancel"));
3782  $this->tpl->parseCurrentBlock();
3783 
3784  $this->tpl->setCurrentBlock("adm_content");
3785  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
3786  $this->tpl->parseCurrentBlock();
3787  }
3788 
3796  function historyObject()
3797  {
3798  global $ilAccess;
3799  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
3800  {
3801  // allow only write access
3802  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3803  $this->ctrl->redirect($this, "infoScreen");
3804  }
3805 
3806  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_status.html", "Modules/Test");
3807  if ($ilAccess->checkAccess("write", "", $this->ref_id))
3808  {
3809  include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
3810  $log =& ilObjAssessmentFolder::_getLog("19700101000000", strftime("%Y%m%d%H%M%S"), $this->object->getId(), TRUE);
3811  if (count($log))
3812  {
3813  $tblrow = array("tblrow1", "tblrow2");
3814  $counter = 0;
3815  include_once './Services/User/classes/class.ilObjUser.php';
3816  foreach ($log as $entry)
3817  {
3818  $this->tpl->setCurrentBlock("changelog_row");
3819  $this->tpl->setVariable("ROW_CLASS", $tblrow[$counter % 2]);
3820  $username = $this->object->userLookupFullName($entry["user_fi"], TRUE);
3821  $this->tpl->setVariable("TXT_USER", $username);
3822  $this->tpl->setVariable("TXT_DATETIME", ilDatePresentation::formatDate(new ilDateTime($entry["timestamp14"],IL_CAL_TIMESTAMP)));
3823  if (strlen($entry["ref_id"]) && strlen($entry["href"]))
3824  {
3825  $this->tpl->setVariable("TXT_TEST_REFERENCE", $this->lng->txt("perma_link"));
3826  $this->tpl->setVariable("HREF_REFERENCE", $entry["href"]);
3827  }
3828  $this->tpl->setVariable("TXT_LOGTEXT", trim(ilUtil::prepareFormOutput($entry["logtext"])));
3829  $this->tpl->parseCurrentBlock();
3830  $counter++;
3831  }
3832  $this->tpl->setCurrentBlock("changelog");
3833  $this->tpl->setVariable("HEADER_DATETIME", $this->lng->txt("assessment_log_datetime"));
3834  $this->tpl->setVariable("HEADER_USER", $this->lng->txt("user"));
3835  $this->tpl->setVariable("HEADER_LOGTEXT", $this->lng->txt("assessment_log_text"));
3836  $this->tpl->setVariable("HEADER_TEST_REFERENCE", $this->lng->txt("location"));
3837  $this->tpl->setVariable("HEADING_CHANGELOG", $this->lng->txt("changelog_heading"));
3838  $this->tpl->setVariable("DESCRIPTION_CHANGELOG", $this->lng->txt("changelog_description"));
3839  $this->tpl->parseCurrentBlock();
3840  }
3841  }
3842 
3843  $this->tpl->setCurrentBlock("adm_content");
3844  $this->tpl->parseCurrentBlock();
3845  }
3846 
3850  function createObject()
3851  {
3852  global $rbacsystem;
3853  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
3854  if (!$rbacsystem->checkAccess("create", $_GET["ref_id"], $new_type))
3855  {
3856  $this->ilias->raiseError($this->lng->txt("permission_denied"),$this->ilias->error_obj->MESSAGE);
3857  }
3858  else
3859  {
3860  $this->getTemplateFile("create", $new_type);
3861 
3862  include_once("./Modules/Test/classes/class.ilObjTest.php");
3863  $tst = new ilObjTest();
3864  $questionpools =& $tst->getAvailableQuestionpools(TRUE, FALSE, TRUE, TRUE);
3865  if (count($questionpools) == 0)
3866  {
3867  }
3868  else
3869  {
3870  foreach ($questionpools as $key => $value)
3871  {
3872  $this->tpl->setCurrentBlock("option_qpl");
3873  $this->tpl->setVariable("OPTION_VALUE", $key);
3874  $this->tpl->setVariable("TXT_OPTION", $value["title"]);
3875  if ($_POST["qpl"] == $key)
3876  {
3877  $this->tpl->setVariable("OPTION_SELECTED", " selected=\"selected\"");
3878  }
3879  $this->tpl->parseCurrentBlock();
3880  }
3881  }
3882 
3883  $defaults =& $tst->getAvailableDefaults();
3884  if (count($defaults))
3885  {
3886  foreach ($defaults as $row)
3887  {
3888  $this->tpl->setCurrentBlock("defaults_row");
3889  $this->tpl->setVariable("DEFAULTS_VALUE", $row["test_defaults_id"]);
3890  $this->tpl->setVariable("DEFAULTS_NAME", ilUtil::prepareFormOutput($row["name"]));
3891  $this->tpl->parseCurrentBlock();
3892  }
3893  $this->tpl->setCurrentBlock("defaults");
3894  $this->tpl->setVariable("TXT_DEFAULTS", $this->lng->txt("defaults"));
3895  $this->tpl->setVariable("TEXT_NO_DEFAULTS", $this->lng->txt("tst_defaults_dont_use"));
3896  $this->tpl->parseCurrentBlock();
3897  }
3898 
3899  $this->fillCloneTemplate('DUPLICATE','tst');
3900  $this->tpl->setCurrentBlock("adm_content");
3901 
3902  // fill in saved values in case of error
3903  $data = array();
3904  $data["fields"] = array();
3905  $data["fields"]["title"] = ilUtil::prepareFormOutput($_SESSION["error_post_vars"]["Fobject"]["title"],true);
3906  $data["fields"]["desc"] = ilUtil::stripSlashes($_SESSION["error_post_vars"]["Fobject"]["desc"]);
3907  foreach ($data["fields"] as $key => $val)
3908  {
3909  $this->tpl->setVariable("TXT_".strtoupper($key), $this->lng->txt($key));
3910  $this->tpl->setVariable(strtoupper($key), $val);
3911 
3912  if ($this->prepare_output)
3913  {
3914  $this->tpl->parseCurrentBlock();
3915  }
3916  }
3917  $this->ctrl->setParameter($this, "new_type", $this->type);
3918  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
3919  $this->tpl->setVariable("TXT_HEADER", $this->lng->txt($new_type."_new"));
3920  $this->tpl->setVariable("TXT_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool"));
3921  $this->tpl->setVariable("OPTION_SELECT_QUESTIONPOOL", $this->lng->txt("select_questionpool_option"));
3922  $this->tpl->setVariable("TXT_CANCEL", $this->lng->txt("cancel"));
3923  $this->tpl->setVariable("TXT_SUBMIT", $this->lng->txt($new_type."_add"));
3924  $this->tpl->setVariable("CMD_SUBMIT", "save");
3925  $this->tpl->setVariable("TARGET", ' target="'. ilFrameTargetInfo::_getFrame("MainContent").'" ');
3926  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
3927 
3928  $this->tpl->setVariable("TXT_IMPORT_TST", $this->lng->txt("import_tst"));
3929  $this->tpl->setVariable("TXT_TST_FILE", $this->lng->txt("tst_upload_file"));
3930  $this->tpl->setVariable("TXT_IMPORT", $this->lng->txt("import"));
3931 
3932  $this->tpl->setVariable("TYPE_IMG", ilUtil::getImagePath('icon_tst.gif'));
3933  $this->tpl->setVariable("ALT_IMG",$this->lng->txt("obj_tst"));
3934  $this->tpl->setVariable("TYPE_IMG2", ilUtil::getImagePath('icon_tst.gif'));
3935  $this->tpl->setVariable("ALT_IMG2",$this->lng->txt("obj_tst"));
3936  $this->tpl->setVariable("NEW_TYPE", $this->type);
3937  $this->tpl->parseCurrentBlock();
3938 
3939  }
3940  }
3941 
3950  {
3951  $this->ctrl->redirect($this, "inviteParticipants");
3952  }
3953 
3962  {
3963  $fixed_participants = 0;
3964  $invited_users = $this->object->getInvitedUsers();
3965  foreach ($invited_users as $user_object)
3966  {
3967  $this->object->disinviteUser($user_object->usr_id);
3968  }
3969  $this->object->setFixedParticipants($fixed_participants);
3970  $this->object->saveToDb();
3971  $this->ctrl->redirect($this, "inviteParticipants");
3972  }
3973 
3982  {
3983  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.confirm_deletion.html", "Modules/Test");
3984 
3985  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
3986 
3987  $this->tpl->setCurrentBlock("table_header");
3988  $this->tpl->setVariable("TEXT", $this->lng->txt("tst_fixed_participants_disable"));
3989  $this->tpl->parseCurrentBlock();
3990 
3991  $this->tpl->setCurrentBlock("table_row");
3992  $this->tpl->setVariable("CSS_ROW", "tblrow1");
3993  $this->tpl->setVariable("TEXT_CONTENT", $this->lng->txt("tst_fixed_participants_disable_description"));
3994  $this->tpl->parseCurrentBlock();
3995 
3996  // cancel/confirm button
3997  $buttons = array( "confirmFixedParticipantsStatusChange" => $this->lng->txt("proceed"),
3998  "cancelFixedParticipantsStatusChange" => $this->lng->txt("cancel"));
3999  foreach ($buttons as $name => $value)
4000  {
4001  $this->tpl->setCurrentBlock("operation_btn");
4002  $this->tpl->setVariable("BTN_NAME",$name);
4003  $this->tpl->setVariable("BTN_VALUE",$value);
4004  $this->tpl->parseCurrentBlock();
4005  }
4006  }
4007 
4016  {
4017  $fixed_participants = 0;
4018  if (array_key_exists("chb_fixed_participants", $_POST))
4019  {
4020  if ($_POST["chb_fixed_participants"])
4021  {
4022  $fixed_participants = 1;
4023  }
4024  }
4025  $invited_users = $this->object->getInvitedUsers();
4026  if ($this->object->getFixedParticipants() && !$fixed_participants && count($invited_users))
4027  {
4029  }
4030  else
4031  {
4032  $this->object->setFixedParticipants($fixed_participants);
4033  $this->object->saveToDb();
4034  $this->ctrl->redirect($this, "inviteParticipants");
4035  }
4036  }
4037 
4046  {
4047  global $ilAccess;
4048  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
4049  {
4050  // allow only write access
4051  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
4052  $this->ctrl->redirect($this, "infoScreen");
4053  }
4054 
4055  $total = $this->object->evalTotalPersons();
4056  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_fixed_users.html", "Modules/Test");
4057 
4058  if ($_POST["cmd"]["cancel"])
4059  {
4060  $this->backToRepositoryObject();
4061  }
4062 
4063  if (strcmp($this->ctrl->getCmd(), "searchParticipants") == 0)
4064  {
4065  if (is_array($_POST["search_for"]))
4066  {
4067  $this->tpl->setCurrentBlock("search_results_title");
4068  $this->tpl->setVariable("TEXT_SEARCH_RESULTS", $this->lng->txt("search_results"));
4069  $this->tpl->parseCurrentBlock();
4070  if (in_array("usr", $_POST["search_for"]) or in_array("grp", $_POST["search_for"]) or in_array("role", $_POST["search_for"]))
4071  {
4072  include_once './classes/class.ilSearch.php';
4073  $search =& new ilSearch($ilUser->id);
4074  $search->setSearchString($_POST["search_term"]);
4075  $search->setCombination($_POST["concatenation"]);
4076  $search->setSearchFor($_POST["search_for"]);
4077  $search->setSearchType("new");
4078  if($search->validate($message))
4079  {
4080  $search->performSearch();
4081  }
4082  if ($message)
4083  {
4084  ilUtil::sendInfo($message);
4085  }
4086 
4087  if(!$search->getNumberOfResults() && $search->getSearchFor())
4088  {
4089  ilUtil::sendInfo($this->lng->txt("search_no_match"));
4090  }
4091  $buttons = array("add");
4092 
4093  $invited_users =& $this->object->getInvitedUsers();
4094 
4095  if ($searchresult = $search->getResultByType("usr"))
4096  {
4097  $users = array();
4098  foreach ($searchresult as $result_array)
4099  {
4100  if (!array_key_exists($result_array["id"], $invited_users))
4101  {
4102  array_push($users, $result_array["id"]);
4103  }
4104  }
4105 
4106  $users = $this->object->getUserData($users);
4107 
4108  if (count ($users))
4109  $this->outUserGroupTable("usr", $users, "user_result", "user_row", $this->lng->txt("search_user"),"TEXT_USER_TITLE", $buttons);
4110  }
4111 
4112  $searchresult = array();
4113 
4114  if ($searchresult = $search->getResultByType("grp"))
4115  {
4116  $groups = array();
4117 
4118  foreach ($searchresult as $result_array)
4119  {
4120  array_push($groups, $result_array["id"]);
4121  }
4122  $groups = $this->object->getGroupData ($groups);
4123 
4124  if (count ($groups))
4125  $this->outUserGroupTable("grp", $groups, "group_result", "group_row", $this->lng->txt("search_group"), "TEXT_GROUP_TITLE", $buttons);
4126  }
4127 
4128  $searchresult = array();
4129 
4130  if ($searchresult = $search->getResultByType("role"))
4131  {
4132  $roles = array();
4133 
4134  foreach ($searchresult as $result_array)
4135  {
4136  array_push($roles, $result_array["id"]);
4137  }
4138 
4139  $roles = $this->object->getRoleData ($roles);
4140 
4141  if (count ($roles))
4142  $this->outUserGroupTable("role", $roles, "role_result", "role_row", $this->lng->txt("role"), "TEXT_ROLE_TITLE", $buttons);
4143  }
4144 
4145  }
4146 
4147  }
4148  else
4149  {
4150  ilUtil::sendInfo($this->lng->txt("no_user_or_group_selected"));
4151  }
4152  }
4153 
4154  if ($_POST["cmd"]["save"])
4155  {
4156  $this->object->saveToDb();
4157  }
4158  $invited_users = $this->object->getInvitedUsers();
4159 
4160  $buttons = array("save","remove");
4161 
4162  if ($this->object->getFixedParticipants())
4163  {
4164  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4165  {
4166  $this->tpl->setCurrentBlock("invitation");
4167  $this->tpl->setVariable("SEARCH_INVITATION", $this->lng->txt("search"));
4168  $this->tpl->setVariable("SEARCH_TERM", $this->lng->txt("search_term"));
4169  $this->tpl->setVariable("SEARCH_FOR", $this->lng->txt("search_for"));
4170  $this->tpl->setVariable("SEARCH_USERS", $this->lng->txt("search_users"));
4171  $this->tpl->setVariable("SEARCH_GROUPS", $this->lng->txt("search_groups"));
4172  $this->tpl->setVariable("SEARCH_ROLES", $this->lng->txt("search_roles"));
4173  $this->tpl->setVariable("TEXT_CONCATENATION", $this->lng->txt("concatenation"));
4174  $this->tpl->setVariable("TEXT_AND", $this->lng->txt("and"));
4175  $this->tpl->setVariable("TEXT_OR", $this->lng->txt("or"));
4176  $this->tpl->setVariable("VALUE_SEARCH_TERM", $_POST["search_term"]);
4177  if (is_array($_POST["search_for"]))
4178  {
4179  if (in_array("usr", $_POST["search_for"]))
4180  {
4181  $this->tpl->setVariable("CHECKED_USERS", " checked=\"checked\"");
4182  }
4183  if (in_array("grp", $_POST["search_for"]))
4184  {
4185  $this->tpl->setVariable("CHECKED_GROUPS", " checked=\"checked\"");
4186  }
4187  if (in_array("role", $_POST["search_for"]))
4188  {
4189  $this->tpl->setVariable("CHECKED_ROLES", " checked=\"checked\"");
4190  }
4191  }
4192  else
4193  {
4194  $this->tpl->setVariable("CHECKED_USERS", " checked=\"checked\"");
4195  }
4196  if (strcmp($_POST["concatenation"], "and") == 0)
4197  {
4198  $this->tpl->setVariable("CHECKED_AND", " checked=\"checked\"");
4199  }
4200  else
4201  {
4202  $this->tpl->setVariable("CHECKED_OR", " checked=\"checked\"");
4203  }
4204  $this->tpl->setVariable("SEARCH", $this->lng->txt("search"));
4205  $this->tpl->setVariable("SEARCH_INTRODUCTION", $this->lng->txt("participants_invitation_search_introduction"));
4206  $this->tpl->setVariable("TEXT_INVITATION", $this->lng->txt("invitation"));
4207  $this->tpl->setVariable("VALUE_ON", $this->lng->txt("on"));
4208  $this->tpl->setVariable("VALUE_OFF", $this->lng->txt("off"));
4209  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
4210  $this->tpl->parseCurrentBlock();
4211  }
4212  }
4213 
4214  $this->tpl->setCurrentBlock("adm_content");
4215  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
4216  $this->tpl->setVariable("TEXT_ALLOW_FIXED_PARTICIPANTS", $this->lng->txt("tst_allow_fixed_participants"));
4217  $this->tpl->setVariable("BUTTON_SAVE", $this->lng->txt("save"));
4218  $this->tpl->setVariable("TEXT_FIXED_PARTICIPANTS", $this->lng->txt("participants_invitation"));
4219  $this->tpl->setVariable("TEXT_FIXED_PARTICIPANTS_DESCRIPTION", $this->lng->txt("participants_invitation_description"));
4220  if ($this->object->getFixedParticipants())
4221  {
4222  $this->tpl->setVariable("CHECKED_FIXED_PARTICIPANTS", " checked=\"checked\"");
4223  }
4224  if ($total && (count($invited_users) == 0))
4225  {
4226  ilUtil::sendInfo($this->lng->txt("tst_fixed_participants_data_exists"));
4227  $this->tpl->setVariable("DISABLED_FIXED_PARTICIPANTS", " disabled=\"disabled\"");
4228  }
4229 
4230  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4231  {
4232  $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
4233  $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
4234  }
4235  $this->tpl->parseCurrentBlock();
4236  }
4237 
4246  {
4247  $command = $_POST["command"];
4248  if (strlen($command))
4249  {
4250  $method = $command . "Object";
4251  if (method_exists($this, $method))
4252  {
4253  $this->$method();
4254  return;
4255  }
4256  }
4257  $this->ctrl->redirect($this, "participants");
4258  }
4259 
4268  {
4269  global $ilAccess;
4270  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
4271  {
4272  // allow only write access
4273  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
4274  $this->ctrl->redirect($this, "infoScreen");
4275  }
4276 
4277  if ($this->object->getFixedParticipants())
4278  {
4279  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_invite.html", "Modules/Test");
4280  }
4281  else
4282  {
4283  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_participants.html", "Modules/Test");
4284  }
4285  include_once "./Services/YUI/classes/class.ilYuiUtil.php";
4287  "deleteAllUserResults",
4288  $this->lng->txt("delete_all_user_data"),
4289  $this->lng->txt("confirm_delete_all_user_data"),
4290  "location.href='" . $this->ctrl->getLinkTarget($this, "confirmDeleteAllUserResults") . "';",
4291  "",
4292  TRUE,
4293  $icon = "warn"
4294  );
4295  if ($_POST["cmd"]["cancel"])
4296  {
4297  $this->backToRepositoryObject();
4298  }
4299 
4300  if ($_POST["cmd"]["save"])
4301  {
4302  $this->object->saveToDb();
4303  }
4304 
4305  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4306  {
4307  if ($this->tpl->blockExists("invitation"))
4308  {
4309  $this->tpl->setCurrentBlock("invitation");
4310  $this->tpl->setVariable("SEARCH_INVITATION", $this->lng->txt("search"));
4311  $this->tpl->setVariable("SEARCH_TERM", $this->lng->txt("search_term"));
4312  $this->tpl->setVariable("SEARCH_FOR", $this->lng->txt("search_for"));
4313  $this->tpl->setVariable("SEARCH_USERS", $this->lng->txt("search_users"));
4314  $this->tpl->setVariable("SEARCH_GROUPS", $this->lng->txt("search_groups"));
4315  $this->tpl->setVariable("SEARCH_ROLES", $this->lng->txt("search_roles"));
4316  $this->tpl->setVariable("TEXT_CONCATENATION", $this->lng->txt("concatenation"));
4317  $this->tpl->setVariable("TEXT_AND", $this->lng->txt("and"));
4318  $this->tpl->setVariable("TEXT_OR", $this->lng->txt("or"));
4319  $this->tpl->setVariable("VALUE_SEARCH_TERM", $_POST["search_term"]);
4320  if (is_array($_POST["search_for"]))
4321  {
4322  if (in_array("usr", $_POST["search_for"]))
4323  {
4324  $this->tpl->setVariable("CHECKED_USERS", " checked=\"checked\"");
4325  }
4326  if (in_array("grp", $_POST["search_for"]))
4327  {
4328  $this->tpl->setVariable("CHECKED_GROUPS", " checked=\"checked\"");
4329  }
4330  if (in_array("role", $_POST["search_for"]))
4331  {
4332  $this->tpl->setVariable("CHECKED_ROLES", " checked=\"checked\"");
4333  }
4334 
4335  }
4336  if (strcmp($_POST["concatenation"], "and") == 0)
4337  {
4338  $this->tpl->setVariable("CHECKED_AND", " checked=\"checked\"");
4339  }
4340  else if (strcmp($_POST["concatenation"], "or") == 0)
4341  {
4342  $this->tpl->setVariable("CHECKED_OR", " checked=\"checked\"");
4343  }
4344  $this->tpl->setVariable("SEARCH", $this->lng->txt("search"));
4345  $this->tpl->parseCurrentBlock();
4346  }
4347  }
4348 
4349  if ($this->object->getFixedParticipants())
4350  {
4351  $invited_users =& $this->object->getInvitedUsers();
4352  if (count($invited_users) == 0)
4353  {
4354  ilUtil::sendInfo($this->lng->txt("tst_participants_no_fixed"));
4355  }
4356  else
4357  {
4358  $this->tpl->setCurrentBlock("delete_all");
4359  $this->tpl->setVariable("VALUE_DELETE_ALL_USER_DATA", $this->lng->txt("delete_all_user_data"));
4360  $this->tpl->setVariable("FORMACTION_DELETEALL", $this->ctrl->getFormAction($this, "deleteAllUserResults"));
4361  $this->tpl->parseCurrentBlock();
4362  }
4363  $buttons = array(array("saveClientIP" => "save"),array("removeParticipant" => "remove_as_participant"));
4364  if (!$this->object->getAnonymity())
4365  {
4366  array_push($buttons, array("showPassOverview" => "show_pass_overview"));
4367  array_push($buttons, array("showUserAnswers" => "show_user_answers"));
4368  array_push($buttons, array("showDetailedResults" => "show_detailed_results"));
4369  }
4370  array_push($buttons, array("deleteSingleUserResults" => "delete_user_data"));
4371  if (count($invited_users))
4372  {
4373  $this->outUserGroupTable("iv_usr", $invited_users, "invited_user_result", "invited_user_row", $this->lng->txt("tst_fixed_participating_users"), "TEXT_INVITED_USER_TITLE",$buttons);
4374  }
4375  }
4376  else
4377  {
4378  $invited_users =& $this->object->getTestParticipants();
4379  if (count($invited_users) == 0)
4380  {
4381  ilUtil::sendInfo($this->lng->txt("tst_participants_no"));
4382  }
4383  else
4384  {
4385  $this->tpl->setCurrentBlock("delete_all");
4386  $this->tpl->setVariable("VALUE_DELETE_ALL_USER_DATA", $this->lng->txt("delete_all_user_data"));
4387  $this->tpl->setVariable("FORMACTION_DELETEALL", $this->ctrl->getFormAction($this, "deleteAllUserResults"));
4388  $this->tpl->parseCurrentBlock();
4389  }
4390  $buttons = array();
4391  if (!$this->object->getAnonymity())
4392  {
4393  array_push($buttons, array("showPassOverview" => "show_pass_overview"));
4394  array_push($buttons, array("showUserAnswers" => "show_user_answers"));
4395  array_push($buttons, array("showDetailedResults" => "show_detailed_results"));
4396  }
4397  array_push($buttons, array("deleteSingleUserResults" => "delete_user_data"));
4398  if (count($invited_users))
4399  {
4400  $this->outUserGroupTable("iv_participants", $invited_users, "invited_user_result", "invited_user_row", $this->lng->txt("tst_participating_users"), "TEXT_INVITED_USER_TITLE",$buttons);
4401  }
4402  }
4403 
4404  if ($this->object->getFixedParticipants())
4405  {
4406  $this->tpl->setCurrentBlock("fixed_participants_hint");
4407  $this->tpl->setVariable("FIXED_PARTICIPANTS_HINT", sprintf($this->lng->txt("fixed_participants_hint"), $this->lng->txt("participants_invitation")));
4408  $this->tpl->parseCurrentBlock();
4409  }
4410 
4411  $this->tpl->setCurrentBlock("adm_content");
4412  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
4413  $this->tpl->setVariable("TEXT_INVITATION", $this->lng->txt("invitation"));
4414  $this->tpl->setVariable("VALUE_ON", $this->lng->txt("on"));
4415  $this->tpl->setVariable("VALUE_OFF", $this->lng->txt("off"));
4416  $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
4417 
4418  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4419  {
4420  $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
4421  $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
4422  }
4423  $this->tpl->parseCurrentBlock();
4424  }
4425 
4434  {
4435  if (count($_POST))
4436  {
4437  $_SESSION["show_user_results"] = $_POST["chbUser"];
4438  }
4439  $this->showUserResults($show_pass_details = TRUE, $show_answers = TRUE, $show_reached_points = TRUE);
4440  }
4441 
4450  {
4451  if (count($_POST))
4452  {
4453  $_SESSION["show_user_results"] = $_POST["chbUser"];
4454  }
4455  $this->showUserResults($show_pass_details = FALSE, $show_answers = TRUE);
4456  }
4457 
4466  {
4467  if (count($_POST))
4468  {
4469  $_SESSION["show_user_results"] = $_POST["chbUser"];
4470  }
4471  $this->showUserResults($show_pass_details = TRUE, $show_answers = FALSE);
4472  }
4473 
4481  function showUserResults($show_pass_details, $show_answers, $show_reached_points = FALSE)
4482  {
4483  $template = new ilTemplate("tpl.il_as_tst_participants_result_output.html", TRUE, TRUE, "Modules/Test");
4484 
4485  if (count($_SESSION["show_user_results"]) == 0)
4486  {
4487  ilUtil::sendInfo($this->lng->txt("select_one_user"), TRUE);
4488  $this->ctrl->redirect($this, "participants");
4489  }
4490 
4491  include_once "./Modules/Test/classes/class.ilTestServiceGUI.php";
4492  $serviceGUI =& new ilTestServiceGUI($this->object);
4493  $count = 0;
4494  foreach ($_SESSION["show_user_results"] as $key => $active_id)
4495  {
4496  $count++;
4497  $results = "";
4498  if ($this->object->getFixedParticipants())
4499  {
4500  $active_id = $this->object->getActiveIdOfUser($active_id);
4501  }
4502  if ($active_id > 0)
4503  {
4504  $results = $serviceGUI->getResultsOfUserOutput($active_id, $this->object->_getResultPass($active_id), $show_pass_details, $show_answers, FALSE, $show_reached_points);
4505  }
4506  if ($count < count($_SESSION["show_user_results"]))
4507  {
4508  $template->touchBlock("break");
4509  }
4510  $template->setCurrentBlock("user_result");
4511  $template->setVariable("USER_RESULT", $results);
4512  $template->parseCurrentBlock();
4513  }
4514  $template->setVariable("BACK_TEXT", $this->lng->txt("back"));
4515  $template->setVariable("BACK_URL", $this->ctrl->getLinkTargetByClass("ilobjtestgui", "participants"));
4516  $template->setVariable("PRINT_TEXT", $this->lng->txt("print"));
4517  $template->setVariable("PRINT_URL", "javascript:window.print();");
4518 
4519  $this->tpl->setVariable("ADM_CONTENT", $template->get());
4520  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
4521  if ($this->object->getShowSolutionAnswersOnly())
4522  {
4523  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
4524  }
4525  }
4526 
4528  {
4529  if (is_array($_POST["chbUser"]))
4530  {
4531  foreach ($_POST["chbUser"] as $user_id)
4532  {
4533  $this->object->disinviteUser($user_id);
4534  }
4535  }
4536  else
4537  {
4538  ilUtil::sendInfo($this->lng->txt("select_one_user"), true);
4539  }
4540  $this->ctrl->redirect($this, "participants");
4541  }
4542 
4544  {
4545  if (is_array($_POST["chbUser"]))
4546  {
4547  foreach ($_POST["chbUser"] as $user_id)
4548  {
4549  $this->object->setClientIP($user_id, $_POST["clientip_".$user_id]);
4550  }
4551  }
4552  else
4553  {
4554  ilUtil::sendInfo($this->lng->txt("select_one_user"), true);
4555  }
4556  $this->ctrl->redirect($this, "participants");
4557  }
4558 
4566  function printobject()
4567  {
4568  global $ilAccess, $ilias;
4569  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
4570  {
4571  // allow only write access
4572  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
4573  $this->ctrl->redirect($this, "infoScreen");
4574  }
4575  $this->getQuestionsSubTabs();
4576  $template = new ilTemplate("tpl.il_as_tst_print_test_confirm.html", TRUE, TRUE, "Modules/Test");
4577 
4578  if ((strlen($ilias->getSetting("rpc_server_host"))) && (strlen($ilias->getSetting("rpc_server_port"))))
4579  {
4580  $this->ctrl->setParameter($this, "pdf", "1");
4581  $template->setCurrentBlock("pdf_export");
4582  $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "print"));
4583  $this->ctrl->setParameter($this, "pdf", "");
4584  $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
4585  $template->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export"));
4586  $template->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")));
4587  $template->parseCurrentBlock();
4588  }
4589 
4590  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
4591 
4592  global $ilUser;
4593  $print_date = mktime(date("H"), date("i"), date("s"), date("m") , date("d"), date("Y"));
4594  $max_points= 0;
4595  $counter = 1;
4596 
4597  foreach ($this->object->questions as $question)
4598  {
4599  $template->setCurrentBlock("question");
4600  $question_gui = $this->object->createQuestionGUI("", $question);
4601  $template->setVariable("COUNTER_QUESTION", $counter.".");
4602  $template->setVariable("QUESTION_TITLE", ilUtil::prepareFormOutput($question_gui->object->getTitle()));
4603  if ($question_gui->object->getMaximumPoints() == 1)
4604  {
4605  $template->setVariable("QUESTION_POINTS", $question_gui->object->getMaximumPoints() . " " . $this->lng->txt("point"));
4606  }
4607  else
4608  {
4609  $template->setVariable("QUESTION_POINTS", $question_gui->object->getMaximumPoints() . " " . $this->lng->txt("points"));
4610  }
4611  $result_output = $question_gui->getSolutionOutput("", NULL, FALSE, TRUE, FALSE, $this->object->getShowSolutionFeedback());
4612  if (strlen($result_output) == 0) $result_output = $question_gui->getPreview(FALSE);
4613  $template->setVariable("SOLUTION_OUTPUT", $result_output);
4614  $template->parseCurrentBlock("question");
4615  $counter ++;
4616  $max_points += $question_gui->object->getMaximumPoints();
4617  }
4618 
4619  $template->setCurrentBlock("navigation_buttons");
4620  $template->setVariable("BUTTON_PRINT", $this->lng->txt("print"));
4621  $template->parseCurrentBlock();
4622 
4623  $template->setVariable("TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
4624  $template->setVariable("PRINT_TEST", ilUtil::prepareFormOutput($this->lng->txt("tst_print")));
4625  $template->setVariable("TXT_PRINT_DATE", ilUtil::prepareFormOutput($this->lng->txt("date")));
4626  $template->setVariable("VALUE_PRINT_DATE", ilUtil::prepareFormOutput(strftime("%c",$print_date)));
4627  $template->setVariable("TXT_MAXIMUM_POINTS", ilUtil::prepareFormOutput($this->lng->txt("tst_maximum_points")));
4628  $template->setVariable("VALUE_MAXIMUM_POINTS", ilUtil::prepareFormOutput($max_points));
4629 
4630  if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1))
4631  {
4632  $printbody = new ilTemplate("tpl.il_as_tst_print_body.html", TRUE, TRUE, "Modules/Test");
4633  $printbody->setVariable("TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
4634  $printbody->setVariable("ADM_CONTENT", $template->get());
4635  $printoutput = $printbody->get();
4636  $printoutput = preg_replace("/href=\".*?\"/", "", $printoutput);
4637  $fo = $this->object->processPrintoutput2FO($printoutput);
4638  $this->object->deliverPDFfromFO($fo);
4639  }
4640  else
4641  {
4642  $this->tpl->setVariable("PRINT_CONTENT", $template->get());
4643  }
4644  }
4645 
4654  function outUserGroupTable($a_type, $data_array, $block_result, $block_row, $title_text, $title_label, $buttons)
4655  {
4656  global $ilAccess;
4657  $rowclass = array("tblrow1", "tblrow2");
4658  switch($a_type)
4659  {
4660  case "iv_usr":
4661  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
4662  {
4663  foreach ($buttons as $arr)
4664  {
4665  foreach ($arr as $val => $cat)
4666  {
4667  $this->tpl->setCurrentBlock("commandoption");
4668  $this->tpl->setVariable("OPTION_NAME", $this->lng->txt($cat));
4669  $this->tpl->setVariable("OPTION_VALUE", $val);
4670  $this->tpl->parseCurrentBlock();
4671  }
4672  }
4673  $this->tpl->setCurrentBlock("user_action_buttons");
4674  $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\"/>");
4675  $this->tpl->setVariable("VALUE_SUBMIT", $this->lng->txt("submit"));
4676  $this->tpl->parseCurrentBlock();
4677  }
4678 
4679  $finished = "<img border=\"0\" align=\"middle\" src=\"".ilUtil::getImagePath("icon_ok.gif") . "\" alt=\"".$this->lng->txt("checkbox_checked")."\" />";
4680  $started = "<img border=\"0\" align=\"middle\" src=\"".ilUtil::getImagePath("icon_ok.gif") . "\" alt=\"".$this->lng->txt("checkbox_checked")."\" />" ;
4681  $counter = 0;
4682  foreach ($data_array as $data)
4683  {
4684  $maxpass = $this->object->_getMaxPass($data->active_id);
4685  if (!is_null($maxpass))
4686  {
4687  $maxpass += 1;
4688  }
4689  $passes = ($maxpass) ? (($maxpass == 1) ? sprintf($this->lng->txt("pass_finished"), $maxpass) : sprintf($this->lng->txt("passes_finished"), $maxpass)) : "&nbsp;";
4690  $this->tpl->setCurrentBlock($block_row);
4691  $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
4692  $this->tpl->setVariable("COUNTER", $data->usr_id);
4693  $this->tpl->setVariable("VALUE_IV_USR_ID", $data->usr_id);
4694  $this->tpl->setVariable("VALUE_IV_LOGIN", $data->login);
4695  $this->tpl->setVariable("VALUE_IV_FIRSTNAME", $data->firstname);
4696  $this->tpl->setVariable("VALUE_IV_LASTNAME", $data->lastname);
4697  $this->tpl->setVariable("VALUE_IV_CLIENT_IP", $data->clientip);
4698  $this->tpl->setVariable("VALUE_IV_TEST_FINISHED", ($data->test_finished==1)?$finished.$passes:$passes);
4699  $this->tpl->setVariable("VALUE_IV_TEST_STARTED", ($data->test_started==1)?$started:"&nbsp;");
4700  if (strlen($data->usr_id))
4701  {
4702  $last_access = $this->object->_getLastAccess($data->active_id);
4703  if (!strlen($last_access))
4704  {
4705  $this->tpl->setVariable("VALUE_IV_LAST_ACCESS", $this->lng->txt("not_yet_accessed"));
4706  }
4707  else
4708  {
4709  $this->tpl->setVariable("VALUE_IV_LAST_ACCESS", ilDatePresentation::formatDate(new ilDateTime($last_access,IL_CAL_DATETIME)));
4710  }
4711  }
4712  else
4713  {
4714  $last_access = $this->lng->txt("not_yet_accessed");
4715  $this->tpl->setVariable("VALUE_IV_LAST_ACCESS", $last_access);
4716  }
4717  $this->ctrl->setParameter($this, "active_id", $data->active_id);
4718  if ($data->test_started)
4719  {
4720  $this->tpl->setVariable("VALUE_TST_SHOW_RESULTS", $this->lng->txt("tst_show_results"));
4721  $this->ctrl->setParameterByClass("iltestevaluationgui", "active_id", $data->active_id);
4722  $this->tpl->setVariable("URL_TST_SHOW_RESULTS", $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "outParticipantsResultsOverview"));
4723  }
4724  $counter++;
4725  $this->tpl->parseCurrentBlock();
4726  }
4727  if (count($data_array))
4728  {
4729  $this->tpl->setCurrentBlock("selectall");
4730  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
4731  $counter++;
4732  $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
4733  $this->tpl->parseCurrentBlock();
4734  }
4735  $this->tpl->setCurrentBlock($block_result);
4736  $this->tpl->setVariable("$title_label", "<img src=\"" . ilUtil::getImagePath("icon_usr_b.gif") . "\" alt=\"".$this->lng->txt("objs_usr")."\" align=\"middle\" /> " . $title_text);
4737  $this->tpl->setVariable("TEXT_IV_LOGIN", $this->lng->txt("login"));
4738  $this->tpl->setVariable("TEXT_IV_FIRSTNAME", $this->lng->txt("firstname"));
4739  $this->tpl->setVariable("TEXT_IV_LASTNAME", $this->lng->txt("lastname"));
4740  $this->tpl->setVariable("TEXT_IV_CLIENT_IP", $this->lng->txt("clientip"));
4741  $this->tpl->setVariable("TEXT_IV_TEST_FINISHED", $this->lng->txt("tst_finished"));
4742  $this->tpl->setVariable("TEXT_IV_TEST_STARTED", $this->lng->txt("tst_started"));
4743  $this->tpl->setVariable("TEXT_IV_LAST_ACCESS", $this->lng->txt("last_access"));
4744  $this->tpl->parseCurrentBlock();
4745  break;
4746  case "iv_participants":
4747  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
4748  {
4749  foreach ($buttons as $arr)
4750  {
4751  foreach ($arr as $val => $cat)
4752  {
4753  $this->tpl->setCurrentBlock("commandoption");
4754  $this->tpl->setVariable("OPTION_NAME", $this->lng->txt($cat));
4755  $this->tpl->setVariable("OPTION_VALUE", $val);
4756  $this->tpl->parseCurrentBlock();
4757  }
4758  }
4759  $this->tpl->setCurrentBlock("user_action_buttons");
4760  $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\"/>");
4761  $this->tpl->setVariable("VALUE_SUBMIT", $this->lng->txt("submit"));
4762  $this->tpl->parseCurrentBlock();
4763  }
4764  $finished = "<img border=\"0\" align=\"middle\" src=\"".ilUtil::getImagePath("icon_ok.gif") . "\" alt=\"".$this->lng->txt("checkbox_checked")."\" />";
4765  $started = "<img border=\"0\" align=\"middle\" src=\"".ilUtil::getImagePath("icon_ok.gif") . "\" alt=\"".$this->lng->txt("checkbox_checked")."\" />" ;
4766  $counter = 0;
4767  foreach ($data_array as $data)
4768  {
4769  $maxpass = $this->object->_getMaxPass($data->active_id);
4770  if (!is_null($maxpass))
4771  {
4772  $maxpass += 1;
4773  }
4774  $passes = ($maxpass) ? (($maxpass == 1) ? sprintf($this->lng->txt("pass_finished"), $maxpass) : sprintf($this->lng->txt("passes_finished"), $maxpass)) : "&nbsp;";
4775  $this->tpl->setCurrentBlock($block_row);
4776  $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
4777  $this->tpl->setVariable("COUNTER", $data->active_id);
4778  $this->tpl->setVariable("VALUE_IV_USR_ID", $data->active_id);
4779  $this->tpl->setVariable("VALUE_IV_LOGIN", $data->login);
4780  $this->tpl->setVariable("VALUE_IV_FIRSTNAME", $data->firstname);
4781  $this->tpl->setVariable("VALUE_IV_LASTNAME", $data->lastname);
4782  $this->tpl->setVariable("VALUE_IV_TEST_FINISHED", ($data->test_finished==1)?$finished.$passes:$passes);
4783  $this->tpl->setVariable("VALUE_IV_TEST_STARTED", ($data->test_started==1)?$started:"&nbsp;");
4784  if (strlen($data->active_id))
4785  {
4786  $last_access = $this->object->_getLastAccess($data->active_id);
4787  $this->tpl->setVariable("VALUE_IV_LAST_ACCESS", ilDatePresentation::formatDate(new ilDateTime($last_access,IL_CAL_DATETIME)));
4788 
4789  }
4790  else
4791  {
4792  $last_access = $this->lng->txt("not_yet_accessed");
4793  $this->tpl->setVariable("VALUE_IV_LAST_ACCESS", $last_access);
4794  }
4795  $this->ctrl->setParameter($this, "active_id", $data->active_id);
4796  if ($data->test_started)
4797  {
4798  $this->tpl->setVariable("VALUE_TST_SHOW_RESULTS", $this->lng->txt("tst_show_results"));
4799  $this->ctrl->setParameterByClass("iltestevaluationgui", "active_id", $data->active_id);
4800  $this->tpl->setVariable("URL_TST_SHOW_RESULTS", $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "outParticipantsResultsOverview"));
4801  }
4802  $counter++;
4803  $this->tpl->parseCurrentBlock();
4804  }
4805  if (count($data_array))
4806  {
4807  $this->tpl->setCurrentBlock("selectall");
4808  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
4809  $counter++;
4810  $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
4811  $this->tpl->parseCurrentBlock();
4812  }
4813  $this->tpl->setCurrentBlock($block_result);
4814  $this->tpl->setVariable("$title_label", "<img src=\"" . ilUtil::getImagePath("icon_usr_b.gif") . "\" alt=\"".$this->lng->txt("objs_usr")."\" align=\"middle\" /> " . $title_text);
4815  $this->tpl->setVariable("TEXT_IV_LOGIN", $this->lng->txt("login"));
4816  $this->tpl->setVariable("TEXT_IV_FIRSTNAME", $this->lng->txt("firstname"));
4817  $this->tpl->setVariable("TEXT_IV_LASTNAME", $this->lng->txt("lastname"));
4818  $this->tpl->setVariable("TEXT_IV_TEST_FINISHED", $this->lng->txt("tst_finished"));
4819  $this->tpl->setVariable("TEXT_IV_TEST_STARTED", $this->lng->txt("tst_started"));
4820  $this->tpl->setVariable("TEXT_IV_LAST_ACCESS", $this->lng->txt("last_access"));
4821  $this->tpl->parseCurrentBlock();
4822  break;
4823  case "usr":
4824  $counter = 0;
4825  foreach ($data_array as $data)
4826  {
4827  $this->tpl->setCurrentBlock($block_row);
4828  $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
4829  $this->tpl->setVariable("COUNTER", $data->usr_id);
4830  $this->tpl->setVariable("VALUE_LOGIN", $data->login);
4831  $this->tpl->setVariable("VALUE_FIRSTNAME", $data->firstname);
4832  $this->tpl->setVariable("VALUE_LASTNAME", $data->lastname);
4833  $this->tpl->setVariable("VALUE_CLIENT_IP", $data->clientip);
4834  $counter++;
4835  $this->tpl->parseCurrentBlock();
4836  }
4837  if (count($data_array))
4838  {
4839  $this->tpl->setCurrentBlock("selectall_user_row");
4840  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
4841  $counter++;
4842  $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
4843  $this->tpl->parseCurrentBlock();
4844  }
4845  $this->tpl->setCurrentBlock($block_result);
4846  $this->tpl->setVariable("$title_label", "<img src=\"" . ilUtil::getImagePath("icon_usr_b.gif") . "\" alt=\"".$this->lng->txt("objs_usr")."\" align=\"middle\" /> " . $title_text);
4847  $this->tpl->setVariable("TEXT_LOGIN", $this->lng->txt("login"));
4848  $this->tpl->setVariable("TEXT_FIRSTNAME", $this->lng->txt("firstname"));
4849  $this->tpl->setVariable("TEXT_LASTNAME", $this->lng->txt("lastname"));
4850  $this->tpl->setVariable("TEXT_CLIENT_IP", $this->lng->txt("clientip"));
4851 
4852  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
4853  {
4854  foreach ($buttons as $cat)
4855  {
4856  $this->tpl->setVariable("VALUE_" . strtoupper($cat), $this->lng->txt($cat));
4857  }
4858  $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\"/>");
4859  }
4860  $this->tpl->parseCurrentBlock();
4861  break;
4862 
4863  case "role":
4864  case "grp":
4865  $counter = 0;
4866  foreach ($data_array as $key => $data)
4867  {
4868  $this->tpl->setCurrentBlock($block_row);
4869  $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
4870  $this->tpl->setVariable("COUNTER", $key);
4871  $this->tpl->setVariable("VALUE_TITLE", $data->title);
4872  $this->tpl->setVariable("VALUE_DESCRIPTION", $data->description);
4873  $counter++;
4874  $this->tpl->parseCurrentBlock();
4875  }
4876  if (count($data_array))
4877  {
4878  $this->tpl->setCurrentBlock("selectall_" . $a_type . "_row");
4879  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
4880  $counter++;
4881  $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
4882  $this->tpl->parseCurrentBlock();
4883  }
4884  $this->tpl->setCurrentBlock($block_result);
4885  $this->tpl->setVariable("$title_label", "<img src=\"" . ilUtil::getImagePath("icon_".$a_type."_b.gif") . "\" align=\"middle\" alt=\"".$this->lng->txt("objs_".$a_type)."\" /> " . $title_text);
4886  $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
4887  $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
4888  if ($ilAccess->checkAccess("write", "", $this->object->getRefId()))
4889  {
4890  foreach ($buttons as $cat)
4891  {
4892  $this->tpl->setVariable("VALUE_" . strtoupper($cat), $this->lng->txt($cat));
4893  }
4894  $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\"/>");
4895  }
4896  $this->tpl->parseCurrentBlock();
4897  break;
4898  }
4899  }
4900 
4902  {
4903  $countusers = 0;
4904  $countgroups = 0;
4905  $countroles = 0;
4906  // add users
4907  if (is_array($_POST["user_select"]))
4908  {
4909  $i = 0;
4910  foreach ($_POST["user_select"] as $user_id)
4911  {
4912  $client_ip = $_POST["client_ip"][$i];
4913  $this->object->inviteUser($user_id, $client_ip);
4914  $countusers++;
4915  $i++;
4916  }
4917  }
4918  // add groups members
4919  if (is_array($_POST["group_select"]))
4920  {
4921  foreach ($_POST["group_select"] as $group_id)
4922  {
4923  $this->object->inviteGroup($group_id);
4924  $countgroups++;
4925  }
4926  }
4927  // add role members
4928  if (is_array($_POST["role_select"]))
4929  {
4930  foreach ($_POST["role_select"] as $role_id)
4931  {
4932  $this->object->inviteRole($role_id);
4933  $countroles++;
4934  }
4935  }
4936  $message = "";
4937  if ($countusers)
4938  {
4939  $message = $this->lng->txt("tst_invited_selected_users");
4940  }
4941  if ($countgroups)
4942  {
4943  if (strlen($message)) $message .= "<br />";
4944  $message = $this->lng->txt("tst_invited_selected_groups");
4945  }
4946  if ($countroles)
4947  {
4948  if (strlen($message)) $message .= "<br />";
4949  $message = $this->lng->txt("tst_invited_selected_roles");
4950  }
4951  if (strlen($message))
4952  {
4953  ilUtil::sendInfo($message, TRUE);
4954  }
4955  else
4956  {
4957  ilUtil::sendInfo($this->lng->txt("tst_invited_nobody"), TRUE);
4958  }
4959 
4960  $this->ctrl->redirect($this, "inviteParticipants");
4961  }
4962 
4964  {
4965  $this->inviteParticipantsObject();
4966  }
4967 
4975  function defaultsObject()
4976  {
4977  global $ilUser;
4978 
4979  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_defaults.html", "Modules/Test");
4980 
4981  $maxentries = $ilUser->getPref("hits_per_page");
4982  if ($maxentries < 1)
4983  {
4984  $maxentries = 9999;
4985  }
4986 
4987  $offset = $_GET["offset"] ? $_GET["offset"] : 0;
4988  $sortby = $_GET["sort_by"] ? $_GET["sort_by"] : "name";
4989  $sortorder = $_GET["sort_order"] ? $_GET["sort_order"] : "asc";
4990 
4991  $defaults =& $this->object->getAvailableDefaults($sortby, $sortorder);
4992  if (count($defaults) > 0)
4993  {
4994  $tablerows = array();
4995  foreach ($defaults as $row)
4996  {
4997  array_push($tablerows, array("checkbox" => "<input type=\"checkbox\" name=\"chb_defaults[]\" value=\"" . $row["test_defaults_id"] . "\"/>", "name" => $row["name"]));
4998  }
4999  $headervars = array("", "name");
5000 
5001  include_once "./Services/Table/classes/class.ilTableGUI.php";
5002  $tbl = new ilTableGUI(0, FALSE);
5003  $tbl->setTitle($this->lng->txt("tst_defaults_available"));
5004  $header_names = array(
5005  "",
5006  $this->lng->txt("title")
5007  );
5008  $tbl->setHeaderNames($header_names);
5009 
5010  $tbl->disable("sort");
5011  $tbl->disable("auto_sort");
5012  $tbl->enable("title");
5013  $tbl->enable("action");
5014  $tbl->enable("select_all");
5015  $tbl->setLimit($maxentries);
5016  $tbl->setOffset($offset);
5017  $tbl->setData($tablerows);
5018  $tbl->setMaxCount(count($tablerows));
5019  $tbl->setOrderDirection($sortorder);
5020  $tbl->setSelectAllCheckbox("chb_defaults");
5021  $tbl->setFormName("formDefaults");
5022  $tbl->addActionButton("deleteDefaults", $this->lng->txt("delete"));
5023  $tbl->addActionButton("applyDefaults", $this->lng->txt("apply"));
5024 
5025  $header_params = $this->ctrl->getParameterArray($this, "defaults");
5026  $tbl->setHeaderVars($headervars, $header_params);
5027 
5028  // footer
5029  $tbl->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next"));
5030  // render table
5031  $tableoutput = $tbl->render();
5032  $this->tpl->setVariable("TEST_DEFAULTS_TABLE", $tableoutput);
5033  }
5034  else
5035  {
5036  $this->tpl->setVariable("TEST_DEFAULTS_TABLE", $this->lng->txt("tst_defaults_not_defined"));
5037  }
5038  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "addDefaults"));
5039  $this->tpl->setVariable("BUTTON_ADD", $this->lng->txt("add"));
5040  $this->tpl->setVariable("TEXT_DEFAULTS_OF_TEST", $this->lng->txt("tst_defaults_defaults_of_test"));
5041  }
5042 
5047  {
5048  if (count($_POST["chb_defaults"]))
5049  {
5050  foreach ($_POST["chb_defaults"] as $test_default_id)
5051  {
5052  $this->object->deleteDefaults($test_default_id);
5053  }
5054  }
5055  $this->defaultsObject();
5056  }
5057 
5062  {
5063  if (count($_POST["chb_defaults"]) == 1)
5064  {
5065  foreach ($_POST["chb_defaults"] as $test_default_id)
5066  {
5067  $result = $this->object->applyDefaults($test_default_id);
5068  if (!$result)
5069  {
5070  ilUtil::sendInfo($this->lng->txt("tst_defaults_apply_not_possible"));
5071  }
5072  else
5073  {
5074  ilUtil::sendInfo($this->lng->txt("tst_defaults_applied"));
5075  }
5076  }
5077  }
5078  else
5079  {
5080  ilUtil::sendInfo($this->lng->txt("tst_defaults_apply_select_one"));
5081  }
5082  $this->defaultsObject();
5083  }
5084 
5089  {
5090  if (strlen($_POST["name"]) > 0)
5091  {
5092  $this->object->addDefaults($_POST['name']);
5093  }
5094  else
5095  {
5096  ilUtil::sendInfo($this->lng->txt("tst_defaults_enter_name"));
5097  }
5098  $this->defaultsObject();
5099  }
5100 
5106  function infoScreenObject()
5107  {
5108  $this->ctrl->setCmd("showSummary");
5109  $this->ctrl->setCmdClass("ilinfoscreengui");
5110  $this->infoScreen();
5111  }
5112 
5114  {
5115  $this->ctrl->setCmd("showSummary");
5116  $this->ctrl->setCmdClass("ilinfoscreengui");
5117  $this->infoScreen($_SESSION["lock"]);
5118  }
5119 
5123  function infoScreen($session_lock = "")
5124  {
5125  global $ilAccess;
5126  global $ilUser;
5127 
5128  // Disabled
5129  /*
5130  if ($_GET['crs_show_result'])
5131  {
5132  $this->object->hideCorrectAnsweredQuestions();
5133  }
5134  else
5135  */
5136  {
5137  if ($this->object->getTestSequence()->hasHiddenQuestions())
5138  {
5139  $this->object->getTestSequence()->clearHiddenQuestions();
5140  $this->object->getTestSequence()->saveToDb();
5141  }
5142  }
5143 
5144  if (!$ilAccess->checkAccess("visible", "", $this->ref_id))
5145  {
5146  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
5147  }
5148 
5149  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
5150  $info = new ilInfoScreenGUI($this);
5151 
5152  $seq = $this->object->getTestSession()->getLastSequence();
5153 
5154  include_once "./Modules/Test/classes/class.ilTestOutputGUI.php";
5155  $output_gui =& new ilTestOutputGUI($this->object);
5156  $this->ctrl->setParameter($output_gui, "sequence", $seq);
5157  $info->setFormAction($this->ctrl->getFormAction($output_gui));
5158  if (strlen($session_lock))
5159  {
5160  $info->addHiddenElement("lock", $session_lock);
5161  }
5162  else
5163  {
5164  $info->addHiddenElement("lock", md5($_COOKIE['PHPSESSID'] . time()));
5165  }
5166  $online_access = false;
5167  if ($this->object->getFixedParticipants())
5168  {
5169  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
5170  $online_access_result = ilObjTestAccess::_lookupOnlineTestAccess($this->object->getId(), $ilUser->getId());
5171  if ($online_access_result === true)
5172  {
5173  $online_access = true;
5174  }
5175  else
5176  {
5177  ilUtil::sendInfo($online_access_result);
5178  }
5179  }
5180  if ($this->object->isComplete())
5181  {
5182  if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id))
5183  {
5184  $executable = $this->object->isExecutable($ilUser->getId(), $allowPassIncrease = TRUE);
5185  if ($executable["executable"])
5186  {
5187  if ($this->object->getTestSession()->getActiveId() > 0)
5188  {
5189  // resume test
5190  $resume_text = $this->lng->txt("tst_resume_test");
5191  if (($seq < 1) || ($seq == $this->object->getTestSequence()->getFirstSequence()))
5192  {
5193  $resume_text = $this->object->getStartTestLabel($this->object->getTestSession()->getActiveId());
5194  }
5195  // Disabled
5196  #if(!$_GET['crs_show_result'] or $this->object->getTestSequence()->getFirstSequence())
5197  {
5198  $info->addFormButton("resume", $resume_text);
5199  }
5200  }
5201  else
5202  {
5203  // start new test
5204  $info->addFormButton("start", $this->object->getStartTestLabel($this->object->getTestSession()->getActiveId()));
5205  }
5206  }
5207  else
5208  {
5209  ilUtil::sendInfo($executable["errormessage"]);
5210  }
5211  if ($this->object->getTestSession()->getActiveId() > 0)
5212  {
5213  // test results button
5214  if ($this->object->canShowTestResults($ilUser->getId()))
5215  {
5216  $info->addFormButton("outUserResultsOverview", $this->lng->txt("tst_show_results"));
5217  }
5218  }
5219  }
5220  if ($this->object->getTestSession()->getActiveId() > 0)
5221  {
5222  if ($this->object->canShowSolutionPrintview($ilUser->getId()))
5223  {
5224  $info->addFormButton("outUserListOfAnswerPasses", $this->lng->txt("tst_list_of_answers_show"));
5225  }
5226  }
5227  }
5228 
5229  if ($this->object->getShowInfo())
5230  {
5231  $info->enablePrivateNotes();
5232 
5233  }
5234  if (strlen($this->object->getIntroduction()))
5235  {
5236  $info->addSection($this->lng->txt("tst_introduction"));
5237  $info->addProperty("", $this->object->prepareTextareaOutput($this->object->getIntroduction()));
5238  }
5239 
5240  $info->addSection($this->lng->txt("tst_general_properties"));
5241  if ($this->object->getShowInfo())
5242  {
5243  $info->addProperty($this->lng->txt("author"), $this->object->getAuthor());
5244  $info->addProperty($this->lng->txt("title"), $this->object->getTitle());
5245  }
5246  if ($this->object->isComplete())
5247  {
5248  if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id))
5249  {
5250  if ($this->object->getShowInfo() || !$this->object->getForceJS())
5251  {
5252  // use javascript
5253  $checked_javascript = false;
5254  if ($this->object->getJavaScriptOutput())
5255  {
5256  $checked_javascript = true;
5257  }
5258  if ($this->object->getForceJS())
5259  {
5260  $info->addProperty($this->lng->txt("tst_test_output"), $this->lng->txt("tst_use_javascript"));
5261  }
5262  else
5263  {
5264  $info->addPropertyCheckbox($this->lng->txt("tst_test_output"), "chb_javascript", 1, $this->lng->txt("tst_use_javascript"), $checked_javascript);
5265  }
5266  }
5267  // hide previous results
5268  if (!$this->object->isRandomTest())
5269  {
5270  if ($this->object->getNrOfTries() != 1)
5271  {
5272  if ($this->object->getUsePreviousAnswers() == 0)
5273  {
5274  if ($this->object->getShowInfo())
5275  {
5276  $info->addProperty($this->lng->txt("tst_use_previous_answers"), $this->lng->txt("tst_dont_use_previous_answers"));
5277  }
5278  }
5279  else
5280  {
5281  $use_previous_answers = FALSE;
5282  if ($ilUser->prefs["tst_use_previous_answers"])
5283  {
5284  $checked_previous_answers = TRUE;
5285  }
5286  $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);
5287  }
5288  }
5289  }
5290  if ($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
5291  {
5292  $info->addPropertyTextinput($this->lng->txt("enter_anonymous_code"), "anonymous_id", "", 8, "setAnonymousId", $this->lng->txt("submit"));
5293  }
5294  }
5295  }
5296 
5297  if ($this->object->getShowInfo())
5298  {
5299  $info->addSection($this->lng->txt("tst_sequence_properties"));
5300  $info->addProperty($this->lng->txt("tst_sequence"), $this->lng->txt(($this->object->getSequenceSettings() == TEST_FIXED_SEQUENCE)? "tst_sequence_fixed":"tst_sequence_postpone"));
5301 
5302  $info->addSection($this->lng->txt("tst_heading_scoring"));
5303  $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"));
5304  $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"));
5305  if ($this->object->isRandomTest())
5306  {
5307  $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"));
5308  }
5309 
5310  $info->addSection($this->lng->txt("tst_score_reporting"));
5311  $score_reporting_text = "";
5312  switch ($this->object->getScoreReporting())
5313  {
5314  case REPORT_AFTER_TEST:
5315  $score_reporting_text = $this->lng->txt("tst_report_after_test");
5316  break;
5317  case REPORT_ALWAYS:
5318  $score_reporting_text = $this->lng->txt("tst_report_after_first_question");
5319  break;
5320  case REPORT_AFTER_DATE:
5321  $score_reporting_text = $this->lng->txt("tst_report_after_date");
5322  break;
5323  }
5324  $info->addProperty($this->lng->txt("tst_score_reporting"), $score_reporting_text);
5325  $reporting_date = $this->object->getReportingDate();
5326  if ($reporting_date)
5327  {
5328  #preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $reporting_date, $matches);
5329  #$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]));
5330  #$info->addProperty($this->lng->txt("tst_score_reporting_date"), $txt_reporting_date);
5331  $info->addProperty($this->lng->txt('tst_score_reporting_date'),
5333  }
5334 
5335  $info->addSection($this->lng->txt("tst_session_settings"));
5336  $info->addProperty($this->lng->txt("tst_nr_of_tries"), ($this->object->getNrOfTries() == 0)?$this->lng->txt("unlimited"):$this->object->getNrOfTries());
5337  if ($this->object->getNrOfTries() != 1)
5338  {
5339  $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());
5340  }
5341 
5342  if ($this->object->getEnableProcessingTime())
5343  {
5344  $info->addProperty($this->lng->txt("tst_processing_time"), $this->object->getProcessingTime());
5345  }
5346  if (strlen($this->object->getAllowedUsers()) && ($this->object->getAllowedUsersTimeGap()))
5347  {
5348  $info->addProperty($this->lng->txt("tst_allowed_users"), $this->object->getAllowedUsers());
5349  }
5350 
5351  $starting_time = $this->object->getStartingTime();
5352  if ($starting_time)
5353  {
5354  $info->addProperty($this->lng->txt("tst_starting_time"),
5356  }
5357  $ending_time = $this->object->getEndingTime();
5358  if ($ending_time)
5359  {
5360  $info->addProperty($this->lng->txt("tst_ending_time"),
5362  }
5363  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
5364  // forward the command
5365 
5366  if($_GET['crs_show_result'] and !$this->object->getTestSequence()->getFirstSequence())
5367  {
5368  #ilUtil::sendInfo($this->lng->txt('crs_all_questions_answered_successfully'));
5369  }
5370  }
5371 
5372  $this->ctrl->forwardCommand($info);
5373  }
5374 
5375  function addLocatorItems()
5376  {
5377  global $ilLocator;
5378  switch ($this->ctrl->getCmd())
5379  {
5380  case "run":
5381  case "infoScreen":
5382  case "redirectToInfoScreen":
5383  case "start":
5384  case "resume":
5385  case "previous":
5386  case "next":
5387  case "summary":
5388  case "finishTest":
5389  case "outCorrectSolution":
5390  case "passDetails":
5391  case "showAnswersOfUser":
5392  case "outUserResultsOverview":
5393  case "backFromSummary":
5394  case "show_answers":
5395  case "setsolved":
5396  case "resetsolved":
5397  case "outTestSummary":
5398  case "outQuestionSummary":
5399  case "gotoQuestion":
5400  case "selectImagemapRegion":
5401  case "confirmSubmitAnswers":
5402  case "finalSubmission":
5403  case "postpone":
5404  case "redirectQuestion":
5405  case "outUserPassDetails":
5406  case "checkPassword":
5407  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"), "", $_GET["ref_id"]);
5408  break;
5409  case "eval_stat":
5410  case "evalAllUsers":
5411  case "evalUserDetail":
5412  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "eval_stat"), "", $_GET["ref_id"]);
5413  break;
5414  case "create":
5415  case "save":
5416  case "cancel":
5417  case "importFile":
5418  case "cloneAll":
5419  case "importVerifiedFile":
5420  case "cancelImport":
5421  break;
5422  default:
5423  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
5424  break;
5425  }
5426  }
5427 
5428  function getBrowseForQuestionsTab(&$tabs_gui)
5429  {
5430  global $ilAccess;
5431  if ($ilAccess->checkAccess("write", "", $this->ref_id))
5432  {
5433  // edit page
5434  $tabs_gui->setBackTarget($this->lng->txt("backtocallingtest"), $this->ctrl->getLinkTarget($this, "questions"));
5435  $tabs_gui->addTarget("tst_browse_for_questions",
5436  $this->ctrl->getLinkTarget($this, "browseForQuestions"),
5437  array("browseForQuestions", "filter", "resetFilter", "resetTextFilter", "insertQuestions"),
5438  "", "", TRUE
5439  );
5440  }
5441  }
5442 
5443  function getRandomQuestionsTab(&$tabs_gui)
5444  {
5445  global $ilAccess;
5446  if ($ilAccess->checkAccess("write", "", $this->ref_id))
5447  {
5448  // edit page
5449  $tabs_gui->setBackTarget($this->lng->txt("backtocallingtest"), $this->ctrl->getLinkTarget($this, "questions"));
5450  $tabs_gui->addTarget("random_selection",
5451  $this->ctrl->getLinkTarget($this, "randomQuestions"),
5452  array("randomQuestions"),
5453  "", ""
5454  );
5455  }
5456  }
5457 
5458  function statisticsObject()
5459  {
5460  }
5461 
5466  {
5467  include_once "./Modules/Test/classes/class.ilTestCertificateGUI.php";
5468  $output_gui = new ilTestCertificateGUI($this->object);
5469  $output_gui->certificateEditor();
5470  }
5471 
5473  {
5474  global $ilTabs;
5475 
5476  // questions subtab
5477  $ilTabs->addSubTabTarget("edit_test_questions",
5478  $this->ctrl->getLinkTarget($this,'questions'),
5479  array("questions", "browseForQuestions", "questionBrowser", "createQuestion",
5480  "randomselect", "filter", "resetFilter", "insertQuestions",
5481  "back", "createRandomSelection", "cancelRandomSelect",
5482  "insertRandomSelection", "removeQuestions", "moveQuestions",
5483  "insertQuestionsBefore", "insertQuestionsAfter", "confirmRemoveQuestions",
5484  "cancelRemoveQuestions", "executeCreateQuestion", "cancelCreateQuestion",
5485  "addQuestionpool", "saveRandomQuestions", "saveQuestionSelectionMode"),
5486  "");
5487 
5488  // print view subtab
5489  if (!$this->object->isRandomTest())
5490  {
5491  $ilTabs->addSubTabTarget("print_view",
5492  $this->ctrl->getLinkTarget($this,'print'),
5493  "print", "");
5494  }
5495 
5496  }
5497 
5499  {
5500  global $ilTabs;
5501 
5502  // user results subtab
5503  $ilTabs->addSubTabTarget("eval_all_users",
5504  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "outEvaluation"),
5505  array("outEvaluation", "detailedEvaluation", "exportEvaluation", "evalUserDetail", "passDetails",
5506  "outStatisticsResultsOverview", "statisticsPassDetails")
5507  , "");
5508 
5509  // aggregated results subtab
5510  $ilTabs->addSubTabTarget("tst_results_aggregated",
5511  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "eval_a"),
5512  array("eval_a"),
5513  "", "");
5514 
5515  if ($this->object->hasPDFProcessing())
5516  {
5517  // question export
5518  $ilTabs->addSubTabTarget("tst_single_results",
5519  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "singleResults"),
5520  array("singleResults"),
5521  "", "");
5522  }
5523 
5524  // settings
5525  $ilTabs->addSubTabTarget("settings",
5526  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "evalSettings"),
5527  array("evalSettings", "saveEvalSettings"),
5528  "", "");
5529 
5530  }
5531 
5533  {
5534  global $ilTabs;
5535 
5536  // user results subtab
5537  $ilTabs->addSubTabTarget("participants_data",
5538  $this->ctrl->getLinkTarget($this,'participants'),
5539  array("participants", "saveFixedParticipantsStatus",
5540  "showParticipantAnswersForAuthor", "showResults",
5541  "confirmDeleteAllUserData",
5542  "deleteAllUserResults",
5543  "cancelDeleteAllUserData", "deleteSingleUserResults",
5544  "outParticipantsResultsOverview", "outParticipantsPassDetails",
5545  "showPassOverview", "showUserAnswers", "participantsAction"
5546  ),
5547  "", "");
5548 
5549  // aggregated results subtab
5550  $ilTabs->addSubTabTarget("participants_invitation",
5551  $this->ctrl->getLinkTarget($this, "inviteParticipants"),
5552  array("inviteParticipants", "searchParticipants"),
5553  "", "");
5554 
5555  }
5556 
5558  {
5559  global $ilTabs, $ilias;
5560 
5561  // general subtab
5562  $force_active = ($this->ctrl->getCmd() == "")
5563  ? true
5564  : false;
5565  $ilTabs->addSubTabTarget("general",
5566  $this->ctrl->getLinkTarget($this,'properties'),
5567  array("properties", "saveProperties", "cancelProperties"),
5568  array("", "ilobjtestgui", "iltestcertificategui"),
5569  "", $force_active);
5570 
5571  // scoring subtab
5572  $ilTabs->addSubTabTarget(
5573  "scoring",
5574  $this->ctrl->getLinkTarget($this,'scoring'),
5575  array("scoring"),
5576  array("", "ilobjtestgui", "iltestcertificategui")
5577  );
5578 
5579  // mark schema subtab
5580  $ilTabs->addSubTabTarget(
5581  "mark_schema",
5582  $this->ctrl->getLinkTarget($this,'marks'),
5583  array("marks", "addMarkStep", "deleteMarkSteps", "addSimpleMarkSchema",
5584  "saveMarks", "cancelMarks"),
5585  array("", "ilobjtestgui", "iltestcertificategui")
5586  );
5587 
5588  if ((strlen($ilias->getSetting("rpc_server_host"))) && (strlen($ilias->getSetting("rpc_server_port"))))
5589  {
5590  // certificate subtab
5591  $ilTabs->addSubTabTarget(
5592  "certificate",
5593  $this->ctrl->getLinkTarget($this,'certificate'),
5594  array("certificate", "certificateEditor", "certificateRemoveBackground", "certificateSave",
5595  "certificatePreview", "certificateDelete", "certificateUpload", "certificateImport"),
5596  array("", "ilobjtestgui", "iltestcertificategui")
5597  );
5598  }
5599 
5600  // defaults subtab
5601  $ilTabs->addSubTabTarget(
5602  "defaults",
5603  $this->ctrl->getLinkTarget($this, "defaults"),
5604  array("defaults", "deleteDefaults", "addDefaults", "applyDefaults"),
5605  array("", "ilobjtestgui", "iltestcertificategui")
5606  );
5607  }
5608 
5614  function getTabs(&$tabs_gui)
5615  {
5616  global $ilAccess,$ilUser;
5617 
5618  switch ($this->ctrl->getCmd())
5619  {
5620  case "start":
5621  case "resume":
5622  case "previous":
5623  case "next":
5624  case "summary":
5625  case "directfeedback":
5626  case "finishTest":
5627  case "outCorrectSolution":
5628  case "passDetails":
5629  case "showAnswersOfUser":
5630  case "outUserResultsOverview":
5631  case "backFromSummary":
5632  case "show_answers":
5633  case "setsolved":
5634  case "resetsolved":
5635  case "confirmFinish":
5636  case "outTestSummary":
5637  case "outQuestionSummary":
5638  case "gotoQuestion":
5639  case "selectImagemapRegion":
5640  case "confirmSubmitAnswers":
5641  case "finalSubmission":
5642  case "postpone":
5643  case "redirectQuestion":
5644  case "outUserPassDetails":
5645  case "checkPassword":
5646  case "exportCertificate":
5647  case "finishListOfAnswers":
5648  case "backConfirmFinish":
5649  case "showFinalStatement":
5650  return;
5651  break;
5652  case "browseForQuestions":
5653  case "filter":
5654  case "resetFilter":
5655  case "resetTextFilter":
5656  case "insertQuestions":
5657  return $this->getBrowseForQuestionsTab($tabs_gui);
5658  break;
5659  case "showParticipantAnswersForAuthor":
5660  case "inviteParticipants":
5661  case "participants":
5662  case "outParticipantsPassDetails":
5663  case "outParticipantsResultsOverview":
5664  case "deleteAllUserResults":
5665  case "confirmDeleteAllUserData":
5666  case "cancelDeleteAllUserData":
5667  case "deleteSingleUserResults":
5668  case "searchParticipants":
5669  case "showPassOverview":
5670  case "showUserAnswers":
5671  $this->getParticipantsSubTabs();
5672  break;
5673  case "scoring":
5674  case "properties":
5675  case "marks":
5676  case "saveMarks":
5677  case "cancelMarks":
5678  case "addMarkStep":
5679  case "deleteMarkSteps":
5680  case "addSimpleMarkSchema":
5681  case "certificate":
5682  case "certificateImport":
5683  case "certificateUpload":
5684  case "certificateEditor":
5685  case "certificateSave":
5686  case "defaults":
5687  case "deleteDefaults":
5688  case "addDefaults":
5689  case "applyDefaults":
5690  case "":
5691  if (($ilAccess->checkAccess("write", "", $this->ref_id)) && ((strcmp($this->ctrl->getCmdClass(), "ilobjtestgui") == 0) || (strcmp($this->ctrl->getCmdClass(), "iltestcertificategui") == 0) || (strlen($this->ctrl->getCmdClass()) == 0)))
5692  {
5693  $this->getSettingsSubTabs();
5694  }
5695  break;
5696  case "export":
5697  case "print":
5698  break;
5699  case "statistics":
5700  case "eval_a":
5701  case "evalSettings":
5702  case "saveEvalSettings":
5703  case "detailedEvaluation":
5704  case "outEvaluation":
5705  case "singleResults":
5706  case "exportEvaluation":
5707  case "evalUserDetail":
5708  case "passDetails":
5709  case "outStatisticsResultsOverview":
5710  case "statisticsPassDetails":
5711  $this->getStatisticsSubTabs();
5712  break;
5713  }
5714 
5715  if (strcmp(strtolower(get_class($this->object)), "ilobjtest") == 0)
5716  {
5717  // questions tab
5718  if ($ilAccess->checkAccess("write", "", $this->ref_id))
5719  {
5720  $force_active = ($_GET["up"] != "" || $_GET["down"] != "")
5721  ? true
5722  : false;
5723  if (!$force_active)
5724  {
5725  if ($_GET["browse"] == 1) $force_active = true;
5726  if (preg_match("/deleteqpl_\d+/", $this->ctrl->getCmd()))
5727  {
5728  $force_active = true;
5729  }
5730  }
5731  $tabs_gui->addTarget("assQuestions",
5732  $this->ctrl->getLinkTarget($this,'questions'),
5733  array("questions", "browseForQuestions", "questionBrowser", "createQuestion",
5734  "randomselect", "filter", "resetFilter", "insertQuestions",
5735  "back", "createRandomSelection", "cancelRandomSelect",
5736  "insertRandomSelection", "removeQuestions", "moveQuestions",
5737  "insertQuestionsBefore", "insertQuestionsAfter", "confirmRemoveQuestions",
5738  "cancelRemoveQuestions", "executeCreateQuestion", "cancelCreateQuestion",
5739  "addQuestionpool", "saveRandomQuestions", "saveQuestionSelectionMode", "print"),
5740  "", "", $force_active);
5741  }
5742 
5743  // info tab
5744  if ($ilAccess->checkAccess("visible", "", $this->ref_id))
5745  {
5746  $tabs_gui->addTarget("info_short",
5747  $this->ctrl->getLinkTarget($this,'infoScreen'),
5748  array("infoScreen", "outIntroductionPage", "showSummary",
5749  "setAnonymousId", "outUserListOfAnswerPasses", "redirectToInfoScreen"));
5750  }
5751 
5752  // settings tab
5753  if ($ilAccess->checkAccess("write", "", $this->ref_id))
5754  {
5755  $tabs_gui->addTarget("settings",
5756  $this->ctrl->getLinkTarget($this,'properties'),
5757  array("properties", "saveProperties", "cancelProperties",
5758  "marks", "addMarkStep", "deleteMarkSteps", "addSimpleMarkSchema",
5759  "saveMarks", "cancelMarks",
5760  "certificate", "certificateEditor", "certificateRemoveBackground",
5761  "certificateSave", "certificatePreview", "certificateDelete", "certificateUpload",
5762  "certificateImport", "scoring", "defaults", "addDefaults", "deleteDefaults", "applyDefaults",
5763  ""
5764  ),
5765  array("", "ilobjtestgui", "iltestcertificategui")
5766  );
5767  }
5768 
5769  if ($ilAccess->checkAccess("write", "", $this->ref_id))
5770  {
5771  // meta data
5772  $tabs_gui->addTarget("meta_data",
5773  $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'),
5774  "", "ilmdeditorgui");
5775  }
5776 
5777  if ($ilAccess->checkAccess("write", "", $this->ref_id))
5778  {
5779  // participants
5780  $tabs_gui->addTarget("participants",
5781  $this->ctrl->getLinkTarget($this,'participants'),
5782  array("participants", "searchParticipants", "addParticipants", "saveClientIP",
5783  "removeParticipant", "inviteParticipants",
5784  "saveFixedParticipantsStatus", "showParticipantAnswersForAuthor",
5785  "deleteAllUserResults",
5786  "cancelDeleteAllUserData", "deleteSingleUserResults",
5787  "outParticipantsResultsOverview", "outParticipantsPassDetails",
5788  "showPassOverview", "showUserAnswers", "participantsAction"),
5789  "");
5790 
5791  // export tab
5792  $tabs_gui->addTarget("export",
5793  $this->ctrl->getLinkTarget($this,'export'),
5794  array("export", "createExportFile", "confirmDeleteExportFile",
5795  "downloadExportFile", "deleteExportFile", "cancelDeleteExportFile"),
5796  "");
5797 
5798  include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
5800  if (count($scoring))
5801  {
5802  // scoring tab
5803  $tabs_gui->addTarget("manscoring",
5804  $this->ctrl->getLinkTargetByClass("iltestscoringgui", "manscoring"),
5805  array("manscoring", "selectParticipant", "setPointsManual", "setFeedbackManual"),
5806  "");
5807  }
5808  }
5809 
5810  if (($ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) || ($ilAccess->checkAccess("write", "", $this->ref_id)))
5811  {
5812  // statistics tab
5813  $tabs_gui->addTarget("statistics",
5814  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "outEvaluation"),
5815  array("statistics", "outEvaluation", "exportEvaluation", "detailedEvaluation", "eval_a", "evalSettings", "saveEvalSettings", "evalUserDetail",
5816  "passDetails", "outStatisticsResultsOverview", "statisticsPassDetails")
5817  , "");
5818  }
5819 
5820  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
5821  if(ilLearningProgressAccess::checkAccess($this->object->getRefId()))
5822  {
5823  $tabs_gui->addTarget('learning_progress',
5824  $this->ctrl->getLinkTargetByClass(array('illearningprogressgui'),''),
5825  '',
5826  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui'));
5827  }
5828 
5829  if ($ilAccess->checkAccess("write", "", $this->ref_id))
5830  {
5831  // history
5832  $tabs_gui->addTarget("history",
5833  $this->ctrl->getLinkTarget($this,'history'),
5834  "history", "");
5835 
5836  if ($ilAccess->checkAccess("edit_permission", "", $this->ref_id))
5837  {
5838  $tabs_gui->addTarget("perm_settings",
5839  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
5840  }
5841  }
5842  }
5843  }
5844 
5853  function _goto($a_target)
5854  {
5855  global $ilAccess, $ilErr, $lng;
5856 
5857  if ($ilAccess->checkAccess("visible", "", $a_target))
5858  {
5859  //include_once "./Services/Utilities/classes/class.ilUtil.php";
5860  $_GET["baseClass"] = "ilObjTestGUI";
5861  $_GET["cmd"] = "infoScreen";
5862  $_GET["ref_id"] = $a_target;
5863  include_once("ilias.php");
5864  exit;
5865  //ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=infoScreen&ref_id=$a_target");
5866  }
5867  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
5868  {
5869  $_GET["cmd"] = "frameset";
5870  $_GET["target"] = "";
5871  $_GET["ref_id"] = ROOT_FOLDER_ID;
5872  ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
5873  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
5874  include("repository.php");
5875  exit;
5876  }
5877 
5878  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
5879  }
5880 
5881 } // END class.ilObjTestGUI
5882 ?>