ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjTestGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once './Modules/Test/exceptions/class.ilTestException.php';
5 require_once './Services/Object/classes/class.ilObjectGUI.php';
6 require_once './Modules/Test/classes/inc.AssessmentConstants.php';
7 require_once './Modules/Test/classes/class.ilObjAssessmentFolderGUI.php';
8 require_once './Modules/Test/classes/class.ilTestExpressPage.php';
9 
39 {
41  public $object = null;
42 
45 
47  private $testPlayerFactory = null;
48 
50  private $testSessionFactory = null;
51 
53  private $testSequenceFactory = null;
54 
59  function ilObjTestGUI()
60  {
61  global $lng, $ilCtrl, $ilDB, $ilPluginAdmin, $tree;
62  $lng->loadLanguageModule("assessment");
63  $this->type = "tst";
64  $this->ctrl =& $ilCtrl;
65  $this->ctrl->saveParameter($this, array("ref_id", "test_ref_id", "calling_test", "test_express_mode", "q_id"));
66  $this->ilObjectGUI("",$_GET["ref_id"], true, false);
67 
68  if( $this->object instanceof ilObjTest )
69  {
70  require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
71  $this->testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($tree, $ilDB, $ilPluginAdmin, $this->object);
72 
73  require_once 'Modules/Test/classes/class.ilTestPlayerFactory.php';
74  $this->testPlayerFactory = new ilTestPlayerFactory($this->object);
75 
76  require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
77  $this->testSessionFactory = new ilTestSessionFactory($this->object);
78 
79  require_once 'Modules/Test/classes/class.ilTestSequenceFactory.php';
80  $this->testSequenceFactory = new ilTestSequenceFactory($ilDB, $lng, $ilPluginAdmin, $this->object);
81  }
82  }
83 
87  function executeCommand()
88  {
89  global $ilAccess, $ilNavigationHistory, $ilCtrl, $ilErr, $tpl, $lng, $ilTabs, $ilPluginAdmin, $ilDB, $tree, $ilUser;
90 
91  if((!$ilAccess->checkAccess("read", "", $_GET["ref_id"])))
92  {
93  global $ilias;
94  $ilias->raiseError($this->lng->txt("permission_denied"), $ilias->error_obj->MESSAGE);
95  }
96 
97  $cmd = $this->ctrl->getCmd("infoScreen");
98 
99  $cmdsDisabledDueToOfflineStatus = array(
100  'resumePlayer', 'resumePlayer', 'outUserResultsOverview', 'outUserListOfAnswerPasses'
101  );
102 
103  if(!$this->getCreationMode() && !$this->object->isOnline() && in_array($cmd, $cmdsDisabledDueToOfflineStatus))
104  {
105  $cmd = 'infoScreen';
106  }
107 
108  $next_class = $this->ctrl->getNextClass($this);
109  $this->ctrl->setReturn($this, "infoScreen");
110 
111  if(method_exists($this->object, "getTestStyleLocation")) $this->tpl->addCss($this->object->getTestStyleLocation("output"), "screen");
112 
113  // add entry to navigation history
114  if(!$this->getCreationMode() &&
115  $ilAccess->checkAccess("read", "", $_GET["ref_id"])
116  )
117  {
118  $ilNavigationHistory->addItem($_GET["ref_id"],
119  "ilias.php?baseClass=ilObjTestGUI&cmd=infoScreen&ref_id=" . $_GET["ref_id"], "tst");
120  }
121 
122  if(!$this->getCreationMode())
123  {
124  if(IS_PAYMENT_ENABLED)
125  {
126  require_once 'Services/Payment/classes/class.ilPaymentObject.php';
127  if(ilPaymentObject::_requiresPurchaseToAccess($this->object->getRefId(), $type = (isset($_GET['purchasetype']) ? $_GET['purchasetype'] : NULL)))
128  {
129  $this->setLocator();
130  $this->tpl->getStandardTemplate();
131 
132  include_once 'Services/Payment/classes/class.ilShopPurchaseGUI.php';
133  $pp = new ilShopPurchaseGUI((int)$_GET['ref_id']);
134  $ret = $this->ctrl->forwardCommand($pp);
135  $this->tpl->show();
136  exit();
137  }
138  }
139  }
140 
141  // elba hack for storing question id for inserting new question after
142  if($_REQUEST['prev_qid'])
143  {
144  global $___prev_question_id;
145  $___prev_question_id = $_REQUEST['prev_qid'];
146  $this->ctrl->setParameter($this, 'prev_qid', $_REQUEST['prev_qid']);
147  }
148 
149  if( !$this->getCreationMode() && $this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken() )
150  {
151  if( !$this->testQuestionSetConfigFactory->getQuestionSetConfig()->isValidRequestOnBrokenQuestionSetDepencies($next_class, $cmd) )
152  {
153  $this->ctrl->redirectByClass('ilObjTestGUI', 'infoScreen');
154  }
155  }
156 
157  switch($next_class)
158  {
159  case 'iltestexportgui':
160  if(!$ilAccess->checkAccess('write', '', $this->ref_id))
161  {
162  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
163  }
164 
165  $this->prepareOutput();
166  $this->addHeaderAction();
167  require_once 'Modules/Test/classes/class.ilTestExportGUI.php';
168  $ilCtrl->forwardCommand(new ilTestExportGUI($this));
169  break;
170 
171  case "ilinfoscreengui":
172  $this->prepareOutput();
173  $this->addHeaderAction();
174  $this->infoScreen(); // forwards command
175  break;
176  case 'ilmdeditorgui':
177  if(!$ilAccess->checkAccess('write', '', $this->object->getRefId()))
178  {
179  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
180  }
181 
182  $this->prepareOutput();
183  $this->addHeaderAction();
184  require_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
185  $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
186  $md_gui->addObserver($this->object, 'MDUpdateListener', 'General');
187 
188  $this->ctrl->forwardCommand($md_gui);
189  break;
190 
191  case "iltestoutputgui":
192  require_once "./Modules/Test/classes/class.ilTestOutputGUI.php";
193  if(!$this->object->getKioskMode()) $this->prepareOutput();
194 
195  $output_gui =& new ilTestOutputGUI($this->object);
196  $this->ctrl->forwardCommand($output_gui);
197  break;
198 
199  case "iltestplayerdynamicquestionsetgui":
200  require_once "./Modules/Test/classes/class.ilTestPlayerDynamicQuestionSetGUI.php";
201  if (!$this->object->getKioskMode()) $this->prepareOutput();
202  $output_gui =& new ilTestPlayerDynamicQuestionSetGUI($this->object);
203  $this->ctrl->forwardCommand($output_gui);
204  break;
205 
206  case "iltestevaluationgui":
207  $this->prepareOutput();
208  $this->addHeaderAction();
209  include_once "./Modules/Test/classes/class.ilTestEvaluationGUI.php";
210  $evaluation_gui =& new ilTestEvaluationGUI($this->object);
211  $this->ctrl->forwardCommand($evaluation_gui);
212  break;
213 
214  case "iltestservicegui":
215  $this->prepareOutput();
216  $this->addHeaderAction();
217  require_once "./Modules/Test/classes/class.ilTestServiceGUI.php";
218  $serviceGUI =& new ilTestServiceGUI($this->object);
219  $this->ctrl->forwardCommand($serviceGUI);
220  break;
221 
222  case 'ilpermissiongui':
223  $this->prepareOutput();
224  $this->addHeaderAction();
225  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
226  $perm_gui =& new ilPermissionGUI($this);
227  $ret =& $this->ctrl->forwardCommand($perm_gui);
228  break;
229 
230  case "illearningprogressgui":
231  $this->prepareOutput();
232  $this->addHeaderAction();
233  require_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
234  $new_gui =& new ilLearningProgressGUI(ilLearningProgressGUI::LP_CONTEXT_REPOSITORY, $this->object->getRefId());
235  $this->ctrl->forwardCommand($new_gui);
236 
237  break;
238 
239  case "ilcertificategui":
240  $this->prepareOutput();
241  $this->addHeaderAction();
242  require_once "./Services/Certificate/classes/class.ilCertificateGUI.php";
243  require_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
244  $output_gui = new ilCertificateGUI(new ilTestCertificateAdapter($this->object));
245  $this->ctrl->forwardCommand($output_gui);
246  break;
247 
248  case "iltestscoringgui":
249  $this->prepareOutput();
250  $this->addHeaderAction();
251  require_once "./Modules/Test/classes/class.ilTestScoringGUI.php";
252  $output_gui = new ilTestScoringGUI($this->object);
253  $this->ctrl->forwardCommand($output_gui);
254  break;
255 
256  case 'iltestscoringbyquestionsgui':
257  $this->prepareOutput();
258  $this->addHeaderAction();
259  include_once 'Modules/Test/classes/class.ilTestScoringByQuestionsGUI.php';
260  $output_gui = new ilTestScoringByQuestionsGUI($this->object);
261  $this->ctrl->forwardCommand($output_gui);
262  break;
263 
264  case 'ilobjtestsettingsgeneralgui':
265  $this->prepareOutput();
266  $this->addHeaderAction();
267  require_once 'Modules/Test/classes/class.ilObjTestSettingsGeneralGUI.php';
268  $gui = new ilObjTestSettingsGeneralGUI(
269  $this->ctrl, $ilAccess, $this->lng, $this->tpl, $this->tree, $ilDB, $ilPluginAdmin, $ilUser, $this
270  );
271  $this->ctrl->forwardCommand($gui);
272  break;
273 
274  case 'ilobjtestdynamicquestionsetconfiggui':
275  $this->prepareOutput();
276  $this->addHeaderAction();
277  require_once 'Modules/Test/classes/class.ilObjTestDynamicQuestionSetConfigGUI.php';
278  $gui = new ilObjTestDynamicQuestionSetConfigGUI($this->ctrl, $ilAccess, $ilTabs, $this->lng, $this->tpl, $ilDB, $tree, $ilPluginAdmin, $this->object);
279  $this->ctrl->forwardCommand($gui);
280  break;
281 
282  case 'iltestrandomquestionsetconfiggui':
283  $this->prepareOutput();
284  $this->addHeaderAction();
285  require_once 'Modules/Test/classes/class.ilTestRandomQuestionSetConfigGUI.php';
286  $gui = new ilTestRandomQuestionSetConfigGUI($this->ctrl, $ilAccess, $ilTabs, $this->lng, $this->tpl, $ilDB, $tree, $ilPluginAdmin, $this->object);
287  $this->ctrl->forwardCommand($gui);
288  break;
289 
290  case 'ilobjectcopygui':
291  $this->prepareOutput();
292  $this->addHeaderAction();
293  require_once './Services/Object/classes/class.ilObjectCopyGUI.php';
294  $cp = new ilObjectCopyGUI($this);
295  $cp->setType('tst');
296  $this->ctrl->forwardCommand($cp);
297  break;
298 
299  case 'ilrepositorysearchgui':
300  $this->prepareOutput();
301  $this->addHeaderAction();
302  require_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
303  $rep_search =& new ilRepositorySearchGUI();
304  $rep_search->setCallback($this,
305  'addParticipantsObject',
306  array()
307  );
308 
309  // Set tabs
310  $this->ctrl->setReturn($this, 'participants');
311  $ret =& $this->ctrl->forwardCommand($rep_search);
312  $this->tabs_gui->setTabActive('participants');
313  break;
314 
315  case 'ilpageeditorgui':
316  case 'iltestexpresspageobjectgui':
317 
318  require_once 'Modules/TestQuestionPool/classes/class.ilAssIncompleteQuestionPurger.php';
319  $incompleteQuestionPurger = new ilAssIncompleteQuestionPurger($ilDB);
320  $incompleteQuestionPurger->setOwnerId($ilUser->getId());
321  $incompleteQuestionPurger->purge();
322 
323  $qid = $_REQUEST['q_id'];
324 
325  // :FIXME: does not work
326  // $this->ctrl->saveParameterByClass(array('iltestexpresspageobjectgui', 'assorderingquestiongui', 'ilpageeditorgui', 'ilpcquestion', 'ilpcquestiongui'), 'test_express_mode');
327 
328  if(!$qid || $qid == 'Array')
329  {
330  $questions = $this->object->getQuestionTitlesAndIndexes();
331  if(!is_array($questions))
332  $questions = array();
333 
334  $keys = array_keys($questions);
335  $qid = $keys[0];
336 
337  $_REQUEST['q_id'] = $qid;
338  $_GET['q_id'] = $qid;
339  $_POST['q_id'] = $qid;
340  }
341 
342  $this->prepareOutput();
343  if(!in_array($cmd, array('addQuestion', 'browseForQuestions')))
344  {
345  $this->buildPageViewToolbar($qid);
346  }
347 
348  if(!$qid || in_array($cmd, array('insertQuestions', 'browseForQuestions')))
349  {
350  require_once "./Modules/Test/classes/class.ilTestExpressPageObjectGUI.php";
351  $pageObject = new ilTestExpressPageObjectGUI (0);
352  $pageObject->test_object = $this->object;
353  $ret =& $this->ctrl->forwardCommand($pageObject);
354  break;
355  }
356  require_once "./Services/Style/classes/class.ilObjStyleSheet.php";
357  $this->tpl->setCurrentBlock("ContentStyle");
358  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
360  $this->tpl->parseCurrentBlock();
361 
362  // syntax style
363  $this->tpl->setCurrentBlock("SyntaxStyle");
364  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
366  $this->tpl->parseCurrentBlock();
367  require_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
368 
369  $q_gui = assQuestionGUI::_getQuestionGUI("", $qid);
370  if(!($q_gui instanceof assQuestionGUI))
371  {
372  $this->ctrl->setParameterByClass('iltestexpresspageobjectgui', 'q_id', '');
373  $this->ctrl->redirectByClass('iltestexpresspageobjectgui', $this->ctrl->getCmd());
374  }
375 
376  $q_gui->outAdditionalOutput();
377  $q_gui->object->setObjId($this->object->getId());
378  $question = $q_gui->object;
379  $this->ctrl->saveParameter($this, "q_id");
380 
381  #$this->lng->loadLanguageModule("content");
382  $this->ctrl->setReturnByClass("ilTestExpressPageObjectGUI", "view");
383  $this->ctrl->setReturn($this, "questions");
384 
385  require_once "./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php";
386  require_once "./Modules/Test/classes/class.ilTestExpressPageObjectGUI.php";
387 
388  $page_gui = new ilTestExpressPageObjectGUI($qid);
389  $page_gui->test_object = $this->object;
390  $page_gui->setEditPreview(true);
391  $page_gui->setEnabledTabs(false);
392  if(strlen($this->ctrl->getCmd()) == 0)
393  {
394  $this->ctrl->setCmdClass(get_class($page_gui));
395  $this->ctrl->setCmd("preview");
396  }
397 
398  $page_gui->setQuestionHTML(array($q_gui->object->getId() => $q_gui->getPreview(TRUE)));
399  $page_gui->setTemplateTargetVar("ADM_CONTENT");
400 
401  $page_gui->setOutputMode($this->object->evalTotalPersons() == 0 ? "edit" : 'preview');
402 
403  $page_gui->setHeader($question->getTitle());
404  $page_gui->setFileDownloadLink($this->ctrl->getLinkTarget($this, "downloadFile"));
405  $page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "fullscreen"));
406  $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTarget($this));
407  $page_gui->setPresentationTitle($question->getTitle() . ' ['. $this->lng->txt('question_id_short') . ': ' . $question->getId() . ']');
408  $ret =& $this->ctrl->forwardCommand($page_gui);
409 
410  global $ilTabs;
411  $ilTabs->activateTab('assQuestions');
412 
413  $this->tpl->setContent($ret);
414  break;
415 
416  case 'ilassquestionpagegui':
417  require_once "./Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php";
418  //echo $_REQUEST['prev_qid'];
419  if($_REQUEST['prev_qid'])
420  {
421  $this->ctrl->setParameter($this, 'prev_qid', $_REQUEST['prev_qid']);
422  }
423 
424  $this->prepareOutput();
425  //global $___test_express_mode;
426  //$___test_express_mode = true;
427  $_GET['calling_test'] = $this->object->getRefId();
428  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
429  $this->tpl->setCurrentBlock("ContentStyle");
430  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
432  $this->tpl->parseCurrentBlock();
433 
434  // syntax style
435  $this->tpl->setCurrentBlock("SyntaxStyle");
436  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
438  $this->tpl->parseCurrentBlock();
439  require_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
440  $q_gui = assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
441  $q_gui->setQuestionTabs();
442  $q_gui->outAdditionalOutput();
443  $q_gui->object->setObjId($this->object->getId());
444  $question =& $q_gui->object;
445  $this->ctrl->saveParameter($this, "q_id");
446  $this->lng->loadLanguageModule("content");
447  $this->ctrl->setReturnByClass("ilAssQuestionPageGUI", "view");
448  $this->ctrl->setReturn($this, "questions");
449  $page_gui = new ilAssQuestionPageGUI($_GET["q_id"]);
450  $page_gui->setEditPreview(true);
451  if(strlen($this->ctrl->getCmd()) == 0)
452  {
453  $this->ctrl->setCmdClass(get_class($page_gui));
454  $this->ctrl->setCmd("preview");
455  }
456  $page_gui->setQuestionHTML(array($q_gui->object->getId() => $q_gui->getPreview(TRUE)));
457  $page_gui->setTemplateTargetVar("ADM_CONTENT");
458  $page_gui->setOutputMode($this->object->evalTotalPersons() == 0 ? "edit" : 'preview');
459  $page_gui->setHeader($question->getTitle());
460  $page_gui->setPresentationTitle($question->getTitle() . ' ['. $this->lng->txt('question_id_short') . ': ' . $question->getId() . ']');
461  $ret =& $this->ctrl->forwardCommand($page_gui);
462  $this->tpl->setContent($ret);
463  break;
464 
465  case 'ilassspecfeedbackpagegui':
466  require_once "./Modules/TestQuestionPool/classes/feedback/class.ilAssSpecFeedbackPageGUI.php";
467  $pg_gui = new ilAssSpecFeedbackPageGUI((int) $_GET["feedback_id"]);
468  $this->ctrl->forwardCommand($pg_gui);
469  break;
470 
471  case 'ilassgenfeedbackpagegui':
472  require_once "./Modules/TestQuestionPool/classes/feedback/class.ilAssGenFeedbackPageGUI.php";
473  $pg_gui = new ilAssGenFeedbackPageGUI((int) $_GET["feedback_id"]);
474  $this->ctrl->forwardCommand($pg_gui);
475  break;
476 
477  case 'illocalunitconfigurationgui':
478  $this->prepareSubGuiOutput();
479 
480  // set return target
481  $this->ctrl->setReturn($this, "questions");
482 
483  // set context tabs
484  require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
485  $questionGUI = assQuestionGUI::_getQuestionGUI('', $_GET['q_id']);
486  $questionGUI->object->setObjId($this->object->getId());
487  $questionGUI->setQuestionTabs();
488 
489  require_once 'Modules/TestQuestionPool/classes/class.ilLocalUnitConfigurationGUI.php';
490  require_once 'Modules/TestQuestionPool/classes/class.ilUnitConfigurationRepository.php';
491  $gui = new ilLocalUnitConfigurationGUI(
492  new ilUnitConfigurationRepository((int)$_GET['q_id'])
493  );
494  $this->ctrl->forwardCommand($gui);
495  break;
496 
497  case "ilcommonactiondispatchergui":
498  require_once "Services/Object/classes/class.ilCommonActionDispatcherGUI.php";
500  $this->ctrl->forwardCommand($gui);
501  break;
502 
503  case 'ilassquestionhintsgui':
504 
505  $this->prepareSubGuiOutput();
506 
507  // set return target
508  $this->ctrl->setReturn($this, "questions");
509 
510  // set context tabs
511  require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
512  $questionGUI =& assQuestionGUI::_getQuestionGUI($q_type, $_GET['q_id']);
513  $questionGUI->object->setObjId($this->object->getId());
514  $questionGUI->setQuestionTabs();
515 
516  // forward to ilAssQuestionHintsGUI
517  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintsGUI.php';
518  $gui = new ilAssQuestionHintsGUI($questionGUI);
519  $ilCtrl->forwardCommand($gui);
520 
521  break;
522 
523  case 'ilassquestionfeedbackeditinggui':
524 
525  $this->prepareSubGuiOutput();
526 
527  // set return target
528  $this->ctrl->setReturn($this, "questions");
529 
530  // set context tabs
531  require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
532  $questionGUI = assQuestionGUI::_getQuestionGUI('', $_GET['q_id']);
533  $questionGUI->object->setObjId($this->object->getId());
534  $questionGUI->setQuestionTabs();
535 
536  // forward to ilAssQuestionFeedbackGUI
537  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionFeedbackEditingGUI.php';
538  $gui = new ilAssQuestionFeedbackEditingGUI($questionGUI, $ilCtrl, $ilAccess, $tpl, $ilTabs, $lng);
539  $ilCtrl->forwardCommand($gui);
540 
541  break;
542 
543  case 'iltesttoplistgui':
544  $this->prepareOutput();
545  require_once './Modules/Test/classes/class.ilTestToplistGUI.php';
546  $gui = new ilTestToplistGUI($this);
547  $this->ctrl->forwardCommand($gui);
548  break;
549 
550  case 'ilscoringadjustmentgui':
551  $this->prepareOutput();
552  require_once './Modules/Test/classes/class.ilScoringAdjustmentGUI.php';
553  $gui = new ilScoringAdjustmentGUI($this->object);
554  $this->ctrl->forwardCommand($gui);
555  break;
556 
557  case '':
558  case 'ilobjtestgui':
559  $this->prepareOutput();
560  $this->addHeaderAction();
561  if((strcmp($cmd, "properties") == 0) && ($_GET["browse"]))
562  {
563  $this->questionBrowser();
564  return;
565  }
566  if((strcmp($cmd, "properties") == 0) && ($_GET["up"] || $_GET["down"]))
567  {
568  $this->questionsObject();
569  return;
570  }
571  $cmd .= "Object";
572  $ret =& $this->$cmd();
573  break;
574  default:
575  // elba hack for storing question id for inserting new question after
576  if($_REQUEST['prev_qid'])
577  {
578  global $___prev_question_id;
579  $___prev_question_id = $_REQUEST['prev_qid'];
580  $this->ctrl->setParameterByClass('ilassquestionpagegui', 'prev_qid', $_REQUEST['prev_qid']);
581  $this->ctrl->setParameterByClass($_GET['sel_question_types'] . 'gui', 'prev_qid', $_REQUEST['prev_qid']);
582  }
583  $this->create_question_mode = true;
584  $this->prepareOutput();
585 
586  $this->ctrl->setReturn($this, "questions");
587  require_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
588  $q_gui =& assQuestionGUI::_getQuestionGUI($_GET['sel_question_types'], $_GET["q_id"]);
589  $q_gui->object->setObjId($this->object->getId());
590  if(!$_GET['sel_question_types'])
591  $qType = assQuestion::getQuestionTypeFromDb($_GET['q_id']);
592  else
593  {
594  $qType = $_GET['sel_question_types'];
595  }
596  $this->ctrl->setParameterByClass($qType . "GUI", 'prev_qid', $_REQUEST['prev_qid']);
597  $this->ctrl->setParameterByClass($qType . "GUI", 'test_ref_id', $_REQUEST['ref_id']);
598  $this->ctrl->setParameterByClass($qType . "GUI", 'q_id', $_REQUEST['q_id']);
599  if($_REQUEST['test_express_mode'])
600  $this->ctrl->setParameterByClass($qType . "GUI", 'test_express_mode', 1);
601 
602  #global $___test_express_mode;
603  #$___test_express_mode = true;
604  if(!$q_gui->isSaveCommand())
605  $_GET['calling_test'] = $this->object->getRefId();
606 
607  $q_gui->setQuestionTabs();
608  #unset($___test_express_mode);
609  $ret =& $this->ctrl->forwardCommand($q_gui);
610  break;
611  }
612  if ( !in_array(strtolower($_GET["baseClass"]), array('iladministrationgui', 'ilrepositorygui')) &&
613  $this->getCreationMode() != true)
614  {
615  $this->tpl->show();
616  }
617  }
618 
619  private function questionsTabGatewayObject()
620  {
621  switch( $this->object->getQuestionSetType() )
622  {
624  $this->ctrl->redirectByClass('ilTestExpressPageObjectGUI', 'showPage');
625 
627  $this->ctrl->redirectByClass('ilTestRandomQuestionSetConfigGUI');
628 
630  $this->ctrl->redirectByClass('ilObjTestDynamicQuestionSetConfigGUI');
631  }
632  }
633 
642  public function createUserResults($show_pass_details, $show_answers, $show_reached_points, $show_user_results)
643  {
644  $template = new ilTemplate("tpl.il_as_tst_participants_result_output.html", TRUE, TRUE, "Modules/Test");
645  include_once "./Modules/Test/classes/class.ilTestServiceGUI.php";
646  $serviceGUI = new ilTestServiceGUI($this->object);
647  $count = 0;
648  foreach ($show_user_results as $key => $active_id)
649  {
650  $count++;
651  $results = "";
652  if ($this->object->getFixedParticipants())
653  {
654  $active_id = $this->object->getActiveIdOfUser( $active_id );
655  }
656  if ($active_id > 0)
657  {
658  $results = $serviceGUI->getResultsOfUserOutput(
659  $this->testSessionFactory->getSession( $active_id ),
660  $active_id,
661  $this->object->_getResultPass( $active_id ),
662  $show_pass_details,
663  $show_answers,
664  FALSE,
665  $show_reached_points
666  );
667  }
668  if ($count < count( $show_user_results ))
669  {
670  $template->touchBlock( "break" );
671  }
672  $template->setCurrentBlock( "user_result" );
673  $template->setVariable( "USER_RESULT", $results );
674  $template->parseCurrentBlock();
675  }
676  $template->setVariable( "BACK_TEXT", $this->lng->txt( "back" ) );
677  $template->setVariable( "BACK_URL", $this->ctrl->getLinkTargetByClass( "ilobjtestgui", "participants" ) );
678  $template->setVariable( "PRINT_TEXT", $this->lng->txt( "print" ) );
679  $template->setVariable( "PRINT_URL", "javascript:window.print();" );
680  return $template;
681  }
682 
684  {
685  require_once 'Modules/Test/classes/class.ilObjTestSettingsGeneralGUI.php';
686  $this->ctrl->redirectByClass('ilObjTestSettingsGeneralGUI', ilObjTestSettingsGeneralGUI::CMD_SHOW_FORM);
687  }
688 
697  private function prepareSubGuiOutput()
698  {
699  global $ilUser;
700 
701  $this->tpl->getStandardTemplate();
702 
703  // set locator
704  $this->setLocator();
705 
706  // catch feedback message
708 
709  // set title and description and title icon
710  $this->setTitleAndDescription();
711 
712  // BEGIN WebDAV: Display Mount Webfolder icon.
713  require_once 'Services/WebDAV/classes/class.ilDAVServer.php';
714  if (ilDAVServer::_isActive() && $ilUser->getId() != ANONYMOUS_USER_ID)
715  {
716  $this->showMountWebfolderIcon();
717  }
718  // END WebDAV: Display Mount Webfolder icon.
719  }
720 
721  function runObject()
722  {
723  $this->ctrl->redirect($this, "infoScreen");
724  }
725 
727  {
728  $this->ctrl->redirectByClass("iltestevaluationgui", "outEvaluation");
729  }
730 
734  function importFileObject()
735  {
736  $form = $this->initImportForm($_REQUEST["new_type"]);
737  if($form->checkInput())
738  {
739  $this->ctrl->setParameter($this, "new_type", $this->type);
740  $this->uploadTstObject();
741  }
742 
743  // display form to correct errors
744  $form->setValuesByPost();
745  $this->tpl->setContent($form->getHTML());
746  }
747 
748  function addDidacticTemplateOptions(array &$a_options)
749  {
750  include_once("./Modules/Test/classes/class.ilObjTest.php");
751  $tst = new ilObjTest();
752  $defaults = $tst->getAvailableDefaults();
753  if (count($defaults))
754  {
755  foreach ($defaults as $row)
756  {
757  $a_options["tstdef_".$row["test_defaults_id"]] = array($row["name"],
758  $this->lng->txt("tst_default_settings"));
759  }
760  }
761 
762  // using template?
763  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
765  if($templates)
766  {
767  foreach($templates as $item)
768  {
769  $a_options["tsttpl_".$item["id"]] = array($item["title"],
770  nl2br(trim($item["description"])));
771  }
772  }
773  }
774 
779  function afterSave(ilObject $a_new_object)
780  {
781  $tstdef = $this->getDidacticTemplateVar("tstdef");
782  if ($tstdef)
783  {
784  $testDefaultsId = $tstdef;
785  $testDefaults = ilObjTest::_getTestDefaults($testDefaultsId);
786  $a_new_object->applyDefaults($testDefaults);
787  }
788 
789  $template_id = $this->getDidacticTemplateVar("tsttpl");
790  if($template_id)
791  {
792  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
794 
795  $template_settings = $template->getSettings();
796  if($template_settings)
797  {
798  $this->applyTemplate($template_settings, $a_new_object);
799  }
800 
801  $a_new_object->setTemplate($template_id);
802  }
803 
804  $a_new_object->saveToDb();
805 
806  // always send a message
807  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
808  $this->ctrl->setParameter($this, 'ref_id', $a_new_object->getRefId());
809  $this->ctrl->redirectByClass('ilObjTestSettingsGeneralGUI');
810  }
811 
813  {
814  include_once "./Services/Utilities/classes/class.ilUtil.php";
815  $path = $this->tree->getPathFull($this->object->getRefID());
816  ilUtil::redirect($this->getReturnLocation("cancel","./ilias.php?baseClass=ilRepositoryGUI&cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
817  }
818 
822  function uploadTstObject()
823  {
824  if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
825  {
826  ilUtil::sendFailure($this->lng->txt("error_upload"));
827  $this->createObject();
828  return;
829  }
830  include_once("./Modules/Test/classes/class.ilObjTest.php");
831  // create import directory
833 
834  // copy uploaded file to import directory
835  $file = pathinfo($_FILES["xmldoc"]["name"]);
836  $full_path = $basedir."/".$_FILES["xmldoc"]["name"];
837  ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path);
838 
839  // unzip file
840  ilUtil::unzip($full_path);
841 
842  // determine filenames of xml files
843  $subdir = basename($file["basename"],".".$file["extension"]);
845  $xml_file = ilObjTest::_getImportDirectory().'/'.$subdir.'/'.$subdir.".xml";
846  $qti_file = ilObjTest::_getImportDirectory().'/'.$subdir.'/'. preg_replace("/test|tst/", "qti", $subdir).".xml";
847  $results_file = ilObjTest::_getImportDirectory().'/'.$subdir.'/'. preg_replace("/test|tst/", "results", $subdir).".xml";
848 
849  if(!is_file($qti_file))
850  {
851  ilUtil::delDir($basedir);
852  ilUtil::sendFailure($this->lng->txt("tst_import_non_ilias_zip"));
853  $this->createObject();
854  return;
855  }
856 
857  // start verification of QTI files
858  include_once "./Services/QTI/classes/class.ilQTIParser.php";
859  $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, "");
860  $result = $qtiParser->startParsing();
861  $founditems =& $qtiParser->getFoundItems();
862 
863  if (count($founditems) == 0)
864  {
865  // nothing found
866 
867  // delete import directory
868  ilUtil::delDir($basedir);
869 
870  ilUtil::sendInfo($this->lng->txt("tst_import_no_items"));
871  $this->createObject();
872  return;
873  }
874 
875  $complete = 0;
876  $incomplete = 0;
877  foreach ($founditems as $item)
878  {
879  if (strlen($item["type"]))
880  {
881  $complete++;
882  }
883  else
884  {
885  $incomplete++;
886  }
887  }
888 
889  if ($complete == 0)
890  {
891  // delete import directory
892  ilUtil::delDir($basedir);
893 
894  ilUtil::sendInfo($this->lng->txt("qpl_import_non_ilias_files"));
895  $this->createObject();
896  return;
897  }
898 
899  $_SESSION["tst_import_results_file"] = $results_file;
900  $_SESSION["tst_import_xml_file"] = $xml_file;
901  $_SESSION["tst_import_qti_file"] = $qti_file;
902  $_SESSION["tst_import_subdir"] = $subdir;
903  // display of found questions
904  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.tst_import_verification.html", "Modules/Test");
905  $row_class = array("tblrow1", "tblrow2");
906  $counter = 0;
907  foreach ($founditems as $item)
908  {
909  $this->tpl->setCurrentBlock("verification_row");
910  $this->tpl->setVariable("ROW_CLASS", $row_class[$counter++ % 2]);
911  $this->tpl->setVariable("QUESTION_TITLE", $item["title"]);
912  $this->tpl->setVariable("QUESTION_IDENT", $item["ident"]);
913  include_once "./Services/QTI/classes/class.ilQTIItem.php";
914  switch ($item["type"])
915  {
916  case "MULTIPLE CHOICE QUESTION":
918  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("qt_multiple_choice"));
919  break;
920  case "SINGLE CHOICE QUESTION":
922  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assSingleChoice"));
923  break;
924  case "NUMERIC QUESTION":
925  case QT_NUMERIC:
926  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assNumeric"));
927  break;
928  case "TEXTSUBSET QUESTION":
929  case QT_TEXTSUBSET:
930  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextSubset"));
931  break;
932  case "CLOZE QUESTION":
933  case QT_CLOZE:
934  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assClozeTest"));
935  break;
936  case "IMAGE MAP QUESTION":
937  case QT_IMAGEMAP:
938  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assImagemapQuestion"));
939  break;
940  case "JAVA APPLET QUESTION":
941  case QT_JAVAAPPLET:
942  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assJavaApplet"));
943  break;
944  case "MATCHING QUESTION":
945  case QT_MATCHING:
946  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assMatchingQuestion"));
947  break;
948  case "ORDERING QUESTION":
949  case QT_ORDERING:
950  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assOrderingQuestion"));
951  break;
952  case "TEXT QUESTION":
953  case QT_TEXT:
954  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextQuestion"));
955  break;
956  }
957  $this->tpl->parseCurrentBlock();
958  }
959 
960  // on import creation screen the pool was chosen (-1 for no pool)
961  // BUT when no pool is available the input on creation screen is missing, so the field value -1 for no pool is not submitted.
962  $QplOrTstID = isset($_POST["qpl"]) && (int)$_POST["qpl"] != 0 ? $_POST["qpl"] : -1;
963 
964  $this->tpl->setCurrentBlock("adm_content");
965  $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt("question_type"));
966  $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("question_title"));
967  $this->tpl->setVariable("FOUND_QUESTIONS_INTRODUCTION", $this->lng->txt("tst_import_verify_found_questions"));
968  $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_tst"));
969  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
970  $this->tpl->setVariable("ARROW", ilUtil::getImagePath("arrow_downright.png"));
971  $this->tpl->setVariable("QUESTIONPOOL_ID", $QplOrTstID);
972  $this->tpl->setVariable("VALUE_IMPORT", $this->lng->txt("import"));
973  $this->tpl->setVariable("VALUE_CANCEL", $this->lng->txt("cancel"));
974  $this->tpl->parseCurrentBlock();
975  }
976 
981  {
982  include_once "./Modules/Test/classes/class.ilObjTest.php";
983  // create new questionpool object
984  $newObj = new ilObjTest(0, true);
985  // set type of questionpool object
986  $newObj->setType($_GET["new_type"]);
987  // set title of questionpool object to "dummy"
988  $newObj->setTitle("dummy");
989  // set description of questionpool object
990  $newObj->setDescription("test import");
991  // create the questionpool class in the ILIAS database (object_data table)
992  $newObj->create(true);
993  // create a reference for the questionpool object in the ILIAS database (object_reference table)
994  $newObj->createReference();
995  // put the questionpool object in the administration tree
996  $newObj->putInTree($_GET["ref_id"]);
997  // get default permissions and set the permissions for the questionpool object
998  $newObj->setPermissions($_GET["ref_id"]);
999  // notify the questionpool object and all its parent objects that a "new" object was created
1000  $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
1001  // empty mark schema
1002  $newObj->mark_schema->flush();
1003 
1004  // start parsing of QTI files
1005  include_once "./Services/QTI/classes/class.ilQTIParser.php";
1006 
1007  // Handle selection of "no questionpool" as qpl_id = -1 -> use test object id instead.
1008  // TODO: chek if empty strings in $_POST["qpl_id"] relates to a bug or not
1009  if ($_POST["qpl_id"] == "-1")
1010  {
1011  $qpl_id = $newObj->id;
1012  }
1013  else
1014  {
1015  $qpl_id = $_POST["qpl_id"];
1016  }
1017 
1018  $qtiParser = new ilQTIParser($_SESSION["tst_import_qti_file"], IL_MO_PARSE_QTI, $qpl_id, $_POST["ident"]);
1019  $qtiParser->setTestObject($newObj);
1020  $result = $qtiParser->startParsing();
1021  $newObj->saveToDb();
1022 
1023  // import page data
1024  include_once ("./Modules/LearningModule/classes/class.ilContObjParser.php");
1025  $contParser = new ilContObjParser($newObj, $_SESSION["tst_import_xml_file"], $_SESSION["tst_import_subdir"]);
1026  $contParser->setQuestionMapping($qtiParser->getImportMapping());
1027  $contParser->startParsing();
1028 
1029  // import test results
1030  if (@file_exists($_SESSION["tst_import_results_file"]))
1031  {
1032  include_once ("./Modules/Test/classes/class.ilTestResultsImportParser.php");
1033  $results = new ilTestResultsImportParser($_SESSION["tst_import_results_file"], $newObj);
1034  $results->startParsing();
1035  }
1036 
1037  // delete import directory
1039  ilUtil::sendSuccess($this->lng->txt("object_imported"),true);
1040 
1041  $newObj->updateMetaData();
1042 
1043  ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
1044  "&baseClass=ilObjTestGUI");
1045  }
1046 
1053  function uploadObject($redirect = true)
1054  {
1055  $this->uploadTstObject();
1056  }
1057 
1058  function confirmScoringObject($confirmCmd = 'saveScoring', $cancelCmd = 'scoring')
1059  {
1060  $this->lng->txt('tst_trigger_result_refreshing');
1061 
1062  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_properties_save_confirmation.html", "Modules/Test");
1063  $information = $this->lng->txt('tst_trigger_result_refreshing');
1064 
1065  foreach ($_POST as $key => $value)
1066  {
1067  if (strcmp($key, "cmd") == 0)
1068  {
1069  continue;
1070  }
1071 
1072  $this->populateHiddenField( $value, $key );
1073  }
1074  $this->tpl->setCurrentBlock("hidden_variable");
1075  $this->tpl->setVariable("HIDDEN_KEY", "tst_properties_confirmation");
1076  $this->tpl->setVariable("HIDDEN_VALUE", "1");
1077  $this->tpl->parseCurrentBlock();
1078  $this->tpl->setCurrentBlock("adm_content");
1079  $this->tpl->setVariable("TXT_CONFIRMATION", $this->lng->txt("confirmation"));
1080  $this->tpl->setVariable("TXT_INFORMATION", $information);
1081  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
1082  $this->tpl->setVariable("CMD_CONFIRM", $confirmCmd);
1083  $this->tpl->setVariable("BTN_CONFIRM", $this->lng->txt("confirm"));
1084  $this->tpl->setVariable("CMD_CANCEL", $cancelCmd);
1085  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
1086  }
1087 
1093  public function populateHiddenField($value, $key, $path = '')
1094  {
1095  if (is_array( $value ))
1096  {
1097  foreach ($value as $k => $v)
1098  {
1099  if (is_array($v))
1100  {
1101  $this->populateHiddenField($v, $key, $path .'['.$k.']');
1102  }
1103  else
1104  {
1105  $this->tpl->setCurrentBlock( "hidden_variable" );
1106  $this->tpl->setVariable( "HIDDEN_KEY", $key . $path . "[" . $k . "]" );
1107  $this->tpl->setVariable( "HIDDEN_VALUE", $v );
1108  $this->tpl->parseCurrentBlock();
1109  }
1110  }
1111  }
1112  else
1113  {
1114  $this->tpl->setCurrentBlock( "hidden_variable" );
1115  $this->tpl->setVariable( "HIDDEN_KEY", $key );
1116  $this->tpl->setVariable( "HIDDEN_VALUE", $value );
1117  $this->tpl->parseCurrentBlock();
1118  }
1119  }
1120 
1127  {
1128  if(isset($_POST['reporting_ts']))
1129  {
1130  $_POST['reporting_date']['date']['y'] = date('Y', $_POST['reporting_ts'] );
1131  $_POST['reporting_date']['date']['m'] = date('m', $_POST['reporting_ts'] );
1132  $_POST['reporting_date']['date']['d'] = date('d', $_POST['reporting_ts'] );
1133  $_POST['reporting_date']['time']['h'] = date('H', $_POST['reporting_ts'] );
1134  $_POST['reporting_date']['time']['m'] = date('i', $_POST['reporting_ts'] );
1135  }
1136 
1137  $hasErrors = $this->scoringObject(true);
1138  if (!$hasErrors)
1139  {
1140  $total = $this->object->evalTotalPersons();
1141 
1142  $this->object->setCountSystem($_POST["count_system"]);
1143  $this->object->setMCScoring($_POST["mc_scoring"]);
1144  $this->object->setScoreCutting($_POST["score_cutting"]);
1145  $this->object->setPassScoring($_POST["pass_scoring"]);
1146 
1147  if(!isset($_POST['disabled_field']))
1148  {
1149  if( isset($_POST['obligations_enabled']) && $_POST['obligations_enabled'] )
1150  {
1151  $this->object->setObligationsEnabled(true);
1152  }
1153  else
1154  {
1155  $this->object->setObligationsEnabled(false);
1156  }
1157 
1158  if( isset($_POST['offer_hints']) && $_POST['offer_hints'] )
1159  {
1160  $this->object->setOfferingQuestionHintsEnabled(true);
1161  }
1162  else
1163  {
1164  $this->object->setOfferingQuestionHintsEnabled(false);
1165  }
1166  }
1167  /*
1168  $this->object->setAnswerFeedback((is_array($_POST['instant_feedback']) && in_array('instant_feedback_answer', $_POST['instant_feedback'])) ? 1 : 0);
1169  $this->object->setAnswerFeedbackPoints((is_array($_POST['instant_feedback']) && in_array('instant_feedback_points', $_POST['instant_feedback'])) ? 1 : 0);
1170  $this->object->setInstantFeedbackSolution((is_array($_POST['instant_feedback']) && in_array('instant_feedback_solution', $_POST['instant_feedback'])) ? 1 : 0);
1171  */
1172 
1177  $this->object->setScoringFeedbackOptionsByArray($_POST['instant_feedback']);
1178 
1179 
1180  $this->object->setScoreReporting($_POST["results_access"]);
1181  if ($this->object->getScoreReporting() == REPORT_AFTER_DATE)
1182  {
1183  // The reporting date is given in database TIMESTAMP notation (yyyymmddhhmmss).
1184  $this->object->setReportingDate(str_replace(array(':', '-'), '', $_POST["reporting_date"]['date'].$_POST["reporting_date"]['time']));
1185  //$this->object->setReportingDate( date('YmdHis', $_POST['reporting_ts'] ));
1186  }
1187  else
1188  {
1189  $this->object->setReportingDate('');
1190  }
1191 
1192  $this->object->setShowPassDetails((is_array($_POST['results_presentation']) && in_array('pass_details', $_POST['results_presentation'])) ? 1 : 0);
1193  $this->object->setShowSolutionDetails((is_array($_POST['results_presentation']) && in_array('solution_details', $_POST['results_presentation'])) ? 1 : 0);
1194  $this->object->setShowSolutionPrintview((is_array($_POST['results_presentation']) && in_array('solution_printview', $_POST['results_presentation'])) ? 1 : 0);
1195  $this->object->setShowSolutionFeedback((is_array($_POST['results_presentation']) && in_array('solution_feedback', $_POST['results_presentation'])) ? 1 : 0);
1196  $this->object->setShowSolutionAnswersOnly((is_array($_POST['results_presentation']) && in_array('solution_answers_only', $_POST['results_presentation'])) ? 1 : 0);
1197  $this->object->setShowSolutionSignature((is_array($_POST['results_presentation']) && in_array('solution_signature', $_POST['results_presentation'])) ? 1 : 0);
1198  $this->object->setShowSolutionSuggested((is_array($_POST['results_presentation']) && in_array('solution_suggested', $_POST['results_presentation'])) ? 1 : 0);
1199  $this->object->setShowSolutionListComparison(isset($_POST['solution_compare']) && $_POST['solution_compare']);
1200  $this->object->setExportSettingsSingleChoiceShort((is_array($_POST['export_settings']) && in_array('exp_sc_short', $_POST['export_settings'])) ? 1 : 0);
1201 
1202  $this->object->setShowExamIdInTestResultsEnabled(isset($_POST['examid_in_test_res']) && $_POST['examid_in_test_res']);
1203 
1204  $this->object->setPrintBestSolutionWithResult((int) $_POST['print_bs_with_res'] ? true : false);
1205 
1206  $this->object->setPassDeletionAllowed((bool)$_POST['pass_deletion_allowed']);
1207 
1208  $this->object->saveToDb(true);
1209  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), TRUE);
1210 
1211  if ($total != 0)
1212  {
1213  $this->object->recalculateScores(true);
1214  }
1215 
1216  $this->ctrl->redirect($this, "scoring");
1217  }
1218  }
1219 
1225  function scoringObject($checkonly = FALSE)
1226  {
1227  global $ilAccess;
1228  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
1229  {
1230  // allow only write access
1231  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
1232  $this->ctrl->redirect($this, "infoScreen");
1233  }
1234 
1235 
1236  // using template?
1237  $template_settings = null;
1238  $template = $this->object->getTemplate();
1239 
1240  if($template)
1241  {
1242  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
1243  include_once "Modules/Test/classes/class.ilObjAssessmentFolderGUI.php";
1244 
1246 
1247  $template_settings = $template->getSettings();
1248  }
1249 
1250  $save = (strcmp($this->ctrl->getCmd(), "saveScoring") == 0) ? TRUE : FALSE;
1251  $total = $this->object->evalTotalPersons();
1252  $this->tpl->addJavascript("./Services/JavaScript/js/Basic.js");
1253 
1254  // Determine settings availability
1255  $setting_available = true; // In general, the scoring settings are available.
1256 
1257  if ($total != 0)
1258  {
1259  $setting_available = false; // Unless there are results from users.
1260  }
1261  if ($this->object->getScoreReporting() == 4)
1262  {
1263  $setting_available = true; // But if the results are not public since they will never be
1264  }
1265  if ($this->object->getScoreReporting() == 3 && $this->object->getReportingDate() > time())
1266  {
1267  $setting_available = true;// or the presentation date is not reached, then we can still edit them.
1268  }
1269 
1270  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1271  $form = new ilPropertyFormGUI();
1272  $form->setFormAction($this->ctrl->getFormAction($this));
1273  $form->setTableWidth("100%");
1274  $form->setId("test_properties_scoring");
1275 
1276  // scoring properties
1277  $header = new ilFormSectionHeaderGUI();
1278  $header->setTitle($this->lng->txt("test_scoring"));
1279  $form->addItem($header);
1280 
1281  // scoring system
1282  $count_system = new ilRadioGroupInputGUI($this->lng->txt("tst_text_count_system"), "count_system");
1283  $count_system->addOption(new ilRadioOption($this->lng->txt("tst_count_partial_solutions"), 0, ''));
1284  $count_system->addOption(new ilRadioOption($this->lng->txt("tst_count_correct_solutions"), 1, ''));
1285  $count_system->setValue($this->object->getCountSystem());
1286  $count_system->setInfo($this->lng->txt("tst_count_system_description"));
1287  $count_system->setDisabled(!$setting_available);
1288  $form->addItem($count_system);
1289 
1290  // mc questions
1291  $mc_scoring = new ilRadioGroupInputGUI($this->lng->txt("tst_score_mcmr_questions"), "mc_scoring");
1292  $mc_scoring->addOption(new ilRadioOption($this->lng->txt("tst_score_mcmr_zero_points_when_unanswered"), 0, ''));
1293  $mc_scoring->addOption(new ilRadioOption($this->lng->txt("tst_score_mcmr_use_scoring_system"), 1, ''));
1294  $mc_scoring->setValue($this->object->getMCScoring());
1295  $mc_scoring->setInfo($this->lng->txt("tst_score_mcmr_questions_description"));
1296  $mc_scoring->setDisabled(!$setting_available);
1297  $form->addItem($mc_scoring);
1298 
1299  // score cutting
1300  $score_cutting = new ilRadioGroupInputGUI($this->lng->txt("tst_score_cutting"), "score_cutting");
1301  $score_cutting->addOption(new ilRadioOption($this->lng->txt("tst_score_cut_question"), 0, ''));
1302  $score_cutting->addOption(new ilRadioOption($this->lng->txt("tst_score_cut_test"), 1, ''));
1303  $score_cutting->setValue($this->object->getScoreCutting());
1304  $score_cutting->setInfo($this->lng->txt("tst_score_cutting_description"));
1305  $score_cutting->setDisabled(!$setting_available);
1306  $form->addItem($score_cutting);
1307 
1308  // pass scoring
1309  $pass_scoring = new ilRadioGroupInputGUI($this->lng->txt("tst_pass_scoring"), "pass_scoring");
1310  $pass_scoring->addOption(new ilRadioOption($this->lng->txt("tst_pass_last_pass"), 0, ''));
1311  $pass_scoring->addOption(new ilRadioOption($this->lng->txt("tst_pass_best_pass"), 1, ''));
1312  $pass_scoring->setValue($this->object->getPassScoring());
1313  $pass_scoring->setInfo($this->lng->txt("tst_pass_scoring_description"));
1314  $pass_scoring->setDisabled(!$setting_available);
1315  $form->addItem($pass_scoring);
1316 
1317  // test presentation
1318  $header_tp = new ilFormSectionHeaderGUI();
1319  $header_tp->setTitle($this->lng->txt("test_presentation"));
1320  $form->addItem($header_tp);
1321 
1322  // enable obligations
1323  $checkBoxEnableObligations = new ilCheckboxInputGUI($this->lng->txt("tst_setting_enable_obligations_label"), "obligations_enabled");
1324  $checkBoxEnableObligations->setChecked($this->object->areObligationsEnabled());
1325  $checkBoxEnableObligations->setInfo($this->lng->txt("tst_setting_enable_obligations_info"));
1326  if( $total )
1327  {
1328  $checkBoxEnableObligations->setDisabled(true);
1329  $checkBoxEnableObligations->setPostVar("disabled_field");
1330  }
1331  $form->addItem($checkBoxEnableObligations);
1332 
1333 
1334  // offer hints
1335  $checkBoxOfferHints = new ilCheckboxInputGUI($this->lng->txt("tst_setting_offer_hints_label"), "offer_hints");
1336  $checkBoxOfferHints->setChecked($this->object->isOfferingQuestionHintsEnabled());
1337  $checkBoxOfferHints->setInfo($this->lng->txt("tst_setting_offer_hints_info"));
1338  if( $total )
1339  {
1340  $checkBoxOfferHints->setDisabled(true);
1341  $checkBoxOfferHints->setPostVar("disabled_field");
1342  }
1343  $form->addItem($checkBoxOfferHints);
1344 
1345  // instant feedback
1346  $instant_feedback = new ilCheckboxGroupInputGUI($this->lng->txt("tst_instant_feedback"), "instant_feedback");
1347  $instant_feedback->addOption(new ilCheckboxOption($this->lng->txt("tst_instant_feedback_answer_specific"), 'instant_feedback_specific', ''));
1348  $instant_feedback->addOption(new ilCheckboxOption($this->lng->txt("tst_instant_feedback_answer_generic"), 'instant_feedback_generic', ''));
1349  $instant_feedback->addOption(new ilCheckboxOption($this->lng->txt("tst_instant_feedback_results"), 'instant_feedback_points', ''));
1350  $instant_feedback->addOption(new ilCheckboxOption($this->lng->txt("tst_instant_feedback_solution"), 'instant_feedback_solution', ''));
1351  $values = array();
1352  if ($this->object->getSpecificAnswerFeedback()) array_push($values, 'instant_feedback_specific');
1353  if ($this->object->getGenericAnswerFeedback()) array_push($values, 'instant_feedback_generic');
1354  if ($this->object->getAnswerFeedbackPoints()) array_push($values, 'instant_feedback_points');
1355  if ($this->object->getInstantFeedbackSolution()) array_push($values, 'instant_feedback_solution');
1356  $instant_feedback->setValue($values);
1357  $instant_feedback->setInfo($this->lng->txt("tst_instant_feedback_description"));
1358  $form->addItem($instant_feedback);
1359 
1360  // scoring properties
1361  $header_tr = new ilFormSectionHeaderGUI();
1362  $header_tr->setTitle($this->lng->txt("test_results"));
1363  $form->addItem($header_tr);
1364 
1365  // access to test results
1366  $results_access = new ilRadioGroupInputGUI($this->lng->txt("tst_results_access"), "results_access");
1367  $results_access->addOption(new ilRadioOption($this->lng->txt("tst_results_access_always"), 2, ''));
1368  $results_access->addOption(new ilRadioOption($this->lng->txt("tst_results_access_finished"), 1, ''));
1369  $results_access_date_limitation = new ilRadioOption($this->lng->txt("tst_results_access_date"), 3, '');
1370  $results_access->addOption($results_access_date_limitation);
1371  $results_access->addOption(new ilRadioOption($this->lng->txt("tst_results_access_never"), 4, ''));
1372  $results_access->setValue($this->object->getScoreReporting());
1373  $results_access->setInfo($this->lng->txt("tst_results_access_description"));
1374 
1375  // access date
1376  $reporting_date = new ilDateTimeInputGUI('', 'reporting_date');
1377  $reporting_date->setShowDate(true);
1378  $reporting_date->setShowTime(true);
1379  if (strlen($this->object->getReportingDate()))
1380  {
1381  $reporting_date->setDate(new ilDateTime($this->object->getReportingDate(), IL_CAL_TIMESTAMP));
1382  }
1383  else
1384  {
1385  $reporting_date->setDate(new ilDateTime(time(), IL_CAL_UNIX));
1386  }
1387  $results_access_date_limitation->addSubItem($reporting_date);
1388  $form->addItem($results_access);
1389 
1390  $results_print_best_solution = new ilCheckboxInputGUI($this->lng->txt("tst_results_print_best_solution"), "print_bs_with_res");
1391  $results_print_best_solution->setInfo($this->lng->txt('tst_results_print_best_solution_info'));
1392  $results_print_best_solution->setValue(1);
1393  $results_print_best_solution->setChecked((bool) $this->object->isBestSolutionPrintedWithResult());
1394  $form->addItem($results_print_best_solution);
1395 
1396  // results presentation
1397  $results_presentation = new ilCheckboxGroupInputGUI($this->lng->txt("tst_results_presentation"), "results_presentation");
1398  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_pass_details"), 'pass_details', $this->lng->txt("tst_show_pass_details_desc")));
1399  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_details"), 'solution_details', $this->lng->txt("tst_show_solution_details_desc")));
1400  $results_presentation->addOption($showSolutionPrintViewOption = new ilCheckboxOption($this->lng->txt("tst_show_solution_printview"), 'solution_printview', $this->lng->txt("tst_show_solution_printview_desc")));
1401  $solutionCompareInput = new ilCheckboxInputGUI($this->lng->txt('tst_show_solution_compare'), 'solution_compare');
1402  $solutionCompareInput->setChecked($this->object->getShowSolutionListComparison());
1403  $showSolutionPrintViewOption->addSubItem($solutionCompareInput);
1404  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_feedback"), 'solution_feedback', $this->lng->txt("tst_show_solution_feedback_desc")));
1405  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_answers_only"), 'solution_answers_only', $this->lng->txt("tst_show_solution_answers_only_desc")));
1406  $signatureOption = new ilCheckboxOption($this->lng->txt("tst_show_solution_signature"), 'solution_signature', $this->lng->txt("tst_show_solution_signature_desc"));
1407  $results_presentation->addOption($signatureOption);
1408  $results_presentation->addOption(new ilCheckboxOption($this->lng->txt("tst_show_solution_suggested"), 'solution_suggested', $this->lng->txt("tst_show_solution_suggested_desc")));
1409  $values = array();
1410  if ($this->object->getShowPassDetails()) array_push($values, 'pass_details');
1411  if ($this->object->getShowSolutionDetails()) array_push($values, 'solution_details');
1412  if ($this->object->getShowSolutionPrintview()) array_push($values, 'solution_printview');
1413  if ($this->object->getShowSolutionFeedback()) array_push($values, 'solution_feedback');
1414  if ($this->object->getShowSolutionAnswersOnly()) array_push($values, 'solution_answers_only');
1415  if ($this->object->getShowSolutionSignature()) array_push($values, 'solution_signature');
1416  if ($this->object->getShowSolutionSuggested()) array_push($values, 'solution_suggested');
1417  if ($this->object->getShowSolutionListComparison()) array_push($values, 'solution_compare');
1418  $results_presentation->setValue($values);
1419  if ($this->object->getAnonymity())
1420  {
1421  $signatureOption->setDisabled(true);
1422  }
1423  $form->addItem($results_presentation);
1424 
1425  // show signature placeholder
1426  $showExamId = new ilCheckboxInputGUI($this->lng->txt('examid_in_test_res'), 'examid_in_test_res');
1427  $showExamId->setInfo($this->lng->txt('examid_in_test_res_desc'));
1428  $showExamId->setChecked($this->object->isShowExamIdInTestResultsEnabled());
1429  $form->addItem($showExamId);
1430 
1431  // misc properties
1432  $header_misc = new ilFormSectionHeaderGUI();
1433  $header_misc->setTitle($this->lng->txt("misc"));
1434  $form->addItem($header_misc);
1435 
1436  // deletion of test results
1437  $passDeletion = new ilRadioGroupInputGUI($this->lng->txt("tst_pass_deletion"), "pass_deletion_allowed");
1438  $passDeletion->addOption(new ilRadioOption($this->lng->txt("tst_pass_deletion_not_allowed"), 0, ''));
1439  $passDeletion->addOption(new ilRadioOption($this->lng->txt("tst_pass_deletion_allowed"), 1, ''));
1440  $passDeletion->setValue($this->object->isPassDeletionAllowed());
1441  $form->addItem($passDeletion);
1442 
1443  // export settings
1444  $export_settings = new ilCheckboxGroupInputGUI($this->lng->txt("tst_export_settings"), "export_settings");
1445  $export_settings->addOption(new ilCheckboxOption($this->lng->txt("tst_exp_sc_short"), 'exp_sc_short', ''));
1446  $values = array();
1447  if ($this->object->getExportSettingsSingleChoiceShort()) array_push($values, 'exp_sc_short');
1448  $export_settings->setValue($values);
1449  $form->addItem($export_settings);
1450 
1451 
1452  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]) && $total == 0) $form->addCommandButton("saveScoring", $this->lng->txt("save"));
1453  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]) && $total != 0) $form->addCommandButton("confirmScoring", $this->lng->txt("save"));
1454 
1455  // remove items when using template
1456  if($template_settings)
1457  {
1458  foreach($template_settings as $id => $item)
1459  {
1460  if($item["hide"])
1461  {
1462  $form->removeItemByPostVar($id);
1463  }
1464  }
1465  }
1466 
1467  $errors = false;
1468 
1469  if ($save)
1470  {
1471  $errors = !$form->checkInput();
1472  $form->setValuesByPost();
1473  if ($errors) $checkonly = false;
1474  }
1475 
1476  if (!$checkonly) $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
1477  return $errors;
1478  }
1479 
1484  {
1485  $file = explode("_", $_GET["file_id"]);
1486  include_once("./Modules/File/classes/class.ilObjFile.php");
1487  $fileObj =& new ilObjFile($file[count($file) - 1], false);
1488  $fileObj->sendFile();
1489  exit;
1490  }
1491 
1495  function fullscreenObject()
1496  {
1497  include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php");
1498  $page_gui = new ilAssQuestionPageGUI($_GET["pg_id"]);
1499  $page_gui->showMediaFullscreen();
1500 
1501  }
1502 
1507  {
1508  include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php");
1509  $pg_obj = new ilAssQuestionPage($_GET["pg_id"]);
1510  $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
1511  exit;
1512  }
1513 
1521  function filterObject()
1522  {
1523  $this->questionBrowser();
1524  }
1525 
1534  {
1535  $this->questionBrowser();
1536  }
1537 
1545  function backObject()
1546  {
1547  $this->ctrl->redirect($this, "questions");
1548  }
1549 
1558  function createQuestionPool($name = "dummy", $description = "")
1559  {
1560  global $tree;
1561  $parent_ref = $tree->getParentId($this->object->getRefId());
1562  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
1563  $qpl = new ilObjQuestionPool();
1564  $qpl->setType("qpl");
1565  $qpl->setTitle($name);
1566  $qpl->setDescription($description);
1567  $qpl->create();
1568  $qpl->createReference();
1569  $qpl->putInTree($parent_ref);
1570  $qpl->setPermissions($parent_ref);
1571  $qpl->setOnline(1); // must be online to be available
1572  $qpl->saveToDb();
1573  return $qpl->getRefId();
1574  }
1575 
1579  public function randomselectObject()
1580  {
1581  global $ilUser;
1582  $this->getQuestionsSubTabs();
1583  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_random_select.html", "Modules/Test");
1584  $questionpools =& $this->object->getAvailableQuestionpools(FALSE, FALSE, FALSE, TRUE);
1585  $this->tpl->setCurrentBlock("option");
1586  $this->tpl->setVariable("VALUE_OPTION", "0");
1587  $this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("all_available_question_pools"));
1588  $this->tpl->parseCurrentBlock();
1589  foreach ($questionpools as $key => $value)
1590  {
1591  $this->tpl->setCurrentBlock("option");
1592  $this->tpl->setVariable("VALUE_OPTION", $key);
1593  $this->tpl->setVariable("TEXT_OPTION", $value["title"]);
1594  $this->tpl->parseCurrentBlock();
1595  }
1596  $this->tpl->setCurrentBlock("hidden");
1597  $this->tpl->setVariable("HIDDEN_NAME", "sel_question_types");
1598  $this->tpl->setVariable("HIDDEN_VALUE", $_POST["sel_question_types"]);
1599  $this->tpl->parseCurrentBlock();
1600  $this->tpl->setCurrentBlock("adm_content");
1601  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
1602  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_random_select_questionpool"));
1603  $this->tpl->setVariable("TXT_NR_OF_QUESTIONS", $this->lng->txt("tst_random_nr_of_questions"));
1604  $this->tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit"));
1605  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
1606  $this->tpl->parseCurrentBlock();
1607  }
1608 
1617  {
1618  $this->ctrl->redirect($this, "questions");
1619  }
1620 
1629  {
1630  $this->getQuestionsSubTabs();
1631  $question_array = $this->object->randomSelectQuestions($_POST["nr_of_questions"], $_POST["sel_qpl"]);
1632  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_random_question_offer.html", "Modules/Test");
1633  $color_class = array("tblrow1", "tblrow2");
1634  $counter = 0;
1635  $questionpools =& $this->object->getAvailableQuestionpools(true);
1636  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
1637  foreach ($question_array as $question_id)
1638  {
1639  $dataset = $this->object->getQuestionDataset($question_id);
1640  $this->tpl->setCurrentBlock("QTab");
1641  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
1642  $this->tpl->setVariable("QUESTION_TITLE", $dataset->title);
1643  $this->tpl->setVariable("QUESTION_COMMENT", $dataset->description);
1644  $this->tpl->setVariable("QUESTION_TYPE", assQuestion::_getQuestionTypeName($dataset->type_tag));
1645  $this->tpl->setVariable("QUESTION_AUTHOR", $dataset->author);
1646  $this->tpl->setVariable("QUESTION_POOL", $questionpools[$dataset->obj_fi]["title"]);
1647  $this->tpl->parseCurrentBlock();
1648  $counter++;
1649  }
1650  if (count($question_array) == 0)
1651  {
1652  $this->tpl->setCurrentBlock("Emptytable");
1653  $this->tpl->setVariable("TEXT_NO_QUESTIONS_AVAILABLE", $this->lng->txt("no_questions_available"));
1654  $this->tpl->parseCurrentBlock();
1655  }
1656  else
1657  {
1658  $this->tpl->setCurrentBlock("Selectionbuttons");
1659  $this->tpl->setVariable("BTN_YES", $this->lng->txt("random_accept_sample"));
1660  $this->tpl->setVariable("BTN_NO", $this->lng->txt("random_another_sample"));
1661  $this->tpl->parseCurrentBlock();
1662  }
1663  $chosen_questions = join($question_array, ",");
1664  $this->tpl->setCurrentBlock("adm_content");
1665  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
1666  $this->tpl->setVariable("QUESTION_TITLE", $this->lng->txt("tst_question_title"));
1667  $this->tpl->setVariable("QUESTION_COMMENT", $this->lng->txt("description"));
1668  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("tst_question_type"));
1669  $this->tpl->setVariable("QUESTION_AUTHOR", $this->lng->txt("author"));
1670  $this->tpl->setVariable("QUESTION_POOL", $this->lng->txt("qpl"));
1671  $this->tpl->setVariable("VALUE_CHOSEN_QUESTIONS", $chosen_questions);
1672  $this->tpl->setVariable("VALUE_QUESTIONPOOL_SELECTION", $_POST["sel_qpl"]);
1673  $this->tpl->setVariable("VALUE_NR_OF_QUESTIONS", $_POST["nr_of_questions"]);
1674  $this->tpl->setVariable("TEXT_QUESTION_OFFER", $this->lng->txt("tst_question_offer"));
1675  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
1676  $this->tpl->parseCurrentBlock();
1677  }
1678 
1687  {
1688  $selected_array = split(",", $_POST["chosen_questions"]);
1689  if (!count($selected_array))
1690  {
1691  ilUtil::sendInfo($this->lng->txt("tst_insert_missing_question"));
1692  }
1693  else
1694  {
1695  $total = $this->object->evalTotalPersons();
1696  if ($total)
1697  {
1698  // the test was executed previously
1699  ilUtil::sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total));
1700  }
1701  else
1702  {
1703  ilUtil::sendInfo($this->lng->txt("tst_insert_questions"));
1704  }
1705  foreach ($selected_array as $key => $value)
1706  {
1707  $this->object->insertQuestion( $this->testQuestionSetConfigFactory->getQuestionSetConfig(), $value );
1708  }
1709  $this->object->saveCompleteStatus( $this->testQuestionSetConfigFactory->getQuestionSetConfig() );
1710  ilUtil::sendSuccess($this->lng->txt("tst_questions_inserted"), true);
1711  $this->ctrl->redirect($this, "questions");
1712  return;
1713  }
1714  }
1715 
1717  {
1718  $this->questionBrowser();
1719  }
1720 
1729  {
1730  $qpl_ref_id = $_REQUEST["sel_qpl"];
1731 
1732  $qpl_mode = $_REQUEST['usage'];
1733 
1734  if(isset($_REQUEST['qtype']))
1735  {
1736  include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
1737  $sel_question_types = ilObjQuestionPool::getQuestionTypeByTypeId($_REQUEST["qtype"]);
1738  }
1739  else if(isset($_REQUEST['sel_question_types']))
1740  {
1741  $sel_question_types = $_REQUEST["sel_question_types"];
1742  }
1743 
1744  if (!$qpl_mode || ($qpl_mode == 2 && strcmp($_REQUEST["txt_qpl"], "") == 0) || ($qpl_mode == 3 && strcmp($qpl_ref_id, "") == 0))
1745  //if ((strcmp($_REQUEST["txt_qpl"], "") == 0) && (strcmp($qpl_ref_id, "") == 0))
1746  {
1747  // Mantis #14890
1748  $_REQUEST['sel_question_types'] = $sel_question_types;
1749  ilUtil::sendInfo($this->lng->txt("questionpool_not_entered"));
1750  $this->createQuestionObject();
1751  return;
1752  }
1753  else
1754  {
1755  $_SESSION["test_id"] = $this->object->getRefId();
1756  if ($qpl_mode == 2 && strcmp($_REQUEST["txt_qpl"], "") != 0)
1757  {
1758  // create a new question pool and return the reference id
1759  $qpl_ref_id = $this->createQuestionPool($_REQUEST["txt_qpl"]);
1760  }
1761  else if ($qpl_mode == 1)
1762  {
1763  $qpl_ref_id = $_GET["ref_id"];
1764  }
1765 
1766  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPoolGUI.php";
1767  $baselink = "ilias.php?baseClass=ilObjQuestionPoolGUI&ref_id=" . $qpl_ref_id . "&cmd=createQuestionForTest&test_ref_id=".$_GET["ref_id"]."&calling_test=".$_GET["ref_id"]."&sel_question_types=" . $sel_question_types;
1768 
1769  if (isset($_REQUEST['prev_qid']))
1770  {
1771  $baselink .= '&prev_qid=' . $_REQUEST['prev_qid'];
1772  }
1773  else if(isset($_REQUEST['position']))
1774  {
1775  $baselink .= '&prev_qid=' . $_REQUEST['position'];
1776  }
1777 
1778  if ($_REQUEST['test_express_mode']) {
1779  $baselink .= '&test_express_mode=1';
1780  }
1781 
1782  if( isset($_REQUEST['add_quest_cont_edit_mode']) )
1783  {
1785  $baselink, "add_quest_cont_edit_mode={$_REQUEST['add_quest_cont_edit_mode']}", false
1786  );
1787  }
1788 
1789 #var_dump($_REQUEST['prev_qid']);
1790  ilUtil::redirect($baselink);
1791 
1792  exit();
1793  }
1794  }
1795 
1804  {
1805  $this->ctrl->redirect($this, "questions");
1806  }
1807 
1816  {
1817  global $ilUser;
1818  $this->getQuestionsSubTabs();
1819  //$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_qpl_select.html", "Modules/Test");
1820  $questionpools =& $this->object->getAvailableQuestionpools(FALSE, FALSE, FALSE, TRUE, FALSE, "write");
1821 
1822  if ($this->object->getPoolUsage()) {
1823  global $lng, $ilCtrl, $tpl;
1824 
1825  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
1826 
1827  $form = new ilPropertyFormGUI();
1828  $form->setFormAction($ilCtrl->getFormAction($this, "executeCreateQuestion"));
1829  $form->setTitle($lng->txt("ass_create_question"));
1830  include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
1831 
1832 
1833  $hidden = new ilHiddenInputGUI('sel_question_types');
1834  $hidden->setValue($_REQUEST["sel_question_types"]);
1835  $form->addItem($hidden);
1836 
1837  // content editing mode
1839  {
1840  $ri = new ilRadioGroupInputGUI($lng->txt("tst_add_quest_cont_edit_mode"), "add_quest_cont_edit_mode");
1841 
1842  $ri->addOption(new ilRadioOption(
1843  $lng->txt('tst_add_quest_cont_edit_mode_default'),
1845  ));
1846 
1847  $ri->addOption(new ilRadioOption(
1848  $lng->txt('tst_add_quest_cont_edit_mode_page_object'),
1850  ));
1851 
1853 
1854  $form->addItem($ri, true);
1855  }
1856  else
1857  {
1858  $hi = new ilHiddenInputGUI("question_content_editing_type");
1860  $form->addItem($hi, true);
1861  }
1862 
1863  // use pool
1864  $usage = new ilRadioGroupInputGUI($this->lng->txt("assessment_pool_selection"), "usage");
1865  $usage->setRequired(true);
1866  $no_pool = new ilRadioOption($this->lng->txt("assessment_no_pool"), 1);
1867  $usage->addOption($no_pool);
1868  $existing_pool = new ilRadioOption($this->lng->txt("assessment_existing_pool"), 3);
1869  $usage->addOption($existing_pool);
1870  $new_pool = new ilRadioOption($this->lng->txt("assessment_new_pool"), 2);
1871  $usage->addOption($new_pool);
1872  $form->addItem($usage);
1873 
1874  $usage->setValue(1);
1875 
1876  $questionpools = ilObjQuestionPool::_getAvailableQuestionpools(FALSE, FALSE, TRUE, FALSE, FALSE, "write");
1877  $pools_data = array();
1878  foreach($questionpools as $key => $p) {
1879  $pools_data[$key] = $p['title'];
1880  }
1881  $pools = new ilSelectInputGUI($this->lng->txt("select_questionpool"), "sel_qpl");
1882  $pools->setOptions($pools_data);
1883  $existing_pool->addSubItem($pools);
1884 
1885 
1886  $this->lng->loadLanguageModule('rbac');
1887  $name = new ilTextInputGUI($this->lng->txt("rbac_create_qpl"), "txt_qpl");
1888  $name->setSize(50);
1889  $name->setMaxLength(50);
1890  $new_pool->addSubItem($name);
1891 
1892  $form->addCommandButton("executeCreateQuestion", $lng->txt("submit"));
1893  $form->addCommandButton("cancelCreateQuestion", $lng->txt("cancel"));
1894 
1895  return $this->tpl->setVariable('ADM_CONTENT', $form->getHTML());
1896 
1897  }
1898  else {
1899  global $ilCtrl;
1900 
1901  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'sel_question_types', $_REQUEST["sel_question_types"]);
1902  $link = $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'handleToolbarCommand','',false,false);
1903  ilUtil::redirect($link);
1904  }
1905  }
1906 
1911  {
1912  $checked_questions = $_POST["q_id"];
1913 
1914  $questions = $this->object->getQuestionTitlesAndIndexes();
1915  $deleted = array();
1916  foreach((array)$checked_questions as $value)
1917  {
1918  $this->object->removeQuestion($value);
1919  $deleted[] = $value;
1920  }
1921 
1922  $this->object->saveCompleteStatus( $this->testQuestionSetConfigFactory->getQuestionSetConfig() );
1923 
1924  ilUtil::sendSuccess($this->lng->txt("tst_questions_removed"));
1925 
1926  if($_REQUEST['test_express_mode'])
1927  {
1928  $prev = null;
1929  $return_to = null;
1930  $deleted_tmp = $deleted;
1931  $first = array_shift($deleted_tmp);
1932  foreach((array)$questions as $key => $value)
1933  {
1934  if(!in_array($key, $deleted))
1935  {
1936  $prev = $key;
1937  if(!$first)
1938  {
1939  $return_to = $prev;
1940  break;
1941  }
1942  else continue;
1943  }
1944  else if($key == $first)
1945  {
1946  if($prev)
1947  {
1948  $return_to = $prev;
1949  break;
1950  }
1951  $first = array_shift($deleted_tmp);
1952  }
1953  }
1954 
1955  if(
1956  count($questions) == count($checked_questions) ||
1957  !$return_to
1958  )
1959  {
1960  $this->ctrl->setParameter($this, 'q_id', '');
1961  $this->ctrl->redirect($this, 'showPage');
1962  }
1963 
1964  $this->ctrl->setParameter($this, 'q_id', $return_to);
1965  $this->ctrl->redirect($this, "showPage");
1966  }
1967  else
1968  {
1969  $this->ctrl->setParameter($this, 'q_id', '');
1970  $this->ctrl->redirect($this, 'questions');
1971  }
1972  }
1973 
1982  {
1983  if ($_REQUEST['test_express_mode']) {
1984  $this->ctrl->setParameter($this, 'q_id', $_REQUEST['q_id']);
1985  $this->ctrl->redirect($this, "showPage");
1986  }
1987  else {
1988  $this->ctrl->redirect($this, "questions");
1989  }
1990  }
1991 
1999  function removeQuestionsForm($checked_questions)
2000  {
2001  $total = $this->object->evalTotalPersons();
2002  if ($total)
2003  {
2004  // the test was executed previously
2005  $question = sprintf($this->lng->txt("tst_remove_questions_and_results"), $total);
2006  }
2007  else
2008  {
2009  if (count($checked_questions) == 1)
2010  {
2011  $question = $this->lng->txt("tst_remove_question");
2012  }
2013  else
2014  {
2015  $question = $this->lng->txt("tst_remove_questions");
2016  }
2017  }
2018 
2019  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
2020  $cgui = new ilConfirmationGUI();
2021  $cgui->setHeaderText($question);
2022 
2023  $this->ctrl->saveParameter($this, 'test_express_mode');
2024  $this->ctrl->saveParameter($this, 'q_id');
2025 
2026  $cgui->setFormAction($this->ctrl->getFormAction($this));
2027  $cgui->setCancel($this->lng->txt("cancel"), "cancelRemoveQuestions");
2028  $cgui->setConfirm($this->lng->txt("confirm"), "confirmRemoveQuestions");
2029 
2030  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
2031  $removablequestions =& $this->object->getTestQuestions();
2032  if (count($removablequestions))
2033  {
2034  foreach ($removablequestions as $data)
2035  {
2036  if (in_array($data["question_id"], $checked_questions))
2037  {
2038  $txt = $data["title"]." (".assQuestion::_getQuestionTypeName($data["type_tag"]).")";
2039  $txt .= ' ['. $this->lng->txt('question_id_short') . ': ' . $data['question_id'] . ']';
2040 
2041  if($data["description"])
2042  {
2043  $txt .= "<div class=\"small\">".$data["description"]."</div>";
2044  }
2045 
2046  $cgui->addItem("q_id[]", $data["question_id"], $txt);
2047  }
2048  }
2049  }
2050 
2051  $this->tpl->setContent($cgui->getHTML());
2052  }
2053 
2062  {
2063  $this->getQuestionsSubTabs();
2064  $checked_questions = $_REQUEST["q_id"];
2065  if (!is_array($checked_questions) && $checked_questions) {
2066  $checked_questions = array($checked_questions);
2067  }
2068  if (count($checked_questions) > 0)
2069  {
2070  $this->removeQuestionsForm($checked_questions);
2071  return;
2072  }
2073  elseif (count($checked_questions) == 0)
2074  {
2075  ilUtil::sendFailure($this->lng->txt("tst_no_question_selected_for_removal"), true);
2076  $this->ctrl->redirect($this, "questions");
2077  }
2078  }
2079 
2084  {
2085  $selected_questions = NULL;
2086  $selected_questions = $_POST['q_id'];
2087  if (is_array($selected_questions))
2088  {
2089  $_SESSION['tst_qst_move_' . $this->object->getTestId()] = $_POST['q_id'];
2090  ilUtil::sendSuccess($this->lng->txt("msg_selected_for_move"), true);
2091  }
2092  else
2093  {
2094  ilUtil::sendFailure($this->lng->txt('no_selection_for_move'), TRUE);
2095  }
2096  $this->ctrl->redirect($this, 'questions');
2097  }
2098 
2103  {
2104  // get all questions to move
2105  $move_questions = $_SESSION['tst_qst_move_' . $this->object->getTestId()];
2106 
2107  if (count($_POST['q_id']) == 0)
2108  {
2109  ilUtil::sendFailure($this->lng->txt("no_target_selected_for_move"), true);
2110  $this->ctrl->redirect($this, 'questions');
2111  }
2112  if (count($_POST['q_id']) > 1)
2113  {
2114  ilUtil::sendFailure($this->lng->txt("too_many_targets_selected_for_move"), true);
2115  $this->ctrl->redirect($this, 'questions');
2116  }
2117  $insert_mode = 0;
2118  $this->object->moveQuestions($_SESSION['tst_qst_move_' . $this->object->getTestId()], $_POST['q_id'][0], $insert_mode);
2119  ilUtil::sendSuccess($this->lng->txt("msg_questions_moved"), true);
2120  unset($_SESSION['tst_qst_move_' . $this->object->getTestId()]);
2121  $this->ctrl->redirect($this, "questions");
2122  }
2123 
2127  public function insertQuestionsAfterObject()
2128  {
2129  // get all questions to move
2130  $move_questions = $_SESSION['tst_qst_move_' . $this->object->getTestId()];
2131  if (count($_POST['q_id']) == 0)
2132  {
2133  ilUtil::sendFailure($this->lng->txt("no_target_selected_for_move"), true);
2134  $this->ctrl->redirect($this, 'questions');
2135  }
2136  if (count($_POST['q_id']) > 1)
2137  {
2138  ilUtil::sendFailure($this->lng->txt("too_many_targets_selected_for_move"), true);
2139  $this->ctrl->redirect($this, 'questions');
2140  }
2141  $insert_mode = 1;
2142  $this->object->moveQuestions($_SESSION['tst_qst_move_' . $this->object->getTestId()], $_POST['q_id'][0], $insert_mode);
2143  ilUtil::sendSuccess($this->lng->txt("msg_questions_moved"), true);
2144  unset($_SESSION['tst_qst_move_' . $this->object->getTestId()]);
2145  $this->ctrl->redirect($this, "questions");
2146  }
2147 
2154  {
2155  $selected_array = (is_array($_POST['q_id'])) ? $_POST['q_id'] : array();
2156  if (!count($selected_array))
2157  {
2158  ilUtil::sendInfo($this->lng->txt("tst_insert_missing_question"), true);
2159  $this->ctrl->redirect($this, "browseForQuestions");
2160  }
2161  else
2162  {
2163  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
2164  $manscoring = FALSE;
2165  foreach ($selected_array as $key => $value)
2166  {
2167  $this->object->insertQuestion( $this->testQuestionSetConfigFactory->getQuestionSetConfig(), $value );
2168  if (!$manscoring)
2169  {
2170  $manscoring = $manscoring | assQuestion::_needsManualScoring($value);
2171  }
2172  }
2173  $this->object->saveCompleteStatus( $this->testQuestionSetConfigFactory->getQuestionSetConfig() );
2174  if ($manscoring)
2175  {
2176  ilUtil::sendInfo($this->lng->txt("manscoring_hint"), TRUE);
2177  }
2178  else
2179  {
2180  ilUtil::sendSuccess($this->lng->txt("tst_questions_inserted"), TRUE);
2181  }
2182  $this->ctrl->redirect($this, "questions");
2183  return;
2184  }
2185  }
2186 
2188  {
2189  include_once "./Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php";
2190  $table_gui = new ilTestQuestionBrowserTableGUI($this, 'browseForQuestions');
2191  $table_gui->writeFilterToSession();
2192  $this->ctrl->redirect($this, "browseForQuestions");
2193  }
2194 
2196  {
2197  include_once "./Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php";
2198  $table_gui = new ilTestQuestionBrowserTableGUI($this, 'browseForQuestions');
2199  $table_gui->resetFilter();
2200  $this->ctrl->redirect($this, "browseForQuestions");
2201  }
2202 
2208  function questionBrowser()
2209  {
2210  global $ilAccess;
2211 
2212  $this->ctrl->setParameterByClass(get_class($this), "browse", "1");
2213 
2214  include_once "./Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php";
2215  $table_gui = new ilTestQuestionBrowserTableGUI($this, 'browseForQuestions', (($ilAccess->checkAccess("write", "", $this->ref_id) ? true : false)));
2216  $arrFilter = array();
2217  foreach ($table_gui->getFilterItems() as $item)
2218  {
2219  if ($item->getValue() !== false)
2220  {
2221  $arrFilter[$item->getPostVar()] = $item->getValue();
2222  }
2223  }
2224  $data = $this->object->getAvailableQuestions($arrFilter, 1);
2225  $table_gui->setData($data);
2226  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
2227  }
2228 
2229  public function addQuestionObject()
2230  {
2231  global $lng, $ilCtrl, $tpl;
2232 
2233  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
2234 
2235  $ilCtrl->setParameter($this, 'qtype', $_REQUEST['qtype']);
2236 
2237  $form = new ilPropertyFormGUI();
2238 
2239  $form->setFormAction($ilCtrl->getFormAction($this, "executeCreateQuestion"));
2240  $form->setTitle($lng->txt("ass_create_question"));
2241  include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
2242 
2243  $pool = new ilObjQuestionPool();
2244  $questionTypes = $pool->getQuestionTypes(false, true);
2245  $options = array();
2246 
2247  // question type
2248  foreach($questionTypes as $label => $data)
2249  {
2250  $options[$data['question_type_id']] = $label;
2251  }
2252 
2253  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
2254  $si = new ilSelectInputGUI($lng->txt("question_type"), "qtype");
2255  $si->setOptions($options);
2256  $form->addItem($si, true);
2257 
2258  // position
2259  $questions = $this->object->getQuestionTitlesAndIndexes();
2260  if($questions)
2261  {
2262  $si = new ilSelectInputGUI($lng->txt("position"), "position");
2263  $options = array('0' => $lng->txt('first'));
2264  foreach($questions as $key => $title)
2265  {
2266  $options[$key] = $lng->txt('behind') . ' '. $title . ' ['.$this->lng->txt('question_id_short') . ': '. $key .']';
2267  }
2268  $si->setOptions($options);
2269  $si->setValue($_REQUEST['q_id']);
2270  $form->addItem($si, true);
2271  }
2272 
2273  // content editing mode
2275  {
2276  $ri = new ilRadioGroupInputGUI($lng->txt("tst_add_quest_cont_edit_mode"), "add_quest_cont_edit_mode");
2277 
2278  $ri->addOption(new ilRadioOption(
2279  $lng->txt('tst_add_quest_cont_edit_mode_default'),
2281  ));
2282 
2283  $ri->addOption(new ilRadioOption(
2284  $lng->txt('tst_add_quest_cont_edit_mode_page_object'),
2286  ));
2287 
2289 
2290  $form->addItem($ri, true);
2291  }
2292  else
2293  {
2294  $hi = new ilHiddenInputGUI("question_content_editing_type");
2296  $form->addItem($hi, true);
2297  }
2298 
2299  if($this->object->getPoolUsage())
2300  {
2301  // use pool
2302  $usage = new ilRadioGroupInputGUI($this->lng->txt("assessment_pool_selection"), "usage");
2303  $usage->setRequired(true);
2304  $no_pool = new ilRadioOption($this->lng->txt("assessment_no_pool"), 1);
2305  $usage->addOption($no_pool);
2306  $existing_pool = new ilRadioOption($this->lng->txt("assessment_existing_pool"), 3);
2307  $usage->addOption($existing_pool);
2308  $new_pool = new ilRadioOption($this->lng->txt("assessment_new_pool"), 2);
2309  $usage->addOption($new_pool);
2310  $form->addItem($usage);
2311 
2312  $usage->setValue(1);
2313 
2314  $questionpools = ilObjQuestionPool::_getAvailableQuestionpools(FALSE, FALSE, TRUE, FALSE, FALSE, "write");
2315  $pools_data = array();
2316  foreach($questionpools as $key => $p)
2317  {
2318  $pools_data[$key] = $p['title'];
2319  }
2320  $pools = new ilSelectInputGUI($this->lng->txt("select_questionpool"), "sel_qpl");
2321  $pools->setOptions($pools_data);
2322  $existing_pool->addSubItem($pools);
2323 
2324  $name = new ilTextInputGUI($this->lng->txt("name"), "txt_qpl");
2325  $name->setSize(50);
2326  $name->setMaxLength(50);
2327  $new_pool->addSubItem($name);
2328  }
2329 
2330  $form->addCommandButton("executeCreateQuestion", $lng->txt("submit"));
2331  $form->addCommandButton("questions", $lng->txt("cancel"));
2332 
2333  return $tpl->setContent($form->getHTML());
2334  }
2335 
2336  function questionsObject()
2337  {
2338  global $ilAccess, $ilTabs;
2339 
2340  $ilTabs->activateTab('assQuestions');
2341 
2342  // #12590
2343  $this->ctrl->setParameter($this, 'test_express_mode', '');
2344 
2345  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
2346  {
2347  // allow only write access
2348  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
2349  $this->ctrl->redirect($this, "infoScreen");
2350  }
2351 
2352  if ($_GET['browse'])
2353  {
2354  return $this->questionbrowser();
2355  }
2356 
2357  $this->getQuestionsSubTabs();
2358 
2359  // #11631, #12994
2360  $this->ctrl->setParameter($this, 'q_id', '');
2361 
2362  if ($_GET["eqid"] && $_GET["eqpl"])
2363  {
2364  ilUtil::redirect("ilias.php?baseClass=ilObjQuestionPoolGUI&ref_id=" . $_GET["eqpl"] . "&cmd=editQuestionForTest&calling_test=".$_GET["ref_id"]."&q_id=" . $_GET["eqid"]);
2365  }
2366 
2367  if ($_GET["up"] > 0)
2368  {
2369  $this->object->questionMoveUp($_GET["up"]);
2370  }
2371  if ($_GET["down"] > 0)
2372  {
2373  $this->object->questionMoveDown($_GET["down"]);
2374  }
2375 
2376  if ($_GET["add"])
2377  {
2378  $selected_array = array();
2379  array_push($selected_array, $_GET["add"]);
2380  $total = $this->object->evalTotalPersons();
2381  if ($total)
2382  {
2383  // the test was executed previously
2384  ilUtil::sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total));
2385  }
2386  else
2387  {
2388  ilUtil::sendInfo($this->lng->txt("tst_insert_questions"));
2389  }
2390  $this->insertQuestions($selected_array);
2391  return;
2392  }
2393 
2394  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_questions.html", "Modules/Test");
2395 
2396  $total = $this->object->evalTotalPersons();
2397  if ($ilAccess->checkAccess("write", "", $this->ref_id))
2398  {
2399  if($total != 0)
2400  {
2401  $link = $this->ctrl->getLinkTarget($this, "participants");
2402  $link = "<a href=\"".$link."\">".$this->lng->txt("test_has_datasets_warning_page_view_link")."</a>";
2403  ilUtil::sendInfo($this->lng->txt("test_has_datasets_warning_page_view")." ".$link);
2404  }
2405  else {
2406  global $ilToolbar;
2407 
2408  $ilToolbar->addButton($this->lng->txt("ass_create_question"), $this->ctrl->getLinkTarget($this, "addQuestion"));
2409 
2410  if ($this->object->getPoolUsage()) {
2411  $ilToolbar->addSeparator();
2412  $ilToolbar->addButton($this->lng->txt("tst_browse_for_questions"), $this->ctrl->getLinkTarget($this, 'browseForQuestions'));
2413  }
2414 
2415  $ilToolbar->addSeparator();
2416  $ilToolbar->addButton($this->lng->txt("random_selection"), $this->ctrl->getLinkTarget($this, "randomselect"));
2417 
2418 
2419  global $ilAccess, $ilUser, $lng, $ilCtrl;
2420  $online_access = false;
2421  if ($this->object->getFixedParticipants())
2422  {
2423  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
2424  $online_access_result = ilObjTestAccess::_lookupOnlineTestAccess($this->object->getId(), $ilUser->getId());
2425  if ($online_access_result === true)
2426  {
2427  $online_access = true;
2428  }
2429  }
2430 
2431  if( $this->object->isOnline() && $this->object->isComplete( $this->testQuestionSetConfigFactory->getQuestionSetConfig() ) )
2432  {
2433  if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id))
2434  {
2435  $testSession = $this->testSessionFactory->getSession();
2436 
2437  $executable = $this->object->isExecutable($testSession, $ilUser->getId(), $allowPassIncrease = TRUE);
2438 
2439  if ($executable["executable"])
2440  {
2441  if ($testSession->getActiveId() > 0)
2442  {
2443  $ilToolbar->addSeparator();
2444  $ilToolbar->addButton($lng->txt('tst_resume_test'), $ilCtrl->getLinkTargetByClass('iltestoutputgui', 'resume'));
2445  }
2446  else
2447  {
2448  $ilToolbar->addSeparator();
2449  $ilToolbar->addButton($lng->txt('tst_start_test'), $ilCtrl->getLinkTargetByClass('iltestoutputgui', 'startTest'));
2450  }
2451  }
2452  }
2453  }
2454 
2455 
2456  }
2457  }
2458 
2459  $this->tpl->setCurrentBlock("adm_content");
2460  include_once "./Modules/Test/classes/tables/class.ilTestQuestionsTableGUI.php";
2461  $checked_move = is_array($_SESSION['tst_qst_move_' . $this->object->getTestId()]) && (count($_SESSION['tst_qst_move_' . $this->object->getTestId()]));
2462  $table_gui = new ilTestQuestionsTableGUI($this, 'questions', (($ilAccess->checkAccess("write", "", $this->ref_id) ? true : false)), $checked_move, $total);
2463  $data = $this->object->getTestQuestions();
2464  $table_gui->setData($data);
2465  $this->tpl->setVariable('QUESTIONBROWSER', $table_gui->getHTML());
2466  $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this));
2467  $this->tpl->parseCurrentBlock();
2468  }
2469 
2470  function takenObject() {
2471  }
2472 
2481  {
2482  $this->saveMarkSchemaFormData();
2483  $this->object->mark_schema->addMarkStep();
2484  $this->marksObject();
2485  }
2486 
2495  {
2496  $this->object->mark_schema->flush();
2497  foreach ($_POST as $key => $value) {
2498  if (preg_match("/mark_short_(\d+)/", $key, $matches))
2499  {
2500  $this->object->mark_schema->addMarkStep(ilUtil::stripSlashes($_POST["mark_short_$matches[1]"]), ilUtil::stripSlashes($_POST["mark_official_$matches[1]"]), ilUtil::stripSlashes($_POST["mark_percentage_$matches[1]"]), ilUtil::stripSlashes($_POST["passed_$matches[1]"]));
2501  }
2502  }
2503  $this->object->ects_grades["A"] = $_POST["ects_grade_a"];
2504  $this->object->ects_grades["B"] = $_POST["ects_grade_b"];
2505  $this->object->ects_grades["C"] = $_POST["ects_grade_c"];
2506  $this->object->ects_grades["D"] = $_POST["ects_grade_d"];
2507  $this->object->ects_grades["E"] = $_POST["ects_grade_e"];
2508  if ($_POST["chbUseFX"])
2509  {
2510  $this->object->ects_fx = $_POST["percentFX"];
2511  }
2512  else
2513  {
2514  $this->object->ects_fx = "";
2515  }
2516  $this->object->ects_output = $_POST["chbECTS"];
2517  }
2518 
2527  {
2528  $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);
2529  $this->marksObject();
2530  }
2531 
2540  {
2541  $this->saveMarkSchemaFormData();
2542  $delete_mark_steps = array();
2543  foreach ($_POST as $key => $value) {
2544  if (preg_match("/cb_(\d+)/", $key, $matches)) {
2545  array_push($delete_mark_steps, $matches[1]);
2546  }
2547  }
2548  if (count($delete_mark_steps)) {
2549  $this->object->mark_schema->deleteMarkSteps($delete_mark_steps);
2550  } else {
2551  ilUtil::sendInfo($this->lng->txt("tst_delete_missing_mark"));
2552  }
2553  $this->marksObject();
2554  }
2555 
2564  {
2565  $this->ctrl->redirect($this, "marks");
2566  }
2567 
2575  function saveMarksObject()
2576  {
2577  try
2578  {
2579  $this->saveMarkSchemaFormData();
2580  $mark_check = $this->object->checkMarks();
2581  }
2582  catch (Exception $ex)
2583  {
2584  $mark_check = $this->lng->txt('mark_schema_invalid');
2585  }
2586 
2587  if ($mark_check !== true)
2588  {
2589  ilUtil::sendFailure($this->lng->txt($mark_check));
2590  }
2591  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)))
2592  {
2593  ilUtil::sendInfo($this->lng->txt("ects_fill_out_all_values"), true);
2594  }
2595  elseif (($_POST["ects_grade_a"] > 100) or ($_POST["ects_grade_a"] < 0))
2596  {
2597  ilUtil::sendInfo($this->lng->txt("ects_range_error_a"), true);
2598  }
2599  elseif (($_POST["ects_grade_b"] > 100) or ($_POST["ects_grade_b"] < 0))
2600  {
2601  ilUtil::sendInfo($this->lng->txt("ects_range_error_b"), true);
2602  }
2603  elseif (($_POST["ects_grade_c"] > 100) or ($_POST["ects_grade_c"] < 0))
2604  {
2605  ilUtil::sendInfo($this->lng->txt("ects_range_error_c"), true);
2606  }
2607  elseif (($_POST["ects_grade_d"] > 100) or ($_POST["ects_grade_d"] < 0))
2608  {
2609  ilUtil::sendInfo($this->lng->txt("ects_range_error_d"), true);
2610  }
2611  elseif (($_POST["ects_grade_e"] > 100) or ($_POST["ects_grade_e"] < 0))
2612  {
2613  ilUtil::sendInfo($this->lng->txt("ects_range_error_e"), true);
2614  }
2615  else
2616  {
2617  $this->object->mark_schema->saveToDb($this->object->getTestId());
2618  $this->object->saveCompleteStatus( $this->testQuestionSetConfigFactory->getQuestionSetConfig() );
2619  if ($this->object->getReportingDate())
2620  {
2621  $fxpercent = "";
2622  if ($_POST["chbUseFX"])
2623  {
2624  $fxpercent = ilUtil::stripSlashes($_POST["percentFX"]);
2625  }
2626  $this->object->saveECTSStatus($_POST["chbECTS"], $fxpercent, ilUtil::stripSlashes($this->object->ects_grades["A"]), ilUtil::stripSlashes($this->object->ects_grades["B"]), ilUtil::stripSlashes($this->object->ects_grades["C"]), ilUtil::stripSlashes($this->object->ects_grades["D"]), ilUtil::stripSlashes($this->object->ects_grades["E"]));
2627  }
2628  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
2629  }
2630  $this->marksObject();
2631  }
2632 
2633  function marksObject()
2634  {
2635  global $ilAccess;
2636  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
2637  {
2638  // allow only write access
2639  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
2640  $this->ctrl->redirect($this, "infoScreen");
2641  }
2642 
2643  if (!$this->object->canEditMarks())
2644  {
2645  ilUtil::sendInfo($this->lng->txt("cannot_edit_marks"));
2646  }
2647 
2648  $this->object->mark_schema->sort();
2649 
2650  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_marks.html", "Modules/Test");
2651  $marks = $this->object->mark_schema->mark_steps;
2652  $rows = array("tblrow1", "tblrow2");
2653  $counter = 0;
2654  foreach ($marks as $key => $value)
2655  {
2656  $this->tpl->setCurrentBlock("markrow");
2657  $this->tpl->setVariable("MARK_SHORT", $value->getShortName());
2658  $this->tpl->setVariable("MARK_OFFICIAL", $value->getOfficialName());
2659  $this->tpl->setVariable("MARK_PERCENTAGE", sprintf("%.2f", $value->getMinimumLevel()));
2660  $this->tpl->setVariable("MARK_PASSED", strtolower($this->lng->txt("tst_mark_passed")));
2661  $this->tpl->setVariable("MARK_ID", "$key");
2662  $this->tpl->setVariable("ROW_CLASS", $rows[$counter % 2]);
2663 
2664  if( $value->getPassed() )
2665  {
2666  $this->tpl->setVariable("MARK_PASSED_CHECKED", " checked=\"checked\"");
2667  }
2668 
2669  $this->tpl->parseCurrentBlock();
2670  $counter++;
2671  }
2672  if (count($marks) == 0)
2673  {
2674  $this->tpl->setCurrentBlock("Emptyrow");
2675  $this->tpl->setVariable("EMPTY_ROW", $this->lng->txt("tst_no_marks_defined"));
2676  $this->tpl->setVariable("ROW_CLASS", $rows[$counter % 2]);
2677  $this->tpl->parseCurrentBlock();
2678  }
2679  else
2680  {
2681  if ($ilAccess->checkAccess("write", "", $this->ref_id) && $this->object->canEditMarks())
2682  {
2683  $this->tpl->setCurrentBlock("selectall");
2684  $counter++;
2685  $this->tpl->setVariable("ROW_CLASS", $rows[$counter % 2]);
2686  $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
2687  $this->tpl->parseCurrentBlock();
2688  $this->tpl->setCurrentBlock("Footer");
2689  $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.png") . "\" alt=\"".$this->lng->txt("arrow_downright")."\"/>");
2690  $this->tpl->setVariable("BUTTON_EDIT", $this->lng->txt("edit"));
2691  $this->tpl->setVariable("BUTTON_DELETE", $this->lng->txt("delete"));
2692  $this->tpl->parseCurrentBlock();
2693  }
2694  }
2695 
2696  if ($this->object->getReportingDate())
2697  {
2698  $this->tpl->setCurrentBlock("ects");
2699  if ($this->object->ects_output)
2700  {
2701  $this->tpl->setVariable("CHECKED_ECTS", " checked=\"checked\"");
2702  }
2703  $this->tpl->setVariable("TEXT_OUTPUT_ECTS_GRADES", $this->lng->txt("ects_output_of_ects_grades"));
2704  $this->tpl->setVariable("TEXT_ALLOW_ECTS_GRADES", $this->lng->txt("ects_allow_ects_grades"));
2705  $this->tpl->setVariable("TEXT_USE_FX", $this->lng->txt("ects_use_fx_grade"));
2706  if (preg_match("/\d+/", $this->object->ects_fx))
2707  {
2708  $this->tpl->setVariable("CHECKED_FX", " checked=\"checked\"");
2709  $this->tpl->setVariable("VALUE_PERCENT_FX", sprintf("value=\"%s\" ", $this->object->ects_fx));
2710  }
2711  $this->tpl->setVariable("TEXT_PERCENT", $this->lng->txt("ects_use_fx_grade_part2"));
2712  $this->tpl->setVariable("ECTS_GRADE", $this->lng->txt("ects_grade"));
2713  $this->tpl->setVariable("PERCENTILE", $this->lng->txt("percentile"));
2714  $this->tpl->setVariable("ECTS_GRADE_A", "A - " . $this->lng->txt("ects_grade_a_short"));
2715  $this->tpl->setVariable("VALUE_GRADE_A", $this->object->ects_grades["A"]);
2716  $this->tpl->setVariable("ECTS_GRADE_B", "B - " . $this->lng->txt("ects_grade_b_short"));
2717  $this->tpl->setVariable("VALUE_GRADE_B", $this->object->ects_grades["B"]);
2718  $this->tpl->setVariable("ECTS_GRADE_C", "C - " . $this->lng->txt("ects_grade_c_short"));
2719  $this->tpl->setVariable("VALUE_GRADE_C", $this->object->ects_grades["C"]);
2720  $this->tpl->setVariable("ECTS_GRADE_D", "D - " . $this->lng->txt("ects_grade_d_short"));
2721  $this->tpl->setVariable("VALUE_GRADE_D", $this->object->ects_grades["D"]);
2722  $this->tpl->setVariable("ECTS_GRADE_E", "E - " . $this->lng->txt("ects_grade_e_short"));
2723  $this->tpl->setVariable("VALUE_GRADE_E", $this->object->ects_grades["E"]);
2724 
2725  $this->tpl->parseCurrentBlock();
2726  }
2727 
2728  $this->tpl->setCurrentBlock("adm_content");
2729  $this->tpl->setVariable("ACTION_MARKS", $this->ctrl->getFormAction($this));
2730  $this->tpl->setVariable("HEADER_SHORT", $this->lng->txt("tst_mark_short_form"));
2731  $this->tpl->setVariable("HEADER_OFFICIAL", $this->lng->txt("tst_mark_official_form"));
2732  $this->tpl->setVariable("HEADER_PERCENTAGE", $this->lng->txt("tst_mark_minimum_level"));
2733  $this->tpl->setVariable("HEADER_PASSED", $this->lng->txt("tst_mark_passed"));
2734  if ($ilAccess->checkAccess("write", "", $this->ref_id) && $this->object->canEditMarks())
2735  {
2736  $this->tpl->setVariable("BUTTON_NEW", $this->lng->txt("tst_mark_create_new_mark_step"));
2737  $this->tpl->setVariable("BUTTON_NEW_SIMPLE", $this->lng->txt("tst_mark_create_simple_mark_schema"));
2738  $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
2739  $this->tpl->setVariable("CANCEL", $this->lng->txt("cancel"));
2740  }
2741  $this->tpl->parseCurrentBlock();
2742  }
2743 
2752  {
2753  global $ilDB, $lng;
2754 
2755  require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
2756 
2757  $participantData = new ilTestParticipantData($ilDB, $lng);
2758  $participantData->load($this->object->getTestId());
2759 
2760  $this->object->removeTestResults($participantData);
2761 
2762  ilUtil::sendSuccess($this->lng->txt("tst_all_user_data_deleted"), true);
2763  $this->ctrl->redirect($this, "participants");
2764  }
2765 
2774  {
2775  global $ilDB, $lng;
2776 
2777  require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
2778  $participantData = new ilTestParticipantData($ilDB, $lng);
2779 
2780  if( $this->object->getFixedParticipants() )
2781  {
2782  $participantData->setUserIds($_POST["chbUser"]);
2783  }
2784  else
2785  {
2786  $participantData->setActiveIds($_POST["chbUser"]);
2787  }
2788 
2789  $participantData->load($this->object->getTestId());
2790 
2791  $this->object->removeTestResults($participantData);
2792 
2793  ilUtil::sendSuccess($this->lng->txt("tst_selected_user_data_deleted"), true);
2794  $this->ctrl->redirect($this, "participants");
2795  }
2796 
2805  {
2806  $this->ctrl->redirect($this, "participants");
2807  }
2808 
2819  {
2820  ilUtil::sendQuestion($this->lng->txt("confirm_delete_all_user_data"));
2821  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_maintenance.html", "Modules/Test");
2822 
2823  $this->tpl->setCurrentBlock("confirm_delete");
2824  $this->tpl->setVariable("BTN_CONFIRM_DELETE_ALL", $this->lng->txt("confirm"));
2825  $this->tpl->setVariable("BTN_CANCEL_DELETE_ALL", $this->lng->txt("cancel"));
2826  $this->tpl->parseCurrentBlock();
2827 
2828  $this->tpl->setCurrentBlock("adm_content");
2829  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
2830  $this->tpl->parseCurrentBlock();
2831  }
2832 
2836  public function deleteAllUserResultsObject()
2837  {
2838  // display confirmation message
2839  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
2840  $cgui = new ilConfirmationGUI();
2841  $cgui->setFormAction($this->ctrl->getFormAction($this, "participants"));
2842  $cgui->setHeaderText($this->lng->txt("delete_all_user_data_confirmation"));
2843  $cgui->setCancel($this->lng->txt("cancel"), "participants");
2844  $cgui->setConfirm($this->lng->txt("proceed"), "confirmDeleteAllUserResults");
2845 
2846  $this->tpl->setContent($cgui->getHTML());
2847  }
2848 
2857  {
2858  if (count($_POST["chbUser"]) == 0)
2859  {
2860  ilUtil::sendInfo($this->lng->txt("select_one_user"), TRUE);
2861  $this->ctrl->redirect($this, "participants");
2862  }
2863 
2864  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
2865  $cgui = new ilConfirmationGUI();
2866  $cgui->setHeaderText($this->lng->txt("confirm_delete_single_user_data"));
2867 
2868  $cgui->setFormAction($this->ctrl->getFormAction($this));
2869  $cgui->setCancel($this->lng->txt("cancel"), "cancelDeleteSelectedUserData");
2870  $cgui->setConfirm($this->lng->txt("confirm"), "confirmDeleteSelectedUserData");
2871 
2872  include_once './Services/User/classes/class.ilObjUser.php';
2873  foreach ($_POST["chbUser"] as $key => $active_id)
2874  {
2875  if ($this->object->getFixedParticipants())
2876  {
2877  $user_id = $active_id;
2878  }
2879  else
2880  {
2881  $user_id = $this->object->_getUserIdFromActiveId($active_id);
2882  }
2883  $user = ilObjUser::_lookupName($user_id);
2884 
2885  if ($this->object->getAnonymity())
2886  {
2887  $name = $this->lng->txt("anonymous");
2888  }
2889  else if($user["lastname"])
2890  {
2891  $name = $user["lastname"].", ".$user["firstname"]." (".
2892  $user["login"].")";
2893  }
2894  else
2895  {
2896  $name = $this->lng->txt("deleted_user");
2897  }
2898 
2899  $cgui->addItem("chbUser[]", $active_id, $name,
2900  ilUtil::getImagePath("icon_usr.png"), $this->lng->txt("usr"));
2901  }
2902 
2903  $this->tpl->setContent($cgui->getHTML());
2904  }
2905 
2913  function historyObject()
2914  {
2915  include_once "./Modules/Test/classes/tables/class.ilTestHistoryTableGUI.php";
2916  $table_gui = new ilTestHistoryTableGUI($this, 'history');
2917  $table_gui->setTestObject($this->object);
2918  include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
2919  $log =& ilObjAssessmentFolder::_getLog(0, time(), $this->object->getId(), TRUE);
2920  $table_gui->setData($log);
2921  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
2922  }
2923 
2924  function initImportForm($a_new_type)
2925  {
2926  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2927  $form = new ilPropertyFormGUI();
2928  $form->setTarget("_top");
2929  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
2930  $this->ctrl->setParameter($this, "new_type", $new_type);
2931  $form->setFormAction($this->ctrl->getFormAction($this));
2932  $form->setTitle($this->lng->txt("import_tst"));
2933 
2934  // file
2935  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
2936  $fi = new ilFileInputGUI($this->lng->txt("import_file"), "xmldoc");
2937  $fi->setSuffixes(array("zip"));
2938  $fi->setRequired(true);
2939  $form->addItem($fi);
2940 
2941  // question pool
2942  include_once("./Modules/Test/classes/class.ilObjTest.php");
2943  $tst = new ilObjTest();
2944  $questionpools = $tst->getAvailableQuestionpools(TRUE, FALSE, TRUE, TRUE);
2945  if (count($questionpools))
2946  {
2947  $options = array("-1" => $this->lng->txt("dont_use_questionpool"));
2948  foreach ($questionpools as $key => $value)
2949  {
2950  $options[$key] = $value["title"];
2951  }
2952 
2953  $pool = new ilSelectInputGUI($this->lng->txt("select_questionpool"), "qpl");
2954  $pool->setOptions($options);
2955  $form->addItem($pool);
2956  }
2957 
2958  $form->addCommandButton("importFile", $this->lng->txt("import"));
2959  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
2960 
2961  return $form;
2962  }
2963 
2970  {
2971  $command = $_POST["command"];
2972  if (strlen($command))
2973  {
2974  $method = $command . "Object";
2975  if (method_exists($this, $method))
2976  {
2977  $this->$method();
2978  return;
2979  }
2980  }
2981  $this->ctrl->redirect($this, "participants");
2982  }
2983 
2990  {
2991  global $ilAccess, $ilToolbar, $lng;
2992 
2993  $this->getParticipantsSubTabs();
2994 
2995  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
2996  {
2997  // allow only write access
2998  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
2999  $this->ctrl->redirect($this, "infoScreen");
3000  }
3001 
3002  if( $this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken($this->tree) )
3003  {
3005  $this->testQuestionSetConfigFactory->getQuestionSetConfig()->getDepenciesBrokenMessage($this->lng)
3006  );
3007  }
3008  elseif( $this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesInVulnerableState($this->tree) )
3009  {
3011  $this->questionSetConfig->getDepenciesInVulnerableStateMessage($this->lng)
3012  );
3013  }
3014 
3015  if ($this->object->getFixedParticipants())
3016  {
3017  // search button
3018  include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
3020  $this,
3021  $tb,
3022  array(
3023  'auto_complete_name' => $lng->txt('user'),
3024  'submit_name' => $lng->txt('add')
3025  )
3026  );
3027 
3028  // search button
3029  $ilToolbar->addButton($this->lng->txt("tst_search_users"),
3030  $this->ctrl->getLinkTargetByClass('ilRepositorySearchGUI','start'));
3031 
3032 
3033  $participants =& $this->object->getInvitedUsers();
3034  $rows = array();
3035  foreach ($participants as $data)
3036  {
3037  $maxpass = $this->object->_getMaxPass($data["active_id"]);
3038  if (!is_null($maxpass))
3039  {
3040  $maxpass += 1;
3041  }
3042  $access = "";
3043  if (strlen($data["active_id"]))
3044  {
3045  $last_access = $this->object->_getLastAccess($data["active_id"]);
3046  $access = $last_access;
3047  }
3048  $this->ctrl->setParameterByClass('iltestevaluationgui', 'active_id', $data['active_id']);
3049 
3050  if ($data['active_id'] == null) // if no active id is set, user is invitee not participant...
3051  {
3052  if ( strlen($data["firstname"].$data["lastname"]) == 0 )
3053  {
3054  $fullname = $lng->txt("deleted_user");
3055  }
3056  else if($this->object->getAnonymity())
3057  {
3058  $fullname = $lng->txt('anonymous');
3059  }
3060  else
3061  {
3062  $fullname = trim($data["lastname"] . ", " . $data["firstname"] . " " . $data["title"]);
3063  }
3064  } else {
3065  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
3066  $fullname = ilObjTestAccess::_getParticipantData($data['active_id']);
3067  }
3068 
3069  array_push($rows, array(
3070  'usr_id' => $data["usr_id"],
3071  'active_id' => $data['active_id'],
3072  'login' => $data["login"],
3073  'clientip' => $data["clientip"],
3074  'firstname' => $data["firstname"],
3075  'lastname' => $data["lastname"],
3076  'name' => $fullname,
3077  'started' => ($data["active_id"] > 0) ? 1 : 0,
3078  'finished' => ($data["test_finished"] == 1) ? 1 : 0,
3079  'access' => $access,
3080  'maxpass' => $maxpass,
3081  'result' => $this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'outParticipantsResultsOverview')
3082  ));
3083  }
3084  include_once "./Modules/Test/classes/tables/class.ilTestFixedParticipantsTableGUI.php";
3085  $table_gui = new ilTestFixedParticipantsTableGUI( $this, 'participants',
3086  $this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken(),
3087  $this->object->getAnonymity(), count($rows)
3088  );
3089  $table_gui->setFilterCommand('fpSetFilter');
3090  $table_gui->setResetCommand('fpResetFiler');
3091  $rows = $this->applyFilterCriteria($rows);
3092  $table_gui->setData($rows);
3093  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
3094  }
3095  else
3096  {
3097  $participants =& $this->object->getTestParticipants();
3098  $rows = array();
3099  foreach ($participants as $data)
3100  {
3101  $maxpass = $this->object->_getMaxPass($data["active_id"]);
3102  if (!is_null($maxpass))
3103  {
3104  $maxpass += 1;
3105  }
3106  $access = "";
3107  if (strlen($data["active_id"]))
3108  {
3109  $last_access = $this->object->_getLastAccess($data["active_id"]);
3110  $access = $last_access;
3111  }
3112  $this->ctrl->setParameterByClass('iltestevaluationgui', 'active_id', $data['active_id']);
3113 
3114  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
3115  $fullname = ilObjTestAccess::_getParticipantData($data['active_id']);
3116  array_push($rows, array(
3117  'usr_id' => $data["active_id"],
3118  'active_id' => $data['active_id'],
3119  'login' => $data["login"],
3120  'name' => $fullname,
3121  'firstname' => $data["firstname"],
3122  'lastname' => $data["lastname"],
3123  'started' => ($data["active_id"] > 0) ? 1 : 0,
3124  'finished' => ($data["test_finished"] == 1) ? 1 : 0,
3125  'access' => $access,
3126  'maxpass' => $maxpass,
3127  'result' => $this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'outParticipantsResultsOverview')
3128  ));
3129  }
3130  include_once "./Modules/Test/classes/tables/class.ilTestParticipantsTableGUI.php";
3131  $table_gui = new ilTestParticipantsTableGUI( $this, 'participants',
3132  $this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken(),
3133  $this->object->getAnonymity(), count($rows)
3134  );
3135  $table_gui->setFilterCommand('npSetFilter');
3136  $table_gui->setResetCommand('npResetFilter');
3137  $rows = $this->applyFilterCriteria($rows);
3138  $table_gui->setData($rows);
3139  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
3140  }
3141  }
3142 
3143  public function timingOverviewObject()
3144  {
3145  $this->getParticipantsSubTabs();
3146 
3147  include_once "./Modules/Test/classes/tables/class.ilTimingOverviewTableGUI.php";
3148  $table_gui = new ilTimingOverviewTableGUI($this, 'timingOverview');
3149 
3150  $participants =& $this->object->getTestParticipants();#
3151  $times = $this->object->getStartingTimeOfParticipants();
3152  $addons = $this->object->getTimeExtensionsOfParticipants();
3153 
3154  $tbl_data = array();
3155  $i = 0;
3156  foreach ($participants as $participant)
3157  {
3158  $started = "";
3159  if ($times[$participant['active_id']])
3160  {
3161  $started = $this->lng->txt('tst_started').': '.ilDatePresentation::formatDate(new ilDateTime($times[$participant['active_id']], IL_CAL_DATETIME));
3162  $tbl_data[$i]['started'] = $started;
3163  }
3164  else
3165  {
3166  $tbl_data[$i]['started'] = '';
3167  }
3168 
3169  if ($addons[$participant['active_id']] > 0)
3170  {
3171  $tbl_data[$i]['extratime'] = $addons[$participant['active_id']];
3172  }
3173 
3174  $tbl_data[$i]['login'] = $participant['login'];
3175 
3176  if ($this->object->getAnonymity())
3177  {
3178  $name = $this->lng->txt("anonymous");
3179  }
3180  else
3181  {
3182  $name = $participant['lastname'] . ', ' . $participant['firstname'];
3183  }
3184 
3185  $tbl_data[$i]['name'] = $name;
3186  }
3187  $table_gui->setData($tbl_data);
3188 
3189  $this->tpl->setContent($table_gui->getHTML());
3190  }
3191 
3192  public function timingObject()
3193  {
3194  $this->getParticipantsSubTabs();
3195 
3196  global $ilAccess;
3197 
3198  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
3199  {
3200  // allow only write access
3201  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3202  $this->ctrl->redirect($this, "infoScreen");
3203  }
3204 
3205  if ($this->object->getProcessingTimeInSeconds() > 0 && $this->object->getNrOfTries() == 1)
3206  {
3207  $form = $this->formTimingObject();
3208  if (count($_POST) && $form->checkInput())
3209  {
3210  $res = $this->object->addExtraTime($form->getInput('participant'), $form->getInput('extratime'));
3211  ilUtil::sendSuccess(sprintf($this->lng->txt('tst_extratime_added'), $form->getInput('extratime')), true);
3212  $this->ctrl->redirect($this, 'timingOverview');
3213  }
3214  else
3215  {
3216  return $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
3217  }
3218  }
3219  else
3220  {
3221  ilUtil::sendInfo($this->lng->txt("tst_extratime_notavailable"));
3222  }
3223  }
3224 
3225  private function formTimingObject()
3226  {
3227  global $ilAccess;
3228 
3229  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
3230  $form = new ilPropertyFormGUI();
3231  $form->setFormAction($this->ctrl->getFormAction($this));
3232  $form->setTableWidth("100%");
3233  $form->setId("tst_change_workingtime");
3234  $form->setTitle($this->lng->txt("tst_change_workingtime"));
3235 
3236  // test users
3237  $participantslist = new ilSelectInputGUI($this->lng->txt('participants'), "participant");
3238  $participants =& $this->object->getTestParticipants();
3239  $times = $this->object->getStartingTimeOfParticipants();
3240  $addons = $this->object->getTimeExtensionsOfParticipants();
3241  $options = array(
3242  '' => $this->lng->txt('please_select'),
3243  '0' => $this->lng->txt('all_participants')
3244  );
3245  foreach ($participants as $participant)
3246  {
3247  $started = "";
3248 
3249  if ($this->object->getAnonymity())
3250  {
3251  $name = $this->lng->txt("anonymous");
3252  }
3253  else
3254  {
3255  $name = $participant['lastname'] . ', ' . $participant['firstname'];
3256  }
3257 
3258 
3259  if ($times[$participant['active_id']])
3260  {
3261  $started = ", ".$this->lng->txt('tst_started').': '.ilDatePresentation::formatDate(new ilDateTime($times[$participant['active_id']], IL_CAL_DATETIME));
3262  }
3263  if ($addons[$participant['active_id']] > 0) $started .= ", " . $this->lng->txt('extratime') . ': ' . $addons[$participant['active_id']] . ' ' . $this->lng->txt('minutes');
3264  $options[$participant['active_id']] = $participant['login'] . ' (' .$name. ')'.$started;
3265  }
3266  $participantslist->setRequired(true);
3267  $participantslist->setOptions($options);
3268  $form->addItem($participantslist);
3269 
3270  // extra time
3271  $extratime = new ilNumberInputGUI($this->lng->txt("extratime"), "extratime");
3272  $extratime->setInfo($this->lng->txt('tst_extratime_info'));
3273  $extratime->setRequired(true);
3274  $extratime->setMinValue(0);
3275  $extratime->setMinvalueShouldBeGreater(false);
3276  $extratime->setSuffix($this->lng->txt('minutes'));
3277  $extratime->setSize(5);
3278  $form->addItem($extratime);
3279 
3280  if (is_array($_POST) && strlen($_POST['cmd']['timing'])) $form->setValuesByArray($_POST);
3281 
3282  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) $form->addCommandButton("timing", $this->lng->txt("save"));
3283  $form->addCommandButton('timingOverview', $this->lng->txt("cancel"));
3284  return $form;
3285  }
3286 
3287  public function showTimingFormObject()
3288  {
3289  $form = $this->formTimingObject();
3290  $this->tpl->setContent($form->getHTML());
3291  }
3292 
3293  function applyFilterCriteria($in_rows)
3294  {
3295  global $ilDB;
3296 
3297  $sess_filter = $_SESSION['form_']['selection'];
3298  $sess_filter = str_replace('"','',$sess_filter);
3299  $sess_filter = explode(':', $sess_filter);
3300  $filter = substr($sess_filter[2],0, strlen($sess_filter[2])-1);
3301 
3302  if ($filter == 'all' || $filter == false)
3303  {
3304  return $in_rows; #unchanged - no filter.
3305  }
3306 
3307  $with_result = array();
3308  $without_result = array();
3309  foreach ($in_rows as $row)
3310  {
3311  $result = $ilDB->query(
3312  'SELECT count(solution_id) count
3313  FROM tst_solutions
3314  WHERE active_fi = ' . $ilDB->quote($row['active_id'])
3315  );
3316  $count = $ilDB->fetchAssoc($result);
3317  $count = $count['count'];
3318 
3319  if ($count == 0)
3320  {
3321  $without_result[] = $row;
3322  }
3323  else
3324  {
3325  $with_result[] = $row;
3326  }
3327  }
3328 
3329  if ($filter == 'withSolutions')
3330  {
3331  return $with_result;
3332  }
3333  return $without_result;
3334 
3335  }
3336 
3338  {
3339  include_once("./Modules/Test/classes/tables/class.ilTestFixedParticipantsTableGUI.php");
3340  $table_gui = new ilTestFixedParticipantsTableGUI($this, "participants", false, $this->object->getAnonymity(), 0);
3341  $table_gui->writeFilterToSession(); // writes filter to session
3342  $table_gui->resetOffset(); // sets record offest to 0 (first page)
3343  $this->participantsObject();
3344  }
3345 
3347  {
3348  include_once("./Modules/Test/classes/tables/class.ilTestFixedParticipantsTableGUI.php");
3349  $table_gui = new ilTestFixedParticipantsTableGUI(
3350  $this, "participants", false, $this->object->getAnonymity(), 0
3351  );
3352  $table_gui->resetFilter(); // writes filter to session
3353  $table_gui->resetOffset(); // sets record offest to 0 (first page)
3354  $this->participantsObject();
3355  }
3356 
3358  {
3359  include_once("./Modules/Test/classes/tables/class.ilTestParticipantsTableGUI.php");
3360  $table_gui = new ilTestParticipantsTableGUI(
3361  $this, "participants", false, $this->object->getAnonymity(), 0
3362  );
3363  $table_gui->writeFilterToSession(); // writes filter to session
3364  $table_gui->resetOffset(); // sets record offest to 0 (first page)
3365  $this->participantsObject();
3366 
3367  }
3368 
3370  {
3371  include_once("./Modules/Test/classes/tables/class.ilTestParticipantsTableGUI.php");
3372  $table_gui = new ilTestParticipantsTableGUI(
3373  $this, "participants", false, $this->object->getAnonymity(), 0
3374  );
3375  $table_gui->resetFilter(); // writes filter to session
3376  $table_gui->resetOffset(); // sets record offest to 0 (first page)
3377  $this->participantsObject();
3378 
3379  }
3380 
3387  {
3388  if (count($_POST))
3389  {
3390  $_SESSION["show_user_results"] = $_POST["chbUser"];
3391  }
3392  $this->showUserResults($show_pass_details = TRUE, $show_answers = TRUE, $show_reached_points = TRUE);
3393  }
3394 
3401  {
3402  if (count($_POST))
3403  {
3404  $_SESSION["show_user_results"] = $_POST["chbUser"];
3405  }
3406  $this->showUserResults($show_pass_details = FALSE, $show_answers = TRUE);
3407  }
3408 
3415  {
3416  if (count($_POST))
3417  {
3418  $_SESSION["show_user_results"] = $_POST["chbUser"];
3419  }
3420  $this->showUserResults($show_pass_details = TRUE, $show_answers = FALSE);
3421  }
3422 
3428  function showUserResults($show_pass_details, $show_answers, $show_reached_points = FALSE)
3429  {
3430  $show_user_results = $_SESSION["show_user_results"];
3431 
3432  if (count($show_user_results) == 0)
3433  {
3434  ilUtil::sendInfo($this->lng->txt("select_one_user"), TRUE);
3435  $this->ctrl->redirect($this, "participants");
3436  }
3437 
3438 
3439  $template = $this->createUserResults( $show_pass_details, $show_answers, $show_reached_points, $show_user_results);
3440 
3441  $this->tpl->setVariable("ADM_CONTENT", $template->get());
3442  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
3443  if ($this->object->getShowSolutionAnswersOnly())
3444  {
3445  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
3446  }
3447  }
3448 
3450  {
3451  if (is_array($_POST["chbUser"]))
3452  {
3453  foreach ($_POST["chbUser"] as $user_id)
3454  {
3455  $this->object->disinviteUser($user_id);
3456  }
3457  }
3458  else
3459  {
3460  ilUtil::sendInfo($this->lng->txt("select_one_user"), true);
3461  }
3462  $this->ctrl->redirect($this, "participants");
3463  }
3464 
3466  {
3467  if (is_array($_POST["chbUser"]))
3468  {
3469  foreach ($_POST["chbUser"] as $user_id)
3470  {
3471  $this->object->setClientIP($user_id, $_POST["clientip_".$user_id]);
3472  }
3473  }
3474  else
3475  {
3476  ilUtil::sendInfo($this->lng->txt("select_one_user"), true);
3477  }
3478  $this->ctrl->redirect($this, "participants");
3479  }
3480 
3488  function printobject()
3489  {
3490  global $ilAccess, $ilias;
3491  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
3492  {
3493  // allow only write access
3494  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3495  $this->ctrl->redirect($this, "infoScreen");
3496  }
3497  $this->getQuestionsSubTabs();
3498  $template = new ilTemplate("tpl.il_as_tst_print_test_confirm.html", TRUE, TRUE, "Modules/Test");
3499 
3500  if(!array_key_exists("pdf", $_GET) || $_GET["pdf"] != 1) // #15243
3501  {
3502  $this->ctrl->setParameter($this, "pdf", "1");
3503  $template->setCurrentBlock("pdf_export");
3504  $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "print"));
3505  $this->ctrl->setParameter($this, "pdf", "");
3506  $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
3507  $template->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export"));
3508  $template->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")));
3509  $template->parseCurrentBlock();
3510 
3511  $template->setCurrentBlock("navigation_buttons");
3512  $template->setVariable("BUTTON_PRINT", $this->lng->txt("print"));
3513  $template->parseCurrentBlock();
3514  }
3515 
3516  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
3517 
3518  global $ilUser;
3519  $print_date = mktime(date("H"), date("i"), date("s"), date("m") , date("d"), date("Y"));
3520  $max_points= 0;
3521  $counter = 1;
3522 
3523  foreach ($this->object->questions as $question)
3524  {
3525  $template->setCurrentBlock("question");
3526  $question_gui = $this->object->createQuestionGUI("", $question);
3527  $template->setVariable("COUNTER_QUESTION", $counter.".");
3528  $template->setVariable("TXT_QUESTION_ID", $this->lng->txt('question_id_short'));
3529  $template->setVariable("QUESTION_ID", $question_gui->object->getId());
3530  $template->setVariable("QUESTION_TITLE", ilUtil::prepareFormOutput($question_gui->object->getTitle()));
3531  if ($question_gui->object->getMaximumPoints() == 1)
3532  {
3533  $template->setVariable("QUESTION_POINTS", $question_gui->object->getMaximumPoints() . " " . $this->lng->txt("point"));
3534  }
3535  else
3536  {
3537  $template->setVariable("QUESTION_POINTS", $question_gui->object->getMaximumPoints() . " " . $this->lng->txt("points"));
3538  }
3539  $result_output = $question_gui->getSolutionOutput("", NULL, FALSE, TRUE, FALSE, $this->object->getShowSolutionFeedback());
3540  if (strlen($result_output) == 0) $result_output = $question_gui->getPreview(FALSE);
3541  $template->setVariable("SOLUTION_OUTPUT", $result_output);
3542  $template->parseCurrentBlock("question");
3543  $counter ++;
3544  $max_points += $question_gui->object->getMaximumPoints();
3545  }
3546 
3547  $template->setVariable("TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
3548  $template->setVariable("PRINT_TEST", ilUtil::prepareFormOutput($this->lng->txt("tst_print")));
3549  $template->setVariable("TXT_PRINT_DATE", ilUtil::prepareFormOutput($this->lng->txt("date")));
3550  $template->setVariable("VALUE_PRINT_DATE", ilUtil::prepareFormOutput(strftime("%c",$print_date)));
3551  $template->setVariable("TXT_MAXIMUM_POINTS", ilUtil::prepareFormOutput($this->lng->txt("tst_maximum_points")));
3552  $template->setVariable("VALUE_MAXIMUM_POINTS", ilUtil::prepareFormOutput($max_points));
3553 
3554  if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1))
3555  {
3556  //$this->object->deliverPDFfromHTML($template->get(), $this->object->getTitle());
3557  require_once 'class.ilTestPDFGenerator.php';
3558  ilTestPDFGenerator::generatePDF($template->get(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->object->getTitle());
3559  }
3560  else
3561  {
3562  $this->tpl->setVariable("PRINT_CONTENT", $template->get());
3563  }
3564  }
3565 
3573  function reviewobject()
3574  {
3575  global $ilAccess, $ilias;
3576  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
3577  {
3578  // allow only write access
3579  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3580  $this->ctrl->redirect($this, "infoScreen");
3581  }
3582  $this->getQuestionsSubTabs();
3583  $template = new ilTemplate("tpl.il_as_tst_print_test_confirm.html", TRUE, TRUE, "Modules/Test");
3584 
3585  $this->ctrl->setParameter($this, "pdf", "1");
3586  $template->setCurrentBlock("pdf_export");
3587  $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "review"));
3588  $this->ctrl->setParameter($this, "pdf", "");
3589  $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
3590  $template->setVariable("PDF_IMG_ALT", $this->lng->txt("pdf_export"));
3591  $template->setVariable("PDF_IMG_URL", ilUtil::getHtmlPath(ilUtil::getImagePath("application-pdf.png")));
3592  $template->parseCurrentBlock();
3593 
3594  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
3595 
3596  global $ilUser;
3597  $print_date = mktime(date("H"), date("i"), date("s"), date("m") , date("d"), date("Y"));
3598  $max_points= 0;
3599  $counter = 1;
3600 
3601  foreach ($this->object->questions as $question)
3602  {
3603  $template->setCurrentBlock("question");
3604  $question_gui = $this->object->createQuestionGUI("", $question);
3605  $template->setVariable("COUNTER_QUESTION", $counter.".");
3606  $template->setVariable("QUESTION_TITLE", ilUtil::prepareFormOutput($question_gui->object->getTitle()));
3607  if ($question_gui->object->getMaximumPoints() == 1)
3608  {
3609  $template->setVariable("QUESTION_POINTS", $question_gui->object->getMaximumPoints() . " " . $this->lng->txt("point"));
3610  }
3611  else
3612  {
3613  $template->setVariable("QUESTION_POINTS", $question_gui->object->getMaximumPoints() . " " . $this->lng->txt("points"));
3614  }
3616  //$result_output = $question_gui->getTestOutput('', NULL, FALSE, FALSE, FALSE);
3617  $result_output = $question_gui->getPreview(false);
3618 
3619  if (strlen($result_output) == 0) $result_output = $question_gui->getPreview(FALSE);
3620  $template->setVariable("SOLUTION_OUTPUT", $result_output);
3621  $template->parseCurrentBlock("question");
3622  $counter ++;
3623  $max_points += $question_gui->object->getMaximumPoints();
3624  }
3625 
3626 
3627 
3628  $template->setVariable("TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
3629  $template->setVariable("PRINT_TEST", ilUtil::prepareFormOutput($this->lng->txt("review_view")));
3630  $template->setVariable("TXT_PRINT_DATE", ilUtil::prepareFormOutput($this->lng->txt("date")));
3631  $template->setVariable("VALUE_PRINT_DATE", ilUtil::prepareFormOutput(strftime("%c",$print_date)));
3632  $template->setVariable("TXT_MAXIMUM_POINTS", ilUtil::prepareFormOutput($this->lng->txt("tst_maximum_points")));
3633  $template->setVariable("VALUE_MAXIMUM_POINTS", ilUtil::prepareFormOutput($max_points));
3634 
3635  if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1))
3636  {
3637  //$this->object->deliverPDFfromHTML($template->get(), $this->object->getTitle());
3638  require_once 'class.ilTestPDFGenerator.php';
3639  $content = $template->get();
3640  ilTestPDFGenerator::generatePDF($template->get(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->object->getTitle());
3641  }
3642  else
3643  {
3644  $template->setCurrentBlock("navigation_buttons");
3645  $template->setVariable("BUTTON_PRINT", $this->lng->txt("print"));
3646  $template->parseCurrentBlock();
3647 
3648 
3649  $this->tpl->setVariable("PRINT_CONTENT", $template->get());
3650  }
3651  }
3652 
3653  function addParticipantsObject($a_user_ids = array())
3654  {
3655  $countusers = 0;
3656  // add users
3657  if (is_array($a_user_ids))
3658  {
3659  $i = 0;
3660  foreach ($a_user_ids as $user_id)
3661  {
3662  $client_ip = $_POST["client_ip"][$i];
3663  $this->object->inviteUser($user_id, $client_ip);
3664  $countusers++;
3665  $i++;
3666  }
3667  }
3668  $message = "";
3669  if ($countusers)
3670  {
3671  $message = $this->lng->txt("tst_invited_selected_users");
3672  }
3673  if (strlen($message))
3674  {
3675  ilUtil::sendInfo($message, TRUE);
3676  }
3677  else
3678  {
3679  ilUtil::sendInfo($this->lng->txt("tst_invited_nobody"), TRUE);
3680  return false;
3681  }
3682 
3683  $this->ctrl->redirect($this, "participants");
3684  }
3685 
3689  public function defaultsObject()
3690  {
3696  global $ilAccess, $ilToolbar, $tpl;
3697 
3698  if(!$ilAccess->checkAccess("write", "", $this->ref_id))
3699  {
3700  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3701  $this->ctrl->redirect($this, "infoScreen");
3702  }
3703 
3704  $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'addDefaults'));
3705  $ilToolbar->addFormButton($this->lng->txt('add'), 'addDefaults');
3706  require_once 'Services/Form/classes/class.ilTextInputGUI.php';
3707  $ilToolbar->addInputItem(new ilTextInputGUI($this->lng->txt('tst_defaults_defaults_of_test'), 'name'), true);
3708 
3709  require_once 'Modules/Test/classes/tables/class.ilTestPersonalDefaultSettingsTableGUI.php';
3710  $table = new ilTestPersonalDefaultSettingsTableGUI($this, 'defaults');
3711  $defaults = $this->object->getAvailableDefaults();
3712  $table->setData((array)$defaults);
3713  $tpl->setContent($table->getHTML());
3714  }
3715 
3719  public function deleteDefaultsObject()
3720  {
3721  if(isset($_POST['chb_defaults']) && is_array($_POST['chb_defaults']) && count($_POST['chb_defaults']))
3722  {
3723  foreach($_POST['chb_defaults'] as $test_default_id)
3724  {
3725  $this->object->deleteDefaults($test_default_id);
3726  }
3727  }
3728  else
3729  {
3730  ilUtil::sendInfo($this->lng->txt('select_one'));
3731  }
3732  $this->defaultsObject();
3733  }
3734 
3739  {
3740  $this->applyDefaultsObject(true);
3741  return;
3742  }
3743 
3747  public function applyDefaultsObject($confirmed = false)
3748  {
3749  if( count($_POST["chb_defaults"]) != 1 )
3750  {
3752  $this->lng->txt("tst_defaults_apply_select_one")
3753  );
3754 
3755  return $this->defaultsObject();
3756  }
3757 
3758  // do not apply if user datasets exist
3759  if($this->object->evalTotalPersons() > 0)
3760  {
3762  $this->lng->txt("tst_defaults_apply_not_possible")
3763  );
3764 
3765  return $this->defaultsObject();
3766  }
3767 
3768  $defaults =& $this->object->getTestDefaults($_POST["chb_defaults"][0]);
3769  $defaultSettings = unserialize($defaults["defaults"]);
3770 
3771  if( isset($defaultSettings['isRandomTest']) )
3772  {
3773  if( $defaultSettings['isRandomTest'] )
3774  {
3775  $newQuestionSetType = ilObjTest::QUESTION_SET_TYPE_RANDOM;
3776  $this->object->setQuestionSetType(ilObjTest::QUESTION_SET_TYPE_RANDOM);
3777  }
3778  else
3779  {
3780  $newQuestionSetType = ilObjTest::QUESTION_SET_TYPE_FIXED;
3781  $this->object->setQuestionSetType(ilObjTest::QUESTION_SET_TYPE_FIXED);
3782  }
3783  }
3784  elseif( isset($defaultSettings['questionSetType']) )
3785  {
3786  $newQuestionSetType = $defaultSettings['questionSetType'];
3787  }
3788  $oldQuestionSetType = $this->object->getQuestionSetType();
3789  $questionSetTypeSettingSwitched = ( $oldQuestionSetType != $newQuestionSetType );
3790 
3791  $oldQuestionSetConfig = $this->testQuestionSetConfigFactory->getQuestionSetConfigByType($oldQuestionSetType);
3792 
3793  switch( true )
3794  {
3795  case !$questionSetTypeSettingSwitched:
3796  case !$oldQuestionSetConfig->doesQuestionSetRelatedDataExist():
3797  case $confirmed:
3798 
3799  break;
3800 
3801  default:
3802 
3803  require_once 'Modules/Test/classes/confirmations/class.ilTestSettingsChangeConfirmationGUI.php';
3804  $confirmation = new ilTestSettingsChangeConfirmationGUI($this->lng, $this->object);
3805 
3806  $confirmation->setFormAction( $this->ctrl->getFormAction($this) );
3807  $confirmation->setCancel($this->lng->txt('cancel'), 'defaults');
3808  $confirmation->setConfirm($this->lng->txt('confirm'), 'confirmedApplyDefaults');
3809 
3810  $confirmation->setOldQuestionSetType($this->object->getQuestionSetType());
3811  $confirmation->setNewQuestionSetType($newQuestionSetType);
3812  $confirmation->setQuestionLossInfoEnabled(false);
3813  $confirmation->build();
3814 
3815  $confirmation->populateParametersFromPost();
3816 
3817  $this->tpl->setContent( $this->ctrl->getHTML($confirmation) );
3818 
3819  return;
3820  }
3821 
3822  if( $questionSetTypeSettingSwitched && $this->object->isOnline() )
3823  {
3824  $this->object->setOnline(false);
3825 
3826  $info = $this->lng->txt("tst_set_offline_due_to_switched_question_set_type_setting");
3827 
3828  ilUtil::sendInfo($info, true);
3829  }
3830 
3831  $this->object->applyDefaults($defaults);
3832 
3833  ilUtil::sendSuccess($this->lng->txt("tst_defaults_applied"), true);
3834 
3835  if( $questionSetTypeSettingSwitched && $oldQuestionSetConfig->doesQuestionSetRelatedDataExist() )
3836  {
3837  $oldQuestionSetConfig->removeQuestionSetRelatedData();
3838  }
3839 
3840  $this->ctrl->redirect($this, 'defaults');
3841  }
3842 
3847  {
3848  if (strlen($_POST["name"]) > 0)
3849  {
3850  $this->object->addDefaults($_POST['name']);
3851  }
3852  else
3853  {
3854  ilUtil::sendInfo($this->lng->txt("tst_defaults_enter_name"));
3855  }
3856  $this->defaultsObject();
3857  }
3858 
3864  function infoScreenObject()
3865  {
3866  $this->ctrl->setCmd("showSummary");
3867  $this->ctrl->setCmdClass("ilinfoscreengui");
3868  $this->infoScreen();
3869  }
3870 
3872  {
3873  $this->ctrl->setCmd("showSummary");
3874  $this->ctrl->setCmdClass("ilinfoscreengui");
3875  $this->infoScreen($_GET['lock']);
3876  }
3877 
3881  function infoScreen($session_lock = "")
3882  {
3888  global $ilAccess, $ilUser, $ilToolbar;
3889 
3890  require_once 'Modules/Test/classes/class.ilTestDynamicQuestionSetFilterSelection.php';
3891 
3892  $testQuestionSetConfig = $this->testQuestionSetConfigFactory->getQuestionSetConfig();
3893  $testSession = $this->testSessionFactory->getSession();
3894  $testSequence = $this->testSequenceFactory->getSequence($testSession);
3895  $testSequence->loadFromDb();
3896  $testSequence->loadQuestions($testQuestionSetConfig, new ilTestDynamicQuestionSetFilterSelection());
3897 
3898  $testPlayerGUI = $this->testPlayerFactory->getPlayerGUI();
3899 
3900  if ($_GET['createRandomSolutions'])
3901  {
3902  $this->object->createRandomSolutions($_GET['createRandomSolutions']);
3903  }
3904 
3905  if (!$ilAccess->checkAccess("read", "", $this->ref_id))
3906  {
3907  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
3908  }
3909 
3910  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
3911  $info = new ilInfoScreenGUI($this);
3912 
3913  $this->ctrl->setParameter($testPlayerGUI, "sequence", $testSession->getLastSequence());
3914 
3915  $info->setFormAction($this->ctrl->getFormAction($testPlayerGUI));
3916 
3917  if (strlen($session_lock))
3918  {
3919  $info->addHiddenElement("lock", $session_lock);
3920  }
3921  else
3922  {
3923  $info->addHiddenElement("lock", md5($_COOKIE['PHPSESSID'] . time()));
3924  }
3925  $online_access = false;
3926  if ($this->object->getFixedParticipants())
3927  {
3928  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
3929  $online_access_result = ilObjTestAccess::_lookupOnlineTestAccess($this->object->getId(), $ilUser->getId());
3930  if ($online_access_result === true)
3931  {
3932  $online_access = true;
3933  }
3934  else
3935  {
3936  ilUtil::sendInfo($online_access_result);
3937  }
3938  }
3939 
3940  $enter_anonymous_code = false;
3941  if( $this->object->isOnline() && $this->object->isComplete( $this->testQuestionSetConfigFactory->getQuestionSetConfig() ) )
3942  {
3943  if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id))
3944  {
3945  $executable = $this->object->isExecutable($testSession, $ilUser->getId(), $allowPassIncrease = TRUE
3946  );
3947  if ($executable["executable"])
3948  {
3949  if( $this->object->areObligationsEnabled() && $this->object->hasObligations($this->object->getTestId()) )
3950  {
3951  ilUtil::sendInfo($GLOBALS['lng']->txt('tst_test_contains_obligatory_questions'));
3952  }
3953 
3954  if ($testSession->getActiveId() > 0)
3955  {
3956  // resume test
3957  require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
3958  $testPassesSelector = new ilTestPassesSelector($GLOBALS['ilDB'], $this->object);
3959  $testPassesSelector->setActiveId($testSession->getActiveId());
3960  $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
3961 
3962  $closedPasses = $testPassesSelector->getClosedPasses();
3963  $existingPasses = $testPassesSelector->getExistingPasses();
3964 
3965  if ($existingPasses > $closedPasses)
3966  {
3967  $resumeTestLabel = $this->lng->txt("tst_resume_test");
3968  $big_button[] = array('resumePlayer', $resumeTestLabel, true);
3969  }
3970  else
3971  {
3972  $resumeTestLabel = $this->object->getStartTestLabel($testSession->getActiveId());
3973  $big_button[] = array('startPlayer', $resumeTestLabel, true);
3974  }
3975  }
3976  else
3977  {
3978  // start new test
3979 
3980  $big_button[] = array("startPlayer", $this->object->getStartTestLabel($testSession->getActiveId()), true);
3981  }
3982  }
3983  else
3984  {
3985  ilUtil::sendInfo($executable["errormessage"]);
3986  }
3987  if ($testSession->getActiveId() > 0)
3988  {
3989  // test results button
3990 
3991  require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
3992  $testPassesSelector = new ilTestPassesSelector($GLOBALS['ilDB'], $this->object);
3993  $testPassesSelector->setActiveId($testSession->getActiveId());
3994  $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
3995 
3996  if ($this->object->canShowTestResults($testSession, $ilUser->getId()) && count($testPassesSelector->getReportablePasses()))
3997  {
3998  //$info->addFormButton("outUserResultsOverview", $this->lng->txt("tst_show_results"));
3999  $big_button[] = array("outUserResultsOverview", $this->lng->txt("tst_show_results"), false);
4000  if ($this->object->getHighscoreEnabled())
4001  {
4002  // Can also compare results then
4003  $big_button[] = array("outResultsToplist", $this->lng->txt("tst_show_toplist"), false);
4004  }
4005  }
4006 
4007  }
4008  }
4009  if ($testSession->getActiveId() > 0)
4010  {
4011  if ($this->object->canShowSolutionPrintview($ilUser->getId()))
4012  {
4013  //$info->addFormButton("outUserListOfAnswerPasses", $this->lng->txt("tst_list_of_answers_show"));
4014  $big_button[] = array("outUserListOfAnswerPasses", $this->lng->txt("tst_list_of_answers_show"), false);
4015  }
4016  }
4017 
4018  if( $this->isDeleteDynamicTestResultsButtonRequired($testSession, $testSequence) )
4019  {
4020  $this->populateDeleteDynamicTestResultsButton($testSession, $big_button);
4021  }
4022 
4023  if($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
4024  {
4025  $enter_anonymous_code = true;
4026  }
4027  }
4028 
4029  if( !$this->object->isOnline() && !$testQuestionSetConfig->areDepenciesBroken() )
4030  {
4031  $message = $this->lng->txt("test_is_offline");
4032 
4033  if($ilAccess->checkAccess("write", "", $this->ref_id))
4034  {
4035  $message .= "<br /><a href=\"".$this->ctrl->getLinkTargetByClass('ilobjtestsettingsgeneralgui')."\">".
4036  $this->lng->txt("test_edit_settings")."</a>";
4037  }
4038 
4039  ilUtil::sendInfo($message);
4040  }
4041 
4042  if( $ilAccess->checkAccess("write", "", $this->ref_id) )
4043  {
4044  $testQuestionSetConfig = $this->testQuestionSetConfigFactory->getQuestionSetConfig();
4045 
4046  if( $testQuestionSetConfig->areDepenciesBroken() )
4047  {
4048  ilUtil::sendFailure( $testQuestionSetConfig->getDepenciesBrokenMessage($this->lng) );
4049 
4050  $big_button = array();
4051  $enter_anonymous_code = false;
4052  }
4053  elseif( $testQuestionSetConfig->areDepenciesInVulnerableState() )
4054  {
4055  ilUtil::sendInfo( $testQuestionSetConfig->getDepenciesInVulnerableStateMessage($this->lng) );
4056  }
4057  }
4058 
4059  if ($this->object->getShowInfo())
4060  {
4061  $info->enablePrivateNotes();
4062  }
4063 
4064  if($big_button || $enter_anonymous_code)
4065  {
4066  $ilToolbar->setFormAction($this->ctrl->getFormAction($testPlayerGUI));
4067 
4068  foreach($big_button as $button)
4069  {
4070  if( isset($button[3]) && strlen($button[3]) )
4071  {
4072  $ilToolbar->addButton($button[1], $button[3], '', '', '', '', $button[2] ? 'submit emphSubmit' : 'submit');
4073  }
4074  else
4075  {
4076  $ilToolbar->addFormButton($button[1], $button[0], "", $button[2]);
4077  }
4078  }
4079 
4080  if($enter_anonymous_code)
4081  {
4082  if($big_button)
4083  {
4084  $ilToolbar->addSeparator();
4085  }
4086 
4087  require_once 'Services/Form/classes/class.ilTextInputGUI.php';
4088  $anonymous_id = new ilTextInputGUI($this->lng->txt('enter_anonymous_code'), 'anonymous_id');
4089  $anonymous_id->setSize(8);
4090  $ilToolbar->addInputItem($anonymous_id, true);
4091  $ilToolbar->addFormButton($this->lng->txt('submit'), 'setAnonymousId');
4092  }
4093 
4094  $ilToolbar->setCloseFormTag(false);
4095  $info->setOpenFormTag(false);
4096  }
4097 
4098  if (strlen($this->object->getIntroduction()))
4099  {
4100  $info->addSection($this->lng->txt("tst_introduction"));
4101  $info->addProperty("", $this->object->prepareTextareaOutput($this->object->getIntroduction(), true).
4102  $info->getHiddenToggleButton());
4103  }
4104  else
4105  {
4106  $info->addSection("");
4107  $info->addProperty("", $info->getHiddenToggleButton());
4108  }
4109 
4110  $info->addSection($this->lng->txt("tst_general_properties"));
4111  if ($this->object->getShowInfo())
4112  {
4113  $info->addProperty($this->lng->txt("author"), $this->object->getAuthor());
4114  $info->addProperty($this->lng->txt("title"), $this->object->getTitle());
4115  }
4116  if( $this->object->isOnline() && $this->object->isComplete( $this->testQuestionSetConfigFactory->getQuestionSetConfig() ) )
4117  {
4118  if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id))
4119  {
4120  if ($this->object->getShowInfo() || !$this->object->getForceJS())
4121  {
4122  // use javascript
4123  $checked_javascript = false;
4124  if ($this->object->getJavaScriptOutput())
4125  {
4126  $checked_javascript = true;
4127  }
4128  if ($this->object->getForceJS())
4129  {
4130  $info->addProperty($this->lng->txt("tst_test_output"), $this->lng->txt("tst_use_javascript"));
4131  }
4132  else
4133  {
4134  $info->addPropertyCheckbox($this->lng->txt("tst_test_output"), "chb_javascript", 1, $this->lng->txt("tst_use_javascript"), $checked_javascript);
4135  }
4136  }
4137  // hide previous results
4138  if( !$this->object->isRandomTest() )
4139  {
4140  if ($this->object->getNrOfTries() != 1)
4141  {
4142  if ($this->object->getUsePreviousAnswers() == 0)
4143  {
4144  if ($this->object->getShowInfo())
4145  {
4146  $info->addProperty($this->lng->txt("tst_use_previous_answers"), $this->lng->txt("tst_dont_use_previous_answers"));
4147  }
4148  }
4149  else
4150  {
4151  $use_previous_answers = FALSE;
4152  if ($ilUser->prefs["tst_use_previous_answers"])
4153  {
4154  $checked_previous_answers = TRUE;
4155  }
4156  $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);
4157  }
4158  }
4159  }
4160  }
4161  }
4162 
4163  $info->hideFurtherSections(false);
4164 
4165  if ($this->object->getShowInfo())
4166  {
4167  $info->addSection($this->lng->txt("tst_sequence_properties"));
4168  $info->addProperty($this->lng->txt("tst_sequence"), $this->lng->txt(($this->object->getSequenceSettings() == TEST_FIXED_SEQUENCE)? "tst_sequence_fixed":"tst_sequence_postpone"));
4169 
4170  $info->addSection($this->lng->txt("tst_heading_scoring"));
4171  $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"));
4172  $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"));
4173  if ($this->object->isRandomTest())
4174  {
4175  $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"));
4176  }
4177 
4178  $info->addSection($this->lng->txt("tst_score_reporting"));
4179  $score_reporting_text = "";
4180  switch ($this->object->getScoreReporting())
4181  {
4182  case REPORT_AFTER_TEST:
4183  $score_reporting_text = $this->lng->txt("tst_report_after_test");
4184  break;
4185  case REPORT_ALWAYS:
4186  $score_reporting_text = $this->lng->txt("tst_report_after_first_question");
4187  break;
4188  case REPORT_AFTER_DATE:
4189  $score_reporting_text = $this->lng->txt("tst_report_after_date");
4190  break;
4191  case 4:
4192  $score_reporting_text = $this->lng->txt("tst_report_never");
4193  break;
4194  }
4195  $info->addProperty($this->lng->txt("tst_score_reporting"), $score_reporting_text);
4196  $reporting_date = $this->object->getReportingDate();
4197  if ($reporting_date)
4198  {
4199  #preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $reporting_date, $matches);
4200  #$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]));
4201  #$info->addProperty($this->lng->txt("tst_score_reporting_date"), $txt_reporting_date);
4202  $info->addProperty($this->lng->txt('tst_score_reporting_date'),
4204  }
4205 
4206  $info->addSection($this->lng->txt("tst_session_settings"));
4207  $info->addProperty($this->lng->txt("tst_nr_of_tries"), ($this->object->getNrOfTries() == 0)?$this->lng->txt("unlimited"):$this->object->getNrOfTries());
4208  if ($this->object->getNrOfTries() != 1)
4209  {
4210  $info->addProperty($this->lng->txt("tst_nr_of_tries_of_user"), ($testSession->getPass() == false)?$this->lng->txt("tst_no_tries"):$testSession->getPass());
4211  }
4212 
4213  if ($this->object->getEnableProcessingTime())
4214  {
4215  $info->addProperty($this->lng->txt("tst_processing_time"), $this->object->getProcessingTime());
4216  }
4217  if (strlen($this->object->getAllowedUsers()) && ($this->object->getAllowedUsersTimeGap()))
4218  {
4219  $info->addProperty($this->lng->txt("tst_allowed_users"), $this->object->getAllowedUsers());
4220  }
4221 
4222  $starting_time = $this->object->getStartingTime();
4223  if ($starting_time)
4224  {
4225  $info->addProperty($this->lng->txt("tst_starting_time"),
4227  }
4228  $ending_time = $this->object->getEndingTime();
4229  if ($ending_time)
4230  {
4231  $info->addProperty($this->lng->txt("tst_ending_time"),
4233  }
4234  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
4235  // forward the command
4236  }
4237 
4238  $this->ctrl->forwardCommand($info);
4239  }
4240 
4241  function addLocatorItems()
4242  {
4243  global $ilLocator;
4244  switch ($this->ctrl->getCmd())
4245  {
4246  case "run":
4247  case "infoScreen":
4248  case "redirectToInfoScreen":
4249  case "start":
4250  case "resume":
4251  case "previous":
4252  case "next":
4253  case "summary":
4254  case "finishTest":
4255  case "outCorrectSolution":
4256  case "passDetails":
4257  case "showAnswersOfUser":
4258  case "outUserResultsOverview":
4259  case "backFromSummary":
4260  case "show_answers":
4261  case "setsolved":
4262  case "resetsolved":
4263  case "outTestSummary":
4264  case "outQuestionSummary":
4265  case "gotoQuestion":
4266  case "selectImagemapRegion":
4267  case "confirmSubmitAnswers":
4268  case "finalSubmission":
4269  case "postpone":
4270  case "redirectQuestion":
4271  case "outUserPassDetails":
4272  case "checkPassword":
4273  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"), "", $_GET["ref_id"]);
4274  break;
4275  case "eval_stat":
4276  case "evalAllUsers":
4277  case "evalUserDetail":
4278  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "eval_stat"), "", $_GET["ref_id"]);
4279  break;
4280  case "create":
4281  case "save":
4282  case "cancel":
4283  case "importFile":
4284  case "cloneAll":
4285  case "importVerifiedFile":
4286  case "cancelImport":
4287  break;
4288  default:
4289  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
4290  break;
4291  }
4292  }
4293 
4294  function getBrowseForQuestionsTab(&$tabs_gui)
4295  {
4296  global $ilAccess;
4297  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4298  {
4299  $this->ctrl->saveParameterByClass($this->ctrl->getCmdClass(), 'q_id');
4300  // edit page
4301  $tabs_gui->setBackTarget($this->lng->txt("backtocallingtest"), $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), "questions"));
4302  $tabs_gui->addTarget("tst_browse_for_questions",
4303  $this->ctrl->getLinkTarget($this, "browseForQuestions"),
4304  array("browseForQuestions", "filter", "resetFilter", "resetTextFilter", "insertQuestions"),
4305  "", "", TRUE
4306  );
4307  }
4308  }
4309 
4310  function getRandomQuestionsTab(&$tabs_gui)
4311  {
4312  global $ilAccess;
4313  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4314  {
4315  // edit page
4316  $tabs_gui->setBackTarget($this->lng->txt("backtocallingtest"), $this->ctrl->getLinkTarget($this, "questions"));
4317  $tabs_gui->addTarget("random_selection",
4318  $this->ctrl->getLinkTarget($this, "randomQuestions"),
4319  array("randomQuestions"),
4320  "", ""
4321  );
4322  }
4323  }
4324 
4325  function statisticsObject()
4326  {
4327  }
4328 
4333  {
4334  include_once "./Services/Certificate/classes/class.ilCertificateGUI.php";
4335  include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
4336  $output_gui = new ilCertificateGUI(new ilTestCertificateAdapter($this->object));
4337  $output_gui->certificateEditor();
4338  }
4339 
4341  {
4342  global $ilTabs, $ilCtrl;
4343  $ilTabs->activateTab('assQuestions');
4344  $a_cmd = $ilCtrl->getCmd();
4345 
4346  if (!$this->object->isRandomTest())
4347  {
4348  #if (in_array($this->object->getEnabledViewMode(), array('both', 'express'))) {
4349  $questions_per_page = ($a_cmd == 'questions_per_page' || ($a_cmd == 'removeQuestions' && $_REQUEST['test_express_mode'])) ? true : false;
4350 
4351  $this->tabs_gui->addSubTabTarget(
4352  "questions_per_page_view",
4353  $this->ctrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'showPage'),
4354  "", "", "", $questions_per_page);
4355  #}
4356  }
4357  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
4358  $template = new ilSettingsTemplate($this->object->getTemplate(), ilObjAssessmentFolderGUI::getSettingsTemplateConfig());
4359 
4360  if (!in_array('questions', $template->getHiddenTabs())) {
4361  // questions subtab
4362  $ilTabs->addSubTabTarget("edit_test_questions",
4363  $this->ctrl->getLinkTarget($this,'questions'),
4364  array("questions", "browseForQuestions", "questionBrowser", "createQuestion",
4365  "randomselect", "filter", "resetFilter", "insertQuestions",
4366  "back", "createRandomSelection", "cancelRandomSelect",
4367  "insertRandomSelection", "removeQuestions", "moveQuestions",
4368  "insertQuestionsBefore", "insertQuestionsAfter", "confirmRemoveQuestions",
4369  "cancelRemoveQuestions", "executeCreateQuestion", "cancelCreateQuestion",
4370  "addQuestionpool", "saveRandomQuestions", "saveQuestionSelectionMode"),
4371  "");
4372 
4373  if (in_array($a_cmd, array('questions', 'createQuestion')) || ($a_cmd == 'removeQuestions' && !$_REQUEST['test_express_mode']))
4374  $this->tabs_gui->activateSubTab('edit_test_questions');
4375  }
4376  #}
4377 
4378  // print view subtab
4379  if (!$this->object->isRandomTest())
4380  {
4381  $ilTabs->addSubTabTarget("print_view",
4382  $this->ctrl->getLinkTarget($this,'print'),
4383  "print", "", "", $this->ctrl->getCmd() == 'print');
4384  $ilTabs->addSubTabTarget('review_view',
4385  $this->ctrl->getLinkTarget($this, 'review'),
4386  'review', '', '', $this->ctrl->getCmd() == 'review');
4387  }
4388 
4389 
4390  }
4391 
4393  {
4394  global $ilTabs;
4395 
4396  // user results subtab
4397  $ilTabs->addSubTabTarget("eval_all_users",
4398  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "outEvaluation"),
4399  array("outEvaluation", "detailedEvaluation", "exportEvaluation", "evalUserDetail", "passDetails",
4400  "outStatisticsResultsOverview", "statisticsPassDetails")
4401  , "");
4402 
4403  // aggregated results subtab
4404  $ilTabs->addSubTabTarget("tst_results_aggregated",
4405  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "eval_a"),
4406  array("eval_a"),
4407  "", "");
4408 
4409  // question export
4410  $ilTabs->addSubTabTarget("tst_single_results",
4411  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "singleResults"),
4412  array("singleResults"),
4413  "", "");
4414  }
4415 
4416  function getSettingsSubTabs($hiddenTabs = array())
4417  {
4418  global $ilTabs, $ilias;
4419 
4420  // general subtab
4421  $ilTabs->addSubTabTarget('general', $this->ctrl->getLinkTargetByClass('ilObjTestSettingsGeneralGUI'),
4422  '', // auto activation regardless from cmd
4423  array('ilobjtestsettingsgeneralgui') // auto activation for ilObjTestSettingsGeneralGUI
4424  );
4425 
4426  if (!in_array('mark_schema', $hiddenTabs)) {
4427  // mark schema subtab
4428  $ilTabs->addSubTabTarget(
4429  "mark_schema",
4430  $this->ctrl->getLinkTarget($this,'marks'),
4431  array("marks", "addMarkStep", "deleteMarkSteps", "addSimpleMarkSchema",
4432  "saveMarks", "cancelMarks"),
4433  array("", "ilobjtestgui", "ilcertificategui")
4434  );
4435  }
4436 
4437  // scoring subtab
4438  $ilTabs->addSubTabTarget(
4439  "scoring",
4440  $this->ctrl->getLinkTarget($this,'scoring'),
4441  array("scoring"),
4442  array("", "ilobjtestgui", "ilcertificategui")
4443  );
4444 
4445  // certificate subtab
4446  include_once "Services/Certificate/classes/class.ilCertificate.php";
4448  {
4449  $ilTabs->addSubTabTarget(
4450  "certificate",
4451  $this->ctrl->getLinkTarget($this,'certificate'),
4452  array("certificate", "certificateEditor", "certificateRemoveBackground", "certificateSave",
4453  "certificatePreview", "certificateDelete", "certificateUpload", "certificateImport"),
4454  array("", "ilobjtestgui", "ilcertificategui")
4455  );
4456  }
4457 
4458  if (!in_array('defaults', $hiddenTabs)) {
4459  // defaults subtab
4460  $ilTabs->addSubTabTarget(
4461  "tst_default_settings",
4462  $this->ctrl->getLinkTarget($this, "defaults"),
4463  array("defaults", "deleteDefaults", "addDefaults", "applyDefaults"),
4464  array("", "ilobjtestgui", "ilcertificategui")
4465  );
4466  }
4467  }
4468 
4470  {
4471  global $ilTabs;
4472 
4473  // participants subtab
4474  $ilTabs->addSubTabTarget( "participants",
4475  $this->ctrl->getLinkTarget($this,'participants'),
4476  array(
4477  "participants", "saveClientIP",
4478  "removeParticipant",
4479  "showParticipantAnswersForAuthor",
4480  "deleteAllUserResults",
4481  "cancelDeleteAllUserData", "deleteSingleUserResults",
4482  "outParticipantsResultsOverview", "outParticipantsPassDetails",
4483  "showPassOverview", "showUserAnswers", "participantsAction",
4484  "showDetailedResults",
4485  'npResetFilter', 'npSetFilter'
4486  ),
4487  ""
4488  );
4489 
4490  if( !$this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken() )
4491  {
4492  if($this->object->getProcessingTimeInSeconds() > 0 && $this->object->getNrOfTries() == 1)
4493  {
4494  // extratime subtab
4495  $ilTabs->addSubTabTarget( "timing",
4496  $this->ctrl->getLinkTarget($this,'timingOverview'),
4497  array("timing", "timingOverview"), "", ""
4498  );
4499  }
4500  }
4501  }
4502 
4508  function getTabs(&$tabs_gui)
4509  {
4510  global $ilAccess, $ilUser, $ilHelp;
4511 
4512  if (preg_match('/^ass(.*?)gui$/i', $this->ctrl->getNextClass($this))) {
4513  return;
4514  }
4515  else if ($this->ctrl->getNextClass($this) == 'ilassquestionpagegui') {
4516  return;
4517  }
4518 
4519  $ilHelp->setScreenIdComponent("tst");
4520 
4521  $hidden_tabs = array();
4522 
4523  $template = $this->object->getTemplate();
4524  if($template)
4525  {
4526  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
4528 
4529  $hidden_tabs = $template->getHiddenTabs();
4530  }
4531 
4532  // for local use in this fucking sledge hammer method
4533  $curUserHasWriteAccess = $ilAccess->checkAccess("write", "", $this->ref_id);
4534 
4535  switch( $this->ctrl->getCmdClass() )
4536  {
4537  case 'iltestoutputgui':
4538 
4539  return; // no tabs .. no subtabs .. during test pass
4540 
4541  case 'ilobjtestsettingsgeneralgui':
4542 
4543  if( $curUserHasWriteAccess )
4544  {
4545  $this->getSettingsSubTabs($hidden_tabs);
4546  }
4547 
4548  break;
4549  }
4550 
4551  switch ($this->ctrl->getCmd())
4552  {
4553  case "resume":
4554  case "previous":
4555  case "next":
4556  case "summary":
4557  case "directfeedback":
4558  case "finishTest":
4559  case "outCorrectSolution":
4560  case "passDetails":
4561  case "showAnswersOfUser":
4562  case "outUserResultsOverview":
4563  case "backFromSummary":
4564  case "show_answers":
4565  case "setsolved":
4566  case "resetsolved":
4567  case "confirmFinish":
4568  case "outTestSummary":
4569  case "outQuestionSummary":
4570  case "gotoQuestion":
4571  case "selectImagemapRegion":
4572  case "confirmSubmitAnswers":
4573  case "finalSubmission":
4574  case "postpone":
4575  case "redirectQuestion":
4576  case "outUserPassDetails":
4577  case "checkPassword":
4578  case "exportCertificate":
4579  case "finishListOfAnswers":
4580  case "backConfirmFinish":
4581  case "showFinalStatement":
4582  return;
4583  break;
4584  case "browseForQuestions":
4585  case "filter":
4586  case "resetFilter":
4587  case "resetTextFilter":
4588  case "insertQuestions":
4589  // #8497: resetfilter is also used in lp
4590  if($this->ctrl->getNextClass($this) != "illearningprogressgui")
4591  {
4592  return $this->getBrowseForQuestionsTab($tabs_gui);
4593  }
4594  break;
4595  case "scoring":
4596  case "marks":
4597  case "saveMarks":
4598  case "cancelMarks":
4599  case "addMarkStep":
4600  case "deleteMarkSteps":
4601  case "addSimpleMarkSchema":
4602  case "certificate":
4603  case "certificateservice":
4604  case "certificateImport":
4605  case "certificateUpload":
4606  case "certificateEditor":
4607  case "certificateDelete":
4608  case "certificateSave":
4609  case "defaults":
4610  case "deleteDefaults":
4611  case "addDefaults":
4612  case "applyDefaults":
4613  case "inviteParticipants":
4614  case "searchParticipants":
4615  if( $curUserHasWriteAccess && in_array($this->ctrl->getCmdClass(), array('ilobjtestgui', 'ilcertificategui')) )
4616  {
4617  $this->getSettingsSubTabs($hidden_tabs);
4618  }
4619  break;
4620  case "export":
4621  case "print":
4622  break;
4623  case "statistics":
4624  case "eval_a":
4625  case "detailedEvaluation":
4626  case "outEvaluation":
4627  case "singleResults":
4628  case "exportEvaluation":
4629  case "evalUserDetail":
4630  case "passDetails":
4631  case "outStatisticsResultsOverview":
4632  case "statisticsPassDetails":
4633  $this->getStatisticsSubTabs();
4634  break;
4635  }
4636 
4637  if (strcmp(strtolower(get_class($this->object)), "ilobjtest") == 0)
4638  {
4639  // questions tab
4640  if ($ilAccess->checkAccess("write", "", $this->ref_id) && !in_array('assQuestions', $hidden_tabs))
4641  {
4642  $force_active = ($_GET["up"] != "" || $_GET["down"] != "")
4643  ? true
4644  : false;
4645  if (!$force_active)
4646  {
4647  if ($_GET["browse"] == 1) $force_active = true;
4648  }
4649 
4650  switch( $this->object->getQuestionSetType() )
4651  {
4653  $target = $this->ctrl->getLinkTargetByClass('iltestexpresspageobjectgui','showPage');
4654  break;
4655 
4657  $target = $this->ctrl->getLinkTargetByClass('ilTestRandomQuestionSetConfigGUI');
4658  break;
4659 
4661  $target = $this->ctrl->getLinkTargetByClass('ilObjTestDynamicQuestionSetConfigGUI');
4662  break;
4663  }
4664 
4665  $tabs_gui->addTarget("assQuestions",
4666  //$this->ctrl->getLinkTarget($this,'questions'),
4667  $target,
4668  array("questions", "browseForQuestions", "questionBrowser", "createQuestion",
4669  "randomselect", "filter", "resetFilter", "insertQuestions",
4670  "back", "createRandomSelection", "cancelRandomSelect",
4671  "insertRandomSelection", "removeQuestions", "moveQuestions",
4672  "insertQuestionsBefore", "insertQuestionsAfter", "confirmRemoveQuestions",
4673  "cancelRemoveQuestions", "executeCreateQuestion", "cancelCreateQuestion",
4674  "addQuestionpool", "saveRandomQuestions", "saveQuestionSelectionMode", "print",
4675  "addsource", "removesource", "randomQuestions"),
4676  "", "", $force_active);
4677  }
4678 
4679  // info tab
4680  if ($ilAccess->checkAccess("read", "", $this->ref_id) && !in_array('info_short', $hidden_tabs))
4681  {
4682  $tabs_gui->addTarget("info_short",
4683  $this->ctrl->getLinkTarget($this,'infoScreen'),
4684  array("infoScreen", "outIntroductionPage", "showSummary",
4685  "setAnonymousId", "outUserListOfAnswerPasses", "redirectToInfoScreen"));
4686  }
4687 
4688  // settings tab
4689  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4690  {
4691  if (!in_array('settings', $hidden_tabs))
4692  {
4693  $settingsCommands = array(
4694  "marks", "addMarkStep", "deleteMarkSteps", "addSimpleMarkSchema", "saveMarks", "cancelMarks",
4695  "certificate", "certificateEditor", "certificateRemoveBackground", "certificateSave",
4696  "certificatePreview", "certificateDelete", "certificateUpload", "certificateImport",
4697  "scoring", "defaults", "addDefaults", "deleteDefaults", "applyDefaults",
4698  "inviteParticipants", "saveFixedParticipantsStatus", "searchParticipants", "addParticipants" // ARE THEY RIGHT HERE
4699  );
4700 
4701  require_once 'Modules/Test/classes/class.ilObjTestSettingsGeneralGUI.php';
4702  $reflection = new ReflectionClass('ilObjTestSettingsGeneralGUI');
4703  foreach($reflection->getConstants() as $name => $value)
4704  if(substr($name, 0, 4) == 'CMD_') $settingsCommands[] = $value;
4705 
4706  $settingsCommands[] = ""; // DO NOT KNOW WHAT THIS IS DOING, BUT IT'S REQUIRED
4707 
4708  $tabs_gui->addTarget("settings",
4709  $this->ctrl->getLinkTargetByClass('ilObjTestSettingsGeneralGUI'),
4710  $settingsCommands, array("ilobjtestsettingsgeneralgui", "ilobjtestgui", "ilcertificategui")
4711  );
4712  }
4713 
4714  if (!in_array('participants', $hidden_tabs))
4715  {
4716  // participants
4717  $tabs_gui->addTarget("participants",
4718  $this->ctrl->getLinkTarget($this,'participants'),
4719  array(
4720  "participants", "saveClientIP",
4721  "removeParticipant",
4722  "showParticipantAnswersForAuthor",
4723  "deleteAllUserResults",
4724  "cancelDeleteAllUserData", "deleteSingleUserResults",
4725  "outParticipantsResultsOverview", "outParticipantsPassDetails",
4726  "showPassOverview", "showUserAnswers", "participantsAction",
4727  "showDetailedResults",
4728  'timing', 'timingOverview', 'npResetFilter', 'npSetFilter', 'showTimingForm'
4729  ),
4730  ""
4731  );
4732  }
4733  }
4734 
4735  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
4736  if(ilLearningProgressAccess::checkAccess($this->object->getRefId()) && !in_array('learning_progress', $hidden_tabs))
4737  {
4738  $tabs_gui->addTarget('learning_progress',
4739  $this->ctrl->getLinkTargetByClass(array('illearningprogressgui'),''),
4740  '',
4741  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui'));
4742  }
4743 
4744  if ($ilAccess->checkAccess("write", "", $this->ref_id) && !in_array('manscoring', $hidden_tabs))
4745  {
4746  include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
4748  if (count($scoring))
4749  {
4750  // scoring tab
4751  $tabs_gui->addTarget(
4752  "manscoring", $this->ctrl->getLinkTargetByClass('ilTestScoringGUI', 'showManScoringParticipantsTable'),
4753  array(
4754  'showManScoringParticipantsTable', 'applyManScoringParticipantsFilter', 'resetManScoringParticipantsFilter', 'showManScoringParticipantScreen',
4755  'showManScoringByQuestionParticipantsTable', 'applyManScoringByQuestionFilter', 'resetManScoringByQuestionFilter', 'saveManScoringByQuestion'
4756 
4757  ), ''
4758  );
4759  }
4760  }
4761 
4762  // Scoring Adjustment
4763  $setting = new ilSetting('assessment');
4764  $scoring_adjust_active = (bool) $setting->get('assessment_adjustments_enabled', false);
4765  if ($ilAccess->checkAccess("write", "", $this->ref_id) && $scoring_adjust_active && !in_array('scoringadjust', $hidden_tabs))
4766  {
4767  // scoring tab
4768  $tabs_gui->addTarget(
4769  "scoringadjust", $this->ctrl->getLinkTargetByClass('ilScoringAdjustmentGUI', 'showquestionlist'),
4770  array(
4771  'showquestionlist',
4772  'applyManScoringParticipantsFilter',
4773  'saveManScoringByQuestion'
4774  ), ''
4775  );
4776  }
4777 
4778  if ((($ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) || ($ilAccess->checkAccess("write", "", $this->ref_id))) && !in_array('statistics', $hidden_tabs))
4779  {
4780  // statistics tab
4781  $tabs_gui->addTarget("statistics",
4782  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "outEvaluation"),
4783  array("statistics", "outEvaluation", "exportEvaluation", "detailedEvaluation", "eval_a", "evalUserDetail",
4784  "passDetails", "outStatisticsResultsOverview", "statisticsPassDetails", "singleResults")
4785  , "");
4786  }
4787 
4788  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4789  {
4790  if (!in_array('history', $hidden_tabs)) {
4791 
4792  // history
4793  $tabs_gui->addTarget("history",
4794  $this->ctrl->getLinkTarget($this,'history'),
4795  "history", "");
4796  }
4797 
4798  if (!in_array('meta_data', $hidden_tabs)) {
4799  // meta data
4800  $tabs_gui->addTarget("meta_data",
4801  $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'),
4802  "", "ilmdeditorgui");
4803  }
4804 
4805  if(!in_array('export', $hidden_tabs))
4806  {
4807  // export tab
4808  $tabs_gui->addTarget(
4809  "export",
4810  $this->ctrl->getLinkTargetByClass('iltestexportgui' ,''),
4811  '',
4812  array('iltestexportgui')
4813  );
4814  }
4815  }
4816 
4817  if ($ilAccess->checkAccess("edit_permission", "", $this->ref_id)&& !in_array('permissions', $hidden_tabs))
4818  {
4819  $tabs_gui->addTarget("perm_settings",
4820  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
4821  }
4822  }
4823 
4824  if( $this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken() )
4825  {
4826  $hideTabs = $this->testQuestionSetConfigFactory->getQuestionSetConfig()->getHiddenTabsOnBrokenDepencies();
4827 
4828  foreach($hideTabs as $tabId)
4829  {
4830  $tabs_gui->removeTab($tabId);
4831  }
4832  }
4833  }
4834 
4843  function _goto($a_target)
4844  {
4845  global $ilAccess, $ilErr, $lng;
4846 
4847  if ($ilAccess->checkAccess("read", "", $a_target))
4848  {
4849  //include_once "./Services/Utilities/classes/class.ilUtil.php";
4850  $_GET["baseClass"] = "ilObjTestGUI";
4851  $_GET["cmd"] = "infoScreen";
4852  $_GET["ref_id"] = $a_target;
4853  include_once("ilias.php");
4854  exit;
4855  //ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=infoScreen&ref_id=$a_target");
4856  }
4857  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
4858  {
4859  ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
4860  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
4862  }
4863 
4864  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
4865  }
4866 
4873  function buildPageViewToolbar($qid = 0)
4874  {
4875  if($this->create_question_mode)
4876  return;
4877 
4878  global $ilToolbar, $ilCtrl, $lng;
4879 
4880  $this->getQuestionsSubTabs();
4881 
4882  $ilCtrl->saveParameter($this, 'q_mode');
4883 
4884  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'test_express_mode', 1);
4885  $ilCtrl->setParameter($this, 'test_express_mode', 1);
4886  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'q_id', $_REQUEST['q_id']);
4887  $ilCtrl->setParameter($this, 'q_id', $_REQUEST['q_id']);
4888  $ilToolbar->setFormAction($ilCtrl->getFormActionByClass('iltestexpresspageobjectgui', 'edit'));
4889 
4890  if($this->object->evalTotalPersons() == 0)
4891  {
4892  /*
4893  include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
4894  $pool = new ilObjQuestionPool();
4895  $questionTypes = $pool->getQuestionTypes();$options = array();
4896  foreach($questionTypes as $label => $data) {
4897  $options[$data['question_type_id']] = $label;
4898  }
4899 
4900  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
4901  $si = new ilSelectInputGUI($lng->txt("test_add_new_question"), "qtype");
4902  $si->setOptions($options);
4903  $ilToolbar->addInputItem($si, true);
4904  /*
4905  // use pool
4906  if ($this->object->isExpressModeQuestionPoolAllowed()) {
4907  include_once("./Services/Form/classes/class.ilCheckboxInputGUI.php");
4908  $cb = new ilCheckboxInputGUI($lng->txt("test_use_pool"), "use_pool");
4909  $ilToolbar->addInputItem($cb, true);
4910  }
4911  */
4912  $ilToolbar->addFormButton($lng->txt("ass_create_question"), "addQuestion");
4913 
4914  $ilToolbar->addSeparator();
4915 
4916  if($this->object->getPoolUsage())
4917  {
4918  $ilToolbar->addFormButton($lng->txt("tst_browse_for_questions"), "browseForQuestions");
4919 
4920  $show_separator = true;
4921  }
4922  }
4923 
4924  $questions = $this->object->getQuestionTitlesAndIndexes();
4925 
4926  // desc
4927  $options = array();
4928  foreach($questions as $id => $label)
4929  {
4930  $options[$id] = $label . ' ['. $this->lng->txt('question_id_short') . ': ' . $id . ']';
4931  }
4932 
4933  $optionKeys = array_keys($options);
4934 
4935  if(!$options)
4936  {
4937  $options[] = $lng->txt('none');
4938  }
4939  //else if (count($options) > 1) {
4940 // $addSeparator = false;
4941 // if ($optionKeys[0] != $qid) {
4942 // //$ilToolbar->addFormButton($lng->txt("test_prev_question"), "prevQuestion");
4943 // $ilToolbar->addLink($lng->txt("test_prev_question"), $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'prevQuestion'));
4944 // $addSeparator = true;
4945 // }
4946 // else {
4947 // $ilToolbar->addSpacer(45);
4948 // }
4949 //
4950 // if ($optionKeys[count($optionKeys)-1] != $qid) {
4951 // //$ilToolbar->addFormButton($lng->txt("test_next_question"), "nextQuestion");
4952 // $ilToolbar->addLink($lng->txt("test_next_question"), $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'nextQuestion'));
4953 // $addSeparator = true;
4954 // }
4955 // else {
4956 // $ilToolbar->addSpacer(45);
4957 // }
4958 //
4959 // //if ($addSeparator) {
4960 // $ilToolbar->addSeparator();
4961 // //}
4962 
4963  if(count($questions))
4964  {
4965  if(isset($show_separator) && $show_separator)
4966  {
4967  $ilToolbar->addSeparator();
4968  }
4969 
4970  $ilToolbar->addLink($lng->txt("test_prev_question"), $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'prevQuestion'), !(count($options) > 1 && $optionKeys[0] != $qid));
4971  $ilToolbar->addLink($lng->txt("test_next_question"), $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'nextQuestion'), !(count($options) > 1 && $optionKeys[count($optionKeys) - 1] != $qid));
4972  }
4973 
4974  if(count($questions) > 1)
4975  {
4976 
4977  $ilToolbar->addSeparator();
4978 
4979  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
4980  $si = new ilSelectInputGUI($lng->txt("test_jump_to"), "q_id");
4981  $si->addCustomAttribute("onChange=\"forms['ilToolbar'].submit();\"");
4982  $si->setOptions($options);
4983 
4984  if($qid)
4985  {
4986  $si->setValue($qid);
4987  }
4988 
4989  $ilToolbar->addInputItem($si, true);
4990  }
4991 
4992  $total = $this->object->evalTotalPersons();
4993 
4994  /*if (count($options)) {
4995  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
4996  $si = new ilSelectInputGUI($lng->txt("test_jump_to"), "q_id");
4997  $si->addCustomAttribute("onChange=\"forms['ilToolbar'].submit();\"");
4998  $si->setOptions($options);
4999 
5000  if ($qid) {
5001  $si->setValue($qid);
5002  }
5003 
5004  $ilToolbar->addInputItem($si, true);
5005  }*/
5006 
5007  if(count($questions) && !$total)
5008  {
5009  $ilCtrl->setParameter($this, 'q_id', $_REQUEST['q_id']);
5010  $ilToolbar->addSeparator();
5011  $ilToolbar->addButton($lng->txt("test_delete_page"), $ilCtrl->getLinkTarget($this, "removeQuestions"));
5012  }
5013 
5014  if(count($questions) > 1 && !$total)
5015  {
5016  $ilToolbar->addSeparator();
5017  $ilToolbar->addButton($lng->txt("test_move_page"), $ilCtrl->getLinkTarget($this, "movePageForm"));
5018  }
5019 
5020  global $ilAccess, $ilUser;
5021 
5022  $online_access = false;
5023  if($this->object->getFixedParticipants())
5024  {
5025  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
5026  $online_access_result = ilObjTestAccess::_lookupOnlineTestAccess($this->object->getId(), $ilUser->getId());
5027  if($online_access_result === true)
5028  {
5029  $online_access = true;
5030  }
5031  }
5032 
5033  if($this->object->isOnline() && $this->object->isComplete( $this->testQuestionSetConfigFactory->getQuestionSetConfig() ))
5034  {
5035  if((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id))
5036  {
5037  $testSession = $this->testSessionFactory->getSession();
5038 
5039  $executable = $this->object->isExecutable($testSession, $ilUser->getId(), $allowPassIncrease = TRUE);
5040 
5041  if($executable["executable"])
5042  {
5043  $player_factory = new ilTestPlayerFactory($this->object);
5044  $player_instance = $player_factory->getPlayerGUI();
5045 
5046  if ($testSession->getActiveId() > 0)
5047  {
5048  $ilToolbar->addSeparator();
5049  $ilToolbar->addButton($lng->txt('tst_resume_test'), $ilCtrl->getLinkTarget($player_instance, 'resumePlayer'));
5050  }
5051  else
5052  {
5053  $ilToolbar->addSeparator();
5054  $ilToolbar->addButton($lng->txt('tst_start_test'), $ilCtrl->getLinkTarget($player_instance, 'startTest'));
5055  }
5056  }
5057  }
5058  }
5059  }
5060 
5061  public function copyQuestionsToPoolObject()
5062  {
5063  $this->copyQuestionsToPool($_REQUEST['q_id'], $_REQUEST['sel_qpl']);
5064  $this->backObject();
5065  }
5066 
5067  public function copyQuestionsToPool($questionIds, $qplId)
5068  {
5069  $newIds = array();
5070  foreach($questionIds as $q_id)
5071  {
5072  $newId = $this->copyQuestionToPool($q_id, $qplId);
5073  $newIds[$q_id] = $newId;
5074  }
5075 
5076  $result = new stdClass();
5077  $result->ids = $newIds;
5078  $result->qpoolid = $qplId;
5079 
5080  return $result;
5081  }
5082 
5083  public function copyQuestionToPool($sourceQuestionId, $targetParentId)
5084  {
5085  require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
5086  $question_gui = assQuestion::instantiateQuestionGUI($sourceQuestionId);
5087 
5088  $newtitle = $question_gui->object->getTitle();
5089  if ($question_gui->object->questionTitleExists($targetParentId, $question_gui->object->getTitle()))
5090  {
5091  $counter = 2;
5092  while ($question_gui->object->questionTitleExists($targetParentId, $question_gui->object->getTitle() . " ($counter)"))
5093  {
5094  $counter++;
5095  }
5096  $newtitle = $question_gui->object->getTitle() . " ($counter)";
5097  }
5098 
5099  return $question_gui->object->createNewOriginalFromThisDuplicate($targetParentId, $newtitle);
5100  }
5101 
5106  {
5107  global $ilObjDataCache;
5108 
5109  $qplId = $ilObjDataCache->lookupObjId($_REQUEST['sel_qpl']);
5110  $result = $this->copyQuestionsToPool($_REQUEST['q_id'], $qplId);
5111 
5112  foreach($result->ids as $oldId => $newId)
5113  {
5114  $questionInstance = assQuestion::_instanciateQuestion($oldId);
5115 
5116  if( assQuestion::originalQuestionExists($questionInstance->getOriginalId()) )
5117  {
5118  $oldOriginal = assQuestion::_instanciateQuestion($questionInstance->getOriginalId());
5119  $oldOriginal->delete($oldOriginal->getId());
5120  }
5121 
5122  $questionInstance->setNewOriginalId($newId);
5123  }
5124 
5125  $this->backObject();
5126  }
5127 
5128  private function getQuestionpoolCreationForm()
5129  {
5130  global $lng;
5131  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
5132  $form = new ilPropertyFormGUI();
5133 
5134  $title = new ilTextInputGUI($lng->txt('title'), 'title');
5135  $title->setRequired(true);
5136  $form->addItem($title);
5137 
5138  $description = new ilTextAreaInputGUI($lng->txt('description'), 'description');
5139  $form->addItem($description);
5140 
5141  $form->addCommandButton('createQuestionPoolAndCopy', $lng->txt('create'));
5142 
5143  if(isset($_REQUEST['q_id']) && is_array($_REQUEST['q_id']))
5144  {
5145  foreach($_REQUEST['q_id'] as $id)
5146  {
5147  $hidden = new ilHiddenInputGUI('q_id[]');
5148  $hidden->setValue($id);
5149  $form->addItem($hidden);
5150  }
5151  }
5152 
5153  return $form;
5154  }
5155 
5156  public function copyToQuestionpoolObject()
5157  {
5158  $this->createQuestionpoolTargetObject('copyQuestionsToPool');
5159  }
5160 
5162  {
5163  global $lng;
5164 
5165  require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
5166 
5167  // #13761; All methods use for this request should be revised, thx japo ;-)
5168  if(
5169  'copyAndLinkToQuestionpool' == $this->ctrl->getCmd() &&
5170  (!isset($_REQUEST['q_id']) || !is_array($_REQUEST['q_id']))
5171  )
5172  {
5173  ilUtil::sendFailure($this->lng->txt('tst_no_question_selected_for_moving_to_qpl'), true);
5174  $this->ctrl->redirect($this, 'questions');
5175  }
5176 
5177  if(isset($_REQUEST['q_id']) && is_array($_REQUEST['q_id']))
5178  {
5179  foreach($_REQUEST['q_id'] as $q_id)
5180  {
5182  {
5183  continue;
5184  }
5185 
5187 
5188  if($type !== 'tst')
5189  {
5190  ilUtil::sendFailure($lng->txt('tst_link_only_unassigned'), true);
5191  $this->backObject();
5192  return;
5193  }
5194  }
5195  }
5196 
5197  $this->createQuestionpoolTargetObject('copyAndLinkQuestionsToPool');
5198  }
5199 
5201  {
5202  $form = $this->getQuestionpoolCreationForm();
5203 
5204  if ($_REQUEST['title'])
5205  {
5206  $title = $_REQUEST['title'];
5207  }
5208  else
5209  {
5210  $title = $_REQUEST['txt_qpl'];
5211  }
5212 
5213  if (!$title)
5214  {
5215  ilUtil::sendInfo($this->lng->txt("questionpool_not_entered"));
5216  return $this->copyAndLinkToQuestionpoolObject();
5217  }
5218 
5219  $ref_id = $this->createQuestionPool($title, $_REQUEST['description']);
5220  $_REQUEST['sel_qpl'] = $ref_id;
5221 
5222  //if ($_REQUEST['link'])
5223  //{
5225  //}
5226  //else
5227  //{
5228  // $this->copyQuestionsToPoolObject();
5229  //}
5230  }
5231 
5239  {
5240  global $ilUser, $ilTabs;
5241  $this->getQuestionsSubTabs();
5242  $ilTabs->activateSubTab('edit_test_questions');
5243 
5244  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_qpl_select_copy.html", "Modules/Test");
5245  $questionpools =& $this->object->getAvailableQuestionpools(FALSE, FALSE, FALSE, TRUE, FALSE, "write");
5246  if(count($questionpools) == 0)
5247  {
5248  $this->tpl->setCurrentBlock("option");
5249  $this->tpl->setVariable("VALUE_QPL", "");
5250  $this->tpl->parseCurrentBlock();
5251  }
5252  else
5253  {
5254  foreach($questionpools as $key => $value)
5255  {
5256  $this->tpl->setCurrentBlock("option");
5257  $this->tpl->setVariable("VALUE_OPTION", $key);
5258  $this->tpl->setVariable("TEXT_OPTION", $value["title"]);
5259  $this->tpl->parseCurrentBlock();
5260  }
5261  }
5262 
5263  if(isset($_REQUEST['q_id']) && is_array($_REQUEST['q_id']))
5264  {
5265  foreach($_REQUEST['q_id'] as $id)
5266  {
5267  $this->tpl->setCurrentBlock("hidden");
5268  $this->tpl->setVariable("HIDDEN_NAME", "q_id[]");
5269  $this->tpl->setVariable("HIDDEN_VALUE", $id);
5270  $this->tpl->parseCurrentBlock();
5271  $this->tpl->setCurrentBlock("adm_content");
5272  }
5273  }
5274  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
5275 
5276  if(count($questionpools) == 0)
5277  {
5278  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_enter_questionpool"));
5279  $cmd = 'createQuestionPoolAndCopy';
5280  }
5281  else
5282  {
5283  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_select_questionpool"));
5284  }
5285 
5286  $this->tpl->setVariable("CMD_SUBMIT", $cmd);
5287  $this->tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit"));
5288  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
5289 
5290  $createForm = $this->getQuestionpoolCreationForm();
5291  switch($cmd)
5292  {
5293  case 'copyAndLinkQuestionsToPool':
5294  $hidden = new ilHiddenInputGUI('link');
5295  $hidden->setValue(1);
5296  $createForm->addItem($hidden);
5297  break;
5298  case 'copyQuestionsToPool':
5299  break;
5300  }
5301  $createForm->setFormAction($this->ctrl->getFormAction($this));
5302 
5303  $this->tpl->parseCurrentBlock();
5304  }
5305 
5306  private function applyTemplate($templateData, $object)
5307  {
5308  // map formFieldName => setterName
5309  $simpleSetters = array(
5310  'anonymity' => 'setAnonymity',
5311  'question_set_type' => 'setQuestionSetType',
5312  'use_pool' => 'setPoolUsage',
5313  'test_enabled_views' => 'setEnabledViewMode',
5314  //'express_allow_question_pool' => 'setExpressModeQuestionPoolAllowed',
5315  'introduction' => 'setIntroduction',
5316  'showinfo' => 'setShowInfo',
5317  'finalstatement' => 'setFinalStatement',
5318  'showfinalstatement' => 'setShowFinalStatement',
5319  'chb_shuffle_questions' => 'setShuffleQuestions',
5320  'list_of_questions' => 'setListOfQuestionsSettings',
5321  'chb_show_marker' => 'setShowMarker',
5322  'chb_show_cancel' => 'setShowCancel',
5323  'kiosk' => 'setKiosk',
5324  'nr_of_tries' => 'setNrOfTries',
5325  'chb_processing_time' => 'setEnableProcessingTime',
5326  'chb_use_previous_answers' => 'setUsePreviousAnswers',
5327  'forcejs' => 'setForceJS',
5328  'title_output' => 'setTitleOutput',
5329  'password' => 'setPassword',
5330  'fixedparticipants' => 'setFixedParticipants',
5331  'allowedUsers' => 'setAllowedUsers',
5332  'allowedUsersTimeGap' => 'setAllowedUsersTimeGap',
5333  'mailnotification' => 'setMailNotification',
5334  'mailnottype' => 'setMailNotificationType',
5335  //'' => '',
5336  'count_system' => 'setCountSystem',
5337  'mc_scoring' => 'setMCScoring',
5338  'score_cutting' => 'setScoreCutting',
5339  'pass_scoring' => 'setScoreReporting',
5340 
5341  'instant_feedback' => 'setScoringFeedbackOptionsByArray',
5342 
5343  'results_presentation' => 'setResultsPresentationOptionsByArray',
5344  'export_settings' => 'setExportSettings',
5345  'print_bs_with_res' => 'setPrintBestSolutionWithResult',
5346  );
5347 
5348  if (!$templateData['results_presentation']['value'])
5349  {
5350  $templateData['results_presentation']['value'] = array();
5351  }
5352 
5353  foreach($simpleSetters as $field => $setter)
5354  {
5355  if($templateData[$field])
5356  {
5357  $object->$setter($templateData[$field]['value']);
5358  }
5359  }
5360  }
5361 
5363  {
5364  global $ilAccess;
5365  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
5366  {
5367  // allow only write access
5368  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
5369  $this->ctrl->redirect($this, "infoScreen");
5370  }
5371 
5372  global $ilCtrl;
5373 
5374  $orders = $obligations = array();
5375 
5376  foreach($_REQUEST['order'] as $qId => $order)
5377  {
5378  $id = (int)str_replace('q_', '', $qId);
5379 
5380  $orders[$id] = $order;
5381  }
5382 
5383  if( $this->object->areObligationsEnabled() && isset($_REQUEST['obligatory']) && is_array($_REQUEST['obligatory']) )
5384  {
5385  foreach($_REQUEST['obligatory'] as $qId => $obligation)
5386  {
5387  $id = (int)str_replace('q_', '', $qId);
5388 
5390  {
5391  $obligations[$id] = $obligation;
5392  }
5393  }
5394  }
5395 
5396  $this->object->setQuestionOrderAndObligations(
5397  $orders, $obligations
5398  );
5399 
5400  $ilCtrl->redirect($this, 'questions');
5401  }
5402 
5406  protected function movePageFormObject()
5407  {
5408  global $lng, $ilCtrl, $tpl;
5409 
5410  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
5411  $form = new ilPropertyFormGUI();
5412  $form->setFormAction($ilCtrl->getFormAction($this, "movePage"));
5413  $form->setTitle($lng->txt("test_move_page"));
5414 
5415  $old_pos = new ilHiddenInputGUI("q_id");
5416  $old_pos->setValue($_REQUEST['q_id']);
5417  $form->addItem($old_pos);
5418 
5419  $questions = $this->object->getQuestionTitlesAndIndexes();
5420  if (!is_array($questions))
5421  $questions = array();
5422 
5423  foreach($questions as $k => $q) {
5424  if ($k == $_REQUEST['q_id']) {
5425  unset($questions[$k]);
5426  continue;
5427  }
5428  $questions[$k] = $lng->txt('behind') . ' '. $q;
5429  }
5430  #$questions['0'] = $lng->txt('first');
5431 
5432  $options = array(
5433  0 => $lng->txt('first')
5434  );
5435  foreach($questions as $k => $q) {
5436  $options[$k] = $q . ' ['. $this->lng->txt('question_id_short') . ': ' . $k . ']';
5437  }
5438 
5439  $pos = new ilSelectInputGUI($lng->txt("position"), "position_after");
5440  $pos->setOptions($options);
5441  $form->addItem($pos);
5442 
5443  $form->addCommandButton("movePage", $lng->txt("submit"));
5444  $form->addCommandButton("showPage", $lng->txt("cancel"));
5445 
5446  return $tpl->setContent($form->getHTML());
5447  }
5448 
5449  public function movePageObject() {
5450  global $ilAccess;
5451  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
5452  {
5453  // allow only write access
5454  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
5455  $this->ctrl->redirect($this, "infoScreen");
5456  }
5457 
5458  $this->object->moveQuestionAfter($_REQUEST['q_id'], $_REQUEST['position_after']);
5459  $this->showPageObject();
5460  }
5461 
5462  public function showPageObject() {
5463  global $ilCtrl;
5464 
5465  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'q_id', $_REQUEST['q_id']);
5466  $ilCtrl->redirectByClass('iltestexpresspageobjectgui', 'showPage');
5467  }
5468 
5469  public function copyQuestionObject() {
5470  global $ilAccess;
5471  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
5472  {
5473  // allow only write access
5474  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
5475  $this->ctrl->redirect($this, "infoScreen");
5476  }
5477 
5478  if ($_REQUEST['q_id'] && !is_array($_REQUEST['q_id']))
5479  $ids = array($_REQUEST['q_id']);
5480  else if ($_REQUEST['q_id'])
5481  $ids = $_REQUEST['q_id'];
5482  else
5483  {
5484  ilUtil::sendFailure( $this->lng->txt('copy_no_questions_selected'), true );
5485  $this->ctrl->redirect($this, 'questions');
5486  }
5487 
5488  $copy_count = 0;
5489 
5490  $questionTitles = $this->object->getQuestionTitles();
5491 
5492  foreach($ids as $id)
5493  {
5494  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
5495  $question = assQuestion::_instanciateQuestionGUI($id);
5496  if ($question)
5497  {
5498  $title = $question->object->getTitle();
5499  $i = 2;
5500  while( in_array( $title . ' (' . $i . ')', $questionTitles ))
5501  $i++;
5502 
5503  $title .= ' (' . $i . ')';
5504 
5505  $questionTitles[] = $title;
5506 
5507  $new_id = $question->object->duplicate(false, $title);
5508 
5509  $clone = assQuestion::_instanciateQuestionGUI($new_id);
5510  $clone->object->setObjId($this->object->getId());
5511  $clone->object->saveToDb();
5512 
5513  $this->object->insertQuestion( $this->testQuestionSetConfigFactory->getQuestionSetConfig(), $new_id, true );
5514 
5515  $copy_count++;
5516  }
5517  }
5518 
5519  ilUtil::sendSuccess($this->lng->txt('copy_questions_success'), true);
5520 
5521  $this->ctrl->redirect($this, 'questions');
5522  }
5523 
5529  private function isDeleteDynamicTestResultsButtonRequired($testSession, $testSequence)
5530  {
5531  if( !$testSession->getActiveId() )
5532  {
5533  return false;
5534  }
5535 
5536  if( !$this->object->isDynamicTest() )
5537  {
5538  return false;
5539  }
5540 
5541  if( !$this->object->isPassDeletionAllowed() )
5542  {
5543  return false;
5544  }
5545 
5546  if( !$testSequence->hasStarted($testSession) )
5547  {
5548  return false;
5549  }
5550 
5551  return true;
5552  }
5553 
5558  private function populateDeleteDynamicTestResultsButton($testSession, &$big_button)
5559  {
5560  require_once 'Modules/Test/classes/confirmations/class.ilTestPassDeletionConfirmationGUI.php';
5561 
5562  $this->ctrl->setParameterByClass(
5563  'iltestevaluationgui', 'context',
5565  );
5566 
5567  $this->ctrl->setParameterByClass('iltestevaluationgui', 'active_id', $testSession->getActiveId());
5568  $this->ctrl->setParameterByClass('iltestevaluationgui', 'pass', $testSession->getPass());
5569 
5570  $big_button[] = array(
5571  '',
5572  $this->lng->txt("tst_delete_dyn_test_results_btn"),
5573  false,
5574  $this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'confirmDeletePass')
5575  );
5576  }
5577 }