ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 require_once 'Modules/OrgUnit/classes/Positions/Operation/class.ilOrgUnitOperation.php';
11 require_once 'Modules/Test/classes/class.ilTestParticipantAccessFilter.php';
12 
53 {
54  private static $infoScreenChildClasses = array(
55  'ilpublicuserprofilegui', 'ilobjportfoliogui'
56  );
57 
59  public $object = null;
60 
63 
65  private $testPlayerFactory = null;
66 
68  private $testSessionFactory = null;
69 
71  private $testSequenceFactory = null;
72 
76  protected $tabsManager;
77 
82 
86  protected $testAccess;
87 
93  public function __construct($refId = null)
94  {
95  global $DIC;
96  $lng = $DIC['lng'];
97  $ilCtrl = $DIC['ilCtrl'];
98  $ilDB = $DIC['ilDB'];
99  $ilPluginAdmin = $DIC['ilPluginAdmin'];
100  $tree = $DIC['tree'];
101  $lng->loadLanguageModule("assessment");
102  $this->type = "tst";
103  $this->ctrl = $ilCtrl;
104  $this->ctrl->saveParameter($this, array("ref_id", "test_ref_id", "calling_test", "test_express_mode", "q_id"));
105  if (isset($_GET['ref_id']) && is_numeric($_GET['ref_id'])) {
106  $refId = (int) $_GET['ref_id'];
107  }
108  parent::__construct("", (int) $refId, true, false);
109 
110  if ($this->object instanceof ilObjTest) {
111  require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
112  $this->testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($tree, $ilDB, $ilPluginAdmin, $this->object);
113 
114  require_once 'Modules/Test/classes/class.ilTestPlayerFactory.php';
115  $this->testPlayerFactory = new ilTestPlayerFactory($this->object);
116 
117  require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
118  $this->testSessionFactory = new ilTestSessionFactory($this->object);
119 
120  require_once 'Modules/Test/classes/class.ilTestSequenceFactory.php';
121  $this->testSequenceFactory = new ilTestSequenceFactory($ilDB, $lng, $ilPluginAdmin, $this->object);
122 
123  require_once 'Modules/Test/classes/class.ilTestAccess.php';
124  $this->setTestAccess(new ilTestAccess($this->ref_id, $this->object->getTestId()));
125  }
126 
127  require_once 'Modules/Test/classes/class.ilTestObjectiveOrientedContainer.php';
128  $this->objectiveOrientedContainer = new ilTestObjectiveOrientedContainer();
129 
130  if ($this->object instanceof ilObjTest) {
131  require_once 'Modules/Test/classes/class.ilTestTabsManager.php';
132  $tabsManager = new ilTestTabsManager($this->testAccess, $this->objectiveOrientedContainer);
133  $tabsManager->setTestOBJ($this->object);
134  $tabsManager->setTestSession($this->testSessionFactory->getSession());
135  $tabsManager->setTestQuestionSetConfig($this->testQuestionSetConfigFactory->getQuestionSetConfig());
136  $tabsManager->initSettingsTemplate();
138  }
139  }
140 
144  public function executeCommand()
145  {
146  global $DIC; /* @var ILIAS\DI\Container $DIC */
147  $ilAccess = $DIC['ilAccess'];
148  $ilNavigationHistory = $DIC['ilNavigationHistory'];
149  $ilCtrl = $DIC['ilCtrl'];
150  $ilErr = $DIC['ilErr'];
151  $tpl = $DIC['tpl'];
152  $lng = $DIC['lng'];
153  $ilTabs = $DIC['ilTabs'];
154  $ilPluginAdmin = $DIC['ilPluginAdmin'];
155  $ilDB = $DIC['ilDB'];
156  $tree = $DIC['tree'];
157  $ilias = $DIC['ilias'];
158  $ilUser = $DIC['ilUser'];
159 
160  if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
161  $ilias->raiseError($this->lng->txt("permission_denied"), $ilias->error_obj->MESSAGE);
162  }
163 
164  $cmd = $this->ctrl->getCmd("infoScreen");
165 
166  $cmdsDisabledDueToOfflineStatus = array(
167  'resumePlayer', 'resumePlayer', 'outUserResultsOverview', 'outUserListOfAnswerPasses'
168  );
169 
170  if (!$this->getCreationMode() && $this->object->getOfflineStatus() && in_array($cmd, $cmdsDisabledDueToOfflineStatus)) {
171  $cmd = 'infoScreen';
172  }
173 
174  $next_class = $this->ctrl->getNextClass($this);
175  $this->ctrl->setReturn($this, "infoScreen");
176 
177  if (method_exists($this->object, "getTestStyleLocation")) {
178  $this->tpl->addCss($this->object->getTestStyleLocation("output"), "screen");
179  }
180 
181  // add entry to navigation history
182  if (!$this->getCreationMode() &&
183  $ilAccess->checkAccess("read", "", $_GET["ref_id"])
184  ) {
185  $ilNavigationHistory->addItem(
186  $_GET["ref_id"],
187  "ilias.php?baseClass=ilObjTestGUI&cmd=infoScreen&ref_id=" . $_GET["ref_id"],
188  "tst"
189  );
190  }
191 
192  // elba hack for storing question id for inserting new question after
193  if ($_REQUEST['prev_qid']) {
194  global $___prev_question_id;
195  $___prev_question_id = $_REQUEST['prev_qid'];
196  $this->ctrl->setParameter($this, 'prev_qid', $_REQUEST['prev_qid']);
197  }
198 
199  if (!$this->getCreationMode() && $this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken()) {
200  if (!$this->testQuestionSetConfigFactory->getQuestionSetConfig()->isValidRequestOnBrokenQuestionSetDepencies($next_class, $cmd)) {
201  $this->ctrl->redirectByClass('ilObjTestGUI', 'infoScreen');
202  }
203  }
204 
206 
207  switch ($next_class) {
208  case 'illtiproviderobjectsettinggui':
209  $this->prepareOutput();
210  $this->addHeaderAction();
211  $this->tabsManager->getSettingsSubTabs();
212  $GLOBALS['DIC']->tabs()->activateTab('settings');
213  $GLOBALS['DIC']->tabs()->activateSubTab('lti_provider');
214  $lti_gui = new ilLTIProviderObjectSettingGUI($this->object->getRefId());
215  $lti_gui->setCustomRolesForSelection($GLOBALS['DIC']->rbac()->review()->getLocalRoles($this->object->getRefId()));
216  $lti_gui->offerLTIRolesForSelection(false);
217  $this->ctrl->forwardCommand($lti_gui);
218  break;
219 
220 
221  case 'iltestexportgui':
222  if (!$ilAccess->checkAccess('write', '', $this->ref_id)) {
223  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
224  }
225 
226  $this->prepareOutput();
227  $this->addHeaderAction();
228  $DIC->tabs()->activateTab(ilTestTabsManager::TAB_ID_EXPORT);
229  require_once 'Modules/Test/classes/class.ilTestExportGUI.php';
230  $ilCtrl->forwardCommand(new ilTestExportGUI($this));
231  break;
232 
233  case "ilinfoscreengui":
234  $this->prepareOutput();
235  $this->addHeaderAction();
236  $this->infoScreen(); // forwards command
237  break;
238  case 'ilobjectmetadatagui':
239  if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
240  $ilErr->raiseError($this->lng->txt('permission_denied'), $ilErr->WARNING);
241  }
242 
243  $this->prepareOutput();
244  $this->addHeaderAction();
245  $DIC->tabs()->activateTab(ilTestTabsManager::TAB_ID_META_DATA);
246  include_once 'Services/Object/classes/class.ilObjectMetaDataGUI.php';
247  $md_gui = new ilObjectMetaDataGUI($this->object);
248  $this->ctrl->forwardCommand($md_gui);
249  break;
250 
251  case 'iltestdashboardgui':
252 
253  $this->prepareOutput();
254  $this->addHeaderAction();
255 
256  require_once 'Modules/Test/classes/class.ilTestDashboardGUI.php';
257 
258  $gui = new ilTestDashboardGUI(
259  $this->object,
260  $this->testQuestionSetConfigFactory->getQuestionSetConfig()
261  );
262 
263  $gui->setTestAccess($this->getTestAccess());
264  $gui->setTestTabs($this->getTabsManager());
265  $gui->setObjectiveParent($this->getObjectiveOrientedContainer());
266 
267  $this->ctrl->forwardCommand($gui);
268  break;
269 
270  case 'iltestresultsgui':
271 
272  $this->prepareOutput();
273  $this->addHeaderAction();
274 
275  require_once 'Modules/Test/classes/class.ilTestResultsGUI.php';
276 
277  $gui = new ilTestResultsGUI(
278  $this->object,
279  $this->testQuestionSetConfigFactory->getQuestionSetConfig()
280  );
281 
282  $gui->setTestAccess($this->getTestAccess());
283  $gui->setTestSession($this->testSessionFactory->getSession());
284  $gui->setTestTabs($this->getTabsManager());
285  $gui->setObjectiveParent($this->getObjectiveOrientedContainer());
286 
287  $this->ctrl->forwardCommand($gui);
288  break;
289 
290  case "iltestplayerfixedquestionsetgui":
291  $this->trackTestObjectReadEvent();
292  require_once "./Modules/Test/classes/class.ilTestPlayerFixedQuestionSetGUI.php";
293  if (!$this->object->getKioskMode()) {
294  $this->prepareOutput();
295  }
296  $gui = new ilTestPlayerFixedQuestionSetGUI($this->object);
297  $gui->setObjectiveOrientedContainer($this->getObjectiveOrientedContainer());
298  $this->ctrl->forwardCommand($gui);
299  break;
300 
301  case "iltestplayerrandomquestionsetgui":
302  $this->trackTestObjectReadEvent();
303  require_once "./Modules/Test/classes/class.ilTestPlayerRandomQuestionSetGUI.php";
304  if (!$this->object->getKioskMode()) {
305  $this->prepareOutput();
306  }
307  $gui = new ilTestPlayerRandomQuestionSetGUI($this->object);
308  $gui->setObjectiveOrientedContainer($this->getObjectiveOrientedContainer());
309  $this->ctrl->forwardCommand($gui);
310  break;
311 
312  case "iltestplayerdynamicquestionsetgui":
313  $this->trackTestObjectReadEvent();
314  require_once "./Modules/Test/classes/class.ilTestPlayerDynamicQuestionSetGUI.php";
315  if (!$this->object->getKioskMode()) {
316  $this->prepareOutput();
317  }
318  $gui = new ilTestPlayerDynamicQuestionSetGUI($this->object);
319  $gui->setObjectiveOrientedContainer($this->getObjectiveOrientedContainer());
320  $this->ctrl->forwardCommand($gui);
321  break;
322 
323  case "iltestevaluationgui":
324  $this->forwardToEvaluationGUI();
325  break;
326 
327  case "iltestevalobjectiveorientedgui":
328  $this->forwardToEvalObjectiveOrientedGUI();
329  break;
330 
331  case "iltestservicegui":
332  $this->prepareOutput();
333  $this->addHeaderAction();
334  require_once "./Modules/Test/classes/class.ilTestServiceGUI.php";
335  $serviceGUI = new ilTestServiceGUI($this->object);
336  $this->ctrl->forwardCommand($serviceGUI);
337  break;
338 
339  case 'ilpermissiongui':
340  $this->prepareOutput();
341  $this->addHeaderAction();
342  $DIC->tabs()->activateTab(ilTestTabsManager::TAB_ID_PERMISSIONS);
343  include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
344  $perm_gui = new ilPermissionGUI($this);
345  $ret = $this->ctrl->forwardCommand($perm_gui);
346  break;
347 
348  case "illearningprogressgui":
349  $this->prepareOutput();
350  $this->addHeaderAction();
351  $DIC->tabs()->activateTab(ilTestTabsManager::TAB_ID_LEARNING_PROGRESS);
352  require_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
353  $new_gui = new ilLearningProgressGUI(ilLearningProgressGUI::LP_CONTEXT_REPOSITORY, $this->object->getRefId());
354  $this->ctrl->forwardCommand($new_gui);
355 
356  break;
357 
358  case "ilcertificategui":
359  $this->prepareOutput();
360  $this->addHeaderAction();
361 
362  $DIC->tabs()->activateTab(ilTestTabsManager::TAB_ID_SETTINGS);
363 
364  $guiFactory = new ilCertificateGUIFactory();
365  $output_gui = $guiFactory->create($this->object);
366 
367  $this->ctrl->forwardCommand($output_gui);
368  break;
369 
370  case "iltestscoringgui":
371  $this->prepareOutput();
372  $this->addHeaderAction();
373  require_once "./Modules/Test/classes/class.ilTestScoringGUI.php";
374  $output_gui = new ilTestScoringGUI($this->object);
375  $output_gui->setTestAccess($this->getTestAccess());
376  $this->ctrl->forwardCommand($output_gui);
377  break;
378 
379  case 'ilmarkschemagui':
380  if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
381  ilUtil::sendInfo($this->lng->txt('cannot_edit_test'), true);
382  $this->ctrl->redirect($this, 'infoScreen');
383  }
384  $this->prepareOutput();
385  $this->addHeaderAction();
386  require_once 'Modules/Test/classes/class.ilMarkSchemaGUI.php';
387  $mark_schema_gui = new ilMarkSchemaGUI($this->object);
388  $this->ctrl->forwardCommand($mark_schema_gui);
389  break;
390 
391  case 'iltestscoringbyquestionsgui':
392  $this->prepareOutput();
393  $this->addHeaderAction();
394  include_once 'Modules/Test/classes/class.ilTestScoringByQuestionsGUI.php';
395  $output_gui = new ilTestScoringByQuestionsGUI($this->object);
396  $output_gui->setTestAccess($this->getTestAccess());
397  $this->ctrl->forwardCommand($output_gui);
398  break;
399 
400  case 'ilobjtestsettingsgeneralgui':
401  $this->prepareOutput();
402  $this->addHeaderAction();
403  require_once 'Modules/Test/classes/class.ilObjTestSettingsGeneralGUI.php';
404  $gui = new ilObjTestSettingsGeneralGUI(
405  $this->ctrl,
406  $ilAccess,
407  $this->lng,
408  $this->tpl,
409  $this->tree,
410  $ilDB,
411  $ilPluginAdmin,
412  $ilUser,
413  $this
414  );
415  $this->ctrl->forwardCommand($gui);
416  break;
417 
418  case 'ilobjtestsettingsscoringresultsgui':
419  $this->prepareOutput();
420  $this->addHeaderAction();
421  require_once 'Modules/Test/classes/class.ilObjTestSettingsScoringResultsGUI.php';
423  $this->ctrl,
424  $ilAccess,
425  $this->lng,
426  $this->tpl,
427  $this->tree,
428  $ilDB,
429  $ilPluginAdmin,
430  $this
431  );
432  $this->ctrl->forwardCommand($gui);
433  break;
434 
435  case 'ilobjtestfixedquestionsetconfiggui':
436  $this->prepareOutput();
437  $this->addHeaderAction();
438  require_once 'Modules/Test/classes/class.ilTestFixedQuestionSetConfigGUI.php';
439  $gui = new ilObjTestDynamicQuestionSetConfigGUI($this->ctrl, $ilAccess, $ilTabs, $this->lng, $this->tpl, $ilDB, $tree, $ilPluginAdmin, $this->object);
440  $this->ctrl->forwardCommand($gui);
441  break;
442 
443  case 'iltestrandomquestionsetconfiggui':
444  $this->prepareOutput();
445  $this->addHeaderAction();
446  require_once 'Modules/Test/classes/class.ilTestRandomQuestionSetConfigGUI.php';
447  $gui = new ilTestRandomQuestionSetConfigGUI($this->ctrl, $ilAccess, $ilTabs, $this->lng, $this->tpl, $ilDB, $tree, $ilPluginAdmin, $this->object);
448  $this->ctrl->forwardCommand($gui);
449  break;
450 
451  case 'ilobjtestdynamicquestionsetconfiggui':
452  $this->prepareOutput();
453  $this->addHeaderAction();
454  require_once 'Modules/Test/classes/class.ilObjTestDynamicQuestionSetConfigGUI.php';
455  $gui = new ilObjTestDynamicQuestionSetConfigGUI($this->ctrl, $ilAccess, $ilTabs, $this->lng, $this->tpl, $ilDB, $tree, $ilPluginAdmin, $this->object);
456  $this->ctrl->forwardCommand($gui);
457  break;
458 
459  case 'iltestquestionbrowsertablegui':
460  $this->prepareOutput();
461  $this->addHeaderAction();
462  require_once 'Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php';
463  $gui = new ilTestQuestionBrowserTableGUI($this->ctrl, $this->tpl, $ilTabs, $this->lng, $tree, $ilDB, $ilPluginAdmin, $this->object, $ilAccess);
464  $gui->setWriteAccess($ilAccess->checkAccess("write", "", $this->ref_id));
465  $gui->init();
466  $this->ctrl->forwardCommand($gui);
467  break;
468 
469  case 'iltestskilladministrationgui':
470  $this->prepareOutput();
471  $this->addHeaderAction();
472  require_once 'Modules/Test/classes/class.ilTestSkillAdministrationGUI.php';
473  $gui = new ilTestSkillAdministrationGUI($ilias, $this->ctrl, $ilAccess, $ilTabs, $this->tpl, $this->lng, $ilDB, $tree, $ilPluginAdmin, $this->object, $this->ref_id);
474  $this->ctrl->forwardCommand($gui);
475  break;
476 
477  case 'ilobjectcopygui':
478  $this->prepareOutput();
479  $this->addHeaderAction();
480  require_once './Services/Object/classes/class.ilObjectCopyGUI.php';
481  $cp = new ilObjectCopyGUI($this);
482  $cp->setType('tst');
483  $this->ctrl->forwardCommand($cp);
484  break;
485 
486  case 'ilpageeditorgui':
487  case 'iltestexpresspageobjectgui':
488 
489  $this->getTabsManager()->getQuestionsSubTabs();
491 
492  require_once 'Modules/TestQuestionPool/classes/class.ilAssIncompleteQuestionPurger.php';
493  $incompleteQuestionPurger = new ilAssIncompleteQuestionPurger($ilDB);
494  $incompleteQuestionPurger->setOwnerId($ilUser->getId());
495  $incompleteQuestionPurger->purge();
496 
497  try {
498  $qid = $this->fetchAuthoringQuestionIdParameter();
499  } catch (ilTestException $e) {
500  $qid = 0;
501  }
502 
503  $this->prepareOutput();
504  if (!in_array($cmd, array('addQuestion', 'browseForQuestions'))) {
505  $this->buildPageViewToolbar($qid);
506  }
507 
508  if (!$qid || in_array($cmd, array('insertQuestions', 'browseForQuestions'))) {
509  require_once "./Modules/Test/classes/class.ilTestExpressPageObjectGUI.php";
510  $pageObject = new ilTestExpressPageObjectGUI(0);
511  $pageObject->test_object = $this->object;
512  $ret = &$this->ctrl->forwardCommand($pageObject);
513  break;
514  }
515  require_once "./Services/Style/Content/classes/class.ilObjStyleSheet.php";
516  $this->tpl->setCurrentBlock("ContentStyle");
517  $this->tpl->setVariable(
518  "LOCATION_CONTENT_STYLESHEET",
520  );
521  $this->tpl->parseCurrentBlock();
522 
523  // syntax style
524  $this->tpl->setCurrentBlock("SyntaxStyle");
525  $this->tpl->setVariable(
526  "LOCATION_SYNTAX_STYLESHEET",
528  );
529  $this->tpl->parseCurrentBlock();
530  require_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
531 
532  $q_gui = assQuestionGUI::_getQuestionGUI("", $qid);
533  if (!($q_gui instanceof assQuestionGUI)) {
534  $this->ctrl->setParameterByClass('iltestexpresspageobjectgui', 'q_id', '');
535  $this->ctrl->redirectByClass('iltestexpresspageobjectgui', $this->ctrl->getCmd());
536  }
537 
538  $q_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_PREVIEW);
539 
540  $q_gui->outAdditionalOutput();
541  $q_gui->object->setObjId($this->object->getId());
542 
543  $q_gui->setTargetGuiClass(null);
544  $q_gui->setQuestionActionCmd(null);
545 
546  $question = $q_gui->object;
547  $this->ctrl->saveParameter($this, "q_id");
548 
549  #$this->lng->loadLanguageModule("content");
550  $this->ctrl->setReturnByClass("ilTestExpressPageObjectGUI", "view");
551  $this->ctrl->setReturn($this, "questions");
552 
553  require_once "./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php";
554  require_once "./Modules/Test/classes/class.ilTestExpressPageObjectGUI.php";
555 
556  $page_gui = new ilTestExpressPageObjectGUI($qid);
557  $page_gui->test_object = $this->object;
558  $page_gui->setEditPreview(true);
559  $page_gui->setEnabledTabs(false);
560  if (strlen($this->ctrl->getCmd()) == 0) {
561  $this->ctrl->setCmdClass(get_class($page_gui));
562  $this->ctrl->setCmd("preview");
563  }
564 
565  $page_gui->setQuestionHTML(array($q_gui->object->getId() => $q_gui->getPreview(true)));
566  $page_gui->setTemplateTargetVar("ADM_CONTENT");
567 
568  $page_gui->setOutputMode($this->object->evalTotalPersons() == 0 ? "edit" : 'preview');
569 
570  $page_gui->setHeader($question->getTitle());
571  $page_gui->setFileDownloadLink($this->ctrl->getLinkTarget($this, "downloadFile"));
572  $page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "fullscreen"));
573  $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTarget($this));
574  $page_gui->setPresentationTitle($question->getTitle() . ' [' . $this->lng->txt('question_id_short') . ': ' . $question->getId() . ']');
575  $ret = &$this->ctrl->forwardCommand($page_gui);
576 
577  global $DIC;
578  $ilTabs = $DIC['ilTabs'];
579  $ilTabs->activateTab('assQuestions');
580 
581  $this->tpl->setContent($ret);
582  break;
583 
584  case 'ilassquestionpreviewgui':
585 
586  $this->prepareOutput();
587 
588  $this->ctrl->saveParameter($this, "q_id");
589 
590  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionPreviewGUI.php';
591  $gui = new ilAssQuestionPreviewGUI($this->ctrl, $this->tabs_gui, $this->tpl, $this->lng, $ilDB, $ilUser);
592 
593  $gui->initQuestion($this->fetchAuthoringQuestionIdParameter(), $this->object->getId());
594  $gui->initPreviewSettings($this->object->getRefId());
595  $gui->initPreviewSession($ilUser->getId(), (int) $_GET['q_id']);
596  $gui->initHintTracking();
597  $gui->initStyleSheets();
598 
599  $this->ctrl->forwardCommand($gui);
600 
601  break;
602 
603  case 'ilassquestionpagegui':
604  $_GET['q_id'] = $this->fetchAuthoringQuestionIdParameter();
605  $this->prepareOutput();
606  require_once 'Modules/Test/classes/class.ilAssQuestionPageCommandForwarder.php';
607  $forwarder = new ilAssQuestionPageCommandForwarder();
608  $forwarder->setTestObj($this->object);
609  $forwarder->forward();
610  break;
611 
612  case 'ilassspecfeedbackpagegui':
613  require_once "./Modules/TestQuestionPool/classes/feedback/class.ilAssSpecFeedbackPageGUI.php";
614  $pg_gui = new ilAssSpecFeedbackPageGUI((int) $_GET["feedback_id"]);
615  $this->ctrl->forwardCommand($pg_gui);
616  break;
617 
618  case 'ilassgenfeedbackpagegui':
619  require_once "./Modules/TestQuestionPool/classes/feedback/class.ilAssGenFeedbackPageGUI.php";
620  $pg_gui = new ilAssGenFeedbackPageGUI((int) $_GET["feedback_id"]);
621  $this->ctrl->forwardCommand($pg_gui);
622  break;
623 
624  case 'illocalunitconfigurationgui':
625  $this->prepareSubGuiOutput();
626 
627  // set return target
628  $this->ctrl->setReturn($this, "questions");
629 
630  // set context tabs
631  require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
633  $questionGUI->object->setObjId($this->object->getId());
634  $questionGUI->setQuestionTabs();
635 
636  require_once 'Modules/TestQuestionPool/classes/class.ilLocalUnitConfigurationGUI.php';
637  require_once 'Modules/TestQuestionPool/classes/class.ilUnitConfigurationRepository.php';
638  $gui = new ilLocalUnitConfigurationGUI(
639  new ilUnitConfigurationRepository((int) $_GET['q_id'])
640  );
641  $this->ctrl->forwardCommand($gui);
642  break;
643 
644  case "ilcommonactiondispatchergui":
645  require_once "Services/Object/classes/class.ilCommonActionDispatcherGUI.php";
647  $this->ctrl->forwardCommand($gui);
648  break;
649 
650  case 'ilassquestionhintsgui':
651 
652  $this->prepareSubGuiOutput();
653 
654  // set return target
655  $this->ctrl->setReturn($this, "questions");
656 
657  // set context tabs
658  require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
659  $questionGUI = &assQuestionGUI::_getQuestionGUI($q_type, $this->fetchAuthoringQuestionIdParameter());
660  $questionGUI->object->setObjId($this->object->getId());
661  $questionGUI->setQuestionTabs();
662 
663  // forward to ilAssQuestionHintsGUI
664  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintsGUI.php';
665  $gui = new ilAssQuestionHintsGUI($questionGUI);
666 
667  $gui->setEditingEnabled(
668  $DIC->access()->checkAccess('write', '', $this->object->getRefId())
669  );
670 
671  $ilCtrl->forwardCommand($gui);
672 
673  break;
674 
675  case 'ilassquestionfeedbackeditinggui':
676 
677  $this->prepareSubGuiOutput();
678 
679  // set return target
680  $this->ctrl->setReturn($this, "questions");
681 
682  // set context tabs
683  require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
685  $questionGUI->object->setObjId($this->object->getId());
686  $questionGUI->setQuestionTabs();
687 
688  // forward to ilAssQuestionFeedbackGUI
689  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionFeedbackEditingGUI.php';
690  $gui = new ilAssQuestionFeedbackEditingGUI($questionGUI, $ilCtrl, $ilAccess, $tpl, $ilTabs, $lng);
691  $ilCtrl->forwardCommand($gui);
692 
693  break;
694 
695  case 'iltestcorrectionsgui':
696  $this->prepareOutput();
697  require_once './Modules/Test/classes/class.ilTestCorrectionsGUI.php';
698  $gui = new ilTestCorrectionsGUI($DIC, $this->object);
699  $this->ctrl->forwardCommand($gui);
700  break;
701 
702  case '':
703  case 'ilobjtestgui':
704  $this->prepareOutput();
705  $this->addHeaderAction();
706  if ((strcmp($cmd, "properties") == 0) && ($_GET["browse"])) {
707  $this->questionBrowser();
708  return;
709  }
710  if ((strcmp($cmd, "properties") == 0) && ($_GET["up"] || $_GET["down"])) {
711  $this->questionsObject();
712  return;
713  }
714  $cmd .= "Object";
715  $ret = &$this->$cmd();
716  break;
717  default:
718  // elba hack for storing question id for inserting new question after
719  if ($_REQUEST['prev_qid']) {
720  global $___prev_question_id;
721  $___prev_question_id = $_REQUEST['prev_qid'];
722  $this->ctrl->setParameterByClass('ilassquestionpagegui', 'prev_qid', $_REQUEST['prev_qid']);
723  $this->ctrl->setParameterByClass($_GET['sel_question_types'] . 'gui', 'prev_qid', $_REQUEST['prev_qid']);
724  }
725  $this->create_question_mode = true;
726  $this->prepareOutput();
727 
728  $this->ctrl->setReturn($this, "questions");
729  require_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
730  $q_gui = &assQuestionGUI::_getQuestionGUI($_GET['sel_question_types'], $this->fetchAuthoringQuestionIdParameter());
731  $q_gui->setEditContext(assQuestionGUI::EDIT_CONTEXT_AUTHORING);
732  $q_gui->object->setObjId($this->object->getId());
733  if (!$_GET['sel_question_types']) {
734  $qType = assQuestion::getQuestionTypeFromDb($_GET['q_id']);
735  } else {
736  $qType = $_GET['sel_question_types'];
737  }
738  $this->ctrl->setParameterByClass($qType . "GUI", 'prev_qid', $_REQUEST['prev_qid']);
739  $this->ctrl->setParameterByClass($qType . "GUI", 'test_ref_id', $_REQUEST['ref_id']);
740  $this->ctrl->setParameterByClass($qType . "GUI", 'q_id', $_REQUEST['q_id']);
741  if ($_REQUEST['test_express_mode']) {
742  $this->ctrl->setParameterByClass($qType . "GUI", 'test_express_mode', 1);
743  }
744 
745  #global $___test_express_mode;
746  #$___test_express_mode = true;
747  if (!$q_gui->isSaveCommand()) {
748  $_GET['calling_test'] = $this->object->getRefId();
749  }
750 
751  $q_gui->setQuestionTabs();
752  #unset($___test_express_mode);
753  $ret = &$this->ctrl->forwardCommand($q_gui);
754  break;
755  }
756  if (!in_array(strtolower($_GET["baseClass"]), array('iladministrationgui', 'ilrepositorygui')) &&
757  $this->getCreationMode() != true) {
758  $this->tpl->show();
759  }
760  }
761 
762  protected function trackTestObjectReadEvent()
763  {
764  /* @var ILIAS\DI\Container $DIC */ global $DIC;
765 
766  require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
767 
769  $this->object->getType(),
770  $this->object->getRefId(),
771  $this->object->getId(),
772  $DIC->user()->getId()
773  );
774  }
775 
780  protected function exportObject()
781  {
782  global $DIC; /* @var ILIAS\DI\Container $DIC */
783  $DIC->ctrl()->redirectByClass('ilTestExportGUI');
784  }
785 
790  {
791  $qid = $_REQUEST['q_id'];
792 
793  if (!$qid || $qid == 'Array') {
794  $questions = $this->object->getQuestionTitlesAndIndexes();
795  if (!is_array($questions)) {
796  $questions = array();
797  }
798 
799  $keys = array_keys($questions);
800  $qid = $keys[0];
801 
802  $_REQUEST['q_id'] = $qid;
803  $_GET['q_id'] = $qid;
804  $_POST['q_id'] = $qid;
805  }
806 
807  if ($this->object->checkQuestionParent($qid)) {
808  return $qid;
809  }
810 
811  throw new ilTestException('question id does not relate to parent object!');
812  }
813 
814  private function questionsTabGatewayObject()
815  {
816  switch ($this->object->getQuestionSetType()) {
818  $this->ctrl->redirectByClass('ilTestExpressPageObjectGUI', 'showPage');
819 
820  // no break
822  $this->ctrl->redirectByClass('ilTestRandomQuestionSetConfigGUI');
823 
824  // no break
826  $this->ctrl->redirectByClass('ilObjTestDynamicQuestionSetConfigGUI');
827  }
828  }
829 
830  private function userResultsGatewayObject()
831  {
832  $this->ctrl->setCmdClass('ilTestEvaluationGUI');
833  $this->ctrl->setCmd('outUserResultsOverview');
834  $this->tabs_gui->clearTargets();
835 
836  $this->forwardToEvaluationGUI();
837  }
838 
842  public function getTestAccess()
843  {
844  return $this->testAccess;
845  }
846 
850  public function setTestAccess($testAccess)
851  {
852  $this->testAccess = $testAccess;
853  }
854 
858  public function getTabsManager()
859  {
860  return $this->tabsManager;
861  }
862 
866  public function setTabsManager($tabsManager)
867  {
868  $this->tabsManager = $tabsManager;
869  }
870 
871  private function forwardToEvaluationGUI()
872  {
873  $this->prepareOutput();
874  $this->addHeaderAction();
875 
876  require_once 'Modules/Test/classes/class.ilTestEvaluationGUI.php';
877  $gui = new ilTestEvaluationGUI($this->object);
878  $gui->setObjectiveOrientedContainer($this->getObjectiveOrientedContainer());
879  $gui->setTestAccess($this->getTestAccess());
880 
881  $this->ctrl->forwardCommand($gui);
882  }
883 
885  {
886  require_once 'Modules/Test/classes/class.ilObjTestSettingsGeneralGUI.php';
887  $this->ctrl->redirectByClass('ilObjTestSettingsGeneralGUI', ilObjTestSettingsGeneralGUI::CMD_SHOW_FORM);
888  }
889 
898  private function prepareSubGuiOutput()
899  {
900  global $DIC;
901  $ilUser = $DIC['ilUser'];
902 
903  $this->tpl->getStandardTemplate();
904 
905  // set locator
906  $this->setLocator();
907 
908  // catch feedback message
910 
911  // set title and description and title icon
912  $this->setTitleAndDescription();
913 
914  // BEGIN WebDAV: Display Mount Webfolder icon.
915  if ($ilUser->getId() != ANONYMOUS_USER_ID) {
916  require_once('Services/WebDAV/classes/class.ilDAVActivationChecker.php');
918  $this->showMountWebfolderIcon();
919  }
920  }
921  // END WebDAV: Display Mount Webfolder icon.
922  }
923 
924  public function runObject()
925  {
926  $this->ctrl->redirect($this, "infoScreen");
927  }
928 
929  public function outEvaluationObject()
930  {
931  $this->ctrl->redirectByClass("iltestevaluationgui", "outEvaluation");
932  }
933 
937  protected function importFileObject($parent_id = null, $a_catch_errors = true)
938  {
939  $form = $this->initImportForm($_REQUEST["new_type"]);
940  if ($form->checkInput()) {
941  $this->ctrl->setParameter($this, "new_type", $this->type);
942  $this->uploadTstObject();
943  }
944 
945  // display form to correct errors
946  $form->setValuesByPost();
947  $this->tpl->setContent($form->getHTML());
948  }
949 
950  public function addDidacticTemplateOptions(array &$a_options)
951  {
952  include_once("./Modules/Test/classes/class.ilObjTest.php");
953  $tst = new ilObjTest();
954  $defaults = $tst->getAvailableDefaults();
955  if (count($defaults)) {
956  foreach ($defaults as $row) {
957  $a_options["tstdef_" . $row["test_defaults_id"]] = array($row["name"],
958  $this->lng->txt("tst_default_settings"));
959  }
960  }
961 
962  // using template?
963  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
965  if ($templates) {
966  foreach ($templates as $item) {
967  $a_options["tsttpl_" . $item["id"]] = array($item["title"],
968  nl2br(trim($item["description"])));
969  }
970  }
971  }
972 
977  public function afterSave(ilObject $a_new_object)
978  {
979  $tstdef = $this->getDidacticTemplateVar("tstdef");
980  if ($tstdef) {
981  $testDefaultsId = $tstdef;
982  $testDefaults = ilObjTest::_getTestDefaults($testDefaultsId);
983  $a_new_object->applyDefaults($testDefaults);
984  }
985 
986  $template_id = $this->getDidacticTemplateVar("tsttpl");
987  if ($template_id) {
988  include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
990 
991  $template_settings = $template->getSettings();
992  if ($template_settings) {
993  $this->applyTemplate($template_settings, $a_new_object);
994  }
995 
996  $a_new_object->setTemplate($template_id);
997  }
998 
999  $a_new_object->saveToDb();
1000 
1001  // always send a message
1002  ilUtil::sendSuccess($this->lng->txt("object_added"), true);
1003  $this->ctrl->setParameter($this, 'ref_id', $a_new_object->getRefId());
1004  $this->ctrl->redirectByClass('ilObjTestSettingsGeneralGUI');
1005  }
1006 
1007  public function backToRepositoryObject()
1008  {
1009  include_once "./Services/Utilities/classes/class.ilUtil.php";
1010  $path = $this->tree->getPathFull($this->object->getRefID());
1011  ilUtil::redirect($this->getReturnLocation("cancel", "./ilias.php?baseClass=ilRepositoryGUI&cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
1012  }
1013 
1017  public function uploadTstObject()
1018  {
1019  if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK) {
1020  ilUtil::sendFailure($this->lng->txt("error_upload"));
1021  $this->createObject();
1022  return;
1023  }
1024  include_once("./Modules/Test/classes/class.ilObjTest.php");
1025  // create import directory
1026  $basedir = ilObjTest::_createImportDirectory();
1027 
1028  // copy uploaded file to import directory
1029  $file = pathinfo($_FILES["xmldoc"]["name"]);
1030  $full_path = $basedir . "/" . $_FILES["xmldoc"]["name"];
1031  ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path);
1032 
1033  // unzip file
1034  ilUtil::unzip($full_path);
1035 
1036  // determine filenames of xml files
1037  $subdir = basename($file["basename"], "." . $file["extension"]);
1039  $xml_file = ilObjTest::_getImportDirectory() . '/' . $subdir . '/' . $subdir . ".xml";
1040  $qti_file = ilObjTest::_getImportDirectory() . '/' . $subdir . '/' . preg_replace("/test|tst/", "qti", $subdir) . ".xml";
1041  $results_file = ilObjTest::_getImportDirectory() . '/' . $subdir . '/' . preg_replace("/test|tst/", "results", $subdir) . ".xml";
1042 
1043  if (!is_file($qti_file)) {
1044  ilUtil::delDir($basedir);
1045  ilUtil::sendFailure($this->lng->txt("tst_import_non_ilias_zip"));
1046  $this->createObject();
1047  return;
1048  }
1049 
1050  // start verification of QTI files
1051  include_once "./Services/QTI/classes/class.ilQTIParser.php";
1052  $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, "");
1053  $result = $qtiParser->startParsing();
1054  $founditems = &$qtiParser->getFoundItems();
1055 
1056  $complete = 0;
1057  $incomplete = 0;
1058  foreach ($founditems as $item) {
1059  if (strlen($item["type"])) {
1060  $complete++;
1061  } else {
1062  $incomplete++;
1063  }
1064  }
1065 
1066  if (count($founditems) && $complete == 0) {
1067  // delete import directory
1068  ilUtil::delDir($basedir);
1069 
1070  ilUtil::sendInfo($this->lng->txt("qpl_import_non_ilias_files"));
1071  $this->createObject();
1072  return;
1073  }
1074 
1075  $_SESSION["tst_import_results_file"] = $results_file;
1076  $_SESSION["tst_import_xml_file"] = $xml_file;
1077  $_SESSION["tst_import_qti_file"] = $qti_file;
1078  $_SESSION["tst_import_subdir"] = $subdir;
1079 
1080  if ($qtiParser->getQuestionSetType() != ilObjTest::QUESTION_SET_TYPE_FIXED) {
1081  $this->importVerifiedFileObject();
1082  return;
1083  }
1084 
1085  // display of found questions
1086  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.tst_import_verification.html", "Modules/Test");
1087  $row_class = array("tblrow1", "tblrow2");
1088  $counter = 0;
1089  foreach ($founditems as $item) {
1090  $this->tpl->setCurrentBlock("verification_row");
1091  $this->tpl->setVariable("ROW_CLASS", $row_class[$counter++ % 2]);
1092  $this->tpl->setVariable("QUESTION_TITLE", $item["title"]);
1093  $this->tpl->setVariable("QUESTION_IDENT", $item["ident"]);
1094  include_once "./Services/QTI/classes/class.ilQTIItem.php";
1095  switch ($item["type"]) {
1097  case QT_MULTIPLE_CHOICE_MR:
1098  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assMultipleChoice"));
1099  break;
1101  case QT_MULTIPLE_CHOICE_SR:
1102  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assSingleChoice"));
1103  break;
1105  case QT_KPRIM_CHOICE:
1106  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assKprimChoice"));
1107  break;
1109  case QT_LONG_MENU:
1110  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assLongMenu"));
1111  break;
1113  case QT_NUMERIC:
1114  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assNumeric"));
1115  break;
1117  case QT_FORMULA:
1118  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assFormulaQuestion"));
1119  break;
1121  case QT_TEXTSUBSET:
1122  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextSubset"));
1123  break;
1124  case CLOZE_TEST_IDENTIFIER:
1125  case QT_CLOZE:
1126  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assClozeTest"));
1127  break;
1128  case ERROR_TEXT_IDENTIFIER:
1129  case QT_ERRORTEXT:
1130  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assErrorText"));
1131  break;
1133  case QT_IMAGEMAP:
1134  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assImagemapQuestion"));
1135  break;
1137  case QT_JAVAAPPLET:
1138  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assJavaApplet"));
1139  break;
1141  case QT_FLASHAPPLET:
1142  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assFlashApplet"));
1143  break;
1145  case QT_MATCHING:
1146  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assMatchingQuestion"));
1147  break;
1149  case QT_ORDERING:
1150  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assOrderingQuestion"));
1151  break;
1154  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assOrderingHorizontal"));
1155  break;
1157  case QT_TEXT:
1158  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextQuestion"));
1159  break;
1161  case QT_FILEUPLOAD:
1162  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("assFileUpload"));
1163  break;
1164  }
1165  $this->tpl->parseCurrentBlock();
1166  }
1167 
1168  // on import creation screen the pool was chosen (-1 for no pool)
1169  // BUT when no pool is available the input on creation screen is missing, so the field value -1 for no pool is not submitted.
1170  $QplOrTstID = isset($_POST["qpl"]) && (int) $_POST["qpl"] != 0 ? $_POST["qpl"] : -1;
1171 
1172  $this->tpl->setCurrentBlock("adm_content");
1173  $this->tpl->setVariable("TEXT_TYPE", $this->lng->txt("question_type"));
1174  $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("question_title"));
1175  $this->tpl->setVariable("FOUND_QUESTIONS_INTRODUCTION", $this->lng->txt("tst_import_verify_found_questions"));
1176  $this->tpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_tst"));
1177  $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1178  $this->tpl->setVariable("ARROW", ilUtil::getImagePath("arrow_downright.svg"));
1179  $this->tpl->setVariable("QUESTIONPOOL_ID", $QplOrTstID);
1180  $this->tpl->setVariable("VALUE_IMPORT", $this->lng->txt("import"));
1181  $this->tpl->setVariable("VALUE_CANCEL", $this->lng->txt("cancel"));
1182  $this->tpl->parseCurrentBlock();
1183  }
1184 
1188  public function importVerifiedFileObject()
1189  {
1190  include_once "./Modules/Test/classes/class.ilObjTest.php";
1191  // create new questionpool object
1192  $newObj = new ilObjTest(0, true);
1193  // set type of questionpool object
1194  $newObj->setType($_GET["new_type"]);
1195  // set title of questionpool object to "dummy"
1196  $newObj->setTitle("dummy");
1197  // set description of questionpool object
1198  $newObj->setDescription("test import");
1199  // create the questionpool class in the ILIAS database (object_data table)
1200  $newObj->create(true);
1201  // create a reference for the questionpool object in the ILIAS database (object_reference table)
1202  $newObj->createReference();
1203  // put the questionpool object in the administration tree
1204  $newObj->putInTree($_GET["ref_id"]);
1205  // get default permissions and set the permissions for the questionpool object
1206  $newObj->setPermissions($_GET["ref_id"]);
1207  // empty mark schema
1208  $newObj->mark_schema->flush();
1209 
1210  // start parsing of QTI files
1211  include_once "./Services/QTI/classes/class.ilQTIParser.php";
1212 
1213  // Handle selection of "no questionpool" as qpl_id = -1 -> use test object id instead.
1214  // possible hint: chek if empty strings in $_POST["qpl_id"] relates to a bug or not
1215  if (!isset($_POST["qpl"]) || "-1" === (string) $_POST["qpl"]) {
1216  $questionParentObjId = $newObj->getId();
1217  } else {
1218  $questionParentObjId = $_POST["qpl"];
1219  }
1220 
1221  if (is_file($_SESSION["tst_import_dir"] . '/' . $_SESSION["tst_import_subdir"] . "/manifest.xml")) {
1222  $newObj->saveToDb();
1223 
1224  $_SESSION['tst_import_idents'] = $_POST['ident'];
1225  $_SESSION['tst_import_qst_parent'] = $questionParentObjId;
1226 
1227  $fileName = $_SESSION['tst_import_subdir'] . '.zip';
1228  $fullPath = $_SESSION['tst_import_dir'] . '/' . $fileName;
1229 
1230  include_once("./Services/Export/classes/class.ilImport.php");
1231  $imp = new ilImport((int) $_GET["ref_id"]);
1232  $map = $imp->getMapping();
1233  $map->addMapping('Modules/Test', 'tst', 'new_id', $newObj->getId());
1234  $imp->importObject($newObj, $fullPath, $fileName, 'tst', 'Modules/Test', true);
1235  } else {
1236  $qtiParser = new ilQTIParser($_SESSION["tst_import_qti_file"], IL_MO_PARSE_QTI, $questionParentObjId, $_POST["ident"]);
1237  if (!isset($_POST["ident"]) || !is_array($_POST["ident"]) || !count($_POST["ident"])) {
1238  $qtiParser->setIgnoreItemsEnabled(true);
1239  }
1240  $qtiParser->setTestObject($newObj);
1241  $result = $qtiParser->startParsing();
1242  $newObj->saveToDb();
1243 
1244  // import page data
1245  include_once("./Modules/LearningModule/classes/class.ilContObjParser.php");
1246  $contParser = new ilContObjParser($newObj, $_SESSION["tst_import_xml_file"], $_SESSION["tst_import_subdir"]);
1247  $contParser->setQuestionMapping($qtiParser->getImportMapping());
1248  $contParser->startParsing();
1249 
1250  if (isset($_POST["ident"]) && is_array($_POST["ident"]) && count($_POST["ident"]) == $qtiParser->getNumImportedItems()) {
1251  // import test results
1252  if (@file_exists($_SESSION["tst_import_results_file"])) {
1253  include_once("./Modules/Test/classes/class.ilTestResultsImportParser.php");
1254  $results = new ilTestResultsImportParser($_SESSION["tst_import_results_file"], $newObj);
1255  $results->setQuestionIdMapping($qtiParser->getQuestionIdMapping());
1256  $results->startParsing();
1257  }
1258  }
1259  $newObj->update();
1260  }
1261 
1262 
1263  // delete import directory
1265 
1266  ilUtil::sendSuccess($this->lng->txt("object_imported"), true);
1267  ilUtil::redirect("ilias.php?ref_id=" . $newObj->getRefId() . "&baseClass=ilObjTestGUI");
1268  }
1269 
1276  public function uploadObject($redirect = true)
1277  {
1278  $this->uploadTstObject();
1279  }
1280 
1284  public function downloadFileObject()
1285  {
1286  $file = explode("_", $_GET["file_id"]);
1287  include_once("./Modules/File/classes/class.ilObjFile.php");
1288  $fileObj = new ilObjFile($file[count($file) - 1], false);
1289  $fileObj->sendFile();
1290  exit;
1291  }
1292 
1296  public function fullscreenObject()
1297  {
1298  include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php");
1299  $page_gui = new ilAssQuestionPageGUI($_GET["pg_id"]);
1300  $page_gui->showMediaFullscreen();
1301  }
1302 
1306  public function download_paragraphObject()
1307  {
1308  include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php");
1309  $pg_obj = new ilAssQuestionPage($_GET["pg_id"]);
1310  $pg_obj->send_paragraph($_GET["par_id"], $_GET["downloadtitle"]);
1311  exit;
1312  }
1313 
1321  public function filterObject()
1322  {
1323  $this->questionBrowser();
1324  }
1325 
1333  public function resetFilterObject()
1334  {
1335  $this->questionBrowser();
1336  }
1337 
1345  public function backObject()
1346  {
1347  $this->ctrl->redirect($this, "questions");
1348  }
1349 
1358  public function createQuestionPool($name = "dummy", $description = "")
1359  {
1360  global $DIC;
1361  $tree = $DIC['tree'];
1362  $parent_ref = $tree->getParentId($this->object->getRefId());
1363  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
1364  $qpl = new ilObjQuestionPool();
1365  $qpl->setType("qpl");
1366  $qpl->setTitle($name);
1367  $qpl->setDescription($description);
1368  $qpl->create();
1369  $qpl->createReference();
1370  $qpl->putInTree($parent_ref);
1371  $qpl->setPermissions($parent_ref);
1372  $qpl->setOnline(1); // must be online to be available
1373  $qpl->saveToDb();
1374  return $qpl->getRefId();
1375  }
1376 
1380  public function randomselectObject()
1381  {
1382  global $DIC;
1383  $ilUser = $DIC['ilUser'];
1384  $this->getTabsManager()->getQuestionsSubTabs();
1386  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_random_select.html", "Modules/Test");
1387  $questionpools = &$this->object->getAvailableQuestionpools(false, false, false, true);
1388  $this->tpl->setCurrentBlock("option");
1389  $this->tpl->setVariable("VALUE_OPTION", "0");
1390  $this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("all_available_question_pools"));
1391  $this->tpl->parseCurrentBlock();
1392  foreach ($questionpools as $key => $value) {
1393  $this->tpl->setCurrentBlock("option");
1394  $this->tpl->setVariable("VALUE_OPTION", $key);
1395  $this->tpl->setVariable("TEXT_OPTION", $value["title"]);
1396  $this->tpl->parseCurrentBlock();
1397  }
1398  $this->tpl->setCurrentBlock("hidden");
1399  $this->tpl->setVariable("HIDDEN_NAME", "sel_question_types");
1400  $this->tpl->setVariable("HIDDEN_VALUE", $_POST["sel_question_types"]);
1401  $this->tpl->parseCurrentBlock();
1402  $this->tpl->setCurrentBlock("adm_content");
1403  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
1404  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_random_select_questionpool"));
1405  $this->tpl->setVariable("TXT_NR_OF_QUESTIONS", $this->lng->txt("tst_random_nr_of_questions"));
1406  $this->tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit"));
1407  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
1408  $this->tpl->parseCurrentBlock();
1409  }
1410 
1418  public function cancelRandomSelectObject()
1419  {
1420  $this->ctrl->redirect($this, "questions");
1421  }
1422 
1431  {
1432  $this->getTabsManager()->getQuestionsSubTabs();
1434  $question_array = $this->object->randomSelectQuestions($_POST["nr_of_questions"], $_POST["sel_qpl"]);
1435  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_random_question_offer.html", "Modules/Test");
1436  $color_class = array("tblrow1", "tblrow2");
1437  $counter = 0;
1438  $questionpools = &$this->object->getAvailableQuestionpools(true);
1439  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
1440  foreach ($question_array as $question_id) {
1441  $dataset = $this->object->getQuestionDataset($question_id);
1442  $this->tpl->setCurrentBlock("QTab");
1443  $this->tpl->setVariable("COLOR_CLASS", $color_class[$counter % 2]);
1444  $this->tpl->setVariable("QUESTION_TITLE", $dataset->title);
1445  $this->tpl->setVariable("QUESTION_COMMENT", $dataset->description);
1446  $this->tpl->setVariable("QUESTION_TYPE", assQuestion::_getQuestionTypeName($dataset->type_tag));
1447  $this->tpl->setVariable("QUESTION_AUTHOR", $dataset->author);
1448  $this->tpl->setVariable("QUESTION_POOL", $questionpools[$dataset->obj_fi]["title"]);
1449  $this->tpl->parseCurrentBlock();
1450  $counter++;
1451  }
1452  if (count($question_array) == 0) {
1453  $this->tpl->setCurrentBlock("Emptytable");
1454  $this->tpl->setVariable("TEXT_NO_QUESTIONS_AVAILABLE", $this->lng->txt("no_questions_available"));
1455  $this->tpl->parseCurrentBlock();
1456  } else {
1457  $this->tpl->setCurrentBlock("Selectionbuttons");
1458  $this->tpl->setVariable("BTN_YES", $this->lng->txt("random_accept_sample"));
1459  $this->tpl->setVariable("BTN_NO", $this->lng->txt("random_another_sample"));
1460  $this->tpl->parseCurrentBlock();
1461  }
1462  $chosen_questions = join($question_array, ",");
1463  $this->tpl->setCurrentBlock("adm_content");
1464  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
1465  $this->tpl->setVariable("QUESTION_TITLE", $this->lng->txt("tst_question_title"));
1466  $this->tpl->setVariable("QUESTION_COMMENT", $this->lng->txt("description"));
1467  $this->tpl->setVariable("QUESTION_TYPE", $this->lng->txt("tst_question_type"));
1468  $this->tpl->setVariable("QUESTION_AUTHOR", $this->lng->txt("author"));
1469  $this->tpl->setVariable("QUESTION_POOL", $this->lng->txt("qpl"));
1470  $this->tpl->setVariable("VALUE_CHOSEN_QUESTIONS", $chosen_questions);
1471  $this->tpl->setVariable("VALUE_QUESTIONPOOL_SELECTION", $_POST["sel_qpl"]);
1472  $this->tpl->setVariable("VALUE_NR_OF_QUESTIONS", $_POST["nr_of_questions"]);
1473  $this->tpl->setVariable("TEXT_QUESTION_OFFER", $this->lng->txt("tst_question_offer"));
1474  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
1475  $this->tpl->parseCurrentBlock();
1476  }
1477 
1486  {
1487  $selected_array = explode(",", $_POST["chosen_questions"]);
1488  if (!count($selected_array)) {
1489  ilUtil::sendInfo($this->lng->txt("tst_insert_missing_question"));
1490  } else {
1491  $total = $this->object->evalTotalPersons();
1492  if ($total) {
1493  // the test was executed previously
1494  ilUtil::sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total));
1495  } else {
1496  ilUtil::sendInfo($this->lng->txt("tst_insert_questions"));
1497  }
1498  foreach ($selected_array as $key => $value) {
1499  $this->object->insertQuestion($this->testQuestionSetConfigFactory->getQuestionSetConfig(), $value);
1500  }
1501  $this->object->saveCompleteStatus($this->testQuestionSetConfigFactory->getQuestionSetConfig());
1502  ilUtil::sendSuccess($this->lng->txt("tst_questions_inserted"), true);
1503  $this->ctrl->redirect($this, "questions");
1504  return;
1505  }
1506  }
1507 
1508  public function browseForQuestionsObject()
1509  {
1510  $this->questionBrowser();
1511  }
1512 
1521  {
1522  $qpl_ref_id = $_REQUEST["sel_qpl"];
1523 
1524  $qpl_mode = $_REQUEST['usage'];
1525 
1526  if (isset($_REQUEST['qtype'])) {
1527  include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
1528  $sel_question_types = ilObjQuestionPool::getQuestionTypeByTypeId($_REQUEST["qtype"]);
1529  } elseif (isset($_REQUEST['sel_question_types'])) {
1530  $sel_question_types = $_REQUEST["sel_question_types"];
1531  }
1532 
1533  if (!$qpl_mode || ($qpl_mode == 2 && strcmp($_REQUEST["txt_qpl"], "") == 0) || ($qpl_mode == 3 && strcmp($qpl_ref_id, "") == 0)) {
1534  //if ((strcmp($_REQUEST["txt_qpl"], "") == 0) && (strcmp($qpl_ref_id, "") == 0))
1535  // Mantis #14890
1536  $_REQUEST['sel_question_types'] = $sel_question_types;
1537  ilUtil::sendInfo($this->lng->txt("questionpool_not_entered"));
1538  $this->createQuestionObject();
1539  return;
1540  } else {
1541  $_SESSION["test_id"] = $this->object->getRefId();
1542  if ($qpl_mode == 2 && strcmp($_REQUEST["txt_qpl"], "") != 0) {
1543  // create a new question pool and return the reference id
1544  $qpl_ref_id = $this->createQuestionPool($_REQUEST["txt_qpl"]);
1545  } elseif ($qpl_mode == 1) {
1546  $qpl_ref_id = $_GET["ref_id"];
1547  }
1548 
1549  include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPoolGUI.php";
1550  $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;
1551 
1552  if (isset($_REQUEST['prev_qid'])) {
1553  $baselink .= '&prev_qid=' . $_REQUEST['prev_qid'];
1554  } elseif (isset($_REQUEST['position'])) {
1555  $baselink .= '&prev_qid=' . $_REQUEST['position'];
1556  }
1557 
1558  if ($_REQUEST['test_express_mode']) {
1559  $baselink .= '&test_express_mode=1';
1560  }
1561 
1562  if (isset($_REQUEST['add_quest_cont_edit_mode'])) {
1564  $baselink,
1565  "add_quest_cont_edit_mode={$_REQUEST['add_quest_cont_edit_mode']}",
1566  false
1567  );
1568  }
1569 
1570  #var_dump($_REQUEST['prev_qid']);
1571  ilUtil::redirect($baselink);
1572 
1573  exit();
1574  }
1575  }
1576 
1584  public function cancelCreateQuestionObject()
1585  {
1586  $this->ctrl->redirect($this, "questions");
1587  }
1588 
1596  public function createQuestionObject()
1597  {
1598  global $DIC;
1599  $ilUser = $DIC['ilUser'];
1600  $this->getTabsManager()->getQuestionsSubTabs();
1602  //$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_qpl_select.html", "Modules/Test");
1603  $questionpools = &$this->object->getAvailableQuestionpools(false, false, false, true, false, "write");
1604 
1605  if ($this->object->getPoolUsage()) {
1606  global $DIC;
1607  $lng = $DIC['lng'];
1608  $ilCtrl = $DIC['ilCtrl'];
1609  $tpl = $DIC['tpl'];
1610 
1611  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
1612 
1613  $form = new ilPropertyFormGUI();
1614  $form->setFormAction($ilCtrl->getFormAction($this, "executeCreateQuestion"));
1615  $form->setTitle($lng->txt("ass_create_question"));
1616  include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
1617 
1618 
1619  $hidden = new ilHiddenInputGUI('sel_question_types');
1620  $hidden->setValue($_REQUEST["sel_question_types"]);
1621  $form->addItem($hidden);
1622 
1623  // content editing mode
1625  $ri = new ilRadioGroupInputGUI($lng->txt("tst_add_quest_cont_edit_mode"), "add_quest_cont_edit_mode");
1626 
1627  $ri->addOption(new ilRadioOption(
1628  $lng->txt('tst_add_quest_cont_edit_mode_default'),
1630  ));
1631 
1632  $ri->addOption(new ilRadioOption(
1633  $lng->txt('tst_add_quest_cont_edit_mode_page_object'),
1635  ));
1636 
1638 
1639  $form->addItem($ri, true);
1640  } else {
1641  $hi = new ilHiddenInputGUI("question_content_editing_type");
1643  $form->addItem($hi, true);
1644  }
1645 
1646  // use pool
1647  $usage = new ilRadioGroupInputGUI($this->lng->txt("assessment_pool_selection"), "usage");
1648  $usage->setRequired(true);
1649  $no_pool = new ilRadioOption($this->lng->txt("assessment_no_pool"), 1);
1650  $usage->addOption($no_pool);
1651  $existing_pool = new ilRadioOption($this->lng->txt("assessment_existing_pool"), 3);
1652  $usage->addOption($existing_pool);
1653  $new_pool = new ilRadioOption($this->lng->txt("assessment_new_pool"), 2);
1654  $usage->addOption($new_pool);
1655  $form->addItem($usage);
1656 
1657  $usage->setValue(1);
1658 
1659  $questionpools = ilObjQuestionPool::_getAvailableQuestionpools(false, false, true, false, false, "write");
1660  $pools_data = array();
1661  foreach ($questionpools as $key => $p) {
1662  $pools_data[$key] = $p['title'];
1663  }
1664  $pools = new ilSelectInputGUI($this->lng->txt("select_questionpool"), "sel_qpl");
1665  $pools->setOptions($pools_data);
1666  $existing_pool->addSubItem($pools);
1667 
1668 
1669  $this->lng->loadLanguageModule('rbac');
1670  $name = new ilTextInputGUI($this->lng->txt("rbac_create_qpl"), "txt_qpl");
1671  $name->setSize(50);
1672  $name->setMaxLength(50);
1673  $new_pool->addSubItem($name);
1674 
1675  $form->addCommandButton("executeCreateQuestion", $lng->txt("submit"));
1676  $form->addCommandButton("cancelCreateQuestion", $lng->txt("cancel"));
1677 
1678  return $this->tpl->setVariable('ADM_CONTENT', $form->getHTML());
1679  } else {
1680  global $DIC;
1681  $ilCtrl = $DIC['ilCtrl'];
1682 
1683  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'sel_question_types', $_REQUEST["sel_question_types"]);
1684  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'add_quest_cont_edit_mode', $_REQUEST["add_quest_cont_edit_mode"]);
1685  $link = $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'handleToolbarCommand', '', false, false);
1686  ilUtil::redirect($link);
1687  }
1688  }
1689 
1694  {
1695  $removeQuestionIds = (array) $_POST["q_id"];
1696 
1697  $questions = $this->object->getQuestionTitlesAndIndexes();
1698 
1699  $this->object->removeQuestions($removeQuestionIds);
1700 
1701  $this->object->saveCompleteStatus($this->testQuestionSetConfigFactory->getQuestionSetConfig());
1702 
1703  ilUtil::sendSuccess($this->lng->txt("tst_questions_removed"));
1704 
1705  if ($_REQUEST['test_express_mode']) {
1706  $prev = null;
1707  $return_to = null;
1708  $deleted_tmp = $removeQuestionIds;
1709  $first = array_shift($deleted_tmp);
1710  foreach ((array) $questions as $key => $value) {
1711  if (!in_array($key, $removeQuestionIds)) {
1712  $prev = $key;
1713  if (!$first) {
1714  $return_to = $prev;
1715  break;
1716  } else {
1717  continue;
1718  }
1719  } elseif ($key == $first) {
1720  if ($prev) {
1721  $return_to = $prev;
1722  break;
1723  }
1724  $first = array_shift($deleted_tmp);
1725  }
1726  }
1727 
1728  if (
1729  count($questions) == count($removeQuestionIds) ||
1730  !$return_to
1731  ) {
1732  $this->ctrl->setParameter($this, 'q_id', '');
1733  $this->ctrl->redirect($this, 'showPage');
1734  }
1735 
1736  $this->ctrl->setParameter($this, 'q_id', $return_to);
1737  $this->ctrl->redirect($this, "showPage");
1738  } else {
1739  $this->ctrl->setParameter($this, 'q_id', '');
1740  $this->ctrl->redirect($this, 'questions');
1741  }
1742  }
1743 
1752  {
1753  if ($_REQUEST['test_express_mode']) {
1754  $this->ctrl->setParameter($this, 'q_id', $_REQUEST['q_id']);
1755  $this->ctrl->redirect($this, "showPage");
1756  } else {
1757  $this->ctrl->redirect($this, "questions");
1758  }
1759  }
1760 
1768  public function removeQuestionsForm($checked_questions)
1769  {
1770  $total = $this->object->evalTotalPersons();
1771  if ($total) {
1772  // the test was executed previously
1773  $question = sprintf($this->lng->txt("tst_remove_questions_and_results"), $total);
1774  } else {
1775  if (count($checked_questions) == 1) {
1776  $question = $this->lng->txt("tst_remove_question");
1777  } else {
1778  $question = $this->lng->txt("tst_remove_questions");
1779  }
1780  }
1781 
1782  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1783  $cgui = new ilConfirmationGUI();
1784  $cgui->setHeaderText($question);
1785 
1786  $this->ctrl->saveParameter($this, 'test_express_mode');
1787  $this->ctrl->saveParameter($this, 'q_id');
1788 
1789  $cgui->setFormAction($this->ctrl->getFormAction($this));
1790  $cgui->setCancel($this->lng->txt("cancel"), "cancelRemoveQuestions");
1791  $cgui->setConfirm($this->lng->txt("confirm"), "confirmRemoveQuestions");
1792 
1793  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
1794  $removablequestions = &$this->object->getTestQuestions();
1795  if (count($removablequestions)) {
1796  foreach ($removablequestions as $data) {
1797  if (in_array($data["question_id"], $checked_questions)) {
1798  $txt = $data["title"] . " (" . assQuestion::_getQuestionTypeName($data["type_tag"]) . ")";
1799  $txt .= ' [' . $this->lng->txt('question_id_short') . ': ' . $data['question_id'] . ']';
1800 
1801  if ($data["description"]) {
1802  $txt .= "<div class=\"small\">" . $data["description"] . "</div>";
1803  }
1804 
1805  $cgui->addItem("q_id[]", $data["question_id"], $txt);
1806  }
1807  }
1808  }
1809 
1810  $this->tpl->setContent($cgui->getHTML());
1811  }
1812 
1816  public function removeQuestionsObject()
1817  {
1818  $this->getTabsManager()->getQuestionsSubTabs();
1819 
1820  $checked_questions = $_REQUEST["q_id"];
1821 
1822  if (!is_array($checked_questions) && $checked_questions) {
1823  $checked_questions = array($checked_questions);
1824  }
1825 
1826  if (!is_array($checked_questions)) {
1827  $checked_questions = [];
1828  }
1829 
1830  if (count($checked_questions) > 0) {
1831  $this->removeQuestionsForm($checked_questions);
1832  } elseif (0 === count($checked_questions)) {
1833  ilUtil::sendFailure($this->lng->txt("tst_no_question_selected_for_removal"), true);
1834  $this->ctrl->redirect($this, "questions");
1835  }
1836  }
1837 
1841  public function moveQuestionsObject()
1842  {
1843  $selected_questions = null;
1844  $selected_questions = $_POST['q_id'];
1845  if (is_array($selected_questions)) {
1846  $_SESSION['tst_qst_move_' . $this->object->getTestId()] = $_POST['q_id'];
1847  ilUtil::sendSuccess($this->lng->txt("msg_selected_for_move"), true);
1848  } else {
1849  ilUtil::sendFailure($this->lng->txt('no_selection_for_move'), true);
1850  }
1851  $this->ctrl->redirect($this, 'questions');
1852  }
1853 
1858  {
1859  // get all questions to move
1860  $move_questions = $_SESSION['tst_qst_move_' . $this->object->getTestId()];
1861 
1862  if (!is_array($_POST['q_id']) || 0 === count($_POST['q_id'])) {
1863  ilUtil::sendFailure($this->lng->txt("no_target_selected_for_move"), true);
1864  $this->ctrl->redirect($this, 'questions');
1865  }
1866  if (count($_POST['q_id']) > 1) {
1867  ilUtil::sendFailure($this->lng->txt("too_many_targets_selected_for_move"), true);
1868  $this->ctrl->redirect($this, 'questions');
1869  }
1870  $insert_mode = 0;
1871  $this->object->moveQuestions($_SESSION['tst_qst_move_' . $this->object->getTestId()], $_POST['q_id'][0], $insert_mode);
1872  ilUtil::sendSuccess($this->lng->txt("msg_questions_moved"), true);
1873  unset($_SESSION['tst_qst_move_' . $this->object->getTestId()]);
1874  $this->ctrl->redirect($this, "questions");
1875  }
1876 
1880  public function insertQuestionsAfterObject()
1881  {
1882  // get all questions to move
1883  $move_questions = $_SESSION['tst_qst_move_' . $this->object->getTestId()];
1884  if (!is_array($_POST['q_id']) || 0 === count($_POST['q_id'])) {
1885  ilUtil::sendFailure($this->lng->txt("no_target_selected_for_move"), true);
1886  $this->ctrl->redirect($this, 'questions');
1887  }
1888  if (count($_POST['q_id']) > 1) {
1889  ilUtil::sendFailure($this->lng->txt("too_many_targets_selected_for_move"), true);
1890  $this->ctrl->redirect($this, 'questions');
1891  }
1892  $insert_mode = 1;
1893  $this->object->moveQuestions($_SESSION['tst_qst_move_' . $this->object->getTestId()], $_POST['q_id'][0], $insert_mode);
1894  ilUtil::sendSuccess($this->lng->txt("msg_questions_moved"), true);
1895  unset($_SESSION['tst_qst_move_' . $this->object->getTestId()]);
1896  $this->ctrl->redirect($this, "questions");
1897  }
1898 
1904  public function insertQuestionsObject()
1905  {
1906  $selected_array = (is_array($_POST['q_id'])) ? $_POST['q_id'] : array();
1907  if (!count($selected_array)) {
1908  ilUtil::sendInfo($this->lng->txt("tst_insert_missing_question"), true);
1909  $this->ctrl->redirect($this, "browseForQuestions");
1910  } else {
1911  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
1912  $manscoring = false;
1913  foreach ($selected_array as $key => $value) {
1914  $this->object->insertQuestion($this->testQuestionSetConfigFactory->getQuestionSetConfig(), $value);
1915  if (!$manscoring) {
1916  $manscoring = $manscoring | assQuestion::_needsManualScoring($value);
1917  }
1918  }
1919  $this->object->saveCompleteStatus($this->testQuestionSetConfigFactory->getQuestionSetConfig());
1920  if ($manscoring) {
1921  ilUtil::sendInfo($this->lng->txt("manscoring_hint"), true);
1922  } else {
1923  ilUtil::sendSuccess($this->lng->txt("tst_questions_inserted"), true);
1924  }
1925  $this->ctrl->redirect($this, "questions");
1926  return;
1927  }
1928  }
1929 
1930  public function addQuestionObject()
1931  {
1932  global $DIC;
1933  $lng = $DIC['lng'];
1934  $ilCtrl = $DIC['ilCtrl'];
1935  $tpl = $DIC['tpl'];
1936  global $DIC; /* @var \ILIAS\DI\Container $DIC */
1937  $ilHelp = $DIC['ilHelp']; /* @var ilHelpGUI $ilHelp */
1938 
1939  $this->getTabsManager()->getQuestionsSubTabs();
1941 
1942  $subScreenId = array('createQuestion');
1943 
1944  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
1945 
1946  $ilCtrl->setParameter($this, 'qtype', $_REQUEST['qtype']);
1947 
1948  $form = new ilPropertyFormGUI();
1949 
1950  $form->setFormAction($ilCtrl->getFormAction($this, "executeCreateQuestion"));
1951  $form->setTitle($lng->txt("ass_create_question"));
1952  include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
1953 
1954  $pool = new ilObjQuestionPool();
1955  $questionTypes = $pool->getQuestionTypes(false, true, false);
1956  $options = array();
1957 
1958  // question type
1959  foreach ($questionTypes as $label => $data) {
1960  $options[$data['question_type_id']] = $label;
1961  }
1962 
1963  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
1964  $si = new ilSelectInputGUI($lng->txt("question_type"), "qtype");
1965  $si->setOptions($options);
1966  $form->addItem($si, true);
1967 
1968  // position
1969  $questions = $this->object->getQuestionTitlesAndIndexes();
1970  if ($questions) {
1971  $si = new ilSelectInputGUI($lng->txt("position"), "position");
1972  $options = array('0' => $lng->txt('first'));
1973  foreach ($questions as $key => $title) {
1974  $options[$key] = $lng->txt('behind') . ' ' . $title . ' [' . $this->lng->txt('question_id_short') . ': ' . $key . ']';
1975  }
1976  $si->setOptions($options);
1977  $si->setValue($_REQUEST['q_id']);
1978  $form->addItem($si, true);
1979  }
1980 
1981  // content editing mode
1983  $subScreenId[] = 'editMode';
1984 
1985  $ri = new ilRadioGroupInputGUI($lng->txt("tst_add_quest_cont_edit_mode"), "add_quest_cont_edit_mode");
1986 
1987  $ri->addOption(new ilRadioOption(
1988  $lng->txt('tst_add_quest_cont_edit_mode_default'),
1990  ));
1991 
1992  $ri->addOption(new ilRadioOption(
1993  $lng->txt('tst_add_quest_cont_edit_mode_page_object'),
1995  ));
1996 
1998 
1999  $form->addItem($ri, true);
2000  } else {
2001  $hi = new ilHiddenInputGUI("question_content_editing_type");
2003  $form->addItem($hi, true);
2004  }
2005 
2006  if ($this->object->getPoolUsage()) {
2007  $subScreenId[] = 'poolSelect';
2008 
2009  // use pool
2010  $usage = new ilRadioGroupInputGUI($this->lng->txt("assessment_pool_selection"), "usage");
2011  $usage->setRequired(true);
2012  $no_pool = new ilRadioOption($this->lng->txt("assessment_no_pool"), 1);
2013  $usage->addOption($no_pool);
2014  $existing_pool = new ilRadioOption($this->lng->txt("assessment_existing_pool"), 3);
2015  $usage->addOption($existing_pool);
2016  $new_pool = new ilRadioOption($this->lng->txt("assessment_new_pool"), 2);
2017  $usage->addOption($new_pool);
2018  $form->addItem($usage);
2019 
2020  $usage->setValue(1);
2021 
2022  $questionpools = ilObjQuestionPool::_getAvailableQuestionpools(false, false, true, false, false, "write");
2023  $pools_data = array();
2024  foreach ($questionpools as $key => $p) {
2025  $pools_data[$key] = $p['title'];
2026  }
2027  $pools = new ilSelectInputGUI($this->lng->txt("select_questionpool"), "sel_qpl");
2028  $pools->setOptions($pools_data);
2029  $existing_pool->addSubItem($pools);
2030 
2031  $name = new ilTextInputGUI($this->lng->txt("name"), "txt_qpl");
2032  $name->setSize(50);
2033  $name->setMaxLength(50);
2034  $new_pool->addSubItem($name);
2035  }
2036 
2037  $form->addCommandButton("executeCreateQuestion", $lng->txt("create"));
2038  $form->addCommandButton("questions", $lng->txt("cancel"));
2039 
2040  $DIC->tabs()->activateTab('assQuestions');
2041  $ilHelp->setScreenId('assQuestions');
2042  $ilHelp->setSubScreenId(implode('_', $subScreenId));
2043 
2044  return $tpl->setContent($form->getHTML());
2045  }
2046 
2047  public function questionsObject()
2048  {
2049  global $DIC; /* @var ILIAS\DI\Container $DIC */
2050  $ilAccess = $DIC['ilAccess'];
2051  $ilTabs = $DIC['ilTabs'];
2052 
2053  // #12590
2054  $this->ctrl->setParameter($this, 'test_express_mode', '');
2055 
2056  if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
2057  // allow only write access
2058  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
2059  $this->ctrl->redirect($this, "infoScreen");
2060  }
2061 
2062  if ($_GET['browse']) {
2063  return $this->questionbrowser();
2064  }
2065 
2066  $this->getTabsManager()->getQuestionsSubTabs();
2068 
2069  // #11631, #12994
2070  $this->ctrl->setParameter($this, 'q_id', '');
2071 
2072  if ($_GET["eqid"] && $_GET["eqpl"]) {
2073  ilUtil::redirect("ilias.php?baseClass=ilObjQuestionPoolGUI&ref_id=" . $_GET["eqpl"] . "&cmd=editQuestionForTest&calling_test=" . $_GET["ref_id"] . "&q_id=" . $_GET["eqid"]);
2074  }
2075 
2076  if ($_GET["up"] > 0) {
2077  $this->object->questionMoveUp($_GET["up"]);
2078  }
2079  if ($_GET["down"] > 0) {
2080  $this->object->questionMoveDown($_GET["down"]);
2081  }
2082 
2083  if ($_GET["add"]) {
2084  $selected_array = array();
2085  array_push($selected_array, $_GET["add"]);
2086  $total = $this->object->evalTotalPersons();
2087  if ($total) {
2088  // the test was executed previously
2089  ilUtil::sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total));
2090  } else {
2091  ilUtil::sendInfo($this->lng->txt("tst_insert_questions"));
2092  }
2093  $this->insertQuestions($selected_array);
2094  return;
2095  }
2096 
2097  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_questions.html", "Modules/Test");
2098 
2099  $total = $this->object->evalTotalPersons();
2100  if ($ilAccess->checkAccess("write", "", $this->ref_id)) {
2101  if ($total != 0) {
2102  $link = $DIC->ui()->factory()->link()->standard(
2103  $DIC->language()->txt("test_has_datasets_warning_page_view_link"),
2104  $DIC->ctrl()->getLinkTargetByClass(array('ilTestResultsGUI', 'ilParticipantsTestResultsGUI'))
2105  );
2106 
2107  $message = $DIC->language()->txt("test_has_datasets_warning_page_view");
2108 
2109  $msgBox = $DIC->ui()->factory()->messageBox()->info($message)->withLinks(array($link));
2110 
2111  $DIC->ui()->mainTemplate()->setCurrentBlock('mess');
2112  $DIC->ui()->mainTemplate()->setVariable(
2113  'MESSAGE',
2114  $DIC->ui()->renderer()->render($msgBox)
2115  );
2116  $DIC->ui()->mainTemplate()->parseCurrentBlock();
2117  } else {
2118  global $DIC;
2119  $ilToolbar = $DIC['ilToolbar'];
2120 
2121  $ilToolbar->addButton($this->lng->txt("ass_create_question"), $this->ctrl->getLinkTarget($this, "addQuestion"));
2122 
2123  if ($this->object->getPoolUsage()) {
2124  $ilToolbar->addSeparator();
2125 
2126  require_once 'Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php';
2127 
2129  }
2130 
2131  $ilToolbar->addSeparator();
2132  $ilToolbar->addButton($this->lng->txt("random_selection"), $this->ctrl->getLinkTarget($this, "randomselect"));
2133 
2134 
2135  global $DIC;
2136  $ilAccess = $DIC['ilAccess'];
2137  $ilUser = $DIC['ilUser'];
2138  $lng = $DIC['lng'];
2139  $ilCtrl = $DIC['ilCtrl'];
2140  $online_access = false;
2141  if ($this->object->getFixedParticipants()) {
2142  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
2143  $online_access_result = ilObjTestAccess::_lookupOnlineTestAccess($this->object->getId(), $ilUser->getId());
2144  if ($online_access_result === true) {
2145  $online_access = true;
2146  }
2147  }
2148 
2149  if (!$this->object->getOfflineStatus() && $this->object->isComplete($this->testQuestionSetConfigFactory->getQuestionSetConfig())) {
2150  if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id)) {
2151  $testSession = $this->testSessionFactory->getSession();
2152  $testSequence = $this->testSequenceFactory->getSequenceByTestSession($testSession);
2153 
2154  $testPlayerGUI = $this->testPlayerFactory->getPlayerGUI();
2155 
2156  $executable = $this->object->isExecutable($testSession, $ilUser->getId(), $allowPassIncrease = true);
2157 
2158  if ($executable["executable"]) {
2159  if ($testSession->getActiveId() > 0) {
2160  // resume test
2161 
2162  if ($testSequence->hasStarted($testSession)) {
2163  $execTestLabel = $this->lng->txt("tst_resume_test");
2164  $execTestLink = $this->ctrl->getLinkTarget($testPlayerGUI, 'resumePlayer');
2165  } else {
2166  $execTestLabel = $this->object->getStartTestLabel($testSession->getActiveId());
2167  $execTestLink = $this->ctrl->getLinkTarget($testPlayerGUI, 'startPlayer');
2168  }
2169  } else {
2170  // start new test
2171 
2172  $execTestLabel = $this->object->getStartTestLabel($testSession->getActiveId());
2173  $execTestLink = $this->ctrl->getLinkTarget($testPlayerGUI, 'startPlayer');
2174  }
2175 
2176  $ilToolbar->addSeparator();
2177  $ilToolbar->addButton($execTestLabel, $execTestLink);
2178  }
2179  }
2180  }
2181  }
2182  }
2183 
2184  $table_gui = new ilTestQuestionsTableGUI(
2185  $this,
2186  'questions',
2187  $this->object->getRefId()
2188  );
2189 
2191  is_array($_SESSION['tst_qst_move_' . $this->object->getTestId()])
2192  && count($_SESSION['tst_qst_move_' . $this->object->getTestId()])
2193  );
2194 
2195  $table_gui->setQuestionTitleLinksEnabled(!$total);
2196  $table_gui->setQuestionPositioningEnabled(!$total);
2197  $table_gui->setQuestionManagingEnabled(!$total);
2198  $table_gui->setObligatoryQuestionsHandlingEnabled($this->object->areObligationsEnabled());
2199 
2200  $table_gui->setTotalPoints($this->object->getFixedQuestionSetTotalPoints());
2201  $table_gui->setTotalWorkingTime($this->object->getFixedQuestionSetTotalWorkingTime());
2202 
2203  $table_gui->init();
2204 
2205  $table_gui->setData($this->object->getTestQuestions());
2206 
2207  $this->tpl->setCurrentBlock("adm_content");
2208  $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this));
2209  $this->tpl->setVariable('QUESTIONBROWSER', $table_gui->getHTML());
2210  $this->tpl->parseCurrentBlock();
2211  }
2212 
2218  {
2219  require_once 'Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php';
2220 
2221  $this->ctrl->setParameterByClass('ilTestQuestionBrowserTableGUI', ilTestQuestionBrowserTableGUI::CONTEXT_PARAMETER, $context);
2222 
2223  $this->ctrl->setParameterByClass('ilTestQuestionBrowserTableGUI', ilTestQuestionBrowserTableGUI::MODE_PARAMETER, ilTestQuestionBrowserTableGUI::MODE_BROWSE_POOLS);
2224 
2225  $toolbar->addButton($this->lng->txt("tst_browse_for_qpl_questions"), $this->ctrl->getLinkTargetByClass('ilTestQuestionBrowserTableGUI', ilTestQuestionBrowserTableGUI::CMD_BROWSE_QUESTIONS));
2226 
2227  $this->ctrl->setParameterByClass('ilTestQuestionBrowserTableGUI', ilTestQuestionBrowserTableGUI::MODE_PARAMETER, ilTestQuestionBrowserTableGUI::MODE_BROWSE_TESTS);
2228 
2229  $toolbar->addButton($this->lng->txt("tst_browse_for_tst_questions"), $this->ctrl->getLinkTargetByClass('ilTestQuestionBrowserTableGUI', ilTestQuestionBrowserTableGUI::CMD_BROWSE_QUESTIONS));
2230  }
2231 
2232  public function takenObject()
2233  {
2234  }
2235 
2243  public function historyObject()
2244  {
2245  global $DIC; /* @var ILIAS\DI\Container $DIC */
2246 
2247  $DIC->tabs()->activateTab(ilTestTabsManager::TAB_ID_HISTORY);
2248 
2249  include_once "./Modules/Test/classes/tables/class.ilTestHistoryTableGUI.php";
2250  $table_gui = new ilTestHistoryTableGUI($this, 'history');
2251  $table_gui->setTestObject($this->object);
2252  include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
2253  $log = &ilObjAssessmentFolder::_getLog(0, time(), $this->object->getId(), true);
2254  $table_gui->setData($log);
2255  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
2256  }
2257 
2258  public function initImportForm($a_new_type)
2259  {
2260  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2261  $form = new ilPropertyFormGUI();
2262  $form->setTarget("_top");
2263  $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
2264  $this->ctrl->setParameter($this, "new_type", $new_type);
2265  $form->setFormAction($this->ctrl->getFormAction($this));
2266  $form->setTitle($this->lng->txt("import_tst"));
2267 
2268  // file
2269  include_once("./Services/Form/classes/class.ilFileInputGUI.php");
2270  $fi = new ilFileInputGUI($this->lng->txt("import_file"), "xmldoc");
2271  $fi->setSuffixes(array("zip"));
2272  $fi->setRequired(true);
2273  $form->addItem($fi);
2274 
2275  // question pool
2276  include_once("./Modules/Test/classes/class.ilObjTest.php");
2277  $tst = new ilObjTest();
2278  $questionpools = $tst->getAvailableQuestionpools(true, false, true, true);
2279  if (count($questionpools)) {
2280  $options = array("-1" => $this->lng->txt("dont_use_questionpool"));
2281  foreach ($questionpools as $key => $value) {
2282  $options[$key] = $value["title"];
2283  }
2284 
2285  $pool = new ilSelectInputGUI($this->lng->txt("select_questionpool"), "qpl");
2286  $pool->setInfo($this->lng->txt('select_question_pool_info'));
2287  $pool->setOptions($options);
2288  $form->addItem($pool);
2289  }
2290 
2291  $form->addCommandButton("importFile", $this->lng->txt("import"));
2292  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
2293 
2294  return $form;
2295  }
2296 
2302  public function participantsActionObject()
2303  {
2304  $command = $_POST["command"];
2305  if (strlen($command)) {
2306  $method = $command . "Object";
2307  if (method_exists($this, $method)) {
2308  $this->$method();
2309  return;
2310  }
2311  }
2312  $this->ctrl->redirect($this, "participants");
2313  }
2314 
2322  public function printobject()
2323  {
2324  global $DIC;
2325  $ilAccess = $DIC['ilAccess'];
2326  $ilias = $DIC['ilias'];
2327  if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
2328  // allow only write access
2329  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
2330  $this->ctrl->redirect($this, "infoScreen");
2331  }
2332 
2333  $isPdfDeliveryRequest = isset($_GET['pdf']) && $_GET['pdf'];
2334 
2335  $this->getTabsManager()->getQuestionsSubTabs();
2336  $template = new ilTemplate("tpl.il_as_tst_print_test_confirm.html", true, true, "Modules/Test");
2337 
2338  if (!$isPdfDeliveryRequest) { // #15243
2339  $this->ctrl->setParameter($this, "pdf", "1");
2340  $template->setCurrentBlock("pdf_export");
2341  $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "print"));
2342  $this->ctrl->setParameter($this, "pdf", "");
2343  $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
2344  $template->parseCurrentBlock();
2345 
2346  $template->setCurrentBlock("navigation_buttons");
2347  $template->setVariable("BUTTON_PRINT", $this->lng->txt("print"));
2348  $template->parseCurrentBlock();
2349  }
2350  // prepare generation before contents are processed (for mathjax)
2351  else {
2353  }
2354 
2355  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
2356 
2357  global $DIC;
2358  $ilUser = $DIC['ilUser'];
2359  $print_date = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y"));
2360  $max_points = 0;
2361  $counter = 1;
2362 
2363  require_once 'Modules/Test/classes/class.ilTestQuestionHeaderBlockBuilder.php';
2364  $questionHeaderBlockBuilder = new ilTestQuestionHeaderBlockBuilder($this->lng);
2365  $questionHeaderBlockBuilder->setHeaderMode($this->object->getTitleOutput());
2366 
2367  if ($isPdfDeliveryRequest) {
2368  require_once 'Services/WebAccessChecker/classes/class.ilWACSignedPath.php';
2370  }
2371 
2372  foreach ($this->object->questions as $question) {
2373  $template->setCurrentBlock("question");
2374  $question_gui = $this->object->createQuestionGUI("", $question);
2375 
2376  if ($isPdfDeliveryRequest) {
2377  $question_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_PRINT_PDF);
2378  }
2379 
2380  $questionHeaderBlockBuilder->setQuestionTitle($question_gui->object->getTitle());
2381  $questionHeaderBlockBuilder->setQuestionPoints($question_gui->object->getMaximumPoints());
2382  $questionHeaderBlockBuilder->setQuestionPosition($counter);
2383  $template->setVariable("QUESTION_HEADER", $questionHeaderBlockBuilder->getHTML());
2384 
2385  $template->setVariable("TXT_QUESTION_ID", $this->lng->txt('question_id_short'));
2386  $template->setVariable("QUESTION_ID", $question_gui->object->getId());
2387  $result_output = $question_gui->getSolutionOutput("", null, false, true, false, $this->object->getShowSolutionFeedback());
2388  $template->setVariable("SOLUTION_OUTPUT", $result_output);
2389  $template->parseCurrentBlock("question");
2390  $counter++;
2391  $max_points += $question_gui->object->getMaximumPoints();
2392  }
2393 
2394  $template->setVariable("TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
2395  $template->setVariable("PRINT_TEST", ilUtil::prepareFormOutput($this->lng->txt("tst_print")));
2396  $template->setVariable("TXT_PRINT_DATE", ilUtil::prepareFormOutput($this->lng->txt("date")));
2397  $template->setVariable("VALUE_PRINT_DATE", ilUtil::prepareFormOutput(strftime("%c", $print_date)));
2398  $template->setVariable("TXT_MAXIMUM_POINTS", ilUtil::prepareFormOutput($this->lng->txt("tst_maximum_points")));
2399  $template->setVariable("VALUE_MAXIMUM_POINTS", ilUtil::prepareFormOutput($max_points));
2400 
2401  if ($isPdfDeliveryRequest) {
2402  require_once 'Modules/Test/classes/class.ilTestPDFGenerator.php';
2404  } else {
2405  $this->tpl->setVariable("PRINT_CONTENT", $template->get());
2406  }
2407  }
2408 
2416  public function reviewobject()
2417  {
2418  global $DIC;
2419  $ilAccess = $DIC['ilAccess'];
2420 
2421  if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
2422  // allow only write access
2423  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
2424  $this->ctrl->redirect($this, "infoScreen");
2425  }
2426  $this->getTabsManager()->getQuestionsSubTabs();
2427  $template = new ilTemplate("tpl.il_as_tst_print_test_confirm.html", true, true, "Modules/Test");
2428 
2429  $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
2430 
2431  $isPdfDeliveryRequest = isset($_GET['pdf']) && $_GET['pdf'];
2432 
2433  $max_points = 0;
2434  $counter = 1;
2435 
2436  require_once 'Modules/Test/classes/class.ilTestQuestionHeaderBlockBuilder.php';
2437  $questionHeaderBlockBuilder = new ilTestQuestionHeaderBlockBuilder($this->lng);
2438  $questionHeaderBlockBuilder->setHeaderMode($this->object->getTitleOutput());
2439 
2440  if ($isPdfDeliveryRequest) {
2441  require_once 'Services/WebAccessChecker/classes/class.ilWACSignedPath.php';
2443 
2444  // prepare generation before contents are processed (for mathjax)
2446  }
2447 
2448  foreach ($this->object->questions as $question) {
2449  $template->setCurrentBlock("question");
2450  $question_gui = $this->object->createQuestionGUI("", $question);
2451  $question_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_PREVIEW);
2452 
2453  $questionHeaderBlockBuilder->setQuestionTitle($question_gui->object->getTitle());
2454  $questionHeaderBlockBuilder->setQuestionPoints($question_gui->object->getMaximumPoints());
2455  $questionHeaderBlockBuilder->setQuestionPosition($counter);
2456  $template->setVariable("QUESTION_HEADER", $questionHeaderBlockBuilder->getHTML());
2457 
2458  $template->setVariable("SOLUTION_OUTPUT", $question_gui->getPreview(false));
2459  $template->parseCurrentBlock("question");
2460  $counter++;
2461  $max_points += $question_gui->object->getMaximumPoints();
2462  }
2463 
2464  $template->setVariable("TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
2465  $template->setVariable("PRINT_TEST", ilUtil::prepareFormOutput($this->lng->txt("review_view")));
2466  $template->setVariable("TXT_PRINT_DATE", ilUtil::prepareFormOutput($this->lng->txt("date")));
2467  $usedRelativeDates = ilDatePresentation::useRelativeDates();
2469  $template->setVariable(
2470  "VALUE_PRINT_DATE",
2472  );
2473  ilDatePresentation::setUseRelativeDates($usedRelativeDates);
2474  $template->setVariable("TXT_MAXIMUM_POINTS", ilUtil::prepareFormOutput($this->lng->txt("tst_maximum_points")));
2475  $template->setVariable("VALUE_MAXIMUM_POINTS", ilUtil::prepareFormOutput($max_points));
2476 
2477  if ($isPdfDeliveryRequest) {
2478  require_once 'Modules/Test/classes/class.ilTestPDFGenerator.php';
2480  } else {
2481  $this->ctrl->setParameter($this, "pdf", "1");
2482  $template->setCurrentBlock("pdf_export");
2483  $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "review"));
2484  $this->ctrl->setParameter($this, "pdf", "");
2485  $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
2486  $template->parseCurrentBlock();
2487 
2488  $template->setCurrentBlock("navigation_buttons");
2489  $template->setVariable("BUTTON_PRINT", $this->lng->txt("print"));
2490  $template->parseCurrentBlock();
2491 
2492 
2493  $this->tpl->setVariable("PRINT_CONTENT", $template->get());
2494  }
2495  }
2496 
2500  public function defaultsObject()
2501  {
2507  global $DIC;
2508  $ilAccess = $DIC['ilAccess'];
2509  $ilToolbar = $DIC['ilToolbar'];
2510  $tpl = $DIC['tpl'];
2511 
2512  if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
2513  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
2514  $this->ctrl->redirect($this, "infoScreen");
2515  }
2516 
2517  global $DIC; /* @var ILIAS\DI\Container $DIC */
2518 
2519  $DIC->tabs()->activateTab(ilTestTabsManager::TAB_ID_SETTINGS);
2520 
2521  $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'addDefaults'));
2522  $ilToolbar->addFormButton($this->lng->txt('add'), 'addDefaults');
2523  require_once 'Services/Form/classes/class.ilTextInputGUI.php';
2524  $ilToolbar->addInputItem(new ilTextInputGUI($this->lng->txt('tst_defaults_defaults_of_test'), 'name'), true);
2525 
2526  require_once 'Modules/Test/classes/tables/class.ilTestPersonalDefaultSettingsTableGUI.php';
2527  $table = new ilTestPersonalDefaultSettingsTableGUI($this, 'defaults');
2528  $defaults = $this->object->getAvailableDefaults();
2529  $table->setData((array) $defaults);
2530  $tpl->setContent($table->getHTML());
2531  }
2532 
2536  public function deleteDefaultsObject()
2537  {
2538  if (isset($_POST['chb_defaults']) && is_array($_POST['chb_defaults']) && count($_POST['chb_defaults'])) {
2539  foreach ($_POST['chb_defaults'] as $test_default_id) {
2540  $this->object->deleteDefaults($test_default_id);
2541  }
2542  } else {
2543  ilUtil::sendInfo($this->lng->txt('select_one'));
2544  }
2545  $this->defaultsObject();
2546  }
2547 
2552  {
2553  $this->applyDefaultsObject(true);
2554  return;
2555  }
2556 
2560  public function applyDefaultsObject($confirmed = false)
2561  {
2562  if (!is_array($_POST["chb_defaults"]) || 1 !== count($_POST["chb_defaults"])) {
2564  $this->lng->txt("tst_defaults_apply_select_one")
2565  );
2566 
2567  return $this->defaultsObject();
2568  }
2569 
2570  // do not apply if user datasets exist
2571  if ($this->object->evalTotalPersons() > 0) {
2573  $this->lng->txt("tst_defaults_apply_not_possible")
2574  );
2575 
2576  return $this->defaultsObject();
2577  }
2578 
2579  $defaults = &$this->object->getTestDefaults($_POST["chb_defaults"][0]);
2580  $defaultSettings = unserialize($defaults["defaults"]);
2581 
2582  if (isset($defaultSettings['isRandomTest'])) {
2583  if ($defaultSettings['isRandomTest']) {
2584  $newQuestionSetType = ilObjTest::QUESTION_SET_TYPE_RANDOM;
2585  $this->object->setQuestionSetType(ilObjTest::QUESTION_SET_TYPE_RANDOM);
2586  } else {
2587  $newQuestionSetType = ilObjTest::QUESTION_SET_TYPE_FIXED;
2588  $this->object->setQuestionSetType(ilObjTest::QUESTION_SET_TYPE_FIXED);
2589  }
2590  } elseif (isset($defaultSettings['questionSetType'])) {
2591  $newQuestionSetType = $defaultSettings['questionSetType'];
2592  }
2593  $oldQuestionSetType = $this->object->getQuestionSetType();
2594  $questionSetTypeSettingSwitched = ($oldQuestionSetType != $newQuestionSetType);
2595 
2596  $oldQuestionSetConfig = $this->testQuestionSetConfigFactory->getQuestionSetConfigByType($oldQuestionSetType);
2597 
2598  switch (true) {
2599  case !$questionSetTypeSettingSwitched:
2600  case !$oldQuestionSetConfig->doesQuestionSetRelatedDataExist():
2601  case $confirmed:
2602 
2603  break;
2604 
2605  default:
2606 
2607  require_once 'Modules/Test/classes/confirmations/class.ilTestSettingsChangeConfirmationGUI.php';
2608  $confirmation = new ilTestSettingsChangeConfirmationGUI($this->lng, $this->object);
2609 
2610  $confirmation->setFormAction($this->ctrl->getFormAction($this));
2611  $confirmation->setCancel($this->lng->txt('cancel'), 'defaults');
2612  $confirmation->setConfirm($this->lng->txt('confirm'), 'confirmedApplyDefaults');
2613 
2614  $confirmation->setOldQuestionSetType($this->object->getQuestionSetType());
2615  $confirmation->setNewQuestionSetType($newQuestionSetType);
2616  $confirmation->setQuestionLossInfoEnabled(false);
2617  $confirmation->build();
2618 
2619  $confirmation->populateParametersFromPost();
2620 
2621  $this->tpl->setContent($this->ctrl->getHTML($confirmation));
2622 
2623  return;
2624  }
2625 
2626  if ($questionSetTypeSettingSwitched && !$this->object->getOfflineStatus()) {
2627  $this->object->setOfflineStatus(true);
2628 
2629  $info = $this->lng->txt("tst_set_offline_due_to_switched_question_set_type_setting");
2630 
2631  ilUtil::sendInfo($info, true);
2632  }
2633 
2634  $this->object->applyDefaults($defaults);
2635 
2636  ilUtil::sendSuccess($this->lng->txt("tst_defaults_applied"), true);
2637 
2638  if ($questionSetTypeSettingSwitched && $oldQuestionSetConfig->doesQuestionSetRelatedDataExist()) {
2639  $oldQuestionSetConfig->removeQuestionSetRelatedData();
2640  }
2641 
2642  $this->ctrl->redirect($this, 'defaults');
2643  }
2644 
2648  public function addDefaultsObject()
2649  {
2650  if (strlen($_POST["name"]) > 0) {
2651  $this->object->addDefaults($_POST['name']);
2652  } else {
2653  ilUtil::sendInfo($this->lng->txt("tst_defaults_enter_name"));
2654  }
2655  $this->defaultsObject();
2656  }
2657 
2659  {
2660  if (in_array($this->ctrl->getCmdClass(), self::$infoScreenChildClasses)) {
2661  return true;
2662  }
2663 
2664  return false;
2665  }
2666 
2672  public function infoScreenObject()
2673  {
2674  #if( !include 'competenzenRocker.php' ) exit;
2675 
2676  $this->ctrl->setCmd("showSummary");
2677  $this->ctrl->setCmdClass("ilinfoscreengui");
2678  $this->infoScreen();
2679  }
2680 
2681  public function redirectToInfoScreenObject()
2682  {
2683  $this->ctrl->setCmd("showSummary");
2684  $this->ctrl->setCmdClass("ilinfoscreengui");
2685  $this->infoScreen($_GET['lock']);
2686  }
2687 
2691  public function infoScreen($session_lock = "")
2692  {
2693  global $DIC; /* @var ILIAS\DI\Container $DIC */
2699  global $DIC;
2700  $ilAccess = $DIC['ilAccess'];
2701  $ilUser = $DIC['ilUser'];
2702  $ilToolbar = $DIC['ilToolbar'];
2703 
2704  if ($_GET['createRandomSolutions']) {
2705  global $DIC;
2706  $ilCtrl = $DIC['ilCtrl'];
2707 
2708  $this->object->createRandomSolutions($_GET['createRandomSolutions']);
2709 
2710  $ilCtrl->redirect($this);
2711  }
2712 
2713  if (!$ilAccess->checkAccess("read", "", $this->ref_id)) {
2714  $this->ilias->raiseError($this->lng->txt("msg_no_perm_read"), $this->ilias->error_obj->MESSAGE);
2715  }
2716 
2717  $DIC->tabs()->activateTab(ilTestTabsManager::TAB_ID_INFOSCREEN);
2718 
2719  $this->trackTestObjectReadEvent();
2720 
2721  include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
2722  $info = new ilInfoScreenGUI($this);
2723  $info->setOpenFormTag(false);
2724 
2725  if ($this->isCommandClassAnyInfoScreenChild()) {
2726  return $this->ctrl->forwardCommand($info);
2727  }
2728 
2729  require_once 'Modules/Test/classes/class.ilTestInfoScreenToolbarFactory.php';
2730  $toolbarFactory = new ilTestInfoScreenToolbarFactory();
2731  $toolbarFactory->setTestOBJ($this->object);
2732  $toolbar = $toolbarFactory->getToolbarInstance();
2733 
2734  $toolbar->setGlobalToolbar($GLOBALS['DIC']['ilToolbar']);
2735  $toolbar->setCloseFormTag(false);
2736 
2737  $toolbar->setSessionLockString($session_lock);
2738  $toolbar->build();
2739  $toolbar->sendMessages();
2740 
2741  if ($this->object->getShowInfo()) {
2742  $info->enablePrivateNotes();
2743  }
2744 
2745  if (strlen($this->object->getIntroduction())) {
2746  $info->addSection($this->lng->txt("tst_introduction"));
2747  $info->addProperty("", $this->object->prepareTextareaOutput($this->object->getIntroduction(), true) .
2748  $info->getHiddenToggleButton());
2749  } else {
2750  $info->addSection("");
2751  $info->addProperty("", $info->getHiddenToggleButton());
2752  }
2753 
2754  $info->addSection($this->lng->txt("tst_general_properties"));
2755  if ($this->object->getShowInfo()) {
2756  $info->addProperty($this->lng->txt("author"), $this->object->getAuthor());
2757  $info->addProperty($this->lng->txt("title"), $this->object->getTitle());
2758  }
2759  if (!$this->object->getOfflineStatus() && $this->object->isComplete($this->testQuestionSetConfigFactory->getQuestionSetConfig())) {
2760  // note smeyer: $online_access is not defined here
2761  if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id)) {
2762  if ($this->object->getShowInfo() || !$this->object->getForceJS()) {
2763  // use javascript
2764  $checked_javascript = false;
2765  if ($this->object->getJavaScriptOutput()) {
2766  $checked_javascript = true;
2767  }
2768  }
2769  // hide previous results
2770  if (!$this->object->isRandomTest() && !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
2771  if ($this->object->getNrOfTries() != 1) {
2772  if ($this->object->getUsePreviousAnswers() == 0) {
2773  if ($this->object->getShowInfo()) {
2774  $info->addProperty($this->lng->txt("tst_use_previous_answers"), $this->lng->txt("tst_dont_use_previous_answers"));
2775  }
2776  } else {
2777  $use_previous_answers = false;
2778  if ($ilUser->prefs["tst_use_previous_answers"]) {
2779  $checked_previous_answers = true;
2780  }
2781  $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);
2782  }
2783  }
2784  }
2785  }
2786  }
2787 
2788  $info->hideFurtherSections(false);
2789 
2790  if ($this->object->getShowInfo()) {
2791  $info->addSection($this->lng->txt("tst_sequence_properties"));
2792  $info->addProperty($this->lng->txt("tst_sequence"), $this->lng->txt(($this->object->getSequenceSettings() == TEST_FIXED_SEQUENCE)? "tst_sequence_fixed":"tst_sequence_postpone"));
2793 
2794  $info->addSection($this->lng->txt("tst_heading_scoring"));
2795  $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"));
2796  $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"));
2797  if ($this->object->isRandomTest()) {
2798  $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"));
2799  }
2800 
2801  $info->addSection($this->lng->txt("tst_score_reporting"));
2802  $score_reporting_text = "";
2803  switch ($this->object->getScoreReporting()) {
2805  $score_reporting_text = $this->lng->txt("tst_report_after_test");
2806  break;
2808  $score_reporting_text = $this->lng->txt("tst_report_after_first_question");
2809  break;
2811  $score_reporting_text = $this->lng->txt("tst_report_after_date");
2812  break;
2814  $score_reporting_text = $this->lng->txt("tst_report_after_passed");
2815  break;
2816  default:
2817  $score_reporting_text = $this->lng->txt("tst_report_never");
2818  break;
2819  }
2820  $info->addProperty($this->lng->txt("tst_score_reporting"), $score_reporting_text);
2821  $reporting_date = $this->object->getReportingDate();
2822  if ($reporting_date) {
2823  #preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $reporting_date, $matches);
2824  #$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]));
2825  #$info->addProperty($this->lng->txt("tst_score_reporting_date"), $txt_reporting_date);
2826  $info->addProperty(
2827  $this->lng->txt('tst_score_reporting_date'),
2829  );
2830  }
2831 
2832  $info->addSection($this->lng->txt("tst_session_settings"));
2833  $info->addProperty($this->lng->txt("tst_nr_of_tries"), ($this->object->getNrOfTries() == 0)?$this->lng->txt("unlimited"):$this->object->getNrOfTries());
2834  if ($this->object->getNrOfTries() != 1) {
2835  $info->addProperty($this->lng->txt("tst_nr_of_tries_of_user"), ($toolbar->getTestSession()->getPass() == false)?$this->lng->txt("tst_no_tries"):$toolbar->getTestSequence()->getPass());
2836  }
2837 
2838  if ($this->object->getEnableProcessingTime()) {
2839  $info->addProperty($this->lng->txt("tst_processing_time"), $this->object->getProcessingTime());
2840  }
2841  if (strlen($this->object->getAllowedUsers()) && ($this->object->getAllowedUsersTimeGap())) {
2842  $info->addProperty($this->lng->txt("tst_allowed_users"), $this->object->getAllowedUsers());
2843  }
2844 
2845  $starting_time = $this->object->getStartingTime();
2846  if ($this->object->isStartingTimeEnabled() && $starting_time != 0) {
2847  $info->addProperty($this->lng->txt("tst_starting_time"), ilDatePresentation::formatDate(new ilDateTime($starting_time, IL_CAL_UNIX)));
2848  }
2849  $ending_time = $this->object->getEndingTime();
2850  if ($this->object->isEndingTimeEnabled() && $ending_time != 0) {
2851  $info->addProperty($this->lng->txt("tst_ending_time"), ilDatePresentation::formatDate(new ilDateTime($ending_time, IL_CAL_UNIX)));
2852  }
2853  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
2854  // forward the command
2855  }
2856 
2857  $this->ctrl->forwardCommand($info);
2858  }
2859 
2860  protected function removeImportFailsObject()
2861  {
2862  require_once 'Modules/TestQuestionPool/classes/questions/class.ilAssQuestionSkillAssignmentImportFails.php';
2863  $qsaImportFails = new ilAssQuestionSkillAssignmentImportFails($this->object->getId());
2864  $qsaImportFails->deleteRegisteredImportFails();
2865 
2866  require_once 'Modules/Test/classes/class.ilTestSkillLevelThresholdImportFails.php';
2867  $sltImportFails = new ilTestSkillLevelThresholdImportFails($this->object->getId());
2868  $sltImportFails->deleteRegisteredImportFails();
2869 
2870  $this->ctrl->redirect($this, 'infoScreen');
2871  }
2872 
2873  public function addLocatorItems()
2874  {
2875  global $DIC;
2876  $ilLocator = $DIC['ilLocator'];
2877  switch ($this->ctrl->getCmd()) {
2878  case "run":
2879  case "infoScreen":
2880  case "redirectToInfoScreen":
2881  case "start":
2882  case "resume":
2883  case "previous":
2884  case "next":
2885  case "summary":
2886  case "finishTest":
2887  case "outCorrectSolution":
2888  case "passDetails":
2889  case "showAnswersOfUser":
2890  case "outUserResultsOverview":
2891  case "backFromSummary":
2892  case "show_answers":
2893  case "setsolved":
2894  case "resetsolved":
2895  case "outTestSummary":
2896  case "outQuestionSummary":
2897  case "gotoQuestion":
2898  case "selectImagemapRegion":
2899  case "confirmSubmitAnswers":
2900  case "finalSubmission":
2901  case "postpone":
2902  case "outUserPassDetails":
2903  case "checkPassword":
2904  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"), "", $_GET["ref_id"]);
2905  break;
2906  case "eval_stat":
2907  case "evalAllUsers":
2908  case "evalUserDetail":
2909  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "eval_stat"), "", $_GET["ref_id"]);
2910  break;
2911  case "create":
2912  case "save":
2913  case "cancel":
2914  case "importFile":
2915  case "cloneAll":
2916  case "importVerifiedFile":
2917  case "cancelImport":
2918  break;
2919  default:
2920  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
2921  break;
2922  }
2923  }
2924 
2925  public function statisticsObject()
2926  {
2927  }
2928 
2932  public function certificateObject()
2933  {
2934  global $DIC; /* @var ILIAS\DI\Container $DIC */
2935 
2936  $DIC->tabs()->activateTab(ilTestTabsManager::TAB_ID_SETTINGS);
2937 
2938  $guiFactory = new ilCertificateGUIFactory();
2939  $output_gui = $guiFactory->create($this->object);
2940 
2941  $output_gui->certificateEditor();
2942  }
2943 
2949  public function getTabs()
2950  {
2951  global $DIC;
2952  $help = $DIC['ilHelp'];
2953  $help->setScreenIdComponent("tst");
2954 
2955  if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
2956  require_once 'Services/Link/classes/class.ilLink.php';
2957  $courseLink = ilLink::_getLink($this->getObjectiveOrientedContainer()->getRefId());
2958  $this->getTabsManager()->setParentBackLabel($this->lng->txt('back_to_objective_container'));
2959  $this->getTabsManager()->setParentBackHref($courseLink);
2960  }
2961 
2962  $this->getTabsManager()->perform();
2963  }
2964 
2965  public static function accessViolationRedirect()
2966  {
2967  global $DIC; /* @var ILIAS\DI\Container $DIC */
2968 
2969  ilUtil::sendInfo($DIC->language()->txt("no_permission"), true);
2970  $DIC->ctrl()->redirectByClass('ilObjTestGUI', "infoScreen");
2971  }
2972 
2981  public static function _goto($a_target)
2982  {
2983  global $DIC;
2984  $ilAccess = $DIC['ilAccess'];
2985  $ilErr = $DIC['ilErr'];
2986  $lng = $DIC['lng'];
2987 
2988  if ($ilAccess->checkAccess("read", "", $a_target)) {
2989  //include_once "./Services/Utilities/classes/class.ilUtil.php";
2990  $_GET["baseClass"] = "ilObjTestGUI";
2991  $_GET["cmd"] = "infoScreen";
2992  $_GET["ref_id"] = $a_target;
2993  include_once("ilias.php");
2994  exit;
2995  //ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=infoScreen&ref_id=$a_target");
2996  } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
2997  ilUtil::sendInfo(sprintf(
2998  $lng->txt("msg_no_perm_read_item"),
3000  ), true);
3002  }
3003 
3004  $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
3005  }
3006 
3013  public function buildPageViewToolbar($qid = 0)
3014  {
3015  if ($this->create_question_mode) {
3016  return;
3017  }
3018 
3019  global $DIC;
3020  $ilToolbar = $DIC['ilToolbar'];
3021  $ilCtrl = $DIC['ilCtrl'];
3022  $lng = $DIC['lng'];
3023 
3024  require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
3025 
3026  $ilCtrl->saveParameter($this, 'q_mode');
3027 
3028  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'test_express_mode', 1);
3029  $ilCtrl->setParameter($this, 'test_express_mode', 1);
3030  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'q_id', $_REQUEST['q_id']);
3031  $ilCtrl->setParameter($this, 'q_id', $_REQUEST['q_id']);
3032  $ilToolbar->setFormAction($ilCtrl->getFormActionByClass('iltestexpresspageobjectgui', 'edit'));
3033 
3034  if ($this->object->evalTotalPersons() == 0) {
3035  /*
3036  include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
3037  $pool = new ilObjQuestionPool();
3038  $questionTypes = $pool->getQuestionTypes();$options = array();
3039  foreach($questionTypes as $label => $data) {
3040  $options[$data['question_type_id']] = $label;
3041  }
3042 
3043  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
3044  $si = new ilSelectInputGUI($lng->txt("test_add_new_question"), "qtype");
3045  $si->setOptions($options);
3046  $ilToolbar->addInputItem($si, true);
3047  /*
3048  // use pool
3049  if ($this->object->isExpressModeQuestionPoolAllowed()) {
3050  include_once("./Services/Form/classes/class.ilCheckboxInputGUI.php");
3051  $cb = new ilCheckboxInputGUI($lng->txt("test_use_pool"), "use_pool");
3052  $ilToolbar->addInputItem($cb, true);
3053  }
3054  */
3055  $ilToolbar->addFormButton($lng->txt("ass_create_question"), "addQuestion");
3056 
3057  $ilToolbar->addSeparator();
3058 
3059  if ($this->object->getPoolUsage()) {
3060  require_once 'Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php';
3061 
3063 
3064  $show_separator = true;
3065  }
3066  }
3067 
3068  $questions = $this->object->getQuestionTitlesAndIndexes();
3069 
3070  // desc
3071  $options = array();
3072  foreach ($questions as $id => $label) {
3073  $options[$id] = $label . ' [' . $this->lng->txt('question_id_short') . ': ' . $id . ']';
3074  }
3075 
3076  $optionKeys = array_keys($options);
3077 
3078  if (!$options) {
3079  $options[] = $lng->txt('none');
3080  }
3081  //else if (count($options) > 1) {
3082 // $addSeparator = false;
3083 // if ($optionKeys[0] != $qid) {
3084 // //$ilToolbar->addFormButton($lng->txt("test_prev_question"), "prevQuestion");
3085 // $ilToolbar->addLink($lng->txt("test_prev_question"), $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'prevQuestion'));
3086 // $addSeparator = true;
3087 // }
3088  // else {
3089  // $ilToolbar->addSpacer(45);
3090  // }
3091 //
3092 // if ($optionKeys[count($optionKeys)-1] != $qid) {
3093 // //$ilToolbar->addFormButton($lng->txt("test_next_question"), "nextQuestion");
3094 // $ilToolbar->addLink($lng->txt("test_next_question"), $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'nextQuestion'));
3095  // $addSeparator = true;
3096 // }
3097  // else {
3098  // $ilToolbar->addSpacer(45);
3099  // }
3100 //
3101 // //if ($addSeparator) {
3102 // $ilToolbar->addSeparator();
3103 // //}
3104 
3105  if (count($questions)) {
3106  if (isset($show_separator) && $show_separator) {
3107  $ilToolbar->addSeparator();
3108  }
3109 
3110  $btn = ilLinkButton::getInstance();
3111  $btn->setCaption("test_prev_question");
3112  $btn->setUrl($ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'prevQuestion'));
3113  $ilToolbar->addButtonInstance($btn);
3114 
3115  if (count($options) <= 1 || $optionKeys[0] == $qid) {
3116  $btn->setDisabled(true);
3117  }
3118 
3119  $btn = ilLinkButton::getInstance();
3120  $btn->setCaption("test_next_question");
3121  $btn->setUrl($ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'nextQuestion'));
3122  $ilToolbar->addButtonInstance($btn);
3123 
3124  if (count($options) <= 1 || $optionKeys[count($optionKeys) - 1] == $qid) {
3125  $btn->setDisabled(true);
3126  }
3127  }
3128 
3129  if (count($questions) > 1) {
3130  $ilToolbar->addSeparator();
3131 
3132  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
3133  $si = new ilSelectInputGUI($lng->txt("test_jump_to"), "q_id");
3134  $si->addCustomAttribute("onChange=\"forms['ilToolbar'].submit();\"");
3135  $si->setOptions($options);
3136 
3137  if ($qid) {
3138  $si->setValue($qid);
3139  }
3140 
3141  $ilToolbar->addInputItem($si, true);
3142  }
3143 
3144  $total = $this->object->evalTotalPersons();
3145 
3146  /*if (count($options)) {
3147  include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
3148  $si = new ilSelectInputGUI($lng->txt("test_jump_to"), "q_id");
3149  $si->addCustomAttribute("onChange=\"forms['ilToolbar'].submit();\"");
3150  $si->setOptions($options);
3151 
3152  if ($qid) {
3153  $si->setValue($qid);
3154  }
3155 
3156  $ilToolbar->addInputItem($si, true);
3157  }*/
3158 
3159  if (count($questions) && !$total) {
3160  $ilCtrl->setParameter($this, 'q_id', $_REQUEST['q_id']);
3161  $ilToolbar->addSeparator();
3162  $ilToolbar->addButton($lng->txt("test_delete_page"), $ilCtrl->getLinkTarget($this, "removeQuestions"));
3163  }
3164 
3165  if (count($questions) > 1 && !$total) {
3166  $ilToolbar->addSeparator();
3167  $ilToolbar->addButton($lng->txt("test_move_page"), $ilCtrl->getLinkTarget($this, "movePageForm"));
3168  }
3169 
3170  global $DIC;
3171  $ilAccess = $DIC['ilAccess'];
3172  $ilUser = $DIC['ilUser'];
3173 
3174  $online_access = false;
3175  if ($this->object->getFixedParticipants()) {
3176  include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
3177  $online_access_result = ilObjTestAccess::_lookupOnlineTestAccess($this->object->getId(), $ilUser->getId());
3178  if ($online_access_result === true) {
3179  $online_access = true;
3180  }
3181  }
3182 
3183  if (!$this->object->getOfflineStatus() && $this->object->isComplete($this->testQuestionSetConfigFactory->getQuestionSetConfig())) {
3184  if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id)) {
3185  $testSession = $this->testSessionFactory->getSession();
3186 
3187  $executable = $this->object->isExecutable($testSession, $ilUser->getId(), $allowPassIncrease = true);
3188 
3189  if ($executable["executable"]) {
3190  $player_factory = new ilTestPlayerFactory($this->object);
3191  $player_instance = $player_factory->getPlayerGUI();
3192 
3193  if ($testSession->getActiveId() > 0) {
3194  $ilToolbar->addSeparator();
3195  $ilToolbar->addButton($lng->txt('tst_resume_test'), $ilCtrl->getLinkTarget($player_instance, 'resumePlayer'));
3196  } else {
3197  $ilToolbar->addSeparator();
3198  $ilToolbar->addButton($lng->txt('tst_start_test'), $ilCtrl->getLinkTarget($player_instance, 'startTest'));
3199  }
3200  }
3201  }
3202  }
3203  }
3204 
3205  public function copyQuestionsToPoolObject()
3206  {
3207  $this->copyQuestionsToPool($_REQUEST['q_id'], $_REQUEST['sel_qpl']);
3208  $this->ctrl->redirect($this, 'questions');
3209  }
3210 
3211  public function copyQuestionsToPool($questionIds, $qplId)
3212  {
3213  $newIds = array();
3214  foreach ($questionIds as $q_id) {
3215  $newId = $this->copyQuestionToPool($q_id, $qplId);
3216  $newIds[$q_id] = $newId;
3217  }
3218 
3219  $result = new stdClass();
3220  $result->ids = $newIds;
3221  $result->qpoolid = $qplId;
3222 
3223  return $result;
3224  }
3225 
3226  public function copyQuestionToPool($sourceQuestionId, $targetParentId)
3227  {
3228  require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
3229  $question_gui = assQuestion::instantiateQuestionGUI($sourceQuestionId);
3230 
3231  $newtitle = $question_gui->object->getTitle();
3232  if ($question_gui->object->questionTitleExists($targetParentId, $question_gui->object->getTitle())) {
3233  $counter = 2;
3234  while ($question_gui->object->questionTitleExists($targetParentId, $question_gui->object->getTitle() . " ($counter)")) {
3235  $counter++;
3236  }
3237  $newtitle = $question_gui->object->getTitle() . " ($counter)";
3238  }
3239 
3240  return $question_gui->object->createNewOriginalFromThisDuplicate($targetParentId, $newtitle);
3241  }
3242 
3247  {
3248  global $DIC;
3249  $ilObjDataCache = $DIC['ilObjDataCache'];
3250 
3251  $qplId = $ilObjDataCache->lookupObjId($_REQUEST['sel_qpl']);
3252  $result = $this->copyQuestionsToPool($_REQUEST['q_id'], $qplId);
3253 
3254  foreach ($result->ids as $oldId => $newId) {
3255  $questionInstance = assQuestion::_instanciateQuestion($oldId);
3256 
3257  if (assQuestion::originalQuestionExists($questionInstance->getOriginalId())) {
3258  $oldOriginal = assQuestion::_instanciateQuestion($questionInstance->getOriginalId());
3259  $oldOriginal->delete($oldOriginal->getId());
3260  }
3261 
3262  $questionInstance->setNewOriginalId($newId);
3263  }
3264 
3265  ilUtil::sendSuccess($this->lng->txt('tst_qst_added_to_pool_' . (count($result->ids) > 1 ? 'p' : 's')), true);
3266  $this->ctrl->redirect($this, 'questions');
3267  }
3268 
3269  private function getQuestionpoolCreationForm()
3270  {
3271  global $DIC;
3272  $lng = $DIC['lng'];
3273  include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
3274  $form = new ilPropertyFormGUI();
3275 
3276  $title = new ilTextInputGUI($lng->txt('title'), 'title');
3277  $title->setRequired(true);
3278  $form->addItem($title);
3279 
3280  $description = new ilTextAreaInputGUI($lng->txt('description'), 'description');
3281  $form->addItem($description);
3282 
3283  $form->addCommandButton('createQuestionPoolAndCopy', $lng->txt('create'));
3284 
3285  if (isset($_REQUEST['q_id']) && is_array($_REQUEST['q_id'])) {
3286  foreach ($_REQUEST['q_id'] as $id) {
3287  $hidden = new ilHiddenInputGUI('q_id[]');
3288  $hidden->setValue($id);
3289  $form->addItem($hidden);
3290  }
3291  }
3292 
3293  return $form;
3294  }
3295 
3296  public function copyToQuestionpoolObject()
3297  {
3298  $this->createQuestionpoolTargetObject('copyQuestionsToPool');
3299  }
3300 
3302  {
3303  global $DIC;
3304  $lng = $DIC['lng'];
3305 
3306  require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
3307 
3308  // #13761; All methods use for this request should be revised, thx japo ;-)
3309  if (
3310  'copyAndLinkToQuestionpool' == $this->ctrl->getCmd() &&
3311  (!isset($_REQUEST['q_id']) || !is_array($_REQUEST['q_id']))
3312  ) {
3313  ilUtil::sendFailure($this->lng->txt('tst_no_question_selected_for_moving_to_qpl'), true);
3314  $this->ctrl->redirect($this, 'questions');
3315  }
3316 
3317  if (isset($_REQUEST['q_id']) && is_array($_REQUEST['q_id'])) {
3318  foreach ($_REQUEST['q_id'] as $q_id) {
3320  continue;
3321  }
3322 
3324 
3325  if ($type !== 'tst') {
3326  ilUtil::sendFailure($lng->txt('tst_link_only_unassigned'), true);
3327  $this->ctrl->redirect($this, 'questions');
3328  return;
3329  }
3330  }
3331  }
3332 
3333  $this->createQuestionpoolTargetObject('copyAndLinkQuestionsToPool');
3334  }
3335 
3337  {
3339 
3340  if ($_REQUEST['title']) {
3341  $title = $_REQUEST['title'];
3342  } else {
3343  $title = $_REQUEST['txt_qpl'];
3344  }
3345 
3346  if (!$title) {
3347  ilUtil::sendInfo($this->lng->txt("questionpool_not_entered"));
3348  return $this->copyAndLinkToQuestionpoolObject();
3349  }
3350 
3351  $ref_id = $this->createQuestionPool($title, $_REQUEST['description']);
3352  $_REQUEST['sel_qpl'] = $ref_id;
3353 
3354  //if ($_REQUEST['link'])
3355  //{
3357  //}
3358  //else
3359  //{
3360  // $this->copyQuestionsToPoolObject();
3361  //}
3362  }
3363 
3370  public function createQuestionpoolTargetObject($cmd)
3371  {
3372  global $DIC;
3373  $ilUser = $DIC['ilUser'];
3374  $ilTabs = $DIC['ilTabs'];
3375  $this->getTabsManager()->getQuestionsSubTabs();
3377 
3378  $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_qpl_select_copy.html", "Modules/Test");
3379  $questionpools = &$this->object->getAvailableQuestionpools(false, false, false, true, false, "write");
3380  if (count($questionpools) == 0) {
3381  $this->tpl->setCurrentBlock("option");
3382  $this->tpl->setVariable("VALUE_QPL", "");
3383  $this->tpl->parseCurrentBlock();
3384  } else {
3385  foreach ($questionpools as $key => $value) {
3386  $this->tpl->setCurrentBlock("option");
3387  $this->tpl->setVariable("VALUE_OPTION", $key);
3388  $this->tpl->setVariable("TEXT_OPTION", $value["title"]);
3389  $this->tpl->parseCurrentBlock();
3390  }
3391  }
3392 
3393  if (isset($_REQUEST['q_id']) && is_array($_REQUEST['q_id'])) {
3394  foreach ($_REQUEST['q_id'] as $id) {
3395  $this->tpl->setCurrentBlock("hidden");
3396  $this->tpl->setVariable("HIDDEN_NAME", "q_id[]");
3397  $this->tpl->setVariable("HIDDEN_VALUE", $id);
3398  $this->tpl->parseCurrentBlock();
3399  $this->tpl->setCurrentBlock("adm_content");
3400  }
3401  }
3402  $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
3403 
3404  if (count($questionpools) == 0) {
3405  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_enter_questionpool"));
3406  $cmd = 'createQuestionPoolAndCopy';
3407  } else {
3408  $this->tpl->setVariable("TXT_QPL_SELECT", $this->lng->txt("tst_select_questionpool"));
3409  }
3410 
3411  $this->tpl->setVariable("CMD_SUBMIT", $cmd);
3412  $this->tpl->setVariable("BTN_SUBMIT", $this->lng->txt("submit"));
3413  $this->tpl->setVariable("BTN_CANCEL", $this->lng->txt("cancel"));
3414 
3415  $createForm = $this->getQuestionpoolCreationForm();
3416  switch ($cmd) {
3417  case 'copyAndLinkQuestionsToPool':
3418  $hidden = new ilHiddenInputGUI('link');
3419  $hidden->setValue(1);
3420  $createForm->addItem($hidden);
3421  break;
3422  case 'copyQuestionsToPool':
3423  break;
3424  }
3425  $createForm->setFormAction($this->ctrl->getFormAction($this));
3426 
3427  $this->tpl->parseCurrentBlock();
3428  }
3429 
3430  // begin-patch lok
3431  public function applyTemplate($templateData, ilObjTest $object)
3432  // end-patch lok
3433  {
3434  // map formFieldName => setterName
3435  $simpleSetters = array(
3436 
3437  // general properties
3438  'use_pool' => 'setPoolUsage',
3439  'question_set_type' => 'setQuestionSetType',
3440 
3441  // test intro properties
3442  'intro_enabled' => 'setIntroductionEnabled',
3443  'showinfo' => 'setShowInfo',
3444 
3445  // test access properties
3446  'chb_starting_time' => 'setStartingTimeEnabled',
3447  'chb_ending_time' => 'setEndingTimeEnabled',
3448  'password_enabled' => 'setPasswordEnabled',
3449  'fixedparticipants' => 'setFixedParticipants',
3450  'limitUsers' => 'setLimitUsersEnabled',
3451 
3452  // test run properties
3453  'nr_of_tries' => 'setNrOfTries',
3454  'chb_processing_time' => 'setEnableProcessingTime',
3455  'kiosk' => 'setKiosk',
3456  'examid_in_test_pass' => 'setShowExamIdInTestPassEnabled',
3457 
3458  // question behavior properties
3459  'title_output' => 'setTitleOutput',
3460  'autosave' => null, // handled specially in loop below
3461  'chb_shuffle_questions' => 'setShuffleQuestions',
3462  'offer_hints' => 'setOfferingQuestionHintsEnabled',
3463  'instant_feedback_contents' => 'setInstantFeedbackOptionsByArray',
3464  'instant_feedback_trigger' => 'setForceInstantFeedbackEnabled',
3465  'answer_fixation_handling' => null, // handled specially in loop below
3466  'obligations_enabled' => 'setObligationsEnabled',
3467 
3468  // test sequence properties
3469  'chb_use_previous_answers' => 'setUsePreviousAnswers',
3470  'chb_show_cancel' => 'setShowCancel',
3471  'chb_postpone' => 'setPostponingEnabled',
3472  'list_of_questions' => 'setListOfQuestionsSettings',
3473  'chb_show_marker' => 'setShowMarker',
3474 
3475  // test finish properties
3476  'enable_examview' => 'setEnableExamview',
3477  'showfinalstatement' => 'setShowFinalStatement',
3478  'redirection_enabled' => null, // handled specially in loop below
3479  'sign_submission' => 'setSignSubmission',
3480  'mailnotification' => 'setMailNotification',
3481 
3482  // scoring options properties
3483  'count_system' => 'setCountSystem',
3484  'mc_scoring' => 'setMCScoring',
3485  'score_cutting' => 'setScoreCutting',
3486  'pass_scoring' => 'setPassScoring',
3487  'pass_deletion_allowed' => 'setPassDeletionAllowed',
3488 
3489  // result summary properties
3490  'results_access_enabled' => 'setScoreReporting',
3491  'grading_status' => 'setShowGradingStatusEnabled',
3492  'grading_mark' => 'setShowGradingMarkEnabled',
3493 
3494  // result details properties
3495  'solution_details' => 'setShowSolutionDetails',
3496  'solution_feedback' => 'setShowSolutionFeedback',
3497  'solution_suggested' => 'setShowSolutionSuggested',
3498  'solution_printview' => 'setShowSolutionPrintview',
3499  'highscore_enabled' => 'setHighscoreEnabled',
3500  'solution_signature' => 'setShowSolutionSignature',
3501  'examid_in_test_res' => 'setShowExamIdInTestResultsEnabled',
3502  'exp_sc_short' => 'setExportSettingsSingleChoiceShort',
3503 
3504  // misc scoring & result properties
3505  'anonymity' => 'setAnonymity',
3506  'enable_archiving' => 'setEnableArchiving'
3507  );
3508 
3509  if (!$templateData['results_presentation']['value']) {
3510  $templateData['results_presentation']['value'] = array();
3511  }
3512 
3513  foreach ($simpleSetters as $field => $setter) {
3514  if ($templateData[$field] && strlen($setter)) {
3515  $object->$setter($templateData[$field]['value']);
3516  continue;
3517  }
3518 
3519  switch ($field) {
3520  case 'autosave':
3521  if ($templateData[$field]['value'] > 0) {
3522  $object->setAutosave(true);
3523  $object->setAutosaveIval($templateData[$field]['value'] * 1000);
3524  } else {
3525  $object->setAutosave(false);
3526  }
3527  break;
3528 
3529  case 'redirection_enabled':
3530  /* if( $templateData[$field]['value'] > REDIRECT_NONE )
3531  {
3532  $object->setRedirectionMode($templateData[$field]['value']);
3533  }
3534  else
3535  {
3536  $object->setRedirectionMode(REDIRECT_NONE);
3537  } */
3538  if (strlen($templateData[$field]['value'])) {
3540  $object->setRedirectionUrl($templateData[$field]['value']);
3541  } else {
3543  $object->setRedirectionUrl('');
3544  }
3545  break;
3546 
3547  case 'answer_fixation_handling':
3548  switch ($templateData[$field]['value']) {
3552  break;
3553 
3557  break;
3558 
3562  break;
3563 
3567  break;
3568  }
3569  break;
3570  }
3571  }
3572  }
3573 
3575  {
3576  global $DIC;
3577  $ilAccess = $DIC['ilAccess'];
3578  if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
3579  // allow only write access
3580  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3581  $this->ctrl->redirect($this, "infoScreen");
3582  }
3583 
3584  global $DIC;
3585  $ilCtrl = $DIC['ilCtrl'];
3586 
3587  $orders = $obligations = array();
3588 
3589  foreach ((array) $_REQUEST['order'] as $qId => $order) {
3590  $id = (int) str_replace('q_', '', $qId);
3591 
3592  $orders[$id] = $order;
3593  }
3594 
3595  if ($this->object->areObligationsEnabled() && isset($_REQUEST['obligatory']) && is_array($_REQUEST['obligatory'])) {
3596  foreach ($_REQUEST['obligatory'] as $qId => $obligation) {
3597  $id = (int) str_replace('q_', '', $qId);
3598 
3600  $obligations[$id] = $obligation;
3601  }
3602  }
3603  }
3604 
3605  $this->object->setQuestionOrderAndObligations(
3606  $orders,
3607  $obligations
3608  );
3609 
3610  ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
3611  $ilCtrl->redirect($this, 'questions');
3612  }
3613 
3617  protected function movePageFormObject()
3618  {
3619  global $DIC;
3620  $lng = $DIC['lng'];
3621  $ilCtrl = $DIC['ilCtrl'];
3622  $tpl = $DIC['tpl'];
3623 
3624  include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
3625  $form = new ilPropertyFormGUI();
3626  $form->setFormAction($ilCtrl->getFormAction($this, "movePage"));
3627  $form->setTitle($lng->txt("test_move_page"));
3628 
3629  $old_pos = new ilHiddenInputGUI("q_id");
3630  $old_pos->setValue($_REQUEST['q_id']);
3631  $form->addItem($old_pos);
3632 
3633  $questions = $this->object->getQuestionTitlesAndIndexes();
3634  if (!is_array($questions)) {
3635  $questions = array();
3636  }
3637 
3638  foreach ($questions as $k => $q) {
3639  if ($k == $_REQUEST['q_id']) {
3640  unset($questions[$k]);
3641  continue;
3642  }
3643  $questions[$k] = $lng->txt('behind') . ' ' . $q;
3644  }
3645  #$questions['0'] = $lng->txt('first');
3646 
3647  $options = array(
3648  0 => $lng->txt('first')
3649  );
3650  foreach ($questions as $k => $q) {
3651  $options[$k] = $q . ' [' . $this->lng->txt('question_id_short') . ': ' . $k . ']';
3652  }
3653 
3654  $pos = new ilSelectInputGUI($lng->txt("position"), "position_after");
3655  $pos->setOptions($options);
3656  $form->addItem($pos);
3657 
3658  $form->addCommandButton("movePage", $lng->txt("submit"));
3659  $form->addCommandButton("showPage", $lng->txt("cancel"));
3660 
3661  return $tpl->setContent($form->getHTML());
3662  }
3663 
3664  public function movePageObject()
3665  {
3666  global $DIC;
3667  $ilAccess = $DIC['ilAccess'];
3668  if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
3669  // allow only write access
3670  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3671  $this->ctrl->redirect($this, "infoScreen");
3672  }
3673 
3674  $this->object->moveQuestionAfter($_REQUEST['q_id'], $_REQUEST['position_after']);
3675  $this->showPageObject();
3676  }
3677 
3678  public function showPageObject()
3679  {
3680  global $DIC;
3681  $ilCtrl = $DIC['ilCtrl'];
3682 
3683  $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'q_id', $_REQUEST['q_id']);
3684  $ilCtrl->redirectByClass('iltestexpresspageobjectgui', 'showPage');
3685  }
3686 
3687  public function copyQuestionObject()
3688  {
3689  global $DIC;
3690  $ilAccess = $DIC['ilAccess'];
3691  if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
3692  // allow only write access
3693  ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3694  $this->ctrl->redirect($this, "infoScreen");
3695  }
3696 
3697  if ($_REQUEST['q_id'] && !is_array($_REQUEST['q_id'])) {
3698  $ids = array($_REQUEST['q_id']);
3699  } elseif ($_REQUEST['q_id']) {
3700  $ids = $_REQUEST['q_id'];
3701  } else {
3702  ilUtil::sendFailure($this->lng->txt('copy_no_questions_selected'), true);
3703  $this->ctrl->redirect($this, 'questions');
3704  }
3705 
3706  $copy_count = 0;
3707 
3708  $questionTitles = $this->object->getQuestionTitles();
3709 
3710  foreach ($ids as $id) {
3711  include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
3712  $question = assQuestion::_instanciateQuestionGUI($id);
3713  if ($question) {
3714  $title = $question->object->getTitle();
3715  $i = 2;
3716  while (in_array($title . ' (' . $i . ')', $questionTitles)) {
3717  $i++;
3718  }
3719 
3720  $title .= ' (' . $i . ')';
3721 
3722  $questionTitles[] = $title;
3723 
3724  $new_id = $question->object->duplicate(false, $title);
3725 
3726  $clone = assQuestion::_instanciateQuestionGUI($new_id);
3727  $clone->object->setObjId($this->object->getId());
3728  $clone->object->saveToDb();
3729 
3730  $this->object->insertQuestion($this->testQuestionSetConfigFactory->getQuestionSetConfig(), $new_id, true);
3731 
3732  $copy_count++;
3733  }
3734  }
3735 
3736  ilUtil::sendSuccess($this->lng->txt('copy_questions_success'), true);
3737 
3738  $this->ctrl->redirect($this, 'questions');
3739  }
3740 
3742  {
3743  require_once 'Modules/Course/classes/Objectives/class.ilLOSettings.php';
3744  $containerObjId = (int) ilLOSettings::isObjectiveTest($this->ref_id);
3745 
3746  $containerRefId = current(ilObject::_getAllReferences($containerObjId));
3747 
3748  $this->objectiveOrientedContainer->setObjId($containerObjId);
3749  $this->objectiveOrientedContainer->setRefId($containerRefId);
3750  }
3751 
3752  protected function getObjectiveOrientedContainer()
3753  {
3755  }
3756 }
const MATCHING_QUESTION_IDENTIFIER
const MULTIPLE_CHOICE_QUESTION_IDENTIFIER
const QT_MATCHING
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.
const QT_FORMULA
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
const PDF_PRINT_VIEW_QUESTIONS
This class represents an option in a radio group.
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.
setAutosave($autosave)
Class ilObjectMetaDataGUI.
static getAllSettingsTemplates($a_type, $a_include_auto_generated=false)
Get all settings templates of type.
$path
Definition: aliased.php:25
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
$context
Definition: webdav.php:25
createQuestionObject()
Called when a new question should be created from a test.
setRedirectionMode($redirection_mode=0)
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.
static getQuestionTypeByTypeId($type_id)
const SCORE_REPORTING_AFTER_PASSED
setTestAccess($testAccess)
static & _instanciateQuestionGUI($question_id)
Creates an instance of a question gui with a given question id.
insertQuestionsBeforeObject()
Insert checked questions before the actual selection.
addDidacticTemplateOptions(array &$a_options)
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
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
$log
Definition: sabredav.php:21
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()
Question page GUI class.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date public.
static $infoScreenChildClasses
setRedirectionUrl($redirection_url=null)
$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.
Base Exception for all Exceptions relating to Modules/Test.
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
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.
const REDIRECT_ALWAYS
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.
const SCORE_REPORTING_IMMIDIATLY
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
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
setAutosaveIval($autosave_ival)
const NUMERIC_QUESTION_IDENTIFIER
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.
setPositionInsertCommandsEnabled(bool $positionInsertCommandsEnabled)
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)
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
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.
__construct($refId=null)
Constructor public.
This class represents a text property in a property form.
Output class for assessment test evaluation.
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) ...
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 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
static _lookupType($a_id, $a_reference=false)
lookup object type
filterObject()
Sets the filter for the question browser.
setTabsManager($tabsManager)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
const QT_JAVAAPPLET
const SCORE_REPORTING_FINISHED
$row
const FLASHAPPLET_QUESTION_IDENTIFIER
static _createImportDirectory()
creates data directory for import files (data_dir/tst_data/tst_<id>/import, depending on data directo...
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}::expo...
exit
Definition: backend.php:16
const QT_NUMERIC
const SCORE_REPORTING_DATE
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
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.
applyTemplate($templateData, ilObjTest $object)
$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
setFollowupQuestionAnswerFixationEnabled($followupQuestionAnswerFixationEnabled)
getCreationMode()
get creation mode
$i
Definition: disco.tpl.php:19
movePageFormObject()
Move current page.
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.
static setTokenMaxLifetimeInSeconds($token_max_lifetime_in_seconds)
Service GUI class for tests.
insertQuestionsObject()
Insert questions from the questionbrowser into the test.
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
uploadTstObject()
imports test and question(s)
deleteDefaultsObject()
Deletes selected test defaults.
$info
Definition: index.php:5
setInstantFeedbackAnswerFixationEnabled($instantFeedbackAnswerFixationEnabled)
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
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"]
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
static prepareGenerationRequest($service, $purpose)
Prepare the content processing for a PDF generation request This function should be called as in a re...
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
static _getTestDefaults($test_defaults_id)
$GLOBALS['JPEG_Segment_Names']
Global Variable: XMP_tag_captions.
setLocator()
set Locator
static _getImportDirectory()
Get the import directory location of the test.
resetFilterObject()
Resets the filter for the question browser.
Confirmation screen class.
const IMAGEMAP_QUESTION_IDENTIFIER
const QT_ERRORTEXT
const FORMULA_QUESTION_IDENTIFIER
removeQuestionsForm($checked_questions)
Displays a form to confirm the removal of questions from the test.