ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 
49 {
50  private static $infoScreenChildClasses = array(
51  'ilpublicuserprofilegui', 'ilobjportfoliogui'
52  );
53 
55  public $object = null;
56 
59 
61  private $testPlayerFactory = null;
62 
64  private $testSessionFactory = null;
65 
67  private $testSequenceFactory = null;
68 
73 
78  public function __construct()
79  {
80  global $lng, $ilCtrl, $ilDB, $ilPluginAdmin, $tree;
81  $lng->loadLanguageModule("assessment");
82  $this->type = "tst";
83  $this->ctrl = $ilCtrl;
84  $this->ctrl->saveParameter($this, array("ref_id", "test_ref_id", "calling_test", "test_express_mode", "q_id"));
85  parent::__construct("", $_GET["ref_id"], true, false);
86 
87  if ($this->object instanceof ilObjTest) {
88  require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
89  $this->testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($tree, $ilDB, $ilPluginAdmin, $this->object);
90 
91  require_once 'Modules/Test/classes/class.ilTestPlayerFactory.php';
92  $this->testPlayerFactory = new ilTestPlayerFactory($this->object);
93 
94  require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
95  $this->testSessionFactory = new ilTestSessionFactory($this->object);
96 
97  require_once 'Modules/Test/classes/class.ilTestSequenceFactory.php';
98  $this->testSequenceFactory = new ilTestSequenceFactory($ilDB, $lng, $ilPluginAdmin, $this->object);
99  }
100 
101  require_once 'Modules/Test/classes/class.ilTestObjectiveOrientedContainer.php';
102  $this->objectiveOrientedContainer = new ilTestObjectiveOrientedContainer();
103  }
104 
108  public function executeCommand()
109  {
110  global $ilAccess, $ilNavigationHistory, $ilCtrl, $ilErr, $tpl, $lng, $ilTabs, $ilPluginAdmin, $ilDB, $tree, $ilias, $ilUser;
111 
112  if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
113  $ilias->raiseError($this->lng->txt("permission_denied"), $ilias->error_obj->MESSAGE);
114  }
115 
116  $cmd = $this->ctrl->getCmd("infoScreen");
117 
118  $cmdsDisabledDueToOfflineStatus = array(
119  'resumePlayer', 'resumePlayer', 'outUserResultsOverview', 'outUserListOfAnswerPasses'
120  );
121 
122  if (!$this->getCreationMode() && !$this->object->isOnline() && in_array($cmd, $cmdsDisabledDueToOfflineStatus)) {
123  $cmd = 'infoScreen';
124  }
125 
126  $next_class = $this->ctrl->getNextClass($this);
127  $this->ctrl->setReturn($this, "infoScreen");
128 
129  if (method_exists($this->object, "getTestStyleLocation")) {
130  $this->tpl->addCss($this->object->getTestStyleLocation("output"), "screen");
131  }
132 
133  // add entry to navigation history
134  if (!$this->getCreationMode() &&
135  $ilAccess->checkAccess("read", "", $_GET["ref_id"])
136  ) {
137  $ilNavigationHistory->addItem(
138  $_GET["ref_id"],
139  "ilias.php?baseClass=ilObjTestGUI&cmd=infoScreen&ref_id=" . $_GET["ref_id"],
140  "tst"
141  );
142  }
143 
144  // elba hack for storing question id for inserting new question after
145  if ($_REQUEST['prev_qid']) {
146  global $___prev_question_id;
147  $___prev_question_id = $_REQUEST['prev_qid'];
148  $this->ctrl->setParameter($this, 'prev_qid', $_REQUEST['prev_qid']);
149  }
150 
151  if (!$this->getCreationMode() && $this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken()) {
152  if (!$this->testQuestionSetConfigFactory->getQuestionSetConfig()->isValidRequestOnBrokenQuestionSetDepencies($next_class, $cmd)) {
153  $this->ctrl->redirectByClass('ilObjTestGUI', 'infoScreen');
154  }
155  }
156 
158 
159  switch ($next_class) {
160  case 'illtiproviderobjectsettinggui':
161  $this->prepareOutput();
162  $this->addHeaderAction();
163  $this->getSettingsSubTabs();
164  $GLOBALS['DIC']->tabs()->activateTab('settings');
165  $GLOBALS['DIC']->tabs()->activateSubTab('lti_provider');
166  $lti_gui = new ilLTIProviderObjectSettingGUI($this->object->getRefId());
167  $lti_gui->setCustomRolesForSelection($GLOBALS['DIC']->rbac()->review()->getLocalRoles($this->object->getRefId()));
168  $lti_gui->offerLTIRolesForSelection(false);
169  $this->ctrl->forwardCommand($lti_gui);
170  break;
171 
172 
173  case 'iltestexportgui':
174  if (!$ilAccess->checkAccess('write', '', $this->ref_id)) {
175  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
176  }
177 
178  $this->prepareOutput();
179  $this->addHeaderAction();
180  require_once 'Modules/Test/classes/class.ilTestExportGUI.php';
181  $ilCtrl->forwardCommand(new ilTestExportGUI($this));
182  break;
183 
184  case "ilinfoscreengui":
185  $this->prepareOutput();
186  $this->addHeaderAction();
187  $this->infoScreen(); // forwards command
188  break;
189  case 'ilobjectmetadatagui':
190  if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
191  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
192  }
193 
194  $this->prepareOutput();
195  $this->addHeaderAction();
196  include_once 'Services/Object/classes/class.ilObjectMetaDataGUI.php';
197  $md_gui = new ilObjectMetaDataGUI($this->object);
198  $this->ctrl->forwardCommand($md_gui);
199  break;
200 
201  case "iltestplayerfixedquestionsetgui":
202  $this->trackTestObjectReadEvent();
203  require_once "./Modules/Test/classes/class.ilTestPlayerFixedQuestionSetGUI.php";
204  if (!$this->object->getKioskMode()) {
205  $this->prepareOutput();
206  }
207  $gui = new ilTestPlayerFixedQuestionSetGUI($this->object);
208  $gui->setObjectiveOrientedContainer($this->getObjectiveOrientedContainer());
209  $this->ctrl->forwardCommand($gui);
210  break;
211 
212  case "iltestplayerrandomquestionsetgui":
213  $this->trackTestObjectReadEvent();
214  require_once "./Modules/Test/classes/class.ilTestPlayerRandomQuestionSetGUI.php";
215  if (!$this->object->getKioskMode()) {
216  $this->prepareOutput();
217  }
218  $gui = new ilTestPlayerRandomQuestionSetGUI($this->object);
219  $gui->setObjectiveOrientedContainer($this->getObjectiveOrientedContainer());
220  $this->ctrl->forwardCommand($gui);
221  break;
222 
223  case "iltestplayerdynamicquestionsetgui":
224  $this->trackTestObjectReadEvent();
225  require_once "./Modules/Test/classes/class.ilTestPlayerDynamicQuestionSetGUI.php";
226  if (!$this->object->getKioskMode()) {
227  $this->prepareOutput();
228  }
229  $gui = new ilTestPlayerDynamicQuestionSetGUI($this->object);
230  $gui->setObjectiveOrientedContainer($this->getObjectiveOrientedContainer());
231  $this->ctrl->forwardCommand($gui);
232  break;
233 
234  case "iltestevaluationgui":
235  $this->forwardToEvaluationGUI();
236  break;
237 
238  case "iltestevalobjectiveorientedgui":
240  break;
241 
242  case "iltestservicegui":
243  $this->prepareOutput();
244  $this->addHeaderAction();
245  require_once "./Modules/Test/classes/class.ilTestServiceGUI.php";
246  $serviceGUI = new ilTestServiceGUI($this->object);
247  $this->ctrl->forwardCommand($serviceGUI);
248  break;
249 
250  case 'ilpermissiongui':
251  $this->prepareOutput();
252  $this->addHeaderAction();
253  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
254  $perm_gui = new ilPermissionGUI($this);
255  $ret = $this->ctrl->forwardCommand($perm_gui);
256  break;
257 
258  case "illearningprogressgui":
259  $this->prepareOutput();
260  $this->addHeaderAction();
261  require_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
263  $this->ctrl->forwardCommand($new_gui);
264 
265  break;
266 
267  case "ilcertificategui":
268  $this->prepareOutput();
269  $this->addHeaderAction();
270  require_once "./Services/Certificate/classes/class.ilCertificateGUI.php";
271  require_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
272  $output_gui = new ilCertificateGUI(new ilTestCertificateAdapter($this->object));
273  $this->ctrl->forwardCommand($output_gui);
274  break;
275 
276  case "iltestscoringgui":
277  $this->prepareOutput();
278  $this->addHeaderAction();
279  require_once "./Modules/Test/classes/class.ilTestScoringGUI.php";
280  $output_gui = new ilTestScoringGUI($this->object);
281  $this->ctrl->forwardCommand($output_gui);
282  break;
283 
284  case 'ilmarkschemagui':
285  if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
286  ilUtil::sendInfo($this->lng->txt('cannot_edit_test'), true);
287  $this->ctrl->redirect($this, 'infoScreen');
288  }
289  $this->prepareOutput();
290  $this->addHeaderAction();
291  require_once 'Modules/Test/classes/class.ilMarkSchemaGUI.php';
292  $mark_schema_gui = new ilMarkSchemaGUI($this->object);
293  $this->ctrl->forwardCommand($mark_schema_gui);
294  break;
295 
296  case 'iltestscoringbyquestionsgui':
297  $this->prepareOutput();
298  $this->addHeaderAction();
299  include_once 'Modules/Test/classes/class.ilTestScoringByQuestionsGUI.php';
300  $output_gui = new ilTestScoringByQuestionsGUI($this->object);
301  $this->ctrl->forwardCommand($output_gui);
302  break;
303 
304  case 'ilobjtestsettingsgeneralgui':
305  $this->prepareOutput();
306  $this->addHeaderAction();
307  require_once 'Modules/Test/classes/class.ilObjTestSettingsGeneralGUI.php';
308  $gui = new ilObjTestSettingsGeneralGUI(
309  $this->ctrl,
310  $ilAccess,
311  $this->lng,
312  $this->tpl,
313  $this->tree,
314  $ilDB,
315  $ilPluginAdmin,
316  $ilUser,
317  $this
318  );
319  $this->ctrl->forwardCommand($gui);
320  break;
321 
322  case 'ilobjtestsettingsscoringresultsgui':
323  $this->prepareOutput();
324  $this->addHeaderAction();
325  require_once 'Modules/Test/classes/class.ilObjTestSettingsScoringResultsGUI.php';
327  $this->ctrl,
328  $ilAccess,
329  $this->lng,
330  $this->tpl,
331  $this->tree,
332  $ilDB,
333  $ilPluginAdmin,
334  $this
335  );
336  $this->ctrl->forwardCommand($gui);
337  break;
338 
339  case 'ilobjtestdynamicquestionsetconfiggui':
340  $this->prepareOutput();
341  $this->addHeaderAction();
342  require_once 'Modules/Test/classes/class.ilObjTestDynamicQuestionSetConfigGUI.php';
343  $gui = new ilObjTestDynamicQuestionSetConfigGUI($this->ctrl, $ilAccess, $ilTabs, $this->lng, $this->tpl, $ilDB, $tree, $ilPluginAdmin, $this->object);
344  $this->ctrl->forwardCommand($gui);
345  break;
346 
347  case 'iltestrandomquestionsetconfiggui':
348  $this->prepareOutput();
349  $this->addHeaderAction();
350  require_once 'Modules/Test/classes/class.ilTestRandomQuestionSetConfigGUI.php';
351  $gui = new ilTestRandomQuestionSetConfigGUI($this->ctrl, $ilAccess, $ilTabs, $this->lng, $this->tpl, $ilDB, $tree, $ilPluginAdmin, $this->object);
352  $this->ctrl->forwardCommand($gui);
353  break;
354 
355  case 'iltestquestionbrowsertablegui':
356  $this->prepareOutput();
357  $this->addHeaderAction();
358  require_once 'Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php';
359  $gui = new ilTestQuestionBrowserTableGUI($this->ctrl, $this->tpl, $ilTabs, $this->lng, $tree, $ilDB, $ilPluginAdmin, $this->object, $ilAccess);
360  $gui->setWriteAccess($ilAccess->checkAccess("write", "", $this->ref_id));
361  $gui->init();
362  $this->ctrl->forwardCommand($gui);
363  break;
364 
365  case 'iltestskilladministrationgui':
366  $this->prepareOutput();
367  $this->addHeaderAction();
368  require_once 'Modules/Test/classes/class.ilTestSkillAdministrationGUI.php';
369  $gui = new ilTestSkillAdministrationGUI($ilias, $this->ctrl, $ilAccess, $ilTabs, $this->tpl, $this->lng, $ilDB, $tree, $ilPluginAdmin, $this->object, $this->ref_id);
370  $this->ctrl->forwardCommand($gui);
371  break;
372 
373  case 'iltestskillevaluationgui':
374  $this->prepareOutput();
375  $this->addHeaderAction();
376 
377  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionList.php';
378  if ($this->object->isDynamicTest()) {
379  require_once 'Modules/Test/classes/class.ilObjTestDynamicQuestionSetConfig.php';
380  $dynamicQuestionSetConfig = new ilObjTestDynamicQuestionSetConfig($tree, $ilDB, $ilPluginAdmin, $this->object);
381  $dynamicQuestionSetConfig->loadFromDb();
382  $questionList = new ilAssQuestionList($ilDB, $this->lng, $ilPluginAdmin);
383  $questionList->setParentObjId($dynamicQuestionSetConfig->getSourceQuestionPoolId());
384  $questionList->setQuestionInstanceTypeFilter(ilAssQuestionList::QUESTION_INSTANCE_TYPE_ORIGINALS);
385  } else {
386  $questionList = new ilAssQuestionList($ilDB, $this->lng, $ilPluginAdmin);
387  $questionList->setParentObjId($this->object->getId());
388  $questionList->setQuestionInstanceTypeFilter(ilAssQuestionList::QUESTION_INSTANCE_TYPE_DUPLICATES);
389  }
390  $questionList->load();
391 
392  require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
393  $testSessionFactory = new ilTestSessionFactory($this->object);
394  $testSession = $testSessionFactory->getSession();
395 
396  require_once 'Modules/Test/classes/class.ilTestSkillEvaluationGUI.php';
397  $gui = new ilTestSkillEvaluationGUI($this->ctrl, $ilTabs, $this->tpl, $this->lng, $ilDB, $this->object);
398  $gui->setQuestionList($questionList);
399  $gui->setTestSession($testSession);
400  $gui->setObjectiveOrientedContainer($this->getObjectiveOrientedContainer());
401  $this->ctrl->forwardCommand($gui);
402  break;
403 
404  case 'ilobjectcopygui':
405  $this->prepareOutput();
406  $this->addHeaderAction();
407  require_once './Services/Object/classes/class.ilObjectCopyGUI.php';
408  $cp = new ilObjectCopyGUI($this);
409  $cp->setType('tst');
410  $this->ctrl->forwardCommand($cp);
411  break;
412 
413  case 'ilrepositorysearchgui':
414  $this->prepareOutput();
415  $this->addHeaderAction();
416  require_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
417  $rep_search = new ilRepositorySearchGUI();
418  $rep_search->setCallback(
419  $this,
420  'addParticipantsObject',
421  array()
422  );
423 
424  // Set tabs
425  $this->ctrl->setReturn($this, 'participants');
426  $ret =&$this->ctrl->forwardCommand($rep_search);
427  $this->tabs_gui->setTabActive('participants');
428  break;
429 
430  case 'ilpageeditorgui':
431  case 'iltestexpresspageobjectgui':
432 
433  require_once 'Modules/TestQuestionPool/classes/class.ilAssIncompleteQuestionPurger.php';
434  $incompleteQuestionPurger = new ilAssIncompleteQuestionPurger($ilDB);
435  $incompleteQuestionPurger->setOwnerId($ilUser->getId());
436  $incompleteQuestionPurger->purge();
437 
438  try {
439  $qid = $this->fetchAuthoringQuestionIdParameter();
440  } catch (ilTestException $e) {
441  $qid = 0;
442  }
443 
444  $this->prepareOutput();
445  if (!in_array($cmd, array('addQuestion', 'browseForQuestions'))) {
446  $this->buildPageViewToolbar($qid);
447  }
448 
449  if (!$qid || in_array($cmd, array('insertQuestions', 'browseForQuestions'))) {
450  require_once "./Modules/Test/classes/class.ilTestExpressPageObjectGUI.php";
451  $pageObject = new ilTestExpressPageObjectGUI(0);
452  $pageObject->test_object = $this->object;
453  $ret =&$this->ctrl->forwardCommand($pageObject);
454  break;
455  }
456  require_once "./Services/Style/Content/classes/class.ilObjStyleSheet.php";
457  $this->tpl->setCurrentBlock("ContentStyle");
458  $this->tpl->setVariable(
459  "LOCATION_CONTENT_STYLESHEET",
461  );
462  $this->tpl->parseCurrentBlock();
463 
464  // syntax style
465  $this->tpl->setCurrentBlock("SyntaxStyle");
466  $this->tpl->setVariable(
467  "LOCATION_SYNTAX_STYLESHEET",
469  );
470  $this->tpl->parseCurrentBlock();
471  require_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
472 
473  $q_gui = assQuestionGUI::_getQuestionGUI("", $qid);
474  if (!($q_gui instanceof assQuestionGUI)) {
475  $this->ctrl->setParameterByClass('iltestexpresspageobjectgui', 'q_id', '');
476  $this->ctrl->redirectByClass('iltestexpresspageobjectgui', $this->ctrl->getCmd());
477  }
478 
479  $q_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_PREVIEW);
480 
481  $q_gui->outAdditionalOutput();
482  $q_gui->object->setObjId($this->object->getId());
483 
484  $q_gui->setTargetGuiClass(null);
485  $q_gui->setQuestionActionCmd(null);
486 
487  $question = $q_gui->object;
488  $this->ctrl->saveParameter($this, "q_id");
489 
490  #$this->lng->loadLanguageModule("content");
491  $this->ctrl->setReturnByClass("ilTestExpressPageObjectGUI", "view");
492  $this->ctrl->setReturn($this, "questions");
493 
494  require_once "./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php";
495  require_once "./Modules/Test/classes/class.ilTestExpressPageObjectGUI.php";
496 
497  $page_gui = new ilTestExpressPageObjectGUI($qid);
498  $page_gui->test_object = $this->object;
499  $page_gui->setEditPreview(true);
500  $page_gui->setEnabledTabs(false);
501  if (strlen($this->ctrl->getCmd()) == 0) {
502  $this->ctrl->setCmdClass(get_class($page_gui));
503  $this->ctrl->setCmd("preview");
504  }
505 
506  $page_gui->setQuestionHTML(array($q_gui->object->getId() => $q_gui->getPreview(true)));
507  $page_gui->setTemplateTargetVar("ADM_CONTENT");
508 
509  $page_gui->setOutputMode($this->object->evalTotalPersons() == 0 ? "edit" : 'preview');
510 
511  $page_gui->setHeader($question->getTitle());
512  $page_gui->setFileDownloadLink($this->ctrl->getLinkTarget($this, "downloadFile"));
513  $page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "fullscreen"));
514  $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTarget($this));
515  $page_gui->setPresentationTitle($question->getTitle() . ' [' . $this->lng->txt('question_id_short') . ': ' . $question->getId() . ']');
516  $ret =&$this->ctrl->forwardCommand($page_gui);
517 
518  global $ilTabs;
519  $ilTabs->activateTab('assQuestions');
520 
521  $this->tpl->setContent($ret);
522  break;
523 
524  case 'ilassquestionpreviewgui':
525 
526  $this->prepareOutput();
527 
528  $this->ctrl->saveParameter($this, "q_id");
529 
530  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionPreviewGUI.php';
531  $gui = new ilAssQuestionPreviewGUI($this->ctrl, $this->tabs_gui, $this->tpl, $this->lng, $ilDB, $ilUser);
532 
533  $gui->initQuestion($this->fetchAuthoringQuestionIdParameter(), $this->object->getId());
534  $gui->initPreviewSettings($this->object->getRefId());
535  $gui->initPreviewSession($ilUser->getId(), (int) $_GET['q_id']);
536  $gui->initHintTracking();
537  $gui->initStyleSheets();
538 
539  $this->ctrl->forwardCommand($gui);
540 
541  break;
542 
543  case 'ilassquestionpagegui':
544 
545  $_GET['q_id'] = $this->fetchAuthoringQuestionIdParameter();
546 
547  require_once "./Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php";
548  //echo $_REQUEST['prev_qid'];
549  if ($_REQUEST['prev_qid']) {
550  $this->ctrl->setParameter($this, 'prev_qid', $_REQUEST['prev_qid']);
551  }
552 
553  $this->prepareOutput();
554  //global $___test_express_mode;
555  //$___test_express_mode = true;
556  $_GET['calling_test'] = $this->object->getRefId();
557  include_once("./Services/Style/Content/classes/class.ilObjStyleSheet.php");
558  $this->tpl->setCurrentBlock("ContentStyle");
559  $this->tpl->setVariable(
560  "LOCATION_CONTENT_STYLESHEET",
562  );
563  $this->tpl->parseCurrentBlock();
564 
565  // syntax style
566  $this->tpl->setCurrentBlock("SyntaxStyle");
567  $this->tpl->setVariable(
568  "LOCATION_SYNTAX_STYLESHEET",
570  );
571  $this->tpl->parseCurrentBlock();
572  require_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
573  $q_gui = assQuestionGUI::_getQuestionGUI("", $_GET["q_id"]);
574  $q_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_PREVIEW);
575  $q_gui->setQuestionTabs();
576  $q_gui->outAdditionalOutput();
577  $q_gui->object->setObjId($this->object->getId());
578  $question =&$q_gui->object;
579  $this->ctrl->saveParameter($this, "q_id");
580  $this->lng->loadLanguageModule("content");
581  $this->ctrl->setReturnByClass("ilAssQuestionPageGUI", "view");
582  $this->ctrl->setReturn($this, "questions");
583  $page_gui = new ilAssQuestionPageGUI($_GET["q_id"]);
584  $page_gui->setEditPreview(true);
585  if (strlen($this->ctrl->getCmd()) == 0) {
586  $this->ctrl->setCmdClass(get_class($page_gui));
587  $this->ctrl->setCmd("preview");
588  }
589  $page_gui->setQuestionHTML(array($q_gui->object->getId() => $q_gui->getPreview(true)));
590  $page_gui->setTemplateTargetVar("ADM_CONTENT");
591  $page_gui->setOutputMode($this->object->evalTotalPersons() == 0 ? "edit" : 'preview');
592  $page_gui->setHeader($question->getTitle());
593  $page_gui->setPresentationTitle($question->getTitle() . ' [' . $this->lng->txt('question_id_short') . ': ' . $question->getId() . ']');
594  $ret =&$this->ctrl->forwardCommand($page_gui);
595  $this->tpl->setContent($ret);
596  break;
597 
598  case 'ilassspecfeedbackpagegui':
599  require_once "./Modules/TestQuestionPool/classes/feedback/class.ilAssSpecFeedbackPageGUI.php";
600  $pg_gui = new ilAssSpecFeedbackPageGUI((int) $_GET["feedback_id"]);
601  $this->ctrl->forwardCommand($pg_gui);
602  break;
603 
604  case 'ilassgenfeedbackpagegui':
605  require_once "./Modules/TestQuestionPool/classes/feedback/class.ilAssGenFeedbackPageGUI.php";
606  $pg_gui = new ilAssGenFeedbackPageGUI((int) $_GET["feedback_id"]);
607  $this->ctrl->forwardCommand($pg_gui);
608  break;
609 
610  case 'illocalunitconfigurationgui':
611  $this->prepareSubGuiOutput();
612 
613  // set return target
614  $this->ctrl->setReturn($this, "questions");
615 
616  // set context tabs
617  require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
619  $questionGUI->object->setObjId($this->object->getId());
620  $questionGUI->setQuestionTabs();
621 
622  require_once 'Modules/TestQuestionPool/classes/class.ilLocalUnitConfigurationGUI.php';
623  require_once 'Modules/TestQuestionPool/classes/class.ilUnitConfigurationRepository.php';
624  $gui = new ilLocalUnitConfigurationGUI(
625  new ilUnitConfigurationRepository((int) $_GET['q_id'])
626  );
627  $this->ctrl->forwardCommand($gui);
628  break;
629 
630  case "ilcommonactiondispatchergui":
631  require_once "Services/Object/classes/class.ilCommonActionDispatcherGUI.php";
633  $this->ctrl->forwardCommand($gui);
634  break;
635 
636  case 'ilassquestionhintsgui':
637 
638  $this->prepareSubGuiOutput();
639 
640  // set return target
641  $this->ctrl->setReturn($this, "questions");
642 
643  // set context tabs
644  require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
645  $questionGUI =&assQuestionGUI::_getQuestionGUI($q_type, $this->fetchAuthoringQuestionIdParameter());
646  $questionGUI->object->setObjId($this->object->getId());
647  $questionGUI->setQuestionTabs();
648 
649  // forward to ilAssQuestionHintsGUI
650  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintsGUI.php';
651  $gui = new ilAssQuestionHintsGUI($questionGUI);
652 
653  global $DIC; /* @var ILIAS\DI\Container $DIC */
654 
655  $gui->setEditingEnabled(
656  $DIC->access()->checkAccess('write', '', $this->object->getRefId())
657  );
658 
659  $ilCtrl->forwardCommand($gui);
660 
661  break;
662 
663  case 'ilassquestionfeedbackeditinggui':
664 
665  $this->prepareSubGuiOutput();
666 
667  // set return target
668  $this->ctrl->setReturn($this, "questions");
669 
670  // set context tabs
671  require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
673  $questionGUI->object->setObjId($this->object->getId());
674  $questionGUI->setQuestionTabs();
675 
676  // forward to ilAssQuestionFeedbackGUI
677  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionFeedbackEditingGUI.php';
678  $gui = new ilAssQuestionFeedbackEditingGUI($questionGUI, $ilCtrl, $ilAccess, $tpl, $ilTabs, $lng);
679  $ilCtrl->forwardCommand($gui);
680 
681  break;
682 
683  case 'iltesttoplistgui':
684  $this->prepareOutput();
685  require_once './Modules/Test/classes/class.ilTestToplistGUI.php';
686  $gui = new ilTestToplistGUI($this);
687  $this->ctrl->forwardCommand($gui);
688  break;
689 
690  case 'ilscoringadjustmentgui':
691  $this->prepareOutput();
692  require_once './Modules/Test/classes/class.ilScoringAdjustmentGUI.php';
693  $gui = new ilScoringAdjustmentGUI($this->object);
694  $this->ctrl->forwardCommand($gui);
695  break;
696 
697  case '':
698  case 'ilobjtestgui':
699  $this->prepareOutput();
700  $this->addHeaderAction();
701  if ((strcmp($cmd, "properties") == 0) && ($_GET["browse"])) {
702  $this->questionBrowser();
703  return;
704  }
705  if ((strcmp($cmd, "properties") == 0) && ($_GET["up"] || $_GET["down"])) {
706  $this->questionsObject();
707  return;
708  }
709  $cmd .= "Object";
710  $ret =&$this->$cmd();
711  break;
712  default:
713  // elba hack for storing question id for inserting new question after
714  if ($_REQUEST['prev_qid']) {
715  global $___prev_question_id;
716  $___prev_question_id = $_REQUEST['prev_qid'];
717  $this->ctrl->setParameterByClass('ilassquestionpagegui', 'prev_qid', $_REQUEST['prev_qid']);
718  $this->ctrl->setParameterByClass($_GET['sel_question_types'] . 'gui', 'prev_qid', $_REQUEST['prev_qid']);
719  }
720  $this->create_question_mode = true;
721  $this->prepareOutput();
722 
723  $this->ctrl->setReturn($this, "questions");
724  require_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
725  $q_gui =&assQuestionGUI::_getQuestionGUI($_GET['sel_question_types'], $this->fetchAuthoringQuestionIdParameter());
726  $q_gui->setEditContext(assQuestionGUI::EDIT_CONTEXT_AUTHORING);
727  $q_gui->object->setObjId($this->object->getId());
728  if (!$_GET['sel_question_types']) {
729  $qType = assQuestion::getQuestionTypeFromDb($_GET['q_id']);
730  } else {
731  $qType = $_GET['sel_question_types'];
732  }
733  $this->ctrl->setParameterByClass($qType . "GUI", 'prev_qid', $_REQUEST['prev_qid']);
734  $this->ctrl->setParameterByClass($qType . "GUI", 'test_ref_id', $_REQUEST['ref_id']);
735  $this->ctrl->setParameterByClass($qType . "GUI", 'q_id', $_REQUEST['q_id']);
736  if ($_REQUEST['test_express_mode']) {
737  $this->ctrl->setParameterByClass($qType . "GUI", 'test_express_mode', 1);
738  }
739 
740  #global $___test_express_mode;
741  #$___test_express_mode = true;
742  if (!$q_gui->isSaveCommand()) {
743  $_GET['calling_test'] = $this->object->getRefId();
744  }
745 
746  $q_gui->setQuestionTabs();
747  #unset($___test_express_mode);
748  $ret =&$this->ctrl->forwardCommand($q_gui);
749  break;
750  }
751  if (!in_array(strtolower($_GET["baseClass"]), array('iladministrationgui', 'ilrepositorygui')) &&
752  $this->getCreationMode() != true) {
753  $this->tpl->show();
754  }
755  }
756 
757  protected function trackTestObjectReadEvent()
758  {
759  /* @var ILIAS\DI\Container $DIC */ global $DIC;
760 
761  require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
762 
764  $this->object->getType(),
765  $this->object->getRefId(),
766  $this->object->getId(),
767  $DIC->user()->getId()
768  );
769  }
770 
775  protected function exportObject()
776  {
777  global $DIC; /* @var ILIAS\DI\Container $DIC */
778  $DIC->ctrl()->redirectByClass('ilTestExportGUI');
779  }
780 
785  {
786  $qid = $_REQUEST['q_id'];
787 
788  if (!$qid || $qid == 'Array') {
789  $questions = $this->object->getQuestionTitlesAndIndexes();
790  if (!is_array($questions)) {
791  $questions = array();
792  }
793 
794  $keys = array_keys($questions);
795  $qid = $keys[0];
796 
797  $_REQUEST['q_id'] = $qid;
798  $_GET['q_id'] = $qid;
799  $_POST['q_id'] = $qid;
800  }
801 
802  if ($this->object->checkQuestionParent($qid)) {
803  return $qid;
804  }
805 
806  throw new ilTestException('question id does not relate to parent object!');
807  }
808 
809  private function questionsTabGatewayObject()
810  {
811  switch ($this->object->getQuestionSetType()) {
813  $this->ctrl->redirectByClass('ilTestExpressPageObjectGUI', 'showPage');
814 
815  // no break
817  $this->ctrl->redirectByClass('ilTestRandomQuestionSetConfigGUI');
818 
819  // no break
821  $this->ctrl->redirectByClass('ilObjTestDynamicQuestionSetConfigGUI');
822  }
823  }
824 
825  private function userResultsGatewayObject()
826  {
827  $this->ctrl->setCmdClass('ilTestEvaluationGUI');
828  $this->ctrl->setCmd('outUserResultsOverview');
829  $this->tabs_gui->clearTargets();
830 
831  $this->forwardToEvaluationGUI();
832  }
833 
834  private function forwardToEvaluationGUI()
835  {
836  $this->prepareOutput();
837  $this->addHeaderAction();
838 
839  require_once 'Modules/Test/classes/class.ilTestEvaluationGUI.php';
840  $gui = new ilTestEvaluationGUI($this->object);
841  $gui->setObjectiveOrientedContainer($this->getObjectiveOrientedContainer());
842 
843  $this->ctrl->forwardCommand($gui);
844  }
845 
847  {
848  $this->prepareOutput();
849  $this->addHeaderAction();
850 
851  require_once 'Modules/Test/classes/class.ilTestEvalObjectiveOrientedGUI.php';
852  $gui = new ilTestEvalObjectiveOrientedGUI($this->object);
853  $gui->setObjectiveOrientedContainer($this->getObjectiveOrientedContainer());
854 
855  $this->ctrl->forwardCommand($gui);
856  }
857 
866  public function createUserResults($show_pass_details, $show_answers, $show_reached_points, $show_user_results)
867  {
868  global $ilTabs, $ilDB;
869 
870  // prepare generation before contents are processed (needed for mathjax)
871  if ($this->isPdfDeliveryRequest()) {
872  require_once 'Services/PDFGeneration/classes/class.ilPDFGeneration.php';
874  }
875 
876  $ilTabs->setBackTarget(
877  $this->lng->txt('back'),
878  $this->ctrl->getLinkTarget($this, 'participants')
879  );
880 
881  if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
882  require_once 'Services/Link/classes/class.ilLink.php';
883  $courseLink = ilLink::_getLink($this->getObjectiveOrientedContainer()->getRefId());
884  $ilTabs->setBack2Target($this->lng->txt('back_to_objective_container'), $courseLink);
885  }
886 
887  $template = new ilTemplate("tpl.il_as_tst_participants_result_output.html", true, true, "Modules/Test");
888 
889  require_once 'Modules/Test/classes/toolbars/class.ilTestResultsToolbarGUI.php';
890  $toolbar = new ilTestResultsToolbarGUI($this->ctrl, $this->tpl, $this->lng);
891 
892  $this->ctrl->setParameter($this, 'pdf', '1');
893  $toolbar->setPdfExportLinkTarget($this->ctrl->getLinkTarget($this, $this->ctrl->getCmd()));
894  $this->ctrl->setParameter($this, 'pdf', '');
895 
896  if ($show_answers) {
897  if (isset($_GET['show_best_solutions'])) {
898  $_SESSION['tst_results_show_best_solutions'] = true;
899  } elseif (isset($_GET['hide_best_solutions'])) {
900  $_SESSION['tst_results_show_best_solutions'] = false;
901  } elseif (!isset($_SESSION['tst_results_show_best_solutions'])) {
902  $_SESSION['tst_results_show_best_solutions'] = false;
903  }
904 
905  if ($_SESSION['tst_results_show_best_solutions']) {
906  $this->ctrl->setParameter($this, 'hide_best_solutions', '1');
907  $toolbar->setHideBestSolutionsLinkTarget($this->ctrl->getLinkTarget($this, $this->ctrl->getCmd()));
908  $this->ctrl->setParameter($this, 'hide_best_solutions', '');
909  } else {
910  $this->ctrl->setParameter($this, 'show_best_solutions', '1');
911  $toolbar->setShowBestSolutionsLinkTarget($this->ctrl->getLinkTarget($this, $this->ctrl->getCmd()));
912  $this->ctrl->setParameterByClass('', 'show_best_solutions', '');
913  }
914  }
915 
916  require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
917  $participantData = new ilTestParticipantData($ilDB, $this->lng);
918  if ($this->object->getFixedParticipants()) {
919  $participantData->setUserIds($show_user_results);
920  } else {
921  $participantData->setActiveIds($show_user_results);
922  }
923  $participantData->load($this->object->getTestId());
924  $toolbar->setParticipantSelectorOptions($participantData->getOptionArray($show_user_results));
925 
926  $toolbar->build();
927  $template->setVariable('RESULTS_TOOLBAR', $this->ctrl->getHTML($toolbar));
928 
929  include_once "./Modules/Test/classes/class.ilTestServiceGUI.php";
930  $serviceGUI = new ilTestServiceGUI($this->object);
931  $serviceGUI->setObjectiveOrientedContainer($this->getObjectiveOrientedContainer());
932  $serviceGUI->setParticipantData($participantData);
933 
934  $count = 0;
935  foreach ($show_user_results as $key => $active_id) {
936  $count++;
937  $results = "";
938  if ($this->object->getFixedParticipants()) {
939  $active_id = $this->object->getActiveIdOfUser($active_id);
940  }
941  if ($active_id > 0) {
942  $results = $serviceGUI->getResultsOfUserOutput(
943  $this->testSessionFactory->getSession($active_id),
944  $active_id,
945  $this->object->_getResultPass($active_id),
946  $this,
947  $show_pass_details,
948  $show_answers,
949  false,
950  $show_reached_points
951  );
952  }
953  if ($count < count($show_user_results)) {
954  $template->touchBlock("break");
955  }
956  $template->setCurrentBlock("user_result");
957  $template->setVariable("USER_RESULT", $results);
958  $template->parseCurrentBlock();
959  }
960 
961  if ($this->isPdfDeliveryRequest()) {
962  require_once 'Modules/Test/classes/class.ilTestPDFGenerator.php';
963 
965  $template->get(),
967  $this->object->getTitle(),
969  );
970  } else {
971  return $template;
972  }
973  }
974 
976  {
977  require_once 'Modules/Test/classes/class.ilObjTestSettingsGeneralGUI.php';
978  $this->ctrl->redirectByClass('ilObjTestSettingsGeneralGUI', ilObjTestSettingsGeneralGUI::CMD_SHOW_FORM);
979  }
980 
989  private function prepareSubGuiOutput()
990  {
991  global $ilUser;
992 
993  $this->tpl->getStandardTemplate();
994 
995  // set locator
996  $this->setLocator();
997 
998  // catch feedback message
1000 
1001  // set title and description and title icon
1002  $this->setTitleAndDescription();
1003 
1004  // BEGIN WebDAV: Display Mount Webfolder icon.
1005  if ($ilUser->getId() != ANONYMOUS_USER_ID) {
1006  require_once('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
1008  $this->showMountWebfolderIcon();
1009  }
1010  }
1011  // END WebDAV: Display Mount Webfolder icon.
1012  }
1013 
1014  public function runObject()
1015  {
1016  $this->ctrl->redirect($this, "infoScreen");
1017  }
1018 
1019  public function outEvaluationObject()
1020  {
1021  $this->ctrl->redirectByClass("iltestevaluationgui", "outEvaluation");
1022  }
1023 
1027  protected function importFileObject($parent_id = null, $a_catch_errors = true)
1028  {
1029  $form = $this->initImportForm($_REQUEST["new_type"]);
1030  if ($form->checkInput()) {
1031  $this->ctrl->setParameter($this, "new_type", $this->type);
1032  $this->uploadTstObject();
1033  }
1034 
1035  // display form to correct errors
1036  $form->setValuesByPost();
1037  $this->tpl->setContent($form->getHTML());
1038  }
1039 
1040  public function addDidacticTemplateOptions(array &$a_options)
1041  {
1042  include_once("./Modules/Test/classes/class.ilObjTest.php");
1043  $tst = new ilObjTest();
1044  $defaults = $tst->getAvailableDefaults();
1045  if (count($defaults)) {
1046  foreach ($defaults as $row) {
1047  $a_options["tstdef_" . $row["test_defaults_id"]] = array($row["name"],
1048  $this->lng->txt("tst_default_settings"));
1049  }
1050  }
1051 
1052  // using template?
1053  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
1054  $templates = ilSettingsTemplate::getAllSettingsTemplates("tst");
1055  if ($templates) {
1056  foreach ($templates as $item) {
1057  $a_options["tsttpl_" . $item["id"]] = array($item["title"],
1058  nl2br(trim($item["description"])));
1059  }
1060  }
1061  }
1062 
1067  public function afterSave(ilObject $a_new_object)
1068  {
1069  $tstdef = $this->getDidacticTemplateVar("tstdef");
1070  if ($tstdef) {
1071  $testDefaultsId = $tstdef;
1072  $testDefaults = ilObjTest::_getTestDefaults($testDefaultsId);
1073  $a_new_object->applyDefaults($testDefaults);
1074  }
1075 
1076  $template_id = $this->getDidacticTemplateVar("tsttpl");
1077  if ($template_id) {
1078  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
1080 
1081  $template_settings = $template->getSettings();
1082  if ($template_settings) {
1083  $this->applyTemplate($template_settings, $a_new_object);
1084  }
1085 
1086  $a_new_object->setTemplate($template_id);
1087  }
1088 
1089  $a_new_object->saveToDb();
1090 
1091  // always send a message
1092  ilUtil::sendSuccess($this->lng->txt("object_added"), true);
1093  $this->ctrl->setParameter($this, 'ref_id', $a_new_object->getRefId());
1094  $this->ctrl->redirectByClass('ilObjTestSettingsGeneralGUI');
1095  }
1096 
1097  public function backToRepositoryObject()
1098  {
1099  include_once "./Services/Utilities/classes/class.ilUtil.php";
1100  $path = $this->tree->getPathFull($this->object->getRefID());
1101  ilUtil::redirect($this->getReturnLocation("cancel", "./ilias.php?baseClass=ilRepositoryGUI&cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
1102  }
1103 
1107  public function uploadTstObject()
1108  {
1109  if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK) {
1110  ilUtil::sendFailure($this->lng->txt("error_upload"));
1111  $this->createObject();
1112  return;
1113  }
1114  include_once("./Modules/Test/classes/class.ilObjTest.php");
1115  // create import directory
1116  $basedir = ilObjTest::_createImportDirectory();
1117 
1118  // copy uploaded file to import directory
1119  $file = pathinfo($_FILES["xmldoc"]["name"]);
1120  $full_path = $basedir . "/" . $_FILES["xmldoc"]["name"];
1121  ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path);
1122 
1123  // unzip file
1124  ilUtil::unzip($full_path);
1125 
1126  // determine filenames of xml files
1127  $subdir = basename($file["basename"], "." . $file["extension"]);
1129  $xml_file = ilObjTest::_getImportDirectory() . '/' . $subdir . '/' . $subdir . ".xml";
1130  $qti_file = ilObjTest::_getImportDirectory() . '/' . $subdir . '/' . preg_replace("/test|tst/", "qti", $subdir) . ".xml";
1131  $results_file = ilObjTest::_getImportDirectory() . '/' . $subdir . '/' . preg_replace("/test|tst/", "results", $subdir) . ".xml";
1132 
1133  if (!is_file($qti_file)) {
1134  ilUtil::delDir($basedir);
1135  ilUtil::sendFailure($this->lng->txt("tst_import_non_ilias_zip"));
1136  $this->createObject();
1137  return;
1138  }
1139 
1140  // start verification of QTI files
1141  include_once "./Services/QTI/classes/class.ilQTIParser.php";
1142  $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, "");
1143  $result = $qtiParser->startParsing();
1144  $founditems =&$qtiParser->getFoundItems();
1145 
1146  $complete = 0;
1147  $incomplete = 0;
1148  foreach ($founditems as $item) {
1149  if (strlen($item["type"])) {
1150  $complete++;
1151  } else {
1152  $incomplete++;
1153  }
1154  }
1155 
1156  if (count($founditems) && $complete == 0) {
1157  // delete import directory
1158  ilUtil::delDir($basedir);
1159 
1160  ilUtil::sendInfo($this->lng->txt("qpl_import_non_ilias_files"));
1161  $this->createObject();
1162  return;
1163  }
1164 
1165  $_SESSION["tst_import_results_file"] = $results_file;
1166  $_SESSION["tst_import_xml_file"] = $xml_file;
1167  $_SESSION["tst_import_qti_file"] = $qti_file;
1168  $_SESSION["tst_import_subdir"] = $subdir;
1169 
1170  if ($qtiParser->getQuestionSetType() != ilObjTest::QUESTION_SET_TYPE_FIXED) {
1171  $this->importVerifiedFileObject();
1172  return;
1173  }
1174 
1175  // display of found questions
1176  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.tst_import_verification.html", "Modules/Test");
1177  $row_class = array("tblrow1", "tblrow2");
1178  $counter = 0;
1179  foreach ($founditems as $item) {
1180  $this->tpl->setCurrentBlock("verification_row");
1181  $this->tpl->setVariable("ROW_CLASS", $row_class[$counter++ % 2]);
1182  $this->tpl->setVariable("QUESTION_TITLE", $item["title"]);
1183  $this->tpl->setVariable("QUESTION_IDENT", $item["ident"]);
1184  include_once "./Services/QTI/classes/class.ilQTIItem.php";
1185  switch ($item["type"]) {
1187  case QT_MULTIPLE_CHOICE_MR:
1188  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assMultipleChoice"));
1189  break;
1191  case QT_MULTIPLE_CHOICE_SR:
1192  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assSingleChoice"));
1193  break;
1195  case QT_KPRIM_CHOICE:
1196  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assKprimChoice"));
1197  break;
1199  case QT_LONG_MENU:
1200  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assLongMenu"));
1201  break;
1203  case QT_NUMERIC:
1204  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assNumeric"));
1205  break;
1207  case QT_FORMULA:
1208  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assFormulaQuestion"));
1209  break;
1211  case QT_TEXTSUBSET:
1212  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextSubset"));
1213  break;
1214  case CLOZE_TEST_IDENTIFIER:
1215  case QT_CLOZE:
1216  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assClozeTest"));
1217  break;
1218  case ERROR_TEXT_IDENTIFIER:
1219  case QT_ERRORTEXT:
1220  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assErrorText"));
1221  break;
1223  case QT_IMAGEMAP:
1224  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assImagemapQuestion"));
1225  break;
1227  case QT_JAVAAPPLET:
1228  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assJavaApplet"));
1229  break;
1231  case QT_FLASHAPPLET:
1232  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assFlashApplet"));
1233  break;
1235  case QT_MATCHING:
1236  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assMatchingQuestion"));
1237  break;
1239  case QT_ORDERING:
1240  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assOrderingQuestion"));
1241  break;
1244  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assOrderingHorizontal"));
1245  break;
1247  case QT_TEXT:
1248  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextQuestion"));
1249  break;
1251  case QT_FILEUPLOAD:
1252  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assFileUpload"));
1253  break;
1254  }
1255  $this->tpl->parseCurrentBlock();
1256  }
1257 
1258  // on import creation screen the pool was chosen (-1 for no pool)
1259  // BUT when no pool is available the input on creation screen is missing, so the field value -1 for no pool is not submitted.
1260  $QplOrTstID = isset($_POST["qpl"]) && (int) $_POST["qpl"] != 0 ? $_POST["qpl"] : -1;
1261 
1262  $this->tpl->setCurrentBlock("adm_content");
1263  $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt("question_type"));
1264  $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("question_title"));
1265  $this->tpl->setVariable("FOUND_QUESTIONS_INTRODUCTION", $this->lng->txt("tst_import_verify_found_questions"));
1266  $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_tst"));
1267  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1268  $this->tpl->setVariable("ARROW", ilUtil::getImagePath("arrow_downright.svg"));
1269  $this->tpl->setVariable("QUESTIONPOOL_ID", $QplOrTstID);
1270  $this->tpl->setVariable("VALUE_IMPORT", $this->lng->txt("import"));
1271  $this->tpl->setVariable("VALUE_CANCEL", $this->lng->txt("cancel"));
1272  $this->tpl->parseCurrentBlock();
1273  }
1274 
1278  public function importVerifiedFileObject()
1279  {
1280  include_once "./Modules/Test/classes/class.ilObjTest.php";
1281  // create new questionpool object
1282  $newObj = new ilObjTest(0, true);
1283  // set type of questionpool object
1284  $newObj->setType($_GET["new_type"]);
1285  // set title of questionpool object to "dummy"
1286  $newObj->setTitle("dummy");
1287  // set description of questionpool object
1288  $newObj->setDescription("test import");
1289  // create the questionpool class in the ILIAS database (object_data table)
1290  $newObj->create(true);
1291  // create a reference for the questionpool object in the ILIAS database (object_reference table)
1292  $newObj->createReference();
1293  // put the questionpool object in the administration tree
1294  $newObj->putInTree($_GET["ref_id"]);
1295  // get default permissions and set the permissions for the questionpool object
1296  $newObj->setPermissions($_GET["ref_id"]);
1297  // empty mark schema
1298  $newObj->mark_schema->flush();
1299 
1300  // start parsing of QTI files
1301  include_once "./Services/QTI/classes/class.ilQTIParser.php";
1302 
1303  // Handle selection of "no questionpool" as qpl_id = -1 -> use test object id instead.
1304  // possible hint: chek if empty strings in $_POST["qpl_id"] relates to a bug or not
1305  if (!isset($_POST["qpl"]) || "-1" === (string) $_POST["qpl"]) {
1306  $questionParentObjId = $newObj->getId();
1307  } else {
1308  $questionParentObjId = $_POST["qpl"];
1309  }
1310 
1311  if (is_file($_SESSION["tst_import_dir"] . '/' . $_SESSION["tst_import_subdir"] . "/manifest.xml")) {
1312  $newObj->saveToDb();
1313 
1314  $_SESSION['tst_import_idents'] = $_POST['ident'];
1315  $_SESSION['tst_import_qst_parent'] = $questionParentObjId;
1316 
1317  $fileName = $_SESSION['tst_import_subdir'] . '.zip';
1318  $fullPath = $_SESSION['tst_import_dir'] . '/' . $fileName;
1319 
1320  include_once("./Services/Export/classes/class.ilImport.php");
1321  $imp = new ilImport((int) $_GET["ref_id"]);
1322  $map = $imp->getMapping();
1323  $map->addMapping('Modules/Test', 'tst', 'new_id', $newObj->getId());
1324  $imp->importObject($newObj, $fullPath, $fileName, 'tst', 'Modules/Test', true);
1325  } else {
1326  $qtiParser = new ilQTIParser($_SESSION["tst_import_qti_file"], IL_MO_PARSE_QTI, $questionParentObjId, $_POST["ident"]);
1327  if (!isset($_POST["ident"]) || !is_array($_POST["ident"]) || !count($_POST["ident"])) {
1328  $qtiParser->setIgnoreItemsEnabled(true);
1329  }
1330  $qtiParser->setTestObject($newObj);
1331  $result = $qtiParser->startParsing();
1332  $newObj->saveToDb();
1333 
1334  // import page data
1335  include_once("./Modules/LearningModule/classes/class.ilContObjParser.php");
1336  $contParser = new ilContObjParser($newObj, $_SESSION["tst_import_xml_file"], $_SESSION["tst_import_subdir"]);
1337  $contParser->setQuestionMapping($qtiParser->getImportMapping());
1338  $contParser->startParsing();
1339 
1340  if (isset($_POST["ident"]) && is_array($_POST["ident"]) && count($_POST["ident"]) == $qtiParser->getNumImportedItems()) {
1341  // import test results
1342  if (@file_exists($_SESSION["tst_import_results_file"])) {
1343  include_once("./Modules/Test/classes/class.ilTestResultsImportParser.php");
1344  $results = new ilTestResultsImportParser($_SESSION["tst_import_results_file"], $newObj);
1345  $results->setQuestionIdMapping($qtiParser->getQuestionIdMapping());
1346  $results->startParsing();
1347  }
1348  }
1349  $newObj->update();
1350  }
1351 
1352 
1353  // delete import directory
1355 
1356  ilUtil::sendSuccess($this->lng->txt("object_imported"), true);
1357  ilUtil::redirect("ilias.php?ref_id=" . $newObj->getRefId() . "&baseClass=ilObjTestGUI");
1358  }
1359 
1366  public function uploadObject($redirect = true)
1367  {
1368  $this->uploadTstObject();
1369  }
1370 
1374  public function downloadFileObject()
1375  {
1376  $file = explode("_", $_GET["file_id"]);
1377  include_once("./Modules/File/classes/class.ilObjFile.php");
1378  $fileObj = new ilObjFile($file[count($file) - 1], false);
1379  $fileObj->sendFile();
1380  exit;
1381  }
1382 
1386  public function fullscreenObject()
1387  {
1388  include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php");
1389  $page_gui = new ilAssQuestionPageGUI($_GET["pg_id"]);
1390  $page_gui->showMediaFullscreen();
1391  }
1392 
1396  public function download_paragraphObject()
1397  {
1398  include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php");
1399  $pg_obj = new ilAssQuestionPage($_GET["pg_id"]);
1400  $pg_obj->send_paragraph($_GET["par_id"], $_GET["downloadtitle"]);
1401  exit;
1402  }
1403 
1411  public function filterObject()
1412  {
1413  $this->questionBrowser();
1414  }
1415 
1423  public function resetFilterObject()
1424  {
1425  $this->questionBrowser();
1426  }
1427 
1435  public function backObject()
1436  {
1437  $this->ctrl->redirect($this, "questions");
1438  }
1439 
1448  public function createQuestionPool($name = "dummy", $description = "")
1449  {
1450  global $tree;
1451  $parent_ref = $tree->getParentId($this->object->getRefId());
1452  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
1453  $qpl = new ilObjQuestionPool();
1454  $qpl->setType("qpl");
1455  $qpl->setTitle($name);
1456  $qpl->setDescription($description);
1457  $qpl->create();
1458  $qpl->createReference();
1459  $qpl->putInTree($parent_ref);
1460  $qpl->setPermissions($parent_ref);
1461  $qpl->setOnline(1); // must be online to be available
1462  $qpl->saveToDb();
1463  return $qpl->getRefId();
1464  }
1465 
1469  public function randomselectObject()
1470  {
1471  global $ilUser;
1472  $this->getQuestionsSubTabs();
1473  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_random_select.html", "Modules/Test");
1474  $questionpools =&$this->object->getAvailableQuestionpools(false, false, false, true);
1475  $this->tpl->setCurrentBlock("option");
1476  $this->tpl->setVariable("VALUE_OPTION", "0");
1477  $this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("all_available_question_pools"));
1478  $this->tpl->parseCurrentBlock();
1479  foreach ($questionpools as $key => $value) {
1480  $this->tpl->setCurrentBlock("option");
1481  $this->tpl->setVariable("VALUE_OPTION", $key);
1482  $this->tpl->setVariable("TEXT_OPTION", $value["title"]);
1483  $this->tpl->parseCurrentBlock();
1484  }
1485  $this->tpl->setCurrentBlock("hidden");
1486  $this->tpl->setVariable("HIDDEN_NAME", "sel_question_types");
1487  $this->tpl->setVariable("HIDDEN_VALUE", $_POST["sel_question_types"]);
1488  $this->tpl->parseCurrentBlock();
1489  $this->tpl->setCurrentBlock("adm_content");
1490  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
1491  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_random_select_questionpool"));
1492  $this->tpl->setVariable("TXT_NR_OF_QUESTIONS", $this->lng->txt("tst_random_nr_of_questions"));
1493  $this->tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit"));
1494  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
1495  $this->tpl->parseCurrentBlock();
1496  }
1497 
1505  public function cancelRandomSelectObject()
1506  {
1507  $this->ctrl->redirect($this, "questions");
1508  }
1509 
1518  {
1519  $this->getQuestionsSubTabs();
1520  $question_array = $this->object->randomSelectQuestions($_POST["nr_of_questions"], $_POST["sel_qpl"]);
1521  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_random_question_offer.html", "Modules/Test");
1522  $color_class = array("tblrow1", "tblrow2");
1523  $counter = 0;
1524  $questionpools =&$this->object->getAvailableQuestionpools(true);
1525  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
1526  foreach ($question_array as $question_id) {
1527  $dataset = $this->object->getQuestionDataset($question_id);
1528  $this->tpl->setCurrentBlock("QTab");
1529  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
1530  $this->tpl->setVariable("QUESTION_TITLE", $dataset->title);
1531  $this->tpl->setVariable("QUESTION_COMMENT", $dataset->description);
1532  $this->tpl->setVariable("QUESTION_TYPE", assQuestion::_getQuestionTypeName($dataset->type_tag));
1533  $this->tpl->setVariable("QUESTION_AUTHOR", $dataset->author);
1534  $this->tpl->setVariable("QUESTION_POOL", $questionpools[$dataset->obj_fi]["title"]);
1535  $this->tpl->parseCurrentBlock();
1536  $counter++;
1537  }
1538  if (count($question_array) == 0) {
1539  $this->tpl->setCurrentBlock("Emptytable");
1540  $this->tpl->setVariable("TEXT_NO_QUESTIONS_AVAILABLE", $this->lng->txt("no_questions_available"));
1541  $this->tpl->parseCurrentBlock();
1542  } else {
1543  $this->tpl->setCurrentBlock("Selectionbuttons");
1544  $this->tpl->setVariable("BTN_YES", $this->lng->txt("random_accept_sample"));
1545  $this->tpl->setVariable("BTN_NO", $this->lng->txt("random_another_sample"));
1546  $this->tpl->parseCurrentBlock();
1547  }
1548  $chosen_questions = join($question_array, ",");
1549  $this->tpl->setCurrentBlock("adm_content");
1550  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
1551  $this->tpl->setVariable("QUESTION_TITLE", $this->lng->txt("tst_question_title"));
1552  $this->tpl->setVariable("QUESTION_COMMENT", $this->lng->txt("description"));
1553  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("tst_question_type"));
1554  $this->tpl->setVariable("QUESTION_AUTHOR", $this->lng->txt("author"));
1555  $this->tpl->setVariable("QUESTION_POOL", $this->lng->txt("qpl"));
1556  $this->tpl->setVariable("VALUE_CHOSEN_QUESTIONS", $chosen_questions);
1557  $this->tpl->setVariable("VALUE_QUESTIONPOOL_SELECTION", $_POST["sel_qpl"]);
1558  $this->tpl->setVariable("VALUE_NR_OF_QUESTIONS", $_POST["nr_of_questions"]);
1559  $this->tpl->setVariable("TEXT_QUESTION_OFFER", $this->lng->txt("tst_question_offer"));
1560  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
1561  $this->tpl->parseCurrentBlock();
1562  }
1563 
1572  {
1573  $selected_array = explode(",", $_POST["chosen_questions"]);
1574  if (!count($selected_array)) {
1575  ilUtil::sendInfo($this->lng->txt("tst_insert_missing_question"));
1576  } else {
1577  $total = $this->object->evalTotalPersons();
1578  if ($total) {
1579  // the test was executed previously
1580  ilUtil::sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total));
1581  } else {
1582  ilUtil::sendInfo($this->lng->txt("tst_insert_questions"));
1583  }
1584  foreach ($selected_array as $key => $value) {
1585  $this->object->insertQuestion($this->testQuestionSetConfigFactory->getQuestionSetConfig(), $value);
1586  }
1587  $this->object->saveCompleteStatus($this->testQuestionSetConfigFactory->getQuestionSetConfig());
1588  ilUtil::sendSuccess($this->lng->txt("tst_questions_inserted"), true);
1589  $this->ctrl->redirect($this, "questions");
1590  return;
1591  }
1592  }
1593 
1594  public function browseForQuestionsObject()
1595  {
1596  $this->questionBrowser();
1597  }
1598 
1607  {
1608  $qpl_ref_id = $_REQUEST["sel_qpl"];
1609 
1610  $qpl_mode = $_REQUEST['usage'];
1611 
1612  if (isset($_REQUEST['qtype'])) {
1613  include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
1614  $sel_question_types = ilObjQuestionPool::getQuestionTypeByTypeId($_REQUEST["qtype"]);
1615  } elseif (isset($_REQUEST['sel_question_types'])) {
1616  $sel_question_types = $_REQUEST["sel_question_types"];
1617  }
1618 
1619  if (!$qpl_mode || ($qpl_mode == 2 && strcmp($_REQUEST["txt_qpl"], "") == 0) || ($qpl_mode == 3 && strcmp($qpl_ref_id, "") == 0)) {
1620  //if ((strcmp($_REQUEST["txt_qpl"], "") == 0) && (strcmp($qpl_ref_id, "") == 0))
1621  // Mantis #14890
1622  $_REQUEST['sel_question_types'] = $sel_question_types;
1623  ilUtil::sendInfo($this->lng->txt("questionpool_not_entered"));
1624  $this->createQuestionObject();
1625  return;
1626  } else {
1627  $_SESSION["test_id"] = $this->object->getRefId();
1628  if ($qpl_mode == 2 && strcmp($_REQUEST["txt_qpl"], "") != 0) {
1629  // create a new question pool and return the reference id
1630  $qpl_ref_id = $this->createQuestionPool($_REQUEST["txt_qpl"]);
1631  } elseif ($qpl_mode == 1) {
1632  $qpl_ref_id = $_GET["ref_id"];
1633  }
1634 
1635  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPoolGUI.php";
1636  $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;
1637 
1638  if (isset($_REQUEST['prev_qid'])) {
1639  $baselink .= '&prev_qid=' . $_REQUEST['prev_qid'];
1640  } elseif (isset($_REQUEST['position'])) {
1641  $baselink .= '&prev_qid=' . $_REQUEST['position'];
1642  }
1643 
1644  if ($_REQUEST['test_express_mode']) {
1645  $baselink .= '&test_express_mode=1';
1646  }
1647 
1648  if (isset($_REQUEST['add_quest_cont_edit_mode'])) {
1650  $baselink,
1651  "add_quest_cont_edit_mode={$_REQUEST['add_quest_cont_edit_mode']}",
1652  false
1653  );
1654  }
1655 
1656  #var_dump($_REQUEST['prev_qid']);
1657  ilUtil::redirect($baselink);
1658 
1659  exit();
1660  }
1661  }
1662 
1670  public function cancelCreateQuestionObject()
1671  {
1672  $this->ctrl->redirect($this, "questions");
1673  }
1674 
1682  public function createQuestionObject()
1683  {
1684  global $ilUser;
1685  $this->getQuestionsSubTabs();
1686  //$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_qpl_select.html", "Modules/Test");
1687  $questionpools =&$this->object->getAvailableQuestionpools(false, false, false, true, false, "write");
1688 
1689  if ($this->object->getPoolUsage()) {
1690  global $lng, $ilCtrl, $tpl;
1691 
1692  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
1693 
1694  $form = new ilPropertyFormGUI();
1695  $form->setFormAction($ilCtrl->getFormAction($this, "executeCreateQuestion"));
1696  $form->setTitle($lng->txt("ass_create_question"));
1697  include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
1698 
1699 
1700  $hidden = new ilHiddenInputGUI('sel_question_types');
1701  $hidden->setValue($_REQUEST["sel_question_types"]);
1702  $form->addItem($hidden);
1703 
1704  // content editing mode
1706  $ri = new ilRadioGroupInputGUI($lng->txt("tst_add_quest_cont_edit_mode"), "add_quest_cont_edit_mode");
1707 
1708  $ri->addOption(new ilRadioOption(
1709  $lng->txt('tst_add_quest_cont_edit_mode_default'),
1711  ));
1712 
1713  $ri->addOption(new ilRadioOption(
1714  $lng->txt('tst_add_quest_cont_edit_mode_page_object'),
1716  ));
1717 
1719 
1720  $form->addItem($ri, true);
1721  } else {
1722  $hi = new ilHiddenInputGUI("question_content_editing_type");
1724  $form->addItem($hi, true);
1725  }
1726 
1727  // use pool
1728  $usage = new ilRadioGroupInputGUI($this->lng->txt("assessment_pool_selection"), "usage");
1729  $usage->setRequired(true);
1730  $no_pool = new ilRadioOption($this->lng->txt("assessment_no_pool"), 1);
1731  $usage->addOption($no_pool);
1732  $existing_pool = new ilRadioOption($this->lng->txt("assessment_existing_pool"), 3);
1733  $usage->addOption($existing_pool);
1734  $new_pool = new ilRadioOption($this->lng->txt("assessment_new_pool"), 2);
1735  $usage->addOption($new_pool);
1736  $form->addItem($usage);
1737 
1738  $usage->setValue(1);
1739 
1740  $questionpools = ilObjQuestionPool::_getAvailableQuestionpools(false, false, true, false, false, "write");
1741  $pools_data = array();
1742  foreach ($questionpools as $key => $p) {
1743  $pools_data[$key] = $p['title'];
1744  }
1745  $pools = new ilSelectInputGUI($this->lng->txt("select_questionpool"), "sel_qpl");
1746  $pools->setOptions($pools_data);
1747  $existing_pool->addSubItem($pools);
1748 
1749 
1750  $this->lng->loadLanguageModule('rbac');
1751  $name = new ilTextInputGUI($this->lng->txt("rbac_create_qpl"), "txt_qpl");
1752  $name->setSize(50);
1753  $name->setMaxLength(50);
1754  $new_pool->addSubItem($name);
1755 
1756  $form->addCommandButton("executeCreateQuestion", $lng->txt("submit"));
1757  $form->addCommandButton("cancelCreateQuestion", $lng->txt("cancel"));
1758 
1759  return $this->tpl->setVariable('ADM_CONTENT', $form->getHTML());
1760  } else {
1761  global $ilCtrl;
1762 
1763  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'sel_question_types', $_REQUEST["sel_question_types"]);
1764  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'add_quest_cont_edit_mode', $_REQUEST["add_quest_cont_edit_mode"]);
1765  $link = $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'handleToolbarCommand', '', false, false);
1766  ilUtil::redirect($link);
1767  }
1768  }
1769 
1774  {
1775  $removeQuestionIds = (array) $_POST["q_id"];
1776 
1777  $questions = $this->object->getQuestionTitlesAndIndexes();
1778 
1779  $this->object->removeQuestions($removeQuestionIds);
1780 
1781  $this->object->saveCompleteStatus($this->testQuestionSetConfigFactory->getQuestionSetConfig());
1782 
1783  ilUtil::sendSuccess($this->lng->txt("tst_questions_removed"));
1784 
1785  if ($_REQUEST['test_express_mode']) {
1786  $prev = null;
1787  $return_to = null;
1788  $deleted_tmp = $removeQuestionIds;
1789  $first = array_shift($deleted_tmp);
1790  foreach ((array) $questions as $key => $value) {
1791  if (!in_array($key, $removeQuestionIds)) {
1792  $prev = $key;
1793  if (!$first) {
1794  $return_to = $prev;
1795  break;
1796  } else {
1797  continue;
1798  }
1799  } elseif ($key == $first) {
1800  if ($prev) {
1801  $return_to = $prev;
1802  break;
1803  }
1804  $first = array_shift($deleted_tmp);
1805  }
1806  }
1807 
1808  if (
1809  count($questions) == count($removeQuestionIds) ||
1810  !$return_to
1811  ) {
1812  $this->ctrl->setParameter($this, 'q_id', '');
1813  $this->ctrl->redirect($this, 'showPage');
1814  }
1815 
1816  $this->ctrl->setParameter($this, 'q_id', $return_to);
1817  $this->ctrl->redirect($this, "showPage");
1818  } else {
1819  $this->ctrl->setParameter($this, 'q_id', '');
1820  $this->ctrl->redirect($this, 'questions');
1821  }
1822  }
1823 
1832  {
1833  if ($_REQUEST['test_express_mode']) {
1834  $this->ctrl->setParameter($this, 'q_id', $_REQUEST['q_id']);
1835  $this->ctrl->redirect($this, "showPage");
1836  } else {
1837  $this->ctrl->redirect($this, "questions");
1838  }
1839  }
1840 
1848  public function removeQuestionsForm($checked_questions)
1849  {
1850  $total = $this->object->evalTotalPersons();
1851  if ($total) {
1852  // the test was executed previously
1853  $question = sprintf($this->lng->txt("tst_remove_questions_and_results"), $total);
1854  } else {
1855  if (count($checked_questions) == 1) {
1856  $question = $this->lng->txt("tst_remove_question");
1857  } else {
1858  $question = $this->lng->txt("tst_remove_questions");
1859  }
1860  }
1861 
1862  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1863  $cgui = new ilConfirmationGUI();
1864  $cgui->setHeaderText($question);
1865 
1866  $this->ctrl->saveParameter($this, 'test_express_mode');
1867  $this->ctrl->saveParameter($this, 'q_id');
1868 
1869  $cgui->setFormAction($this->ctrl->getFormAction($this));
1870  $cgui->setCancel($this->lng->txt("cancel"), "cancelRemoveQuestions");
1871  $cgui->setConfirm($this->lng->txt("confirm"), "confirmRemoveQuestions");
1872 
1873  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
1874  $removablequestions =&$this->object->getTestQuestions();
1875  if (count($removablequestions)) {
1876  foreach ($removablequestions as $data) {
1877  if (in_array($data["question_id"], $checked_questions)) {
1878  $txt = $data["title"] . " (" . assQuestion::_getQuestionTypeName($data["type_tag"]) . ")";
1879  $txt .= ' [' . $this->lng->txt('question_id_short') . ': ' . $data['question_id'] . ']';
1880 
1881  if ($data["description"]) {
1882  $txt .= "<div class=\"small\">" . $data["description"] . "</div>";
1883  }
1884 
1885  $cgui->addItem("q_id[]", $data["question_id"], $txt);
1886  }
1887  }
1888  }
1889 
1890  $this->tpl->setContent($cgui->getHTML());
1891  }
1892 
1896  public function removeQuestionsObject()
1897  {
1898  $this->getQuestionsSubTabs();
1899  $checked_questions = $_REQUEST["q_id"];
1900 
1901  if (!is_array($checked_questions) && $checked_questions) {
1902  $checked_questions = array($checked_questions);
1903  }
1904 
1905  if (!is_array($checked_questions)) {
1906  $checked_questions = [];
1907  }
1908 
1909  if (count($checked_questions) > 0) {
1910  $this->removeQuestionsForm($checked_questions);
1911  } elseif (0 === count($checked_questions)) {
1912  ilUtil::sendFailure($this->lng->txt("tst_no_question_selected_for_removal"), true);
1913  $this->ctrl->redirect($this, "questions");
1914  }
1915  }
1916 
1920  public function moveQuestionsObject()
1921  {
1922  $selected_questions = null;
1923  $selected_questions = $_POST['q_id'];
1924  if (is_array($selected_questions)) {
1925  $_SESSION['tst_qst_move_' . $this->object->getTestId()] = $_POST['q_id'];
1926  ilUtil::sendSuccess($this->lng->txt("msg_selected_for_move"), true);
1927  } else {
1928  ilUtil::sendFailure($this->lng->txt('no_selection_for_move'), true);
1929  }
1930  $this->ctrl->redirect($this, 'questions');
1931  }
1932 
1937  {
1938  // get all questions to move
1939  $move_questions = $_SESSION['tst_qst_move_' . $this->object->getTestId()];
1940 
1941  if (!is_array($_POST['q_id']) || 0 === count($_POST['q_id'])) {
1942  ilUtil::sendFailure($this->lng->txt("no_target_selected_for_move"), true);
1943  $this->ctrl->redirect($this, 'questions');
1944  }
1945  if (count($_POST['q_id']) > 1) {
1946  ilUtil::sendFailure($this->lng->txt("too_many_targets_selected_for_move"), true);
1947  $this->ctrl->redirect($this, 'questions');
1948  }
1949  $insert_mode = 0;
1950  $this->object->moveQuestions($_SESSION['tst_qst_move_' . $this->object->getTestId()], $_POST['q_id'][0], $insert_mode);
1951  ilUtil::sendSuccess($this->lng->txt("msg_questions_moved"), true);
1952  unset($_SESSION['tst_qst_move_' . $this->object->getTestId()]);
1953  $this->ctrl->redirect($this, "questions");
1954  }
1955 
1959  public function insertQuestionsAfterObject()
1960  {
1961  // get all questions to move
1962  $move_questions = $_SESSION['tst_qst_move_' . $this->object->getTestId()];
1963  if (!is_array($_POST['q_id']) || 0 === count($_POST['q_id'])) {
1964  ilUtil::sendFailure($this->lng->txt("no_target_selected_for_move"), true);
1965  $this->ctrl->redirect($this, 'questions');
1966  }
1967  if (count($_POST['q_id']) > 1) {
1968  ilUtil::sendFailure($this->lng->txt("too_many_targets_selected_for_move"), true);
1969  $this->ctrl->redirect($this, 'questions');
1970  }
1971  $insert_mode = 1;
1972  $this->object->moveQuestions($_SESSION['tst_qst_move_' . $this->object->getTestId()], $_POST['q_id'][0], $insert_mode);
1973  ilUtil::sendSuccess($this->lng->txt("msg_questions_moved"), true);
1974  unset($_SESSION['tst_qst_move_' . $this->object->getTestId()]);
1975  $this->ctrl->redirect($this, "questions");
1976  }
1977 
1983  public function insertQuestionsObject()
1984  {
1985  $selected_array = (is_array($_POST['q_id'])) ? $_POST['q_id'] : array();
1986  if (!count($selected_array)) {
1987  ilUtil::sendInfo($this->lng->txt("tst_insert_missing_question"), true);
1988  $this->ctrl->redirect($this, "browseForQuestions");
1989  } else {
1990  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
1991  $manscoring = false;
1992  foreach ($selected_array as $key => $value) {
1993  $this->object->insertQuestion($this->testQuestionSetConfigFactory->getQuestionSetConfig(), $value);
1994  if (!$manscoring) {
1995  $manscoring = $manscoring | assQuestion::_needsManualScoring($value);
1996  }
1997  }
1998  $this->object->saveCompleteStatus($this->testQuestionSetConfigFactory->getQuestionSetConfig());
1999  if ($manscoring) {
2000  ilUtil::sendInfo($this->lng->txt("manscoring_hint"), true);
2001  } else {
2002  ilUtil::sendSuccess($this->lng->txt("tst_questions_inserted"), true);
2003  }
2004  $this->ctrl->redirect($this, "questions");
2005  return;
2006  }
2007  }
2008 
2009  public function addQuestionObject()
2010  {
2011  global $lng, $ilCtrl, $tpl;
2012  global $DIC; /* @var \ILIAS\DI\Container $DIC */
2013  $ilHelp = $DIC['ilHelp']; /* @var ilHelpGUI $ilHelp */
2014 
2015  $subScreenId = array('createQuestion');
2016 
2017  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
2018 
2019  $ilCtrl->setParameter($this, 'qtype', $_REQUEST['qtype']);
2020 
2021  $form = new ilPropertyFormGUI();
2022 
2023  $form->setFormAction($ilCtrl->getFormAction($this, "executeCreateQuestion"));
2024  $form->setTitle($lng->txt("ass_create_question"));
2025  include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
2026 
2027  $pool = new ilObjQuestionPool();
2028  $questionTypes = $pool->getQuestionTypes(false, true);
2029  $options = array();
2030 
2031  // question type
2032  foreach ($questionTypes as $label => $data) {
2033  $options[$data['question_type_id']] = $label;
2034  }
2035 
2036  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
2037  $si = new ilSelectInputGUI($lng->txt("question_type"), "qtype");
2038  $si->setOptions($options);
2039  $form->addItem($si, true);
2040 
2041  // position
2042  $questions = $this->object->getQuestionTitlesAndIndexes();
2043  if ($questions) {
2044  $si = new ilSelectInputGUI($lng->txt("position"), "position");
2045  $options = array('0' => $lng->txt('first'));
2046  foreach ($questions as $key => $title) {
2047  $options[$key] = $lng->txt('behind') . ' ' . $title . ' [' . $this->lng->txt('question_id_short') . ': ' . $key . ']';
2048  }
2049  $si->setOptions($options);
2050  $si->setValue($_REQUEST['q_id']);
2051  $form->addItem($si, true);
2052  }
2053 
2054  // content editing mode
2056  $subScreenId[] = 'editMode';
2057 
2058  $ri = new ilRadioGroupInputGUI($lng->txt("tst_add_quest_cont_edit_mode"), "add_quest_cont_edit_mode");
2059 
2060  $ri->addOption(new ilRadioOption(
2061  $lng->txt('tst_add_quest_cont_edit_mode_default'),
2063  ));
2064 
2065  $ri->addOption(new ilRadioOption(
2066  $lng->txt('tst_add_quest_cont_edit_mode_page_object'),
2068  ));
2069 
2071 
2072  $form->addItem($ri, true);
2073  } else {
2074  $hi = new ilHiddenInputGUI("question_content_editing_type");
2076  $form->addItem($hi, true);
2077  }
2078 
2079  if ($this->object->getPoolUsage()) {
2080  $subScreenId[] = 'poolSelect';
2081 
2082  // use pool
2083  $usage = new ilRadioGroupInputGUI($this->lng->txt("assessment_pool_selection"), "usage");
2084  $usage->setRequired(true);
2085  $no_pool = new ilRadioOption($this->lng->txt("assessment_no_pool"), 1);
2086  $usage->addOption($no_pool);
2087  $existing_pool = new ilRadioOption($this->lng->txt("assessment_existing_pool"), 3);
2088  $usage->addOption($existing_pool);
2089  $new_pool = new ilRadioOption($this->lng->txt("assessment_new_pool"), 2);
2090  $usage->addOption($new_pool);
2091  $form->addItem($usage);
2092 
2093  $usage->setValue(1);
2094 
2095  $questionpools = ilObjQuestionPool::_getAvailableQuestionpools(false, false, true, false, false, "write");
2096  $pools_data = array();
2097  foreach ($questionpools as $key => $p) {
2098  $pools_data[$key] = $p['title'];
2099  }
2100  $pools = new ilSelectInputGUI($this->lng->txt("select_questionpool"), "sel_qpl");
2101  $pools->setOptions($pools_data);
2102  $existing_pool->addSubItem($pools);
2103 
2104  $name = new ilTextInputGUI($this->lng->txt("name"), "txt_qpl");
2105  $name->setSize(50);
2106  $name->setMaxLength(50);
2107  $new_pool->addSubItem($name);
2108  }
2109 
2110  $form->addCommandButton("executeCreateQuestion", $lng->txt("create"));
2111  $form->addCommandButton("questions", $lng->txt("cancel"));
2112 
2113  $ilHelp->setScreenId('assQuestions');
2114  $ilHelp->setSubScreenId(implode('_', $subScreenId));
2115 
2116  return $tpl->setContent($form->getHTML());
2117  }
2118 
2119  public function questionsObject()
2120  {
2121  global $ilAccess, $ilTabs;
2122 
2123  $ilTabs->activateTab('assQuestions');
2124 
2125  // #12590
2126  $this->ctrl->setParameter($this, 'test_express_mode', '');
2127 
2128  if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
2129  // allow only write access
2130  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
2131  $this->ctrl->redirect($this, "infoScreen");
2132  }
2133 
2134  if ($_GET['browse']) {
2135  return $this->questionbrowser();
2136  }
2137 
2138  $this->getQuestionsSubTabs();
2139 
2140  // #11631, #12994
2141  $this->ctrl->setParameter($this, 'q_id', '');
2142 
2143  if ($_GET["eqid"] && $_GET["eqpl"]) {
2144  ilUtil::redirect("ilias.php?baseClass=ilObjQuestionPoolGUI&ref_id=" . $_GET["eqpl"] . "&cmd=editQuestionForTest&calling_test=" . $_GET["ref_id"] . "&q_id=" . $_GET["eqid"]);
2145  }
2146 
2147  if ($_GET["up"] > 0) {
2148  $this->object->questionMoveUp($_GET["up"]);
2149  }
2150  if ($_GET["down"] > 0) {
2151  $this->object->questionMoveDown($_GET["down"]);
2152  }
2153 
2154  if ($_GET["add"]) {
2155  $selected_array = array();
2156  array_push($selected_array, $_GET["add"]);
2157  $total = $this->object->evalTotalPersons();
2158  if ($total) {
2159  // the test was executed previously
2160  ilUtil::sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total));
2161  } else {
2162  ilUtil::sendInfo($this->lng->txt("tst_insert_questions"));
2163  }
2164  $this->insertQuestions($selected_array);
2165  return;
2166  }
2167 
2168  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_questions.html", "Modules/Test");
2169 
2170  $total = $this->object->evalTotalPersons();
2171  if ($ilAccess->checkAccess("write", "", $this->ref_id)) {
2172  if ($total != 0) {
2173  $link = $this->ctrl->getLinkTarget($this, "participants");
2174  $link = "<a href=\"" . $link . "\">" . $this->lng->txt("test_has_datasets_warning_page_view_link") . "</a>";
2175  ilUtil::sendInfo($this->lng->txt("test_has_datasets_warning_page_view") . " " . $link);
2176  } else {
2177  global $ilToolbar;
2178 
2179  $ilToolbar->addButton($this->lng->txt("ass_create_question"), $this->ctrl->getLinkTarget($this, "addQuestion"));
2180 
2181  if ($this->object->getPoolUsage()) {
2182  $ilToolbar->addSeparator();
2183 
2184  require_once 'Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php';
2185 
2187  }
2188 
2189  $ilToolbar->addSeparator();
2190  $ilToolbar->addButton($this->lng->txt("random_selection"), $this->ctrl->getLinkTarget($this, "randomselect"));
2191 
2192 
2193  global $ilAccess, $ilUser, $lng, $ilCtrl;
2194  $online_access = false;
2195  if ($this->object->getFixedParticipants()) {
2196  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
2197  $online_access_result = ilObjTestAccess::_lookupOnlineTestAccess($this->object->getId(), $ilUser->getId());
2198  if ($online_access_result === true) {
2199  $online_access = true;
2200  }
2201  }
2202 
2203  if ($this->object->isOnline() && $this->object->isComplete($this->testQuestionSetConfigFactory->getQuestionSetConfig())) {
2204  if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id)) {
2205  $testSession = $this->testSessionFactory->getSession();
2206  $testSequence = $this->testSequenceFactory->getSequenceByTestSession($testSession);
2207 
2208  $testPlayerGUI = $this->testPlayerFactory->getPlayerGUI();
2209 
2210  $executable = $this->object->isExecutable($testSession, $ilUser->getId(), $allowPassIncrease = true);
2211 
2212  if ($executable["executable"]) {
2213  if ($testSession->getActiveId() > 0) {
2214  // resume test
2215 
2216  if ($testSequence->hasStarted($testSession)) {
2217  $execTestLabel = $this->lng->txt("tst_resume_test");
2218  $execTestLink = $this->ctrl->getLinkTarget($testPlayerGUI, 'resumePlayer');
2219  } else {
2220  $execTestLabel = $this->object->getStartTestLabel($testSession->getActiveId());
2221  $execTestLink = $this->ctrl->getLinkTarget($testPlayerGUI, 'startPlayer');
2222  }
2223  } else {
2224  // start new test
2225 
2226  $execTestLabel = $this->object->getStartTestLabel($testSession->getActiveId());
2227  $execTestLink = $this->ctrl->getLinkTarget($testPlayerGUI, 'startPlayer');
2228  }
2229 
2230  $ilToolbar->addSeparator();
2231  $ilToolbar->addButton($execTestLabel, $execTestLink);
2232  }
2233  }
2234  }
2235  }
2236  }
2237 
2238  $this->tpl->setCurrentBlock("adm_content");
2239  include_once "./Modules/Test/classes/tables/class.ilTestQuestionsTableGUI.php";
2240  $checked_move = is_array($_SESSION['tst_qst_move_' . $this->object->getTestId()]) && (count($_SESSION['tst_qst_move_' . $this->object->getTestId()]));
2241  $table_gui = new ilTestQuestionsTableGUI($this, 'questions', (($ilAccess->checkAccess("write", "", $this->ref_id) ? true : false)), $checked_move, $total);
2242  $data = $this->object->getTestQuestions();
2243  $table_gui->setData($data);
2244  $this->tpl->setVariable('QUESTIONBROWSER', $table_gui->getHTML());
2245  $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this));
2246  $this->tpl->parseCurrentBlock();
2247  }
2248 
2254  {
2255  require_once 'Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php';
2256 
2257  $this->ctrl->setParameterByClass('ilTestQuestionBrowserTableGUI', ilTestQuestionBrowserTableGUI::CONTEXT_PARAMETER, $context);
2258 
2259  $this->ctrl->setParameterByClass('ilTestQuestionBrowserTableGUI', ilTestQuestionBrowserTableGUI::MODE_PARAMETER, ilTestQuestionBrowserTableGUI::MODE_BROWSE_POOLS);
2260 
2261  $toolbar->addButton($this->lng->txt("tst_browse_for_qpl_questions"), $this->ctrl->getLinkTargetByClass('ilTestQuestionBrowserTableGUI', ilTestQuestionBrowserTableGUI::CMD_BROWSE_QUESTIONS));
2262 
2263  $this->ctrl->setParameterByClass('ilTestQuestionBrowserTableGUI', ilTestQuestionBrowserTableGUI::MODE_PARAMETER, ilTestQuestionBrowserTableGUI::MODE_BROWSE_TESTS);
2264 
2265  $toolbar->addButton($this->lng->txt("tst_browse_for_tst_questions"), $this->ctrl->getLinkTargetByClass('ilTestQuestionBrowserTableGUI', ilTestQuestionBrowserTableGUI::CMD_BROWSE_QUESTIONS));
2266  }
2267 
2268  public function takenObject()
2269  {
2270  }
2271 
2280  {
2281  global $ilDB, $lng;
2282 
2283  require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
2284 
2285  $participantData = new ilTestParticipantData($ilDB, $lng);
2286  $participantData->load($this->object->getTestId());
2287 
2288  $this->object->removeTestResults($participantData);
2289 
2290  ilUtil::sendSuccess($this->lng->txt("tst_all_user_data_deleted"), true);
2291  $this->ctrl->redirect($this, "participants");
2292  }
2293 
2302  {
2303  global $ilDB, $lng;
2304 
2305  require_once 'Modules/Test/classes/class.ilTestParticipantData.php';
2306  $participantData = new ilTestParticipantData($ilDB, $lng);
2307 
2308  if ($this->object->getFixedParticipants()) {
2309  $participantData->setUserIds($_POST["chbUser"]);
2310  } else {
2311  $participantData->setActiveIds($_POST["chbUser"]);
2312  }
2313 
2314  $participantData->load($this->object->getTestId());
2315 
2316  $this->object->removeTestResults($participantData);
2317 
2318  ilUtil::sendSuccess($this->lng->txt("tst_selected_user_data_deleted"), true);
2319  $this->ctrl->redirect($this, "participants");
2320  }
2321 
2330  {
2331  $this->ctrl->redirect($this, "participants");
2332  }
2333 
2343  public function deleteAllUserDataObject()
2344  {
2345  ilUtil::sendQuestion($this->lng->txt("confirm_delete_all_user_data"));
2346  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_maintenance.html", "Modules/Test");
2347 
2348  $this->tpl->setCurrentBlock("confirm_delete");
2349  $this->tpl->setVariable("BTN_CONFIRM_DELETE_ALL", $this->lng->txt("confirm"));
2350  $this->tpl->setVariable("BTN_CANCEL_DELETE_ALL", $this->lng->txt("cancel"));
2351  $this->tpl->parseCurrentBlock();
2352 
2353  $this->tpl->setCurrentBlock("adm_content");
2354  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
2355  $this->tpl->parseCurrentBlock();
2356  }
2357 
2361  public function deleteAllUserResultsObject()
2362  {
2363  // display confirmation message
2364  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
2365  $cgui = new ilConfirmationGUI();
2366  $cgui->setFormAction($this->ctrl->getFormAction($this, "participants"));
2367  $cgui->setHeaderText($this->lng->txt("delete_all_user_data_confirmation"));
2368  $cgui->setCancel($this->lng->txt("cancel"), "participants");
2369  $cgui->setConfirm($this->lng->txt("proceed"), "confirmDeleteAllUserResults");
2370 
2371  $this->tpl->setContent($cgui->getHTML());
2372  }
2373 
2382  {
2383  if (count($_POST["chbUser"]) == 0) {
2384  ilUtil::sendInfo($this->lng->txt("select_one_user"), true);
2385  $this->ctrl->redirect($this, "participants");
2386  }
2387 
2388  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
2389  $cgui = new ilConfirmationGUI();
2390  $cgui->setHeaderText($this->lng->txt("confirm_delete_single_user_data"));
2391 
2392  $cgui->setFormAction($this->ctrl->getFormAction($this));
2393  $cgui->setCancel($this->lng->txt("cancel"), "cancelDeleteSelectedUserData");
2394  $cgui->setConfirm($this->lng->txt("confirm"), "confirmDeleteSelectedUserData");
2395 
2396  include_once './Services/User/classes/class.ilObjUser.php';
2397  foreach ($_POST["chbUser"] as $key => $active_id) {
2398  if ($this->object->getFixedParticipants()) {
2399  $user_id = $active_id;
2400  } else {
2401  $user_id = $this->object->_getUserIdFromActiveId($active_id);
2402  }
2403  $user = ilObjUser::_lookupName($user_id);
2404 
2405  if ($this->object->getAnonymity()) {
2406  $name = $this->lng->txt("anonymous");
2407  } elseif ($user["lastname"]) {
2408  $name = $user["lastname"] . ", " . $user["firstname"] . " (" .
2409  $user["login"] . ")";
2410  } else {
2411  $name = $this->lng->txt("deleted_user");
2412  }
2413 
2414  $cgui->addItem(
2415  "chbUser[]",
2416  $active_id,
2417  $name,
2418  ilUtil::getImagePath("icon_usr.svg"),
2419  $this->lng->txt("usr")
2420  );
2421  }
2422 
2423  $this->tpl->setContent($cgui->getHTML());
2424  }
2425 
2433  public function historyObject()
2434  {
2435  include_once "./Modules/Test/classes/tables/class.ilTestHistoryTableGUI.php";
2436  $table_gui = new ilTestHistoryTableGUI($this, 'history');
2437  $table_gui->setTestObject($this->object);
2438  include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
2439  $log =&ilObjAssessmentFolder::_getLog(0, time(), $this->object->getId(), true);
2440  $table_gui->setData($log);
2441  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
2442  }
2443 
2444  public function initImportForm($a_new_type)
2445  {
2446  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2447  $form = new ilPropertyFormGUI();
2448  $form->setTarget("_top");
2449  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
2450  $this->ctrl->setParameter($this, "new_type", $new_type);
2451  $form->setFormAction($this->ctrl->getFormAction($this));
2452  $form->setTitle($this->lng->txt("import_tst"));
2453 
2454  // file
2455  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
2456  $fi = new ilFileInputGUI($this->lng->txt("import_file"), "xmldoc");
2457  $fi->setSuffixes(array("zip"));
2458  $fi->setRequired(true);
2459  $form->addItem($fi);
2460 
2461  // question pool
2462  include_once("./Modules/Test/classes/class.ilObjTest.php");
2463  $tst = new ilObjTest();
2464  $questionpools = $tst->getAvailableQuestionpools(true, false, true, true);
2465  if (count($questionpools)) {
2466  $options = array("-1" => $this->lng->txt("dont_use_questionpool"));
2467  foreach ($questionpools as $key => $value) {
2468  $options[$key] = $value["title"];
2469  }
2470 
2471  $pool = new ilSelectInputGUI($this->lng->txt("select_questionpool"), "qpl");
2472  $pool->setInfo($this->lng->txt('select_question_pool_info'));
2473  $pool->setOptions($options);
2474  $form->addItem($pool);
2475  }
2476 
2477  $form->addCommandButton("importFile", $this->lng->txt("import"));
2478  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
2479 
2480  return $form;
2481  }
2482 
2488  public function participantsActionObject()
2489  {
2490  $command = $_POST["command"];
2491  if (strlen($command)) {
2492  $method = $command . "Object";
2493  if (method_exists($this, $method)) {
2494  $this->$method();
2495  return;
2496  }
2497  }
2498  $this->ctrl->redirect($this, "participants");
2499  }
2500 
2506  public function participantsObject()
2507  {
2508  global $ilAccess, $ilToolbar, $lng;
2509 
2510  $this->getParticipantsSubTabs();
2511 
2512  if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
2513  // allow only write access
2514  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
2515  $this->ctrl->redirect($this, "infoScreen");
2516  }
2517 
2518  if ($this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken()) {
2520  $this->testQuestionSetConfigFactory->getQuestionSetConfig()->getDepenciesBrokenMessage($this->lng)
2521  );
2522  } elseif ($this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesInVulnerableState()) {
2524  $this->testQuestionSetConfigFactory->getQuestionSetConfig()->getDepenciesInVulnerableStateMessage($this->lng)
2525  );
2526  }
2527 
2528  if ($this->object->getFixedParticipants()) {
2529  // search button
2530  include_once './Services/Search/classes/class.ilRepositorySearchGUI.php';
2532  $this,
2533  $ilToolbar,
2534  array(
2535  'auto_complete_name' => $lng->txt('user'),
2536  'submit_name' => $lng->txt('add')
2537  )
2538  );
2539 
2540  $ilToolbar->addSeparator();
2541  $search_btn = ilLinkButton::getInstance();
2542  $search_btn->setCaption('tst_search_users');
2543  $search_btn->setUrl($this->ctrl->getLinkTargetByClass('ilRepositorySearchGUI', 'start'));
2544  $ilToolbar->addButtonInstance($search_btn);
2545  require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
2546 
2547  $participants =&$this->object->getInvitedUsers();
2548  $rows = array();
2549  $unfinished_passes = false;
2550  foreach ($participants as $data) {
2551  $maxpass = $this->object->_getMaxPass($data["active_id"]);
2552  if (!is_null($maxpass)) {
2553  $maxpass += 1;
2554  }
2555  $access = "";
2556  if (strlen($data["active_id"])) {
2557  $last_access = $this->object->_getLastAccess($data["active_id"]);
2558  $access = $last_access;
2559  }
2560  $this->ctrl->setParameterByClass('iltestevaluationgui', 'active_id', $data['active_id']);
2561 
2562  if ($data['active_id'] == null) { // if no active id is set, user is invitee not participant...
2563  if (strlen($data["firstname"] . $data["lastname"]) == 0) {
2564  $fullname = $lng->txt("deleted_user");
2565  } elseif ($this->object->getAnonymity()) {
2566  $fullname = $lng->txt('anonymous');
2567  } else {
2568  $fullname = trim($data["lastname"] . ", " . $data["firstname"] . " " . $data["title"]);
2569  }
2570  } else {
2571  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
2572  $fullname = ilObjTestAccess::_getParticipantData($data['active_id']);
2573  }
2574 
2575  $unfinished_pass_data = 0;
2576  if ($data["unfinished_passes"] == 1) {
2577  $unfinished_pass_data = 1;
2578  $unfinished_passes = true;
2579  }
2580 
2581  array_push($rows, array(
2582  'usr_id' => $data["usr_id"],
2583  'active_id' => $data['active_id'],
2584  'login' => $data["login"],
2585  'clientip' => $data["clientip"],
2586  'firstname' => $data["firstname"],
2587  'lastname' => $data["lastname"],
2588  'name' => $fullname,
2589  'started' => ($data["active_id"] > 0) ? 1 : 0,
2590  'unfinished' => $unfinished_pass_data,
2591  'finished' => ($data["test_finished"] == 1) ? 1 : 0,
2592  'access' => $access,
2593  'maxpass' => $maxpass,
2594  'result' => $this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'outParticipantsResultsOverview'),
2595  'finish_link' => $this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'finishTestPassForSingleUser')
2596  ));
2597  }
2598  include_once "./Modules/Test/classes/tables/class.ilTestFixedParticipantsTableGUI.php";
2599  $table_gui = new ilTestFixedParticipantsTableGUI(
2600  $this,
2601  'participants',
2602  $this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken(),
2603  $this->object->getAnonymity(),
2604  count($rows)
2605  );
2606  $table_gui->setFilterCommand('fpSetFilter');
2607  $table_gui->setResetCommand('fpResetFiler');
2608  $rows = $this->applyFilterCriteria($rows);
2609  $table_gui->setData($rows);
2610  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
2611 
2612  if (count($rows) > 0) {
2613  $ilToolbar->addSeparator();
2614  $delete_all_results_btn = ilLinkButton::getInstance();
2615  $delete_all_results_btn->setCaption('delete_all_user_data');
2616  $delete_all_results_btn->setUrl($this->ctrl->getLinkTarget($this, 'deleteAllUserResults'));
2617  $ilToolbar->addButtonInstance($delete_all_results_btn);
2618  }
2619  $this->addFinishAllPassesButton($unfinished_passes, $ilToolbar);
2620  } else {
2621  $participants =&$this->object->getTestParticipants();
2622  $rows = array();
2623  $unfinished_passes = false;
2624 
2625  foreach ($participants as $data) {
2626  $maxpass = $this->object->_getMaxPass($data["active_id"]);
2627  if (!is_null($maxpass)) {
2628  $maxpass += 1;
2629  }
2630  $access = "";
2631  if (strlen($data["active_id"])) {
2632  $last_access = $this->object->_getLastAccess($data["active_id"]);
2633  $access = $last_access;
2634  }
2635  $this->ctrl->setParameterByClass('iltestevaluationgui', 'active_id', $data['active_id']);
2636 
2637  $unfinished_pass_data = 0;
2638  if ($data["unfinished_passes"] == 1) {
2639  $unfinished_pass_data = 1;
2640  $unfinished_passes = true;
2641  }
2642 
2643  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
2644  $fullname = ilObjTestAccess::_getParticipantData($data['active_id']);
2645  array_push($rows, array(
2646  'usr_id' => $data["active_id"],
2647  'active_id' => $data['active_id'],
2648  'login' => $data["login"],
2649  'name' => $fullname,
2650  'firstname' => $data["firstname"],
2651  'lastname' => $data["lastname"],
2652  'started' => ($data["active_id"] > 0) ? 1 : 0,
2653  'unfinished' => $unfinished_pass_data,
2654  'finished' => ($data["test_finished"] == 1) ? 1 : 0,
2655  'access' => $access,
2656  'maxpass' => $maxpass,
2657  'result' => $this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'outParticipantsResultsOverview'),
2658  'finish_link' => $this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'finishTestPassForSingleUser')
2659  ));
2660  }
2661  include_once "./Modules/Test/classes/tables/class.ilTestParticipantsTableGUI.php";
2662  $table_gui = new ilTestParticipantsTableGUI(
2663  $this,
2664  'participants',
2665  $this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken(),
2666  $this->object->getAnonymity(),
2667  count($rows)
2668  );
2669 
2670  if (count($rows) > 0) {
2671  require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
2672  $delete_all_results_btn = ilLinkButton::getInstance();
2673  $delete_all_results_btn->setCaption('delete_all_user_data');
2674  $delete_all_results_btn->setUrl($this->ctrl->getLinkTarget($this, 'deleteAllUserResults'));
2675  $ilToolbar->addStickyItem($delete_all_results_btn);
2676  }
2677 
2678  $this->addFinishAllPassesButton($unfinished_passes, $ilToolbar);
2679 
2680  $table_gui->setFilterCommand('npSetFilter');
2681  $table_gui->setResetCommand('npResetFilter');
2682  $rows = $this->applyFilterCriteria($rows);
2683  $table_gui->setData($rows);
2684  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
2685  }
2686  }
2687 
2692  protected function addFinishAllPassesButton($unfinished_passes, $ilToolbar)
2693  {
2694  if ($unfinished_passes) {
2695  $ilToolbar->addSeparator();
2696  $finish_all_user_passes_btn = ilLinkButton::getInstance();
2697  $finish_all_user_passes_btn->setCaption('finish_all_user_passes');
2698  $finish_all_user_passes_btn->setUrl($this->ctrl->getLinkTargetByClass('iltestevaluationgui', 'finishAllUserPasses'));
2699  $ilToolbar->addButtonInstance($finish_all_user_passes_btn);
2700  }
2701  }
2702 
2703  public function timingOverviewObject()
2704  {
2705  $this->getParticipantsSubTabs();
2706 
2707  include_once "./Modules/Test/classes/tables/class.ilTimingOverviewTableGUI.php";
2708  $table_gui = new ilTimingOverviewTableGUI($this, 'timingOverview');
2709 
2710  $participants =&$this->object->getTestParticipants();#
2711  $times = $this->object->getStartingTimeOfParticipants();
2712  $addons = $this->object->getTimeExtensionsOfParticipants();
2713 
2714  $tbl_data = array();
2715  foreach ($participants as $participant) {
2716  $tblRow = array();
2717 
2718  $started = "";
2719  if ($times[$participant['active_id']]) {
2720  $started = $this->lng->txt('tst_started') . ': ' . ilDatePresentation::formatDate(new ilDateTime($times[$participant['active_id']], IL_CAL_DATETIME));
2721  $tblRow['started'] = $started;
2722  } else {
2723  $tblRow['started'] = '';
2724  }
2725 
2726  if ($addons[$participant['active_id']] > 0) {
2727  $tblRow['extratime'] = $addons[$participant['active_id']];
2728  }
2729 
2730  $tblRow['login'] = $participant['login'];
2731 
2732  if ($this->object->getAnonymity()) {
2733  $tblRow['name'] = $this->lng->txt("anonymous");
2734  } else {
2735  $tblRow['name'] = $participant['lastname'] . ', ' . $participant['firstname'];
2736  }
2737 
2738  $tbl_data[] = $tblRow;
2739  }
2740  $table_gui->setData($tbl_data);
2741 
2742  $this->tpl->setContent($table_gui->getHTML());
2743  }
2744 
2745  public function timingObject()
2746  {
2747  $this->getParticipantsSubTabs();
2748 
2749  global $ilAccess;
2750 
2751  if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
2752  // allow only write access
2753  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
2754  $this->ctrl->redirect($this, "infoScreen");
2755  }
2756 
2757  if ($this->object->getProcessingTimeInSeconds() > 0 && $this->object->getNrOfTries() == 1) {
2758  $form = $this->formTimingObject();
2759  if (count($_POST) && $form->checkInput()) {
2760  $res = $this->object->addExtraTime($form->getInput('participant'), $form->getInput('extratime'));
2761  ilUtil::sendSuccess(sprintf($this->lng->txt('tst_extratime_added'), $form->getInput('extratime')), true);
2762  $this->ctrl->redirect($this, 'timingOverview');
2763  } else {
2764  return $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
2765  }
2766  } else {
2767  ilUtil::sendInfo($this->lng->txt("tst_extratime_notavailable"));
2768  }
2769  }
2770 
2771  private function formTimingObject()
2772  {
2773  global $ilAccess;
2774 
2775  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
2776  $form = new ilPropertyFormGUI();
2777  $form->setFormAction($this->ctrl->getFormAction($this));
2778  $form->setTableWidth("100%");
2779  $form->setId("tst_change_workingtime");
2780  $form->setTitle($this->lng->txt("tst_change_workingtime"));
2781 
2782  // test users
2783  $participantslist = new ilSelectInputGUI($this->lng->txt('participants'), "participant");
2784  $participants =&$this->object->getTestParticipants();
2785  $times = $this->object->getStartingTimeOfParticipants();
2786  $addons = $this->object->getTimeExtensionsOfParticipants();
2787  $options = array(
2788  '' => $this->lng->txt('please_select'),
2789  '0' => $this->lng->txt('all_participants')
2790  );
2791  foreach ($participants as $participant) {
2792  $started = "";
2793 
2794  if ($this->object->getAnonymity()) {
2795  $name = $this->lng->txt("anonymous");
2796  } else {
2797  $name = $participant['lastname'] . ', ' . $participant['firstname'];
2798  }
2799 
2800 
2801  if ($times[$participant['active_id']]) {
2802  $started = ", " . $this->lng->txt('tst_started') . ': ' . ilDatePresentation::formatDate(new ilDateTime($times[$participant['active_id']], IL_CAL_DATETIME));
2803  }
2804  if ($addons[$participant['active_id']] > 0) {
2805  $started .= ", " . $this->lng->txt('extratime') . ': ' . $addons[$participant['active_id']] . ' ' . $this->lng->txt('minutes');
2806  }
2807  $options[$participant['active_id']] = $participant['login'] . ' (' . $name . ')' . $started;
2808  }
2809  $participantslist->setRequired(true);
2810  $participantslist->setOptions($options);
2811  $form->addItem($participantslist);
2812 
2813  // extra time
2814  $extratime = new ilNumberInputGUI($this->lng->txt("extratime"), "extratime");
2815  $extratime->setInfo($this->lng->txt('tst_extratime_info'));
2816  $extratime->setRequired(true);
2817  $extratime->setMinValue(0);
2818  $extratime->setMinvalueShouldBeGreater(false);
2819  $extratime->setSuffix($this->lng->txt('minutes'));
2820  $extratime->setSize(5);
2821  $form->addItem($extratime);
2822 
2823  if (is_array($_POST) && strlen($_POST['cmd']['timing'])) {
2824  $form->setValuesByArray($_POST);
2825  }
2826 
2827  if ($ilAccess->checkAccess("write", "", $_GET["ref_id"])) {
2828  $form->addCommandButton("timing", $this->lng->txt("save"));
2829  }
2830  $form->addCommandButton('timingOverview', $this->lng->txt("cancel"));
2831  return $form;
2832  }
2833 
2834  public function showTimingFormObject()
2835  {
2836  $form = $this->formTimingObject();
2837  $this->tpl->setContent($form->getHTML());
2838  }
2839 
2840  public function applyFilterCriteria($in_rows)
2841  {
2842  global $ilDB;
2843  $sess_filter = $_SESSION['form_tst_participants_' . $this->ref_id]['selection'];
2844  $sess_filter = str_replace('"', '', $sess_filter);
2845  $sess_filter = explode(':', $sess_filter);
2846  $filter = substr($sess_filter[2], 0, strlen($sess_filter[2])-1);
2847 
2848  if ($filter == 'all' || $filter == false) {
2849  return $in_rows; #unchanged - no filter.
2850  }
2851 
2852  $with_result = array();
2853  $without_result = array();
2854  foreach ($in_rows as $row) {
2855  $result = $ilDB->query(
2856  'SELECT count(solution_id) count
2857  FROM tst_solutions
2858  WHERE active_fi = ' . $ilDB->quote($row['active_id'])
2859  );
2860  $count = $ilDB->fetchAssoc($result);
2861  $count = $count['count'];
2862 
2863  if ($count == 0) {
2864  $without_result[] = $row;
2865  } else {
2866  $with_result[] = $row;
2867  }
2868  }
2869 
2870  if ($filter == 'withSolutions') {
2871  return $with_result;
2872  }
2873  return $without_result;
2874  }
2875 
2876  public function fpSetFilterObject()
2877  {
2878  include_once("./Modules/Test/classes/tables/class.ilTestFixedParticipantsTableGUI.php");
2879  $table_gui = new ilTestFixedParticipantsTableGUI($this, "participants", false, $this->object->getAnonymity(), 0);
2880  $table_gui->writeFilterToSession(); // writes filter to session
2881  $table_gui->resetOffset(); // sets record offest to 0 (first page)
2882  $this->participantsObject();
2883  }
2884 
2885  public function fpResetFilterObject()
2886  {
2887  include_once("./Modules/Test/classes/tables/class.ilTestFixedParticipantsTableGUI.php");
2888  $table_gui = new ilTestFixedParticipantsTableGUI(
2889  $this,
2890  "participants",
2891  false,
2892  $this->object->getAnonymity(),
2893  0
2894  );
2895  $table_gui->resetFilter(); // writes filter to session
2896  $table_gui->resetOffset(); // sets record offest to 0 (first page)
2897  $this->participantsObject();
2898  }
2899 
2900  public function npSetFilterObject()
2901  {
2902  include_once("./Modules/Test/classes/tables/class.ilTestParticipantsTableGUI.php");
2903  $table_gui = new ilTestParticipantsTableGUI(
2904  $this,
2905  "participants",
2906  false,
2907  $this->object->getAnonymity(),
2908  0
2909  );
2910  $table_gui->writeFilterToSession(); // writes filter to session
2911  $table_gui->resetOffset(); // sets record offest to 0 (first page)
2912  $this->participantsObject();
2913  }
2914 
2915  public function npResetFilterObject()
2916  {
2917  include_once("./Modules/Test/classes/tables/class.ilTestParticipantsTableGUI.php");
2918  $table_gui = new ilTestParticipantsTableGUI(
2919  $this,
2920  "participants",
2921  false,
2922  $this->object->getAnonymity(),
2923  0
2924  );
2925  $table_gui->resetFilter(); // writes filter to session
2926  $table_gui->resetOffset(); // sets record offest to 0 (first page)
2927  $this->participantsObject();
2928  }
2929 
2935  public function showDetailedResultsObject()
2936  {
2937  if (count($_POST)) {
2938  $_SESSION["show_user_results"] = $_POST["chbUser"];
2939  }
2940  $this->showUserResults($show_pass_details = true, $show_answers = true, $show_reached_points = true);
2941  }
2942 
2948  public function showUserAnswersObject()
2949  {
2950  if (count($_POST)) {
2951  $_SESSION["show_user_results"] = $_POST["chbUser"];
2952  }
2953  $this->showUserResults($show_pass_details = false, $show_answers = true);
2954  }
2955 
2961  public function showPassOverviewObject()
2962  {
2963  if (count($_POST)) {
2964  $_SESSION["show_user_results"] = $_POST["chbUser"];
2965  }
2966  $this->showUserResults($show_pass_details = true, $show_answers = false);
2967  }
2968 
2974  public function showUserResults($show_pass_details, $show_answers, $show_reached_points = false)
2975  {
2976  $show_user_results = $_SESSION["show_user_results"];
2977 
2978  if (count($show_user_results) == 0) {
2979  ilUtil::sendInfo($this->lng->txt("select_one_user"), true);
2980  $this->ctrl->redirect($this, "participants");
2981  }
2982 
2983 
2984  $template = $this->createUserResults($show_pass_details, $show_answers, $show_reached_points, $show_user_results);
2985 
2986  if ($template instanceof ilTemplate) {
2987  $this->tpl->setVariable("ADM_CONTENT", $template->get());
2988  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
2989  if ($this->object->getShowSolutionAnswersOnly()) {
2990  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css", "Modules/Test"), "print");
2991  }
2992  }
2993  }
2994 
2995  public function removeParticipantObject()
2996  {
2997  if (is_array($_POST["chbUser"])) {
2998  foreach ($_POST["chbUser"] as $user_id) {
2999  $this->object->disinviteUser($user_id);
3000  }
3001  } else {
3002  ilUtil::sendInfo($this->lng->txt("select_one_user"), true);
3003  }
3004  $this->ctrl->redirect($this, "participants");
3005  }
3006 
3007  public function saveClientIPObject()
3008  {
3009  if (is_array($_POST["chbUser"])) {
3010  foreach ($_POST["chbUser"] as $user_id) {
3011  $this->object->setClientIP($user_id, $_POST["clientip_" . $user_id]);
3012  }
3013  } else {
3014  ilUtil::sendInfo($this->lng->txt("select_one_user"), true);
3015  }
3016  $this->ctrl->redirect($this, "participants");
3017  }
3018 
3026  public function printobject()
3027  {
3028  global $ilAccess, $ilias;
3029  if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
3030  // allow only write access
3031  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3032  $this->ctrl->redirect($this, "infoScreen");
3033  }
3034 
3035  $isPdfDeliveryRequest = isset($_GET['pdf']) && $_GET['pdf'];
3036 
3037  $this->getQuestionsSubTabs();
3038  $template = new ilTemplate("tpl.il_as_tst_print_test_confirm.html", true, true, "Modules/Test");
3039 
3040  if (!$isPdfDeliveryRequest) { // #15243
3041  $this->ctrl->setParameter($this, "pdf", "1");
3042  $template->setCurrentBlock("pdf_export");
3043  $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "print"));
3044  $this->ctrl->setParameter($this, "pdf", "");
3045  $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
3046  $template->parseCurrentBlock();
3047 
3048  $template->setCurrentBlock("navigation_buttons");
3049  $template->setVariable("BUTTON_PRINT", $this->lng->txt("print"));
3050  $template->parseCurrentBlock();
3051  }
3052  // prepare generation before contents are processed (for mathjax)
3053  else {
3054  require_once 'Services/PDFGeneration/classes/class.ilPDFGeneration.php';
3056  }
3057 
3058  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
3059 
3060  global $ilUser;
3061  $print_date = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y"));
3062  $max_points= 0;
3063  $counter = 1;
3064 
3065  require_once 'Modules/Test/classes/class.ilTestQuestionHeaderBlockBuilder.php';
3066  $questionHeaderBlockBuilder = new ilTestQuestionHeaderBlockBuilder($this->lng);
3067  $questionHeaderBlockBuilder->setHeaderMode($this->object->getTitleOutput());
3068 
3069  if ($isPdfDeliveryRequest) {
3070  require_once 'Services/WebAccessChecker/classes/class.ilWACSignedPath.php';
3072  }
3073 
3074  foreach ($this->object->questions as $question) {
3075  $template->setCurrentBlock("question");
3076  $question_gui = $this->object->createQuestionGUI("", $question);
3077 
3078  if ($isPdfDeliveryRequest) {
3079  $question_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_PRINT_PDF);
3080  }
3081 
3082  $questionHeaderBlockBuilder->setQuestionTitle($question_gui->object->getTitle());
3083  $questionHeaderBlockBuilder->setQuestionPoints($question_gui->object->getMaximumPoints());
3084  $questionHeaderBlockBuilder->setQuestionPosition($counter);
3085  $template->setVariable("QUESTION_HEADER", $questionHeaderBlockBuilder->getHTML());
3086 
3087  $template->setVariable("TXT_QUESTION_ID", $this->lng->txt('question_id_short'));
3088  $template->setVariable("QUESTION_ID", $question_gui->object->getId());
3089  $result_output = $question_gui->getSolutionOutput("", null, false, true, false, $this->object->getShowSolutionFeedback());
3090  $template->setVariable("SOLUTION_OUTPUT", $result_output);
3091  $template->parseCurrentBlock("question");
3092  $counter++;
3093  $max_points += $question_gui->object->getMaximumPoints();
3094  }
3095 
3096  $template->setVariable("TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
3097  $template->setVariable("PRINT_TEST", ilUtil::prepareFormOutput($this->lng->txt("tst_print")));
3098  $template->setVariable("TXT_PRINT_DATE", ilUtil::prepareFormOutput($this->lng->txt("date")));
3099  $template->setVariable("VALUE_PRINT_DATE", ilUtil::prepareFormOutput(strftime("%c", $print_date)));
3100  $template->setVariable("TXT_MAXIMUM_POINTS", ilUtil::prepareFormOutput($this->lng->txt("tst_maximum_points")));
3101  $template->setVariable("VALUE_MAXIMUM_POINTS", ilUtil::prepareFormOutput($max_points));
3102 
3103  if ($isPdfDeliveryRequest) {
3104  require_once 'Modules/Test/classes/class.ilTestPDFGenerator.php';
3106  } else {
3107  $this->tpl->setVariable("PRINT_CONTENT", $template->get());
3108  }
3109  }
3110 
3118  public function reviewobject()
3119  {
3120  global $ilAccess;
3121 
3122  if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
3123  // allow only write access
3124  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3125  $this->ctrl->redirect($this, "infoScreen");
3126  }
3127  $this->getQuestionsSubTabs();
3128  $template = new ilTemplate("tpl.il_as_tst_print_test_confirm.html", true, true, "Modules/Test");
3129 
3130  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
3131 
3132  $isPdfDeliveryRequest = isset($_GET['pdf']) && $_GET['pdf'];
3133 
3134  $max_points= 0;
3135  $counter = 1;
3136 
3137  require_once 'Modules/Test/classes/class.ilTestQuestionHeaderBlockBuilder.php';
3138  $questionHeaderBlockBuilder = new ilTestQuestionHeaderBlockBuilder($this->lng);
3139  $questionHeaderBlockBuilder->setHeaderMode($this->object->getTitleOutput());
3140 
3141  if ($isPdfDeliveryRequest) {
3142  require_once 'Services/WebAccessChecker/classes/class.ilWACSignedPath.php';
3144 
3145  // prepare generation before contents are processed (for mathjax)
3146  require_once 'Services/PDFGeneration/classes/class.ilPDFGeneration.php';
3148  }
3149 
3150  foreach ($this->object->questions as $question) {
3151  $template->setCurrentBlock("question");
3152  $question_gui = $this->object->createQuestionGUI("", $question);
3153  $question_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_PREVIEW);
3154 
3155  $questionHeaderBlockBuilder->setQuestionTitle($question_gui->object->getTitle());
3156  $questionHeaderBlockBuilder->setQuestionPoints($question_gui->object->getMaximumPoints());
3157  $questionHeaderBlockBuilder->setQuestionPosition($counter);
3158  $template->setVariable("QUESTION_HEADER", $questionHeaderBlockBuilder->getHTML());
3159 
3160  $template->setVariable("SOLUTION_OUTPUT", $question_gui->getPreview(false));
3161  $template->parseCurrentBlock("question");
3162  $counter++;
3163  $max_points += $question_gui->object->getMaximumPoints();
3164  }
3165 
3166  $template->setVariable("TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
3167  $template->setVariable("PRINT_TEST", ilUtil::prepareFormOutput($this->lng->txt("review_view")));
3168  $template->setVariable("TXT_PRINT_DATE", ilUtil::prepareFormOutput($this->lng->txt("date")));
3169  $usedRelativeDates = ilDatePresentation::useRelativeDates();
3171  $template->setVariable(
3172  "VALUE_PRINT_DATE",
3174  );
3175  ilDatePresentation::setUseRelativeDates($usedRelativeDates);
3176  $template->setVariable("TXT_MAXIMUM_POINTS", ilUtil::prepareFormOutput($this->lng->txt("tst_maximum_points")));
3177  $template->setVariable("VALUE_MAXIMUM_POINTS", ilUtil::prepareFormOutput($max_points));
3178 
3179  if ($isPdfDeliveryRequest) {
3180  require_once 'Modules/Test/classes/class.ilTestPDFGenerator.php';
3182  } else {
3183  $this->ctrl->setParameter($this, "pdf", "1");
3184  $template->setCurrentBlock("pdf_export");
3185  $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "review"));
3186  $this->ctrl->setParameter($this, "pdf", "");
3187  $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
3188  $template->parseCurrentBlock();
3189 
3190  $template->setCurrentBlock("navigation_buttons");
3191  $template->setVariable("BUTTON_PRINT", $this->lng->txt("print"));
3192  $template->parseCurrentBlock();
3193 
3194 
3195  $this->tpl->setVariable("PRINT_CONTENT", $template->get());
3196  }
3197  }
3198 
3199  public function addParticipantsObject($a_user_ids = array())
3200  {
3201  $countusers = 0;
3202  // add users
3203  if (is_array($a_user_ids)) {
3204  $i = 0;
3205  foreach ($a_user_ids as $user_id) {
3206  $client_ip = $_POST["client_ip"][$i];
3207  $this->object->inviteUser($user_id, $client_ip);
3208  $countusers++;
3209  $i++;
3210  }
3211  }
3212  $message = "";
3213  if ($countusers) {
3214  $message = $this->lng->txt("tst_invited_selected_users");
3215  }
3216  if (strlen($message)) {
3217  ilUtil::sendInfo($message, true);
3218  } else {
3219  ilUtil::sendInfo($this->lng->txt("tst_invited_nobody"), true);
3220  return false;
3221  }
3222 
3223  $this->ctrl->redirect($this, "participants");
3224  }
3225 
3229  public function defaultsObject()
3230  {
3236  global $ilAccess, $ilToolbar, $tpl;
3237 
3238  if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
3239  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3240  $this->ctrl->redirect($this, "infoScreen");
3241  }
3242 
3243  $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'addDefaults'));
3244  $ilToolbar->addFormButton($this->lng->txt('add'), 'addDefaults');
3245  require_once 'Services/Form/classes/class.ilTextInputGUI.php';
3246  $ilToolbar->addInputItem(new ilTextInputGUI($this->lng->txt('tst_defaults_defaults_of_test'), 'name'), true);
3247 
3248  require_once 'Modules/Test/classes/tables/class.ilTestPersonalDefaultSettingsTableGUI.php';
3249  $table = new ilTestPersonalDefaultSettingsTableGUI($this, 'defaults');
3250  $defaults = $this->object->getAvailableDefaults();
3251  $table->setData((array) $defaults);
3252  $tpl->setContent($table->getHTML());
3253  }
3254 
3258  public function deleteDefaultsObject()
3259  {
3260  if (isset($_POST['chb_defaults']) && is_array($_POST['chb_defaults']) && count($_POST['chb_defaults'])) {
3261  foreach ($_POST['chb_defaults'] as $test_default_id) {
3262  $this->object->deleteDefaults($test_default_id);
3263  }
3264  } else {
3265  ilUtil::sendInfo($this->lng->txt('select_one'));
3266  }
3267  $this->defaultsObject();
3268  }
3269 
3274  {
3275  $this->applyDefaultsObject(true);
3276  return;
3277  }
3278 
3282  public function applyDefaultsObject($confirmed = false)
3283  {
3284  if (!is_array($_POST["chb_defaults"]) || 1 !== count($_POST["chb_defaults"])) {
3286  $this->lng->txt("tst_defaults_apply_select_one")
3287  );
3288 
3289  return $this->defaultsObject();
3290  }
3291 
3292  // do not apply if user datasets exist
3293  if ($this->object->evalTotalPersons() > 0) {
3295  $this->lng->txt("tst_defaults_apply_not_possible")
3296  );
3297 
3298  return $this->defaultsObject();
3299  }
3300 
3301  $defaults =&$this->object->getTestDefaults($_POST["chb_defaults"][0]);
3302  $defaultSettings = unserialize($defaults["defaults"]);
3303 
3304  if (isset($defaultSettings['isRandomTest'])) {
3305  if ($defaultSettings['isRandomTest']) {
3306  $newQuestionSetType = ilObjTest::QUESTION_SET_TYPE_RANDOM;
3307  $this->object->setQuestionSetType(ilObjTest::QUESTION_SET_TYPE_RANDOM);
3308  } else {
3309  $newQuestionSetType = ilObjTest::QUESTION_SET_TYPE_FIXED;
3310  $this->object->setQuestionSetType(ilObjTest::QUESTION_SET_TYPE_FIXED);
3311  }
3312  } elseif (isset($defaultSettings['questionSetType'])) {
3313  $newQuestionSetType = $defaultSettings['questionSetType'];
3314  }
3315  $oldQuestionSetType = $this->object->getQuestionSetType();
3316  $questionSetTypeSettingSwitched = ($oldQuestionSetType != $newQuestionSetType);
3317 
3318  $oldQuestionSetConfig = $this->testQuestionSetConfigFactory->getQuestionSetConfigByType($oldQuestionSetType);
3319 
3320  switch (true) {
3321  case !$questionSetTypeSettingSwitched:
3322  case !$oldQuestionSetConfig->doesQuestionSetRelatedDataExist():
3323  case $confirmed:
3324 
3325  break;
3326 
3327  default:
3328 
3329  require_once 'Modules/Test/classes/confirmations/class.ilTestSettingsChangeConfirmationGUI.php';
3330  $confirmation = new ilTestSettingsChangeConfirmationGUI($this->lng, $this->object);
3331 
3332  $confirmation->setFormAction($this->ctrl->getFormAction($this));
3333  $confirmation->setCancel($this->lng->txt('cancel'), 'defaults');
3334  $confirmation->setConfirm($this->lng->txt('confirm'), 'confirmedApplyDefaults');
3335 
3336  $confirmation->setOldQuestionSetType($this->object->getQuestionSetType());
3337  $confirmation->setNewQuestionSetType($newQuestionSetType);
3338  $confirmation->setQuestionLossInfoEnabled(false);
3339  $confirmation->build();
3340 
3341  $confirmation->populateParametersFromPost();
3342 
3343  $this->tpl->setContent($this->ctrl->getHTML($confirmation));
3344 
3345  return;
3346  }
3347 
3348  if ($questionSetTypeSettingSwitched && $this->object->isOnline()) {
3349  $this->object->setOnline(false);
3350 
3351  $info = $this->lng->txt("tst_set_offline_due_to_switched_question_set_type_setting");
3352 
3353  ilUtil::sendInfo($info, true);
3354  }
3355 
3356  $this->object->applyDefaults($defaults);
3357 
3358  ilUtil::sendSuccess($this->lng->txt("tst_defaults_applied"), true);
3359 
3360  if ($questionSetTypeSettingSwitched && $oldQuestionSetConfig->doesQuestionSetRelatedDataExist()) {
3361  $oldQuestionSetConfig->removeQuestionSetRelatedData();
3362  }
3363 
3364  $this->ctrl->redirect($this, 'defaults');
3365  }
3366 
3370  public function addDefaultsObject()
3371  {
3372  if (strlen($_POST["name"]) > 0) {
3373  $this->object->addDefaults($_POST['name']);
3374  } else {
3375  ilUtil::sendInfo($this->lng->txt("tst_defaults_enter_name"));
3376  }
3377  $this->defaultsObject();
3378  }
3379 
3381  {
3382  if (in_array($this->ctrl->getCmdClass(), self::$infoScreenChildClasses)) {
3383  return true;
3384  }
3385 
3386  return false;
3387  }
3388 
3394  public function infoScreenObject()
3395  {
3396  #if( !include 'competenzenRocker.php' ) exit;
3397 
3398  $this->ctrl->setCmd("showSummary");
3399  $this->ctrl->setCmdClass("ilinfoscreengui");
3400  $this->infoScreen();
3401  }
3402 
3403  public function redirectToInfoScreenObject()
3404  {
3405  $this->ctrl->setCmd("showSummary");
3406  $this->ctrl->setCmdClass("ilinfoscreengui");
3407  $this->infoScreen($_GET['lock']);
3408  }
3409 
3413  public function infoScreen($session_lock = "")
3414  {
3420  global $ilAccess, $ilUser, $ilToolbar;
3421 
3422  if ($_GET['createRandomSolutions']) {
3423  global $ilCtrl;
3424 
3425  $this->object->createRandomSolutions($_GET['createRandomSolutions']);
3426 
3427  $ilCtrl->redirect($this);
3428  }
3429 
3430  if (!$ilAccess->checkAccess("read", "", $this->ref_id)) {
3431  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"), $this->ilias->error_obj->MESSAGE);
3432  }
3433 
3434  $this->trackTestObjectReadEvent();
3435 
3436  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
3437  $info = new ilInfoScreenGUI($this);
3438  $info->setOpenFormTag(false);
3439 
3440  if ($this->isCommandClassAnyInfoScreenChild()) {
3441  return $this->ctrl->forwardCommand($info);
3442  }
3443 
3444  require_once 'Modules/Test/classes/class.ilTestInfoScreenToolbarFactory.php';
3445  $toolbarFactory = new ilTestInfoScreenToolbarFactory();
3446  $toolbarFactory->setTestOBJ($this->object);
3447  $toolbar = $toolbarFactory->getToolbarInstance();
3448 
3449  $toolbar->setGlobalToolbar($GLOBALS['DIC']['ilToolbar']);
3450  $toolbar->setCloseFormTag(false);
3451 
3452  $toolbar->setSessionLockString($session_lock);
3453  $toolbar->build();
3454  $toolbar->sendMessages();
3455 
3456  if ($this->object->getShowInfo()) {
3457  $info->enablePrivateNotes();
3458  }
3459 
3460  if (strlen($this->object->getIntroduction())) {
3461  $info->addSection($this->lng->txt("tst_introduction"));
3462  $info->addProperty("", $this->object->prepareTextareaOutput($this->object->getIntroduction(), true) .
3463  $info->getHiddenToggleButton());
3464  } else {
3465  $info->addSection("");
3466  $info->addProperty("", $info->getHiddenToggleButton());
3467  }
3468 
3469  $info->addSection($this->lng->txt("tst_general_properties"));
3470  if ($this->object->getShowInfo()) {
3471  $info->addProperty($this->lng->txt("author"), $this->object->getAuthor());
3472  $info->addProperty($this->lng->txt("title"), $this->object->getTitle());
3473  }
3474  if ($this->object->isOnline() && $this->object->isComplete($this->testQuestionSetConfigFactory->getQuestionSetConfig())) {
3475  if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id)) {
3476  if ($this->object->getShowInfo() || !$this->object->getForceJS()) {
3477  // use javascript
3478  $checked_javascript = false;
3479  if ($this->object->getJavaScriptOutput()) {
3480  $checked_javascript = true;
3481  }
3482  }
3483  // hide previous results
3484  if (!$this->object->isRandomTest() && !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
3485  if ($this->object->getNrOfTries() != 1) {
3486  if ($this->object->getUsePreviousAnswers() == 0) {
3487  if ($this->object->getShowInfo()) {
3488  $info->addProperty($this->lng->txt("tst_use_previous_answers"), $this->lng->txt("tst_dont_use_previous_answers"));
3489  }
3490  } else {
3491  $use_previous_answers = false;
3492  if ($ilUser->prefs["tst_use_previous_answers"]) {
3493  $checked_previous_answers = true;
3494  }
3495  $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);
3496  }
3497  }
3498  }
3499  }
3500  }
3501 
3502  $info->hideFurtherSections(false);
3503 
3504  if ($this->object->getShowInfo()) {
3505  $info->addSection($this->lng->txt("tst_sequence_properties"));
3506  $info->addProperty($this->lng->txt("tst_sequence"), $this->lng->txt(($this->object->getSequenceSettings() == TEST_FIXED_SEQUENCE)? "tst_sequence_fixed":"tst_sequence_postpone"));
3507 
3508  $info->addSection($this->lng->txt("tst_heading_scoring"));
3509  $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"));
3510  $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"));
3511  if ($this->object->isRandomTest()) {
3512  $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"));
3513  }
3514 
3515  $info->addSection($this->lng->txt("tst_score_reporting"));
3516  $score_reporting_text = "";
3517  switch ($this->object->getScoreReporting()) {
3518  case REPORT_AFTER_TEST:
3519  $score_reporting_text = $this->lng->txt("tst_report_after_test");
3520  break;
3521  case REPORT_ALWAYS:
3522  $score_reporting_text = $this->lng->txt("tst_report_after_first_question");
3523  break;
3524  case REPORT_AFTER_DATE:
3525  $score_reporting_text = $this->lng->txt("tst_report_after_date");
3526  break;
3527  case 4:
3528  $score_reporting_text = $this->lng->txt("tst_report_never");
3529  break;
3530  }
3531  $info->addProperty($this->lng->txt("tst_score_reporting"), $score_reporting_text);
3532  $reporting_date = $this->object->getReportingDate();
3533  if ($reporting_date) {
3534  #preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $reporting_date, $matches);
3535  #$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]));
3536  #$info->addProperty($this->lng->txt("tst_score_reporting_date"), $txt_reporting_date);
3537  $info->addProperty(
3538  $this->lng->txt('tst_score_reporting_date'),
3540  );
3541  }
3542 
3543  $info->addSection($this->lng->txt("tst_session_settings"));
3544  $info->addProperty($this->lng->txt("tst_nr_of_tries"), ($this->object->getNrOfTries() == 0)?$this->lng->txt("unlimited"):$this->object->getNrOfTries());
3545  if ($this->object->getNrOfTries() != 1) {
3546  $info->addProperty($this->lng->txt("tst_nr_of_tries_of_user"), ($toolbar->getTestSession()->getPass() == false)?$this->lng->txt("tst_no_tries"):$toolbar->getTestSequence()->getPass());
3547  }
3548 
3549  if ($this->object->getEnableProcessingTime()) {
3550  $info->addProperty($this->lng->txt("tst_processing_time"), $this->object->getProcessingTime());
3551  }
3552  if (strlen($this->object->getAllowedUsers()) && ($this->object->getAllowedUsersTimeGap())) {
3553  $info->addProperty($this->lng->txt("tst_allowed_users"), $this->object->getAllowedUsers());
3554  }
3555 
3556  $starting_time = $this->object->getStartingTime();
3557  if ($this->object->isStartingTimeEnabled() && $starting_time != 0) {
3558  $info->addProperty($this->lng->txt("tst_starting_time"), ilDatePresentation::formatDate(new ilDateTime($starting_time, IL_CAL_UNIX)));
3559  }
3560  $ending_time = $this->object->getEndingTime();
3561  if ($this->object->isEndingTimeEnabled() && $ending_time != 0) {
3562  $info->addProperty($this->lng->txt("tst_ending_time"), ilDatePresentation::formatDate(new ilDateTime($ending_time, IL_CAL_UNIX)));
3563  }
3564  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
3565  // forward the command
3566  }
3567 
3568  $this->ctrl->forwardCommand($info);
3569  }
3570 
3571  protected function removeImportFailsObject()
3572  {
3573  require_once 'Modules/TestQuestionPool/classes/questions/class.ilAssQuestionSkillAssignmentImportFails.php';
3574  $qsaImportFails = new ilAssQuestionSkillAssignmentImportFails($this->object->getId());
3575  $qsaImportFails->deleteRegisteredImportFails();
3576 
3577  require_once 'Modules/Test/classes/class.ilTestSkillLevelThresholdImportFails.php';
3578  $sltImportFails = new ilTestSkillLevelThresholdImportFails($this->object->getId());
3579  $sltImportFails->deleteRegisteredImportFails();
3580 
3581  $this->ctrl->redirect($this, 'infoScreen');
3582  }
3583 
3584  public function addLocatorItems()
3585  {
3586  global $ilLocator;
3587  switch ($this->ctrl->getCmd()) {
3588  case "run":
3589  case "infoScreen":
3590  case "redirectToInfoScreen":
3591  case "start":
3592  case "resume":
3593  case "previous":
3594  case "next":
3595  case "summary":
3596  case "finishTest":
3597  case "outCorrectSolution":
3598  case "passDetails":
3599  case "showAnswersOfUser":
3600  case "outUserResultsOverview":
3601  case "backFromSummary":
3602  case "show_answers":
3603  case "setsolved":
3604  case "resetsolved":
3605  case "outTestSummary":
3606  case "outQuestionSummary":
3607  case "gotoQuestion":
3608  case "selectImagemapRegion":
3609  case "confirmSubmitAnswers":
3610  case "finalSubmission":
3611  case "postpone":
3612  case "outUserPassDetails":
3613  case "checkPassword":
3614  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"), "", $_GET["ref_id"]);
3615  break;
3616  case "eval_stat":
3617  case "evalAllUsers":
3618  case "evalUserDetail":
3619  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "eval_stat"), "", $_GET["ref_id"]);
3620  break;
3621  case "create":
3622  case "save":
3623  case "cancel":
3624  case "importFile":
3625  case "cloneAll":
3626  case "importVerifiedFile":
3627  case "cancelImport":
3628  break;
3629  default:
3630  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
3631  break;
3632  }
3633  }
3634 
3636  {
3637  global $ilAccess;
3638  if ($ilAccess->checkAccess("write", "", $this->ref_id)) {
3639  $this->ctrl->saveParameterByClass($this->ctrl->getCmdClass(), 'q_id');
3640  // edit page
3641  $tabs_gui->setBackTarget($this->lng->txt("backtocallingtest"), $this->ctrl->getLinkTargetByClass($this->ctrl->getCmdClass(), "questions"));
3642  $tabs_gui->addTarget(
3643  "tst_browse_for_questions",
3644  $this->ctrl->getLinkTarget($this, "browseForQuestions"),
3645  array("browseForQuestions", "filter", "resetFilter", "resetTextFilter", "insertQuestions"),
3646  "",
3647  "",
3648  true
3649  );
3650  }
3651  }
3652 
3654  {
3655  global $ilAccess;
3656  if ($ilAccess->checkAccess("write", "", $this->ref_id)) {
3657  // edit page
3658  $tabs_gui->setBackTarget($this->lng->txt("backtocallingtest"), $this->ctrl->getLinkTarget($this, "questions"));
3659  $tabs_gui->addTarget(
3660  "random_selection",
3661  $this->ctrl->getLinkTarget($this, "randomQuestions"),
3662  array("randomQuestions"),
3663  "",
3664  ""
3665  );
3666  }
3667  }
3668 
3669  public function statisticsObject()
3670  {
3671  }
3672 
3676  public function certificateObject()
3677  {
3678  include_once "./Services/Certificate/classes/class.ilCertificateGUI.php";
3679  include_once "./Modules/Test/classes/class.ilTestCertificateAdapter.php";
3680  $output_gui = new ilCertificateGUI(new ilTestCertificateAdapter($this->object));
3681  $output_gui->certificateEditor();
3682  }
3683 
3684  public function getQuestionsSubTabs()
3685  {
3686  global $ilTabs, $ilCtrl;
3687  $ilTabs->activateTab('assQuestions');
3688  $a_cmd = $ilCtrl->getCmd();
3689 
3690  if (!$this->object->isRandomTest()) {
3691  #if (in_array($this->object->getEnabledViewMode(), array('both', 'express'))) {
3692  $questions_per_page = ($a_cmd == 'questions_per_page' || ($a_cmd == 'removeQuestions' && $_REQUEST['test_express_mode'])) ? true : false;
3693 
3694  $this->tabs_gui->addSubTabTarget(
3695  "questions_per_page_view",
3696  $this->ctrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'showPage'),
3697  "",
3698  "",
3699  "",
3700  $questions_per_page
3701  );
3702  #}
3703  }
3704  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
3706 
3707  if (!in_array('questions', $template->getHiddenTabs())) {
3708  // questions subtab
3709  $ilTabs->addSubTabTarget(
3710  "edit_test_questions",
3711  $this->ctrl->getLinkTarget($this, 'questions'),
3712  array("questions", "browseForQuestions", "questionBrowser", "createQuestion",
3713  "randomselect", "filter", "resetFilter", "insertQuestions",
3714  "back", "createRandomSelection", "cancelRandomSelect",
3715  "insertRandomSelection", "removeQuestions", "moveQuestions",
3716  "insertQuestionsBefore", "insertQuestionsAfter", "confirmRemoveQuestions",
3717  "cancelRemoveQuestions", "executeCreateQuestion", "cancelCreateQuestion",
3718  "addQuestionpool", "saveRandomQuestions", "saveQuestionSelectionMode"),
3719  ""
3720  );
3721 
3722  if (in_array($a_cmd, array('questions', 'createQuestion')) || ($a_cmd == 'removeQuestions' && !$_REQUEST['test_express_mode'])) {
3723  $this->tabs_gui->activateSubTab('edit_test_questions');
3724  }
3725  }
3726  #}
3727 
3728  // print view subtab
3729  if (!$this->object->isRandomTest()) {
3730  $ilTabs->addSubTabTarget(
3731  "print_view",
3732  $this->ctrl->getLinkTarget($this, 'print'),
3733  "print",
3734  "",
3735  "",
3736  $this->ctrl->getCmd() == 'print'
3737  );
3738  $ilTabs->addSubTabTarget(
3739  'review_view',
3740  $this->ctrl->getLinkTarget($this, 'review'),
3741  'review',
3742  '',
3743  '',
3744  $this->ctrl->getCmd() == 'review'
3745  );
3746  }
3747  }
3748 
3749  public function getStatisticsSubTabs()
3750  {
3751  global $ilTabs;
3752 
3753  // user results subtab
3754  $ilTabs->addSubTabTarget(
3755  "eval_all_users",
3756  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "outEvaluation"),
3757  array("outEvaluation", "detailedEvaluation", "exportEvaluation", "evalUserDetail", "passDetails",
3758  "outStatisticsResultsOverview", "statisticsPassDetails"),
3759  ""
3760  );
3761 
3762  // aggregated results subtab
3763  $ilTabs->addSubTabTarget(
3764  "tst_results_aggregated",
3765  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "eval_a"),
3766  array("eval_a"),
3767  "",
3768  ""
3769  );
3770 
3771  // question export
3772  $ilTabs->addSubTabTarget(
3773  "tst_single_results",
3774  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "singleResults"),
3775  array("singleResults"),
3776  "",
3777  ""
3778  );
3779  }
3780 
3781  public function getSettingsSubTabs($hiddenTabs = array())
3782  {
3786  global $ilTabs, $ilias;
3787 
3788  // general subtab
3789  $ilTabs->addSubTabTarget(
3790  'general',
3791  $this->ctrl->getLinkTargetByClass('ilObjTestSettingsGeneralGUI'),
3792  '', // auto activation regardless from cmd
3793  array('ilobjtestsettingsgeneralgui') // auto activation for ilObjTestSettingsGeneralGUI
3794  );
3795 
3796  if (!in_array('mark_schema', $hiddenTabs)) {
3797  $ilTabs->addSubTabTarget(
3798  'mark_schema',
3799  $this->ctrl->getLinkTargetByClass('ilmarkschemagui', 'showMarkSchema'),
3800  '',
3801  array('ilmarkschemagui')
3802  );
3803  }
3804 
3805  // scoring subtab
3806  $ilTabs->addSubTabTarget(
3807  'scoring',
3808  $this->ctrl->getLinkTargetByClass('ilObjTestSettingsScoringResultsGUI'),
3809  '', // auto activation regardless from cmd
3810  array('ilobjtestsettingsscoringresultsgui') // auto activation for ilObjTestSettingsScoringResultsGUI
3811  );
3812 
3813  // certificate subtab
3814  include_once "Services/Certificate/classes/class.ilCertificate.php";
3815  if (!in_array('certificate', $hiddenTabs) && ilCertificate::isActive()) {
3816  $ilTabs->addSubTabTarget(
3817  "certificate",
3818  $this->ctrl->getLinkTarget($this, 'certificate'),
3819  array("certificate", "certificateEditor", "certificateRemoveBackground", "certificateSave",
3820  "certificatePreview", "certificateDelete", "certificateUpload", "certificateImport"),
3821  array("", "ilobjtestgui", "ilcertificategui")
3822  );
3823  }
3824 
3825  if (!in_array('defaults', $hiddenTabs)) {
3826  // defaults subtab
3827  $ilTabs->addSubTabTarget(
3828  "tst_default_settings",
3829  $this->ctrl->getLinkTarget($this, "defaults"),
3830  array("defaults", "deleteDefaults", "addDefaults", "applyDefaults"),
3831  array("", "ilobjtestgui", "ilcertificategui")
3832  );
3833  }
3834 
3835  $lti_settings = new ilLTIProviderObjectSettingGUI($this->object->getRefId());
3836  if ($lti_settings->hasSettingsAccess()) {
3837  $this->tabs_gui->addSubTabTarget(
3838  'lti_provider',
3839  $this->ctrl->getLinkTargetByClass(ilLTIProviderObjectSettingGUI::class),
3840  '',
3841  [ilLTIProviderObjectSettingGUI::class]
3842  );
3843  }
3844  }
3845 
3846  public function getParticipantsSubTabs()
3847  {
3848  global $ilTabs;
3849 
3850  // participants subtab
3851  $ilTabs->addSubTabTarget(
3852  "participants",
3853  $this->ctrl->getLinkTarget($this, 'participants'),
3854  array(
3855  "participants", "saveClientIP",
3856  "removeParticipant",
3857  "showParticipantAnswersForAuthor",
3858  "deleteAllUserResults",
3859  "cancelDeleteAllUserData", "deleteSingleUserResults",
3860  "outParticipantsResultsOverview", "outParticipantsPassDetails",
3861  "showPassOverview", "showUserAnswers", "participantsAction",
3862  "showDetailedResults",
3863  'npResetFilter', 'npSetFilter'
3864  ),
3865  ""
3866  );
3867 
3868  if (!$this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken()) {
3869  if ($this->object->getProcessingTimeInSeconds() > 0 && $this->object->getNrOfTries() == 1) {
3870  // extratime subtab
3871  $ilTabs->addSubTabTarget(
3872  "timing",
3873  $this->ctrl->getLinkTarget($this, 'timingOverview'),
3874  array("timing", "timingOverview"),
3875  "",
3876  ""
3877  );
3878  }
3879  }
3880  }
3881 
3887  public function getTabs()
3888  {
3889  global $ilAccess, $ilHelp;
3890 
3891  if (preg_match('/^ass(.*?)gui$/i', $this->ctrl->getNextClass($this))) {
3892  return;
3893  } elseif ($this->ctrl->getNextClass($this) == 'ilassquestionpagegui') {
3894  return;
3895  }
3896 
3897  $ilHelp->setScreenIdComponent("tst");
3898 
3899  $hidden_tabs = array();
3900 
3901  $template = $this->object->getTemplate();
3902  if ($template) {
3903  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
3905 
3906  $hidden_tabs = $template->getHiddenTabs();
3907  }
3908 
3909  // for local use in this fucking sledge hammer method
3910  $curUserHasWriteAccess = $ilAccess->checkAccess("write", "", $this->ref_id);
3911 
3912  switch ($this->ctrl->getCmdClass()) {
3913  // no tabs .. no subtabs .. during test pass
3914  case 'iltestoutputgui':
3915 
3916  // tab handling happens within GUIs
3917  case 'iltestevaluationgui':
3918  $nonSelfTabbingCommands = array(
3919  'outParticipantsResultsOverview', 'outEvaluation',
3920  'eval_a', 'singleResults', 'detailedEvaluation'
3921  );
3922  if (in_array($this->ctrl->getCmd(), $nonSelfTabbingCommands)) {
3923  break;
3924  }
3925  // no break
3926  case 'iltestevalobjectiveorientedgui':
3927  return;
3928 
3929  case 'ilmarkschemagui':
3930  case 'ilobjtestsettingsgeneralgui':
3931  case 'ilobjtestsettingsscoringresultsgui':
3932 
3933  if ($curUserHasWriteAccess) {
3934  $this->getSettingsSubTabs($hidden_tabs);
3935  }
3936 
3937  break;
3938  }
3939 
3940  if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
3941  require_once 'Services/Link/classes/class.ilLink.php';
3942  $courseLink = ilLink::_getLink($this->getObjectiveOrientedContainer()->getRefId());
3943  $this->tabs_gui->setBack2Target($this->lng->txt('back_to_objective_container'), $courseLink);
3944  }
3945 
3946  switch ($this->ctrl->getCmd()) {
3947  case "resume":
3948  case "previous":
3949  case "next":
3950  case "summary":
3951  case "directfeedback":
3952  case "finishTest":
3953  case "outCorrectSolution":
3954  case "passDetails":
3955  case "showAnswersOfUser":
3956  case "outUserResultsOverview":
3957  case "backFromSummary":
3958  case "show_answers":
3959  case "setsolved":
3960  case "resetsolved":
3961  case "confirmFinish":
3962  case "outTestSummary":
3963  case "outQuestionSummary":
3964  case "gotoQuestion":
3965  case "selectImagemapRegion":
3966  case "confirmSubmitAnswers":
3967  case "finalSubmission":
3968  case "postpone":
3969  case "outUserPassDetails":
3970  case "checkPassword":
3971  case "exportCertificate":
3972  case "finishListOfAnswers":
3973  case "backConfirmFinish":
3974  case "showFinalStatement":
3975  return;
3976  break;
3977  case "browseForQuestions":
3978  case "filter":
3979  case "resetFilter":
3980  case "resetTextFilter":
3981  case "insertQuestions":
3982  // #8497: resetfilter is also used in lp
3983  if ($this->ctrl->getNextClass($this) != "illearningprogressgui") {
3984  return $this->getBrowseForQuestionsTab($this->tabs_gui);
3985  }
3986  break;
3987  case "scoring":
3988  case "certificate":
3989  case "certificateservice":
3990  case "certificateImport":
3991  case "certificateUpload":
3992  case "certificateEditor":
3993  case "certificateDelete":
3994  case "certificateSave":
3995  case "defaults":
3996  case "deleteDefaults":
3997  case "addDefaults":
3998  case "applyDefaults":
3999  case "inviteParticipants":
4000  case "searchParticipants":
4001  if ($curUserHasWriteAccess && in_array($this->ctrl->getCmdClass(), array('ilobjtestgui', 'ilcertificategui'))) {
4002  $this->getSettingsSubTabs($hidden_tabs);
4003  }
4004  break;
4005  case "export":
4006  case "print":
4007  break;
4008  case "statistics":
4009  case "eval_a":
4010  case "detailedEvaluation":
4011  case "outEvaluation":
4012  case "singleResults":
4013  case "exportEvaluation":
4014  case "evalUserDetail":
4015  case "outStatisticsResultsOverview":
4016  case "statisticsPassDetails":
4017  $this->getStatisticsSubTabs();
4018  break;
4019  }
4020 
4021  if (strcmp(strtolower(get_class($this->object)), "ilobjtest") == 0) {
4022  // questions tab
4023  if ($ilAccess->checkAccess("write", "", $this->ref_id) && !in_array('assQuestions', $hidden_tabs)) {
4024  $force_active = ($_GET["up"] != "" || $_GET["down"] != "")
4025  ? true
4026  : false;
4027  if (!$force_active) {
4028  if ($_GET["browse"] == 1) {
4029  $force_active = true;
4030  }
4031  }
4032 
4033  switch ($this->object->getQuestionSetType()) {
4035  $target = $this->ctrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'showPage');
4036  break;
4037 
4039  $target = $this->ctrl->getLinkTargetByClass('ilTestRandomQuestionSetConfigGUI');
4040  break;
4041 
4043  $target = $this->ctrl->getLinkTargetByClass('ilObjTestDynamicQuestionSetConfigGUI');
4044  break;
4045  }
4046 
4047  $this->tabs_gui->addTarget(
4048  "assQuestions",
4049  //$this->ctrl->getLinkTarget($this,'questions'),
4050  $target,
4051  array("questions", "browseForQuestions", "questionBrowser", "createQuestion",
4052  "randomselect", "filter", "resetFilter", "insertQuestions",
4053  "back", "createRandomSelection", "cancelRandomSelect",
4054  "insertRandomSelection", "removeQuestions", "moveQuestions",
4055  "insertQuestionsBefore", "insertQuestionsAfter", "confirmRemoveQuestions",
4056  "cancelRemoveQuestions", "executeCreateQuestion", "cancelCreateQuestion",
4057  "addQuestionpool", "saveRandomQuestions", "saveQuestionSelectionMode", "print",
4058  "addsource", "removesource", "randomQuestions"),
4059  "",
4060  "",
4061  $force_active
4062  );
4063  }
4064 
4065  // info tab
4066  if ($ilAccess->checkAccess("read", "", $this->ref_id) && !in_array('info_short', $hidden_tabs)) {
4067  $this->tabs_gui->addTarget(
4068  "info_short",
4069  $this->ctrl->getLinkTarget($this, 'infoScreen'),
4070  array("infoScreen", "outIntroductionPage", "showSummary",
4071  "setAnonymousId", "outUserListOfAnswerPasses", "redirectToInfoScreen")
4072  );
4073  }
4074 
4075  // settings tab
4076  if ($ilAccess->checkAccess("write", "", $this->ref_id)) {
4077  if (!in_array('settings', $hidden_tabs)) {
4078  $settingsCommands = array(
4079  "marks", "showMarkSchema","addMarkStep", "deleteMarkSteps", "addSimpleMarkSchema", "saveMarks",
4080  "certificate", "certificateEditor", "certificateRemoveBackground", "certificateSave",
4081  "certificatePreview", "certificateDelete", "certificateUpload", "certificateImport",
4082  "scoring", "defaults", "addDefaults", "deleteDefaults", "applyDefaults",
4083  "inviteParticipants", "saveFixedParticipantsStatus", "searchParticipants", "addParticipants" // ARE THEY RIGHT HERE
4084  );
4085 
4086  require_once 'Modules/Test/classes/class.ilObjTestSettingsGeneralGUI.php';
4087  $reflection = new ReflectionClass('ilObjTestSettingsGeneralGUI');
4088  foreach ($reflection->getConstants() as $name => $value) {
4089  if (substr($name, 0, 4) == 'CMD_') {
4090  $settingsCommands[] = $value;
4091  }
4092  }
4093 
4094  require_once 'Modules/Test/classes/class.ilObjTestSettingsScoringResultsGUI.php';
4095  $reflection = new ReflectionClass('ilObjTestSettingsScoringResultsGUI');
4096  foreach ($reflection->getConstants() as $name => $value) {
4097  if (substr($name, 0, 4) == 'CMD_') {
4098  $settingsCommands[] = $value;
4099  }
4100  }
4101 
4102  $settingsCommands[] = ""; // DO NOT KNOW WHAT THIS IS DOING, BUT IT'S REQUIRED
4103 
4104  $this->tabs_gui->addTarget(
4105  "settings",
4106  $this->ctrl->getLinkTargetByClass('ilObjTestSettingsGeneralGUI'),
4107  $settingsCommands,
4108  array("ilmarkschemagui", "ilobjtestsettingsgeneralgui", "ilobjtestsettingsscoringresultsgui", "ilobjtestgui", "ilcertificategui")
4109  );
4110  }
4111 
4112  // skill service
4113  if ($this->object->isSkillServiceEnabled() && ilObjTest::isSkillManagementGloballyActivated()) {
4114  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionSkillAssignmentsGUI.php';
4115 
4116  $link = $this->ctrl->getLinkTargetByClass(
4117  array('ilTestSkillAdministrationGUI', 'ilAssQuestionSkillAssignmentsGUI'),
4119  );
4120 
4121  $this->tabs_gui->addTarget('tst_tab_competences', $link, array(), array());
4122  }
4123 
4124  if (!in_array('participants', $hidden_tabs)) {
4125  // participants
4126  $this->tabs_gui->addTarget(
4127  "participants",
4128  $this->ctrl->getLinkTarget($this, 'participants'),
4129  array(
4130  "participants", "saveClientIP",
4131  "removeParticipant",
4132  "showParticipantAnswersForAuthor",
4133  "deleteAllUserResults",
4134  "cancelDeleteAllUserData", "deleteSingleUserResults",
4135  "outParticipantsResultsOverview", "outParticipantsPassDetails",
4136  "showPassOverview", "showUserAnswers", "participantsAction",
4137  "showDetailedResults",
4138  'timing', 'timingOverview', 'npResetFilter', 'npSetFilter', 'showTimingForm'
4139  ),
4140  ""
4141  );
4142  }
4143  }
4144 
4145  include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
4146  if (ilLearningProgressAccess::checkAccess($this->object->getRefId()) && !in_array('learning_progress', $hidden_tabs)) {
4147  $this->tabs_gui->addTarget(
4148  'learning_progress',
4149  $this->ctrl->getLinkTargetByClass(array('illearningprogressgui'), ''),
4150  '',
4151  array('illplistofobjectsgui','illplistofsettingsgui','illearningprogressgui','illplistofprogressgui')
4152  );
4153  }
4154 
4155  if ($ilAccess->checkAccess("write", "", $this->ref_id) && !in_array('manscoring', $hidden_tabs)) {
4156  include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
4158  if (count($scoring)) {
4159  // scoring tab
4160  $this->tabs_gui->addTarget(
4161  "manscoring",
4162  $this->ctrl->getLinkTargetByClass('ilTestScoringByQuestionsGUI', 'showManScoringByQuestionParticipantsTable'),
4163  array(
4164  'showManScoringParticipantsTable', 'applyManScoringParticipantsFilter', 'resetManScoringParticipantsFilter', 'showManScoringParticipantScreen',
4165  'showManScoringByQuestionParticipantsTable', 'applyManScoringByQuestionFilter', 'resetManScoringByQuestionFilter', 'saveManScoringByQuestion'
4166 
4167  ),
4168  ''
4169  );
4170  }
4171  }
4172 
4173  // Scoring Adjustment
4174  $setting = new ilSetting('assessment');
4175  $scoring_adjust_active = (bool) $setting->get('assessment_adjustments_enabled', false);
4176  if ($ilAccess->checkAccess("write", "", $this->ref_id) && $scoring_adjust_active && !in_array('scoringadjust', $hidden_tabs)) {
4177  // scoring tab
4178  $this->tabs_gui->addTarget(
4179  "scoringadjust",
4180  $this->ctrl->getLinkTargetByClass('ilScoringAdjustmentGUI', 'showquestionlist'),
4181  array(
4182  'showquestionlist',
4183  'savescoringfortest',
4184  'adjustscoringfortest'
4185  ),
4186  ''
4187  );
4188  }
4189 
4190  if ((($ilAccess->checkAccess("tst_statistics", "", $this->ref_id)) || ($ilAccess->checkAccess("write", "", $this->ref_id))) && !in_array('statistics', $hidden_tabs)) {
4191  // statistics tab
4192  $this->tabs_gui->addTarget(
4193  "statistics",
4194  $this->ctrl->getLinkTargetByClass("iltestevaluationgui", "outEvaluation"),
4195  array(
4196  "statistics", "outEvaluation", "exportEvaluation", "detailedEvaluation", "eval_a", "evalUserDetail",
4197  "passDetails", "outStatisticsResultsOverview", "statisticsPassDetails", "singleResults"
4198  ),
4199  ""
4200  );
4201  }
4202 
4203  if ($ilAccess->checkAccess("write", "", $this->ref_id)) {
4204  if (!in_array('history', $hidden_tabs)) {
4205 
4206  // history
4207  $this->tabs_gui->addTarget(
4208  "history",
4209  $this->ctrl->getLinkTarget($this, 'history'),
4210  "history",
4211  ""
4212  );
4213  }
4214 
4215  if (!in_array('meta_data', $hidden_tabs)) {
4216  // meta data
4217  include_once "Services/Object/classes/class.ilObjectMetaDataGUI.php";
4218  $mdgui = new ilObjectMetaDataGUI($this->object);
4219  $mdtab = $mdgui->getTab();
4220  if ($mdtab) {
4221  $this->tabs_gui->addTarget(
4222  "meta_data",
4223  $mdtab,
4224  "",
4225  "ilmdeditorgui"
4226  );
4227  }
4228  }
4229 
4230  if (!in_array('export', $hidden_tabs)) {
4231  // export tab
4232  $this->tabs_gui->addTarget(
4233  "export",
4234  $this->ctrl->getLinkTargetByClass('iltestexportgui', ''),
4235  '',
4236  array('iltestexportgui')
4237  );
4238  }
4239  }
4240 
4241  if ($ilAccess->checkAccess("edit_permission", "", $this->ref_id)&& !in_array('permissions', $hidden_tabs)) {
4242  $this->tabs_gui->addTarget(
4243  "perm_settings",
4244  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
4245  array("perm","info","owner"),
4246  'ilpermissiongui'
4247  );
4248  }
4249  }
4250 
4251  if ($this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken()) {
4252  $hideTabs = $this->testQuestionSetConfigFactory->getQuestionSetConfig()->getHiddenTabsOnBrokenDepencies();
4253 
4254  foreach ($hideTabs as $tabId) {
4255  $this->tabs_gui->removeTab($tabId);
4256  }
4257  }
4258  }
4259 
4260  public static function accessViolationRedirect()
4261  {
4262  global $DIC; /* @var ILIAS\DI\Container $DIC */
4263 
4264  ilUtil::sendInfo($DIC->language()->txt("no_permission"), true);
4265  $DIC->ctrl()->redirectByClass('ilObjTestGUI', "infoScreen");
4266  }
4267 
4276  public static function _goto($a_target)
4277  {
4278  global $ilAccess, $ilErr, $lng;
4279 
4280  if ($ilAccess->checkAccess("read", "", $a_target)) {
4281  //include_once "./Services/Utilities/classes/class.ilUtil.php";
4282  $_GET["baseClass"] = "ilObjTestGUI";
4283  $_GET["cmd"] = "infoScreen";
4284  $_GET["ref_id"] = $a_target;
4285  include_once("ilias.php");
4286  exit;
4287  //ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=infoScreen&ref_id=$a_target");
4288  } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
4289  ilUtil::sendInfo(sprintf(
4290  $lng->txt("msg_no_perm_read_item"),
4292  ), true);
4294  }
4295 
4296  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
4297  }
4298 
4305  public function buildPageViewToolbar($qid = 0)
4306  {
4307  if ($this->create_question_mode) {
4308  return;
4309  }
4310 
4311  global $ilToolbar, $ilCtrl, $lng;
4312 
4313  require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
4314 
4315  $this->getQuestionsSubTabs();
4316 
4317  $ilCtrl->saveParameter($this, 'q_mode');
4318 
4319  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'test_express_mode', 1);
4320  $ilCtrl->setParameter($this, 'test_express_mode', 1);
4321  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'q_id', $_REQUEST['q_id']);
4322  $ilCtrl->setParameter($this, 'q_id', $_REQUEST['q_id']);
4323  $ilToolbar->setFormAction($ilCtrl->getFormActionByClass('iltestexpresspageobjectgui', 'edit'));
4324 
4325  if ($this->object->evalTotalPersons() == 0) {
4326  /*
4327  include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
4328  $pool = new ilObjQuestionPool();
4329  $questionTypes = $pool->getQuestionTypes();$options = array();
4330  foreach($questionTypes as $label => $data) {
4331  $options[$data['question_type_id']] = $label;
4332  }
4333 
4334  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
4335  $si = new ilSelectInputGUI($lng->txt("test_add_new_question"), "qtype");
4336  $si->setOptions($options);
4337  $ilToolbar->addInputItem($si, true);
4338  /*
4339  // use pool
4340  if ($this->object->isExpressModeQuestionPoolAllowed()) {
4341  include_once("./Services/Form/classes/class.ilCheckboxInputGUI.php");
4342  $cb = new ilCheckboxInputGUI($lng->txt("test_use_pool"), "use_pool");
4343  $ilToolbar->addInputItem($cb, true);
4344  }
4345  */
4346  $ilToolbar->addFormButton($lng->txt("ass_create_question"), "addQuestion");
4347 
4348  $ilToolbar->addSeparator();
4349 
4350  if ($this->object->getPoolUsage()) {
4351  require_once 'Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php';
4352 
4354 
4355  $show_separator = true;
4356  }
4357  }
4358 
4359  $questions = $this->object->getQuestionTitlesAndIndexes();
4360 
4361  // desc
4362  $options = array();
4363  foreach ($questions as $id => $label) {
4364  $options[$id] = $label . ' [' . $this->lng->txt('question_id_short') . ': ' . $id . ']';
4365  }
4366 
4367  $optionKeys = array_keys($options);
4368 
4369  if (!$options) {
4370  $options[] = $lng->txt('none');
4371  }
4372  //else if (count($options) > 1) {
4373 // $addSeparator = false;
4374 // if ($optionKeys[0] != $qid) {
4375 // //$ilToolbar->addFormButton($lng->txt("test_prev_question"), "prevQuestion");
4376 // $ilToolbar->addLink($lng->txt("test_prev_question"), $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'prevQuestion'));
4377 // $addSeparator = true;
4378 // }
4379  // else {
4380  // $ilToolbar->addSpacer(45);
4381  // }
4382 //
4383 // if ($optionKeys[count($optionKeys)-1] != $qid) {
4384 // //$ilToolbar->addFormButton($lng->txt("test_next_question"), "nextQuestion");
4385 // $ilToolbar->addLink($lng->txt("test_next_question"), $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'nextQuestion'));
4386  // $addSeparator = true;
4387 // }
4388  // else {
4389  // $ilToolbar->addSpacer(45);
4390  // }
4391 //
4392 // //if ($addSeparator) {
4393 // $ilToolbar->addSeparator();
4394 // //}
4395 
4396  if (count($questions)) {
4397  if (isset($show_separator) && $show_separator) {
4398  $ilToolbar->addSeparator();
4399  }
4400 
4401  $btn = ilLinkButton::getInstance();
4402  $btn->setCaption("test_prev_question");
4403  $btn->setUrl($ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'prevQuestion'));
4404  $ilToolbar->addButtonInstance($btn);
4405 
4406  if (count($options) <= 1 || $optionKeys[0] == $qid) {
4407  $btn->setDisabled(true);
4408  }
4409 
4410  $btn = ilLinkButton::getInstance();
4411  $btn->setCaption("test_next_question");
4412  $btn->setUrl($ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'nextQuestion'));
4413  $ilToolbar->addButtonInstance($btn);
4414 
4415  if (count($options) <= 1 || $optionKeys[count($optionKeys) - 1] == $qid) {
4416  $btn->setDisabled(true);
4417  }
4418  }
4419 
4420  if (count($questions) > 1) {
4421  $ilToolbar->addSeparator();
4422 
4423  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
4424  $si = new ilSelectInputGUI($lng->txt("test_jump_to"), "q_id");
4425  $si->addCustomAttribute("onChange=\"forms['ilToolbar'].submit();\"");
4426  $si->setOptions($options);
4427 
4428  if ($qid) {
4429  $si->setValue($qid);
4430  }
4431 
4432  $ilToolbar->addInputItem($si, true);
4433  }
4434 
4435  $total = $this->object->evalTotalPersons();
4436 
4437  /*if (count($options)) {
4438  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
4439  $si = new ilSelectInputGUI($lng->txt("test_jump_to"), "q_id");
4440  $si->addCustomAttribute("onChange=\"forms['ilToolbar'].submit();\"");
4441  $si->setOptions($options);
4442 
4443  if ($qid) {
4444  $si->setValue($qid);
4445  }
4446 
4447  $ilToolbar->addInputItem($si, true);
4448  }*/
4449 
4450  if (count($questions) && !$total) {
4451  $ilCtrl->setParameter($this, 'q_id', $_REQUEST['q_id']);
4452  $ilToolbar->addSeparator();
4453  $ilToolbar->addButton($lng->txt("test_delete_page"), $ilCtrl->getLinkTarget($this, "removeQuestions"));
4454  }
4455 
4456  if (count($questions) > 1 && !$total) {
4457  $ilToolbar->addSeparator();
4458  $ilToolbar->addButton($lng->txt("test_move_page"), $ilCtrl->getLinkTarget($this, "movePageForm"));
4459  }
4460 
4461  global $ilAccess, $ilUser;
4462 
4463  $online_access = false;
4464  if ($this->object->getFixedParticipants()) {
4465  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
4466  $online_access_result = ilObjTestAccess::_lookupOnlineTestAccess($this->object->getId(), $ilUser->getId());
4467  if ($online_access_result === true) {
4468  $online_access = true;
4469  }
4470  }
4471 
4472  if ($this->object->isOnline() && $this->object->isComplete($this->testQuestionSetConfigFactory->getQuestionSetConfig())) {
4473  if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id)) {
4474  $testSession = $this->testSessionFactory->getSession();
4475 
4476  $executable = $this->object->isExecutable($testSession, $ilUser->getId(), $allowPassIncrease = true);
4477 
4478  if ($executable["executable"]) {
4479  $player_factory = new ilTestPlayerFactory($this->object);
4480  $player_instance = $player_factory->getPlayerGUI();
4481 
4482  if ($testSession->getActiveId() > 0) {
4483  $ilToolbar->addSeparator();
4484  $ilToolbar->addButton($lng->txt('tst_resume_test'), $ilCtrl->getLinkTarget($player_instance, 'resumePlayer'));
4485  } else {
4486  $ilToolbar->addSeparator();
4487  $ilToolbar->addButton($lng->txt('tst_start_test'), $ilCtrl->getLinkTarget($player_instance, 'startTest'));
4488  }
4489  }
4490  }
4491  }
4492  }
4493 
4494  public function copyQuestionsToPoolObject()
4495  {
4496  $this->copyQuestionsToPool($_REQUEST['q_id'], $_REQUEST['sel_qpl']);
4497  $this->ctrl->redirect($this, 'questions');
4498  }
4499 
4500  public function copyQuestionsToPool($questionIds, $qplId)
4501  {
4502  $newIds = array();
4503  foreach ($questionIds as $q_id) {
4504  $newId = $this->copyQuestionToPool($q_id, $qplId);
4505  $newIds[$q_id] = $newId;
4506  }
4507 
4508  $result = new stdClass();
4509  $result->ids = $newIds;
4510  $result->qpoolid = $qplId;
4511 
4512  return $result;
4513  }
4514 
4515  public function copyQuestionToPool($sourceQuestionId, $targetParentId)
4516  {
4517  require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
4518  $question_gui = assQuestion::instantiateQuestionGUI($sourceQuestionId);
4519 
4520  $newtitle = $question_gui->object->getTitle();
4521  if ($question_gui->object->questionTitleExists($targetParentId, $question_gui->object->getTitle())) {
4522  $counter = 2;
4523  while ($question_gui->object->questionTitleExists($targetParentId, $question_gui->object->getTitle() . " ($counter)")) {
4524  $counter++;
4525  }
4526  $newtitle = $question_gui->object->getTitle() . " ($counter)";
4527  }
4528 
4529  return $question_gui->object->createNewOriginalFromThisDuplicate($targetParentId, $newtitle);
4530  }
4531 
4536  {
4537  global $ilObjDataCache;
4538 
4539  $qplId = $ilObjDataCache->lookupObjId($_REQUEST['sel_qpl']);
4540  $result = $this->copyQuestionsToPool($_REQUEST['q_id'], $qplId);
4541 
4542  foreach ($result->ids as $oldId => $newId) {
4543  $questionInstance = assQuestion::_instanciateQuestion($oldId);
4544 
4545  if (assQuestion::originalQuestionExists($questionInstance->getOriginalId())) {
4546  $oldOriginal = assQuestion::_instanciateQuestion($questionInstance->getOriginalId());
4547  $oldOriginal->delete($oldOriginal->getId());
4548  }
4549 
4550  $questionInstance->setNewOriginalId($newId);
4551  }
4552 
4553  ilUtil::sendSuccess($this->lng->txt('tst_qst_added_to_pool_' . (count($result->ids) > 1 ? 'p' : 's')), true);
4554  $this->ctrl->redirect($this, 'questions');
4555  }
4556 
4557  private function getQuestionpoolCreationForm()
4558  {
4559  global $lng;
4560  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
4561  $form = new ilPropertyFormGUI();
4562 
4563  $title = new ilTextInputGUI($lng->txt('title'), 'title');
4564  $title->setRequired(true);
4565  $form->addItem($title);
4566 
4567  $description = new ilTextAreaInputGUI($lng->txt('description'), 'description');
4568  $form->addItem($description);
4569 
4570  $form->addCommandButton('createQuestionPoolAndCopy', $lng->txt('create'));
4571 
4572  if (isset($_REQUEST['q_id']) && is_array($_REQUEST['q_id'])) {
4573  foreach ($_REQUEST['q_id'] as $id) {
4574  $hidden = new ilHiddenInputGUI('q_id[]');
4575  $hidden->setValue($id);
4576  $form->addItem($hidden);
4577  }
4578  }
4579 
4580  return $form;
4581  }
4582 
4583  public function copyToQuestionpoolObject()
4584  {
4585  $this->createQuestionpoolTargetObject('copyQuestionsToPool');
4586  }
4587 
4589  {
4590  global $lng;
4591 
4592  require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
4593 
4594  // #13761; All methods use for this request should be revised, thx japo ;-)
4595  if (
4596  'copyAndLinkToQuestionpool' == $this->ctrl->getCmd() &&
4597  (!isset($_REQUEST['q_id']) || !is_array($_REQUEST['q_id']))
4598  ) {
4599  ilUtil::sendFailure($this->lng->txt('tst_no_question_selected_for_moving_to_qpl'), true);
4600  $this->ctrl->redirect($this, 'questions');
4601  }
4602 
4603  if (isset($_REQUEST['q_id']) && is_array($_REQUEST['q_id'])) {
4604  foreach ($_REQUEST['q_id'] as $q_id) {
4606  continue;
4607  }
4608 
4610 
4611  if ($type !== 'tst') {
4612  ilUtil::sendFailure($lng->txt('tst_link_only_unassigned'), true);
4613  $this->ctrl->redirect($this, 'questions');
4614  return;
4615  }
4616  }
4617  }
4618 
4619  $this->createQuestionpoolTargetObject('copyAndLinkQuestionsToPool');
4620  }
4621 
4623  {
4625 
4626  if ($_REQUEST['title']) {
4627  $title = $_REQUEST['title'];
4628  } else {
4629  $title = $_REQUEST['txt_qpl'];
4630  }
4631 
4632  if (!$title) {
4633  ilUtil::sendInfo($this->lng->txt("questionpool_not_entered"));
4634  return $this->copyAndLinkToQuestionpoolObject();
4635  }
4636 
4637  $ref_id = $this->createQuestionPool($title, $_REQUEST['description']);
4638  $_REQUEST['sel_qpl'] = $ref_id;
4639 
4640  //if ($_REQUEST['link'])
4641  //{
4643  //}
4644  //else
4645  //{
4646  // $this->copyQuestionsToPoolObject();
4647  //}
4648  }
4649 
4656  public function createQuestionpoolTargetObject($cmd)
4657  {
4658  global $ilUser, $ilTabs;
4659  $this->getQuestionsSubTabs();
4660  $ilTabs->activateSubTab('edit_test_questions');
4661 
4662  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_qpl_select_copy.html", "Modules/Test");
4663  $questionpools =&$this->object->getAvailableQuestionpools(false, false, false, true, false, "write");
4664  if (count($questionpools) == 0) {
4665  $this->tpl->setCurrentBlock("option");
4666  $this->tpl->setVariable("VALUE_QPL", "");
4667  $this->tpl->parseCurrentBlock();
4668  } else {
4669  foreach ($questionpools as $key => $value) {
4670  $this->tpl->setCurrentBlock("option");
4671  $this->tpl->setVariable("VALUE_OPTION", $key);
4672  $this->tpl->setVariable("TEXT_OPTION", $value["title"]);
4673  $this->tpl->parseCurrentBlock();
4674  }
4675  }
4676 
4677  if (isset($_REQUEST['q_id']) && is_array($_REQUEST['q_id'])) {
4678  foreach ($_REQUEST['q_id'] as $id) {
4679  $this->tpl->setCurrentBlock("hidden");
4680  $this->tpl->setVariable("HIDDEN_NAME", "q_id[]");
4681  $this->tpl->setVariable("HIDDEN_VALUE", $id);
4682  $this->tpl->parseCurrentBlock();
4683  $this->tpl->setCurrentBlock("adm_content");
4684  }
4685  }
4686  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
4687 
4688  if (count($questionpools) == 0) {
4689  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_enter_questionpool"));
4690  $cmd = 'createQuestionPoolAndCopy';
4691  } else {
4692  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_select_questionpool"));
4693  }
4694 
4695  $this->tpl->setVariable("CMD_SUBMIT", $cmd);
4696  $this->tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit"));
4697  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
4698 
4699  $createForm = $this->getQuestionpoolCreationForm();
4700  switch ($cmd) {
4701  case 'copyAndLinkQuestionsToPool':
4702  $hidden = new ilHiddenInputGUI('link');
4703  $hidden->setValue(1);
4704  $createForm->addItem($hidden);
4705  break;
4706  case 'copyQuestionsToPool':
4707  break;
4708  }
4709  $createForm->setFormAction($this->ctrl->getFormAction($this));
4710 
4711  $this->tpl->parseCurrentBlock();
4712  }
4713 
4714  // begin-patch lok
4715  public function applyTemplate($templateData, $object)
4716  // end-patch lok
4717  {
4718  // map formFieldName => setterName
4719  $simpleSetters = array(
4720 
4721  // general properties
4722  'use_pool' => 'setPoolUsage',
4723  'question_set_type' => 'setQuestionSetType',
4724 
4725  // test intro properties
4726  'intro_enabled' => 'setIntroductionEnabled',
4727  'showinfo' => 'setShowInfo',
4728 
4729  // test access properties
4730  'chb_starting_time' => 'setStartingTimeEnabled',
4731  'chb_ending_time' => 'setEndingTimeEnabled',
4732  'password_enabled' => 'setPasswordEnabled',
4733  'fixedparticipants' => 'setFixedParticipants',
4734  'limitUsers' => 'setLimitUsersEnabled',
4735 
4736  // test run properties
4737  'nr_of_tries' => 'setNrOfTries',
4738  'chb_processing_time' => 'setEnableProcessingTime',
4739  'kiosk' => 'setKiosk',
4740  'examid_in_test_pass' => 'setShowExamIdInTestPassEnabled',
4741 
4742  // question behavior properties
4743  'title_output' => 'setTitleOutput',
4744  'autosave' => null, // handled specially in loop below
4745  'chb_shuffle_questions' => 'setShuffleQuestions',
4746  'offer_hints' => 'setOfferingQuestionHintsEnabled',
4747  'instant_feedback' => 'setScoringFeedbackOptionsByArray',
4748  'obligations_enabled' => 'setObligationsEnabled',
4749 
4750  // test sequence properties
4751  'chb_use_previous_answers' => 'setUsePreviousAnswers',
4752  'chb_show_cancel' => 'setShowCancel',
4753  'chb_postpone' => 'setPostponingEnabled',
4754  'list_of_questions' => 'setListOfQuestionsSettings',
4755  'chb_show_marker' => 'setShowMarker',
4756 
4757  // test finish properties
4758  'enable_examview' => 'setEnableExamview',
4759  'showfinalstatement' => 'setShowFinalStatement',
4760  'redirection_enabled' => null, // handled specially in loop below
4761  'sign_submission' => 'setSignSubmission',
4762  'mailnotification' => 'setMailNotification',
4763 
4764  // scoring options properties
4765  'count_system' => 'setCountSystem',
4766  'mc_scoring' => 'setMCScoring',
4767  'score_cutting' => 'setScoreCutting',
4768  'pass_scoring' => 'setPassScoring',
4769  'pass_deletion_allowed' => 'setPassDeletionAllowed',
4770 
4771  // result summary properties
4772  'results_access_enabled' => 'setScoreReporting',
4773  'grading_status' => 'setShowGradingStatusEnabled',
4774  'grading_mark' => 'setShowGradingMarkEnabled',
4775 
4776  // result details properties
4777  'solution_details' => 'setShowSolutionDetails',
4778  'solution_feedback' => 'setShowSolutionFeedback',
4779  'solution_suggested' => 'setShowSolutionSuggested',
4780  'solution_printview' => 'setShowSolutionPrintview',
4781  'highscore_enabled' => 'setHighscoreEnabled',
4782  'solution_signature' => 'setShowSolutionSignature',
4783  'examid_in_test_res' => 'setShowExamIdInTestResultsEnabled',
4784  'exp_sc_short' => 'setExportSettingsSingleChoiceShort',
4785 
4786  // misc scoring & result properties
4787  'anonymity' => 'setAnonymity',
4788  'enable_archiving' => 'setEnableArchiving'
4789  );
4790 
4791  if (!$templateData['results_presentation']['value']) {
4792  $templateData['results_presentation']['value'] = array();
4793  }
4794 
4795  foreach ($simpleSetters as $field => $setter) {
4796  if ($templateData[$field] && strlen($setter)) {
4797  $object->$setter($templateData[$field]['value']);
4798  continue;
4799  }
4800 
4801  switch ($field) {
4802  case 'autosave':
4803  if ($templateData[$field]['value'] > 0) {
4804  $object->setAutosave(true);
4805  $object->setAutosaveIval($templateData[$field]['value'] * 1000);
4806  } else {
4807  $object->setAutosave(false);
4808  }
4809  break;
4810 
4811  case 'redirection_enabled':
4812  /* if( $templateData[$field]['value'] > REDIRECT_NONE )
4813  {
4814  $object->setRedirectionMode($templateData[$field]['value']);
4815  }
4816  else
4817  {
4818  $object->setRedirectionMode(REDIRECT_NONE);
4819  } */
4820  if (strlen($templateData[$field]['value'])) {
4821  $object->setRedirectionMode(REDIRECT_ALWAYS);
4822  $object->setRedirectionUrl($templateData[$field]['value']);
4823  } else {
4824  $object->setRedirectionMode(REDIRECT_NONE);
4825  $object->setRedirectionUrl('');
4826  }
4827  }
4828  }
4829  }
4830 
4832  {
4833  global $ilAccess;
4834  if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
4835  // allow only write access
4836  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
4837  $this->ctrl->redirect($this, "infoScreen");
4838  }
4839 
4840  global $ilCtrl;
4841 
4842  $orders = $obligations = array();
4843 
4844  foreach ((array) $_REQUEST['order'] as $qId => $order) {
4845  $id = (int) str_replace('q_', '', $qId);
4846 
4847  $orders[$id] = $order;
4848  }
4849 
4850  if ($this->object->areObligationsEnabled() && isset($_REQUEST['obligatory']) && is_array($_REQUEST['obligatory'])) {
4851  foreach ($_REQUEST['obligatory'] as $qId => $obligation) {
4852  $id = (int) str_replace('q_', '', $qId);
4853 
4855  $obligations[$id] = $obligation;
4856  }
4857  }
4858  }
4859 
4860  $this->object->setQuestionOrderAndObligations(
4861  $orders,
4862  $obligations
4863  );
4864 
4865  ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
4866  $ilCtrl->redirect($this, 'questions');
4867  }
4868 
4872  protected function movePageFormObject()
4873  {
4874  global $lng, $ilCtrl, $tpl;
4875 
4876  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
4877  $form = new ilPropertyFormGUI();
4878  $form->setFormAction($ilCtrl->getFormAction($this, "movePage"));
4879  $form->setTitle($lng->txt("test_move_page"));
4880 
4881  $old_pos = new ilHiddenInputGUI("q_id");
4882  $old_pos->setValue($_REQUEST['q_id']);
4883  $form->addItem($old_pos);
4884 
4885  $questions = $this->object->getQuestionTitlesAndIndexes();
4886  if (!is_array($questions)) {
4887  $questions = array();
4888  }
4889 
4890  foreach ($questions as $k => $q) {
4891  if ($k == $_REQUEST['q_id']) {
4892  unset($questions[$k]);
4893  continue;
4894  }
4895  $questions[$k] = $lng->txt('behind') . ' ' . $q;
4896  }
4897  #$questions['0'] = $lng->txt('first');
4898 
4899  $options = array(
4900  0 => $lng->txt('first')
4901  );
4902  foreach ($questions as $k => $q) {
4903  $options[$k] = $q . ' [' . $this->lng->txt('question_id_short') . ': ' . $k . ']';
4904  }
4905 
4906  $pos = new ilSelectInputGUI($lng->txt("position"), "position_after");
4907  $pos->setOptions($options);
4908  $form->addItem($pos);
4909 
4910  $form->addCommandButton("movePage", $lng->txt("submit"));
4911  $form->addCommandButton("showPage", $lng->txt("cancel"));
4912 
4913  return $tpl->setContent($form->getHTML());
4914  }
4915 
4916  public function movePageObject()
4917  {
4918  global $ilAccess;
4919  if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
4920  // allow only write access
4921  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
4922  $this->ctrl->redirect($this, "infoScreen");
4923  }
4924 
4925  $this->object->moveQuestionAfter($_REQUEST['q_id'], $_REQUEST['position_after']);
4926  $this->showPageObject();
4927  }
4928 
4929  public function showPageObject()
4930  {
4931  global $ilCtrl;
4932 
4933  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'q_id', $_REQUEST['q_id']);
4934  $ilCtrl->redirectByClass('iltestexpresspageobjectgui', 'showPage');
4935  }
4936 
4937  public function copyQuestionObject()
4938  {
4939  global $ilAccess;
4940  if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
4941  // allow only write access
4942  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
4943  $this->ctrl->redirect($this, "infoScreen");
4944  }
4945 
4946  if ($_REQUEST['q_id'] && !is_array($_REQUEST['q_id'])) {
4947  $ids = array($_REQUEST['q_id']);
4948  } elseif ($_REQUEST['q_id']) {
4949  $ids = $_REQUEST['q_id'];
4950  } else {
4951  ilUtil::sendFailure($this->lng->txt('copy_no_questions_selected'), true);
4952  $this->ctrl->redirect($this, 'questions');
4953  }
4954 
4955  $copy_count = 0;
4956 
4957  $questionTitles = $this->object->getQuestionTitles();
4958 
4959  foreach ($ids as $id) {
4960  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
4961  $question = assQuestion::_instanciateQuestionGUI($id);
4962  if ($question) {
4963  $title = $question->object->getTitle();
4964  $i = 2;
4965  while (in_array($title . ' (' . $i . ')', $questionTitles)) {
4966  $i++;
4967  }
4968 
4969  $title .= ' (' . $i . ')';
4970 
4971  $questionTitles[] = $title;
4972 
4973  $new_id = $question->object->duplicate(false, $title);
4974 
4975  $clone = assQuestion::_instanciateQuestionGUI($new_id);
4976  $clone->object->setObjId($this->object->getId());
4977  $clone->object->saveToDb();
4978 
4979  $this->object->insertQuestion($this->testQuestionSetConfigFactory->getQuestionSetConfig(), $new_id, true);
4980 
4981  $copy_count++;
4982  }
4983  }
4984 
4985  ilUtil::sendSuccess($this->lng->txt('copy_questions_success'), true);
4986 
4987  $this->ctrl->redirect($this, 'questions');
4988  }
4989 
4993  private function isPdfDeliveryRequest()
4994  {
4995  if (!isset($_GET['pdf'])) {
4996  return false;
4997  }
4998 
4999  if (!(bool) $_GET['pdf']) {
5000  return false;
5001  }
5002 
5003  return true;
5004  }
5005 
5007  {
5008  require_once 'Modules/Course/classes/Objectives/class.ilLOSettings.php';
5009  $containerObjId = (int) ilLOSettings::isObjectiveTest($this->ref_id);
5010 
5011  $containerRefId = current(ilObject::_getAllReferences($containerObjId));
5012 
5013  $this->objectiveOrientedContainer->setObjId($containerObjId);
5014  $this->objectiveOrientedContainer->setRefId($containerRefId);
5015  }
5016 
5017  protected function getObjectiveOrientedContainer()
5018  {
5020  }
5021 }
const MATCHING_QUESTION_IDENTIFIER
const MULTIPLE_CHOICE_QUESTION_IDENTIFIER
const QT_MATCHING
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
showUserResults($show_pass_details, $show_answers, $show_reached_points=false)
Shows the pass overview of the scored pass for one ore more users.
static _lookupName($a_user_id)
lookup user name
static _recordReadEvent( $a_type, $a_ref_id, $obj_id, $usr_id, $isCatchupWriteEvents=true, $a_ext_rc=false, $a_ext_time=false)
Records a read event and catches up with write events.
Scoring class for tests.
const QT_FORMULA
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
applyTemplate($templateData, $object)
const PDF_PRINT_VIEW_QUESTIONS
This class represents an option in a radio group.
const REPORT_AFTER_TEST
static _getAvailableQuestionpools($use_object_id=false, $equal_points=false, $could_be_offline=false, $showPath=false, $with_questioncount=false, $permission="read", $usr_id="")
Returns the available question pools for the active user.
Class ilObjectMetaDataGUI.
const REPORT_AFTER_DATE
static getAllSettingsTemplates($a_type, $a_include_auto_generated=false)
Get all settings templates of type.
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
static _getOriginalId($question_id)
Returns the original id of a question.
Content Object Parser.
const QT_FILEUPLOAD
Class ilInfoScreenGUI.
static getQuestionTypeFromDb($question_id)
get question type for question id
const ERROR_TEXT_IDENTIFIER
static _getParticipantData($active_id)
Retrieves a participant name from active id.
createQuestionObject()
Called when a new question should be created from a test.
const IL_CAL_DATETIME
getTabs()
adds tabs to tab gui object
Export User Interface Class.
Class ilObjTestGUI.
$_SESSION["AccountId"]
This class represents a selection list property in a property form.
$result
const QT_TEXT
reviewobject()
Review tab to create a print of all questions without points and solutions.
$template
This class represents a property form user interface.
fullscreenObject()
show fullscreen view
GUI class for the workflow of copying objects.
static originalQuestionExists($questionId)
$type
const QUESTION_SET_TYPE_RANDOM
type setting value for random question set
copyQuestionToPool($sourceQuestionId, $targetParentId)
global $DIC
Definition: saml.php:7
uploadObject($redirect=true)
display status information or report errors messages in case of error
const ADDITIONAL_CONTENT_EDITING_MODE_PAGE_OBJECT
constant for additional content editing mode "pageobject"
Generic feedback page GUI class.
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
$_GET["client_id"]
static _needsManualScoring($question_id)
cancelCreateQuestionObject()
Called when the creation of a new question is cancelled.
This class represents a file property in a property form.
buildPageViewToolbar($qid=0)
Questions per page.
showDetailedResultsObject()
Shows the pass overview and the answers of one ore more users for the scored pass.
static getQuestionTypeByTypeId($type_id)
applyFilterCriteria($in_rows)
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false)
Format a date public.
const PDF_USER_RESULT
PDF Purposes.
static & _instanciateQuestionGUI($question_id)
Creates an instance of a question gui with a given question id.
$dataset
Definition: showstats.php:45
insertQuestionsBeforeObject()
Insert checked questions before the actual selection.
addDidacticTemplateOptions(array &$a_options)
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
const QT_ORDERING_HORIZONTAL
const KPRIM_CHOICE_QUESTION_IDENTIFIER
if(!array_key_exists('StateId', $_REQUEST)) $id
static _getQuestionTypeName($type_tag)
Return the translation for a given question type tag.
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
static unzip($a_file, $overwrite=false, $a_flat=false)
unzip file
const LONG_MENU_QUESTION_IDENTIFIER
static isObjectiveTest($a_trst_ref_id)
Check if test ref_id is used in an objective course.
Class ilUnitConfigurationRepository.
const TEXTSUBSET_QUESTION_IDENTIFIER
deleteSingleUserResultsObject()
Asks for a confirmation to delete selected user data of the test object.
static _goto($a_target)
Redirect script to call a test with the test reference id.
Question page object.
Import class.
static setUseRelativeDates($a_status)
set use relative dates
static _lookupTitle($a_id)
lookup object title
const REDIRECT_NONE
Redirect after finishing test constants.
const QT_KPRIM_CHOICE
historyObject()
Creates the change history for a test.
downloadFileObject()
download file
createQuestionpoolTargetObject($cmd)
Called when a new question should be created from a test Important: $cmd may be overwritten if no que...
createObject()
create new object form
static _isActive()
Static getter.
insertRandomSelectionObject()
Inserts a random selection into the test.
const QT_IMAGEMAP
redirectTo_ilObjTestSettingsGeneralGUI_showForm_Object()
Scoring class for tests.
confirmRemoveQuestionsObject()
Remove questions from the test after confirmation.
const IL_CAL_UNIX
$keys
static lookupParentObjId($questionId)
ilDBInterface $ilDB
static accessViolationRedirect()
cancelDeleteSelectedUserDataObject()
Cancels the deletion of all user data for the test object.
Question page GUI class.
static $infoScreenChildClasses
$total
Definition: Utf8Test.php:87
static _getAllReferences($a_id)
get all reference ids of object
addDefaultsObject()
Adds the defaults of this test to the defaults.
deleteAllUserDataObject()
Asks for a confirmation to delete all user data of the test object.
Base Exception for all Exceptions relating to Modules/Test.
createUserResults($show_pass_details, $show_answers, $show_reached_points, $show_user_results)
participantsActionObject()
Evaluates the actions on the participants page.
afterSave(ilObject $a_new_object)
save object public
static useRelativeDates()
check if relative dates are used
const FILE_UPLOAD_IDENTIFIER
const QT_MULTIPLE_CHOICE_SR
const JAVAAPPLET_QUESTION_IDENTIFIER
global $ilCtrl
Definition: ilias.php:18
confirmDeleteSelectedUserDataObject()
Deletes the selected user data for the test object.
cancelRemoveQuestionsObject()
Cancels the removal of questions from the test.
setInfo($a_info)
Set Information Text.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$counter
const REDIRECT_ALWAYS
deleteAllUserResultsObject()
Asks for a confirmation to delete all user data of the test object.
static checkAccess($a_ref_id, $a_allow_only_read=true)
check access to learning progress
prepareSubGuiOutput()
prepares ilias to get output rendered by sub gui class
setCustomRolesForSelection($a_roles)
Set custom roles for mapping to LTI roles.
copyAndLinkQuestionsToPoolObject()
ilObjectDataCache $ilObjDataCache
This class represents a hidden form property in a property form.
static _lookupOnlineTestAccess($a_test_id, $a_user_id)
Checks if a user is allowd to run an online exam.
prepareOutput($a_show_subobjects=true)
prepare output
showUserAnswersObject()
Shows the answers of one ore more users for the scored pass.
if($format !==null) $name
Definition: metadata.php:146
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
catch(Exception $e) $message
This class represents a property in a property form.
addOption($a_option)
Add Option.
const QT_LONG_MENU
getBrowseForQuestionsTab(&$tabs_gui)
const NUMERIC_QUESTION_IDENTIFIER
foreach($_POST as $key=> $value) $res
if(isset($_POST['submit'])) $form
GUI class for LTI provider object settings.
const IL_MO_PARSE_QTI
removeQuestionsObject()
Called when a selection of questions should be removed from the test.
const ORDERING_HORIZONTAL_IDENTIFIER
const SCORE_ZERO_POINTS_WHEN_UNANSWERED
initImportForm($a_new_type)
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
This class represents a number property in a property form.
Class ilTimingOverviewTableGUI.
confirmDeleteAllUserResultsObject()
Deletes all user data for the test object.
const COUNT_PARTIAL_SOLUTIONS
applyDefaultsObject($confirmed=false)
Applies the selected test defaults.
static _getQuestionGUI($question_type, $question_id=-1)
Creates a question gui representation and returns the alias to the question gui note: please do not u...
download_paragraphObject()
download source code paragraph
Class ilObjectGUI Basic methods of all Output classes.
static _lookupObjId($a_id)
const ORDERING_QUESTION_IDENTIFIER
date( 'd-M-Y', $objPHPExcel->getProperties() ->getCreated())
insertQuestionsAfterObject()
Insert checked questions after the actual selection.
special template class to simplify handling of ITX/PEAR
createQuestionPool($name="dummy", $description="")
Creates a new questionpool and returns the reference id.
This class represents a text property in a property form.
Output class for assessment test evaluation.
GUI class to create PDF certificates.
static infoPanel($a_keep=true)
Date and time handling
$ilUser
Definition: imgupload.php:18
redirection script todo: (a better solution should control the processing via a xml file) ...
static isSkillManagementGloballyActivated()
setTitleAndDescription()
called by prepare output
static getSyntaxStylePath()
get syntax style path
infoScreenObject()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually...
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
static getContentStylePath($a_style_id, $add_random=true)
get content style path
setOptions($a_options)
Set Options.
const TEXT_QUESTION_IDENTIFIER
Basic GUI class for assessment questions.
$txt
Definition: error.php:11
static isQuestionObligationPossible($questionId)
checks wether the obligation for question with given id is possible or not
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
filterObject()
Sets the filter for the question browser.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
participantsObject()
Creates the output of the test participants.
const QT_JAVAAPPLET
const FLASHAPPLET_QUESTION_IDENTIFIER
writeFilterToSession()
Write filter values to session.
static _createImportDirectory()
creates data directory for import files (data_dir/tst_data/tst_<id>/import, depending on data directo...
$rows
Definition: xhr_table.php:10
const TEST_FIXED_SEQUENCE
Test constants.
const ADDITIONAL_CONTENT_EDITING_MODE_DEFAULT
constant for additional content editing mode "default"
executeCommand()
execute command
exportObject()
Gateway for exports initiated from workspace, as there is a generic forward to {objTypeMainGUI}export...
static prepareGeneration()
Prepare the PDF generation This initializes the purpose for MathJax rendering It has to be called bef...
const QT_NUMERIC
Specific feedback page GUI class.
randomselectObject()
Creates a form for random selection of questions.
importVerifiedFileObject()
imports question(s) into the questionpool (after verification)
const QT_TEXTSUBSET
createRandomSelectionObject()
Offers a random selection for insertion in the test.
certificateObject()
Shows the certificate editor.
const QT_FLASHAPPLET
Create new PHPExcel object
obj_idprivate
static _getManualScoring()
Retrieve the manual scoring settings.
static _getLog($ts_from, $ts_to, $test_id, $test_only=false)
Retrieve assessment log datasets from the database.
cancelRandomSelectObject()
Cancels the form for random selection of questions.
$results
Definition: svg-scanner.php:47
addButton( $a_txt, $a_cmd, $a_target="", $a_acc_key="", $a_additional_attrs='', $a_id="", $a_class='submit')
Add button to toolbar.
This class represents a text area property in a property form.
importFileObject($parent_id=null, $a_catch_errors=true)
form for new test object import
executeCreateQuestionObject()
Called when a new question should be created from a test after confirmation.
global $ilDB
$ret
Definition: parser.php:6
static isAdditionalQuestionContentEditingModePageObjectEnabled()
returns the fact wether content editing with ilias page editor is enabled for questions or not ...
const QUESTION_SET_TYPE_FIXED
type setting value for fixed question set
getCreationMode()
get creation mode
movePageFormObject()
Move current page.
$i
Definition: disco.tpl.php:19
getRefId()
get reference id public
Class ilLocalUnitConfigurationGUI.
getDidacticTemplateVar($a_type)
Get didactic template setting from creation screen.
moveQuestionsObject()
Marks selected questions for moving.
populateQuestionBrowserToolbarButtons(ilToolbarGUI $toolbar, $context)
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
const REPORT_ALWAYS
addFinishAllPassesButton($unfinished_passes, $ilToolbar)
static setTokenMaxLifetimeInSeconds($token_max_lifetime_in_seconds)
Service GUI class for tests.
insertQuestionsObject()
Insert questions from the questionbrowser into the test.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
static fillAutoCompleteToolbar($parent_object, ilToolbarGUI $toolbar=null, $a_options=array(), $a_sticky=false)
fill toolbar with
printobject()
Print tab to create a print of all questions with points and solutions.
static generatePDF($pdf_output, $output_mode, $filename=null, $purpose=null)
if(empty($password)) $table
Definition: pwgen.php:24
const IL_CAL_TIMESTAMP
const QT_CLOZE
const QT_MULTIPLE_CHOICE_MR
const IL_MO_VERIFY_QTI
Class ilScoringAdjustmentGUI.
uploadTstObject()
imports test and question(s)
deleteDefaultsObject()
Deletes selected test defaults.
$info
Definition: index.php:5
backObject()
Called when the back button in the question browser was pressed.
static redirect($a_script)
const QUESTION_SET_TYPE_DYNAMIC
type setting value for dynamic question set (continues testing mode)
const SINGLE_CHOICE_QUESTION_IDENTIFIER
const QT_ORDERING
addHeaderAction()
Add header action menu.
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
copyQuestionsToPool($questionIds, $qplId)
$key
Definition: croninfo.php:18
getRandomQuestionsTab(&$tabs_gui)
setSuffixes($a_suffixes)
Set Accepted Suffixes.
ilTestExpressPageObjectGUI: assMultipleChoiceGUI, assClozeTestGUI, assMatchingQuestionGUI ilTestExpr...
Class ilObjUserTrackingGUI.
getReturnLocation($a_cmd, $a_location="")
get return location for command (command is method name without "Object", e.g.
$template_id
$_POST["username"]
resetFilter()
Reset filter.
Settings template application class.
const CLOZE_TEST_IDENTIFIER
Question identifier constants.
static instantiateQuestionGUI($a_question_id)
Creates an instance of a question gui with a given question id.
const SCORE_BEST_PASS
setRequired($a_required)
Set Required.
static _setImportDirectory($a_import_dir=null)
set import directory
showPassOverviewObject()
Shows the pass overview of the scored pass for one ore more users.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
static _getTestDefaults($test_defaults_id)
__construct()
Constructor public.
setLocator()
set Locator
static _getImportDirectory()
Get the import directory location of the test.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options
Definition: as_login.php:20
resetFilterObject()
Resets the filter for the question browser.
Confirmation screen class.
const IMAGEMAP_QUESTION_IDENTIFIER
const QT_ERRORTEXT
const FORMULA_QUESTION_IDENTIFIER
addParticipantsObject($a_user_ids=array())
setFilterCommand($a_val, $a_caption=null)
Set filter command.
removeQuestionsForm($checked_questions)
Displays a form to confirm the removal of questions from the test.