ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjTestGUI.php
Go to the documentation of this file.
1 <?php
2 /* 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.ilObjAssessmentFolder.php';
9 require_once './Modules/Test/classes/class.ilTestExpressPage.php';
10 
47 {
48  private static $infoScreenChildClasses = array(
49  'ilpublicuserprofilegui', 'ilobjportfoliogui'
50  );
51 
53  public $object = null;
54 
57 
59  private $testPlayerFactory = null;
60 
62  private $testSessionFactory = null;
63 
65  private $testSequenceFactory = null;
66 
71  function ilObjTestGUI()
72  {
73  global $lng, $ilCtrl, $ilDB, $ilPluginAdmin, $tree;
74  $lng->loadLanguageModule("assessment");
75  $this->type = "tst";
76  $this->ctrl =& $ilCtrl;
77  $this->ctrl->saveParameter($this, array("ref_id", "test_ref_id", "calling_test", "test_express_mode", "q_id"));
78  $this->ilObjectGUI("",$_GET["ref_id"], true, false);
79 
80  if( $this->object instanceof ilObjTest )
81  {
82  require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
83  $this->testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($tree, $ilDB, $ilPluginAdmin, $this->object);
84 
85  require_once 'Modules/Test/classes/class.ilTestPlayerFactory.php';
86  $this->testPlayerFactory = new ilTestPlayerFactory($this->object);
87 
88  require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
89  $this->testSessionFactory = new ilTestSessionFactory($this->object);
90 
91  require_once 'Modules/Test/classes/class.ilTestSequenceFactory.php';
92  $this->testSequenceFactory = new ilTestSequenceFactory($ilDB, $lng, $ilPluginAdmin, $this->object);
93  }
94  }
95 
99  function executeCommand()
100  {
101  global $ilAccess, $ilNavigationHistory, $ilCtrl, $ilErr, $tpl, $lng, $ilTabs, $ilPluginAdmin, $ilDB, $tree, $ilias, $ilUser;
102 
103  if((!$ilAccess->checkAccess("read", "", $_GET["ref_id"])))
104  {
105  $ilias->raiseError($this->lng->txt("permission_denied"), $ilias->error_obj->MESSAGE);
106  }
107 
108  $cmd = $this->ctrl->getCmd("infoScreen");
109 
110  $cmdsDisabledDueToOfflineStatus = array(
111  'resumePlayer', 'resumePlayer', 'outUserResultsOverview', 'outUserListOfAnswerPasses'
112  );
113 
114  if(!$this->getCreationMode() && !$this->object->isOnline() && in_array($cmd, $cmdsDisabledDueToOfflineStatus))
115  {
116  $cmd = 'infoScreen';
117  }
118 
119  $next_class = $this->ctrl->getNextClass($this);
120  $this->ctrl->setReturn($this, "infoScreen");
121 
122  if(method_exists($this->object, "getTestStyleLocation")) $this->tpl->addCss($this->object->getTestStyleLocation("output"), "screen");
123 
124  // add entry to navigation history
125  if(!$this->getCreationMode() &&
126  $ilAccess->checkAccess("read", "", $_GET["ref_id"])
127  )
128  {
129  $ilNavigationHistory->addItem($_GET["ref_id"],
130  "ilias.php?baseClass=ilObjTestGUI&cmd=infoScreen&ref_id=" . $_GET["ref_id"], "tst");
131  }
132 
133  if(!$this->getCreationMode())
134  {
135  if(IS_PAYMENT_ENABLED)
136  {
137  require_once 'Services/Payment/classes/class.ilPaymentObject.php';
138  if(ilPaymentObject::_requiresPurchaseToAccess($this->object->getRefId(), $type = (isset($_GET['purchasetype']) ? $_GET['purchasetype'] : NULL)))
139  {
140  $this->setLocator();
141  $this->tpl->getStandardTemplate();
142 
143  include_once 'Services/Payment/classes/class.ilShopPurchaseGUI.php';
144  $pp = new ilShopPurchaseGUI((int)$_GET['ref_id']);
145  $ret = $this->ctrl->forwardCommand($pp);
146  $this->tpl->show();
147  exit();
148  }
149  }
150  }
151 
152  // elba hack for storing question id for inserting new question after
153  if($_REQUEST['prev_qid'])
154  {
155  global $___prev_question_id;
156  $___prev_question_id = $_REQUEST['prev_qid'];
157  $this->ctrl->setParameter($this, 'prev_qid', $_REQUEST['prev_qid']);
158  }
159 
160  if( !$this->getCreationMode() && $this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken() )
161  {
162  if( !$this->testQuestionSetConfigFactory->getQuestionSetConfig()->isValidRequestOnBrokenQuestionSetDepencies($next_class, $cmd) )
163  {
164  $this->ctrl->redirectByClass('ilObjTestGUI', 'infoScreen');
165  }
166  }
167 
168  switch($next_class)
169  {
170  case 'iltestexportgui':
171  if(!$ilAccess->checkAccess('write', '', $this->ref_id))
172  {
173  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
174  }
175 
176  $this->prepareOutput();
177  $this->addHeaderAction();
178  require_once 'Modules/Test/classes/class.ilTestExportGUI.php';
179  $ilCtrl->forwardCommand(new ilTestExportGUI($this));
180  break;
181 
182  case "ilinfoscreengui":
183  $this->prepareOutput();
184  $this->addHeaderAction();
185  $this->infoScreen(); // forwards command
186  break;
187  case 'ilmdeditorgui':
188  if(!$ilAccess->checkAccess('write', '', $this->object->getRefId()))
189  {
190  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
191  }
192 
193  $this->prepareOutput();
194  $this->addHeaderAction();
195  require_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
196  $md_gui =& new ilMDEditorGUI($this->object->getId(), 0, $this->object->getType());
197  $md_gui->addObserver($this->object, 'MDUpdateListener', 'General');
198 
199  $this->ctrl->forwardCommand($md_gui);
200  break;
201 
202  case "iltestplayerfixedquestionsetgui":
203  require_once "./Modules/Test/classes/class.ilTestPlayerFixedQuestionSetGUI.php";
204  if(!$this->object->getKioskMode()) $this->prepareOutput();
205  $output_gui =& new ilTestPlayerFixedQuestionSetGUI($this->object);
206  $this->ctrl->forwardCommand($output_gui);
207  break;
208 
209  case "iltestplayerrandomquestionsetgui":
210  require_once "./Modules/Test/classes/class.ilTestPlayerRandomQuestionSetGUI.php";
211  if(!$this->object->getKioskMode()) $this->prepareOutput();
212  $output_gui =& new ilTestPlayerRandomQuestionSetGUI($this->object);
213  $this->ctrl->forwardCommand($output_gui);
214  break;
215 
216  case "iltestplayerdynamicquestionsetgui":
217  require_once "./Modules/Test/classes/class.ilTestPlayerDynamicQuestionSetGUI.php";
218  if (!$this->object->getKioskMode()) $this->prepareOutput();
219  $output_gui =& new ilTestPlayerDynamicQuestionSetGUI($this->object);
220  $this->ctrl->forwardCommand($output_gui);
221  break;
222 
223  case "iltestevaluationgui":
224  $this->prepareOutput();
225  $this->addHeaderAction();
226  include_once "./Modules/Test/classes/class.ilTestEvaluationGUI.php";
227  $evaluation_gui =& new ilTestEvaluationGUI($this->object);
228  $this->ctrl->forwardCommand($evaluation_gui);
229  break;
230 
231  case "iltestservicegui":
232  $this->prepareOutput();
233  $this->addHeaderAction();
234  require_once "./Modules/Test/classes/class.ilTestServiceGUI.php";
235  $serviceGUI =& new ilTestServiceGUI($this->object);
236  $this->ctrl->forwardCommand($serviceGUI);
237  break;
238 
239  case 'ilpermissiongui':
240  $this->prepareOutput();
241  $this->addHeaderAction();
242  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
243  $perm_gui =& new ilPermissionGUI($this);
244  $ret =& $this->ctrl->forwardCommand($perm_gui);
245  break;
246 
247  case "illearningprogressgui":
248  $this->prepareOutput();
249  $this->addHeaderAction();
250  require_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
251  $new_gui =& new ilLearningProgressGUI(ilLearningProgressGUI::LP_CONTEXT_REPOSITORY, $this->object->getRefId());
252  $this->ctrl->forwardCommand($new_gui);
253 
254  break;
255 
256  case "ilcertificategui":
257  $this->prepareOutput();
258  $this->addHeaderAction();
259  require_once "./Services/Certificate/classes/class.ilCertificateGUI.php";
260  require_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
261  $output_gui = new ilCertificateGUI(new ilTestCertificateAdapter($this->object));
262  $this->ctrl->forwardCommand($output_gui);
263  break;
264 
265  case "iltestscoringgui":
266  $this->prepareOutput();
267  $this->addHeaderAction();
268  require_once "./Modules/Test/classes/class.ilTestScoringGUI.php";
269  $output_gui = new ilTestScoringGUI($this->object);
270  $this->ctrl->forwardCommand($output_gui);
271  break;
272 
273  case 'ilmarkschemagui':
274  if(!$ilAccess->checkAccess('write', '', $this->object->getRefId()))
275  {
276  ilUtil::sendInfo($this->lng->txt('cannot_edit_test'), true);
277  $this->ctrl->redirect($this, 'infoScreen');
278  }
279  $this->prepareOutput();
280  $this->addHeaderAction();
281  require_once 'Modules/Test/classes/class.ilMarkSchemaGUI.php';
282  $mark_schema_gui = new ilMarkSchemaGUI($this->object);
283  $this->ctrl->forwardCommand($mark_schema_gui);
284  break;
285 
286  case 'iltestscoringbyquestionsgui':
287  $this->prepareOutput();
288  $this->addHeaderAction();
289  include_once 'Modules/Test/classes/class.ilTestScoringByQuestionsGUI.php';
290  $output_gui = new ilTestScoringByQuestionsGUI($this->object);
291  $this->ctrl->forwardCommand($output_gui);
292  break;
293 
294  case 'ilobjtestsettingsgeneralgui':
295  $this->prepareOutput();
296  $this->addHeaderAction();
297  require_once 'Modules/Test/classes/class.ilObjTestSettingsGeneralGUI.php';
298  $gui = new ilObjTestSettingsGeneralGUI(
299  $this->ctrl, $ilAccess, $this->lng, $this->tpl, $this->tree, $ilDB, $ilPluginAdmin, $ilUser, $this
300  );
301  $this->ctrl->forwardCommand($gui);
302  break;
303 
304  case 'ilobjtestsettingsscoringresultsgui':
305  $this->prepareOutput();
306  $this->addHeaderAction();
307  require_once 'Modules/Test/classes/class.ilObjTestSettingsScoringResultsGUI.php';
309  $this->ctrl, $ilAccess, $this->lng, $this->tpl, $this->tree, $ilDB, $ilPluginAdmin, $this
310  );
311  $this->ctrl->forwardCommand($gui);
312  break;
313 
314  case 'ilobjtestdynamicquestionsetconfiggui':
315  $this->prepareOutput();
316  $this->addHeaderAction();
317  require_once 'Modules/Test/classes/class.ilObjTestDynamicQuestionSetConfigGUI.php';
318  $gui = new ilObjTestDynamicQuestionSetConfigGUI($this->ctrl, $ilAccess, $ilTabs, $this->lng, $this->tpl, $ilDB, $tree, $ilPluginAdmin, $this->object);
319  $this->ctrl->forwardCommand($gui);
320  break;
321 
322  case 'iltestrandomquestionsetconfiggui':
323  $this->prepareOutput();
324  $this->addHeaderAction();
325  require_once 'Modules/Test/classes/class.ilTestRandomQuestionSetConfigGUI.php';
326  $gui = new ilTestRandomQuestionSetConfigGUI($this->ctrl, $ilAccess, $ilTabs, $this->lng, $this->tpl, $ilDB, $tree, $ilPluginAdmin, $this->object);
327  $this->ctrl->forwardCommand($gui);
328  break;
329 
330  case 'iltestskilladministrationgui':
331  $this->prepareOutput();
332  $this->addHeaderAction();
333  require_once 'Modules/Test/classes/class.ilTestSkillAdministrationGUI.php';
334  $gui = new ilTestSkillAdministrationGUI($ilias, $this->ctrl, $ilAccess, $ilTabs, $this->tpl, $this->lng, $ilDB, $this->object, $this->ref_id);
335  $this->ctrl->forwardCommand($gui);
336  break;
337 
338  case 'iltestskillevaluationgui':
339  $this->prepareOutput();
340  $this->addHeaderAction();
341  require_once 'Modules/Test/classes/class.ilTestSkillEvaluationGUI.php';
342  $gui = new ilTestSkillEvaluationGUI($this->ctrl, $ilTabs, $this->tpl, $this->lng, $ilDB, $this->object);
343  $this->ctrl->forwardCommand($gui);
344  break;
345 
346  case 'ilobjectcopygui':
347  $this->prepareOutput();
348  $this->addHeaderAction();
349  require_once './Services/Object/classes/class.ilObjectCopyGUI.php';
350  $cp = new ilObjectCopyGUI($this);
351  $cp->setType('tst');
352  $this->ctrl->forwardCommand($cp);
353  break;
354 
355  case 'ilrepositorysearchgui':
356  $this->prepareOutput();
357  $this->addHeaderAction();
358  require_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
359  $rep_search =& new ilRepositorySearchGUI();
360  $rep_search->setCallback($this,
361  'addParticipantsObject',
362  array()
363  );
364 
365  // Set tabs
366  $this->ctrl->setReturn($this, 'participants');
367  $ret =& $this->ctrl->forwardCommand($rep_search);
368  $this->tabs_gui->setTabActive('participants');
369  break;
370 
371  case 'ilpageeditorgui':
372  case 'iltestexpresspageobjectgui':
373 
374  require_once 'Modules/TestQuestionPool/classes/class.ilAssIncompleteQuestionPurger.php';
375  $incompleteQuestionPurger = new ilAssIncompleteQuestionPurger($ilDB);
376  $incompleteQuestionPurger->setOwnerId($ilUser->getId());
377  $incompleteQuestionPurger->purge();
378 
379  $qid = $_REQUEST['q_id'];
380 
381  // :FIXME: does not work
382  // $this->ctrl->saveParameterByClass(array('iltestexpresspageobjectgui', 'assorderingquestiongui', 'ilpageeditorgui', 'ilpcquestion', 'ilpcquestiongui'), 'test_express_mode');
383 
384  if(!$qid || $qid == 'Array')
385  {
386  $questions = $this->object->getQuestionTitlesAndIndexes();
387  if(!is_array($questions))
388  $questions = array();
389 
390  $keys = array_keys($questions);
391  $qid = $keys[0];
392 
393  $_REQUEST['q_id'] = $qid;
394  $_GET['q_id'] = $qid;
395  $_POST['q_id'] = $qid;
396  }
397 
398  $this->prepareOutput();
399  if(!in_array($cmd, array('addQuestion', 'browseForQuestions')))
400  {
401  $this->buildPageViewToolbar($qid);
402  }
403 
404  if(!$qid || in_array($cmd, array('insertQuestions', 'browseForQuestions')))
405  {
406  require_once "./Modules/Test/classes/class.ilTestExpressPageObjectGUI.php";
407  $pageObject = new ilTestExpressPageObjectGUI (0);
408  $pageObject->test_object = $this->object;
409  $ret =& $this->ctrl->forwardCommand($pageObject);
410  break;
411  }
412  require_once "./Services/Style/classes/class.ilObjStyleSheet.php";
413  $this->tpl->setCurrentBlock("ContentStyle");
414  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
416  $this->tpl->parseCurrentBlock();
417 
418  // syntax style
419  $this->tpl->setCurrentBlock("SyntaxStyle");
420  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
422  $this->tpl->parseCurrentBlock();
423  require_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
424 
425  $q_gui = assQuestionGUI::_getQuestionGUI("", $qid);
426  if(!($q_gui instanceof assQuestionGUI))
427  {
428  $this->ctrl->setParameterByClass('iltestexpresspageobjectgui', 'q_id', '');
429  $this->ctrl->redirectByClass('iltestexpresspageobjectgui', $this->ctrl->getCmd());
430  }
431 
432  $q_gui->outAdditionalOutput();
433  $q_gui->object->setObjId($this->object->getId());
434 
435  $q_gui->setTargetGuiClass(null);
436  $q_gui->setQuestionActionCmd(null);
437 
438  $question = $q_gui->object;
439  $this->ctrl->saveParameter($this, "q_id");
440 
441  #$this->lng->loadLanguageModule("content");
442  $this->ctrl->setReturnByClass("ilTestExpressPageObjectGUI", "view");
443  $this->ctrl->setReturn($this, "questions");
444 
445  require_once "./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php";
446  require_once "./Modules/Test/classes/class.ilTestExpressPageObjectGUI.php";
447 
448  $page_gui = new ilTestExpressPageObjectGUI($qid);
449  $page_gui->test_object = $this->object;
450  $page_gui->setEditPreview(true);
451  $page_gui->setEnabledTabs(false);
452  if(strlen($this->ctrl->getCmd()) == 0)
453  {
454  $this->ctrl->setCmdClass(get_class($page_gui));
455  $this->ctrl->setCmd("preview");
456  }
457 
458  $page_gui->setQuestionHTML(array($q_gui->object->getId() => $q_gui->getPreview(TRUE)));
459  $page_gui->setTemplateTargetVar("ADM_CONTENT");
460 
461  $page_gui->setOutputMode($this->object->evalTotalPersons() == 0 ? "edit" : 'preview');
462 
463  $page_gui->setHeader($question->getTitle());
464  $page_gui->setFileDownloadLink($this->ctrl->getLinkTarget($this, "downloadFile"));
465  $page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "fullscreen"));
466  $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTarget($this));
467  $page_gui->setPresentationTitle($question->getTitle() . ' ['. $this->lng->txt('question_id_short') . ': ' . $question->getId() . ']');
468  $ret =& $this->ctrl->forwardCommand($page_gui);
469 
470  global $ilTabs;
471  $ilTabs->activateTab('assQuestions');
472 
473  $this->tpl->setContent($ret);
474  break;
475 
476  case 'ilassquestionpreviewgui':
477 
478  $this->prepareOutput();
479 
480  $this->ctrl->saveParameter($this, "q_id");
481 
482  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionPreviewGUI.php';
483  $gui = new ilAssQuestionPreviewGUI($this->ctrl, $this->tabs_gui, $this->tpl, $this->lng, $ilDB);
484 
485  $gui->initQuestion((int)$_GET['q_id'], $this->object->getId());
486  $gui->initPreviewSettings($this->object->getRefId());
487  $gui->initPreviewSession($ilUser->getId(), (int)$_GET['q_id']);
488  $gui->initHintTracking();
489  $gui->initStyleSheets();
490 
491  $this->ctrl->forwardCommand($gui);
492 
493  break;
494 
495  case 'ilassquestionpagegui':
496  require_once "./Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php";
497  //echo $_REQUEST['prev_qid'];
498  if($_REQUEST['prev_qid'])
499  {
500  $this->ctrl->setParameter($this, 'prev_qid', $_REQUEST['prev_qid']);
501  }
502 
503  $this->prepareOutput();
504  //global $___test_express_mode;
505  //$___test_express_mode = true;
506  $_GET['calling_test'] = $this->object->getRefId();
507  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
508  $this->tpl->setCurrentBlock("ContentStyle");
509  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
511  $this->tpl->parseCurrentBlock();
512 
513  // syntax style
514  $this->tpl->setCurrentBlock("SyntaxStyle");
515  $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET",
517  $this->tpl->parseCurrentBlock();
518  require_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
519  $q_gui = assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
520  $q_gui->setQuestionTabs();
521  $q_gui->outAdditionalOutput();
522  $q_gui->object->setObjId($this->object->getId());
523  $question =& $q_gui->object;
524  $this->ctrl->saveParameter($this, "q_id");
525  $this->lng->loadLanguageModule("content");
526  $this->ctrl->setReturnByClass("ilAssQuestionPageGUI", "view");
527  $this->ctrl->setReturn($this, "questions");
528  $page_gui = new ilAssQuestionPageGUI($_GET["q_id"]);
529  $page_gui->setEditPreview(true);
530  if(strlen($this->ctrl->getCmd()) == 0)
531  {
532  $this->ctrl->setCmdClass(get_class($page_gui));
533  $this->ctrl->setCmd("preview");
534  }
535  $page_gui->setQuestionHTML(array($q_gui->object->getId() => $q_gui->getPreview(TRUE)));
536  $page_gui->setTemplateTargetVar("ADM_CONTENT");
537  $page_gui->setOutputMode($this->object->evalTotalPersons() == 0 ? "edit" : 'preview');
538  $page_gui->setHeader($question->getTitle());
539  $page_gui->setPresentationTitle($question->getTitle() . ' ['. $this->lng->txt('question_id_short') . ': ' . $question->getId() . ']');
540  $ret =& $this->ctrl->forwardCommand($page_gui);
541  $this->tpl->setContent($ret);
542  break;
543 
544  case 'ilassspecfeedbackpagegui':
545  require_once "./Modules/TestQuestionPool/classes/feedback/class.ilAssSpecFeedbackPageGUI.php";
546  $pg_gui = new ilAssSpecFeedbackPageGUI((int) $_GET["feedback_id"]);
547  $this->ctrl->forwardCommand($pg_gui);
548  break;
549 
550  case 'ilassgenfeedbackpagegui':
551  require_once "./Modules/TestQuestionPool/classes/feedback/class.ilAssGenFeedbackPageGUI.php";
552  $pg_gui = new ilAssGenFeedbackPageGUI((int) $_GET["feedback_id"]);
553  $this->ctrl->forwardCommand($pg_gui);
554  break;
555 
556  case 'illocalunitconfigurationgui':
557  $this->prepareSubGuiOutput();
558 
559  // set return target
560  $this->ctrl->setReturn($this, "questions");
561 
562  // set context tabs
563  require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
564  $questionGUI = assQuestionGUI::_getQuestionGUI('', $_GET['q_id']);
565  $questionGUI->object->setObjId($this->object->getId());
566  $questionGUI->setQuestionTabs();
567 
568  require_once 'Modules/TestQuestionPool/classes/class.ilLocalUnitConfigurationGUI.php';
569  require_once 'Modules/TestQuestionPool/classes/class.ilUnitConfigurationRepository.php';
570  $gui = new ilLocalUnitConfigurationGUI(
571  new ilUnitConfigurationRepository((int)$_GET['q_id'])
572  );
573  $this->ctrl->forwardCommand($gui);
574  break;
575 
576  case "ilcommonactiondispatchergui":
577  require_once "Services/Object/classes/class.ilCommonActionDispatcherGUI.php";
579  $this->ctrl->forwardCommand($gui);
580  break;
581 
582  case 'ilassquestionhintsgui':
583 
584  $this->prepareSubGuiOutput();
585 
586  // set return target
587  $this->ctrl->setReturn($this, "questions");
588 
589  // set context tabs
590  require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
591  $questionGUI =& assQuestionGUI::_getQuestionGUI($q_type, $_GET['q_id']);
592  $questionGUI->object->setObjId($this->object->getId());
593  $questionGUI->setQuestionTabs();
594 
595  // forward to ilAssQuestionHintsGUI
596  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintsGUI.php';
597  $gui = new ilAssQuestionHintsGUI($questionGUI);
598  $ilCtrl->forwardCommand($gui);
599 
600  break;
601 
602  case 'ilassquestionfeedbackeditinggui':
603 
604  $this->prepareSubGuiOutput();
605 
606  // set return target
607  $this->ctrl->setReturn($this, "questions");
608 
609  // set context tabs
610  require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
611  $questionGUI = assQuestionGUI::_getQuestionGUI('', $_GET['q_id']);
612  $questionGUI->object->setObjId($this->object->getId());
613  $questionGUI->setQuestionTabs();
614 
615  // forward to ilAssQuestionFeedbackGUI
616  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionFeedbackEditingGUI.php';
617  $gui = new ilAssQuestionFeedbackEditingGUI($questionGUI, $ilCtrl, $ilAccess, $tpl, $ilTabs, $lng);
618  $ilCtrl->forwardCommand($gui);
619 
620  break;
621 
622  case 'iltesttoplistgui':
623  $this->prepareOutput();
624  require_once './Modules/Test/classes/class.ilTestToplistGUI.php';
625  $gui = new ilTestToplistGUI($this);
626  $this->ctrl->forwardCommand($gui);
627  break;
628 
629  case 'ilscoringadjustmentgui':
630  $this->prepareOutput();
631  require_once './Modules/Test/classes/class.ilScoringAdjustmentGUI.php';
632  $gui = new ilScoringAdjustmentGUI($this->object);
633  $this->ctrl->forwardCommand($gui);
634  break;
635 
636  case '':
637  case 'ilobjtestgui':
638  $this->prepareOutput();
639  $this->addHeaderAction();
640  if((strcmp($cmd, "properties") == 0) && ($_GET["browse"]))
641  {
642  $this->questionBrowser();
643  return;
644  }
645  if((strcmp($cmd, "properties") == 0) && ($_GET["up"] || $_GET["down"]))
646  {
647  $this->questionsObject();
648  return;
649  }
650  $cmd .= "Object";
651  $ret =& $this->$cmd();
652  break;
653  default:
654  // elba hack for storing question id for inserting new question after
655  if($_REQUEST['prev_qid'])
656  {
657  global $___prev_question_id;
658  $___prev_question_id = $_REQUEST['prev_qid'];
659  $this->ctrl->setParameterByClass('ilassquestionpagegui', 'prev_qid', $_REQUEST['prev_qid']);
660  $this->ctrl->setParameterByClass($_GET['sel_question_types'] . 'gui', 'prev_qid', $_REQUEST['prev_qid']);
661  }
662  $this->create_question_mode = true;
663  $this->prepareOutput();
664 
665  $this->ctrl->setReturn($this, "questions");
666  require_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
667  $q_gui =& assQuestionGUI::_getQuestionGUI($_GET['sel_question_types'], $_GET["q_id"]);
668  $q_gui->object->setObjId($this->object->getId());
669  if(!$_GET['sel_question_types'])
670  $qType = assQuestion::getQuestionTypeFromDb($_GET['q_id']);
671  else
672  {
673  $qType = $_GET['sel_question_types'];
674  }
675  $this->ctrl->setParameterByClass($qType . "GUI", 'prev_qid', $_REQUEST['prev_qid']);
676  $this->ctrl->setParameterByClass($qType . "GUI", 'test_ref_id', $_REQUEST['ref_id']);
677  $this->ctrl->setParameterByClass($qType . "GUI", 'q_id', $_REQUEST['q_id']);
678  if($_REQUEST['test_express_mode'])
679  $this->ctrl->setParameterByClass($qType . "GUI", 'test_express_mode', 1);
680 
681  #global $___test_express_mode;
682  #$___test_express_mode = true;
683  if(!$q_gui->isSaveCommand())
684  $_GET['calling_test'] = $this->object->getRefId();
685 
686  $q_gui->setQuestionTabs();
687  #unset($___test_express_mode);
688  $ret =& $this->ctrl->forwardCommand($q_gui);
689  break;
690  }
691  if ( !in_array(strtolower($_GET["baseClass"]), array('iladministrationgui', 'ilrepositorygui')) &&
692  $this->getCreationMode() != true)
693  {
694  $this->tpl->show();
695  }
696  }
697 
698  private function questionsTabGatewayObject()
699  {
700  switch( $this->object->getQuestionSetType() )
701  {
703  $this->ctrl->redirectByClass('ilTestExpressPageObjectGUI', 'showPage');
704 
706  $this->ctrl->redirectByClass('ilTestRandomQuestionSetConfigGUI');
707 
709  $this->ctrl->redirectByClass('ilObjTestDynamicQuestionSetConfigGUI');
710  }
711  }
712 
721  public function createUserResults($show_pass_details, $show_answers, $show_reached_points, $show_user_results)
722  {
723  global $ilTabs, $ilDB;
724 
725  $ilTabs->setBackTarget(
726  $this->lng->txt('back'), $this->ctrl->getLinkTarget($this, 'participants')
727  );
728 
729  $template = new ilTemplate("tpl.il_as_tst_participants_result_output.html", TRUE, TRUE, "Modules/Test");
730 
731  require_once 'Modules/Test/classes/toolbars/class.ilTestResultsToolbarGUI.php';
732  $toolbar = new ilTestResultsToolbarGUI($this->ctrl, $this->tpl, $this->lng);
733 
734  $this->ctrl->setParameter($this, 'pdf', '1');
735  $toolbar->setPdfExportLinkTarget( $this->ctrl->getLinkTarget($this, $this->ctrl->getCmd()) );
736  $this->ctrl->setParameter($this, 'pdf', '');
737 
738  if( $show_answers )
739  {
740  if( isset($_GET['show_best_solutions']) )
741  {
742  $_SESSION['tst_results_show_best_solutions'] = true;
743  }
744  elseif( isset($_GET['hide_best_solutions']) )
745  {
746  $_SESSION['tst_results_show_best_solutions'] = false;
747  }
748  elseif( !isset($_SESSION['tst_results_show_best_solutions']) )
749  {
750  $_SESSION['tst_results_show_best_solutions'] = false;
751  }
752 
753  if( $_SESSION['tst_results_show_best_solutions'] )
754  {
755  $this->ctrl->setParameter($this, 'hide_best_solutions', '1');
756  $toolbar->setHideBestSolutionsLinkTarget($this->ctrl->getLinkTarget($this, 'showUserAnswers'));
757  $this->ctrl->setParameter($this, 'hide_best_solutions', '');
758  }
759  else
760  {
761  $this->ctrl->setParameter($this, 'show_best_solutions', '1');
762  $toolbar->setShowBestSolutionsLinkTarget($this->ctrl->getLinkTarget($this, 'showUserAnswers'));
763  $this->ctrl->setParameterByClass('', 'show_best_solutions', '');
764  }
765  }
766 
767  require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
768  $participantData = new ilTestParticipantData($ilDB, $this->lng);
769  if( $this->object->getFixedParticipants() )
770  {
771  $participantData->setUserIds($show_user_results);
772  }
773  else
774  {
775  $participantData->setActiveIds($show_user_results);
776  }
777  $participantData->load($this->object->getTestId());
778  $toolbar->setParticipantSelectorOptions($participantData->getOptionArray($show_user_results));
779 
780  $toolbar->build();
781  $template->setVariable('RESULTS_TOOLBAR', $this->ctrl->getHTML($toolbar));
782 
783  include_once "./Modules/Test/classes/class.ilTestServiceGUI.php";
784  $serviceGUI = new ilTestServiceGUI($this->object);
785  $serviceGUI->setParticipantData($participantData);
786 
787  $count = 0;
788  foreach ($show_user_results as $key => $active_id)
789  {
790  $count++;
791  $results = "";
792  if ($this->object->getFixedParticipants())
793  {
794  $active_id = $this->object->getActiveIdOfUser( $active_id );
795  }
796  if ($active_id > 0)
797  {
798  $results = $serviceGUI->getResultsOfUserOutput(
799  $this->testSessionFactory->getSession( $active_id ),
800  $active_id,
801  $this->object->_getResultPass( $active_id ),
802  $this,
803  $show_pass_details,
804  $show_answers,
805  FALSE,
806  $show_reached_points
807  );
808  }
809  if ($count < count( $show_user_results ))
810  {
811  $template->touchBlock( "break" );
812  }
813  $template->setCurrentBlock( "user_result" );
814  $template->setVariable( "USER_RESULT", $results );
815  $template->parseCurrentBlock();
816  }
817 
818  if( $this->isPdfDeliveryRequest() )
819  {
820  require_once 'class.ilTestPDFGenerator.php';
821 
823  $template->get(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->object->getTitle()
824  );
825  }
826  else
827  {
828  return $template;
829  }
830  }
831 
833  {
834  require_once 'Modules/Test/classes/class.ilObjTestSettingsGeneralGUI.php';
835  $this->ctrl->redirectByClass('ilObjTestSettingsGeneralGUI', ilObjTestSettingsGeneralGUI::CMD_SHOW_FORM);
836  }
837 
846  private function prepareSubGuiOutput()
847  {
848  global $ilUser;
849 
850  $this->tpl->getStandardTemplate();
851 
852  // set locator
853  $this->setLocator();
854 
855  // catch feedback message
857 
858  // set title and description and title icon
859  $this->setTitleAndDescription();
860 
861  // BEGIN WebDAV: Display Mount Webfolder icon.
862  require_once 'Services/WebDAV/classes/class.ilDAVServer.php';
863  if (ilDAVServer::_isActive() && $ilUser->getId() != ANONYMOUS_USER_ID)
864  {
865  $this->showMountWebfolderIcon();
866  }
867  // END WebDAV: Display Mount Webfolder icon.
868  }
869 
870  function runObject()
871  {
872  $this->ctrl->redirect($this, "infoScreen");
873  }
874 
876  {
877  $this->ctrl->redirectByClass("iltestevaluationgui", "outEvaluation");
878  }
879 
883  function importFileObject()
884  {
885  $form = $this->initImportForm($_REQUEST["new_type"]);
886  if($form->checkInput())
887  {
888  $this->ctrl->setParameter($this, "new_type", $this->type);
889  $this->uploadTstObject();
890  }
891 
892  // display form to correct errors
893  $form->setValuesByPost();
894  $this->tpl->setContent($form->getHTML());
895  }
896 
897  function addDidacticTemplateOptions(array &$a_options)
898  {
899  include_once("./Modules/Test/classes/class.ilObjTest.php");
900  $tst = new ilObjTest();
901  $defaults = $tst->getAvailableDefaults();
902  if (count($defaults))
903  {
904  foreach ($defaults as $row)
905  {
906  $a_options["tstdef_".$row["test_defaults_id"]] = array($row["name"],
907  $this->lng->txt("tst_default_settings"));
908  }
909  }
910 
911  // using template?
912  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
914  if($templates)
915  {
916  foreach($templates as $item)
917  {
918  $a_options["tsttpl_".$item["id"]] = array($item["title"],
919  nl2br(trim($item["description"])));
920  }
921  }
922  }
923 
928  function afterSave(ilObject $a_new_object)
929  {
930  $tstdef = $this->getDidacticTemplateVar("tstdef");
931  if ($tstdef)
932  {
933  $testDefaultsId = $tstdef;
934  $testDefaults = ilObjTest::_getTestDefaults($testDefaultsId);
935  $a_new_object->applyDefaults($testDefaults);
936  }
937 
938  $template_id = $this->getDidacticTemplateVar("tsttpl");
939  if($template_id)
940  {
941  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
943 
944  $template_settings = $template->getSettings();
945  if($template_settings)
946  {
947  $this->applyTemplate($template_settings, $a_new_object);
948  }
949 
950  $a_new_object->setTemplate($template_id);
951  }
952 
953  $a_new_object->saveToDb();
954 
955  // always send a message
956  ilUtil::sendSuccess($this->lng->txt("object_added"),true);
957  $this->ctrl->setParameter($this, 'ref_id', $a_new_object->getRefId());
958  $this->ctrl->redirectByClass('ilObjTestSettingsGeneralGUI');
959  }
960 
962  {
963  include_once "./Services/Utilities/classes/class.ilUtil.php";
964  $path = $this->tree->getPathFull($this->object->getRefID());
965  ilUtil::redirect($this->getReturnLocation("cancel","./ilias.php?baseClass=ilRepositoryGUI&cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
966  }
967 
971  function uploadTstObject()
972  {
973  if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK)
974  {
975  ilUtil::sendFailure($this->lng->txt("error_upload"));
976  $this->createObject();
977  return;
978  }
979  include_once("./Modules/Test/classes/class.ilObjTest.php");
980  // create import directory
982 
983  // copy uploaded file to import directory
984  $file = pathinfo($_FILES["xmldoc"]["name"]);
985  $full_path = $basedir."/".$_FILES["xmldoc"]["name"];
986  ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path);
987 
988  // unzip file
989  ilUtil::unzip($full_path);
990 
991  // determine filenames of xml files
992  $subdir = basename($file["basename"],".".$file["extension"]);
994  $xml_file = ilObjTest::_getImportDirectory().'/'.$subdir.'/'.$subdir.".xml";
995  $qti_file = ilObjTest::_getImportDirectory().'/'.$subdir.'/'. preg_replace("/test|tst/", "qti", $subdir).".xml";
996  $results_file = ilObjTest::_getImportDirectory().'/'.$subdir.'/'. preg_replace("/test|tst/", "results", $subdir).".xml";
997 
998  if(!is_file($qti_file))
999  {
1000  ilUtil::delDir($basedir);
1001  ilUtil::sendFailure($this->lng->txt("tst_import_non_ilias_zip"));
1002  $this->createObject();
1003  return;
1004  }
1005 
1006  // start verification of QTI files
1007  include_once "./Services/QTI/classes/class.ilQTIParser.php";
1008  $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, "");
1009  $result = $qtiParser->startParsing();
1010  $founditems =& $qtiParser->getFoundItems();
1011 
1012  if (count($founditems) == 0)
1013  {
1014  // nothing found
1015 
1016  // delete import directory
1017  ilUtil::delDir($basedir);
1018 
1019  ilUtil::sendInfo($this->lng->txt("tst_import_no_items"));
1020  $this->createObject();
1021  return;
1022  }
1023 
1024  $complete = 0;
1025  $incomplete = 0;
1026  foreach ($founditems as $item)
1027  {
1028  if (strlen($item["type"]))
1029  {
1030  $complete++;
1031  }
1032  else
1033  {
1034  $incomplete++;
1035  }
1036  }
1037 
1038  if ($complete == 0)
1039  {
1040  // delete import directory
1041  ilUtil::delDir($basedir);
1042 
1043  ilUtil::sendInfo($this->lng->txt("qpl_import_non_ilias_files"));
1044  $this->createObject();
1045  return;
1046  }
1047 
1048  $_SESSION["tst_import_results_file"] = $results_file;
1049  $_SESSION["tst_import_xml_file"] = $xml_file;
1050  $_SESSION["tst_import_qti_file"] = $qti_file;
1051  $_SESSION["tst_import_subdir"] = $subdir;
1052  // display of found questions
1053  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.tst_import_verification.html", "Modules/Test");
1054  $row_class = array("tblrow1", "tblrow2");
1055  $counter = 0;
1056  foreach ($founditems as $item)
1057  {
1058  $this->tpl->setCurrentBlock("verification_row");
1059  $this->tpl->setVariable("ROW_CLASS", $row_class[$counter++ % 2]);
1060  $this->tpl->setVariable("QUESTION_TITLE", $item["title"]);
1061  $this->tpl->setVariable("QUESTION_IDENT", $item["ident"]);
1062  include_once "./Services/QTI/classes/class.ilQTIItem.php";
1063  switch ($item["type"])
1064  {
1065  case "MULTIPLE CHOICE QUESTION":
1066  case QT_MULTIPLE_CHOICE_MR:
1067  //$this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("qt_multiple_choice"));
1068  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assMultipleChoice"));
1069  break;
1070  case "SINGLE CHOICE QUESTION":
1071  case QT_MULTIPLE_CHOICE_SR:
1072  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assSingleChoice"));
1073  break;
1075  case QT_KPRIM_CHOICE:
1076  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assKprimChoice"));
1077  break;
1078  case "NUMERIC QUESTION":
1079  case QT_NUMERIC:
1080  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assNumeric"));
1081  break;
1082  case "TEXTSUBSET QUESTION":
1083  case QT_TEXTSUBSET:
1084  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextSubset"));
1085  break;
1086  case "CLOZE QUESTION":
1087  case QT_CLOZE:
1088  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assClozeTest"));
1089  break;
1090  case "IMAGE MAP QUESTION":
1091  case QT_IMAGEMAP:
1092  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assImagemapQuestion"));
1093  break;
1094  case "JAVA APPLET QUESTION":
1095  case QT_JAVAAPPLET:
1096  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assJavaApplet"));
1097  break;
1098  case "MATCHING QUESTION":
1099  case QT_MATCHING:
1100  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assMatchingQuestion"));
1101  break;
1102  case "ORDERING QUESTION":
1103  case QT_ORDERING:
1104  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assOrderingQuestion"));
1105  break;
1106  case "TEXT QUESTION":
1107  case QT_TEXT:
1108  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextQuestion"));
1109  break;
1110  }
1111  $this->tpl->parseCurrentBlock();
1112  }
1113 
1114  // on import creation screen the pool was chosen (-1 for no pool)
1115  // BUT when no pool is available the input on creation screen is missing, so the field value -1 for no pool is not submitted.
1116  $QplOrTstID = isset($_POST["qpl"]) && (int)$_POST["qpl"] != 0 ? $_POST["qpl"] : -1;
1117 
1118  $this->tpl->setCurrentBlock("adm_content");
1119  $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt("question_type"));
1120  $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("question_title"));
1121  $this->tpl->setVariable("FOUND_QUESTIONS_INTRODUCTION", $this->lng->txt("tst_import_verify_found_questions"));
1122  $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_tst"));
1123  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1124  $this->tpl->setVariable("ARROW", ilUtil::getImagePath("arrow_downright.svg"));
1125  $this->tpl->setVariable("QUESTIONPOOL_ID", $QplOrTstID);
1126  $this->tpl->setVariable("VALUE_IMPORT", $this->lng->txt("import"));
1127  $this->tpl->setVariable("VALUE_CANCEL", $this->lng->txt("cancel"));
1128  $this->tpl->parseCurrentBlock();
1129  }
1130 
1135  {
1136  include_once "./Modules/Test/classes/class.ilObjTest.php";
1137  // create new questionpool object
1138  $newObj = new ilObjTest(0, true);
1139  // set type of questionpool object
1140  $newObj->setType($_GET["new_type"]);
1141  // set title of questionpool object to "dummy"
1142  $newObj->setTitle("dummy");
1143  // set description of questionpool object
1144  $newObj->setDescription("test import");
1145  // create the questionpool class in the ILIAS database (object_data table)
1146  $newObj->create(true);
1147  // create a reference for the questionpool object in the ILIAS database (object_reference table)
1148  $newObj->createReference();
1149  // put the questionpool object in the administration tree
1150  $newObj->putInTree($_GET["ref_id"]);
1151  // get default permissions and set the permissions for the questionpool object
1152  $newObj->setPermissions($_GET["ref_id"]);
1153  // notify the questionpool object and all its parent objects that a "new" object was created
1154  $newObj->notify("new",$_GET["ref_id"],$_GET["parent_non_rbac_id"],$_GET["ref_id"],$newObj->getRefId());
1155  // empty mark schema
1156  $newObj->mark_schema->flush();
1157 
1158  // start parsing of QTI files
1159  include_once "./Services/QTI/classes/class.ilQTIParser.php";
1160 
1161  // Handle selection of "no questionpool" as qpl_id = -1 -> use test object id instead.
1162  // TODO: chek if empty strings in $_POST["qpl_id"] relates to a bug or not
1163  if ($_POST["qpl_id"] == "-1")
1164  {
1165  $qpl_id = $newObj->id;
1166  }
1167  else
1168  {
1169  $qpl_id = $_POST["qpl_id"];
1170  }
1171 
1172  $qtiParser = new ilQTIParser($_SESSION["tst_import_qti_file"], IL_MO_PARSE_QTI, $qpl_id, $_POST["ident"]);
1173  $qtiParser->setTestObject($newObj);
1174  $result = $qtiParser->startParsing();
1175  $newObj->saveToDb();
1176 
1177  // import page data
1178  include_once ("./Modules/LearningModule/classes/class.ilContObjParser.php");
1179  $contParser = new ilContObjParser($newObj, $_SESSION["tst_import_xml_file"], $_SESSION["tst_import_subdir"]);
1180  $contParser->setQuestionMapping($qtiParser->getImportMapping());
1181  $contParser->startParsing();
1182 
1183  // import test results
1184  if (@file_exists($_SESSION["tst_import_results_file"]))
1185  {
1186  include_once ("./Modules/Test/classes/class.ilTestResultsImportParser.php");
1187  $results = new ilTestResultsImportParser($_SESSION["tst_import_results_file"], $newObj);
1188  $results->startParsing();
1189  }
1190 
1191  // delete import directory
1193  ilUtil::sendSuccess($this->lng->txt("object_imported"),true);
1194 
1195  $newObj->updateMetaData();
1196 
1197  ilUtil::redirect("ilias.php?ref_id=".$newObj->getRefId().
1198  "&baseClass=ilObjTestGUI");
1199  }
1200 
1207  function uploadObject($redirect = true)
1208  {
1209  $this->uploadTstObject();
1210  }
1211 
1216  {
1217  $file = explode("_", $_GET["file_id"]);
1218  include_once("./Modules/File/classes/class.ilObjFile.php");
1219  $fileObj =& new ilObjFile($file[count($file) - 1], false);
1220  $fileObj->sendFile();
1221  exit;
1222  }
1223 
1227  function fullscreenObject()
1228  {
1229  include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php");
1230  $page_gui = new ilAssQuestionPageGUI($_GET["pg_id"]);
1231  $page_gui->showMediaFullscreen();
1232 
1233  }
1234 
1239  {
1240  include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php");
1241  $pg_obj = new ilAssQuestionPage($_GET["pg_id"]);
1242  $pg_obj->send_paragraph ($_GET["par_id"], $_GET["downloadtitle"]);
1243  exit;
1244  }
1245 
1253  function filterObject()
1254  {
1255  $this->questionBrowser();
1256  }
1257 
1266  {
1267  $this->questionBrowser();
1268  }
1269 
1277  function backObject()
1278  {
1279  $this->ctrl->redirect($this, "questions");
1280  }
1281 
1290  function createQuestionPool($name = "dummy", $description = "")
1291  {
1292  global $tree;
1293  $parent_ref = $tree->getParentId($this->object->getRefId());
1294  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
1295  $qpl = new ilObjQuestionPool();
1296  $qpl->setType("qpl");
1297  $qpl->setTitle($name);
1298  $qpl->setDescription($description);
1299  $qpl->create();
1300  $qpl->createReference();
1301  $qpl->putInTree($parent_ref);
1302  $qpl->setPermissions($parent_ref);
1303  $qpl->setOnline(1); // must be online to be available
1304  $qpl->saveToDb();
1305  return $qpl->getRefId();
1306  }
1307 
1311  public function randomselectObject()
1312  {
1313  global $ilUser;
1314  $this->getQuestionsSubTabs();
1315  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_random_select.html", "Modules/Test");
1316  $questionpools =& $this->object->getAvailableQuestionpools(FALSE, FALSE, FALSE, TRUE);
1317  $this->tpl->setCurrentBlock("option");
1318  $this->tpl->setVariable("VALUE_OPTION", "0");
1319  $this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("all_available_question_pools"));
1320  $this->tpl->parseCurrentBlock();
1321  foreach ($questionpools as $key => $value)
1322  {
1323  $this->tpl->setCurrentBlock("option");
1324  $this->tpl->setVariable("VALUE_OPTION", $key);
1325  $this->tpl->setVariable("TEXT_OPTION", $value["title"]);
1326  $this->tpl->parseCurrentBlock();
1327  }
1328  $this->tpl->setCurrentBlock("hidden");
1329  $this->tpl->setVariable("HIDDEN_NAME", "sel_question_types");
1330  $this->tpl->setVariable("HIDDEN_VALUE", $_POST["sel_question_types"]);
1331  $this->tpl->parseCurrentBlock();
1332  $this->tpl->setCurrentBlock("adm_content");
1333  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
1334  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_random_select_questionpool"));
1335  $this->tpl->setVariable("TXT_NR_OF_QUESTIONS", $this->lng->txt("tst_random_nr_of_questions"));
1336  $this->tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit"));
1337  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
1338  $this->tpl->parseCurrentBlock();
1339  }
1340 
1349  {
1350  $this->ctrl->redirect($this, "questions");
1351  }
1352 
1361  {
1362  $this->getQuestionsSubTabs();
1363  $question_array = $this->object->randomSelectQuestions($_POST["nr_of_questions"], $_POST["sel_qpl"]);
1364  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_random_question_offer.html", "Modules/Test");
1365  $color_class = array("tblrow1", "tblrow2");
1366  $counter = 0;
1367  $questionpools =& $this->object->getAvailableQuestionpools(true);
1368  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
1369  foreach ($question_array as $question_id)
1370  {
1371  $dataset = $this->object->getQuestionDataset($question_id);
1372  $this->tpl->setCurrentBlock("QTab");
1373  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
1374  $this->tpl->setVariable("QUESTION_TITLE", $dataset->title);
1375  $this->tpl->setVariable("QUESTION_COMMENT", $dataset->description);
1376  $this->tpl->setVariable("QUESTION_TYPE", assQuestion::_getQuestionTypeName($dataset->type_tag));
1377  $this->tpl->setVariable("QUESTION_AUTHOR", $dataset->author);
1378  $this->tpl->setVariable("QUESTION_POOL", $questionpools[$dataset->obj_fi]["title"]);
1379  $this->tpl->parseCurrentBlock();
1380  $counter++;
1381  }
1382  if (count($question_array) == 0)
1383  {
1384  $this->tpl->setCurrentBlock("Emptytable");
1385  $this->tpl->setVariable("TEXT_NO_QUESTIONS_AVAILABLE", $this->lng->txt("no_questions_available"));
1386  $this->tpl->parseCurrentBlock();
1387  }
1388  else
1389  {
1390  $this->tpl->setCurrentBlock("Selectionbuttons");
1391  $this->tpl->setVariable("BTN_YES", $this->lng->txt("random_accept_sample"));
1392  $this->tpl->setVariable("BTN_NO", $this->lng->txt("random_another_sample"));
1393  $this->tpl->parseCurrentBlock();
1394  }
1395  $chosen_questions = join($question_array, ",");
1396  $this->tpl->setCurrentBlock("adm_content");
1397  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
1398  $this->tpl->setVariable("QUESTION_TITLE", $this->lng->txt("tst_question_title"));
1399  $this->tpl->setVariable("QUESTION_COMMENT", $this->lng->txt("description"));
1400  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("tst_question_type"));
1401  $this->tpl->setVariable("QUESTION_AUTHOR", $this->lng->txt("author"));
1402  $this->tpl->setVariable("QUESTION_POOL", $this->lng->txt("qpl"));
1403  $this->tpl->setVariable("VALUE_CHOSEN_QUESTIONS", $chosen_questions);
1404  $this->tpl->setVariable("VALUE_QUESTIONPOOL_SELECTION", $_POST["sel_qpl"]);
1405  $this->tpl->setVariable("VALUE_NR_OF_QUESTIONS", $_POST["nr_of_questions"]);
1406  $this->tpl->setVariable("TEXT_QUESTION_OFFER", $this->lng->txt("tst_question_offer"));
1407  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
1408  $this->tpl->parseCurrentBlock();
1409  }
1410 
1419  {
1420  $selected_array = split(",", $_POST["chosen_questions"]);
1421  if (!count($selected_array))
1422  {
1423  ilUtil::sendInfo($this->lng->txt("tst_insert_missing_question"));
1424  }
1425  else
1426  {
1427  $total = $this->object->evalTotalPersons();
1428  if ($total)
1429  {
1430  // the test was executed previously
1431  ilUtil::sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total));
1432  }
1433  else
1434  {
1435  ilUtil::sendInfo($this->lng->txt("tst_insert_questions"));
1436  }
1437  foreach ($selected_array as $key => $value)
1438  {
1439  $this->object->insertQuestion( $this->testQuestionSetConfigFactory->getQuestionSetConfig(), $value );
1440  }
1441  $this->object->saveCompleteStatus( $this->testQuestionSetConfigFactory->getQuestionSetConfig() );
1442  ilUtil::sendSuccess($this->lng->txt("tst_questions_inserted"), true);
1443  $this->ctrl->redirect($this, "questions");
1444  return;
1445  }
1446  }
1447 
1449  {
1450  $this->questionBrowser();
1451  }
1452 
1461  {
1462  $qpl_ref_id = $_REQUEST["sel_qpl"];
1463 
1464  $qpl_mode = $_REQUEST['usage'];
1465 
1466  if(isset($_REQUEST['qtype']))
1467  {
1468  include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
1469  $sel_question_types = ilObjQuestionPool::getQuestionTypeByTypeId($_REQUEST["qtype"]);
1470  }
1471  else if(isset($_REQUEST['sel_question_types']))
1472  {
1473  $sel_question_types = $_REQUEST["sel_question_types"];
1474  }
1475 
1476  if (!$qpl_mode || ($qpl_mode == 2 && strcmp($_REQUEST["txt_qpl"], "") == 0) || ($qpl_mode == 3 && strcmp($qpl_ref_id, "") == 0))
1477  //if ((strcmp($_REQUEST["txt_qpl"], "") == 0) && (strcmp($qpl_ref_id, "") == 0))
1478  {
1479  // Mantis #14890
1480  $_REQUEST['sel_question_types'] = $sel_question_types;
1481  ilUtil::sendInfo($this->lng->txt("questionpool_not_entered"));
1482  $this->createQuestionObject();
1483  return;
1484  }
1485  else
1486  {
1487  $_SESSION["test_id"] = $this->object->getRefId();
1488  if ($qpl_mode == 2 && strcmp($_REQUEST["txt_qpl"], "") != 0)
1489  {
1490  // create a new question pool and return the reference id
1491  $qpl_ref_id = $this->createQuestionPool($_REQUEST["txt_qpl"]);
1492  }
1493  else if ($qpl_mode == 1)
1494  {
1495  $qpl_ref_id = $_GET["ref_id"];
1496  }
1497 
1498  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPoolGUI.php";
1499  $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;
1500 
1501  if (isset($_REQUEST['prev_qid']))
1502  {
1503  $baselink .= '&prev_qid=' . $_REQUEST['prev_qid'];
1504  }
1505  else if(isset($_REQUEST['position']))
1506  {
1507  $baselink .= '&prev_qid=' . $_REQUEST['position'];
1508  }
1509 
1510  if ($_REQUEST['test_express_mode']) {
1511  $baselink .= '&test_express_mode=1';
1512  }
1513 
1514  if( isset($_REQUEST['add_quest_cont_edit_mode']) )
1515  {
1517  $baselink, "add_quest_cont_edit_mode={$_REQUEST['add_quest_cont_edit_mode']}", false
1518  );
1519  }
1520 
1521 #var_dump($_REQUEST['prev_qid']);
1522  ilUtil::redirect($baselink);
1523 
1524  exit();
1525  }
1526  }
1527 
1536  {
1537  $this->ctrl->redirect($this, "questions");
1538  }
1539 
1548  {
1549  global $ilUser;
1550  $this->getQuestionsSubTabs();
1551  //$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_qpl_select.html", "Modules/Test");
1552  $questionpools =& $this->object->getAvailableQuestionpools(FALSE, FALSE, FALSE, TRUE, FALSE, "write");
1553 
1554  if ($this->object->getPoolUsage()) {
1555  global $lng, $ilCtrl, $tpl;
1556 
1557  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
1558 
1559  $form = new ilPropertyFormGUI();
1560  $form->setFormAction($ilCtrl->getFormAction($this, "executeCreateQuestion"));
1561  $form->setTitle($lng->txt("ass_create_question"));
1562  include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
1563 
1564 
1565  $hidden = new ilHiddenInputGUI('sel_question_types');
1566  $hidden->setValue($_REQUEST["sel_question_types"]);
1567  $form->addItem($hidden);
1568 
1569  // content editing mode
1571  {
1572  $ri = new ilRadioGroupInputGUI($lng->txt("tst_add_quest_cont_edit_mode"), "add_quest_cont_edit_mode");
1573 
1574  $ri->addOption(new ilRadioOption(
1575  $lng->txt('tst_add_quest_cont_edit_mode_default'),
1577  ));
1578 
1579  $ri->addOption(new ilRadioOption(
1580  $lng->txt('tst_add_quest_cont_edit_mode_page_object'),
1582  ));
1583 
1585 
1586  $form->addItem($ri, true);
1587  }
1588  else
1589  {
1590  $hi = new ilHiddenInputGUI("question_content_editing_type");
1592  $form->addItem($hi, true);
1593  }
1594 
1595  // use pool
1596  $usage = new ilRadioGroupInputGUI($this->lng->txt("assessment_pool_selection"), "usage");
1597  $usage->setRequired(true);
1598  $no_pool = new ilRadioOption($this->lng->txt("assessment_no_pool"), 1);
1599  $usage->addOption($no_pool);
1600  $existing_pool = new ilRadioOption($this->lng->txt("assessment_existing_pool"), 3);
1601  $usage->addOption($existing_pool);
1602  $new_pool = new ilRadioOption($this->lng->txt("assessment_new_pool"), 2);
1603  $usage->addOption($new_pool);
1604  $form->addItem($usage);
1605 
1606  $usage->setValue(1);
1607 
1608  $questionpools = ilObjQuestionPool::_getAvailableQuestionpools(FALSE, FALSE, TRUE, FALSE, FALSE, "write");
1609  $pools_data = array();
1610  foreach($questionpools as $key => $p) {
1611  $pools_data[$key] = $p['title'];
1612  }
1613  $pools = new ilSelectInputGUI($this->lng->txt("select_questionpool"), "sel_qpl");
1614  $pools->setOptions($pools_data);
1615  $existing_pool->addSubItem($pools);
1616 
1617 
1618  $this->lng->loadLanguageModule('rbac');
1619  $name = new ilTextInputGUI($this->lng->txt("rbac_create_qpl"), "txt_qpl");
1620  $name->setSize(50);
1621  $name->setMaxLength(50);
1622  $new_pool->addSubItem($name);
1623 
1624  $form->addCommandButton("executeCreateQuestion", $lng->txt("submit"));
1625  $form->addCommandButton("cancelCreateQuestion", $lng->txt("cancel"));
1626 
1627  return $this->tpl->setVariable('ADM_CONTENT', $form->getHTML());
1628 
1629  }
1630  else {
1631  global $ilCtrl;
1632 
1633  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'sel_question_types', $_REQUEST["sel_question_types"]);
1634  $link = $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'handleToolbarCommand','',false,false);
1635  ilUtil::redirect($link);
1636  }
1637  }
1638 
1643  {
1644  $checked_questions = $_POST["q_id"];
1645 
1646  $questions = $this->object->getQuestionTitlesAndIndexes();
1647  $deleted = array();
1648  foreach((array)$checked_questions as $value)
1649  {
1650  $this->object->removeQuestion($value);
1651  $deleted[] = $value;
1652  }
1653 
1654  $this->object->saveCompleteStatus( $this->testQuestionSetConfigFactory->getQuestionSetConfig() );
1655 
1656  ilUtil::sendSuccess($this->lng->txt("tst_questions_removed"));
1657 
1658  if($_REQUEST['test_express_mode'])
1659  {
1660  $prev = null;
1661  $return_to = null;
1662  $deleted_tmp = $deleted;
1663  $first = array_shift($deleted_tmp);
1664  foreach((array)$questions as $key => $value)
1665  {
1666  if(!in_array($key, $deleted))
1667  {
1668  $prev = $key;
1669  if(!$first)
1670  {
1671  $return_to = $prev;
1672  break;
1673  }
1674  else continue;
1675  }
1676  else if($key == $first)
1677  {
1678  if($prev)
1679  {
1680  $return_to = $prev;
1681  break;
1682  }
1683  $first = array_shift($deleted_tmp);
1684  }
1685  }
1686 
1687  if(
1688  count($questions) == count($checked_questions) ||
1689  !$return_to
1690  )
1691  {
1692  $this->ctrl->setParameter($this, 'q_id', '');
1693  $this->ctrl->redirect($this, 'showPage');
1694  }
1695 
1696  $this->ctrl->setParameter($this, 'q_id', $return_to);
1697  $this->ctrl->redirect($this, "showPage");
1698  }
1699  else
1700  {
1701  $this->ctrl->setParameter($this, 'q_id', '');
1702  $this->ctrl->redirect($this, 'questions');
1703  }
1704  }
1705 
1714  {
1715  if ($_REQUEST['test_express_mode']) {
1716  $this->ctrl->setParameter($this, 'q_id', $_REQUEST['q_id']);
1717  $this->ctrl->redirect($this, "showPage");
1718  }
1719  else {
1720  $this->ctrl->redirect($this, "questions");
1721  }
1722  }
1723 
1731  function removeQuestionsForm($checked_questions)
1732  {
1733  $total = $this->object->evalTotalPersons();
1734  if ($total)
1735  {
1736  // the test was executed previously
1737  $question = sprintf($this->lng->txt("tst_remove_questions_and_results"), $total);
1738  }
1739  else
1740  {
1741  if (count($checked_questions) == 1)
1742  {
1743  $question = $this->lng->txt("tst_remove_question");
1744  }
1745  else
1746  {
1747  $question = $this->lng->txt("tst_remove_questions");
1748  }
1749  }
1750 
1751  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1752  $cgui = new ilConfirmationGUI();
1753  $cgui->setHeaderText($question);
1754 
1755  $this->ctrl->saveParameter($this, 'test_express_mode');
1756  $this->ctrl->saveParameter($this, 'q_id');
1757 
1758  $cgui->setFormAction($this->ctrl->getFormAction($this));
1759  $cgui->setCancel($this->lng->txt("cancel"), "cancelRemoveQuestions");
1760  $cgui->setConfirm($this->lng->txt("confirm"), "confirmRemoveQuestions");
1761 
1762  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
1763  $removablequestions =& $this->object->getTestQuestions();
1764  if (count($removablequestions))
1765  {
1766  foreach ($removablequestions as $data)
1767  {
1768  if (in_array($data["question_id"], $checked_questions))
1769  {
1770  $txt = $data["title"]." (".assQuestion::_getQuestionTypeName($data["type_tag"]).")";
1771  $txt .= ' ['. $this->lng->txt('question_id_short') . ': ' . $data['question_id'] . ']';
1772 
1773  if($data["description"])
1774  {
1775  $txt .= "<div class=\"small\">".$data["description"]."</div>";
1776  }
1777 
1778  $cgui->addItem("q_id[]", $data["question_id"], $txt);
1779  }
1780  }
1781  }
1782 
1783  $this->tpl->setContent($cgui->getHTML());
1784  }
1785 
1794  {
1795  $this->getQuestionsSubTabs();
1796  $checked_questions = $_REQUEST["q_id"];
1797  if (!is_array($checked_questions) && $checked_questions) {
1798  $checked_questions = array($checked_questions);
1799  }
1800  if (count($checked_questions) > 0)
1801  {
1802  $this->removeQuestionsForm($checked_questions);
1803  return;
1804  }
1805  elseif (count($checked_questions) == 0)
1806  {
1807  ilUtil::sendFailure($this->lng->txt("tst_no_question_selected_for_removal"), true);
1808  $this->ctrl->redirect($this, "questions");
1809  }
1810  }
1811 
1816  {
1817  $selected_questions = NULL;
1818  $selected_questions = $_POST['q_id'];
1819  if (is_array($selected_questions))
1820  {
1821  $_SESSION['tst_qst_move_' . $this->object->getTestId()] = $_POST['q_id'];
1822  ilUtil::sendSuccess($this->lng->txt("msg_selected_for_move"), true);
1823  }
1824  else
1825  {
1826  ilUtil::sendFailure($this->lng->txt('no_selection_for_move'), TRUE);
1827  }
1828  $this->ctrl->redirect($this, 'questions');
1829  }
1830 
1835  {
1836  // get all questions to move
1837  $move_questions = $_SESSION['tst_qst_move_' . $this->object->getTestId()];
1838 
1839  if (count($_POST['q_id']) == 0)
1840  {
1841  ilUtil::sendFailure($this->lng->txt("no_target_selected_for_move"), true);
1842  $this->ctrl->redirect($this, 'questions');
1843  }
1844  if (count($_POST['q_id']) > 1)
1845  {
1846  ilUtil::sendFailure($this->lng->txt("too_many_targets_selected_for_move"), true);
1847  $this->ctrl->redirect($this, 'questions');
1848  }
1849  $insert_mode = 0;
1850  $this->object->moveQuestions($_SESSION['tst_qst_move_' . $this->object->getTestId()], $_POST['q_id'][0], $insert_mode);
1851  ilUtil::sendSuccess($this->lng->txt("msg_questions_moved"), true);
1852  unset($_SESSION['tst_qst_move_' . $this->object->getTestId()]);
1853  $this->ctrl->redirect($this, "questions");
1854  }
1855 
1859  public function insertQuestionsAfterObject()
1860  {
1861  // get all questions to move
1862  $move_questions = $_SESSION['tst_qst_move_' . $this->object->getTestId()];
1863  if (count($_POST['q_id']) == 0)
1864  {
1865  ilUtil::sendFailure($this->lng->txt("no_target_selected_for_move"), true);
1866  $this->ctrl->redirect($this, 'questions');
1867  }
1868  if (count($_POST['q_id']) > 1)
1869  {
1870  ilUtil::sendFailure($this->lng->txt("too_many_targets_selected_for_move"), true);
1871  $this->ctrl->redirect($this, 'questions');
1872  }
1873  $insert_mode = 1;
1874  $this->object->moveQuestions($_SESSION['tst_qst_move_' . $this->object->getTestId()], $_POST['q_id'][0], $insert_mode);
1875  ilUtil::sendSuccess($this->lng->txt("msg_questions_moved"), true);
1876  unset($_SESSION['tst_qst_move_' . $this->object->getTestId()]);
1877  $this->ctrl->redirect($this, "questions");
1878  }
1879 
1886  {
1887  $selected_array = (is_array($_POST['q_id'])) ? $_POST['q_id'] : array();
1888  if (!count($selected_array))
1889  {
1890  ilUtil::sendInfo($this->lng->txt("tst_insert_missing_question"), true);
1891  $this->ctrl->redirect($this, "browseForQuestions");
1892  }
1893  else
1894  {
1895  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
1896  $manscoring = FALSE;
1897  foreach ($selected_array as $key => $value)
1898  {
1899  $this->object->insertQuestion( $this->testQuestionSetConfigFactory->getQuestionSetConfig(), $value );
1900  if (!$manscoring)
1901  {
1902  $manscoring = $manscoring | assQuestion::_needsManualScoring($value);
1903  }
1904  }
1905  $this->object->saveCompleteStatus( $this->testQuestionSetConfigFactory->getQuestionSetConfig() );
1906  if ($manscoring)
1907  {
1908  ilUtil::sendInfo($this->lng->txt("manscoring_hint"), TRUE);
1909  }
1910  else
1911  {
1912  ilUtil::sendSuccess($this->lng->txt("tst_questions_inserted"), TRUE);
1913  }
1914  $this->ctrl->redirect($this, "questions");
1915  return;
1916  }
1917  }
1918 
1920  {
1921  include_once "./Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php";
1922  $table_gui = new ilTestQuestionBrowserTableGUI($this, 'browseForQuestions', $this->ref_id);
1923  $table_gui->resetOffset();
1924  $table_gui->writeFilterToSession();
1925  $this->ctrl->redirect($this, "browseForQuestions");
1926  }
1927 
1929  {
1930  include_once "./Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php";
1931  $table_gui = new ilTestQuestionBrowserTableGUI($this, 'browseForQuestions', $this->ref_id);
1932  $table_gui->resetOffset();
1933  $table_gui->resetFilter();
1934  $this->ctrl->redirect($this, "browseForQuestions");
1935  }
1936 
1942  function questionBrowser()
1943  {
1944  global $ilAccess;
1945 
1946  $this->ctrl->setParameterByClass(get_class($this), "browse", "1");
1947 
1948  include_once "./Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php";
1949  $table_gui = new ilTestQuestionBrowserTableGUI($this, 'browseForQuestions', $this->ref_id, (($ilAccess->checkAccess("write", "", $this->ref_id) ? true : false)));
1950  $arrFilter = array();
1951  foreach ($table_gui->getFilterItems() as $item)
1952  {
1953  if ($item->getValue() !== false)
1954  {
1955  $arrFilter[$item->getPostVar()] = $item->getValue();
1956  }
1957  }
1958  $data = $this->object->getAvailableQuestions($arrFilter, 1);
1959  $table_gui->setData($data);
1960  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
1961  }
1962 
1963  public function addQuestionObject()
1964  {
1965  global $lng, $ilCtrl, $tpl;
1966 
1967  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
1968 
1969  $ilCtrl->setParameter($this, 'qtype', $_REQUEST['qtype']);
1970 
1971  $form = new ilPropertyFormGUI();
1972 
1973  $form->setFormAction($ilCtrl->getFormAction($this, "executeCreateQuestion"));
1974  $form->setTitle($lng->txt("ass_create_question"));
1975  include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
1976 
1977  $pool = new ilObjQuestionPool();
1978  $questionTypes = $pool->getQuestionTypes(false, true);
1979  $options = array();
1980 
1981  // question type
1982  foreach($questionTypes as $label => $data)
1983  {
1984  $options[$data['question_type_id']] = $label;
1985  }
1986 
1987  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
1988  $si = new ilSelectInputGUI($lng->txt("question_type"), "qtype");
1989  $si->setOptions($options);
1990  $form->addItem($si, true);
1991 
1992  // position
1993  $questions = $this->object->getQuestionTitlesAndIndexes();
1994  if($questions)
1995  {
1996  $si = new ilSelectInputGUI($lng->txt("position"), "position");
1997  $options = array('0' => $lng->txt('first'));
1998  foreach($questions as $key => $title)
1999  {
2000  $options[$key] = $lng->txt('behind') . ' '. $title . ' ['.$this->lng->txt('question_id_short') . ': '. $key .']';
2001  }
2002  $si->setOptions($options);
2003  $si->setValue($_REQUEST['q_id']);
2004  $form->addItem($si, true);
2005  }
2006 
2007  // content editing mode
2009  {
2010  $ri = new ilRadioGroupInputGUI($lng->txt("tst_add_quest_cont_edit_mode"), "add_quest_cont_edit_mode");
2011 
2012  $ri->addOption(new ilRadioOption(
2013  $lng->txt('tst_add_quest_cont_edit_mode_default'),
2015  ));
2016 
2017  $ri->addOption(new ilRadioOption(
2018  $lng->txt('tst_add_quest_cont_edit_mode_page_object'),
2020  ));
2021 
2023 
2024  $form->addItem($ri, true);
2025  }
2026  else
2027  {
2028  $hi = new ilHiddenInputGUI("question_content_editing_type");
2030  $form->addItem($hi, true);
2031  }
2032 
2033  if($this->object->getPoolUsage())
2034  {
2035  // use pool
2036  $usage = new ilRadioGroupInputGUI($this->lng->txt("assessment_pool_selection"), "usage");
2037  $usage->setRequired(true);
2038  $no_pool = new ilRadioOption($this->lng->txt("assessment_no_pool"), 1);
2039  $usage->addOption($no_pool);
2040  $existing_pool = new ilRadioOption($this->lng->txt("assessment_existing_pool"), 3);
2041  $usage->addOption($existing_pool);
2042  $new_pool = new ilRadioOption($this->lng->txt("assessment_new_pool"), 2);
2043  $usage->addOption($new_pool);
2044  $form->addItem($usage);
2045 
2046  $usage->setValue(1);
2047 
2048  $questionpools = ilObjQuestionPool::_getAvailableQuestionpools(FALSE, FALSE, TRUE, FALSE, FALSE, "write");
2049  $pools_data = array();
2050  foreach($questionpools as $key => $p)
2051  {
2052  $pools_data[$key] = $p['title'];
2053  }
2054  $pools = new ilSelectInputGUI($this->lng->txt("select_questionpool"), "sel_qpl");
2055  $pools->setOptions($pools_data);
2056  $existing_pool->addSubItem($pools);
2057 
2058  $name = new ilTextInputGUI($this->lng->txt("name"), "txt_qpl");
2059  $name->setSize(50);
2060  $name->setMaxLength(50);
2061  $new_pool->addSubItem($name);
2062  }
2063 
2064  $form->addCommandButton("executeCreateQuestion", $lng->txt("submit"));
2065  $form->addCommandButton("questions", $lng->txt("cancel"));
2066 
2067  return $tpl->setContent($form->getHTML());
2068  }
2069 
2070  function questionsObject()
2071  {
2072  global $ilAccess, $ilTabs;
2073 
2074  $ilTabs->activateTab('assQuestions');
2075 
2076  // #12590
2077  $this->ctrl->setParameter($this, 'test_express_mode', '');
2078 
2079  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
2080  {
2081  // allow only write access
2082  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
2083  $this->ctrl->redirect($this, "infoScreen");
2084  }
2085 
2086  if ($_GET['browse'])
2087  {
2088  return $this->questionbrowser();
2089  }
2090 
2091  $this->getQuestionsSubTabs();
2092 
2093  // #11631, #12994
2094  $this->ctrl->setParameter($this, 'q_id', '');
2095 
2096  if ($_GET["eqid"] && $_GET["eqpl"])
2097  {
2098  ilUtil::redirect("ilias.php?baseClass=ilObjQuestionPoolGUI&ref_id=" . $_GET["eqpl"] . "&cmd=editQuestionForTest&calling_test=".$_GET["ref_id"]."&q_id=" . $_GET["eqid"]);
2099  }
2100 
2101  if ($_GET["up"] > 0)
2102  {
2103  $this->object->questionMoveUp($_GET["up"]);
2104  }
2105  if ($_GET["down"] > 0)
2106  {
2107  $this->object->questionMoveDown($_GET["down"]);
2108  }
2109 
2110  if ($_GET["add"])
2111  {
2112  $selected_array = array();
2113  array_push($selected_array, $_GET["add"]);
2114  $total = $this->object->evalTotalPersons();
2115  if ($total)
2116  {
2117  // the test was executed previously
2118  ilUtil::sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total));
2119  }
2120  else
2121  {
2122  ilUtil::sendInfo($this->lng->txt("tst_insert_questions"));
2123  }
2124  $this->insertQuestions($selected_array);
2125  return;
2126  }
2127 
2128  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_questions.html", "Modules/Test");
2129 
2130  $total = $this->object->evalTotalPersons();
2131  if ($ilAccess->checkAccess("write", "", $this->ref_id))
2132  {
2133  if($total != 0)
2134  {
2135  $link = $this->ctrl->getLinkTarget($this, "participants");
2136  $link = "<a href=\"".$link."\">".$this->lng->txt("test_has_datasets_warning_page_view_link")."</a>";
2137  ilUtil::sendInfo($this->lng->txt("test_has_datasets_warning_page_view")." ".$link);
2138  }
2139  else {
2140  global $ilToolbar;
2141 
2142  $ilToolbar->addButton($this->lng->txt("ass_create_question"), $this->ctrl->getLinkTarget($this, "addQuestion"));
2143 
2144  if ($this->object->getPoolUsage()) {
2145  $ilToolbar->addSeparator();
2146  $ilToolbar->addButton($this->lng->txt("tst_browse_for_questions"), $this->ctrl->getLinkTarget($this, 'browseForQuestions'));
2147  }
2148 
2149  $ilToolbar->addSeparator();
2150  $ilToolbar->addButton($this->lng->txt("random_selection"), $this->ctrl->getLinkTarget($this, "randomselect"));
2151 
2152 
2153  global $ilAccess, $ilUser, $lng, $ilCtrl;
2154  $online_access = false;
2155  if ($this->object->getFixedParticipants())
2156  {
2157  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
2158  $online_access_result = ilObjTestAccess::_lookupOnlineTestAccess($this->object->getId(), $ilUser->getId());
2159  if ($online_access_result === true)
2160  {
2161  $online_access = true;
2162  }
2163  }
2164 
2165  if( $this->object->isOnline() && $this->object->isComplete( $this->testQuestionSetConfigFactory->getQuestionSetConfig() ) )
2166  {
2167  if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id))
2168  {
2169  $testSession = $this->testSessionFactory->getSession();
2170  $testSequence = $this->testSequenceFactory->getSequence($testSession);
2171 
2172  $testPlayerGUI = $this->testPlayerFactory->getPlayerGUI();
2173 
2174  $executable = $this->object->isExecutable($testSession, $ilUser->getId(), $allowPassIncrease = TRUE);
2175 
2176  if ($executable["executable"])
2177  {
2178  if ($testSession->getActiveId() > 0)
2179  {
2180  // resume test
2181 
2182  if ($testSequence->hasStarted($testSession))
2183  {
2184  $execTestLabel = $this->lng->txt("tst_resume_test");
2185  $execTestLink = $this->ctrl->getLinkTarget($testPlayerGUI, 'resumePlayer');
2186  }
2187  else
2188  {
2189  $execTestLabel = $this->object->getStartTestLabel($testSession->getActiveId());
2190  $execTestLink = $this->ctrl->getLinkTarget($testPlayerGUI, 'startPlayer');
2191  }
2192  }
2193  else
2194  {
2195  // start new test
2196 
2197  $execTestLabel = $this->object->getStartTestLabel($testSession->getActiveId());
2198  $execTestLink = $this->ctrl->getLinkTarget($testPlayerGUI, 'startPlayer');
2199  }
2200 
2201  $ilToolbar->addSeparator();
2202  $ilToolbar->addButton($execTestLabel, $execTestLink);
2203  }
2204  }
2205  }
2206 
2207 
2208  }
2209  }
2210 
2211  $this->tpl->setCurrentBlock("adm_content");
2212  include_once "./Modules/Test/classes/tables/class.ilTestQuestionsTableGUI.php";
2213  $checked_move = is_array($_SESSION['tst_qst_move_' . $this->object->getTestId()]) && (count($_SESSION['tst_qst_move_' . $this->object->getTestId()]));
2214  $table_gui = new ilTestQuestionsTableGUI($this, 'questions', (($ilAccess->checkAccess("write", "", $this->ref_id) ? true : false)), $checked_move, $total);
2215  $data = $this->object->getTestQuestions();
2216  $table_gui->setData($data);
2217  $this->tpl->setVariable('QUESTIONBROWSER', $table_gui->getHTML());
2218  $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this));
2219  $this->tpl->parseCurrentBlock();
2220  }
2221 
2222  function takenObject() {
2223  }
2224 
2233  {
2234  global $ilDB, $lng;
2235 
2236  require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
2237 
2238  $participantData = new ilTestParticipantData($ilDB, $lng);
2239  $participantData->load($this->object->getTestId());
2240 
2241  $this->object->removeTestResults($participantData);
2242 
2243  ilUtil::sendSuccess($this->lng->txt("tst_all_user_data_deleted"), true);
2244  $this->ctrl->redirect($this, "participants");
2245  }
2246 
2255  {
2256  global $ilDB, $lng;
2257 
2258  require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
2259  $participantData = new ilTestParticipantData($ilDB, $lng);
2260 
2261  if( $this->object->getFixedParticipants() )
2262  {
2263  $participantData->setUserIds($_POST["chbUser"]);
2264  }
2265  else
2266  {
2267  $participantData->setActiveIds($_POST["chbUser"]);
2268  }
2269 
2270  $participantData->load($this->object->getTestId());
2271 
2272  $this->object->removeTestResults($participantData);
2273 
2274  ilUtil::sendSuccess($this->lng->txt("tst_selected_user_data_deleted"), true);
2275  $this->ctrl->redirect($this, "participants");
2276  }
2277 
2286  {
2287  $this->ctrl->redirect($this, "participants");
2288  }
2289 
2300  {
2301  ilUtil::sendQuestion($this->lng->txt("confirm_delete_all_user_data"));
2302  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_maintenance.html", "Modules/Test");
2303 
2304  $this->tpl->setCurrentBlock("confirm_delete");
2305  $this->tpl->setVariable("BTN_CONFIRM_DELETE_ALL", $this->lng->txt("confirm"));
2306  $this->tpl->setVariable("BTN_CANCEL_DELETE_ALL", $this->lng->txt("cancel"));
2307  $this->tpl->parseCurrentBlock();
2308 
2309  $this->tpl->setCurrentBlock("adm_content");
2310  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
2311  $this->tpl->parseCurrentBlock();
2312  }
2313 
2317  public function deleteAllUserResultsObject()
2318  {
2319  // display confirmation message
2320  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
2321  $cgui = new ilConfirmationGUI();
2322  $cgui->setFormAction($this->ctrl->getFormAction($this, "participants"));
2323  $cgui->setHeaderText($this->lng->txt("delete_all_user_data_confirmation"));
2324  $cgui->setCancel($this->lng->txt("cancel"), "participants");
2325  $cgui->setConfirm($this->lng->txt("proceed"), "confirmDeleteAllUserResults");
2326 
2327  $this->tpl->setContent($cgui->getHTML());
2328  }
2329 
2338  {
2339  if (count($_POST["chbUser"]) == 0)
2340  {
2341  ilUtil::sendInfo($this->lng->txt("select_one_user"), TRUE);
2342  $this->ctrl->redirect($this, "participants");
2343  }
2344 
2345  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
2346  $cgui = new ilConfirmationGUI();
2347  $cgui->setHeaderText($this->lng->txt("confirm_delete_single_user_data"));
2348 
2349  $cgui->setFormAction($this->ctrl->getFormAction($this));
2350  $cgui->setCancel($this->lng->txt("cancel"), "cancelDeleteSelectedUserData");
2351  $cgui->setConfirm($this->lng->txt("confirm"), "confirmDeleteSelectedUserData");
2352 
2353  include_once './Services/User/classes/class.ilObjUser.php';
2354  foreach ($_POST["chbUser"] as $key => $active_id)
2355  {
2356  if ($this->object->getFixedParticipants())
2357  {
2358  $user_id = $active_id;
2359  }
2360  else
2361  {
2362  $user_id = $this->object->_getUserIdFromActiveId($active_id);
2363  }
2364  $user = ilObjUser::_lookupName($user_id);
2365 
2366  if ($this->object->getAnonymity())
2367  {
2368  $name = $this->lng->txt("anonymous");
2369  }
2370  else if($user["lastname"])
2371  {
2372  $name = $user["lastname"].", ".$user["firstname"]." (".
2373  $user["login"].")";
2374  }
2375  else
2376  {
2377  $name = $this->lng->txt("deleted_user");
2378  }
2379 
2380  $cgui->addItem("chbUser[]", $active_id, $name,
2381  ilUtil::getImagePath("icon_usr.svg"), $this->lng->txt("usr"));
2382  }
2383 
2384  $this->tpl->setContent($cgui->getHTML());
2385  }
2386 
2394  function historyObject()
2395  {
2396  include_once "./Modules/Test/classes/tables/class.ilTestHistoryTableGUI.php";
2397  $table_gui = new ilTestHistoryTableGUI($this, 'history');
2398  $table_gui->setTestObject($this->object);
2399  include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
2400  $log =& ilObjAssessmentFolder::_getLog(0, time(), $this->object->getId(), TRUE);
2401  $table_gui->setData($log);
2402  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
2403  }
2404 
2405  function initImportForm($a_new_type)
2406  {
2407  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2408  $form = new ilPropertyFormGUI();
2409  $form->setTarget("_top");
2410  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
2411  $this->ctrl->setParameter($this, "new_type", $new_type);
2412  $form->setFormAction($this->ctrl->getFormAction($this));
2413  $form->setTitle($this->lng->txt("import_tst"));
2414 
2415  // file
2416  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
2417  $fi = new ilFileInputGUI($this->lng->txt("import_file"), "xmldoc");
2418  $fi->setSuffixes(array("zip"));
2419  $fi->setRequired(true);
2420  $form->addItem($fi);
2421 
2422  // question pool
2423  include_once("./Modules/Test/classes/class.ilObjTest.php");
2424  $tst = new ilObjTest();
2425  $questionpools = $tst->getAvailableQuestionpools(TRUE, FALSE, TRUE, TRUE);
2426  if (count($questionpools))
2427  {
2428  $options = array("-1" => $this->lng->txt("dont_use_questionpool"));
2429  foreach ($questionpools as $key => $value)
2430  {
2431  $options[$key] = $value["title"];
2432  }
2433 
2434  $pool = new ilSelectInputGUI($this->lng->txt("select_questionpool"), "qpl");
2435  $pool->setOptions($options);
2436  $form->addItem($pool);
2437  }
2438 
2439  $form->addCommandButton("importFile", $this->lng->txt("import"));
2440  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
2441 
2442  return $form;
2443  }
2444 
2451  {
2452  $command = $_POST["command"];
2453  if (strlen($command))
2454  {
2455  $method = $command . "Object";
2456  if (method_exists($this, $method))
2457  {
2458  $this->$method();
2459  return;
2460  }
2461  }
2462  $this->ctrl->redirect($this, "participants");
2463  }
2464 
2471  {
2472  global $ilAccess, $ilToolbar, $lng;
2473 
2474  $this->getParticipantsSubTabs();
2475 
2476  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
2477  {
2478  // allow only write access
2479  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
2480  $this->ctrl->redirect($this, "infoScreen");
2481  }
2482 
2483  if( $this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken($this->tree) )
2484  {
2486  $this->testQuestionSetConfigFactory->getQuestionSetConfig()->getDepenciesBrokenMessage($this->lng)
2487  );
2488  }
2489  elseif( $this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesInVulnerableState($this->tree) )
2490  {
2492  $this->questionSetConfig->getDepenciesInVulnerableStateMessage($this->lng)
2493  );
2494  }
2495 
2496  if ($this->object->getFixedParticipants())
2497  {
2498  // search button
2499  include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
2501  $this,
2502  $tb,
2503  array(
2504  'auto_complete_name' => $lng->txt('user'),
2505  'submit_name' => $lng->txt('add')
2506  )
2507  );
2508 
2509  // search button
2510  $ilToolbar->addButton($this->lng->txt("tst_search_users"),
2511  $this->ctrl->getLinkTargetByClass('ilRepositorySearchGUI','start'));
2512 
2513 
2514  $participants =& $this->object->getInvitedUsers();
2515  $rows = array();
2516  foreach ($participants as $data)
2517  {
2518  $maxpass = $this->object->_getMaxPass($data["active_id"]);
2519  if (!is_null($maxpass))
2520  {
2521  $maxpass += 1;
2522  }
2523  $access = "";
2524  if (strlen($data["active_id"]))
2525  {
2526  $last_access = $this->object->_getLastAccess($data["active_id"]);
2527  $access = $last_access;
2528  }
2529  $this->ctrl->setParameterByClass('iltestevaluationgui', 'active_id', $data['active_id']);
2530 
2531  if ($data['active_id'] == null) // if no active id is set, user is invitee not participant...
2532  {
2533  if ( strlen($data["firstname"].$data["lastname"]) == 0 )
2534  {
2535  $fullname = $lng->txt("deleted_user");
2536  }
2537  else if($this->object->getAnonymity())
2538  {
2539  $fullname = $lng->txt('anonymous');
2540  }
2541  else
2542  {
2543  $fullname = trim($data["lastname"] . ", " . $data["firstname"] . " " . $data["title"]);
2544  }
2545  } else {
2546  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
2547  $fullname = ilObjTestAccess::_getParticipantData($data['active_id']);
2548  }
2549 
2550  array_push($rows, array(
2551  'usr_id' => $data["usr_id"],
2552  'active_id' => $data['active_id'],
2553  'login' => $data["login"],
2554  'clientip' => $data["clientip"],
2555  'firstname' => $data["firstname"],
2556  'lastname' => $data["lastname"],
2557  'name' => $fullname,
2558  'started' => ($data["active_id"] > 0) ? 1 : 0,
2559  'finished' => ($data["test_finished"] == 1) ? 1 : 0,
2560  'access' => $access,
2561  'maxpass' => $maxpass,
2562  'result' => $this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'outParticipantsResultsOverview')
2563  ));
2564  }
2565  include_once "./Modules/Test/classes/tables/class.ilTestFixedParticipantsTableGUI.php";
2566  $table_gui = new ilTestFixedParticipantsTableGUI( $this, 'participants',
2567  $this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken(),
2568  $this->object->getAnonymity(), count($rows)
2569  );
2570  $table_gui->setFilterCommand('fpSetFilter');
2571  $table_gui->setResetCommand('fpResetFiler');
2572  $rows = $this->applyFilterCriteria($rows);
2573  $table_gui->setData($rows);
2574  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
2575  }
2576  else
2577  {
2578  $participants =& $this->object->getTestParticipants();
2579  $rows = array();
2580  foreach ($participants as $data)
2581  {
2582  $maxpass = $this->object->_getMaxPass($data["active_id"]);
2583  if (!is_null($maxpass))
2584  {
2585  $maxpass += 1;
2586  }
2587  $access = "";
2588  if (strlen($data["active_id"]))
2589  {
2590  $last_access = $this->object->_getLastAccess($data["active_id"]);
2591  $access = $last_access;
2592  }
2593  $this->ctrl->setParameterByClass('iltestevaluationgui', 'active_id', $data['active_id']);
2594 
2595  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
2596  $fullname = ilObjTestAccess::_getParticipantData($data['active_id']);
2597  array_push($rows, array(
2598  'usr_id' => $data["active_id"],
2599  'active_id' => $data['active_id'],
2600  'login' => $data["login"],
2601  'name' => $fullname,
2602  'firstname' => $data["firstname"],
2603  'lastname' => $data["lastname"],
2604  'started' => ($data["active_id"] > 0) ? 1 : 0,
2605  'finished' => ($data["test_finished"] == 1) ? 1 : 0,
2606  'access' => $access,
2607  'maxpass' => $maxpass,
2608  'result' => $this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'outParticipantsResultsOverview')
2609  ));
2610  }
2611  include_once "./Modules/Test/classes/tables/class.ilTestParticipantsTableGUI.php";
2612  $table_gui = new ilTestParticipantsTableGUI( $this, 'participants',
2613  $this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken(),
2614  $this->object->getAnonymity(), count($rows)
2615  );
2616  $table_gui->setFilterCommand('npSetFilter');
2617  $table_gui->setResetCommand('npResetFilter');
2618  $rows = $this->applyFilterCriteria($rows);
2619  $table_gui->setData($rows);
2620  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
2621  }
2622  }
2623 
2624  public function timingOverviewObject()
2625  {
2626  $this->getParticipantsSubTabs();
2627 
2628  include_once "./Modules/Test/classes/tables/class.ilTimingOverviewTableGUI.php";
2629  $table_gui = new ilTimingOverviewTableGUI($this, 'timingOverview');
2630 
2631  $participants =& $this->object->getTestParticipants();#
2632  $times = $this->object->getStartingTimeOfParticipants();
2633  $addons = $this->object->getTimeExtensionsOfParticipants();
2634 
2635  $tbl_data = array();
2636  foreach ($participants as $participant)
2637  {
2638  $tblRow = array();
2639 
2640  $started = "";
2641  if ($times[$participant['active_id']])
2642  {
2643  $started = $this->lng->txt('tst_started').': '.ilDatePresentation::formatDate(new ilDateTime($times[$participant['active_id']], IL_CAL_DATETIME));
2644  $tblRow['started'] = $started;
2645  }
2646  else
2647  {
2648  $tblRow['started'] = '';
2649  }
2650 
2651  if ($addons[$participant['active_id']] > 0)
2652  {
2653  $tblRow['extratime'] = $addons[$participant['active_id']];
2654  }
2655 
2656  $tblRow['login'] = $participant['login'];
2657 
2658  if ($this->object->getAnonymity())
2659  {
2660  $tblRow['name'] = $this->lng->txt("anonymous");
2661  }
2662  else
2663  {
2664  $tblRow['name'] = $participant['lastname'] . ', ' . $participant['firstname'];
2665  }
2666 
2667  $tbl_data[] = $tblRow;
2668  }
2669  $table_gui->setData($tbl_data);
2670 
2671  $this->tpl->setContent($table_gui->getHTML());
2672  }
2673 
2674  public function timingObject()
2675  {
2676  $this->getParticipantsSubTabs();
2677 
2678  global $ilAccess;
2679 
2680  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
2681  {
2682  // allow only write access
2683  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
2684  $this->ctrl->redirect($this, "infoScreen");
2685  }
2686 
2687  if ($this->object->getProcessingTimeInSeconds() > 0 && $this->object->getNrOfTries() == 1)
2688  {
2689  $form = $this->formTimingObject();
2690  if (count($_POST) && $form->checkInput())
2691  {
2692  $res = $this->object->addExtraTime($form->getInput('participant'), $form->getInput('extratime'));
2693  ilUtil::sendSuccess(sprintf($this->lng->txt('tst_extratime_added'), $form->getInput('extratime')), true);
2694  $this->ctrl->redirect($this, 'timingOverview');
2695  }
2696  else
2697  {
2698  return $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
2699  }
2700  }
2701  else
2702  {
2703  ilUtil::sendInfo($this->lng->txt("tst_extratime_notavailable"));
2704  }
2705  }
2706 
2707  private function formTimingObject()
2708  {
2709  global $ilAccess;
2710 
2711  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
2712  $form = new ilPropertyFormGUI();
2713  $form->setFormAction($this->ctrl->getFormAction($this));
2714  $form->setTableWidth("100%");
2715  $form->setId("tst_change_workingtime");
2716  $form->setTitle($this->lng->txt("tst_change_workingtime"));
2717 
2718  // test users
2719  $participantslist = new ilSelectInputGUI($this->lng->txt('participants'), "participant");
2720  $participants =& $this->object->getTestParticipants();
2721  $times = $this->object->getStartingTimeOfParticipants();
2722  $addons = $this->object->getTimeExtensionsOfParticipants();
2723  $options = array(
2724  '' => $this->lng->txt('please_select'),
2725  '0' => $this->lng->txt('all_participants')
2726  );
2727  foreach ($participants as $participant)
2728  {
2729  $started = "";
2730 
2731  if ($this->object->getAnonymity())
2732  {
2733  $name = $this->lng->txt("anonymous");
2734  }
2735  else
2736  {
2737  $name = $participant['lastname'] . ', ' . $participant['firstname'];
2738  }
2739 
2740 
2741  if ($times[$participant['active_id']])
2742  {
2743  $started = ", ".$this->lng->txt('tst_started').': '.ilDatePresentation::formatDate(new ilDateTime($times[$participant['active_id']], IL_CAL_DATETIME));
2744  }
2745  if ($addons[$participant['active_id']] > 0) $started .= ", " . $this->lng->txt('extratime') . ': ' . $addons[$participant['active_id']] . ' ' . $this->lng->txt('minutes');
2746  $options[$participant['active_id']] = $participant['login'] . ' (' .$name. ')'.$started;
2747  }
2748  $participantslist->setRequired(true);
2749  $participantslist->setOptions($options);
2750  $form->addItem($participantslist);
2751 
2752  // extra time
2753  $extratime = new ilNumberInputGUI($this->lng->txt("extratime"), "extratime");
2754  $extratime->setInfo($this->lng->txt('tst_extratime_info'));
2755  $extratime->setRequired(true);
2756  $extratime->setMinValue(0);
2757  $extratime->setMinvalueShouldBeGreater(false);
2758  $extratime->setSuffix($this->lng->txt('minutes'));
2759  $extratime->setSize(5);
2760  $form->addItem($extratime);
2761 
2762  if (is_array($_POST) && strlen($_POST['cmd']['timing'])) $form->setValuesByArray($_POST);
2763 
2764  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) $form->addCommandButton("timing", $this->lng->txt("save"));
2765  $form->addCommandButton('timingOverview', $this->lng->txt("cancel"));
2766  return $form;
2767  }
2768 
2769  public function showTimingFormObject()
2770  {
2771  $form = $this->formTimingObject();
2772  $this->tpl->setContent($form->getHTML());
2773  }
2774 
2775  function applyFilterCriteria($in_rows)
2776  {
2777  global $ilDB;
2778  $sess_filter = $_SESSION['form_tst_participants_' . $this->ref_id]['selection'];
2779  $sess_filter = str_replace('"','',$sess_filter);
2780  $sess_filter = explode(':', $sess_filter);
2781  $filter = substr($sess_filter[2],0, strlen($sess_filter[2])-1);
2782 
2783  if ($filter == 'all' || $filter == false)
2784  {
2785  return $in_rows; #unchanged - no filter.
2786  }
2787 
2788  $with_result = array();
2789  $without_result = array();
2790  foreach ($in_rows as $row)
2791  {
2792  $result = $ilDB->query(
2793  'SELECT count(solution_id) count
2794  FROM tst_solutions
2795  WHERE active_fi = ' . $ilDB->quote($row['active_id'])
2796  );
2797  $count = $ilDB->fetchAssoc($result);
2798  $count = $count['count'];
2799 
2800  if ($count == 0)
2801  {
2802  $without_result[] = $row;
2803  }
2804  else
2805  {
2806  $with_result[] = $row;
2807  }
2808  }
2809 
2810  if ($filter == 'withSolutions')
2811  {
2812  return $with_result;
2813  }
2814  return $without_result;
2815 
2816  }
2817 
2819  {
2820  include_once("./Modules/Test/classes/tables/class.ilTestFixedParticipantsTableGUI.php");
2821  $table_gui = new ilTestFixedParticipantsTableGUI($this, "participants", false, $this->object->getAnonymity(), 0);
2822  $table_gui->writeFilterToSession(); // writes filter to session
2823  $table_gui->resetOffset(); // sets record offest to 0 (first page)
2824  $this->participantsObject();
2825  }
2826 
2828  {
2829  include_once("./Modules/Test/classes/tables/class.ilTestFixedParticipantsTableGUI.php");
2830  $table_gui = new ilTestFixedParticipantsTableGUI(
2831  $this, "participants", false, $this->object->getAnonymity(), 0
2832  );
2833  $table_gui->resetFilter(); // writes filter to session
2834  $table_gui->resetOffset(); // sets record offest to 0 (first page)
2835  $this->participantsObject();
2836  }
2837 
2839  {
2840  include_once("./Modules/Test/classes/tables/class.ilTestParticipantsTableGUI.php");
2841  $table_gui = new ilTestParticipantsTableGUI(
2842  $this, "participants", false, $this->object->getAnonymity(), 0
2843  );
2844  $table_gui->writeFilterToSession(); // writes filter to session
2845  $table_gui->resetOffset(); // sets record offest to 0 (first page)
2846  $this->participantsObject();
2847 
2848  }
2849 
2851  {
2852  include_once("./Modules/Test/classes/tables/class.ilTestParticipantsTableGUI.php");
2853  $table_gui = new ilTestParticipantsTableGUI(
2854  $this, "participants", false, $this->object->getAnonymity(), 0
2855  );
2856  $table_gui->resetFilter(); // writes filter to session
2857  $table_gui->resetOffset(); // sets record offest to 0 (first page)
2858  $this->participantsObject();
2859 
2860  }
2861 
2868  {
2869  if (count($_POST))
2870  {
2871  $_SESSION["show_user_results"] = $_POST["chbUser"];
2872  }
2873  $this->showUserResults($show_pass_details = TRUE, $show_answers = TRUE, $show_reached_points = TRUE);
2874  }
2875 
2882  {
2883  if (count($_POST))
2884  {
2885  $_SESSION["show_user_results"] = $_POST["chbUser"];
2886  }
2887  $this->showUserResults($show_pass_details = FALSE, $show_answers = TRUE);
2888  }
2889 
2896  {
2897  if (count($_POST))
2898  {
2899  $_SESSION["show_user_results"] = $_POST["chbUser"];
2900  }
2901  $this->showUserResults($show_pass_details = TRUE, $show_answers = FALSE);
2902  }
2903 
2909  function showUserResults($show_pass_details, $show_answers, $show_reached_points = FALSE)
2910  {
2911  $show_user_results = $_SESSION["show_user_results"];
2912 
2913  if (count($show_user_results) == 0)
2914  {
2915  ilUtil::sendInfo($this->lng->txt("select_one_user"), TRUE);
2916  $this->ctrl->redirect($this, "participants");
2917  }
2918 
2919 
2920  $template = $this->createUserResults( $show_pass_details, $show_answers, $show_reached_points, $show_user_results);
2921 
2922  $this->tpl->setVariable("ADM_CONTENT", $template->get());
2923  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
2924  if ($this->object->getShowSolutionAnswersOnly())
2925  {
2926  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
2927  }
2928  }
2929 
2931  {
2932  if (is_array($_POST["chbUser"]))
2933  {
2934  foreach ($_POST["chbUser"] as $user_id)
2935  {
2936  $this->object->disinviteUser($user_id);
2937  }
2938  }
2939  else
2940  {
2941  ilUtil::sendInfo($this->lng->txt("select_one_user"), true);
2942  }
2943  $this->ctrl->redirect($this, "participants");
2944  }
2945 
2947  {
2948  if (is_array($_POST["chbUser"]))
2949  {
2950  foreach ($_POST["chbUser"] as $user_id)
2951  {
2952  $this->object->setClientIP($user_id, $_POST["clientip_".$user_id]);
2953  }
2954  }
2955  else
2956  {
2957  ilUtil::sendInfo($this->lng->txt("select_one_user"), true);
2958  }
2959  $this->ctrl->redirect($this, "participants");
2960  }
2961 
2969  function printobject()
2970  {
2971  global $ilAccess, $ilias;
2972  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
2973  {
2974  // allow only write access
2975  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
2976  $this->ctrl->redirect($this, "infoScreen");
2977  }
2978  $this->getQuestionsSubTabs();
2979  $template = new ilTemplate("tpl.il_as_tst_print_test_confirm.html", TRUE, TRUE, "Modules/Test");
2980 
2981  if(!array_key_exists("pdf", $_GET) || $_GET["pdf"] != 1) // #15243
2982  {
2983  $this->ctrl->setParameter($this, "pdf", "1");
2984  $template->setCurrentBlock("pdf_export");
2985  $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "print"));
2986  $this->ctrl->setParameter($this, "pdf", "");
2987  $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
2988  $template->parseCurrentBlock();
2989 
2990  $template->setCurrentBlock("navigation_buttons");
2991  $template->setVariable("BUTTON_PRINT", $this->lng->txt("print"));
2992  $template->parseCurrentBlock();
2993  }
2994 
2995  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
2996 
2997  global $ilUser;
2998  $print_date = mktime(date("H"), date("i"), date("s"), date("m") , date("d"), date("Y"));
2999  $max_points= 0;
3000  $counter = 1;
3001 
3002  require_once 'Modules/Test/classes/class.ilTestQuestionHeaderBlockBuilder.php';
3003  $questionHeaderBlockBuilder = new ilTestQuestionHeaderBlockBuilder($this->lng);
3004  $questionHeaderBlockBuilder->setHeaderMode($this->object->getTitleOutput());
3005 
3006  foreach ($this->object->questions as $question)
3007  {
3008  $template->setCurrentBlock("question");
3009  $question_gui = $this->object->createQuestionGUI("", $question);
3010 
3011  $questionHeaderBlockBuilder->setQuestionTitle($question_gui->object->getTitle());
3012  $questionHeaderBlockBuilder->setQuestionPoints($question_gui->object->getMaximumPoints());
3013  $questionHeaderBlockBuilder->setQuestionPosition($counter);
3014  $template->setVariable("QUESTION_HEADER", $questionHeaderBlockBuilder->getHTML());
3015 
3016  $template->setVariable("TXT_QUESTION_ID", $this->lng->txt('question_id_short'));
3017  $template->setVariable("QUESTION_ID", $question_gui->object->getId());
3018  $result_output = $question_gui->getSolutionOutput("", NULL, FALSE, TRUE, FALSE, $this->object->getShowSolutionFeedback());
3019  if (strlen($result_output) == 0) $result_output = $question_gui->getPreview(FALSE);
3020  $template->setVariable("SOLUTION_OUTPUT", $result_output);
3021  $template->parseCurrentBlock("question");
3022  $counter ++;
3023  $max_points += $question_gui->object->getMaximumPoints();
3024  }
3025 
3026  $template->setVariable("TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
3027  $template->setVariable("PRINT_TEST", ilUtil::prepareFormOutput($this->lng->txt("tst_print")));
3028  $template->setVariable("TXT_PRINT_DATE", ilUtil::prepareFormOutput($this->lng->txt("date")));
3029  $template->setVariable("VALUE_PRINT_DATE", ilUtil::prepareFormOutput(strftime("%c",$print_date)));
3030  $template->setVariable("TXT_MAXIMUM_POINTS", ilUtil::prepareFormOutput($this->lng->txt("tst_maximum_points")));
3031  $template->setVariable("VALUE_MAXIMUM_POINTS", ilUtil::prepareFormOutput($max_points));
3032 
3033  if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1))
3034  {
3035  //$this->object->deliverPDFfromHTML($template->get(), $this->object->getTitle());
3036  require_once 'class.ilTestPDFGenerator.php';
3037  ilTestPDFGenerator::generatePDF($template->get(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->object->getTitle());
3038  }
3039  else
3040  {
3041  $this->tpl->setVariable("PRINT_CONTENT", $template->get());
3042  }
3043  }
3044 
3052  function reviewobject()
3053  {
3054  global $ilAccess, $ilias;
3055  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
3056  {
3057  // allow only write access
3058  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3059  $this->ctrl->redirect($this, "infoScreen");
3060  }
3061  $this->getQuestionsSubTabs();
3062  $template = new ilTemplate("tpl.il_as_tst_print_test_confirm.html", TRUE, TRUE, "Modules/Test");
3063 
3064  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
3065 
3066  global $ilUser;
3067  $print_date = mktime(date("H"), date("i"), date("s"), date("m") , date("d"), date("Y"));
3068  $max_points= 0;
3069  $counter = 1;
3070 
3071  require_once 'Modules/Test/classes/class.ilTestQuestionHeaderBlockBuilder.php';
3072  $questionHeaderBlockBuilder = new ilTestQuestionHeaderBlockBuilder($this->lng);
3073  $questionHeaderBlockBuilder->setHeaderMode($this->object->getTitleOutput());
3074 
3075  foreach ($this->object->questions as $question)
3076  {
3077  $template->setCurrentBlock("question");
3078  $question_gui = $this->object->createQuestionGUI("", $question);
3079 
3080  $questionHeaderBlockBuilder->setQuestionTitle($question_gui->object->getTitle());
3081  $questionHeaderBlockBuilder->setQuestionPoints($question_gui->object->getMaximumPoints());
3082  $questionHeaderBlockBuilder->setQuestionPosition($counter);
3083  $template->setVariable("QUESTION_HEADER", $questionHeaderBlockBuilder->getHTML());
3084 
3086  //$result_output = $question_gui->getTestOutput('', NULL, FALSE, FALSE, FALSE);
3087  $result_output = $question_gui->getPreview(false);
3088 
3089  if (strlen($result_output) == 0) $result_output = $question_gui->getPreview(FALSE);
3090  $template->setVariable("SOLUTION_OUTPUT", $result_output);
3091  $template->parseCurrentBlock("question");
3092  $counter ++;
3093  $max_points += $question_gui->object->getMaximumPoints();
3094  }
3095 
3096 
3097 
3098  $template->setVariable("TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
3099  $template->setVariable("PRINT_TEST", ilUtil::prepareFormOutput($this->lng->txt("review_view")));
3100  $template->setVariable("TXT_PRINT_DATE", ilUtil::prepareFormOutput($this->lng->txt("date")));
3101  $template->setVariable("VALUE_PRINT_DATE", ilUtil::prepareFormOutput(strftime("%c",$print_date)));
3102  $template->setVariable("TXT_MAXIMUM_POINTS", ilUtil::prepareFormOutput($this->lng->txt("tst_maximum_points")));
3103  $template->setVariable("VALUE_MAXIMUM_POINTS", ilUtil::prepareFormOutput($max_points));
3104 
3105  if (array_key_exists("pdf", $_GET) && ($_GET["pdf"] == 1))
3106  {
3107  //$this->object->deliverPDFfromHTML($template->get(), $this->object->getTitle());
3108  require_once 'class.ilTestPDFGenerator.php';
3109  $content = $template->get();
3110  ilTestPDFGenerator::generatePDF($template->get(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->object->getTitle());
3111  }
3112  else
3113  {
3114  $this->ctrl->setParameter($this, "pdf", "1");
3115  $template->setCurrentBlock("pdf_export");
3116  $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "review"));
3117  $this->ctrl->setParameter($this, "pdf", "");
3118  $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
3119  $template->parseCurrentBlock();
3120 
3121  $template->setCurrentBlock("navigation_buttons");
3122  $template->setVariable("BUTTON_PRINT", $this->lng->txt("print"));
3123  $template->parseCurrentBlock();
3124 
3125 
3126  $this->tpl->setVariable("PRINT_CONTENT", $template->get());
3127  }
3128  }
3129 
3130  function addParticipantsObject($a_user_ids = array())
3131  {
3132  $countusers = 0;
3133  // add users
3134  if (is_array($a_user_ids))
3135  {
3136  $i = 0;
3137  foreach ($a_user_ids as $user_id)
3138  {
3139  $client_ip = $_POST["client_ip"][$i];
3140  $this->object->inviteUser($user_id, $client_ip);
3141  $countusers++;
3142  $i++;
3143  }
3144  }
3145  $message = "";
3146  if ($countusers)
3147  {
3148  $message = $this->lng->txt("tst_invited_selected_users");
3149  }
3150  if (strlen($message))
3151  {
3152  ilUtil::sendInfo($message, TRUE);
3153  }
3154  else
3155  {
3156  ilUtil::sendInfo($this->lng->txt("tst_invited_nobody"), TRUE);
3157  return false;
3158  }
3159 
3160  $this->ctrl->redirect($this, "participants");
3161  }
3162 
3166  public function defaultsObject()
3167  {
3173  global $ilAccess, $ilToolbar, $tpl;
3174 
3175  if(!$ilAccess->checkAccess("write", "", $this->ref_id))
3176  {
3177  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3178  $this->ctrl->redirect($this, "infoScreen");
3179  }
3180 
3181  $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'addDefaults'));
3182  $ilToolbar->addFormButton($this->lng->txt('add'), 'addDefaults');
3183  require_once 'Services/Form/classes/class.ilTextInputGUI.php';
3184  $ilToolbar->addInputItem(new ilTextInputGUI($this->lng->txt('tst_defaults_defaults_of_test'), 'name'), true);
3185 
3186  require_once 'Modules/Test/classes/tables/class.ilTestPersonalDefaultSettingsTableGUI.php';
3187  $table = new ilTestPersonalDefaultSettingsTableGUI($this, 'defaults');
3188  $defaults = $this->object->getAvailableDefaults();
3189  $table->setData((array)$defaults);
3190  $tpl->setContent($table->getHTML());
3191  }
3192 
3196  public function deleteDefaultsObject()
3197  {
3198  if(isset($_POST['chb_defaults']) && is_array($_POST['chb_defaults']) && count($_POST['chb_defaults']))
3199  {
3200  foreach($_POST['chb_defaults'] as $test_default_id)
3201  {
3202  $this->object->deleteDefaults($test_default_id);
3203  }
3204  }
3205  else
3206  {
3207  ilUtil::sendInfo($this->lng->txt('select_one'));
3208  }
3209  $this->defaultsObject();
3210  }
3211 
3216  {
3217  $this->applyDefaultsObject(true);
3218  return;
3219  }
3220 
3224  public function applyDefaultsObject($confirmed = false)
3225  {
3226  if( count($_POST["chb_defaults"]) != 1 )
3227  {
3229  $this->lng->txt("tst_defaults_apply_select_one")
3230  );
3231 
3232  return $this->defaultsObject();
3233  }
3234 
3235  // do not apply if user datasets exist
3236  if($this->object->evalTotalPersons() > 0)
3237  {
3239  $this->lng->txt("tst_defaults_apply_not_possible")
3240  );
3241 
3242  return $this->defaultsObject();
3243  }
3244 
3245  $defaults =& $this->object->getTestDefaults($_POST["chb_defaults"][0]);
3246  $defaultSettings = unserialize($defaults["defaults"]);
3247 
3248  if( isset($defaultSettings['isRandomTest']) )
3249  {
3250  if( $defaultSettings['isRandomTest'] )
3251  {
3252  $newQuestionSetType = ilObjTest::QUESTION_SET_TYPE_RANDOM;
3253  $this->object->setQuestionSetType(ilObjTest::QUESTION_SET_TYPE_RANDOM);
3254  }
3255  else
3256  {
3257  $newQuestionSetType = ilObjTest::QUESTION_SET_TYPE_FIXED;
3258  $this->object->setQuestionSetType(ilObjTest::QUESTION_SET_TYPE_FIXED);
3259  }
3260  }
3261  elseif( isset($defaultSettings['questionSetType']) )
3262  {
3263  $newQuestionSetType = $defaultSettings['questionSetType'];
3264  }
3265  $oldQuestionSetType = $this->object->getQuestionSetType();
3266  $questionSetTypeSettingSwitched = ( $oldQuestionSetType != $newQuestionSetType );
3267 
3268  $oldQuestionSetConfig = $this->testQuestionSetConfigFactory->getQuestionSetConfigByType($oldQuestionSetType);
3269 
3270  switch( true )
3271  {
3272  case !$questionSetTypeSettingSwitched:
3273  case !$oldQuestionSetConfig->doesQuestionSetRelatedDataExist():
3274  case $confirmed:
3275 
3276  break;
3277 
3278  default:
3279 
3280  require_once 'Modules/Test/classes/confirmations/class.ilTestSettingsChangeConfirmationGUI.php';
3281  $confirmation = new ilTestSettingsChangeConfirmationGUI($this->lng, $this->object);
3282 
3283  $confirmation->setFormAction( $this->ctrl->getFormAction($this) );
3284  $confirmation->setCancel($this->lng->txt('cancel'), 'defaults');
3285  $confirmation->setConfirm($this->lng->txt('confirm'), 'confirmedApplyDefaults');
3286 
3287  $confirmation->setOldQuestionSetType($this->object->getQuestionSetType());
3288  $confirmation->setNewQuestionSetType($newQuestionSetType);
3289  $confirmation->setQuestionLossInfoEnabled(false);
3290  $confirmation->build();
3291 
3292  $confirmation->populateParametersFromPost();
3293 
3294  $this->tpl->setContent( $this->ctrl->getHTML($confirmation) );
3295 
3296  return;
3297  }
3298 
3299  if( $questionSetTypeSettingSwitched && $this->object->isOnline() )
3300  {
3301  $this->object->setOnline(false);
3302 
3303  $info = $this->lng->txt("tst_set_offline_due_to_switched_question_set_type_setting");
3304 
3305  ilUtil::sendInfo($info, true);
3306  }
3307 
3308  $this->object->applyDefaults($defaults);
3309 
3310  ilUtil::sendSuccess($this->lng->txt("tst_defaults_applied"), true);
3311 
3312  if( $questionSetTypeSettingSwitched && $oldQuestionSetConfig->doesQuestionSetRelatedDataExist() )
3313  {
3314  $oldQuestionSetConfig->removeQuestionSetRelatedData();
3315  }
3316 
3317  $this->ctrl->redirect($this, 'defaults');
3318  }
3319 
3324  {
3325  if (strlen($_POST["name"]) > 0)
3326  {
3327  $this->object->addDefaults($_POST['name']);
3328  }
3329  else
3330  {
3331  ilUtil::sendInfo($this->lng->txt("tst_defaults_enter_name"));
3332  }
3333  $this->defaultsObject();
3334  }
3335 
3337  {
3338  if( in_array($this->ctrl->getCmdClass(), self::$infoScreenChildClasses) )
3339  {
3340  return true;
3341  }
3342 
3343  return false;
3344  }
3345 
3351  function infoScreenObject()
3352  {
3353  #if( !include 'competenzenRocker.php' ) exit;
3354 
3355  $this->ctrl->setCmd("showSummary");
3356  $this->ctrl->setCmdClass("ilinfoscreengui");
3357  $this->infoScreen();
3358  }
3359 
3361  {
3362  $this->ctrl->setCmd("showSummary");
3363  $this->ctrl->setCmdClass("ilinfoscreengui");
3364  $this->infoScreen($_GET['lock']);
3365  }
3366 
3370  function infoScreen($session_lock = "")
3371  {
3377  global $ilAccess, $ilUser, $ilToolbar;
3378 
3379  require_once 'Modules/Test/classes/class.ilTestDynamicQuestionSetFilterSelection.php';
3380 
3381  require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
3382  require_once 'Services/UIComponent/Button/classes/class.ilSubmitButton.php';
3383 
3384  $testQuestionSetConfig = $this->testQuestionSetConfigFactory->getQuestionSetConfig();
3385  $testSession = $this->testSessionFactory->getSession();
3386  $testSequence = $this->testSequenceFactory->getSequence($testSession);
3387  $testSequence->loadFromDb();
3388  $testSequence->loadQuestions($testQuestionSetConfig, new ilTestDynamicQuestionSetFilterSelection());
3389 
3390  $testPlayerGUI = $this->testPlayerFactory->getPlayerGUI();
3391 
3392  if ($_GET['createRandomSolutions'])
3393  {
3394  $this->object->createRandomSolutions($_GET['createRandomSolutions']);
3395  }
3396 
3397  if (!$ilAccess->checkAccess("read", "", $this->ref_id))
3398  {
3399  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"),$this->ilias->error_obj->MESSAGE);
3400  }
3401 
3402  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
3403  $info = new ilInfoScreenGUI($this);
3404 
3405  if( $this->isCommandClassAnyInfoScreenChild() )
3406  {
3407  return $this->ctrl->forwardCommand($info);
3408  }
3409 
3410  $this->ctrl->setParameter($testPlayerGUI, "sequence", $testSession->getLastSequence());
3411 
3412  $info->setFormAction($this->ctrl->getFormAction($testPlayerGUI));
3413 
3414  if (strlen($session_lock))
3415  {
3416  $info->addHiddenElement("lock", $session_lock);
3417  }
3418  else
3419  {
3420  $info->addHiddenElement("lock", md5($_COOKIE['PHPSESSID'] . time()));
3421  }
3422  $online_access = false;
3423  if ($this->object->getFixedParticipants())
3424  {
3425  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
3426  $online_access_result = ilObjTestAccess::_lookupOnlineTestAccess($this->object->getId(), $ilUser->getId());
3427  if ($online_access_result === true)
3428  {
3429  $online_access = true;
3430  }
3431  else
3432  {
3433  ilUtil::sendInfo($online_access_result);
3434  }
3435  }
3436 
3437  $enter_anonymous_code = false;
3438  if( $this->object->isOnline() && $this->object->isComplete( $this->testQuestionSetConfigFactory->getQuestionSetConfig() ) )
3439  {
3440  if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id))
3441  {
3442  $executable = $this->object->isExecutable($testSession, $ilUser->getId(), $allowPassIncrease = TRUE
3443  );
3444  if ($executable["executable"])
3445  {
3446  if( $this->object->areObligationsEnabled() && $this->object->hasObligations($this->object->getTestId()) )
3447  {
3448  ilUtil::sendInfo($GLOBALS['lng']->txt('tst_test_contains_obligatory_questions'));
3449  }
3450 
3451  if ($testSession->getActiveId() > 0)
3452  {
3453  // resume test
3454  require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
3455  $testPassesSelector = new ilTestPassesSelector($GLOBALS['ilDB'], $this->object);
3456  $testPassesSelector->setActiveId($testSession->getActiveId());
3457  $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
3458 
3459  $closedPasses = $testPassesSelector->getClosedPasses();
3460  $existingPasses = $testPassesSelector->getExistingPasses();
3461 
3462  if ($existingPasses > $closedPasses)
3463  {
3464  $btn = ilSubmitButton::getInstance();
3465  $btn->setCaption('tst_resume_test');
3466  $btn->setCommand('resumePlayer');
3467  $btn->setPrimary(true);
3468  $big_button[] = $btn;
3469  }
3470  else
3471  {
3472  $btn = ilSubmitButton::getInstance();
3473  $btn->setCaption($this->object->getStartTestLabel($testSession->getActiveId()), false);
3474  $btn->setCommand('startPlayer');
3475  $btn->setPrimary(true);
3476  $big_button[] = $btn;
3477  }
3478  }
3479  else
3480  {
3481  // start new test
3482  $btn = ilSubmitButton::getInstance();
3483  $btn->setCaption($this->object->getStartTestLabel($testSession->getActiveId()), false);
3484  $btn->setCommand('startPlayer');
3485  $btn->setPrimary(true);
3486  $big_button[] = $btn;
3487  }
3488  }
3489  else
3490  {
3491  ilUtil::sendInfo($executable["errormessage"]);
3492  }
3493  if ($testSession->getActiveId() > 0)
3494  {
3495  // test results button
3496 
3497  require_once 'Modules/Test/classes/class.ilTestPassesSelector.php';
3498  $testPassesSelector = new ilTestPassesSelector($GLOBALS['ilDB'], $this->object);
3499  $testPassesSelector->setActiveId($testSession->getActiveId());
3500  $testPassesSelector->setLastFinishedPass($testSession->getLastFinishedPass());
3501 
3502  if ($this->object->canShowTestResults($testSession, $ilUser->getId()) && count($testPassesSelector->getReportablePasses()))
3503  {
3504  $btn = ilLinkButton::getInstance();
3505  $btn->setCaption('tst_show_results');
3506  $btn->setUrl($this->ctrl->getLinkTargetByClass('ilTestEvaluationGUI', 'outUserResultsOverview'));
3507  $btn->setPrimary(false);
3508  $big_button[] = $btn;
3509 
3510  if ($this->object->getHighscoreEnabled())
3511  {
3512  // Can also compare results then
3513  $btn = ilSubmitButton::getInstance();
3514  $btn->setCaption('tst_show_toplist');
3515  $btn->setCommand('outResultsToplist');
3516  $btn->setPrimary(false);
3517  $big_button[] = $btn;
3518  }
3519 
3520  if( $this->object->isSkillServiceToBeConsidered() )
3521  {
3522  require_once 'Modules/Test/classes/class.ilTestSkillEvaluationGUI.php';
3523 
3524  $btn = ilLinkButton::getInstance();
3525  $btn->setCaption('tst_show_comp_results');
3526  $btn->setUrl($this->ctrl->getLinkTargetByClass('ilTestSkillEvaluationGUI', ilTestSkillEvaluationGUI::CMD_SHOW));
3527  $btn->setPrimary(false);
3528  $big_button[] = $btn;
3529  }
3530  }
3531 
3532  }
3533  }
3534  if ($testSession->getActiveId() > 0)
3535  {
3536  if ($this->object->canShowSolutionPrintview($ilUser->getId()))
3537  {
3538  $btn = ilSubmitButton::getInstance();
3539  $btn->setCaption('tst_list_of_answers_show');
3540  $btn->setCommand('outUserListOfAnswerPasses');
3541  $btn->setPrimary(false);
3542  $big_button[] = $btn;
3543  }
3544  }
3545 
3546  if( $this->isDeleteDynamicTestResultsButtonRequired($testSession, $testSequence) )
3547  {
3548  $this->populateDeleteDynamicTestResultsButton($testSession, $big_button);
3549  }
3550 
3551  if($_SESSION["AccountId"] == ANONYMOUS_USER_ID)
3552  {
3553  $enter_anonymous_code = true;
3554  }
3555  }
3556 
3557  if( !$this->object->isOnline() && !$testQuestionSetConfig->areDepenciesBroken() )
3558  {
3559  $message = $this->lng->txt("test_is_offline");
3560 
3561  if($ilAccess->checkAccess("write", "", $this->ref_id))
3562  {
3563  $message .= "<br /><a href=\"".$this->ctrl->getLinkTargetByClass('ilobjtestsettingsgeneralgui')."\">".
3564  $this->lng->txt("test_edit_settings")."</a>";
3565  }
3566 
3567  ilUtil::sendInfo($message);
3568  }
3569 
3570  if( $ilAccess->checkAccess("write", "", $this->ref_id) )
3571  {
3572  $testQuestionSetConfig = $this->testQuestionSetConfigFactory->getQuestionSetConfig();
3573 
3574  if( $testQuestionSetConfig->areDepenciesBroken() )
3575  {
3576  ilUtil::sendFailure( $testQuestionSetConfig->getDepenciesBrokenMessage($this->lng) );
3577 
3578  $big_button = array();
3579  $enter_anonymous_code = false;
3580  }
3581  elseif( $testQuestionSetConfig->areDepenciesInVulnerableState() )
3582  {
3583  ilUtil::sendInfo( $testQuestionSetConfig->getDepenciesInVulnerableStateMessage($this->lng) );
3584  }
3585  }
3586 
3587  if ($this->object->getShowInfo())
3588  {
3589  $info->enablePrivateNotes();
3590  }
3591 
3592  if($big_button || $enter_anonymous_code)
3593  {
3594  $ilToolbar->setFormAction($this->ctrl->getFormAction($testPlayerGUI));
3595 
3596  foreach($big_button as $button)
3597  {
3598  $ilToolbar->addButtonInstance($button);
3599  }
3600 
3601  if($enter_anonymous_code)
3602  {
3603  if($big_button)
3604  {
3605  $ilToolbar->addSeparator();
3606  }
3607 
3608  require_once 'Services/Form/classes/class.ilTextInputGUI.php';
3609  $anonymous_id = new ilTextInputGUI($this->lng->txt('enter_anonymous_code'), 'anonymous_id');
3610  $anonymous_id->setSize(8);
3611  $ilToolbar->addInputItem($anonymous_id, true);
3612  $ilToolbar->addFormButton($this->lng->txt('submit'), 'setAnonymousId');
3613  }
3614 
3615  $ilToolbar->setCloseFormTag(false);
3616  $info->setOpenFormTag(false);
3617  }
3618 
3619  if (strlen($this->object->getIntroduction()))
3620  {
3621  $info->addSection($this->lng->txt("tst_introduction"));
3622  $info->addProperty("", $this->object->prepareTextareaOutput($this->object->getIntroduction(), true).
3623  $info->getHiddenToggleButton());
3624  }
3625  else
3626  {
3627  $info->addSection("");
3628  $info->addProperty("", $info->getHiddenToggleButton());
3629  }
3630 
3631  $info->addSection($this->lng->txt("tst_general_properties"));
3632  if ($this->object->getShowInfo())
3633  {
3634  $info->addProperty($this->lng->txt("author"), $this->object->getAuthor());
3635  $info->addProperty($this->lng->txt("title"), $this->object->getTitle());
3636  }
3637  if( $this->object->isOnline() && $this->object->isComplete( $this->testQuestionSetConfigFactory->getQuestionSetConfig() ) )
3638  {
3639  if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id))
3640  {
3641  if ($this->object->getShowInfo() || !$this->object->getForceJS())
3642  {
3643  // use javascript
3644  $checked_javascript = false;
3645  if ($this->object->getJavaScriptOutput())
3646  {
3647  $checked_javascript = true;
3648  }
3649  }
3650  // hide previous results
3651  if( !$this->object->isRandomTest() )
3652  {
3653  if ($this->object->getNrOfTries() != 1)
3654  {
3655  if ($this->object->getUsePreviousAnswers() == 0)
3656  {
3657  if ($this->object->getShowInfo())
3658  {
3659  $info->addProperty($this->lng->txt("tst_use_previous_answers"), $this->lng->txt("tst_dont_use_previous_answers"));
3660  }
3661  }
3662  else
3663  {
3664  $use_previous_answers = FALSE;
3665  if ($ilUser->prefs["tst_use_previous_answers"])
3666  {
3667  $checked_previous_answers = TRUE;
3668  }
3669  $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);
3670  }
3671  }
3672  }
3673  }
3674  }
3675 
3676  $info->hideFurtherSections(false);
3677 
3678  if ($this->object->getShowInfo())
3679  {
3680  $info->addSection($this->lng->txt("tst_sequence_properties"));
3681  $info->addProperty($this->lng->txt("tst_sequence"), $this->lng->txt(($this->object->getSequenceSettings() == TEST_FIXED_SEQUENCE)? "tst_sequence_fixed":"tst_sequence_postpone"));
3682 
3683  $info->addSection($this->lng->txt("tst_heading_scoring"));
3684  $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"));
3685  $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"));
3686  if ($this->object->isRandomTest())
3687  {
3688  $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"));
3689  }
3690 
3691  $info->addSection($this->lng->txt("tst_score_reporting"));
3692  $score_reporting_text = "";
3693  switch ($this->object->getScoreReporting())
3694  {
3695  case REPORT_AFTER_TEST:
3696  $score_reporting_text = $this->lng->txt("tst_report_after_test");
3697  break;
3698  case REPORT_ALWAYS:
3699  $score_reporting_text = $this->lng->txt("tst_report_after_first_question");
3700  break;
3701  case REPORT_AFTER_DATE:
3702  $score_reporting_text = $this->lng->txt("tst_report_after_date");
3703  break;
3704  case 4:
3705  $score_reporting_text = $this->lng->txt("tst_report_never");
3706  break;
3707  }
3708  $info->addProperty($this->lng->txt("tst_score_reporting"), $score_reporting_text);
3709  $reporting_date = $this->object->getReportingDate();
3710  if ($reporting_date)
3711  {
3712  #preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $reporting_date, $matches);
3713  #$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]));
3714  #$info->addProperty($this->lng->txt("tst_score_reporting_date"), $txt_reporting_date);
3715  $info->addProperty($this->lng->txt('tst_score_reporting_date'),
3717  }
3718 
3719  $info->addSection($this->lng->txt("tst_session_settings"));
3720  $info->addProperty($this->lng->txt("tst_nr_of_tries"), ($this->object->getNrOfTries() == 0)?$this->lng->txt("unlimited"):$this->object->getNrOfTries());
3721  if ($this->object->getNrOfTries() != 1)
3722  {
3723  $info->addProperty($this->lng->txt("tst_nr_of_tries_of_user"), ($testSession->getPass() == false)?$this->lng->txt("tst_no_tries"):$testSession->getPass());
3724  }
3725 
3726  if ($this->object->getEnableProcessingTime())
3727  {
3728  $info->addProperty($this->lng->txt("tst_processing_time"), $this->object->getProcessingTime());
3729  }
3730  if (strlen($this->object->getAllowedUsers()) && ($this->object->getAllowedUsersTimeGap()))
3731  {
3732  $info->addProperty($this->lng->txt("tst_allowed_users"), $this->object->getAllowedUsers());
3733  }
3734 
3735  $starting_time = $this->object->getStartingTime();
3736  if ($starting_time && $this->object->isStartingTimeEnabled())
3737  {
3738  $info->addProperty($this->lng->txt("tst_starting_time"),
3740  }
3741  $ending_time = $this->object->getEndingTime();
3742  if ($ending_time && $this->object->isEndingTimeEnabled())
3743  {
3744  $info->addProperty($this->lng->txt("tst_ending_time"),
3746  }
3747  $info->addMetaDataSections($this->object->getId(),0, $this->object->getType());
3748  // forward the command
3749  }
3750 
3751  $this->ctrl->forwardCommand($info);
3752  }
3753 
3754  function addLocatorItems()
3755  {
3756  global $ilLocator;
3757  switch ($this->ctrl->getCmd())
3758  {
3759  case "run":
3760  case "infoScreen":
3761  case "redirectToInfoScreen":
3762  case "start":
3763  case "resume":
3764  case "previous":
3765  case "next":
3766  case "summary":
3767  case "finishTest":
3768  case "outCorrectSolution":
3769  case "passDetails":
3770  case "showAnswersOfUser":
3771  case "outUserResultsOverview":
3772  case "backFromSummary":
3773  case "show_answers":
3774  case "setsolved":
3775  case "resetsolved":
3776  case "outTestSummary":
3777  case "outQuestionSummary":
3778  case "gotoQuestion":
3779  case "selectImagemapRegion":
3780  case "confirmSubmitAnswers":
3781  case "finalSubmission":
3782  case "postpone":
3783  case "redirectQuestion":
3784  case "outUserPassDetails":
3785  case "checkPassword":
3786  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"), "", $_GET["ref_id"]);
3787  break;
3788  case "eval_stat":
3789  case "evalAllUsers":
3790  case "evalUserDetail":
3791  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "eval_stat"), "", $_GET["ref_id"]);
3792  break;
3793  case "create":
3794  case "save":
3795  case "cancel":
3796  case "importFile":
3797  case "cloneAll":
3798  case "importVerifiedFile":
3799  case "cancelImport":
3800  break;
3801  default:
3802  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
3803  break;
3804  }
3805  }
3806 
3807  function getBrowseForQuestionsTab(&$tabs_gui)
3808  {
3809  global $ilAccess;
3810  if ($ilAccess->checkAccess("write", "", $this->ref_id))
3811  {
3812  $this->ctrl->saveParameterByClass($this->ctrl->getCmdClass(), 'q_id');
3813  // edit page
3814  $tabs_gui->setBackTarget($this->lng->txt("backtocallingtest"), $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), "questions"));
3815  $tabs_gui->addTarget("tst_browse_for_questions",
3816  $this->ctrl->getLinkTarget($this, "browseForQuestions"),
3817  array("browseForQuestions", "filter", "resetFilter", "resetTextFilter", "insertQuestions"),
3818  "", "", TRUE
3819  );
3820  }
3821  }
3822 
3823  function getRandomQuestionsTab(&$tabs_gui)
3824  {
3825  global $ilAccess;
3826  if ($ilAccess->checkAccess("write", "", $this->ref_id))
3827  {
3828  // edit page
3829  $tabs_gui->setBackTarget($this->lng->txt("backtocallingtest"), $this->ctrl->getLinkTarget($this, "questions"));
3830  $tabs_gui->addTarget("random_selection",
3831  $this->ctrl->getLinkTarget($this, "randomQuestions"),
3832  array("randomQuestions"),
3833  "", ""
3834  );
3835  }
3836  }
3837 
3838  function statisticsObject()
3839  {
3840  }
3841 
3846  {
3847  include_once "./Services/Certificate/classes/class.ilCertificateGUI.php";
3848  include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
3849  $output_gui = new ilCertificateGUI(new ilTestCertificateAdapter($this->object));
3850  $output_gui->certificateEditor();
3851  }
3852 
3854  {
3855  global $ilTabs, $ilCtrl;
3856  $ilTabs->activateTab('assQuestions');
3857  $a_cmd = $ilCtrl->getCmd();
3858 
3859  if (!$this->object->isRandomTest())
3860  {
3861  #if (in_array($this->object->getEnabledViewMode(), array('both', 'express'))) {
3862  $questions_per_page = ($a_cmd == 'questions_per_page' || ($a_cmd == 'removeQuestions' && $_REQUEST['test_express_mode'])) ? true : false;
3863 
3864  $this->tabs_gui->addSubTabTarget(
3865  "questions_per_page_view",
3866  $this->ctrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'showPage'),
3867  "", "", "", $questions_per_page);
3868  #}
3869  }
3870  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
3871  $template = new ilSettingsTemplate($this->object->getTemplate(), ilObjAssessmentFolderGUI::getSettingsTemplateConfig());
3872 
3873  if (!in_array('questions', $template->getHiddenTabs())) {
3874  // questions subtab
3875  $ilTabs->addSubTabTarget("edit_test_questions",
3876  $this->ctrl->getLinkTarget($this,'questions'),
3877  array("questions", "browseForQuestions", "questionBrowser", "createQuestion",
3878  "randomselect", "filter", "resetFilter", "insertQuestions",
3879  "back", "createRandomSelection", "cancelRandomSelect",
3880  "insertRandomSelection", "removeQuestions", "moveQuestions",
3881  "insertQuestionsBefore", "insertQuestionsAfter", "confirmRemoveQuestions",
3882  "cancelRemoveQuestions", "executeCreateQuestion", "cancelCreateQuestion",
3883  "addQuestionpool", "saveRandomQuestions", "saveQuestionSelectionMode"),
3884  "");
3885 
3886  if (in_array($a_cmd, array('questions', 'createQuestion')) || ($a_cmd == 'removeQuestions' && !$_REQUEST['test_express_mode']))
3887  $this->tabs_gui->activateSubTab('edit_test_questions');
3888  }
3889  #}
3890 
3891  // print view subtab
3892  if (!$this->object->isRandomTest())
3893  {
3894  $ilTabs->addSubTabTarget("print_view",
3895  $this->ctrl->getLinkTarget($this,'print'),
3896  "print", "", "", $this->ctrl->getCmd() == 'print');
3897  $ilTabs->addSubTabTarget('review_view',
3898  $this->ctrl->getLinkTarget($this, 'review'),
3899  'review', '', '', $this->ctrl->getCmd() == 'review');
3900  }
3901 
3902 
3903  }
3904 
3906  {
3907  global $ilTabs;
3908 
3909  // user results subtab
3910  $ilTabs->addSubTabTarget("eval_all_users",
3911  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "outEvaluation"),
3912  array("outEvaluation", "detailedEvaluation", "exportEvaluation", "evalUserDetail", "passDetails",
3913  "outStatisticsResultsOverview", "statisticsPassDetails")
3914  , "");
3915 
3916  // aggregated results subtab
3917  $ilTabs->addSubTabTarget("tst_results_aggregated",
3918  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "eval_a"),
3919  array("eval_a"),
3920  "", "");
3921 
3922  // question export
3923  $ilTabs->addSubTabTarget("tst_single_results",
3924  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "singleResults"),
3925  array("singleResults"),
3926  "", "");
3927  }
3928 
3929  function getSettingsSubTabs($hiddenTabs = array())
3930  {
3934  global $ilTabs, $ilias;
3935 
3936  // general subtab
3937  $ilTabs->addSubTabTarget('general', $this->ctrl->getLinkTargetByClass('ilObjTestSettingsGeneralGUI'),
3938  '', // auto activation regardless from cmd
3939  array('ilobjtestsettingsgeneralgui') // auto activation for ilObjTestSettingsGeneralGUI
3940  );
3941 
3942  if(!in_array('mark_schema', $hiddenTabs))
3943  {
3944  $ilTabs->addSubTabTarget(
3945  'mark_schema',
3946  $this->ctrl->getLinkTargetByClass('ilmarkschemagui', 'showMarkSchema'),
3947  '',
3948  array('ilmarkschemagui')
3949  );
3950  }
3951 
3952  // scoring subtab
3953  $ilTabs->addSubTabTarget('scoring', $this->ctrl->getLinkTargetByClass('ilObjTestSettingsScoringResultsGUI'),
3954  '', // auto activation regardless from cmd
3955  array('ilobjtestsettingsscoringresultsgui') // auto activation for ilObjTestSettingsScoringResultsGUI
3956  );
3957 
3958  // certificate subtab
3959  include_once "Services/Certificate/classes/class.ilCertificate.php";
3960  if( !in_array('certificate', $hiddenTabs) && ilCertificate::isActive())
3961  {
3962  $ilTabs->addSubTabTarget(
3963  "certificate",
3964  $this->ctrl->getLinkTarget($this,'certificate'),
3965  array("certificate", "certificateEditor", "certificateRemoveBackground", "certificateSave",
3966  "certificatePreview", "certificateDelete", "certificateUpload", "certificateImport"),
3967  array("", "ilobjtestgui", "ilcertificategui")
3968  );
3969  }
3970 
3971  if (!in_array('defaults', $hiddenTabs)) {
3972  // defaults subtab
3973  $ilTabs->addSubTabTarget(
3974  "tst_default_settings",
3975  $this->ctrl->getLinkTarget($this, "defaults"),
3976  array("defaults", "deleteDefaults", "addDefaults", "applyDefaults"),
3977  array("", "ilobjtestgui", "ilcertificategui")
3978  );
3979  }
3980  }
3981 
3983  {
3984  global $ilTabs;
3985 
3986  // participants subtab
3987  $ilTabs->addSubTabTarget( "participants",
3988  $this->ctrl->getLinkTarget($this,'participants'),
3989  array(
3990  "participants", "saveClientIP",
3991  "removeParticipant",
3992  "showParticipantAnswersForAuthor",
3993  "deleteAllUserResults",
3994  "cancelDeleteAllUserData", "deleteSingleUserResults",
3995  "outParticipantsResultsOverview", "outParticipantsPassDetails",
3996  "showPassOverview", "showUserAnswers", "participantsAction",
3997  "showDetailedResults",
3998  'npResetFilter', 'npSetFilter'
3999  ),
4000  ""
4001  );
4002 
4003  if( !$this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken() )
4004  {
4005  if($this->object->getProcessingTimeInSeconds() > 0 && $this->object->getNrOfTries() == 1)
4006  {
4007  // extratime subtab
4008  $ilTabs->addSubTabTarget( "timing",
4009  $this->ctrl->getLinkTarget($this,'timingOverview'),
4010  array("timing", "timingOverview"), "", ""
4011  );
4012  }
4013  }
4014  }
4015 
4021  function getTabs(&$tabs_gui)
4022  {
4023  global $ilAccess, $ilUser, $ilHelp;
4024 
4025  if (preg_match('/^ass(.*?)gui$/i', $this->ctrl->getNextClass($this))) {
4026  return;
4027  }
4028  else if ($this->ctrl->getNextClass($this) == 'ilassquestionpagegui') {
4029  return;
4030  }
4031 
4032  $ilHelp->setScreenIdComponent("tst");
4033 
4034  $hidden_tabs = array();
4035 
4036  $template = $this->object->getTemplate();
4037  if($template)
4038  {
4039  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
4041 
4042  $hidden_tabs = $template->getHiddenTabs();
4043  }
4044 
4045  // for local use in this fucking sledge hammer method
4046  $curUserHasWriteAccess = $ilAccess->checkAccess("write", "", $this->ref_id);
4047 
4048  switch( $this->ctrl->getCmdClass() )
4049  {
4050  case 'iltestoutputgui':
4051 
4052  return; // no tabs .. no subtabs .. during test pass
4053 
4054  case 'ilmarkschemagui':
4055  case 'ilobjtestsettingsgeneralgui':
4056  case 'ilobjtestsettingsscoringresultsgui':
4057 
4058  if( $curUserHasWriteAccess )
4059  {
4060  $this->getSettingsSubTabs($hidden_tabs);
4061  }
4062 
4063  break;
4064  }
4065 
4066  switch ($this->ctrl->getCmd())
4067  {
4068  case "resume":
4069  case "previous":
4070  case "next":
4071  case "summary":
4072  case "directfeedback":
4073  case "finishTest":
4074  case "outCorrectSolution":
4075  case "passDetails":
4076  case "showAnswersOfUser":
4077  case "outUserResultsOverview":
4078  case "backFromSummary":
4079  case "show_answers":
4080  case "setsolved":
4081  case "resetsolved":
4082  case "confirmFinish":
4083  case "outTestSummary":
4084  case "outQuestionSummary":
4085  case "gotoQuestion":
4086  case "selectImagemapRegion":
4087  case "confirmSubmitAnswers":
4088  case "finalSubmission":
4089  case "postpone":
4090  case "redirectQuestion":
4091  case "outUserPassDetails":
4092  case "checkPassword":
4093  case "exportCertificate":
4094  case "finishListOfAnswers":
4095  case "backConfirmFinish":
4096  case "showFinalStatement":
4097  return;
4098  break;
4099  case "browseForQuestions":
4100  case "filter":
4101  case "resetFilter":
4102  case "resetTextFilter":
4103  case "insertQuestions":
4104  // #8497: resetfilter is also used in lp
4105  if($this->ctrl->getNextClass($this) != "illearningprogressgui")
4106  {
4107  return $this->getBrowseForQuestionsTab($tabs_gui);
4108  }
4109  break;
4110  case "scoring":
4111  case "certificate":
4112  case "certificateservice":
4113  case "certificateImport":
4114  case "certificateUpload":
4115  case "certificateEditor":
4116  case "certificateDelete":
4117  case "certificateSave":
4118  case "defaults":
4119  case "deleteDefaults":
4120  case "addDefaults":
4121  case "applyDefaults":
4122  case "inviteParticipants":
4123  case "searchParticipants":
4124  if( $curUserHasWriteAccess && in_array($this->ctrl->getCmdClass(), array('ilobjtestgui', 'ilcertificategui')) )
4125  {
4126  $this->getSettingsSubTabs($hidden_tabs);
4127  }
4128  break;
4129  case "export":
4130  case "print":
4131  break;
4132  case "statistics":
4133  case "eval_a":
4134  case "detailedEvaluation":
4135  case "outEvaluation":
4136  case "singleResults":
4137  case "exportEvaluation":
4138  case "evalUserDetail":
4139  case "passDetails":
4140  case "outStatisticsResultsOverview":
4141  case "statisticsPassDetails":
4142  $this->getStatisticsSubTabs();
4143  break;
4144  }
4145 
4146  if (strcmp(strtolower(get_class($this->object)), "ilobjtest") == 0)
4147  {
4148  // questions tab
4149  if ($ilAccess->checkAccess("write", "", $this->ref_id) && !in_array('assQuestions', $hidden_tabs))
4150  {
4151  $force_active = ($_GET["up"] != "" || $_GET["down"] != "")
4152  ? true
4153  : false;
4154  if (!$force_active)
4155  {
4156  if ($_GET["browse"] == 1) $force_active = true;
4157  }
4158 
4159  switch( $this->object->getQuestionSetType() )
4160  {
4162  $target = $this->ctrl->getLinkTargetByClass('iltestexpresspageobjectgui','showPage');
4163  break;
4164 
4166  $target = $this->ctrl->getLinkTargetByClass('ilTestRandomQuestionSetConfigGUI');
4167  break;
4168 
4170  $target = $this->ctrl->getLinkTargetByClass('ilObjTestDynamicQuestionSetConfigGUI');
4171  break;
4172  }
4173 
4174  $tabs_gui->addTarget("assQuestions",
4175  //$this->ctrl->getLinkTarget($this,'questions'),
4176  $target,
4177  array("questions", "browseForQuestions", "questionBrowser", "createQuestion",
4178  "randomselect", "filter", "resetFilter", "insertQuestions",
4179  "back", "createRandomSelection", "cancelRandomSelect",
4180  "insertRandomSelection", "removeQuestions", "moveQuestions",
4181  "insertQuestionsBefore", "insertQuestionsAfter", "confirmRemoveQuestions",
4182  "cancelRemoveQuestions", "executeCreateQuestion", "cancelCreateQuestion",
4183  "addQuestionpool", "saveRandomQuestions", "saveQuestionSelectionMode", "print",
4184  "addsource", "removesource", "randomQuestions"),
4185  "", "", $force_active);
4186  }
4187 
4188  // info tab
4189  if ($ilAccess->checkAccess("read", "", $this->ref_id) && !in_array('info_short', $hidden_tabs))
4190  {
4191  $tabs_gui->addTarget("info_short",
4192  $this->ctrl->getLinkTarget($this,'infoScreen'),
4193  array("infoScreen", "outIntroductionPage", "showSummary",
4194  "setAnonymousId", "outUserListOfAnswerPasses", "redirectToInfoScreen"));
4195  }
4196 
4197  // settings tab
4198  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4199  {
4200  if (!in_array('settings', $hidden_tabs))
4201  {
4202  $settingsCommands = array(
4203  "marks", "showMarkSchema","addMarkStep", "deleteMarkSteps", "addSimpleMarkSchema", "saveMarks",
4204  "certificate", "certificateEditor", "certificateRemoveBackground", "certificateSave",
4205  "certificatePreview", "certificateDelete", "certificateUpload", "certificateImport",
4206  "scoring", "defaults", "addDefaults", "deleteDefaults", "applyDefaults",
4207  "inviteParticipants", "saveFixedParticipantsStatus", "searchParticipants", "addParticipants" // ARE THEY RIGHT HERE
4208  );
4209 
4210  require_once 'Modules/Test/classes/class.ilObjTestSettingsGeneralGUI.php';
4211  $reflection = new ReflectionClass('ilObjTestSettingsGeneralGUI');
4212  foreach($reflection->getConstants() as $name => $value)
4213  if(substr($name, 0, 4) == 'CMD_') $settingsCommands[] = $value;
4214 
4215  require_once 'Modules/Test/classes/class.ilObjTestSettingsScoringResultsGUI.php';
4216  $reflection = new ReflectionClass('ilObjTestSettingsScoringResultsGUI');
4217  foreach($reflection->getConstants() as $name => $value)
4218  if(substr($name, 0, 4) == 'CMD_') $settingsCommands[] = $value;
4219 
4220  $settingsCommands[] = ""; // DO NOT KNOW WHAT THIS IS DOING, BUT IT'S REQUIRED
4221 
4222  $tabs_gui->addTarget("settings",
4223  $this->ctrl->getLinkTargetByClass('ilObjTestSettingsGeneralGUI'),
4224  $settingsCommands,
4225  array("ilmarkschemagui", "ilobjtestsettingsgeneralgui", "ilobjtestsettingsscoringresultsgui", "ilobjtestgui", "ilcertificategui")
4226  );
4227  }
4228 
4229  // skill service
4230  if( $this->object->isSkillServiceEnabled() && ilObjTest::isSkillManagementGloballyActivated() )
4231  {
4232  require_once 'Modules/Test/classes/class.ilTestSkillQuestionAssignmentsGUI.php';
4233 
4234  $link = $this->ctrl->getLinkTargetByClass(
4235  array('ilTestSkillAdministrationGUI', 'ilTestSkillQuestionAssignmentsGUI'),
4237  );
4238 
4239  $tabs_gui->addTarget('tst_tab_competences', $link, array(), array());
4240  }
4241 
4242  if (!in_array('participants', $hidden_tabs))
4243  {
4244  // participants
4245  $tabs_gui->addTarget("participants",
4246  $this->ctrl->getLinkTarget($this,'participants'),
4247  array(
4248  "participants", "saveClientIP",
4249  "removeParticipant",
4250  "showParticipantAnswersForAuthor",
4251  "deleteAllUserResults",
4252  "cancelDeleteAllUserData", "deleteSingleUserResults",
4253  "outParticipantsResultsOverview", "outParticipantsPassDetails",
4254  "showPassOverview", "showUserAnswers", "participantsAction",
4255  "showDetailedResults",
4256  'timing', 'timingOverview', 'npResetFilter', 'npSetFilter', 'showTimingForm'
4257  ),
4258  ""
4259  );
4260  }
4261  }
4262 
4263  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
4264  if(ilLearningProgressAccess::checkAccess($this->object->getRefId()) && !in_array('learning_progress', $hidden_tabs))
4265  {
4266  $tabs_gui->addTarget('learning_progress',
4267  $this->ctrl->getLinkTargetByClass(array('illearningprogressgui'),''),
4268  '',
4269  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui'));
4270  }
4271 
4272  if ($ilAccess->checkAccess("write", "", $this->ref_id) && !in_array('manscoring', $hidden_tabs))
4273  {
4274  include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
4276  if (count($scoring))
4277  {
4278  // scoring tab
4279  $tabs_gui->addTarget(
4280  "manscoring", $this->ctrl->getLinkTargetByClass('ilTestScoringGUI', 'showManScoringParticipantsTable'),
4281  array(
4282  'showManScoringParticipantsTable', 'applyManScoringParticipantsFilter', 'resetManScoringParticipantsFilter', 'showManScoringParticipantScreen',
4283  'showManScoringByQuestionParticipantsTable', 'applyManScoringByQuestionFilter', 'resetManScoringByQuestionFilter', 'saveManScoringByQuestion'
4284 
4285  ), ''
4286  );
4287  }
4288  }
4289 
4290  // Scoring Adjustment
4291  $setting = new ilSetting('assessment');
4292  $scoring_adjust_active = (bool) $setting->get('assessment_adjustments_enabled', false);
4293  if ($ilAccess->checkAccess("write", "", $this->ref_id) && $scoring_adjust_active && !in_array('scoringadjust', $hidden_tabs))
4294  {
4295  // scoring tab
4296  $tabs_gui->addTarget(
4297  "scoringadjust", $this->ctrl->getLinkTargetByClass('ilScoringAdjustmentGUI', 'showquestionlist'),
4298  array(
4299  'showquestionlist',
4300  'savescoringfortest',
4301  'adjustscoringfortest'
4302  ), ''
4303  );
4304  }
4305 
4306  if ((($ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) || ($ilAccess->checkAccess("write", "", $this->ref_id))) && !in_array('statistics', $hidden_tabs))
4307  {
4308  // statistics tab
4309  $tabs_gui->addTarget(
4310  "statistics",
4311  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "outEvaluation"),
4312  array(
4313  "statistics", "outEvaluation", "exportEvaluation", "detailedEvaluation", "eval_a", "evalUserDetail",
4314  "passDetails", "outStatisticsResultsOverview", "statisticsPassDetails", "singleResults"
4315  ),
4316  ""
4317  );
4318  }
4319 
4320  if ($ilAccess->checkAccess("write", "", $this->ref_id))
4321  {
4322  if (!in_array('history', $hidden_tabs)) {
4323 
4324  // history
4325  $tabs_gui->addTarget("history",
4326  $this->ctrl->getLinkTarget($this,'history'),
4327  "history", "");
4328  }
4329 
4330  if (!in_array('meta_data', $hidden_tabs)) {
4331  // meta data
4332  $tabs_gui->addTarget("meta_data",
4333  $this->ctrl->getLinkTargetByClass('ilmdeditorgui','listSection'),
4334  "", "ilmdeditorgui");
4335  }
4336 
4337  if(!in_array('export', $hidden_tabs))
4338  {
4339  // export tab
4340  $tabs_gui->addTarget(
4341  "export",
4342  $this->ctrl->getLinkTargetByClass('iltestexportgui' ,''),
4343  '',
4344  array('iltestexportgui')
4345  );
4346  }
4347  }
4348 
4349  if ($ilAccess->checkAccess("edit_permission", "", $this->ref_id)&& !in_array('permissions', $hidden_tabs))
4350  {
4351  $tabs_gui->addTarget("perm_settings",
4352  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"), array("perm","info","owner"), 'ilpermissiongui');
4353  }
4354  }
4355 
4356  if( $this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken() )
4357  {
4358  $hideTabs = $this->testQuestionSetConfigFactory->getQuestionSetConfig()->getHiddenTabsOnBrokenDepencies();
4359 
4360  foreach($hideTabs as $tabId)
4361  {
4362  $tabs_gui->removeTab($tabId);
4363  }
4364  }
4365  }
4366 
4375  public static function _goto($a_target)
4376  {
4377  global $ilAccess, $ilErr, $lng;
4378 
4379  if ($ilAccess->checkAccess("read", "", $a_target))
4380  {
4381  //include_once "./Services/Utilities/classes/class.ilUtil.php";
4382  $_GET["baseClass"] = "ilObjTestGUI";
4383  $_GET["cmd"] = "infoScreen";
4384  $_GET["ref_id"] = $a_target;
4385  include_once("ilias.php");
4386  exit;
4387  //ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=infoScreen&ref_id=$a_target");
4388  }
4389  else if ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID))
4390  {
4391  ilUtil::sendInfo(sprintf($lng->txt("msg_no_perm_read_item"),
4392  ilObject::_lookupTitle(ilObject::_lookupObjId($a_target))), true);
4394  }
4395 
4396  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
4397  }
4398 
4405  function buildPageViewToolbar($qid = 0)
4406  {
4407  if($this->create_question_mode)
4408  return;
4409 
4410  global $ilToolbar, $ilCtrl, $lng;
4411 
4412  require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
4413 
4414  $this->getQuestionsSubTabs();
4415 
4416  $ilCtrl->saveParameter($this, 'q_mode');
4417 
4418  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'test_express_mode', 1);
4419  $ilCtrl->setParameter($this, 'test_express_mode', 1);
4420  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'q_id', $_REQUEST['q_id']);
4421  $ilCtrl->setParameter($this, 'q_id', $_REQUEST['q_id']);
4422  $ilToolbar->setFormAction($ilCtrl->getFormActionByClass('iltestexpresspageobjectgui', 'edit'));
4423 
4424  if($this->object->evalTotalPersons() == 0)
4425  {
4426  /*
4427  include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
4428  $pool = new ilObjQuestionPool();
4429  $questionTypes = $pool->getQuestionTypes();$options = array();
4430  foreach($questionTypes as $label => $data) {
4431  $options[$data['question_type_id']] = $label;
4432  }
4433 
4434  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
4435  $si = new ilSelectInputGUI($lng->txt("test_add_new_question"), "qtype");
4436  $si->setOptions($options);
4437  $ilToolbar->addInputItem($si, true);
4438  /*
4439  // use pool
4440  if ($this->object->isExpressModeQuestionPoolAllowed()) {
4441  include_once("./Services/Form/classes/class.ilCheckboxInputGUI.php");
4442  $cb = new ilCheckboxInputGUI($lng->txt("test_use_pool"), "use_pool");
4443  $ilToolbar->addInputItem($cb, true);
4444  }
4445  */
4446  $ilToolbar->addFormButton($lng->txt("ass_create_question"), "addQuestion");
4447 
4448  $ilToolbar->addSeparator();
4449 
4450  if($this->object->getPoolUsage())
4451  {
4452  $ilToolbar->addFormButton($lng->txt("tst_browse_for_questions"), "browseForQuestions");
4453 
4454  $show_separator = true;
4455  }
4456  }
4457 
4458  $questions = $this->object->getQuestionTitlesAndIndexes();
4459 
4460  // desc
4461  $options = array();
4462  foreach($questions as $id => $label)
4463  {
4464  $options[$id] = $label . ' ['. $this->lng->txt('question_id_short') . ': ' . $id . ']';
4465  }
4466 
4467  $optionKeys = array_keys($options);
4468 
4469  if(!$options)
4470  {
4471  $options[] = $lng->txt('none');
4472  }
4473  //else if (count($options) > 1) {
4474 // $addSeparator = false;
4475 // if ($optionKeys[0] != $qid) {
4476 // //$ilToolbar->addFormButton($lng->txt("test_prev_question"), "prevQuestion");
4477 // $ilToolbar->addLink($lng->txt("test_prev_question"), $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'prevQuestion'));
4478 // $addSeparator = true;
4479 // }
4480 // else {
4481 // $ilToolbar->addSpacer(45);
4482 // }
4483 //
4484 // if ($optionKeys[count($optionKeys)-1] != $qid) {
4485 // //$ilToolbar->addFormButton($lng->txt("test_next_question"), "nextQuestion");
4486 // $ilToolbar->addLink($lng->txt("test_next_question"), $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'nextQuestion'));
4487 // $addSeparator = true;
4488 // }
4489 // else {
4490 // $ilToolbar->addSpacer(45);
4491 // }
4492 //
4493 // //if ($addSeparator) {
4494 // $ilToolbar->addSeparator();
4495 // //}
4496 
4497  if(count($questions))
4498  {
4499  if(isset($show_separator) && $show_separator)
4500  {
4501  $ilToolbar->addSeparator();
4502  }
4503 
4504  $btn = ilLinkButton::getInstance();
4505  $btn->setCaption("test_prev_question");
4506  $btn->setUrl($ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'prevQuestion'));
4507  $ilToolbar->addButtonInstance($btn);
4508 
4509  if( count($options) <= 1 || $optionKeys[0] == $qid )
4510  {
4511  $btn->setDisabled(true);
4512  }
4513 
4514  $btn = ilLinkButton::getInstance();
4515  $btn->setCaption("test_next_question");
4516  $btn->setUrl($ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'nextQuestion'));
4517  $ilToolbar->addButtonInstance($btn);
4518 
4519  if( count($options) <= 1 || $optionKeys[count($optionKeys) - 1] == $qid )
4520  {
4521  $btn->setDisabled(true);
4522  }
4523  }
4524 
4525  if(count($questions) > 1)
4526  {
4527 
4528  $ilToolbar->addSeparator();
4529 
4530  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
4531  $si = new ilSelectInputGUI($lng->txt("test_jump_to"), "q_id");
4532  $si->addCustomAttribute("onChange=\"forms['ilToolbar'].submit();\"");
4533  $si->setOptions($options);
4534 
4535  if($qid)
4536  {
4537  $si->setValue($qid);
4538  }
4539 
4540  $ilToolbar->addInputItem($si, true);
4541  }
4542 
4543  $total = $this->object->evalTotalPersons();
4544 
4545  /*if (count($options)) {
4546  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
4547  $si = new ilSelectInputGUI($lng->txt("test_jump_to"), "q_id");
4548  $si->addCustomAttribute("onChange=\"forms['ilToolbar'].submit();\"");
4549  $si->setOptions($options);
4550 
4551  if ($qid) {
4552  $si->setValue($qid);
4553  }
4554 
4555  $ilToolbar->addInputItem($si, true);
4556  }*/
4557 
4558  if(count($questions) && !$total)
4559  {
4560  $ilCtrl->setParameter($this, 'q_id', $_REQUEST['q_id']);
4561  $ilToolbar->addSeparator();
4562  $ilToolbar->addButton($lng->txt("test_delete_page"), $ilCtrl->getLinkTarget($this, "removeQuestions"));
4563  }
4564 
4565  if(count($questions) > 1 && !$total)
4566  {
4567  $ilToolbar->addSeparator();
4568  $ilToolbar->addButton($lng->txt("test_move_page"), $ilCtrl->getLinkTarget($this, "movePageForm"));
4569  }
4570 
4571  global $ilAccess, $ilUser;
4572 
4573  $online_access = false;
4574  if($this->object->getFixedParticipants())
4575  {
4576  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
4577  $online_access_result = ilObjTestAccess::_lookupOnlineTestAccess($this->object->getId(), $ilUser->getId());
4578  if($online_access_result === true)
4579  {
4580  $online_access = true;
4581  }
4582  }
4583 
4584  if($this->object->isOnline() && $this->object->isComplete( $this->testQuestionSetConfigFactory->getQuestionSetConfig() ))
4585  {
4586  if((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id))
4587  {
4588  $testSession = $this->testSessionFactory->getSession();
4589 
4590  $executable = $this->object->isExecutable($testSession, $ilUser->getId(), $allowPassIncrease = TRUE);
4591 
4592  if($executable["executable"])
4593  {
4594  $player_factory = new ilTestPlayerFactory($this->object);
4595  $player_instance = $player_factory->getPlayerGUI();
4596 
4597  if ($testSession->getActiveId() > 0)
4598  {
4599  $ilToolbar->addSeparator();
4600  $ilToolbar->addButton($lng->txt('tst_resume_test'), $ilCtrl->getLinkTarget($player_instance, 'resumePlayer'));
4601  }
4602  else
4603  {
4604  $ilToolbar->addSeparator();
4605  $ilToolbar->addButton($lng->txt('tst_start_test'), $ilCtrl->getLinkTarget($player_instance, 'startTest'));
4606  }
4607  }
4608  }
4609  }
4610  }
4611 
4612  public function copyQuestionsToPoolObject()
4613  {
4614  $this->copyQuestionsToPool($_REQUEST['q_id'], $_REQUEST['sel_qpl']);
4615  $this->backObject();
4616  }
4617 
4618  public function copyQuestionsToPool($questionIds, $qplId)
4619  {
4620  $newIds = array();
4621  foreach($questionIds as $q_id)
4622  {
4623  $newId = $this->copyQuestionToPool($q_id, $qplId);
4624  $newIds[$q_id] = $newId;
4625  }
4626 
4627  $result = new stdClass();
4628  $result->ids = $newIds;
4629  $result->qpoolid = $qplId;
4630 
4631  return $result;
4632  }
4633 
4634  public function copyQuestionToPool($sourceQuestionId, $targetParentId)
4635  {
4636  require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
4637  $question_gui = assQuestion::instantiateQuestionGUI($sourceQuestionId);
4638 
4639  $newtitle = $question_gui->object->getTitle();
4640  if ($question_gui->object->questionTitleExists($targetParentId, $question_gui->object->getTitle()))
4641  {
4642  $counter = 2;
4643  while ($question_gui->object->questionTitleExists($targetParentId, $question_gui->object->getTitle() . " ($counter)"))
4644  {
4645  $counter++;
4646  }
4647  $newtitle = $question_gui->object->getTitle() . " ($counter)";
4648  }
4649 
4650  return $question_gui->object->createNewOriginalFromThisDuplicate($targetParentId, $newtitle);
4651  }
4652 
4657  {
4658  global $ilObjDataCache;
4659 
4660  $qplId = $ilObjDataCache->lookupObjId($_REQUEST['sel_qpl']);
4661  $result = $this->copyQuestionsToPool($_REQUEST['q_id'], $qplId);
4662 
4663  foreach($result->ids as $oldId => $newId)
4664  {
4665  $questionInstance = assQuestion::_instanciateQuestion($oldId);
4666 
4667  if( assQuestion::originalQuestionExists($questionInstance->getOriginalId()) )
4668  {
4669  $oldOriginal = assQuestion::_instanciateQuestion($questionInstance->getOriginalId());
4670  $oldOriginal->delete($oldOriginal->getId());
4671  }
4672 
4673  $questionInstance->setNewOriginalId($newId);
4674  }
4675 
4676  $this->backObject();
4677  }
4678 
4679  private function getQuestionpoolCreationForm()
4680  {
4681  global $lng;
4682  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
4683  $form = new ilPropertyFormGUI();
4684 
4685  $title = new ilTextInputGUI($lng->txt('title'), 'title');
4686  $title->setRequired(true);
4687  $form->addItem($title);
4688 
4689  $description = new ilTextAreaInputGUI($lng->txt('description'), 'description');
4690  $form->addItem($description);
4691 
4692  $form->addCommandButton('createQuestionPoolAndCopy', $lng->txt('create'));
4693 
4694  if(isset($_REQUEST['q_id']) && is_array($_REQUEST['q_id']))
4695  {
4696  foreach($_REQUEST['q_id'] as $id)
4697  {
4698  $hidden = new ilHiddenInputGUI('q_id[]');
4699  $hidden->setValue($id);
4700  $form->addItem($hidden);
4701  }
4702  }
4703 
4704  return $form;
4705  }
4706 
4707  public function copyToQuestionpoolObject()
4708  {
4709  $this->createQuestionpoolTargetObject('copyQuestionsToPool');
4710  }
4711 
4713  {
4714  global $lng;
4715 
4716  require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
4717 
4718  // #13761; All methods use for this request should be revised, thx japo ;-)
4719  if(
4720  'copyAndLinkToQuestionpool' == $this->ctrl->getCmd() &&
4721  (!isset($_REQUEST['q_id']) || !is_array($_REQUEST['q_id']))
4722  )
4723  {
4724  ilUtil::sendFailure($this->lng->txt('tst_no_question_selected_for_moving_to_qpl'), true);
4725  $this->ctrl->redirect($this, 'questions');
4726  }
4727 
4728  if(isset($_REQUEST['q_id']) && is_array($_REQUEST['q_id']))
4729  {
4730  foreach($_REQUEST['q_id'] as $q_id)
4731  {
4733  {
4734  continue;
4735  }
4736 
4738 
4739  if($type !== 'tst')
4740  {
4741  ilUtil::sendFailure($lng->txt('tst_link_only_unassigned'), true);
4742  $this->backObject();
4743  return;
4744  }
4745  }
4746  }
4747 
4748  $this->createQuestionpoolTargetObject('copyAndLinkQuestionsToPool');
4749  }
4750 
4752  {
4753  $form = $this->getQuestionpoolCreationForm();
4754 
4755  if ($_REQUEST['title'])
4756  {
4757  $title = $_REQUEST['title'];
4758  }
4759  else
4760  {
4761  $title = $_REQUEST['txt_qpl'];
4762  }
4763 
4764  if (!$title)
4765  {
4766  ilUtil::sendInfo($this->lng->txt("questionpool_not_entered"));
4767  return $this->copyAndLinkToQuestionpoolObject();
4768  }
4769 
4770  $ref_id = $this->createQuestionPool($title, $_REQUEST['description']);
4771  $_REQUEST['sel_qpl'] = $ref_id;
4772 
4773  //if ($_REQUEST['link'])
4774  //{
4776  //}
4777  //else
4778  //{
4779  // $this->copyQuestionsToPoolObject();
4780  //}
4781  }
4782 
4790  {
4791  global $ilUser, $ilTabs;
4792  $this->getQuestionsSubTabs();
4793  $ilTabs->activateSubTab('edit_test_questions');
4794 
4795  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_qpl_select_copy.html", "Modules/Test");
4796  $questionpools =& $this->object->getAvailableQuestionpools(FALSE, FALSE, FALSE, TRUE, FALSE, "write");
4797  if(count($questionpools) == 0)
4798  {
4799  $this->tpl->setCurrentBlock("option");
4800  $this->tpl->setVariable("VALUE_QPL", "");
4801  $this->tpl->parseCurrentBlock();
4802  }
4803  else
4804  {
4805  foreach($questionpools as $key => $value)
4806  {
4807  $this->tpl->setCurrentBlock("option");
4808  $this->tpl->setVariable("VALUE_OPTION", $key);
4809  $this->tpl->setVariable("TEXT_OPTION", $value["title"]);
4810  $this->tpl->parseCurrentBlock();
4811  }
4812  }
4813 
4814  if(isset($_REQUEST['q_id']) && is_array($_REQUEST['q_id']))
4815  {
4816  foreach($_REQUEST['q_id'] as $id)
4817  {
4818  $this->tpl->setCurrentBlock("hidden");
4819  $this->tpl->setVariable("HIDDEN_NAME", "q_id[]");
4820  $this->tpl->setVariable("HIDDEN_VALUE", $id);
4821  $this->tpl->parseCurrentBlock();
4822  $this->tpl->setCurrentBlock("adm_content");
4823  }
4824  }
4825  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
4826 
4827  if(count($questionpools) == 0)
4828  {
4829  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_enter_questionpool"));
4830  $cmd = 'createQuestionPoolAndCopy';
4831  }
4832  else
4833  {
4834  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_select_questionpool"));
4835  }
4836 
4837  $this->tpl->setVariable("CMD_SUBMIT", $cmd);
4838  $this->tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit"));
4839  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
4840 
4841  $createForm = $this->getQuestionpoolCreationForm();
4842  switch($cmd)
4843  {
4844  case 'copyAndLinkQuestionsToPool':
4845  $hidden = new ilHiddenInputGUI('link');
4846  $hidden->setValue(1);
4847  $createForm->addItem($hidden);
4848  break;
4849  case 'copyQuestionsToPool':
4850  break;
4851  }
4852  $createForm->setFormAction($this->ctrl->getFormAction($this));
4853 
4854  $this->tpl->parseCurrentBlock();
4855  }
4856 
4857  // begin-patch lok
4858  public function applyTemplate($templateData, $object)
4859  // end-patch lok
4860  {
4861  // map formFieldName => setterName
4862  $simpleSetters = array(
4863 
4864  // general properties
4865  'use_pool' => 'setPoolUsage',
4866  'question_set_type' => 'setQuestionSetType',
4867 
4868  // test intro properties
4869  'intro_enabled' => 'setIntroductionEnabled',
4870  'showinfo' => 'setShowInfo',
4871 
4872  // test access properties
4873  'chb_starting_time' => 'setStartingTimeEnabled',
4874  'chb_ending_time' => 'setEndingTimeEnabled',
4875  'password_enabled' => 'setPasswordEnabled',
4876  'fixedparticipants' => 'setFixedParticipants',
4877  'limitUsers' => 'setLimitUsersEnabled',
4878 
4879  // test run properties
4880  'nr_of_tries' => 'setNrOfTries',
4881  'chb_processing_time' => 'setEnableProcessingTime',
4882  'kiosk' => 'setKiosk',
4883  'examid_in_test_pass' => 'setShowExamIdInTestPassEnabled',
4884 
4885  // question behavior properties
4886  'title_output' => 'setTitleOutput',
4887  'autosave' => null, // handled specially in loop below
4888  'chb_shuffle_questions' => 'setShuffleQuestions',
4889  'offer_hints' => 'setOfferingQuestionHintsEnabled',
4890  'instant_feedback' => 'setScoringFeedbackOptionsByArray',
4891  'obligations_enabled' => 'setObligationsEnabled',
4892 
4893  // test sequence properties
4894  'chb_use_previous_answers' => 'setUsePreviousAnswers',
4895  'chb_show_cancel' => 'setShowCancel',
4896  'chb_postpone' => 'setPostponingEnabled',
4897  'list_of_questions' => 'setListOfQuestionsSettings',
4898  'chb_show_marker' => 'setShowMarker',
4899 
4900  // test finish properties
4901  'enable_examview' => 'setEnableExamview',
4902  'showfinalstatement' => 'setShowFinalStatement',
4903  'redirection_enabled' => null, // handled specially in loop below
4904  'sign_submission' => 'setSignSubmission',
4905  'mailnotification' => 'setMailNotification',
4906 
4907  // scoring options properties
4908  'count_system' => 'setCountSystem',
4909  'mc_scoring' => 'setMCScoring',
4910  'score_cutting' => 'setScoreCutting',
4911  'pass_scoring' => 'setPassScoring',
4912  'pass_deletion_allowed' => 'setPassDeletionAllowed',
4913 
4914  // result summary properties
4915  'results_access_enabled' => 'setScoreReporting',
4916  'grading_status' => 'setShowGradingStatusEnabled',
4917  'grading_mark' => 'setShowGradingMarkEnabled',
4918 
4919  // result details properties
4920  'solution_details' => 'setShowSolutionDetails',
4921  'solution_feedback' => 'setShowSolutionFeedback',
4922  'solution_suggested' => 'setShowSolutionSuggested',
4923  'solution_printview' => 'setShowSolutionPrintview',
4924  'highscore_enabled' => 'setHighscoreEnabled',
4925  'solution_signature' => 'setShowSolutionSignature',
4926  'examid_in_test_res' => 'setShowExamIdInTestResultsEnabled',
4927  'exp_sc_short' => 'setExportSettingsSingleChoiceShort',
4928 
4929  // misc scoring & result properties
4930  'anonymity' => 'setAnonymity',
4931  'enable_archiving' => 'setEnableArchiving'
4932  );
4933 
4934  if (!$templateData['results_presentation']['value'])
4935  {
4936  $templateData['results_presentation']['value'] = array();
4937  }
4938 
4939  foreach($simpleSetters as $field => $setter)
4940  {
4941  if($templateData[$field] && strlen($setter))
4942  {
4943  $object->$setter($templateData[$field]['value']);
4944  continue;
4945  }
4946 
4947  switch($field)
4948  {
4949  case 'autosave':
4950  if( $templateData[$field]['value'] > 0 )
4951  {
4952  $object->setAutosave(true);
4953  $object->setAutosaveIval($templateData[$field]['value'] * 1000);
4954  }
4955  else
4956  {
4957  $object->setAutosave(false);
4958  }
4959  break;
4960 
4961  case 'redirection_enabled':
4962  /* if( $templateData[$field]['value'] > REDIRECT_NONE )
4963  {
4964  $object->setRedirectionMode($templateData[$field]['value']);
4965  }
4966  else
4967  {
4968  $object->setRedirectionMode(REDIRECT_NONE);
4969  } */
4970  if( strlen($templateData[$field]['value']) )
4971  {
4972  $object->setRedirectionMode(REDIRECT_ALWAYS);
4973  $object->setRedirectionUrl($templateData[$field]['value']);
4974  }
4975  else
4976  {
4977  $object->setRedirectionMode(REDIRECT_NONE);
4978  $object->setRedirectionUrl('');
4979  }
4980  }
4981  }
4982  }
4983 
4985  {
4986  global $ilAccess;
4987  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
4988  {
4989  // allow only write access
4990  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
4991  $this->ctrl->redirect($this, "infoScreen");
4992  }
4993 
4994  global $ilCtrl;
4995 
4996  $orders = $obligations = array();
4997 
4998  foreach($_REQUEST['order'] as $qId => $order)
4999  {
5000  $id = (int)str_replace('q_', '', $qId);
5001 
5002  $orders[$id] = $order;
5003  }
5004 
5005  if( $this->object->areObligationsEnabled() && isset($_REQUEST['obligatory']) && is_array($_REQUEST['obligatory']) )
5006  {
5007  foreach($_REQUEST['obligatory'] as $qId => $obligation)
5008  {
5009  $id = (int)str_replace('q_', '', $qId);
5010 
5012  {
5013  $obligations[$id] = $obligation;
5014  }
5015  }
5016  }
5017 
5018  $this->object->setQuestionOrderAndObligations(
5019  $orders, $obligations
5020  );
5021 
5022  $ilCtrl->redirect($this, 'questions');
5023  }
5024 
5028  protected function movePageFormObject()
5029  {
5030  global $lng, $ilCtrl, $tpl;
5031 
5032  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
5033  $form = new ilPropertyFormGUI();
5034  $form->setFormAction($ilCtrl->getFormAction($this, "movePage"));
5035  $form->setTitle($lng->txt("test_move_page"));
5036 
5037  $old_pos = new ilHiddenInputGUI("q_id");
5038  $old_pos->setValue($_REQUEST['q_id']);
5039  $form->addItem($old_pos);
5040 
5041  $questions = $this->object->getQuestionTitlesAndIndexes();
5042  if (!is_array($questions))
5043  $questions = array();
5044 
5045  foreach($questions as $k => $q) {
5046  if ($k == $_REQUEST['q_id']) {
5047  unset($questions[$k]);
5048  continue;
5049  }
5050  $questions[$k] = $lng->txt('behind') . ' '. $q;
5051  }
5052  #$questions['0'] = $lng->txt('first');
5053 
5054  $options = array(
5055  0 => $lng->txt('first')
5056  );
5057  foreach($questions as $k => $q) {
5058  $options[$k] = $q . ' ['. $this->lng->txt('question_id_short') . ': ' . $k . ']';
5059  }
5060 
5061  $pos = new ilSelectInputGUI($lng->txt("position"), "position_after");
5062  $pos->setOptions($options);
5063  $form->addItem($pos);
5064 
5065  $form->addCommandButton("movePage", $lng->txt("submit"));
5066  $form->addCommandButton("showPage", $lng->txt("cancel"));
5067 
5068  return $tpl->setContent($form->getHTML());
5069  }
5070 
5071  public function movePageObject() {
5072  global $ilAccess;
5073  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
5074  {
5075  // allow only write access
5076  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
5077  $this->ctrl->redirect($this, "infoScreen");
5078  }
5079 
5080  $this->object->moveQuestionAfter($_REQUEST['q_id'], $_REQUEST['position_after']);
5081  $this->showPageObject();
5082  }
5083 
5084  public function showPageObject() {
5085  global $ilCtrl;
5086 
5087  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'q_id', $_REQUEST['q_id']);
5088  $ilCtrl->redirectByClass('iltestexpresspageobjectgui', 'showPage');
5089  }
5090 
5091  public function copyQuestionObject() {
5092  global $ilAccess;
5093  if (!$ilAccess->checkAccess("write", "", $this->ref_id))
5094  {
5095  // allow only write access
5096  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
5097  $this->ctrl->redirect($this, "infoScreen");
5098  }
5099 
5100  if ($_REQUEST['q_id'] && !is_array($_REQUEST['q_id']))
5101  $ids = array($_REQUEST['q_id']);
5102  else if ($_REQUEST['q_id'])
5103  $ids = $_REQUEST['q_id'];
5104  else
5105  {
5106  ilUtil::sendFailure( $this->lng->txt('copy_no_questions_selected'), true );
5107  $this->ctrl->redirect($this, 'questions');
5108  }
5109 
5110  $copy_count = 0;
5111 
5112  $questionTitles = $this->object->getQuestionTitles();
5113 
5114  foreach($ids as $id)
5115  {
5116  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
5117  $question = assQuestion::_instanciateQuestionGUI($id);
5118  if ($question)
5119  {
5120  $title = $question->object->getTitle();
5121  $i = 2;
5122  while( in_array( $title . ' (' . $i . ')', $questionTitles ))
5123  $i++;
5124 
5125  $title .= ' (' . $i . ')';
5126 
5127  $questionTitles[] = $title;
5128 
5129  $new_id = $question->object->duplicate(false, $title);
5130 
5131  $clone = assQuestion::_instanciateQuestionGUI($new_id);
5132  $clone->object->setObjId($this->object->getId());
5133  $clone->object->saveToDb();
5134 
5135  $this->object->insertQuestion( $this->testQuestionSetConfigFactory->getQuestionSetConfig(), $new_id, true );
5136 
5137  $copy_count++;
5138  }
5139  }
5140 
5141  ilUtil::sendSuccess($this->lng->txt('copy_questions_success'), true);
5142 
5143  $this->ctrl->redirect($this, 'questions');
5144  }
5145 
5151  private function isDeleteDynamicTestResultsButtonRequired($testSession, $testSequence)
5152  {
5153  if( !$testSession->getActiveId() )
5154  {
5155  return false;
5156  }
5157 
5158  if( !$this->object->isDynamicTest() )
5159  {
5160  return false;
5161  }
5162 
5163  if( !$this->object->isPassDeletionAllowed() )
5164  {
5165  return false;
5166  }
5167 
5168  if( !$testSequence->hasStarted($testSession) )
5169  {
5170  return false;
5171  }
5172 
5173  return true;
5174  }
5175 
5180  private function populateDeleteDynamicTestResultsButton($testSession, &$big_button)
5181  {
5182  require_once 'Modules/Test/classes/confirmations/class.ilTestPassDeletionConfirmationGUI.php';
5183  require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
5184 
5185  $this->ctrl->setParameterByClass(
5186  'iltestevaluationgui', 'context',
5188  );
5189 
5190  $this->ctrl->setParameterByClass('iltestevaluationgui', 'active_id', $testSession->getActiveId());
5191  $this->ctrl->setParameterByClass('iltestevaluationgui', 'pass', $testSession->getPass());
5192 
5193  $btn = ilLinkButton::getInstance();
5194  $btn->setCaption('tst_delete_dyn_test_results_btn');
5195  $btn->setUrl($this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'confirmDeletePass'));
5196  $btn->setPrimary(false);
5197  $big_button[] = $btn;
5198  }
5199 
5203  private function isPdfDeliveryRequest()
5204  {
5205  if( !isset($_GET['pdf']) )
5206  {
5207  return false;
5208  }
5209 
5210  if( !(bool)$_GET['pdf'] )
5211  {
5212  return false;
5213  }
5214 
5215  return true;
5216  }
5217 }