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