ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilObjTestGUI.php
Go to the documentation of this file.
1<?php
18require_once './Modules/Test/exceptions/class.ilTestException.php';
19require_once './Services/Object/classes/class.ilObjectGUI.php';
20require_once './Modules/Test/classes/inc.AssessmentConstants.php';
21require_once './Modules/Test/classes/class.ilObjAssessmentFolderGUI.php';
22require_once './Modules/Test/classes/class.ilObjAssessmentFolder.php';
23require_once './Modules/Test/classes/class.ilTestExpressPage.php';
24require_once 'Modules/OrgUnit/classes/Positions/Operation/class.ilOrgUnitOperation.php';
25require_once 'Modules/Test/classes/class.ilTestParticipantAccessFilter.php';
26
67{
68 private static $infoScreenChildClasses = array(
69 'ilpublicuserprofilegui', 'ilobjportfoliogui'
70 );
71
73 public $object = null;
74
77
79 private $testPlayerFactory = null;
80
82 private $testSessionFactory = null;
83
85 private $testSequenceFactory = null;
86
90 protected $tabsManager;
91
96
100 protected $testAccess;
101
103 private $error;
104
110 public function __construct($refId = null)
111 {
112 global $DIC;
113 $lng = $DIC['lng'];
114 $ilCtrl = $DIC['ilCtrl'];
115 $ilDB = $DIC['ilDB'];
116 $refinery = $DIC['refinery'];
117 $ilPluginAdmin = $DIC['ilPluginAdmin'];
118 $tree = $DIC['tree'];
119 $lng->loadLanguageModule("assessment");
120 $this->type = "tst";
121 $this->error = $DIC['ilErr'];
122 $this->ctrl = $ilCtrl;
123 $this->ctrl->saveParameter($this, array("ref_id", "test_ref_id", "calling_test", "test_express_mode", "q_id"));
124 if (isset($_GET['ref_id']) && is_numeric($_GET['ref_id'])) {
125 $refId = (int) $_GET['ref_id'];
126 }
127 parent::__construct("", (int) $refId, true, false);
128
129 if ($this->object instanceof ilObjTest) {
130 require_once 'Modules/Test/classes/class.ilTestQuestionSetConfigFactory.php';
131 $this->testQuestionSetConfigFactory = new ilTestQuestionSetConfigFactory($tree, $ilDB, $ilPluginAdmin, $this->object);
132
133 require_once 'Modules/Test/classes/class.ilTestPlayerFactory.php';
134 $this->testPlayerFactory = new ilTestPlayerFactory($this->object);
135
136 require_once 'Modules/Test/classes/class.ilTestSessionFactory.php';
137 $this->testSessionFactory = new ilTestSessionFactory($this->object);
138
139 require_once 'Modules/Test/classes/class.ilTestSequenceFactory.php';
140 $this->testSequenceFactory = new ilTestSequenceFactory($ilDB, $lng, $refinery, $ilPluginAdmin, $this->object);
141
142 require_once 'Modules/Test/classes/class.ilTestAccess.php';
143 $this->setTestAccess(new ilTestAccess($this->ref_id, $this->object->getTestId()));
144 }
145
146 require_once 'Modules/Test/classes/class.ilTestObjectiveOrientedContainer.php';
147 $this->objectiveOrientedContainer = new ilTestObjectiveOrientedContainer();
148
149 if ($this->object instanceof ilObjTest) {
150 require_once 'Modules/Test/classes/class.ilTestTabsManager.php';
151 $tabsManager = new ilTestTabsManager($this->testAccess, $this->objectiveOrientedContainer);
152 $tabsManager->setTestOBJ($this->object);
153 $tabsManager->setTestSession($this->testSessionFactory->getSession());
154 $tabsManager->setTestQuestionSetConfig($this->testQuestionSetConfigFactory->getQuestionSetConfig());
155 $tabsManager->initSettingsTemplate();
157 }
158 }
159
163 public function executeCommand()
164 {
165 global $DIC; /* @var ILIAS\DI\Container $DIC */
166 $ilAccess = $DIC['ilAccess'];
167 $ilNavigationHistory = $DIC['ilNavigationHistory'];
168 $ilCtrl = $DIC['ilCtrl'];
169 $ilErr = $DIC['ilErr'];
170 $tpl = $DIC['tpl'];
171 $lng = $DIC['lng'];
172 $ilTabs = $DIC['ilTabs'];
173 $ilPluginAdmin = $DIC['ilPluginAdmin'];
174 $ilDB = $DIC['ilDB'];
175 $tree = $DIC['tree'];
176 $ilias = $DIC['ilias'];
177 $ilUser = $DIC['ilUser'];
178
179 $cmd = $this->ctrl->getCmd("infoScreen");
180
181 $cmdsDisabledDueToOfflineStatus = array(
182 'resumePlayer', 'resumePlayer', 'outUserResultsOverview', 'outUserListOfAnswerPasses'
183 );
184
185 if (!$this->getCreationMode() && $this->object->getOfflineStatus() && in_array($cmd, $cmdsDisabledDueToOfflineStatus)) {
186 $cmd = 'infoScreen';
187 }
188
189 $next_class = $this->ctrl->getNextClass($this);
190 $this->ctrl->setReturn($this, "infoScreen");
191
192 // add entry to navigation history
193 if (!$this->getCreationMode() &&
194 $ilAccess->checkAccess("read", "", $_GET["ref_id"])
195 ) {
196 $ilNavigationHistory->addItem(
197 $_GET["ref_id"],
198 "ilias.php?baseClass=ilObjTestGUI&cmd=infoScreen&ref_id=" . $_GET["ref_id"],
199 "tst"
200 );
201 }
202
203 // elba hack for storing question id for inserting new question after
204 if ($_REQUEST['prev_qid']) {
205 global $___prev_question_id;
206 $___prev_question_id = $_REQUEST['prev_qid'];
207 $this->ctrl->setParameter($this, 'prev_qid', $_REQUEST['prev_qid']);
208 }
209
210 if (!$this->getCreationMode() && $this->testQuestionSetConfigFactory->getQuestionSetConfig()->areDepenciesBroken()) {
211 if (!$this->testQuestionSetConfigFactory->getQuestionSetConfig()->isValidRequestOnBrokenQuestionSetDepencies($next_class, $cmd)) {
212 $this->ctrl->redirectByClass('ilObjTestGUI', 'infoScreen');
213 }
214 }
215
217
218 switch ($next_class) {
219 case 'illtiproviderobjectsettinggui':
220 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
222 return;
223 }
224 $this->prepareOutput();
225 $this->addHeaderAction();
226 $this->tabsManager->getSettingsSubTabs();
227 $GLOBALS['DIC']->tabs()->activateTab('settings');
228 $GLOBALS['DIC']->tabs()->activateSubTab('lti_provider');
229 $lti_gui = new ilLTIProviderObjectSettingGUI($this->object->getRefId());
230 $lti_gui->setCustomRolesForSelection($GLOBALS['DIC']->rbac()->review()->getLocalRoles($this->object->getRefId()));
231 $lti_gui->offerLTIRolesForSelection(false);
232 $this->ctrl->forwardCommand($lti_gui);
233 break;
234
235
236 case 'iltestexportgui':
237 if (!$ilAccess->checkAccess('write', '', $this->ref_id)) {
239 return;
240 }
241
242 $this->prepareOutput();
243 $this->addHeaderAction();
244 $DIC->tabs()->activateTab(ilTestTabsManager::TAB_ID_EXPORT);
245 require_once 'Modules/Test/classes/class.ilTestExportGUI.php';
246 $ilCtrl->forwardCommand(new ilTestExportGUI($this));
247 break;
248
249 case "ilinfoscreengui":
250 if (!$ilAccess->checkAccess("read", "", $_GET["ref_id"]) && !$ilAccess->checkAccess("visible", "", $_GET["ref_id"])) {
252 return;
253 }
254 $this->prepareOutput();
255 $this->addHeaderAction();
256 $this->infoScreen(); // forwards command
257 break;
258 case 'ilobjectmetadatagui':
259 if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
261 return;
262 }
263
264 $this->prepareOutput();
265 $this->addHeaderAction();
266 $DIC->tabs()->activateTab(ilTestTabsManager::TAB_ID_META_DATA);
267 include_once 'Services/Object/classes/class.ilObjectMetaDataGUI.php';
268 $md_gui = new ilObjectMetaDataGUI($this->object);
269 $this->ctrl->forwardCommand($md_gui);
270 break;
271
272 case 'iltestdashboardgui':
273 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
275 return;
276 }
277 $this->prepareOutput();
278 $this->addHeaderAction();
279
280 require_once 'Modules/Test/classes/class.ilTestDashboardGUI.php';
281
282 $gui = new ilTestDashboardGUI(
283 $this->object,
284 $this->testQuestionSetConfigFactory->getQuestionSetConfig()
285 );
286
287 $gui->setTestAccess($this->getTestAccess());
288 $gui->setTestTabs($this->getTabsManager());
289 $gui->setObjectiveParent($this->getObjectiveOrientedContainer());
290
291 $this->ctrl->forwardCommand($gui);
292 break;
293
294 case 'iltestresultsgui':
295 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
297 return;
298 }
299 $this->prepareOutput();
300 $this->addHeaderAction();
301
302 require_once 'Modules/Test/classes/class.ilTestResultsGUI.php';
303
304 $gui = new ilTestResultsGUI(
305 $this->object,
306 $this->testQuestionSetConfigFactory->getQuestionSetConfig()
307 );
308
309 $gui->setTestAccess($this->getTestAccess());
310 $gui->setTestSession($this->testSessionFactory->getSession());
311 $gui->setTestTabs($this->getTabsManager());
312 $gui->setObjectiveParent($this->getObjectiveOrientedContainer());
313
314 $this->ctrl->forwardCommand($gui);
315 break;
316
317 case "iltestplayerfixedquestionsetgui":
318 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
320 return;
321 }
323 require_once "./Modules/Test/classes/class.ilTestPlayerFixedQuestionSetGUI.php";
324 if (!$this->object->getKioskMode()) {
325 $this->prepareOutput();
326 }
327 $gui = new ilTestPlayerFixedQuestionSetGUI($this->object);
328 $gui->setObjectiveOrientedContainer($this->getObjectiveOrientedContainer());
329 $this->ctrl->forwardCommand($gui);
330 break;
331
332 case "iltestplayerrandomquestionsetgui":
333 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
335 return;
336 }
338 require_once "./Modules/Test/classes/class.ilTestPlayerRandomQuestionSetGUI.php";
339 if (!$this->object->getKioskMode()) {
340 $this->prepareOutput();
341 }
342 $gui = new ilTestPlayerRandomQuestionSetGUI($this->object);
343 $gui->setObjectiveOrientedContainer($this->getObjectiveOrientedContainer());
344 $this->ctrl->forwardCommand($gui);
345 break;
346
347 case "iltestplayerdynamicquestionsetgui":
348 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
350 return;
351 }
353 require_once "./Modules/Test/classes/class.ilTestPlayerDynamicQuestionSetGUI.php";
354 if (!$this->object->getKioskMode()) {
355 $this->prepareOutput();
356 }
357 $gui = new ilTestPlayerDynamicQuestionSetGUI($this->object);
358 $gui->setObjectiveOrientedContainer($this->getObjectiveOrientedContainer());
359 $this->ctrl->forwardCommand($gui);
360 break;
361
362 case "iltestevaluationgui":
363 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
365 return;
366 }
367 $this->forwardToEvaluationGUI();
368 break;
369
370 case "iltestevalobjectiveorientedgui":
371 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
373 return;
374 }
375 $this->forwardToEvalObjectiveOrientedGUI();
376 break;
377
378 case "iltestservicegui":
379 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
381 return;
382 }
383 $this->prepareOutput();
384 $this->addHeaderAction();
385 require_once "./Modules/Test/classes/class.ilTestServiceGUI.php";
386 $serviceGUI = new ilTestServiceGUI($this->object);
387 $this->ctrl->forwardCommand($serviceGUI);
388 break;
389
390 case 'ilpermissiongui':
391 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
393 return;
394 }
395 $this->prepareOutput();
396 $this->addHeaderAction();
397 $DIC->tabs()->activateTab(ilTestTabsManager::TAB_ID_PERMISSIONS);
398 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
399 $perm_gui = new ilPermissionGUI($this);
400 $ret = $this->ctrl->forwardCommand($perm_gui);
401 break;
402
403 case "illearningprogressgui":
404 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
406 return;
407 }
408 $this->prepareOutput();
409 $this->addHeaderAction();
410 $DIC->tabs()->activateTab(ilTestTabsManager::TAB_ID_LEARNING_PROGRESS);
411 require_once './Services/Tracking/classes/class.ilLearningProgressGUI.php';
412 $new_gui = new ilLearningProgressGUI(ilLearningProgressGUI::LP_CONTEXT_REPOSITORY, $this->object->getRefId());
413 $this->ctrl->forwardCommand($new_gui);
414
415 break;
416
417 case "ilcertificategui":
418 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
420 return;
421 }
422 $this->prepareOutput();
423 $this->addHeaderAction();
424
425 $DIC->tabs()->activateTab(ilTestTabsManager::TAB_ID_SETTINGS);
426
427 $guiFactory = new ilCertificateGUIFactory();
428 $output_gui = $guiFactory->create($this->object);
429
430 $this->ctrl->forwardCommand($output_gui);
431 break;
432
433 case "iltestscoringgui":
434 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
436 return;
437 }
438 $this->prepareOutput();
439 $this->addHeaderAction();
440 require_once "./Modules/Test/classes/class.ilTestScoringGUI.php";
441 $output_gui = new ilTestScoringGUI($this->object);
442 $output_gui->setTestAccess($this->getTestAccess());
443 $this->ctrl->forwardCommand($output_gui);
444 break;
445
446 case 'ilmarkschemagui':
447 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
449 return;
450 }
451 if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
452 ilUtil::sendInfo($this->lng->txt('cannot_edit_test'), true);
453 $this->ctrl->redirect($this, 'infoScreen');
454 }
455 $this->prepareOutput();
456 $this->addHeaderAction();
457 require_once 'Modules/Test/classes/class.ilMarkSchemaGUI.php';
458 $mark_schema_gui = new ilMarkSchemaGUI($this->object);
459 $this->ctrl->forwardCommand($mark_schema_gui);
460 break;
461
462 case 'iltestscoringbyquestionsgui':
463 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
465 return;
466 }
467 $this->prepareOutput();
468 $this->addHeaderAction();
469 include_once 'Modules/Test/classes/class.ilTestScoringByQuestionsGUI.php';
470 $output_gui = new ilTestScoringByQuestionsGUI($this->object);
471 $output_gui->setTestAccess($this->getTestAccess());
472 $this->ctrl->forwardCommand($output_gui);
473 break;
474
475 case 'ilobjtestsettingsgeneralgui':
476 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
478 return;
479 }
480 $this->prepareOutput();
481 $this->addHeaderAction();
482 require_once 'Modules/Test/classes/class.ilObjTestSettingsGeneralGUI.php';
484 $this->ctrl,
485 $ilAccess,
486 $this->lng,
487 $this->tree,
488 $ilDB,
489 $ilPluginAdmin,
490 $ilUser,
491 $this
492 );
493 $this->ctrl->forwardCommand($gui);
494 break;
495
496 case 'ilobjtestsettingsscoringresultsgui':
497 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
499 return;
500 }
501 $this->prepareOutput();
502 $this->addHeaderAction();
503 require_once 'Modules/Test/classes/class.ilObjTestSettingsScoringResultsGUI.php';
505 $this->ctrl,
506 $ilAccess,
507 $this->lng,
508 $this->tree,
509 $ilDB,
510 $ilPluginAdmin,
511 $this
512 );
513 $this->ctrl->forwardCommand($gui);
514 break;
515
516 case 'ilobjtestfixedquestionsetconfiggui':
517 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
519 return;
520 }
521 $this->prepareOutput();
522 $this->addHeaderAction();
523 require_once 'Modules/Test/classes/class.ilTestFixedQuestionSetConfigGUI.php';
524 $gui = new ilObjTestDynamicQuestionSetConfigGUI($this->ctrl, $ilAccess, $ilTabs, $this->lng, $this->tpl, $ilDB, $tree, $ilPluginAdmin, $this->object);
525 $this->ctrl->forwardCommand($gui);
526 break;
527
528 case 'iltestrandomquestionsetconfiggui':
529 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
531 return;
532 }
533 $this->prepareOutput();
534 $this->addHeaderAction();
535 require_once 'Modules/Test/classes/class.ilTestRandomQuestionSetConfigGUI.php';
537 $this->ctrl,
538 $ilAccess,
539 $ilTabs,
540 $this->lng,
541 $this->tpl,
542 $ilDB,
543 $tree,
544 $ilPluginAdmin,
545 $this->object,
547 new ilSetting('assessment'),
548 $ilDB
549 ))->withContextId($this->object->getId())
550 );
551 $this->ctrl->forwardCommand($gui);
552 break;
553
554 case 'ilobjtestdynamicquestionsetconfiggui':
555 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
557 return;
558 }
559 $this->prepareOutput();
560 $this->addHeaderAction();
561 require_once 'Modules/Test/classes/class.ilObjTestDynamicQuestionSetConfigGUI.php';
562 $gui = new ilObjTestDynamicQuestionSetConfigGUI($this->ctrl, $ilAccess, $ilTabs, $this->lng, $this->tpl, $ilDB, $tree, $ilPluginAdmin, $this->object);
563 $this->ctrl->forwardCommand($gui);
564 break;
565
566 case 'iltestquestionbrowsertablegui':
567 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
569 return;
570 }
571 $this->prepareOutput();
572 $this->addHeaderAction();
574 $this->ctrl,
575 $this->tpl,
576 $ilTabs,
577 $this->lng,
578 $tree,
579 $ilDB,
580 $ilPluginAdmin,
581 $this->object,
582 $ilAccess,
583 $DIC['refinery'],
584 $DIC['ui.factory'],
585 $DIC['ui.renderer']
586 );
587 $gui->setWriteAccess($ilAccess->checkAccess("write", "", $this->ref_id));
588 $gui->init();
589 $this->ctrl->forwardCommand($gui);
590 break;
591
592 case 'iltestskilladministrationgui':
593 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
595 return;
596 }
597 $this->prepareOutput();
598 $this->addHeaderAction();
599 require_once 'Modules/Test/classes/class.ilTestSkillAdministrationGUI.php';
600 $gui = new ilTestSkillAdministrationGUI($ilias, $this->ctrl, $ilAccess, $ilTabs, $this->tpl, $this->lng, $this->refinery, $ilDB, $tree, $ilPluginAdmin, $this->object, $this->ref_id);
601 $this->ctrl->forwardCommand($gui);
602 break;
603
604 case 'ilobjectcopygui':
605 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
607 return;
608 }
609 $this->prepareOutput();
610 $this->addHeaderAction();
611 require_once './Services/Object/classes/class.ilObjectCopyGUI.php';
612 $cp = new ilObjectCopyGUI($this);
613 $cp->setType('tst');
614 $this->ctrl->forwardCommand($cp);
615 break;
616
617 case 'ilpageeditorgui':
618 case 'iltestexpresspageobjectgui':
619 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
621 return;
622 }
623 $this->getTabsManager()->getQuestionsSubTabs();
625
626 require_once 'Modules/TestQuestionPool/classes/class.ilAssIncompleteQuestionPurger.php';
627 $incompleteQuestionPurger = new ilAssIncompleteQuestionPurger($ilDB);
628 $incompleteQuestionPurger->setOwnerId($ilUser->getId());
629 $incompleteQuestionPurger->purge();
630
631 try {
632 $qid = $this->fetchAuthoringQuestionIdParameter();
633 } catch (ilTestException $e) {
634 $qid = 0;
635 }
636
637 $this->prepareOutput();
638 if (!in_array($cmd, array('addQuestion', 'browseForQuestions'))) {
639 $this->buildPageViewToolbar($qid);
640 }
641
642 if (!$qid || in_array($cmd, array('insertQuestions', 'browseForQuestions'))) {
643 require_once "./Modules/Test/classes/class.ilTestExpressPageObjectGUI.php";
644 $pageObject = new ilTestExpressPageObjectGUI(0);
645 $pageObject->test_object = $this->object;
646 $ret = &$this->ctrl->forwardCommand($pageObject);
647 $this->tpl->setContent($ret);
648 break;
649 }
650 require_once "./Services/Style/Content/classes/class.ilObjStyleSheet.php";
651 $this->tpl->setCurrentBlock("ContentStyle");
652 $this->tpl->setVariable(
653 "LOCATION_CONTENT_STYLESHEET",
655 );
656 $this->tpl->parseCurrentBlock();
657
658 // syntax style
659 $this->tpl->setCurrentBlock("SyntaxStyle");
660 $this->tpl->setVariable(
661 "LOCATION_SYNTAX_STYLESHEET",
663 );
664 $this->tpl->parseCurrentBlock();
665 require_once "./Modules/TestQuestionPool/classes/class.assQuestionGUI.php";
666
667 $q_gui = assQuestionGUI::_getQuestionGUI("", $qid);
668 if (!($q_gui instanceof assQuestionGUI)) {
669 $this->ctrl->setParameterByClass('iltestexpresspageobjectgui', 'q_id', '');
670 $this->ctrl->redirectByClass('iltestexpresspageobjectgui', $this->ctrl->getCmd());
671 }
672
673 $q_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_PREVIEW);
674
675 $q_gui->outAdditionalOutput();
676 $q_gui->object->setObjId($this->object->getId());
677
678 $q_gui->setTargetGuiClass(null);
679 $q_gui->setQuestionActionCmd(null);
680
681 $question = $q_gui->object;
682 $this->ctrl->saveParameter($this, "q_id");
683
684 #$this->lng->loadLanguageModule("content");
685 $this->ctrl->setReturnByClass("ilTestExpressPageObjectGUI", "view");
686 $this->ctrl->setReturn($this, "questions");
687
688 require_once "./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php";
689 require_once "./Modules/Test/classes/class.ilTestExpressPageObjectGUI.php";
690
691 $page_gui = new ilTestExpressPageObjectGUI($qid);
692 $page_gui->test_object = $this->object;
693 $page_gui->setEditPreview(true);
694 $page_gui->setEnabledTabs(false);
695 if (strlen($this->ctrl->getCmd()) == 0) {
696 $this->ctrl->setCmdClass(get_class($page_gui));
697 $this->ctrl->setCmd("preview");
698 }
699
700 $page_gui->setQuestionHTML(array($q_gui->object->getId() => $q_gui->getPreview(true)));
701 $page_gui->setTemplateTargetVar("ADM_CONTENT");
702
703 $page_gui->setOutputMode($this->object->evalTotalPersons() == 0 ? "edit" : 'preview');
704
705 $page_gui->setHeader($question->getTitle());
706 $page_gui->setFileDownloadLink($this->ctrl->getLinkTarget($this, "downloadFile"));
707 $page_gui->setFullscreenLink($this->ctrl->getLinkTarget($this, "fullscreen"));
708 $page_gui->setSourcecodeDownloadScript($this->ctrl->getLinkTarget($this));
709 $page_gui->setPresentationTitle($question->getTitle() . ' [' . $this->lng->txt('question_id_short') . ': ' . $question->getId() . ']');
710 $ret = $this->ctrl->forwardCommand($page_gui);
711 if ($ret != "") {
712 $tpl->setContent($ret);
713 }
714
715 global $DIC;
716 $ilTabs = $DIC['ilTabs'];
717 $ilTabs->activateTab('assQuestions');
718
719 break;
720
721 case 'ilassquestionpreviewgui':
722 if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
724 }
725 $this->prepareOutput();
726
727 $this->ctrl->saveParameter($this, "q_id");
728
729 $gui = new ilAssQuestionPreviewGUI(
730 $this->ctrl,
731 $this->tabs_gui,
732 $this->tpl,
733 $this->lng,
734 $ilDB,
735 $ilUser,
736 $DIC->rbac()
737 );
738
739 $gui->initQuestion($this->fetchAuthoringQuestionIdParameter(), $this->object->getId());
740 $gui->initPreviewSettings($this->object->getRefId());
741 $gui->initPreviewSession($ilUser->getId(), (int) $_GET['q_id']);
742 $gui->initHintTracking();
743 $gui->initStyleSheets();
744
745 $this->ctrl->forwardCommand($gui);
746
747 break;
748
749 case 'ilassquestionpagegui':
750 if ($cmd == 'finishEditing') {
751 $this->ctrl->redirectByClass('ilassquestionpreviewgui', 'show');
752 break;
753 }
754 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
756 return;
757 }
758 if ($cmd === 'edit' && !$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
760 }
761 $_GET['q_id'] = $this->fetchAuthoringQuestionIdParameter();
762 $this->prepareOutput();
763 require_once 'Modules/Test/classes/class.ilAssQuestionPageCommandForwarder.php';
764 $forwarder = new ilAssQuestionPageCommandForwarder();
765 $forwarder->setTestObj($this->object);
766 $forwarder->forward();
767 break;
768
769 case 'ilassspecfeedbackpagegui':
770 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
772 return;
773 }
774 require_once "./Modules/TestQuestionPool/classes/feedback/class.ilAssSpecFeedbackPageGUI.php";
775 $pg_gui = new ilAssSpecFeedbackPageGUI((int) $_GET["feedback_id"]);
776 $this->ctrl->forwardCommand($pg_gui);
777 break;
778
779 case 'ilassgenfeedbackpagegui':
780 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
782 return;
783 }
784 require_once "./Modules/TestQuestionPool/classes/feedback/class.ilAssGenFeedbackPageGUI.php";
785 $pg_gui = new ilAssGenFeedbackPageGUI((int) $_GET["feedback_id"]);
786 $this->ctrl->forwardCommand($pg_gui);
787 break;
788
789 case 'illocalunitconfigurationgui':
790 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
792 return;
793 }
794 $this->prepareSubGuiOutput();
795
796 // set return target
797 $this->ctrl->setReturn($this, "questions");
798
799 // set context tabs
800 require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
802 $questionGUI->object->setObjId($this->object->getId());
803 $questionGUI->setQuestionTabs();
804
805 require_once 'Modules/TestQuestionPool/classes/class.ilLocalUnitConfigurationGUI.php';
806 require_once 'Modules/TestQuestionPool/classes/class.ilUnitConfigurationRepository.php';
808 new ilUnitConfigurationRepository((int) $_GET['q_id'])
809 );
810 $this->ctrl->forwardCommand($gui);
811 break;
812
813 case "ilcommonactiondispatchergui":
814 if (!$ilAccess->checkAccess("read", "", $_GET["ref_id"]) && !$ilAccess->checkAccess("visible", "", $_GET["ref_id"])) {
816 return;
817 }
818 $this->prepareOutput();
819 require_once "Services/Object/classes/class.ilCommonActionDispatcherGUI.php";
821 $this->ctrl->forwardCommand($gui);
822 break;
823
824 case 'ilassquestionhintsgui':
825 if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
827 }
828 $this->prepareSubGuiOutput();
829
830 // set return target
831 $this->ctrl->setReturn($this, "questions");
832
833 // set context tabs
834 require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
836 $questionGUI->object->setObjId($this->object->getId());
837 $questionGUI->setQuestionTabs();
838
839 if ($questionGUI->object->isInActiveTest()) {
840 ilUtil::sendFailure($this->lng->txt("question_is_part_of_running_test"), true);
841 $this->ctrl->redirectByClass('ilAssQuestionPreviewGUI', ilAssQuestionPreviewGUI::CMD_SHOW);
842 }
843
844 // forward to ilAssQuestionHintsGUI
845 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionHintsGUI.php';
846 $gui = new ilAssQuestionHintsGUI($questionGUI);
847
848 $gui->setEditingEnabled(
849 $DIC->access()->checkAccess('write', '', $this->object->getRefId())
850 );
851
852 $ilCtrl->forwardCommand($gui);
853
854 break;
855
856 case 'ilassquestionfeedbackeditinggui':
857 if (!$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
859 }
860 $this->prepareSubGuiOutput();
861
862 // set return target
863 $this->ctrl->setReturn($this, "questions");
864
865 // set context tabs
866 require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
868 $questionGUI->object->setObjId($this->object->getId());
869 $questionGUI->setQuestionTabs();
870
871 if ($questionGUI->object->isInActiveTest()) {
872 ilUtil::sendFailure($this->lng->txt("question_is_part_of_running_test"), true);
873 $this->ctrl->redirectByClass('ilAssQuestionPreviewGUI', ilAssQuestionPreviewGUI::CMD_SHOW);
874 }
875
876 // forward to ilAssQuestionFeedbackGUI
877 require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionFeedbackEditingGUI.php';
878 $gui = new ilAssQuestionFeedbackEditingGUI($questionGUI, $ilCtrl, $ilAccess, $tpl, $ilTabs, $lng);
879 $ilCtrl->forwardCommand($gui);
880
881 break;
882
883 case 'iltestcorrectionsgui':
884 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
886 return;
887 }
888 $this->prepareOutput();
889 require_once './Modules/Test/classes/class.ilTestCorrectionsGUI.php';
890 $gui = new ilTestCorrectionsGUI($DIC, $this->object);
891 $this->ctrl->forwardCommand($gui);
892 break;
893
894 case '':
895 case 'ilobjtestgui':
896 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]) && !$ilAccess->checkAccess("visible", "", $_GET["ref_id"]))) {
898 return;
899 }
900 $this->prepareOutput();
901 $this->addHeaderAction();
902 if ((strcmp($cmd, "properties") == 0) && ($_GET["browse"])) {
903 $this->questionBrowser();
904 return;
905 }
906 if ((strcmp($cmd, "properties") == 0) && ($_GET["up"] || $_GET["down"])) {
907 $this->questionsObject();
908 return;
909 }
910 $cmd .= "Object";
911 $ret = &$this->$cmd();
912 break;
913 default:
914 if ((!$ilAccess->checkAccess("read", "", $_GET["ref_id"]))) {
916 return;
917 }
918 if (in_array($cmd, ['editQuestion', 'save', 'suggestedsolution']) && !$ilAccess->checkAccess('write', '', $this->object->getRefId())) {
920 }
921 // elba hack for storing question id for inserting new question after
922 if ($_REQUEST['prev_qid']) {
923 global $___prev_question_id;
924 $___prev_question_id = $_REQUEST['prev_qid'];
925 $this->ctrl->setParameterByClass('ilassquestionpagegui', 'prev_qid', $_REQUEST['prev_qid']);
926 $this->ctrl->setParameterByClass($_GET['sel_question_types'] . 'gui', 'prev_qid', $_REQUEST['prev_qid']);
927 }
928 $this->create_question_mode = true;
929 $this->prepareOutput();
930
931 $this->ctrl->setReturn($this, "questions");
932
933 try {
934 $qid = $this->fetchAuthoringQuestionIdParameter();
935
936 $questionGui = assQuestionGUI::_getQuestionGUI(
937 ilUtil::stripSlashes($_GET['sel_question_types'] ?? ''),
938 $qid
939 );
940
941 $questionGui->setEditContext(assQuestionGUI::EDIT_CONTEXT_AUTHORING);
942 $questionGui->object->setObjId($this->object->getId());
943
944 if (in_array($cmd, ['editQuestion', 'save', 'suggestedsolution']) && $questionGui->object->isInActiveTest()) {
945 ilUtil::sendFailure($this->lng->txt("question_is_part_of_running_test"), true);
946 $this->ctrl->redirectByClass('ilAssQuestionPreviewGUI', ilAssQuestionPreviewGUI::CMD_SHOW);
947 }
948
949 $questionGuiClass = get_class($questionGui);
950 $this->ctrl->setParameterByClass($questionGuiClass, 'prev_qid', $_REQUEST['prev_qid']);
951 $this->ctrl->setParameterByClass($questionGuiClass, 'test_ref_id', $_REQUEST['ref_id']);
952 $this->ctrl->setParameterByClass($questionGuiClass, 'q_id', $qid);
953
954 if (isset($_REQUEST['test_express_mode'])) {
955 $this->ctrl->setParameterByClass($questionGuiClass, 'test_express_mode', 1);
956 }
957
958 if (!$questionGui->isSaveCommand()) {
959 $_GET['calling_test'] = $this->object->getRefId();
960 }
961
962 $questionGui->setQuestionTabs();
963
964 $this->ctrl->forwardCommand($questionGui);
965 } catch (ilTestException $e) {
966 if (isset($_REQUEST['test_express_mode'])) {
967 $this->ctrl->redirect($this, 'showPage');
968 } else {
969 $this->ctrl->redirect($this, 'questions');
970 }
971 }
972 break;
973 }
974 if (!in_array(strtolower($_GET["baseClass"]), array('iladministrationgui', 'ilrepositorygui')) &&
975 $this->getCreationMode() != true) {
976 $this->tpl->printToStdout();
977 }
978 }
979
980 protected function redirectAfterMissingWrite()
981 {
982 ilUtil::sendFailure($this->lng->txt("no_permission"), true);
983 $target_class = get_class($this->object) . "GUI";
984 $this->ctrl->setParameterByClass($target_class, 'ref_id', $this->ref_id);
985 $this->ctrl->redirectByClass($target_class);
986 }
987
988 protected function redirectAfterMissingRead() : void
989 {
990 $this->tpl->setOnScreenMessage('failure', sprintf(
991 $this->lng->txt("msg_no_perm_read_item"),
992 $this->object->getTitle()
993 ), true);
994 $this->ctrl->setParameterByClass('ilrepositorygui', 'ref_id', ROOT_FOLDER_ID);
995 $this->ctrl->redirectByClass('ilrepositorygui');
996 }
997
998 protected function trackTestObjectReadEvent()
999 {
1000 /* @var ILIAS\DI\Container $DIC */ global $DIC;
1001
1002 require_once 'Services/Tracking/classes/class.ilChangeEvent.php';
1003
1005 $this->object->getType(),
1006 $this->object->getRefId(),
1007 $this->object->getId(),
1008 $DIC->user()->getId()
1009 );
1010 }
1011
1016 protected function exportObject()
1017 {
1018 global $DIC; /* @var ILIAS\DI\Container $DIC */
1019 $DIC->ctrl()->redirectByClass('ilTestExportGUI');
1020 }
1021
1027 {
1028 $qid = $_REQUEST['q_id'];
1029
1030 if (!$qid || $qid == 'Array') {
1031 $questions = $this->object->getQuestionTitlesAndIndexes();
1032
1033 $keys = array_keys($questions);
1034 $qid = (int) ($keys[0] ?? 0);
1035
1036 $_REQUEST['q_id'] = $qid;
1037 $_GET['q_id'] = $qid;
1038 $_POST['q_id'] = $qid;
1039 }
1040
1041 if ($this->object->checkQuestionParent($qid)) {
1042 return $qid;
1043 }
1044
1045 throw new ilTestException('question id does not relate to parent object!');
1046 }
1047
1048 private function questionsTabGatewayObject()
1049 {
1050 switch ($this->object->getQuestionSetType()) {
1052 $this->ctrl->redirectByClass('ilObjTestGUI', 'questions');
1053
1054 // no break
1056 $this->ctrl->redirectByClass('ilTestRandomQuestionSetConfigGUI');
1057
1058 // no break
1060 $this->ctrl->redirectByClass('ilObjTestDynamicQuestionSetConfigGUI');
1061 }
1062 }
1063
1064 private function userResultsGatewayObject()
1065 {
1066 $this->ctrl->setCmdClass('ilTestEvaluationGUI');
1067 $this->ctrl->setCmd('outUserResultsOverview');
1068 $this->tabs_gui->clearTargets();
1069
1070 $this->forwardToEvaluationGUI();
1071 }
1072
1073 private function testResultsGatewayObject() : void
1074 {
1075 $this->ctrl->redirectByClass(
1076 [
1077 ilRepositoryGUI::class,
1078 __CLASS__,
1079 ilTestResultsGUI::class,
1080 ilParticipantsTestResultsGUI::class
1081 ],
1082 'showParticipants'
1083 );
1084 }
1085
1089 public function getTestAccess()
1090 {
1091 return $this->testAccess;
1092 }
1093
1098 {
1099 $this->testAccess = $testAccess;
1100 }
1101
1105 public function getTabsManager()
1106 {
1107 return $this->tabsManager;
1108 }
1109
1114 {
1115 $this->tabsManager = $tabsManager;
1116 }
1117
1118 private function forwardToEvaluationGUI()
1119 {
1120 $this->prepareOutput();
1121 $this->addHeaderAction();
1122
1123 require_once 'Modules/Test/classes/class.ilTestEvaluationGUI.php';
1124 $gui = new ilTestEvaluationGUI($this->object);
1125 $gui->setObjectiveOrientedContainer($this->getObjectiveOrientedContainer());
1126 $gui->setTestAccess($this->getTestAccess());
1127
1128 $this->ctrl->forwardCommand($gui);
1129 }
1130
1132 {
1133 require_once 'Modules/Test/classes/class.ilObjTestSettingsGeneralGUI.php';
1134 $this->ctrl->redirectByClass('ilObjTestSettingsGeneralGUI', ilObjTestSettingsGeneralGUI::CMD_SHOW_FORM);
1135 }
1136
1145 private function prepareSubGuiOutput()
1146 {
1147 global $DIC;
1148 $ilUser = $DIC['ilUser'];
1149
1150 $this->tpl->loadStandardTemplate();
1151
1152 // set locator
1153 $this->setLocator();
1154
1155 // catch feedback message
1157
1158 // set title and description and title icon
1159 $this->setTitleAndDescription();
1160 }
1161
1162 public function runObject()
1163 {
1164 $this->ctrl->redirect($this, "infoScreen");
1165 }
1166
1167 public function outEvaluationObject()
1168 {
1169 $this->ctrl->redirectByClass("iltestevaluationgui", "outEvaluation");
1170 }
1171
1175 protected function importFileObject($parent_id = null, $a_catch_errors = true)
1176 {
1177 if (!$this->checkPermissionBool("create", "", $_REQUEST["new_type"])) {
1178 $this->error->raiseError($this->lng->txt("no_create_permission"));
1179 }
1180
1181 $form = $this->initImportForm($_REQUEST["new_type"]);
1182 if ($form->checkInput()) {
1183 $this->ctrl->setParameter($this, "new_type", $this->type);
1184 $this->uploadTstObject();
1185 return;
1186 }
1187
1188 // display form to correct errors
1189 $form->setValuesByPost();
1190 $this->tpl->setContent($form->getHTML());
1191 }
1192
1193 public function addDidacticTemplateOptions(array &$a_options)
1194 {
1195 include_once("./Modules/Test/classes/class.ilObjTest.php");
1196 $tst = new ilObjTest();
1197 $defaults = $tst->getAvailableDefaults();
1198 if (count($defaults)) {
1199 foreach ($defaults as $row) {
1200 $a_options["tstdef_" . $row["test_defaults_id"]] = array($row["name"],
1201 $this->lng->txt("tst_default_settings"));
1202 }
1203 }
1204
1205 // using template?
1206 include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
1208 if ($templates) {
1209 foreach ($templates as $item) {
1210 $a_options["tsttpl_" . $item["id"]] = array($item["title"],
1211 nl2br(trim($item["description"])));
1212 }
1213 }
1214 }
1215
1220 public function afterSave(ilObject $a_new_object)
1221 {
1222 $tstdef = $this->getDidacticTemplateVar("tstdef");
1223 if ($tstdef) {
1224 $testDefaultsId = $tstdef;
1225 $testDefaults = ilObjTest::_getTestDefaults($testDefaultsId);
1226 $a_new_object->applyDefaults($testDefaults);
1227 }
1228
1229 $template_id = $this->getDidacticTemplateVar("tsttpl");
1230 if ($template_id) {
1231 include_once "Services/Administration/classes/class.ilSettingsTemplate.php";
1233
1234 $template_settings = $template->getSettings();
1235 if ($template_settings) {
1236 $this->applyTemplate($template_settings, $a_new_object);
1237 }
1238
1239 $a_new_object->setTemplate($template_id);
1240 }
1241
1242 $a_new_object->saveToDb();
1243
1244 // always send a message
1245 ilUtil::sendSuccess($this->lng->txt("object_added"), true);
1246 $this->ctrl->setParameter($this, 'ref_id', $a_new_object->getRefId());
1247 $this->ctrl->redirectByClass('ilObjTestSettingsGeneralGUI');
1248 }
1249
1250 public function backToRepositoryObject()
1251 {
1252 include_once "./Services/Utilities/classes/class.ilUtil.php";
1253 $path = $this->tree->getPathFull($this->object->getRefID());
1254 ilUtil::redirect($this->getReturnLocation("cancel", "./ilias.php?baseClass=ilRepositoryGUI&cmd=frameset&ref_id=" . $path[count($path) - 2]["child"]));
1255 }
1256
1260 public function uploadTstObject()
1261 {
1262 if ($_FILES["xmldoc"]["error"] > UPLOAD_ERR_OK) {
1263 $this->lng->loadLanguageModule('file');
1264 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('general_upload_error_occured'));
1265 $this->ctrl->redirect($this, 'create');
1266 return false;
1267 }
1268
1269 $file = pathinfo($_FILES["xmldoc"]["name"]);
1270 $subdir = basename($file["basename"], "." . $file["extension"]);
1271
1272 if (strpos($subdir, 'tst') === false) {
1273 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('import_file_not_valid'), true);
1274 $this->ctrl->redirect($this, 'create');
1275 return false;
1276 }
1277
1279
1280 $full_path = $basedir . "/" . $_FILES["xmldoc"]["name"];
1281
1282 ilUtil::moveUploadedFile($_FILES["xmldoc"]["tmp_name"], $_FILES["xmldoc"]["name"], $full_path);
1283 ilUtil::unzip($full_path);
1284
1286 $xml_file = ilObjTest::_getImportDirectory() . '/' . $subdir . '/' . $subdir . ".xml";
1287 $qti_file = ilObjTest::_getImportDirectory() . '/' . $subdir . '/' . preg_replace("/test|tst/", "qti", $subdir) . ".xml";
1288 $results_file = ilObjTest::_getImportDirectory() . '/' . $subdir . '/' . preg_replace("/test|tst/", "results", $subdir) . ".xml";
1289
1290 if (!is_file($qti_file)) {
1291 ilUtil::delDir($basedir);
1292 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("tst_import_non_ilias_zip"), true);
1293 $this->ctrl->redirect($this, 'create');
1294 return false;
1295 }
1296
1297 // start verification of QTI files
1298 include_once "./Services/QTI/classes/class.ilQTIParser.php";
1299 $qtiParser = new ilQTIParser($qti_file, IL_MO_VERIFY_QTI, 0, "");
1300 $result = $qtiParser->startParsing();
1301 $founditems = &$qtiParser->getFoundItems();
1302
1303 $complete = 0;
1304 $incomplete = 0;
1305 foreach ($founditems as $item) {
1306 if (strlen($item["type"])) {
1307 $complete++;
1308 } else {
1309 $incomplete++;
1310 }
1311 }
1312
1313 if (count($founditems) && $complete == 0) {
1314 // delete import directory
1315 ilUtil::delDir($basedir);
1316
1317 ilUtil::sendInfo($this->lng->txt("qpl_import_non_ilias_files"));
1318 $this->createObject();
1319 return;
1320 }
1321
1322 $_SESSION["tst_import_results_file"] = $results_file;
1323 $_SESSION["tst_import_xml_file"] = $xml_file;
1324 $_SESSION["tst_import_qti_file"] = $qti_file;
1325 $_SESSION["tst_import_subdir"] = $subdir;
1326
1327 if ($qtiParser->getQuestionSetType() != ilObjTest::QUESTION_SET_TYPE_FIXED) {
1328 $this->importVerifiedFileObject();
1329 return;
1330 }
1331
1332 $importVerificationTpl = new ilTemplate('tpl.tst_import_verification.html', true, true, 'Modules/Test');
1333 // Keep this include because of global constants
1334 include_once "./Services/QTI/classes/class.ilQTIItem.php";
1335
1336 // on import creation screen the pool was chosen (-1 for no pool)
1337 // BUT when no pool is available the input on creation screen is missing, so the field value -1 for no pool is not submitted.
1338 $QplOrTstID = isset($_POST["qpl"]) && (int) $_POST["qpl"] != 0 ? $_POST["qpl"] : -1;
1339
1340 $importVerificationTpl->setVariable("TEXT_TYPE", $this->lng->txt("question_type"));
1341 $importVerificationTpl->setVariable("TEXT_TITLE", $this->lng->txt("question_title"));
1342 $importVerificationTpl->setVariable("FOUND_QUESTIONS_INTRODUCTION", $this->lng->txt("tst_import_verify_found_questions"));
1343 $importVerificationTpl->setVariable("VERIFICATION_HEADING", $this->lng->txt("import_tst"));
1344 $importVerificationTpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
1345 $importVerificationTpl->setVariable("ARROW", ilUtil::getImagePath("arrow_downright.svg"));
1346 $importVerificationTpl->setVariable("QUESTIONPOOL_ID", $QplOrTstID);
1347 $importVerificationTpl->setVariable("VALUE_IMPORT", $this->lng->txt("import"));
1348 $importVerificationTpl->setVariable("VALUE_CANCEL", $this->lng->txt("cancel"));
1349
1350 $row_class = ["tblrow1", "tblrow2"];
1351 $counter = 0;
1352 foreach ($founditems as $item) {
1353 $importVerificationTpl->setCurrentBlock("verification_row");
1354 $importVerificationTpl->setVariable("ROW_CLASS", $row_class[$counter++ % 2]);
1355 $importVerificationTpl->setVariable("QUESTION_TITLE", $item["title"]);
1356 $importVerificationTpl->setVariable("QUESTION_IDENT", $item["ident"]);
1357
1358 switch ($item["type"]) {
1361 $importVerificationTpl->setVariable("QUESTION_TYPE", $this->lng->txt("assMultipleChoice"));
1362 break;
1365 $importVerificationTpl->setVariable("QUESTION_TYPE", $this->lng->txt("assSingleChoice"));
1366 break;
1368 case QT_KPRIM_CHOICE:
1369 $importVerificationTpl->setVariable("QUESTION_TYPE", $this->lng->txt("assKprimChoice"));
1370 break;
1372 case QT_LONG_MENU:
1373 $importVerificationTpl->setVariable("QUESTION_TYPE", $this->lng->txt("assLongMenu"));
1374 break;
1376 case QT_NUMERIC:
1377 $importVerificationTpl->setVariable("QUESTION_TYPE", $this->lng->txt("assNumeric"));
1378 break;
1380 case QT_FORMULA:
1381 $importVerificationTpl->setVariable("QUESTION_TYPE", $this->lng->txt("assFormulaQuestion"));
1382 break;
1384 case QT_TEXTSUBSET:
1385 $importVerificationTpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextSubset"));
1386 break;
1388 case QT_CLOZE:
1389 $importVerificationTpl->setVariable("QUESTION_TYPE", $this->lng->txt("assClozeTest"));
1390 break;
1392 case QT_ERRORTEXT:
1393 $importVerificationTpl->setVariable("QUESTION_TYPE", $this->lng->txt("assErrorText"));
1394 break;
1396 case QT_IMAGEMAP:
1397 $importVerificationTpl->setVariable("QUESTION_TYPE", $this->lng->txt("assImagemapQuestion"));
1398 break;
1400 case QT_JAVAAPPLET:
1401 $importVerificationTpl->setVariable("QUESTION_TYPE", $this->lng->txt("assJavaApplet"));
1402 break;
1404 case QT_FLASHAPPLET:
1405 $importVerificationTpl->setVariable("QUESTION_TYPE", $this->lng->txt("assFlashApplet"));
1406 break;
1408 case QT_MATCHING:
1409 $importVerificationTpl->setVariable("QUESTION_TYPE", $this->lng->txt("assMatchingQuestion"));
1410 break;
1412 case QT_ORDERING:
1413 $importVerificationTpl->setVariable("QUESTION_TYPE", $this->lng->txt("assOrderingQuestion"));
1414 break;
1417 $importVerificationTpl->setVariable("QUESTION_TYPE", $this->lng->txt("assOrderingHorizontal"));
1418 break;
1420 case QT_TEXT:
1421 $importVerificationTpl->setVariable("QUESTION_TYPE", $this->lng->txt("assTextQuestion"));
1422 break;
1424 case QT_FILEUPLOAD:
1425 $importVerificationTpl->setVariable("QUESTION_TYPE", $this->lng->txt("assFileUpload"));
1426 break;
1427 }
1428 $importVerificationTpl->parseCurrentBlock();
1429 }
1430
1431 $this->tpl->setContent($importVerificationTpl->get());
1432 }
1433
1438 {
1439 include_once "./Modules/Test/classes/class.ilObjTest.php";
1440 // create new questionpool object
1441 $newObj = new ilObjTest(0, true);
1442 // set type of questionpool object
1443 $newObj->setType($_GET["new_type"]);
1444 // set title of questionpool object to "dummy"
1445 $newObj->setTitle("dummy");
1446 // set description of questionpool object
1447 $newObj->setDescription("test import");
1448 // create the questionpool class in the ILIAS database (object_data table)
1449 $newObj->create(true);
1450 // create a reference for the questionpool object in the ILIAS database (object_reference table)
1451 $newObj->createReference();
1452 // put the questionpool object in the administration tree
1453 $newObj->putInTree($_GET["ref_id"]);
1454 // get default permissions and set the permissions for the questionpool object
1455 $newObj->setPermissions($_GET["ref_id"]);
1456 // empty mark schema
1457 $newObj->mark_schema->flush();
1458
1459 // start parsing of QTI files
1460 include_once "./Services/QTI/classes/class.ilQTIParser.php";
1461
1462 // Handle selection of "no questionpool" as qpl_id = -1 -> use test object id instead.
1463 // possible hint: chek if empty strings in $_POST["qpl_id"] relates to a bug or not
1464 if (!isset($_POST["qpl"]) || "-1" === (string) $_POST["qpl"]) {
1465 $questionParentObjId = $newObj->getId();
1466 } else {
1467 $questionParentObjId = $_POST["qpl"];
1468 }
1469
1470 if (is_file($_SESSION["tst_import_dir"] . '/' . $_SESSION["tst_import_subdir"] . "/manifest.xml")) {
1471 $newObj->saveToDb();
1472
1473 $_SESSION['tst_import_idents'] = $_POST['ident'];
1474 $_SESSION['tst_import_qst_parent'] = $questionParentObjId;
1475
1476 $fileName = $_SESSION['tst_import_subdir'] . '.zip';
1477 $fullPath = $_SESSION['tst_import_dir'] . '/' . $fileName;
1478
1479 include_once("./Services/Export/classes/class.ilImport.php");
1480 $imp = new ilImport((int) $_GET["ref_id"]);
1481 $map = $imp->getMapping();
1482 $map->addMapping('Modules/Test', 'tst', 'new_id', $newObj->getId());
1483 $imp->importObject($newObj, $fullPath, $fileName, 'tst', 'Modules/Test', true);
1484 } else {
1485 $qtiParser = new ilQTIParser($_SESSION["tst_import_qti_file"], IL_MO_PARSE_QTI, $questionParentObjId, $_POST["ident"]);
1486 if (!isset($_POST["ident"]) || !is_array($_POST["ident"]) || !count($_POST["ident"])) {
1487 $qtiParser->setIgnoreItemsEnabled(true);
1488 }
1489 $qtiParser->setTestObject($newObj);
1490 $result = $qtiParser->startParsing();
1491 $newObj->saveToDb();
1492
1493 // import page data
1494 $contParser = new ilQuestionPageParser($newObj, $_SESSION["tst_import_xml_file"], $_SESSION["tst_import_subdir"]);
1495 $contParser->setQuestionMapping($qtiParser->getImportMapping());
1496 $contParser->startParsing();
1497
1498 if (isset($_POST["ident"]) && is_array($_POST["ident"]) && count($_POST["ident"]) == $qtiParser->getNumImportedItems()) {
1499 // import test results
1500 if (@file_exists($_SESSION["tst_import_results_file"])) {
1501 include_once("./Modules/Test/classes/class.ilTestResultsImportParser.php");
1502 $results = new ilTestResultsImportParser($_SESSION["tst_import_results_file"], $newObj);
1503 $results->setQuestionIdMapping($qtiParser->getQuestionIdMapping());
1504 $results->startParsing();
1505 }
1506 }
1507 $newObj->update();
1508 }
1509
1510
1511 // delete import directory
1513
1514 ilUtil::sendSuccess($this->lng->txt("object_imported"), true);
1515 ilUtil::redirect("ilias.php?ref_id=" . $newObj->getRefId() . "&baseClass=ilObjTestGUI");
1516 }
1517
1524 public function uploadObject($redirect = true)
1525 {
1526 $this->uploadTstObject();
1527 }
1528
1532 public function downloadFileObject()
1533 {
1534 $file = explode("_", $_GET["file_id"]);
1535 include_once("./Modules/File/classes/class.ilObjFile.php");
1536 $fileObj = new ilObjFile($file[count($file) - 1], false);
1537 $fileObj->sendFile();
1538 exit;
1539 }
1540
1544 public function fullscreenObject()
1545 {
1546 include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPageGUI.php");
1547 $page_gui = new ilAssQuestionPageGUI($_GET["pg_id"]);
1548 $page_gui->showMediaFullscreen();
1549 }
1550
1555 {
1556 include_once("./Modules/TestQuestionPool/classes/class.ilAssQuestionPage.php");
1557 $pg_obj = new ilAssQuestionPage($_GET["pg_id"]);
1558 $pg_obj->send_paragraph($_GET["par_id"], $_GET["downloadtitle"]);
1559 exit;
1560 }
1561
1569 public function filterObject()
1570 {
1571 $this->questionBrowser();
1572 }
1573
1581 public function resetFilterObject()
1582 {
1583 $this->questionBrowser();
1584 }
1585
1593 public function backObject()
1594 {
1595 $this->ctrl->redirect($this, "questions");
1596 }
1597
1606 public function createQuestionPool($name = "dummy", $description = "")
1607 {
1608 global $DIC;
1609 $tree = $DIC['tree'];
1610 $parent_ref = $tree->getParentId($this->object->getRefId());
1611 include_once "./Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php";
1612 $qpl = new ilObjQuestionPool();
1613 $qpl->setType("qpl");
1614 $qpl->setTitle($name);
1615 $qpl->setDescription($description);
1616 $qpl->create();
1617 $qpl->createReference();
1618 $qpl->putInTree($parent_ref);
1619 $qpl->setPermissions($parent_ref);
1620 $qpl->setOnline(1); // must be online to be available
1621 $qpl->saveToDb();
1622 return $qpl->getRefId();
1623 }
1624
1625 public function randomselectObject()
1626 {
1627 $this->getTabsManager()->getQuestionsSubTabs();
1629
1630 $form = new ilPropertyFormGUI();
1631 $form->setTitle($this->lng->txt('random_selection'));
1632 $form->setFormAction($this->ctrl->getFormAction($this, 'cancelRandomSelect'));
1633
1634 $form->addCommandButton('createRandomSelection', $this->lng->txt('submit'));
1635 $form->addCommandButton('cancelRandomSelect', $this->lng->txt('cancel'));
1636
1637 $amount = new ilNumberInputGUI($this->lng->txt('tst_random_nr_of_questions'), 'nr_of_questions');
1638 $amount->allowDecimals(false);
1639 $amount->setSize(5);
1640 $amount->setMinValue(1);
1641 $amount->setValue(5);
1642 $form->addItem($amount);
1643
1644 $poolSelection = new ilSelectInputGUI($this->lng->txt('tst_source_question_pool'), 'sel_qpl');
1645 $poolSelection->setInfo($this->lng->txt('tst_random_select_questionpool'));
1646 $poolSelection->setRequired(true);
1647 $poolOptions = [];
1648 $questionpools = $this->object->getAvailableQuestionpools(false, false, false, true);
1649 foreach ($questionpools as $key => $value) {
1650 $poolOptions[$key] = $value['title'];
1651 }
1652 $poolSelection->setOptions(
1653 ['0' => $this->lng->txt('all_available_question_pools')] + $poolOptions
1654 );
1655 $form->addItem($poolSelection);
1656
1657 $questionType = new ilHiddenInputGUI('sel_question_types');
1658 $questionType->setValue(ilUtil::stripSlashes($_POST['sel_question_types']));
1659 $form->addItem($questionType);
1660
1661 $this->tpl->setContent($form->getHTML());
1662 }
1663
1665 {
1666 $this->ctrl->redirect($this, "questions");
1667 }
1668
1670 {
1671 $this->getTabsManager()->getQuestionsSubTabs();
1673
1674 $randomQuestionSelectionTable = new ilTestRandomQuestionSelectionTableGUI($this, 'createRandomSelection', $this->object);
1675
1676 $this->tpl->setContent(
1677 $randomQuestionSelectionTable
1678 ->build((int) $_POST['nr_of_questions'], (int) $_POST['sel_qpl'])
1679 ->getHtml()
1680 );
1681 }
1682
1691 {
1692 $selected_array = explode(",", $_POST["chosen_questions"]);
1693 if (!count($selected_array)) {
1694 ilUtil::sendInfo($this->lng->txt("tst_insert_missing_question"));
1695 } else {
1696 $total = $this->object->evalTotalPersons();
1697 if ($total) {
1698 // the test was executed previously
1699 ilUtil::sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total));
1700 } else {
1701 ilUtil::sendInfo($this->lng->txt("tst_insert_questions"));
1702 }
1703 foreach ($selected_array as $key => $value) {
1704 $this->object->insertQuestion($this->testQuestionSetConfigFactory->getQuestionSetConfig(), $value);
1705 }
1706 $this->object->saveCompleteStatus($this->testQuestionSetConfigFactory->getQuestionSetConfig());
1707 ilUtil::sendSuccess($this->lng->txt("tst_questions_inserted"), true);
1708 $this->ctrl->redirect($this, "questions");
1709 return;
1710 }
1711 }
1712
1714 {
1715 $this->questionBrowser();
1716 }
1717
1724 {
1725 $qpl_ref_id = $_REQUEST["sel_qpl"];
1726
1727 $qpl_mode = 1;
1728 if (array_key_exists('usage', $_REQUEST) && is_numeric($_REQUEST['usage'])) {
1729 $qpl_mode = $_REQUEST['usage'];
1730 }
1731
1732 if (isset($_REQUEST['qtype'])) {
1733 include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
1734 $sel_question_types = ilObjQuestionPool::getQuestionTypeByTypeId($_REQUEST["qtype"]);
1735 } elseif (isset($_REQUEST['sel_question_types'])) {
1736 $sel_question_types = $_REQUEST["sel_question_types"];
1737 }
1738
1739 if (($qpl_mode == 2 && strcmp($_REQUEST["txt_qpl"], "") == 0) ||
1740 ($qpl_mode == 3 && strcmp($qpl_ref_id, "") == 0)) {
1741 // Mantis #14890
1742 $_REQUEST['sel_question_types'] = $sel_question_types;
1743 ilUtil::sendInfo($this->lng->txt("questionpool_not_entered"));
1744 $this->createQuestionObject();
1745 return;
1746 } else {
1747 $_SESSION["test_id"] = $this->object->getRefId();
1748 if ($qpl_mode == 2 && strcmp($_REQUEST["txt_qpl"], "") != 0) {
1749 // create a new question pool and return the reference id
1750 $qpl_ref_id = $this->createQuestionPool($_REQUEST["txt_qpl"]);
1751 } elseif ($qpl_mode == 1) {
1752 $qpl_ref_id = $_GET["ref_id"];
1753 }
1754
1755 $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;
1756
1757 if (isset($_REQUEST['prev_qid'])) {
1758 $baselink .= '&prev_qid=' . $_REQUEST['prev_qid'];
1759 } elseif (isset($_REQUEST['position'])) {
1760 $baselink .= '&prev_qid=' . $_REQUEST['position'];
1761 }
1762
1763 if ($_REQUEST['test_express_mode']) {
1764 $baselink .= '&test_express_mode=1';
1765 }
1766
1767 if (isset($_REQUEST['add_quest_cont_edit_mode'])) {
1769 $baselink,
1770 "add_quest_cont_edit_mode={$_REQUEST['add_quest_cont_edit_mode']}",
1771 false
1772 );
1773 }
1774
1775 ilUtil::redirect($baselink);
1776
1777 exit();
1778 }
1779 }
1780
1789 {
1790 $this->ctrl->redirect($this, "questions");
1791 }
1792
1800 public function createQuestionObject()
1801 {
1802 global $DIC;
1803 $ilUser = $DIC['ilUser'];
1804 $this->getTabsManager()->getQuestionsSubTabs();
1806 //$this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_qpl_select.html", "Modules/Test");
1807 $questionpools = &$this->object->getAvailableQuestionpools(false, false, false, true, false, "write");
1808
1809 if ($this->object->getPoolUsage()) {
1810 global $DIC;
1811 $lng = $DIC['lng'];
1812 $ilCtrl = $DIC['ilCtrl'];
1813 $tpl = $DIC['tpl'];
1814
1815 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
1816
1817 $form = new ilPropertyFormGUI();
1818 $form->setFormAction($ilCtrl->getFormAction($this, "executeCreateQuestion"));
1819 $form->setTitle($lng->txt("ass_create_question"));
1820 include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
1821
1822
1823 $hidden = new ilHiddenInputGUI('sel_question_types');
1824 $hidden->setValue($_REQUEST["sel_question_types"]);
1825 $form->addItem($hidden);
1826
1827 // content editing mode
1829 $ri = new ilRadioGroupInputGUI($lng->txt("tst_add_quest_cont_edit_mode"), "add_quest_cont_edit_mode");
1830
1831 $option_ipe = new ilRadioOption(
1832 $lng->txt('tst_add_quest_cont_edit_mode_IPE'),
1833 assQuestion::ADDITIONAL_CONTENT_EDITING_MODE_PAGE_OBJECT
1834 );
1835 $option_ipe->setInfo($lng->txt('tst_add_quest_cont_edit_mode_IPE_info'));
1836 $ri->addOption($option_ipe);
1837
1838 $option_rte = new ilRadioOption(
1839 $lng->txt('tst_add_quest_cont_edit_mode_RTE'),
1841 );
1842 $option_rte->setInfo($lng->txt('tst_add_quest_cont_edit_mode_RTE_info'));
1843 $ri->addOption($option_rte);
1844
1846
1847 $form->addItem($ri, true);
1848 } else {
1849 $hi = new ilHiddenInputGUI("question_content_editing_type");
1851 $form->addItem($hi, true);
1852 }
1853
1854 // use pool
1855 $usage = new ilRadioGroupInputGUI($this->lng->txt("assessment_pool_selection"), "usage");
1856 $usage->setRequired(true);
1857 $no_pool = new ilRadioOption($this->lng->txt("assessment_no_pool"), 1);
1858 $usage->addOption($no_pool);
1859 $existing_pool = new ilRadioOption($this->lng->txt("assessment_existing_pool"), 3);
1860 $usage->addOption($existing_pool);
1861 $new_pool = new ilRadioOption($this->lng->txt("assessment_new_pool"), 2);
1862 $usage->addOption($new_pool);
1863 $form->addItem($usage);
1864
1865 $usage->setValue(1);
1866
1867 $questionpools = ilObjQuestionPool::_getAvailableQuestionpools(false, false, true, false, false, "write");
1868 $pools_data = array();
1869 foreach ($questionpools as $key => $p) {
1870 $pools_data[$key] = $p['title'];
1871 }
1872 $pools = new ilSelectInputGUI($this->lng->txt("select_questionpool"), "sel_qpl");
1873 $pools->setOptions($pools_data);
1874 $existing_pool->addSubItem($pools);
1875
1876
1877 $this->lng->loadLanguageModule('rbac');
1878 $name = new ilTextInputGUI($this->lng->txt("rbac_create_qpl"), "txt_qpl");
1879 $name->setSize(50);
1880 $name->setMaxLength(50);
1881 $new_pool->addSubItem($name);
1882
1883 $form->addCommandButton("executeCreateQuestion", $lng->txt("submit"));
1884 $form->addCommandButton("cancelCreateQuestion", $lng->txt("cancel"));
1885
1886 return $this->tpl->setVariable('ADM_CONTENT', $form->getHTML());
1887 } else {
1888 global $DIC;
1889 $ilCtrl = $DIC['ilCtrl'];
1890
1891 $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'sel_question_types', $_REQUEST["sel_question_types"]);
1892 $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'add_quest_cont_edit_mode', $_REQUEST["add_quest_cont_edit_mode"]);
1893 $link = $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'handleToolbarCommand', '', false, false);
1894 ilUtil::redirect($link);
1895 }
1896 }
1897
1902 {
1903 $removeQuestionIds = (array) $_POST["q_id"];
1904
1905 $questions = $this->object->getQuestionTitlesAndIndexes();
1906
1907 $this->object->removeQuestions($removeQuestionIds);
1908
1909 $this->object->saveCompleteStatus($this->testQuestionSetConfigFactory->getQuestionSetConfig());
1910
1911 ilUtil::sendSuccess($this->lng->txt("tst_questions_removed"));
1912
1913 if ($_REQUEST['test_express_mode']) {
1914 $prev = null;
1915 $return_to = null;
1916 $deleted_tmp = $removeQuestionIds;
1917 $first = array_shift($deleted_tmp);
1918 foreach ((array) $questions as $key => $value) {
1919 if (!in_array($key, $removeQuestionIds)) {
1920 $prev = $key;
1921 if (!$first) {
1922 $return_to = $prev;
1923 break;
1924 } else {
1925 continue;
1926 }
1927 } elseif ($key == $first) {
1928 if ($prev) {
1929 $return_to = $prev;
1930 break;
1931 }
1932 $first = array_shift($deleted_tmp);
1933 }
1934 }
1935
1936 if (
1937 count($questions) == count($removeQuestionIds) ||
1938 !$return_to
1939 ) {
1940 $this->ctrl->setParameter($this, 'q_id', '');
1941 $this->ctrl->redirect($this, 'showPage');
1942 }
1943
1944 $this->ctrl->setParameter($this, 'q_id', $return_to);
1945 $this->ctrl->redirect($this, "showPage");
1946 } else {
1947 $this->ctrl->setParameter($this, 'q_id', '');
1948 $this->ctrl->redirect($this, 'questions');
1949 }
1950 }
1951
1960 {
1961 if ($_REQUEST['test_express_mode']) {
1962 $this->ctrl->setParameter($this, 'q_id', $_REQUEST['q_id']);
1963 $this->ctrl->redirect($this, "showPage");
1964 } else {
1965 $this->ctrl->redirect($this, "questions");
1966 }
1967 }
1968
1976 public function removeQuestionsForm($checked_questions)
1977 {
1978 $total = $this->object->evalTotalPersons();
1979 if ($total) {
1980 // the test was executed previously
1981 $question = sprintf($this->lng->txt("tst_remove_questions_and_results"), $total);
1982 } else {
1983 if (count($checked_questions) == 1) {
1984 $question = $this->lng->txt("tst_remove_question");
1985 } else {
1986 $question = $this->lng->txt("tst_remove_questions");
1987 }
1988 }
1989
1990 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
1991 $cgui = new ilConfirmationGUI();
1992 $cgui->setHeaderText($question);
1993
1994 $this->ctrl->saveParameter($this, 'test_express_mode');
1995 $this->ctrl->saveParameter($this, 'q_id');
1996
1997 $cgui->setFormAction($this->ctrl->getFormAction($this));
1998 $cgui->setCancel($this->lng->txt("cancel"), "cancelRemoveQuestions");
1999 $cgui->setConfirm($this->lng->txt("confirm"), "confirmRemoveQuestions");
2000
2001 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
2002 $removablequestions = &$this->object->getTestQuestions();
2003 if (count($removablequestions)) {
2004 foreach ($removablequestions as $data) {
2005 if (in_array($data["question_id"], $checked_questions)) {
2006 $txt = $data["title"] . " (" . assQuestion::_getQuestionTypeName($data["type_tag"]) . ")";
2007 $txt .= ' [' . $this->lng->txt('question_id_short') . ': ' . $data['question_id'] . ']';
2008
2009 if ($data["description"]) {
2010 $txt .= "<div class=\"small\">" . $data["description"] . "</div>";
2011 }
2012
2013 $cgui->addItem("q_id[]", $data["question_id"], $txt);
2014 }
2015 }
2016 }
2017
2018 $this->tpl->setContent($cgui->getHTML());
2019 }
2020
2024 public function removeQuestionsObject()
2025 {
2026 $this->getTabsManager()->getQuestionsSubTabs();
2027
2028 $checked_questions = $_REQUEST["q_id"];
2029
2030 if (!is_array($checked_questions) && $checked_questions) {
2031 $checked_questions = array($checked_questions);
2032 }
2033
2034 if (!is_array($checked_questions)) {
2035 $checked_questions = [];
2036 }
2037
2038 if (count($checked_questions) > 0) {
2039 $this->removeQuestionsForm($checked_questions);
2040 } elseif (0 === count($checked_questions)) {
2041 ilUtil::sendFailure($this->lng->txt("tst_no_question_selected_for_removal"), true);
2042 $this->ctrl->redirect($this, "questions");
2043 }
2044 }
2045
2049 public function moveQuestionsObject()
2050 {
2051 $selected_questions = null;
2052 $selected_questions = $_POST['q_id'];
2053 if ($selected_questions === null && is_numeric($_GET['q_id'])) {
2054 $selected_questions = [$_GET['q_id']];
2055 }
2056 if (is_array($selected_questions)) {
2057 $_SESSION['tst_qst_move_' . $this->object->getTestId()] = $selected_questions;
2058 ilUtil::sendSuccess($this->lng->txt("msg_selected_for_move"), true);
2059 } else {
2060 ilUtil::sendFailure($this->lng->txt('no_selection_for_move'), true);
2061 }
2062 $this->ctrl->redirect($this, 'questions');
2063 }
2064
2069 {
2070 // get all questions to move
2071 $move_questions = $_SESSION['tst_qst_move_' . $this->object->getTestId()];
2072
2073 if (!is_array($_POST['q_id']) || 0 === count($_POST['q_id'])) {
2074 ilUtil::sendFailure($this->lng->txt("no_target_selected_for_move"), true);
2075 $this->ctrl->redirect($this, 'questions');
2076 }
2077 if (count($_POST['q_id']) > 1) {
2078 ilUtil::sendFailure($this->lng->txt("too_many_targets_selected_for_move"), true);
2079 $this->ctrl->redirect($this, 'questions');
2080 }
2081 $insert_mode = 0;
2082 $this->object->moveQuestions($_SESSION['tst_qst_move_' . $this->object->getTestId()], $_POST['q_id'][0], $insert_mode);
2083 ilUtil::sendSuccess($this->lng->txt("msg_questions_moved"), true);
2084 unset($_SESSION['tst_qst_move_' . $this->object->getTestId()]);
2085 $this->ctrl->redirect($this, "questions");
2086 }
2087
2092 {
2093 // get all questions to move
2094 $move_questions = $_SESSION['tst_qst_move_' . $this->object->getTestId()];
2095 if (!is_array($_POST['q_id']) || 0 === count($_POST['q_id'])) {
2096 ilUtil::sendFailure($this->lng->txt("no_target_selected_for_move"), true);
2097 $this->ctrl->redirect($this, 'questions');
2098 }
2099 if (count($_POST['q_id']) > 1) {
2100 ilUtil::sendFailure($this->lng->txt("too_many_targets_selected_for_move"), true);
2101 $this->ctrl->redirect($this, 'questions');
2102 }
2103 $insert_mode = 1;
2104 $this->object->moveQuestions($_SESSION['tst_qst_move_' . $this->object->getTestId()], $_POST['q_id'][0], $insert_mode);
2105 ilUtil::sendSuccess($this->lng->txt("msg_questions_moved"), true);
2106 unset($_SESSION['tst_qst_move_' . $this->object->getTestId()]);
2107 $this->ctrl->redirect($this, "questions");
2108 }
2109
2115 public function insertQuestionsObject()
2116 {
2117 $selected_array = (is_array($_POST['q_id'])) ? $_POST['q_id'] : array();
2118 if (!count($selected_array)) {
2119 ilUtil::sendInfo($this->lng->txt("tst_insert_missing_question"), true);
2120 $this->ctrl->redirect($this, "browseForQuestions");
2121 } else {
2122 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
2123 $manscoring = false;
2124 foreach ($selected_array as $key => $value) {
2125 $this->object->insertQuestion($this->testQuestionSetConfigFactory->getQuestionSetConfig(), $value);
2126 if (!$manscoring) {
2127 $manscoring = $manscoring | assQuestion::_needsManualScoring($value);
2128 }
2129 }
2130 $this->object->saveCompleteStatus($this->testQuestionSetConfigFactory->getQuestionSetConfig());
2131 if ($manscoring) {
2132 ilUtil::sendInfo($this->lng->txt("manscoring_hint"), true);
2133 } else {
2134 ilUtil::sendSuccess($this->lng->txt("tst_questions_inserted"), true);
2135 }
2136 $this->ctrl->redirect($this, "questions");
2137 return;
2138 }
2139 }
2140
2141 public function addQuestionObject()
2142 {
2143 global $DIC;
2144 $lng = $DIC['lng'];
2145 $ilCtrl = $DIC['ilCtrl'];
2146 $tpl = $DIC['tpl'];
2147 global $DIC; /* @var \ILIAS\DI\Container $DIC */
2148 $ilHelp = $DIC['ilHelp']; /* @var ilHelpGUI $ilHelp */
2149
2150 $this->getTabsManager()->getQuestionsSubTabs();
2152
2153 $subScreenId = array('createQuestion');
2154
2155 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
2156
2157 $ilCtrl->setParameter($this, 'qtype', $_REQUEST['qtype']);
2158
2159 $form = new ilPropertyFormGUI();
2160
2161 $form->setFormAction($ilCtrl->getFormAction($this, "executeCreateQuestion"));
2162 $form->setTitle($lng->txt("ass_create_question"));
2163 include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
2164
2165 $pool = new ilObjQuestionPool();
2166 $questionTypes = $pool->getQuestionTypes(false, true, false);
2167 $options = array();
2168
2169 // question type
2170 foreach ($questionTypes as $label => $data) {
2171 $options[$data['question_type_id']] = $label;
2172 }
2173
2174 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
2175 $si = new ilSelectInputGUI($lng->txt("question_type"), "qtype");
2176 $si->setOptions($options);
2177 $form->addItem($si, true);
2178
2179 // position
2180 $questions = $this->object->getQuestionTitlesAndIndexes();
2181 if ($questions) {
2182 $si = new ilSelectInputGUI($lng->txt("position"), "position");
2183 $options = array('0' => $lng->txt('first'));
2184 foreach ($questions as $key => $title) {
2185 $options[$key] = $lng->txt('behind') . ' ' . $title . ' [' . $this->lng->txt('question_id_short') . ': ' . $key . ']';
2186 }
2187 $si->setOptions($options);
2188 $si->setValue($_REQUEST['q_id']);
2189 $form->addItem($si, true);
2190 }
2191
2192 // content editing mode
2194 $subScreenId[] = 'editMode';
2195
2196 $ri = new ilRadioGroupInputGUI($lng->txt("tst_add_quest_cont_edit_mode"), "add_quest_cont_edit_mode");
2197
2198 $option_ipe = new ilRadioOption(
2199 $lng->txt('tst_add_quest_cont_edit_mode_IPE'),
2201 );
2202 $option_ipe->setInfo($lng->txt('tst_add_quest_cont_edit_mode_IPE_info'));
2203 $ri->addOption($option_ipe);
2204
2205 $option_rte = new ilRadioOption(
2206 $lng->txt('tst_add_quest_cont_edit_mode_RTE'),
2208 );
2209 $option_rte->setInfo($lng->txt('tst_add_quest_cont_edit_mode_RTE_info'));
2210 $ri->addOption($option_rte);
2211
2213
2214 $form->addItem($ri, true);
2215 } else {
2216 $hi = new ilHiddenInputGUI("question_content_editing_type");
2218 $form->addItem($hi, true);
2219 }
2220
2221 if ($this->object->getPoolUsage()) {
2222 $subScreenId[] = 'poolSelect';
2223
2224 // use pool
2225 $usage = new ilRadioGroupInputGUI($this->lng->txt("assessment_pool_selection"), "usage");
2226 $usage->setRequired(true);
2227 $no_pool = new ilRadioOption($this->lng->txt("assessment_no_pool"), 1);
2228 $usage->addOption($no_pool);
2229 $existing_pool = new ilRadioOption($this->lng->txt("assessment_existing_pool"), 3);
2230 $usage->addOption($existing_pool);
2231 $new_pool = new ilRadioOption($this->lng->txt("assessment_new_pool"), 2);
2232 $usage->addOption($new_pool);
2233 $form->addItem($usage);
2234
2235 $usage->setValue(1);
2236
2237 $questionpools = ilObjQuestionPool::_getAvailableQuestionpools(false, false, true, false, false, "write");
2238 $pools_data = array();
2239 foreach ($questionpools as $key => $p) {
2240 $pools_data[$key] = $p['title'];
2241 }
2242 $pools = new ilSelectInputGUI($this->lng->txt("select_questionpool"), "sel_qpl");
2243 $pools->setOptions($pools_data);
2244 $existing_pool->addSubItem($pools);
2245
2246 $name = new ilTextInputGUI($this->lng->txt("name"), "txt_qpl");
2247 $name->setSize(50);
2248 $name->setMaxLength(50);
2249 $new_pool->addSubItem($name);
2250 }
2251
2252 $form->addCommandButton("executeCreateQuestion", $lng->txt("create"));
2253 $form->addCommandButton("questions", $lng->txt("cancel"));
2254
2255 $DIC->tabs()->activateTab('assQuestions');
2256 $ilHelp->setScreenId('assQuestions');
2257 $ilHelp->setSubScreenId(implode('_', $subScreenId));
2258
2259 return $tpl->setContent($form->getHTML());
2260 }
2261
2262 public function questionsObject()
2263 {
2264 global $DIC; /* @var ILIAS\DI\Container $DIC */
2265 $ilAccess = $DIC['ilAccess'];
2266 $ilTabs = $DIC['ilTabs'];
2267
2268 // #12590
2269 $this->ctrl->setParameter($this, 'test_express_mode', '');
2270
2271 if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
2272 // allow only write access
2273 ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
2274 $this->ctrl->redirect($this, "infoScreen");
2275 }
2276
2277 if ($_GET['browse']) {
2278 return $this->questionbrowser();
2279 }
2280
2281 $this->getTabsManager()->getQuestionsSubTabs();
2283
2284 // #11631, #12994
2285 $this->ctrl->setParameter($this, 'q_id', '');
2286
2287 if ($_GET["eqid"] && $_GET["eqpl"]) {
2288 ilUtil::redirect("ilias.php?baseClass=ilObjQuestionPoolGUI&ref_id=" . $_GET["eqpl"] . "&cmd=editQuestionForTest&calling_test=" . $_GET["ref_id"] . "&q_id=" . $_GET["eqid"]);
2289 }
2290
2291 if ($_GET["up"] > 0) {
2292 $this->object->questionMoveUp($_GET["up"]);
2293 }
2294 if ($_GET["down"] > 0) {
2295 $this->object->questionMoveDown($_GET["down"]);
2296 }
2297
2298 if ($_GET["add"]) {
2299 $selected_array = array();
2300 array_push($selected_array, $_GET["add"]);
2301 $total = $this->object->evalTotalPersons();
2302 if ($total) {
2303 // the test was executed previously
2304 ilUtil::sendInfo(sprintf($this->lng->txt("tst_insert_questions_and_results"), $total));
2305 } else {
2306 ilUtil::sendInfo($this->lng->txt("tst_insert_questions"));
2307 }
2308 $this->insertQuestions($selected_array);
2309 return;
2310 }
2311
2312 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_questions.html", "Modules/Test");
2313
2314 $total = $this->object->evalTotalPersons();
2315 if ($ilAccess->checkAccess("write", "", $this->ref_id)) {
2316 if ($total != 0) {
2317 $link = $DIC->ui()->factory()->link()->standard(
2318 $DIC->language()->txt("test_has_datasets_warning_page_view_link"),
2319 $DIC->ctrl()->getLinkTargetByClass(array('ilTestResultsGUI', 'ilParticipantsTestResultsGUI'))
2320 );
2321
2322 $message = $DIC->language()->txt("test_has_datasets_warning_page_view");
2323
2324 $msgBox = $DIC->ui()->factory()->messageBox()->info($message)->withLinks(array($link));
2325
2326 $DIC->ui()->mainTemplate()->setCurrentBlock('mess');
2327 $DIC->ui()->mainTemplate()->setVariable(
2328 'MESSAGE',
2329 $DIC->ui()->renderer()->render($msgBox)
2330 );
2331 $DIC->ui()->mainTemplate()->parseCurrentBlock();
2332 } else {
2333 global $DIC;
2334 $ilToolbar = $DIC['ilToolbar'];
2335
2336 $ilToolbar->addButton($this->lng->txt("ass_create_question"), $this->ctrl->getLinkTarget($this, "addQuestion"));
2337
2338 if ($this->object->getPoolUsage()) {
2339 $ilToolbar->addSeparator();
2340
2341 require_once 'Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php';
2342
2344 }
2345
2346 $ilToolbar->addSeparator();
2347 $ilToolbar->addButton($this->lng->txt("random_selection"), $this->ctrl->getLinkTarget($this, "randomselect"));
2348
2349
2350 global $DIC;
2351 $ilAccess = $DIC['ilAccess'];
2352 $ilUser = $DIC['ilUser'];
2353 $lng = $DIC['lng'];
2354 $ilCtrl = $DIC['ilCtrl'];
2355 $online_access = false;
2356 if ($this->object->getFixedParticipants()) {
2357 include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
2358 $online_access_result = ilObjTestAccess::_lookupOnlineTestAccess($this->object->getId(), $ilUser->getId());
2359 if ($online_access_result === true) {
2360 $online_access = true;
2361 }
2362 }
2363 /*
2364 if (!$this->object->getOfflineStatus() && $this->object->isComplete($this->testQuestionSetConfigFactory->getQuestionSetConfig())) {
2365 if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id)) {
2366 $testSession = $this->testSessionFactory->getSession();
2367 $testSequence = $this->testSequenceFactory->getSequenceByTestSession($testSession);
2368
2369 $testPlayerGUI = $this->testPlayerFactory->getPlayerGUI();
2370
2371 $executable = $this->object->isExecutable($testSession, $ilUser->getId(), $allowPassIncrease = true);
2372
2373 if ($executable["executable"]) {
2374 if ($testSession->getActiveId() > 0) {
2375 // resume test
2376
2377 if ($testSequence->hasStarted($testSession)) {
2378 $execTestLabel = $this->lng->txt("tst_resume_test");
2379 $execTestLink = $this->ctrl->getLinkTarget($testPlayerGUI, 'resumePlayer');
2380 } else {
2381 $execTestLabel = $this->object->getStartTestLabel($testSession->getActiveId());
2382 $execTestLink = $this->ctrl->getLinkTarget($testPlayerGUI, 'startPlayer');
2383 }
2384 } else {
2385 // start new test
2386
2387 $execTestLabel = $this->object->getStartTestLabel($testSession->getActiveId());
2388 $execTestLink = $this->ctrl->getLinkTarget($testPlayerGUI, 'startPlayer');
2389 }
2390
2391 $ilToolbar->addSeparator();
2392 $ilToolbar->addButton($execTestLabel, $execTestLink);
2393 }
2394 }
2395 }
2396 */
2397 }
2398 }
2399
2400 $table_gui = new ilTestQuestionsTableGUI(
2401 $this,
2402 'questions',
2403 $this->object->getRefId()
2404 );
2405
2406 $table_gui->setPositionInsertCommandsEnabled(
2407 is_array($_SESSION['tst_qst_move_' . $this->object->getTestId()])
2408 && count($_SESSION['tst_qst_move_' . $this->object->getTestId()])
2409 );
2410
2411 $table_gui->setQuestionPositioningEnabled(!$total);
2412 $table_gui->setQuestionManagingEnabled(!$total);
2413 $table_gui->setObligatoryQuestionsHandlingEnabled($this->object->areObligationsEnabled());
2414
2415 $table_gui->setTotalPoints($this->object->getFixedQuestionSetTotalPoints());
2416 $table_gui->setTotalWorkingTime($this->object->getFixedQuestionSetTotalWorkingTime());
2417
2418 $table_gui->init();
2419
2420 $table_gui->setData($this->object->getTestQuestions());
2421
2422 $this->tpl->setCurrentBlock("adm_content");
2423 $this->tpl->setVariable("ACTION_QUESTION_FORM", $this->ctrl->getFormAction($this));
2424 $this->tpl->setVariable('QUESTIONBROWSER', $table_gui->getHTML());
2425 $this->tpl->parseCurrentBlock();
2426 }
2427
2433 {
2434 require_once 'Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php';
2435
2436 $this->ctrl->setParameterByClass('ilTestQuestionBrowserTableGUI', ilTestQuestionBrowserTableGUI::CONTEXT_PARAMETER, $context);
2437
2438 $this->ctrl->setParameterByClass('ilTestQuestionBrowserTableGUI', ilTestQuestionBrowserTableGUI::MODE_PARAMETER, ilTestQuestionBrowserTableGUI::MODE_BROWSE_POOLS);
2439
2440 $toolbar->addButton($this->lng->txt("tst_browse_for_qpl_questions"), $this->ctrl->getLinkTargetByClass('ilTestQuestionBrowserTableGUI', ilTestQuestionBrowserTableGUI::CMD_BROWSE_QUESTIONS));
2441
2442 $this->ctrl->setParameterByClass('ilTestQuestionBrowserTableGUI', ilTestQuestionBrowserTableGUI::MODE_PARAMETER, ilTestQuestionBrowserTableGUI::MODE_BROWSE_TESTS);
2443
2444 $toolbar->addButton($this->lng->txt("tst_browse_for_tst_questions"), $this->ctrl->getLinkTargetByClass('ilTestQuestionBrowserTableGUI', ilTestQuestionBrowserTableGUI::CMD_BROWSE_QUESTIONS));
2445 }
2446
2447 public function takenObject()
2448 {
2449 }
2450
2458 public function historyObject()
2459 {
2460 global $DIC; /* @var ILIAS\DI\Container $DIC */
2461
2462 $DIC->tabs()->activateTab(ilTestTabsManager::TAB_ID_HISTORY);
2463
2464 include_once "./Modules/Test/classes/tables/class.ilTestHistoryTableGUI.php";
2465 $table_gui = new ilTestHistoryTableGUI($this, 'history');
2466 $table_gui->setTestObject($this->object);
2467 include_once "./Modules/Test/classes/class.ilObjAssessmentFolder.php";
2468 $log = ilObjAssessmentFolder::_getLog(0, time(), $this->object->getId(), true);
2469 $table_gui->setData($log);
2470 $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
2471 }
2472
2473 public function initImportForm($a_new_type)
2474 {
2475 include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
2476 $form = new ilPropertyFormGUI();
2477 $form->setTarget("_top");
2478 $new_type = $_POST["new_type"] ? $_POST["new_type"] : $_GET["new_type"];
2479 $this->ctrl->setParameter($this, "new_type", $new_type);
2480 $form->setFormAction($this->ctrl->getFormAction($this));
2481 $form->setTitle($this->lng->txt("import_tst"));
2482
2483 // file
2484 include_once("./Services/Form/classes/class.ilFileInputGUI.php");
2485 $fi = new ilFileInputGUI($this->lng->txt("import_file"), "xmldoc");
2486 $fi->setSuffixes(array("zip"));
2487 $fi->setRequired(true);
2488 $form->addItem($fi);
2489
2490 // question pool
2491 include_once("./Modules/Test/classes/class.ilObjTest.php");
2492 $tst = new ilObjTest();
2493 $questionpools = $tst->getAvailableQuestionpools(true, false, true, true);
2494 if (count($questionpools)) {
2495 $options = array("-1" => $this->lng->txt("dont_use_questionpool"));
2496 foreach ($questionpools as $key => $value) {
2497 $options[$key] = $value["title"];
2498 }
2499
2500 $pool = new ilSelectInputGUI($this->lng->txt("select_questionpool"), "qpl");
2501 $pool->setInfo($this->lng->txt('select_question_pool_info'));
2502 $pool->setOptions($options);
2503 $form->addItem($pool);
2504 }
2505
2506 $form->addCommandButton("importFile", $this->lng->txt("import"));
2507 $form->addCommandButton("cancel", $this->lng->txt("cancel"));
2508
2509 return $form;
2510 }
2511
2518 {
2519 $command = $_POST["command"];
2520 if (strlen($command)) {
2521 $method = $command . "Object";
2522 if (method_exists($this, $method)) {
2523 $this->$method();
2524 return;
2525 }
2526 }
2527 $this->ctrl->redirect($this, "participants");
2528 }
2529
2537 public function printobject()
2538 {
2539 global $DIC;
2540 $ilAccess = $DIC['ilAccess'];
2541 $ilias = $DIC['ilias'];
2542 if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
2543 // allow only write access
2544 ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
2545 $this->ctrl->redirect($this, "infoScreen");
2546 }
2547
2548 $isPdfDeliveryRequest = isset($_GET['pdf']) && $_GET['pdf'];
2549
2550 $this->getTabsManager()->getQuestionsSubTabs();
2551 $template = new ilTemplate("tpl.il_as_tst_print_test_confirm.html", true, true, "Modules/Test");
2552
2553 if (!$isPdfDeliveryRequest) { // #15243
2554 $this->ctrl->setParameter($this, "pdf", "1");
2555 $template->setCurrentBlock("pdf_export");
2556 $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "print"));
2557 $this->ctrl->setParameter($this, "pdf", "");
2558 $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
2559 $template->parseCurrentBlock();
2560
2561 $template->setCurrentBlock("navigation_buttons");
2562 $template->setVariable("BUTTON_PRINT", $this->lng->txt("print"));
2563 $template->parseCurrentBlock();
2564 }
2565 // prepare generation before contents are processed (for mathjax)
2566 else {
2568 }
2569
2570 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
2571
2572 global $DIC;
2573 $ilUser = $DIC['ilUser'];
2574 $print_date = mktime(date("H"), date("i"), date("s"), date("m"), date("d"), date("Y"));
2575 $max_points = 0;
2576 $counter = 1;
2577
2578 require_once 'Modules/Test/classes/class.ilTestQuestionHeaderBlockBuilder.php';
2579 $questionHeaderBlockBuilder = new ilTestQuestionHeaderBlockBuilder($this->lng);
2580 $questionHeaderBlockBuilder->setHeaderMode($this->object->getTitleOutput());
2581
2582 if ($isPdfDeliveryRequest) {
2583 require_once 'Services/WebAccessChecker/classes/class.ilWACSignedPath.php';
2585 }
2586
2587 foreach ($this->object->questions as $question) {
2588 $template->setCurrentBlock("question");
2589 $question_gui = $this->object->createQuestionGUI("", $question);
2590
2591 if ($isPdfDeliveryRequest) {
2592 $question_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_PRINT_PDF);
2593 }
2594
2595 $questionHeaderBlockBuilder->setQuestionTitle($question_gui->object->getTitle());
2596 $questionHeaderBlockBuilder->setQuestionPoints($question_gui->object->getMaximumPoints());
2597 $questionHeaderBlockBuilder->setQuestionPosition($counter);
2598 $template->setVariable("QUESTION_HEADER", $questionHeaderBlockBuilder->getHTML());
2599
2600 $template->setVariable("TXT_QUESTION_ID", $this->lng->txt('question_id_short'));
2601 $template->setVariable("QUESTION_ID", $question_gui->object->getId());
2602 $result_output = $question_gui->getSolutionOutput("", null, false, true, false, $this->object->getShowSolutionFeedback());
2603 $template->setVariable("SOLUTION_OUTPUT", $result_output);
2604 $template->parseCurrentBlock("question");
2605 $counter++;
2606 $max_points += $question_gui->object->getMaximumPoints();
2607 }
2608
2609 $template->setVariable("TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
2610 $template->setVariable("PRINT_TEST", ilUtil::prepareFormOutput($this->lng->txt("tst_print")));
2611 $template->setVariable("TXT_PRINT_DATE", ilUtil::prepareFormOutput($this->lng->txt("date")));
2612 $template->setVariable("VALUE_PRINT_DATE", ilUtil::prepareFormOutput(strftime("%c", $print_date)));
2613 $template->setVariable("TXT_MAXIMUM_POINTS", ilUtil::prepareFormOutput($this->lng->txt("tst_maximum_points")));
2614 $template->setVariable("VALUE_MAXIMUM_POINTS", ilUtil::prepareFormOutput($max_points));
2615
2616 if ($isPdfDeliveryRequest) {
2617 ilTestPDFGenerator::generatePDF($template->get(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->object->getTitleFilenameCompliant(), PDF_PRINT_VIEW_QUESTIONS);
2618 } else {
2619 $this->tpl->setVariable("PRINT_CONTENT", $template->get());
2620 }
2621 }
2622
2630 public function reviewobject()
2631 {
2632 global $DIC;
2633 $ilAccess = $DIC['ilAccess'];
2634
2635 if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
2636 // allow only write access
2637 ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
2638 $this->ctrl->redirect($this, "infoScreen");
2639 }
2640 $this->getTabsManager()->getQuestionsSubTabs();
2641 $template = new ilTemplate("tpl.il_as_tst_print_test_confirm.html", true, true, "Modules/Test");
2642
2643 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css", "Modules/Test"), "print");
2644
2645 $isPdfDeliveryRequest = isset($_GET['pdf']) && $_GET['pdf'];
2646
2647 $max_points = 0;
2648 $counter = 1;
2649
2650 require_once 'Modules/Test/classes/class.ilTestQuestionHeaderBlockBuilder.php';
2651 $questionHeaderBlockBuilder = new ilTestQuestionHeaderBlockBuilder($this->lng);
2652 $questionHeaderBlockBuilder->setHeaderMode($this->object->getTitleOutput());
2653
2654 if ($isPdfDeliveryRequest) {
2655 require_once 'Services/WebAccessChecker/classes/class.ilWACSignedPath.php';
2657
2658 // prepare generation before contents are processed (for mathjax)
2660 }
2661
2662 foreach ($this->object->questions as $question) {
2663 $template->setCurrentBlock("question");
2664 $question_gui = $this->object->createQuestionGUI("", $question);
2665 $question_gui->setRenderPurpose(assQuestionGUI::RENDER_PURPOSE_PREVIEW);
2666
2667 $questionHeaderBlockBuilder->setQuestionTitle($question_gui->object->getTitle());
2668 $questionHeaderBlockBuilder->setQuestionPoints($question_gui->object->getMaximumPoints());
2669 $questionHeaderBlockBuilder->setQuestionPosition($counter);
2670 $template->setVariable("QUESTION_HEADER", $questionHeaderBlockBuilder->getHTML());
2671
2672 $template->setVariable("SOLUTION_OUTPUT", $question_gui->getPreview(false));
2673 $template->parseCurrentBlock("question");
2674 $counter++;
2675 $max_points += $question_gui->object->getMaximumPoints();
2676 }
2677
2678 $template->setVariable("TITLE", ilUtil::prepareFormOutput($this->object->getTitle()));
2679 $template->setVariable("PRINT_TEST", ilUtil::prepareFormOutput($this->lng->txt("review_view")));
2680 $template->setVariable("TXT_PRINT_DATE", ilUtil::prepareFormOutput($this->lng->txt("date")));
2681 $usedRelativeDates = ilDatePresentation::useRelativeDates();
2683 $template->setVariable(
2684 "VALUE_PRINT_DATE",
2686 );
2687 ilDatePresentation::setUseRelativeDates($usedRelativeDates);
2688 $template->setVariable("TXT_MAXIMUM_POINTS", ilUtil::prepareFormOutput($this->lng->txt("tst_maximum_points")));
2689 $template->setVariable("VALUE_MAXIMUM_POINTS", ilUtil::prepareFormOutput($max_points));
2690
2691 if ($isPdfDeliveryRequest) {
2692 ilTestPDFGenerator::generatePDF($template->get(), ilTestPDFGenerator::PDF_OUTPUT_DOWNLOAD, $this->object->getTitleFilenameCompliant(), PDF_PRINT_VIEW_QUESTIONS);
2693 } else {
2694 $this->ctrl->setParameter($this, "pdf", "1");
2695 $template->setCurrentBlock("pdf_export");
2696 $template->setVariable("PDF_URL", $this->ctrl->getLinkTarget($this, "review"));
2697 $this->ctrl->setParameter($this, "pdf", "");
2698 $template->setVariable("PDF_TEXT", $this->lng->txt("pdf_export"));
2699 $template->parseCurrentBlock();
2700
2701 $template->setCurrentBlock("navigation_buttons");
2702 $template->setVariable("BUTTON_PRINT", $this->lng->txt("print"));
2703 $template->parseCurrentBlock();
2704
2705
2706 $this->tpl->setVariable("PRINT_CONTENT", $template->get());
2707 }
2708 }
2709
2713 public function defaultsObject()
2714 {
2720 global $DIC;
2721 $ilAccess = $DIC['ilAccess'];
2722 $ilToolbar = $DIC['ilToolbar'];
2723 $tpl = $DIC['tpl'];
2724
2725 if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
2726 ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
2727 $this->ctrl->redirect($this, "infoScreen");
2728 }
2729
2730 global $DIC; /* @var ILIAS\DI\Container $DIC */
2731
2732 $DIC->tabs()->activateTab(ilTestTabsManager::TAB_ID_SETTINGS);
2733
2734 $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 'addDefaults'));
2735 $ilToolbar->addFormButton($this->lng->txt('add'), 'addDefaults');
2736 require_once 'Services/Form/classes/class.ilTextInputGUI.php';
2737 $ilToolbar->addInputItem(new ilTextInputGUI($this->lng->txt('tst_defaults_defaults_of_test'), 'name'), true);
2738
2739 require_once 'Modules/Test/classes/tables/class.ilTestPersonalDefaultSettingsTableGUI.php';
2740 $table = new ilTestPersonalDefaultSettingsTableGUI($this, 'defaults');
2741 $defaults = $this->object->getAvailableDefaults();
2742 $table->setData((array) $defaults);
2743 $tpl->setContent($table->getHTML());
2744 }
2745
2749 public function deleteDefaultsObject()
2750 {
2751 if (isset($_POST['chb_defaults']) && is_array($_POST['chb_defaults']) && count($_POST['chb_defaults'])) {
2752 foreach ($_POST['chb_defaults'] as $test_default_id) {
2753 $this->object->deleteDefaults($test_default_id);
2754 }
2755 } else {
2756 ilUtil::sendInfo($this->lng->txt('select_one'));
2757 }
2758 $this->defaultsObject();
2759 }
2760
2765 {
2766 $this->applyDefaultsObject(true);
2767 return;
2768 }
2769
2773 public function applyDefaultsObject($confirmed = false)
2774 {
2775 if (!is_array($_POST["chb_defaults"]) || 1 !== count($_POST["chb_defaults"])) {
2777 $this->lng->txt("tst_defaults_apply_select_one")
2778 );
2779
2780 return $this->defaultsObject();
2781 }
2782
2783 // do not apply if user datasets exist
2784 if ($this->object->evalTotalPersons() > 0) {
2786 $this->lng->txt("tst_defaults_apply_not_possible")
2787 );
2788
2789 return $this->defaultsObject();
2790 }
2791
2792 $defaults = &$this->object->getTestDefaults($_POST["chb_defaults"][0]);
2793 $defaultSettings = unserialize($defaults["defaults"]);
2794
2795 if (isset($defaultSettings['isRandomTest'])) {
2796 if ($defaultSettings['isRandomTest']) {
2797 $newQuestionSetType = ilObjTest::QUESTION_SET_TYPE_RANDOM;
2798 $this->object->setQuestionSetType(ilObjTest::QUESTION_SET_TYPE_RANDOM);
2799 } else {
2800 $newQuestionSetType = ilObjTest::QUESTION_SET_TYPE_FIXED;
2801 $this->object->setQuestionSetType(ilObjTest::QUESTION_SET_TYPE_FIXED);
2802 }
2803 } elseif (isset($defaultSettings['questionSetType'])) {
2804 $newQuestionSetType = $defaultSettings['questionSetType'];
2805 }
2806 $oldQuestionSetType = $this->object->getQuestionSetType();
2807 $questionSetTypeSettingSwitched = ($oldQuestionSetType != $newQuestionSetType);
2808
2809 $oldQuestionSetConfig = $this->testQuestionSetConfigFactory->getQuestionSetConfigByType($oldQuestionSetType);
2810
2811 switch (true) {
2812 case !$questionSetTypeSettingSwitched:
2813 case !$oldQuestionSetConfig->doesQuestionSetRelatedDataExist():
2814 case $confirmed:
2815
2816 break;
2817
2818 default:
2819
2820 require_once 'Modules/Test/classes/confirmations/class.ilTestSettingsChangeConfirmationGUI.php';
2821 $confirmation = new ilTestSettingsChangeConfirmationGUI($this->lng, $this->object);
2822
2823 $confirmation->setFormAction($this->ctrl->getFormAction($this));
2824 $confirmation->setCancel($this->lng->txt('cancel'), 'defaults');
2825 $confirmation->setConfirm($this->lng->txt('confirm'), 'confirmedApplyDefaults');
2826
2827 $confirmation->setOldQuestionSetType($this->object->getQuestionSetType());
2828 $confirmation->setNewQuestionSetType($newQuestionSetType);
2829 $confirmation->setQuestionLossInfoEnabled(false);
2830 $confirmation->build();
2831
2832 $confirmation->populateParametersFromPost();
2833
2834 $this->tpl->setContent($this->ctrl->getHTML($confirmation));
2835
2836 return;
2837 }
2838
2839 if ($questionSetTypeSettingSwitched && !$this->object->getOfflineStatus()) {
2840 $this->object->setOfflineStatus(true);
2841
2842 $info = $this->lng->txt("tst_set_offline_due_to_switched_question_set_type_setting");
2843
2844 ilUtil::sendInfo($info, true);
2845 }
2846
2847 $this->object->applyDefaults($defaults);
2848
2849 ilUtil::sendSuccess($this->lng->txt("tst_defaults_applied"), true);
2850
2851 if ($questionSetTypeSettingSwitched && $oldQuestionSetConfig->doesQuestionSetRelatedDataExist()) {
2852 $oldQuestionSetConfig->removeQuestionSetRelatedData();
2853 }
2854
2855 $this->ctrl->redirect($this, 'defaults');
2856 }
2857
2861 public function addDefaultsObject()
2862 {
2863 if (strlen($_POST["name"]) > 0) {
2864 $this->object->addDefaults($_POST['name']);
2865 } else {
2866 ilUtil::sendInfo($this->lng->txt("tst_defaults_enter_name"));
2867 }
2868 $this->defaultsObject();
2869 }
2870
2872 {
2873 if (in_array($this->ctrl->getCmdClass(), self::$infoScreenChildClasses)) {
2874 return true;
2875 }
2876
2877 return false;
2878 }
2879
2885 public function infoScreenObject()
2886 {
2887 #if( !include 'competenzenRocker.php' ) exit;
2888
2889 $this->ctrl->setCmd("showSummary");
2890 $this->ctrl->setCmdClass("ilinfoscreengui");
2891 $this->infoScreen();
2892 }
2893
2895 {
2896 $this->ctrl->setCmd("showSummary");
2897 $this->ctrl->setCmdClass("ilinfoscreengui");
2898 $this->infoScreen($_GET['lock']);
2899 }
2900
2904 public function infoScreen($session_lock = "")
2905 {
2906 global $DIC; /* @var ILIAS\DI\Container $DIC */
2912 global $DIC;
2913 $ilAccess = $DIC['ilAccess'];
2914 $ilUser = $DIC['ilUser'];
2915 $ilToolbar = $DIC['ilToolbar'];
2916
2917 if (!$ilAccess->checkAccess("visible", "", $this->ref_id) && !$ilAccess->checkAccess("read", "", $_GET["ref_id"])) {
2918 $this->redirectAfterMissingRead();
2919 return '';
2920 }
2921
2922 $DIC->tabs()->activateTab(ilTestTabsManager::TAB_ID_INFOSCREEN);
2923
2924 if ($ilAccess->checkAccess("read", "", $_GET["ref_id"])) {
2925 $this->trackTestObjectReadEvent();
2926 }
2927
2928
2929 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
2930 $info = new ilInfoScreenGUI($this);
2931 $info->setOpenFormTag(false);
2932
2933 if ($this->isCommandClassAnyInfoScreenChild()) {
2934 return $this->ctrl->forwardCommand($info);
2935 }
2936
2937 require_once 'Modules/Test/classes/class.ilTestInfoScreenToolbarFactory.php';
2938 $toolbarFactory = new ilTestInfoScreenToolbarFactory();
2939 $toolbarFactory->setTestOBJ($this->object);
2940 $toolbar = $toolbarFactory->getToolbarInstance();
2941
2942 $toolbar->setGlobalToolbar($GLOBALS['DIC']['ilToolbar']);
2943 $toolbar->setCloseFormTag(false);
2944
2945 $toolbar->setSessionLockString($session_lock);
2946 $toolbar->build();
2947 $toolbar->sendMessages();
2948
2949 if ($this->object->getShowInfo()) {
2950 $info->enablePrivateNotes();
2951 }
2952
2953 if (strlen($this->object->getIntroduction())) {
2954 $info->addSection($this->lng->txt("tst_introduction"));
2955 $info->addProperty("", $this->object->prepareTextareaOutput($this->object->getIntroduction(), true) .
2956 $info->getHiddenToggleButton());
2957 } else {
2958 $info->addSection($this->lng->txt("show_details"));
2959 $info->addProperty("", $info->getHiddenToggleButton());
2960 }
2961
2962 $info->addSection($this->lng->txt("tst_general_properties"));
2963 if ($this->object->getShowInfo()) {
2964 $info->addProperty(
2965 $this->lng->txt("author"),
2966 strip_tags(
2967 $this->object->getAuthor(),
2969 )
2970 );
2971 $info->addProperty(
2972 $this->lng->txt("title"),
2973 strip_tags(
2974 $this->object->getTitle(),
2976 )
2977 );
2978 }
2979 if (!$this->object->getOfflineStatus() &&
2980 $this->object->isComplete($this->testQuestionSetConfigFactory->getQuestionSetConfig()) &&
2981 $ilAccess->checkAccess("read", "", $this->ref_id) &&
2982 !$this->object->isRandomTest() &&
2983 !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired() &&
2984 $this->object->getNrOfTries() != 1) {
2985 if ($this->object->getUsePreviousAnswers() == 0) {
2986 if ($this->object->getShowInfo()) {
2987 $info->addProperty($this->lng->txt("tst_use_previous_answers"), $this->lng->txt("tst_dont_use_previous_answers"));
2988 }
2989 } else {
2990 $checked_previous_answers = false;
2991 if ($ilUser->prefs["tst_use_previous_answers"]) {
2992 $checked_previous_answers = true;
2993 }
2994 $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);
2995 }
2996 }
2997
2998 $info->hideFurtherSections(false);
2999
3000 if ($this->object->getShowInfo()) {
3001 $info->addSection($this->lng->txt("tst_sequence_properties"));
3002 $info->addProperty($this->lng->txt("tst_sequence"), $this->lng->txt(($this->object->getSequenceSettings() == TEST_FIXED_SEQUENCE)? "tst_sequence_fixed":"tst_sequence_postpone"));
3003
3004 $info->addSection($this->lng->txt("tst_heading_scoring"));
3005 $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"));
3006 $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"));
3007 if ($this->object->isRandomTest()) {
3008 $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"));
3009 }
3010
3011 $info->addSection($this->lng->txt("tst_score_reporting"));
3012 $score_reporting_text = "";
3013 switch ($this->object->getScoreReporting()) {
3015 $score_reporting_text = $this->lng->txt("tst_report_after_test");
3016 break;
3018 $score_reporting_text = $this->lng->txt("tst_report_after_first_question");
3019 break;
3021 $score_reporting_text = $this->lng->txt("tst_report_after_date");
3022 break;
3024 $score_reporting_text = $this->lng->txt("tst_report_after_passed");
3025 break;
3026 default:
3027 $score_reporting_text = $this->lng->txt("tst_report_never");
3028 break;
3029 }
3030 $info->addProperty($this->lng->txt("tst_score_reporting"), $score_reporting_text);
3031 $reporting_date = $this->object->getReportingDate();
3032 if ($reporting_date) {
3033 #preg_match("/(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})/", $reporting_date, $matches);
3034 #$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]));
3035 #$info->addProperty($this->lng->txt("tst_score_reporting_date"), $txt_reporting_date);
3036 $info->addProperty(
3037 $this->lng->txt('tst_score_reporting_date'),
3039 );
3040 }
3041
3042 $info->addSection($this->lng->txt("tst_session_settings"));
3043 $info->addProperty($this->lng->txt("tst_nr_of_tries"), ($this->object->getNrOfTries() == 0)?$this->lng->txt("unlimited"):$this->object->getNrOfTries());
3044 if ($this->object->getNrOfTries() != 1) {
3045 $info->addProperty($this->lng->txt("tst_nr_of_tries_of_user"), ($toolbar->getTestSession()->getPass() == false)?$this->lng->txt("tst_no_tries"):$toolbar->getTestSequence()->getPass());
3046 }
3047
3048 if ($this->object->getEnableProcessingTime()) {
3049 $info->addProperty($this->lng->txt("tst_processing_time"), $this->object->getProcessingTime());
3050 }
3051 if (strlen($this->object->getAllowedUsers()) && ($this->object->getAllowedUsersTimeGap())) {
3052 $info->addProperty($this->lng->txt("tst_allowed_users"), $this->object->getAllowedUsers());
3053 }
3054
3055 $starting_time = $this->object->getStartingTime();
3056 if ($this->object->isStartingTimeEnabled() && $starting_time != 0) {
3057 $info->addProperty($this->lng->txt("tst_starting_time"), ilDatePresentation::formatDate(new ilDateTime($starting_time, IL_CAL_UNIX)));
3058 }
3059 $ending_time = $this->object->getEndingTime();
3060 if ($this->object->isEndingTimeEnabled() && $ending_time != 0) {
3061 $info->addProperty($this->lng->txt("tst_ending_time"), ilDatePresentation::formatDate(new ilDateTime($ending_time, IL_CAL_UNIX)));
3062 }
3063 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
3064 // forward the command
3065 }
3066
3067 $this->ctrl->forwardCommand($info);
3068 }
3069
3070 protected function removeImportFailsObject()
3071 {
3072 require_once 'Modules/TestQuestionPool/classes/questions/class.ilAssQuestionSkillAssignmentImportFails.php';
3073 $qsaImportFails = new ilAssQuestionSkillAssignmentImportFails($this->object->getId());
3074 $qsaImportFails->deleteRegisteredImportFails();
3075
3076 require_once 'Modules/Test/classes/class.ilTestSkillLevelThresholdImportFails.php';
3077 $sltImportFails = new ilTestSkillLevelThresholdImportFails($this->object->getId());
3078 $sltImportFails->deleteRegisteredImportFails();
3079
3080 $this->ctrl->redirect($this, 'infoScreen');
3081 }
3082
3083 public function addLocatorItems()
3084 {
3085 global $DIC;
3086 $ilLocator = $DIC['ilLocator'];
3087 switch ($this->ctrl->getCmd()) {
3088 case "run":
3089 case "infoScreen":
3090 case "redirectToInfoScreen":
3091 case "start":
3092 case "resume":
3093 case "previous":
3094 case "next":
3095 case "summary":
3096 case "finishTest":
3097 case "outCorrectSolution":
3098 case "passDetails":
3099 case "showAnswersOfUser":
3100 case "outUserResultsOverview":
3101 case "backFromSummary":
3102 case "show_answers":
3103 case "setsolved":
3104 case "resetsolved":
3105 case "outTestSummary":
3106 case "outQuestionSummary":
3107 case "gotoQuestion":
3108 case "selectImagemapRegion":
3109 case "confirmSubmitAnswers":
3110 case "finalSubmission":
3111 case "postpone":
3112 case "outUserPassDetails":
3113 case "checkPassword":
3114 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "infoScreen"), "", $_GET["ref_id"]);
3115 break;
3116 case "eval_stat":
3117 case "evalAllUsers":
3118 case "evalUserDetail":
3119 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, "eval_stat"), "", $_GET["ref_id"]);
3120 break;
3121 case "create":
3122 case "save":
3123 case "cancel":
3124 case "importFile":
3125 case "cloneAll":
3126 case "importVerifiedFile":
3127 case "cancelImport":
3128 break;
3129 default:
3130 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $_GET["ref_id"]);
3131 break;
3132 }
3133 }
3134
3135 public function statisticsObject()
3136 {
3137 }
3138
3142 public function certificateObject()
3143 {
3144 global $DIC; /* @var ILIAS\DI\Container $DIC */
3145
3146 $DIC->tabs()->activateTab(ilTestTabsManager::TAB_ID_SETTINGS);
3147
3148 $guiFactory = new ilCertificateGUIFactory();
3149 $output_gui = $guiFactory->create($this->object);
3150
3151 $output_gui->certificateEditor();
3152 }
3153
3159 public function getTabs()
3160 {
3161 global $DIC;
3162 $help = $DIC['ilHelp'];
3163 $help->setScreenIdComponent("tst");
3164
3165 if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
3166 require_once 'Services/Link/classes/class.ilLink.php';
3167 $courseLink = ilLink::_getLink($this->getObjectiveOrientedContainer()->getRefId());
3168 $this->getTabsManager()->setParentBackLabel($this->lng->txt('back_to_objective_container'));
3169 $this->getTabsManager()->setParentBackHref($courseLink);
3170 }
3171
3172 $this->getTabsManager()->perform();
3173 }
3174
3175 public static function accessViolationRedirect()
3176 {
3177 global $DIC; /* @var ILIAS\DI\Container $DIC */
3178
3179 ilUtil::sendInfo($DIC->language()->txt("no_permission"), true);
3180 $DIC->ctrl()->redirectByClass('ilObjTestGUI', "infoScreen");
3181 }
3182
3191 public static function _goto($a_target)
3192 {
3193 global $DIC;
3194 $ilAccess = $DIC['ilAccess'];
3195 $ilErr = $DIC['ilErr'];
3196 $lng = $DIC['lng'];
3197
3198 if ($ilAccess->checkAccess("read", "", $a_target) || $ilAccess->checkAccess("visible", "", $a_target)) {
3199 //include_once "./Services/Utilities/classes/class.ilUtil.php";
3200 $_GET["baseClass"] = "ilObjTestGUI";
3201 $_GET["cmd"] = "infoScreen";
3202 $_GET["ref_id"] = $a_target;
3203 include_once("ilias.php");
3204 exit;
3205 //ilUtil::redirect("ilias.php?baseClass=ilObjTestGUI&cmd=infoScreen&ref_id=$a_target");
3206 } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
3207 ilUtil::sendInfo(sprintf(
3208 $lng->txt("msg_no_perm_read_item"),
3210 ), true);
3212 }
3213
3214 $ilErr->raiseError($lng->txt("msg_no_perm_read_lm"), $ilErr->FATAL);
3215 }
3216
3223 public function buildPageViewToolbar($qid = 0)
3224 {
3225 if ($this->create_question_mode) {
3226 return;
3227 }
3228
3229 global $DIC;
3230 $ilToolbar = $DIC['ilToolbar'];
3231 $ilCtrl = $DIC['ilCtrl'];
3232 $lng = $DIC['lng'];
3233
3234 require_once 'Services/UIComponent/Button/classes/class.ilLinkButton.php';
3235
3236 $ilCtrl->saveParameter($this, 'q_mode');
3237
3238 $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'test_express_mode', 1);
3239 $ilCtrl->setParameter($this, 'test_express_mode', 1);
3240 $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'q_id', $_REQUEST['q_id']);
3241 $ilCtrl->setParameter($this, 'q_id', $_REQUEST['q_id']);
3242 $ilToolbar->setFormAction($ilCtrl->getFormActionByClass('iltestexpresspageobjectgui', 'edit'));
3243
3244 if ($this->object->evalTotalPersons() == 0) {
3245 /*
3246 include_once 'Modules/TestQuestionPool/classes/class.ilObjQuestionPool.php';
3247 $pool = new ilObjQuestionPool();
3248 $questionTypes = $pool->getQuestionTypes();$options = array();
3249 foreach($questionTypes as $label => $data) {
3250 $options[$data['question_type_id']] = $label;
3251 }
3252
3253 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
3254 $si = new ilSelectInputGUI($lng->txt("test_add_new_question"), "qtype");
3255 $si->setOptions($options);
3256 $ilToolbar->addInputItem($si, true);
3257 /*
3258 // use pool
3259 if ($this->object->isExpressModeQuestionPoolAllowed()) {
3260 include_once("./Services/Form/classes/class.ilCheckboxInputGUI.php");
3261 $cb = new ilCheckboxInputGUI($lng->txt("test_use_pool"), "use_pool");
3262 $ilToolbar->addInputItem($cb, true);
3263 }
3264 */
3265 $ilToolbar->addFormButton($lng->txt("ass_create_question"), "addQuestion");
3266
3267 $ilToolbar->addSeparator();
3268
3269 if ($this->object->getPoolUsage()) {
3270 require_once 'Modules/Test/classes/tables/class.ilTestQuestionBrowserTableGUI.php';
3271
3273
3274 $show_separator = true;
3275 }
3276 }
3277
3278 $questions = $this->object->getQuestionTitlesAndIndexes();
3279
3280 // desc
3281 $options = array();
3282 foreach ($questions as $id => $label) {
3283 $options[$id] = $label . ' [' . $this->lng->txt('question_id_short') . ': ' . $id . ']';
3284 }
3285
3286 $optionKeys = array_keys($options);
3287
3288 if (!$options) {
3289 $options[] = $lng->txt('none');
3290 }
3291 //else if (count($options) > 1) {
3292// $addSeparator = false;
3293// if ($optionKeys[0] != $qid) {
3294// //$ilToolbar->addFormButton($lng->txt("test_prev_question"), "prevQuestion");
3295// $ilToolbar->addLink($lng->txt("test_prev_question"), $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'prevQuestion'));
3296// $addSeparator = true;
3297// }
3298 // else {
3299 // $ilToolbar->addSpacer(45);
3300 // }
3301//
3302// if ($optionKeys[count($optionKeys)-1] != $qid) {
3303// //$ilToolbar->addFormButton($lng->txt("test_next_question"), "nextQuestion");
3304// $ilToolbar->addLink($lng->txt("test_next_question"), $ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'nextQuestion'));
3305 // $addSeparator = true;
3306// }
3307 // else {
3308 // $ilToolbar->addSpacer(45);
3309 // }
3310//
3311// //if ($addSeparator) {
3312// $ilToolbar->addSeparator();
3313// //}
3314
3315 if (count($questions)) {
3316 if (isset($show_separator) && $show_separator) {
3317 $ilToolbar->addSeparator();
3318 }
3319
3321 $btn->setCaption("test_prev_question");
3322 $btn->setUrl($ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'prevQuestion'));
3323 $ilToolbar->addButtonInstance($btn);
3324
3325 if (count($options) <= 1 || $optionKeys[0] == $qid) {
3326 $btn->setDisabled(true);
3327 }
3328
3330 $btn->setCaption("test_next_question");
3331 $btn->setUrl($ilCtrl->getLinkTargetByClass('iltestexpresspageobjectgui', 'nextQuestion'));
3332 $ilToolbar->addButtonInstance($btn);
3333
3334 if (count($options) <= 1 || $optionKeys[count($optionKeys) - 1] == $qid) {
3335 $btn->setDisabled(true);
3336 }
3337 }
3338
3339 if (count($questions) > 1) {
3340 $ilToolbar->addSeparator();
3341
3342 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
3343 $si = new ilSelectInputGUI($lng->txt("test_jump_to"), "q_id");
3344 $si->addCustomAttribute("onChange=\"forms['ilToolbar'].submit();\"");
3345 $si->setOptions($options);
3346
3347 if ($qid) {
3348 $si->setValue($qid);
3349 }
3350
3351 $ilToolbar->addInputItem($si, true);
3352 }
3353
3354 $total = $this->object->evalTotalPersons();
3355
3356 /*if (count($options)) {
3357 include_once("./Services/Form/classes/class.ilSelectInputGUI.php");
3358 $si = new ilSelectInputGUI($lng->txt("test_jump_to"), "q_id");
3359 $si->addCustomAttribute("onChange=\"forms['ilToolbar'].submit();\"");
3360 $si->setOptions($options);
3361
3362 if ($qid) {
3363 $si->setValue($qid);
3364 }
3365
3366 $ilToolbar->addInputItem($si, true);
3367 }*/
3368
3369 if (count($questions) && !$total) {
3370 $ilCtrl->setParameter($this, 'q_id', $_REQUEST['q_id']);
3371 $ilToolbar->addSeparator();
3372 $ilToolbar->addButton($lng->txt("test_delete_page"), $ilCtrl->getLinkTarget($this, "removeQuestions"));
3373 }
3374
3375 if (count($questions) > 1 && !$total) {
3376 $ilToolbar->addSeparator();
3377 $ilToolbar->addButton($lng->txt("test_move_page"), $ilCtrl->getLinkTarget($this, "movePageForm"));
3378 }
3379
3380 global $DIC;
3381 $ilAccess = $DIC['ilAccess'];
3382 $ilUser = $DIC['ilUser'];
3383
3384 $online_access = false;
3385 if ($this->object->getFixedParticipants()) {
3386 include_once "./Modules/Test/classes/class.ilObjTestAccess.php";
3387 $online_access_result = ilObjTestAccess::_lookupOnlineTestAccess($this->object->getId(), $ilUser->getId());
3388 if ($online_access_result === true) {
3389 $online_access = true;
3390 }
3391 }
3392
3393 if (!$this->object->getOfflineStatus() && $this->object->isComplete($this->testQuestionSetConfigFactory->getQuestionSetConfig())) {
3394 if ((!$this->object->getFixedParticipants() || $online_access) && $ilAccess->checkAccess("read", "", $this->ref_id)) {
3395 $testSession = $this->testSessionFactory->getSession();
3396
3397 $executable = $this->object->isExecutable($testSession, $ilUser->getId(), $allowPassIncrease = true);
3398
3399 if ($executable["executable"]) {
3400 $player_factory = new ilTestPlayerFactory($this->object);
3401 $player_instance = $player_factory->getPlayerGUI();
3402
3403 if ($testSession->getActiveId() > 0) {
3404 $ilToolbar->addSeparator();
3405 $ilToolbar->addButton($lng->txt('tst_resume_test'), $ilCtrl->getLinkTarget($player_instance, 'resumePlayer'));
3406 } else {
3407 $ilToolbar->addSeparator();
3408 $ilToolbar->addButton($lng->txt('tst_start_test'), $ilCtrl->getLinkTarget($player_instance, 'startTest'));
3409 }
3410 }
3411 }
3412 }
3413 }
3414
3416 {
3417 $this->copyQuestionsToPool($_REQUEST['q_id'], $_REQUEST['sel_qpl']);
3418 $this->ctrl->redirect($this, 'questions');
3419 }
3420
3421 public function copyQuestionsToPool($questionIds, $qplId)
3422 {
3423 $newIds = array();
3424 foreach ($questionIds as $q_id) {
3425 $newId = $this->copyQuestionToPool($q_id, $qplId);
3426 $newIds[$q_id] = $newId;
3427 }
3428
3429 $result = new stdClass();
3430 $result->ids = $newIds;
3431 $result->qpoolid = $qplId;
3432
3433 return $result;
3434 }
3435
3436 public function copyQuestionToPool($sourceQuestionId, $targetParentId)
3437 {
3438 require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
3439 $question_gui = assQuestion::instantiateQuestionGUI($sourceQuestionId);
3440
3441 $newtitle = $question_gui->object->getTitle();
3442 if ($question_gui->object->questionTitleExists($targetParentId, $question_gui->object->getTitle())) {
3443 $counter = 2;
3444 while ($question_gui->object->questionTitleExists($targetParentId, $question_gui->object->getTitle() . " ($counter)")) {
3445 $counter++;
3446 }
3447 $newtitle = $question_gui->object->getTitle() . " ($counter)";
3448 }
3449
3450 return $question_gui->object->createNewOriginalFromThisDuplicate($targetParentId, $newtitle);
3451 }
3452
3457 {
3458 global $DIC;
3459 $ilObjDataCache = $DIC['ilObjDataCache'];
3460
3461 if (!(int) $_REQUEST['sel_qpl']) {
3462 ilUtil::sendFailure($this->lng->txt("questionpool_not_selected"));
3463 return $this->copyAndLinkToQuestionpoolObject();
3464 }
3465
3466 $qplId = $ilObjDataCache->lookupObjId($_REQUEST['sel_qpl']);
3467 $result = $this->copyQuestionsToPool($_REQUEST['q_id'], $qplId);
3468
3469 foreach ($result->ids as $oldId => $newId) {
3470 $questionInstance = assQuestion::_instanciateQuestion($oldId);
3471
3472 if (assQuestion::originalQuestionExists($questionInstance->getOriginalId())) {
3473 $oldOriginal = assQuestion::_instanciateQuestion($questionInstance->getOriginalId());
3474 $oldOriginal->delete($oldOriginal->getId());
3475 }
3476
3477 $questionInstance->setNewOriginalId($newId);
3478 }
3479
3480 ilUtil::sendSuccess($this->lng->txt('tst_qst_added_to_pool_' . (count($result->ids) > 1 ? 'p' : 's')), true);
3481 $this->ctrl->redirect($this, 'questions');
3482 }
3483
3485 {
3486 global $DIC;
3487 $lng = $DIC['lng'];
3488 include_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
3489 $form = new ilPropertyFormGUI();
3490
3491 $title = new ilTextInputGUI($lng->txt('title'), 'title');
3492 $title->setRequired(true);
3493 $form->addItem($title);
3494
3495 $description = new ilTextAreaInputGUI($lng->txt('description'), 'description');
3496 $form->addItem($description);
3497
3498 $form->addCommandButton('createQuestionPoolAndCopy', $lng->txt('create'));
3499
3500 if (isset($_REQUEST['q_id']) && is_array($_REQUEST['q_id'])) {
3501 foreach ($_REQUEST['q_id'] as $id) {
3502 $hidden = new ilHiddenInputGUI('q_id[]');
3503 $hidden->setValue($id);
3504 $form->addItem($hidden);
3505 }
3506 }
3507
3508 return $form;
3509 }
3510
3512 {
3513 $this->createQuestionpoolTargetObject('copyQuestionsToPool');
3514 }
3515
3517 {
3518 global $DIC;
3519 $lng = $DIC['lng'];
3520
3521 require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
3522
3523 // #13761; All methods use for this request should be revised, thx japo ;-)
3524 if (
3525 'copyAndLinkToQuestionpool' == $this->ctrl->getCmd() &&
3526 (!isset($_REQUEST['q_id']) || !is_array($_REQUEST['q_id']))
3527 ) {
3528 ilUtil::sendFailure($this->lng->txt('tst_no_question_selected_for_moving_to_qpl'), true);
3529 $this->ctrl->redirect($this, 'questions');
3530 }
3531
3532 if (isset($_REQUEST['q_id']) && is_array($_REQUEST['q_id'])) {
3533 foreach ($_REQUEST['q_id'] as $q_id) {
3535 continue;
3536 }
3537
3539
3540 if ($type !== 'tst') {
3541 ilUtil::sendFailure($lng->txt('tst_link_only_unassigned'), true);
3542 $this->ctrl->redirect($this, 'questions');
3543 return;
3544 }
3545 }
3546 }
3547
3548 $this->createQuestionpoolTargetObject('copyAndLinkQuestionsToPool');
3549 }
3550
3552 {
3553 if ($_REQUEST['title']) {
3554 $title = $_REQUEST['title'];
3555 } else {
3556 $title = $_REQUEST['txt_qpl'];
3557 }
3558
3559 if (!$title) {
3560 ilUtil::sendFailure($this->lng->txt("questionpool_not_entered"));
3561 return $this->copyAndLinkToQuestionpoolObject();
3562 }
3563
3564 $ref_id = $this->createQuestionPool($title, $_REQUEST['description']);
3565 $_REQUEST['sel_qpl'] = $ref_id;
3566
3567 //if ($_REQUEST['link'])
3568 //{
3570 //}
3571 //else
3572 //{
3573 // $this->copyQuestionsToPoolObject();
3574 //}
3575 }
3576
3584 {
3585 global $DIC; /* @var \ILIAS\DI\Container $DIC */
3586
3587 $this->getTabsManager()->getQuestionsSubTabs();
3589
3590 $questionpools = $this->object->getAvailableQuestionpools(
3591 false,
3592 false,
3593 false,
3594 true,
3595 false,
3596 "write"
3597 );
3598
3599 if (count($questionpools) == 0) {
3600 $form = $this->getTargetQuestionpoolForm($questionpools, 'createQuestionPoolAndCopy');
3601 } else {
3602 $form = $this->getTargetQuestionpoolForm($questionpools, $cmd);
3603
3604 switch ($cmd) {
3605 case 'copyQuestionsToPool':
3606 break;
3607
3608 case 'copyAndLinkQuestionsToPool':
3609 $hidden = new ilHiddenInputGUI('link');
3610 $hidden->setValue(1);
3611 $form->addItem($hidden);
3612 break;
3613 }
3614 }
3615
3616 $DIC->ui()->mainTemplate()->setContent($form->getHTML());
3617 }
3618
3619 protected function getTargetQuestionpoolForm($questionpools, $cmd)
3620 {
3621 global $DIC; /* @var \ILIAS\DI\Container $DIC */
3622
3623 $form = new ilPropertyFormGUI();
3624 $form->setFormAction($DIC->ctrl()->getFormAction($this));
3625 $form->addCommandButton($cmd, $DIC->language()->txt('submit'));
3626 $form->addCommandButton('cancelCreateQuestion', $DIC->language()->txt('cancel'));
3627
3628 if (count($questionpools) == 0) {
3629 $form->setTitle($this->lng->txt("tst_enter_questionpool"));
3630
3631 $title = new ilTextInputGUI($DIC->language()->txt('title'), 'title');
3632 $title->setRequired(true);
3633 $form->addItem($title);
3634
3635 $description = new ilTextAreaInputGUI($DIC->language()->txt('description'), 'description');
3636 $form->addItem($description);
3637 } else {
3638 $form->setTitle($this->lng->txt("tst_select_questionpool"));
3639
3640 $selectOptions = [
3641 '' => $DIC->language()->txt('please_select')
3642 ];
3643
3644 foreach ($questionpools as $key => $value) {
3645 $selectOptions[$key] = $value["title"];
3646 }
3647
3648 $select = new ilSelectInputGUI($DIC->language()->txt('tst_source_question_pool'), 'sel_qpl');
3649 $select->setRequired(true);
3650 $select->setOptions($selectOptions);
3651
3652 $form->addItem($select);
3653 }
3654
3655 if (isset($_REQUEST['q_id']) && is_array($_REQUEST['q_id'])) {
3656 foreach ($_REQUEST['q_id'] as $id) {
3657 $hidden = new ilHiddenInputGUI('q_id[]');
3658 $hidden->setValue($id);
3659 $form->addItem($hidden);
3660 }
3661 }
3662
3663 return $form;
3664 }
3665
3666 // begin-patch lok
3667 public function applyTemplate($templateData, ilObjTest $object)
3668 // end-patch lok
3669 {
3670 // map formFieldName => setterName
3671 $simpleSetters = array(
3672
3673 // general properties
3674 'use_pool' => 'setPoolUsage',
3675 'question_set_type' => 'setQuestionSetType',
3676
3677 // test intro properties
3678 'intro_enabled' => 'setIntroductionEnabled',
3679 'showinfo' => 'setShowInfo',
3680
3681 // test access properties
3682 'chb_starting_time' => 'setStartingTimeEnabled',
3683 'chb_ending_time' => 'setEndingTimeEnabled',
3684 'password_enabled' => 'setPasswordEnabled',
3685 'fixedparticipants' => 'setFixedParticipants',
3686 'limitUsers' => 'setLimitUsersEnabled',
3687
3688 // test run properties
3689 'nr_of_tries' => 'setNrOfTries',
3690 'chb_processing_time' => 'setEnableProcessingTime',
3691 'kiosk' => 'setKiosk',
3692 'examid_in_test_pass' => 'setShowExamIdInTestPassEnabled',
3693
3694 // question behavior properties
3695 'title_output' => 'setTitleOutput',
3696 'autosave' => null, // handled specially in loop below
3697 'chb_shuffle_questions' => 'setShuffleQuestions',
3698 'offer_hints' => 'setOfferingQuestionHintsEnabled',
3699 'instant_feedback_contents' => 'setInstantFeedbackOptionsByArray',
3700 'instant_feedback_trigger' => 'setForceInstantFeedbackEnabled',
3701 'answer_fixation_handling' => null, // handled specially in loop below
3702 'obligations_enabled' => 'setObligationsEnabled',
3703
3704 // test sequence properties
3705 'chb_use_previous_answers' => 'setUsePreviousAnswers',
3706 'chb_show_cancel' => 'setShowCancel',
3707 'chb_postpone' => 'setPostponingEnabled',
3708 'list_of_questions' => 'setListOfQuestionsSettings',
3709 'chb_show_marker' => 'setShowMarker',
3710
3711 // test finish properties
3712 'enable_examview' => 'setEnableExamview',
3713 'showfinalstatement' => 'setShowFinalStatement',
3714 'redirection_enabled' => null, // handled specially in loop below
3715 'sign_submission' => 'setSignSubmission',
3716 'mailnotification' => 'setMailNotification',
3717
3718 // scoring options properties
3719 'count_system' => 'setCountSystem',
3720 'mc_scoring' => 'setMCScoring',
3721 'score_cutting' => 'setScoreCutting',
3722 'pass_scoring' => 'setPassScoring',
3723 'pass_deletion_allowed' => 'setPassDeletionAllowed',
3724
3725 // result summary properties
3726 'results_access_enabled' => 'setScoreReporting',
3727 'grading_status' => 'setShowGradingStatusEnabled',
3728 'grading_mark' => 'setShowGradingMarkEnabled',
3729
3730 // result details properties
3731 'solution_details' => 'setShowSolutionDetails',
3732 'solution_feedback' => 'setShowSolutionFeedback',
3733 'solution_suggested' => 'setShowSolutionSuggested',
3734 'solution_printview' => 'setShowSolutionPrintview',
3735 'highscore_enabled' => 'setHighscoreEnabled',
3736 'solution_signature' => 'setShowSolutionSignature',
3737 'examid_in_test_res' => 'setShowExamIdInTestResultsEnabled',
3738 'exp_sc_short' => 'setExportSettingsSingleChoiceShort',
3739
3740 // misc scoring & result properties
3741 'anonymity' => 'setAnonymity',
3742 'enable_archiving' => 'setEnableArchiving'
3743 );
3744
3745 if (!$templateData['results_presentation']['value']) {
3746 $templateData['results_presentation']['value'] = array();
3747 }
3748
3749 foreach ($simpleSetters as $field => $setter) {
3750 if ($templateData[$field] && strlen($setter)) {
3751 $object->$setter($templateData[$field]['value']);
3752 continue;
3753 }
3754
3755 switch ($field) {
3756 case 'autosave':
3757 if ($templateData[$field]['value'] > 0) {
3758 $object->setAutosave(true);
3759 $object->setAutosaveIval($templateData[$field]['value'] * 1000);
3760 } else {
3761 $object->setAutosave(false);
3762 }
3763 break;
3764
3765 case 'redirection_enabled':
3766 /* if( $templateData[$field]['value'] > REDIRECT_NONE )
3767 {
3768 $object->setRedirectionMode($templateData[$field]['value']);
3769 }
3770 else
3771 {
3772 $object->setRedirectionMode(REDIRECT_NONE);
3773 } */
3774 if (strlen($templateData[$field]['value'])) {
3775 $object->setRedirectionMode(REDIRECT_ALWAYS);
3776 $object->setRedirectionUrl($templateData[$field]['value']);
3777 } else {
3778 $object->setRedirectionMode(REDIRECT_NONE);
3779 $object->setRedirectionUrl('');
3780 }
3781 break;
3782
3783 case 'answer_fixation_handling':
3784 switch ($templateData[$field]['value']) {
3786 $object->setInstantFeedbackAnswerFixationEnabled(false);
3787 $object->setFollowupQuestionAnswerFixationEnabled(false);
3788 break;
3789
3791 $object->setInstantFeedbackAnswerFixationEnabled(true);
3792 $object->setFollowupQuestionAnswerFixationEnabled(false);
3793 break;
3794
3796 $object->setInstantFeedbackAnswerFixationEnabled(false);
3797 $object->setFollowupQuestionAnswerFixationEnabled(true);
3798 break;
3799
3801 $object->setInstantFeedbackAnswerFixationEnabled(true);
3802 $object->setFollowupQuestionAnswerFixationEnabled(true);
3803 break;
3804 }
3805 break;
3806 }
3807 }
3808 }
3809
3811 {
3812 global $DIC;
3813 $ilAccess = $DIC['ilAccess'];
3814 if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
3815 // allow only write access
3816 ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3817 $this->ctrl->redirect($this, "infoScreen");
3818 }
3819
3820 global $DIC;
3821 $ilCtrl = $DIC['ilCtrl'];
3822
3823 $orders = $obligations = array();
3824
3825 foreach ((array) $_REQUEST['order'] as $qId => $order) {
3826 $id = (int) str_replace('q_', '', $qId);
3827
3828 $orders[$id] = $order;
3829 }
3830
3831 if ($this->object->areObligationsEnabled() && isset($_REQUEST['obligatory']) && is_array($_REQUEST['obligatory'])) {
3832 foreach ($_REQUEST['obligatory'] as $qId => $obligation) {
3833 $id = (int) str_replace('q_', '', $qId);
3834
3836 $obligations[$id] = $obligation;
3837 }
3838 }
3839 }
3840
3841 $this->object->setQuestionOrderAndObligations(
3842 $orders,
3843 $obligations
3844 );
3845
3846 ilUtil::sendSuccess($this->lng->txt('saved_successfully'), true);
3847 $ilCtrl->redirect($this, 'questions');
3848 }
3849
3853 protected function movePageFormObject()
3854 {
3855 global $DIC;
3856 $lng = $DIC['lng'];
3857 $ilCtrl = $DIC['ilCtrl'];
3858 $tpl = $DIC['tpl'];
3859
3860 include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
3861 $form = new ilPropertyFormGUI();
3862 $form->setFormAction($ilCtrl->getFormAction($this, "movePage"));
3863 $form->setTitle($lng->txt("test_move_page"));
3864
3865 $old_pos = new ilHiddenInputGUI("q_id");
3866 $old_pos->setValue($_REQUEST['q_id']);
3867 $form->addItem($old_pos);
3868
3869 $questions = $this->object->getQuestionTitlesAndIndexes();
3870 if (!is_array($questions)) {
3871 $questions = array();
3872 }
3873
3874 foreach ($questions as $k => $q) {
3875 if ($k == $_REQUEST['q_id']) {
3876 unset($questions[$k]);
3877 continue;
3878 }
3879 $questions[$k] = $lng->txt('behind') . ' ' . $q;
3880 }
3881 #$questions['0'] = $lng->txt('first');
3882
3883 $options = array(
3884 0 => $lng->txt('first')
3885 );
3886 foreach ($questions as $k => $q) {
3887 $options[$k] = $q . ' [' . $this->lng->txt('question_id_short') . ': ' . $k . ']';
3888 }
3889
3890 $pos = new ilSelectInputGUI($lng->txt("position"), "position_after");
3891 $pos->setOptions($options);
3892 $form->addItem($pos);
3893
3894 $form->addCommandButton("movePage", $lng->txt("submit"));
3895 $form->addCommandButton("showPage", $lng->txt("cancel"));
3896
3897 return $tpl->setContent($form->getHTML());
3898 }
3899
3900 public function movePageObject()
3901 {
3902 global $DIC;
3903 $ilAccess = $DIC['ilAccess'];
3904 if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
3905 // allow only write access
3906 ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3907 $this->ctrl->redirect($this, "infoScreen");
3908 }
3909
3910 $this->object->moveQuestionAfter($_REQUEST['q_id'], $_REQUEST['position_after']);
3911 $this->showPageObject();
3912 }
3913
3914 public function showPageObject()
3915 {
3916 global $DIC;
3917 $ilCtrl = $DIC['ilCtrl'];
3918
3919 $ilCtrl->setParameterByClass('iltestexpresspageobjectgui', 'q_id', $_REQUEST['q_id']);
3920 $ilCtrl->redirectByClass('iltestexpresspageobjectgui', 'showPage');
3921 }
3922
3923 public function copyQuestionObject()
3924 {
3925 global $DIC;
3926 $ilAccess = $DIC['ilAccess'];
3927 if (!$ilAccess->checkAccess("write", "", $this->ref_id)) {
3928 // allow only write access
3929 ilUtil::sendInfo($this->lng->txt("cannot_edit_test"), true);
3930 $this->ctrl->redirect($this, "infoScreen");
3931 }
3932
3933 if ($_REQUEST['q_id'] && !is_array($_REQUEST['q_id'])) {
3934 $ids = array($_REQUEST['q_id']);
3935 } elseif ($_REQUEST['q_id']) {
3936 $ids = $_REQUEST['q_id'];
3937 } else {
3938 ilUtil::sendFailure($this->lng->txt('copy_no_questions_selected'), true);
3939 $this->ctrl->redirect($this, 'questions');
3940 }
3941
3942 $copy_count = 0;
3943
3944 $questionTitles = $this->object->getQuestionTitles();
3945
3946 foreach ($ids as $id) {
3947 include_once "./Modules/TestQuestionPool/classes/class.assQuestion.php";
3948 $question = assQuestion::_instanciateQuestionGUI($id);
3949 if ($question) {
3950 $title = $question->object->getTitle();
3951 $i = 2;
3952 while (in_array($title . ' (' . $i . ')', $questionTitles)) {
3953 $i++;
3954 }
3955
3956 $title .= ' (' . $i . ')';
3957
3958 $questionTitles[] = $title;
3959
3960 $new_id = $question->object->duplicate(false, $title);
3961
3962 $clone = assQuestion::_instanciateQuestionGUI($new_id);
3963 $clone->object->setObjId($this->object->getId());
3964 $clone->object->saveToDb();
3965
3966 $this->object->insertQuestion($this->testQuestionSetConfigFactory->getQuestionSetConfig(), $new_id, true);
3967
3968 $copy_count++;
3969 }
3970 }
3971
3972 ilUtil::sendSuccess($this->lng->txt('copy_questions_success'), true);
3973
3974 $this->ctrl->redirect($this, 'questions');
3975 }
3976
3978 {
3979 require_once 'Modules/Course/classes/Objectives/class.ilLOSettings.php';
3980 $containerObjId = (int) ilLOSettings::isObjectiveTest($this->ref_id);
3981
3982 $containerRefId = current(ilObject::_getAllReferences($containerObjId));
3983
3984 $this->objectiveOrientedContainer->setObjId($containerObjId);
3985 $this->objectiveOrientedContainer->setRefId($containerRefId);
3986 }
3987
3989 {
3991 }
3992}
$result
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
$total
Definition: Utf8Test.php:87
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
const IL_CAL_TIMESTAMP
const IL_CAL_UNIX
error($a_errmsg)
set error message @access public
const QT_CLOZE
const QT_IMAGEMAP
const QT_TEXTSUBSET
const QT_JAVAAPPLET
const QT_KPRIM_CHOICE
const QT_MULTIPLE_CHOICE_MR
const QT_MATCHING
const QT_ORDERING_HORIZONTAL
const QT_ORDERING
const QT_FILEUPLOAD
const QT_FORMULA
const QT_NUMERIC
const QT_MULTIPLE_CHOICE_SR
const QT_FLASHAPPLET
const QT_LONG_MENU
const QT_TEXT
const QT_ERRORTEXT
const IL_MO_VERIFY_QTI
const IL_MO_PARSE_QTI
Basic GUI class for assessment questions.
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...
static _getOriginalId($question_id)
Returns the original id of a question.
const ADDITIONAL_CONTENT_EDITING_MODE_RTE
constant for additional content editing mode "default"
static instantiateQuestionGUI($a_question_id)
Creates an instance of a question gui with a given question id.
static originalQuestionExists($questionId)
const ADDITIONAL_CONTENT_EDITING_MODE_IPE
constant for additional content editing mode "pageobject"
static _getQuestionTypeName($type_tag)
Return the translation for a given question type tag.
static _needsManualScoring($question_id)
static & _instanciateQuestionGUI($question_id)
Creates an instance of a question gui with a given question id.
static lookupParentObjId($questionId)
@global ilDBInterface $ilDB
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
Generic feedback page GUI class.
Question page GUI class.
Question page object.
Specific feedback page GUI class.
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.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
Confirmation screen class.
static formatDate(ilDateTime $date, $a_skip_day=false, $a_include_wd=false, $include_seconds=false)
Format a date @access public.
static setUseRelativeDates($a_status)
set use relative dates
static useRelativeDates()
check if relative dates are used
@classDescription Date and time handling
This class represents a file property in a property form.
This class represents a hidden form property in a property form.
Import class.
Class ilInfoScreenGUI.
static isObjectiveTest($a_trst_ref_id)
Check if test ref_id is used in an objective course.
GUI class for LTI provider object settings.
Class ilObjUserTrackingGUI.
static getInstance()
Factory.
Class ilLocalUnitConfigurationGUI.
This class represents a number property in a property form.
static isAdditionalQuestionContentEditingModePageObjectEnabled()
returns the fact wether content editing with ilias page editor is enabled for questions or not
static _getLog($ts_from, $ts_to, $test_id, $test_only=false)
Retrieve assessment log datasets from the database.
Class ilObjFile.
static getQuestionTypeByTypeId($type_id)
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.
static getSyntaxStylePath()
get syntax style path
static getContentStylePath($a_style_id, $add_random=true, $add_token=true)
get content style path
static _lookupOnlineTestAccess($a_test_id, $a_user_id)
Checks if a user is allowd to run an online exam.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
importFileObject($parent_id=null, $a_catch_errors=true)
form for new test object import
createQuestionObject()
Called when a new question should be created from a test.
createQuestionpoolTargetObject($cmd)
Called when a new question should be created from a test Important: $cmd may be overwritten if no que...
download_paragraphObject()
download source code paragraph
setTestAccess($testAccess)
printobject()
Print tab to create a print of all questions with points and solutions.
addLocatorItems()
should be overwritten to add object specific items (repository items are preloaded)
backObject()
Called when the back button in the question browser was pressed.
removeQuestionsForm($checked_questions)
Displays a form to confirm the removal of questions from the test.
insertQuestionsBeforeObject()
Insert checked questions before the actual selection.
cancelRemoveQuestionsObject()
Cancels the removal of questions from the test.
createQuestionPool($name="dummy", $description="")
Creates a new questionpool and returns the reference id.
infoScreenObject()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually,...
static $infoScreenChildClasses
copyAndLinkQuestionsToPoolObject()
@global ilObjectDataCache $ilObjDataCache
addDidacticTemplateOptions(array &$a_options)
Add custom templates.
afterSave(ilObject $a_new_object)
save object @access public
movePageFormObject()
Move current page.
prepareSubGuiOutput()
prepares ilias to get output rendered by sub gui class
buildPageViewToolbar($qid=0)
Questions per page.
participantsActionObject()
Evaluates the actions on the participants page.
executeCreateQuestionObject()
Called when a new question should be created from a test after confirmation.
executeCommand()
execute command
insertQuestionsObject()
Insert questions from the questionbrowser into the test.
static _goto($a_target)
Redirect script to call a test with the test reference id.
copyQuestionToPool($sourceQuestionId, $targetParentId)
insertRandomSelectionObject()
Inserts a random selection into the test.
applyDefaultsObject($confirmed=false)
Applies the selected test defaults.
removeQuestionsObject()
Called when a selection of questions should be removed from the test.
downloadFileObject()
download file
importVerifiedFileObject()
imports question(s) into the questionpool (after verification)
setTabsManager($tabsManager)
uploadObject($redirect=true)
display status information or report errors messages in case of error
moveQuestionsObject()
Marks selected questions for moving.
getTabs()
adds tabs to tab gui object
fullscreenObject()
show fullscreen view
redirectTo_ilObjTestSettingsGeneralGUI_showForm_Object()
confirmRemoveQuestionsObject()
Remove questions from the test after confirmation.
getTargetQuestionpoolForm($questionpools, $cmd)
cancelCreateQuestionObject()
Called when the creation of a new question is cancelled.
populateQuestionBrowserToolbarButtons(ilToolbarGUI $toolbar, $context)
__construct($refId=null)
Constructor @access public.
reviewobject()
Review tab to create a print of all questions without points and solutions.
initImportForm($a_new_type)
Init object import form.
exportObject()
Gateway for exports initiated from workspace, as there is a generic forward to {objTypeMainGUI}::expo...
deleteDefaultsObject()
Deletes selected test defaults.
historyObject()
Creates the change history for a test.
uploadTstObject()
imports test and question(s)
insertQuestionsAfterObject()
Insert checked questions after the actual selection.
copyQuestionsToPool($questionIds, $qplId)
applyTemplate($templateData, ilObjTest $object)
resetFilterObject()
Resets the filter for the question browser.
addDefaultsObject()
Adds the defaults of this test to the defaults.
filterObject()
Sets the filter for the question browser.
certificateObject()
Shows the certificate editor.
static accessViolationRedirect()
const QUESTION_SET_TYPE_DYNAMIC
type setting value for dynamic question set (continues testing mode)
static _getTestDefaults($test_defaults_id)
const QUESTION_SET_TYPE_RANDOM
type setting value for random question set
const SCORE_REPORTING_IMMIDIATLY
const QUESTION_SET_TYPE_FIXED
type setting value for fixed question set
const SCORE_REPORTING_FINISHED
const SCORE_REPORTING_AFTER_PASSED
static _setImportDirectory($a_import_dir=null)
set import directory
static _getImportDirectory()
Get the import directory location of the test.
static isQuestionObligationPossible($questionId)
checks wether the obligation for question with given id is possible or not
static _createImportDirectory()
creates data directory for import files (data_dir/tst_data/tst_<id>/import, depending on data directo...
const SCORE_REPORTING_DATE
GUI class for the workflow of copying objects.
Class ilObjectGUI Basic methods of all Output classes.
getDidacticTemplateVar($a_type)
Get didactic template setting from creation screen.
prepareOutput($a_show_subobjects=true)
prepare output
getReturnLocation($a_cmd, $a_location="")
get return location for command (command is method name without "Object", e.g.
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
getCreationMode()
get creation mode
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_ref_id=null)
Check permission.
addHeaderAction()
Add header action menu.
createObject()
create new object form
const ALLOWED_TAGS_IN_TITLE_AND_DESCRIPTION
setLocator()
set Locator
setTitleAndDescription()
called by prepare output
Class ilObjectMetaDataGUI.
Class ilObject Basic functions for all objects.
static _lookupObjId($a_id)
static _lookupTitle($a_id)
lookup object title
getRefId()
get reference id @access public
static _getAllReferences($a_id)
get all reference ids of object
static _lookupType($a_id, $a_reference=false)
lookup object type
static prepareGenerationRequest($service, $purpose)
Prepare the content processing for a PDF generation request This function should be called as in a re...
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
Legacy Content Object Parser.
This class represents a property in a property form.
This class represents an option in a radio group.
This class represents a selection list property in a property form.
ILIAS Setting Class.
Settings template application class.
static getAllSettingsTemplates($a_type, $a_include_auto_generated=false)
Get all settings templates of type.
special template class to simplify handling of ITX/PEAR
Output class for assessment test evaluation.
Base Exception for all Exceptions relating to Modules/Test.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
@ilCtrl_Calls ilTestExpressPageObjectGUI: assMultipleChoiceGUI, assClozeTestGUI, assMatchingQuestionG...
static generatePDF($pdf_output, $output_mode, $filename=null, $purpose=null)
Scoring class for tests.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text area property in a property form.
This class represents a text property in a property form.
Class ilUnitConfigurationRepository.
static moveUploadedFile($a_file, $a_name, $a_target, $a_raise_errors=true, $a_mode="move_uploaded")
move uploaded file
static delDir($a_dir, $a_clean_only=false)
removes a dir and all its content (subdirs and files) recursively
static appendUrlParameterString($a_url, $a_par, $xml_style=false)
append URL parameter string ("par1=value1&par2=value2...") to given URL string
static getStyleSheetLocation($mode="output", $a_css_name="", $a_css_location="")
get full style sheet file name (path inclusive) of current user
static redirect($a_script)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static unzip(string $path_to_zip_file, bool $overwrite_existing=false, bool $unpack_flat=false)
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
static infoPanel($a_keep=true)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms @access public
static setTokenMaxLifetimeInSeconds($token_max_lifetime_in_seconds)
const ROOT_FOLDER_ID
Definition: constants.php:30
$txt
Definition: error.php:13
global $DIC
Definition: goto.php:24
$ilUser
Definition: imgupload.php:18
const SCORE_BEST_PASS
const CLOZE_TEST_IDENTIFIER
Question identifier constants.
const REDIRECT_NONE
Redirect after finishing test constants.
const FLASHAPPLET_QUESTION_IDENTIFIER
const IMAGEMAP_QUESTION_IDENTIFIER
const SINGLE_CHOICE_QUESTION_IDENTIFIER
const FORMULA_QUESTION_IDENTIFIER
const ERROR_TEXT_IDENTIFIER
const SCORE_ZERO_POINTS_WHEN_UNANSWERED
const TEXTSUBSET_QUESTION_IDENTIFIER
const COUNT_PARTIAL_SOLUTIONS
const NUMERIC_QUESTION_IDENTIFIER
const JAVAAPPLET_QUESTION_IDENTIFIER
const TEST_FIXED_SEQUENCE
Test constants.
const FILE_UPLOAD_IDENTIFIER
const TEXT_QUESTION_IDENTIFIER
const PDF_PRINT_VIEW_QUESTIONS
const LONG_MENU_QUESTION_IDENTIFIER
const KPRIM_CHOICE_QUESTION_IDENTIFIER
const ORDERING_HORIZONTAL_IDENTIFIER
const MATCHING_QUESTION_IDENTIFIER
const MULTIPLE_CHOICE_QUESTION_IDENTIFIER
const REDIRECT_ALWAYS
const ORDERING_QUESTION_IDENTIFIER
exit
Definition: login.php:29
if($format !==null) $name
Definition: metadata.php:230
$i
Definition: metadata.php:24
$keys
Definition: metadata.php:187
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$ret
Definition: parser.php:6
$type
$log
Definition: result.php:15
$results
global $ilDB
$context
Definition: webdav.php:26
$message
Definition: xapiexit.php:14
$refId
Definition: xapitoken.php:40