ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilTestPlayerAbstractGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21use ILIAS\Data\Factory as DataFactory;
31use ILIAS\UI\Component\Modal\Interruptive as InterruptiveModal;
33
39{
40 public const PRESENTATION_MODE_VIEW = 'view';
41 public const PRESENTATION_MODE_EDIT = 'edit';
42
43 protected const FINISH_TEST_CMD = 'finishTest';
44
46
49 public int $ref_id;
50
54 private array $cached_question_guis = [];
55
59 private array $cached_question_objects = [];
60
63 protected ?ilTestSession $test_session = null;
64 protected ?ilSetting $ass_settings = null;
65 protected ?ilTestSequence $test_sequence = null;
67
68 protected ?InterruptiveModal $finish_test_modal = null;
69
70 protected const DISCARD_MODAL = "discard_modal";
71 protected const LOCKS_CHANGED_MODAL = "locks_changed_modal";
72 protected const LOCKS_UNCHANGED_MODAL = "locks_unchanged_modal";
73
78 protected array $modal_signals = [];
79
80 public function __construct(ilObjTest $object)
81 {
82 parent::__construct($object);
83 $this->ref_id = $this->testrequest->getRefId();
84 $this->password_checker = new ilTestPasswordChecker($this->rbac_system, $this->user, $this->object, $this->lng);
85 }
86
87 public function executeCommand()
88 {
89 $this->tabs->clearTargets();
90
91 $cmd = $this->ctrl->getCmd();
92 $next_class = $this->ctrl->getNextClass($this);
93
94 if (($read_access = $this->checkReadAccess()) !== true) {
95 if ($cmd === 'autosave') {
96 echo $this->lng->txt('autosave_failed') . ': ' . $read_access;
97 exit;
98 }
99 $this->tpl->setOnScreenMessage('failure', $read_access, true);
100 $this->ctrl->redirectByClass([ilRepositoryGUI::class, ilObjTestGUI::class, TestScreenGUI::class]);
101 }
102
103 $this->ctrl->saveParameter($this, "sequence");
104 $this->ctrl->saveParameter($this, "pmode");
105 $this->ctrl->saveParameter($this, "active_id");
106
107 $this->initAssessmentSettings();
108
109 $testSessionFactory = new ilTestSessionFactory($this->object, $this->db, $this->user);
110 $this->test_session = $testSessionFactory->getSession($this->testrequest->int('active_id'));
111
112 $this->ensureExistingTestSession($this->test_session);
113 $this->checkTestSessionUser($this->test_session);
114
115 $this->initProcessLocker($this->test_session->getActiveId());
116
117 $test_sequence_factory = new ilTestSequenceFactory($this->object, $this->db, $this->questionrepository);
118 $this->test_sequence = $test_sequence_factory->getSequenceByTestSession($this->test_session);
119 $this->test_sequence->loadFromDb();
120 $this->test_sequence->loadQuestions();
121
122 $this->question_related_objectives_list = new ilTestQuestionRelatedObjectivesList();
123
125
127
128 $instance_name = $this->settings->get('short_inst_name') ?? '';
129 if (trim($instance_name) === '') {
130 $instance_name = 'ILIAS';
131 }
132 $this->global_screen->tool()->context()->current()->addAdditionalData(
134 $instance_name
135 );
136 $this->global_screen->tool()->context()->current()->addAdditionalData(
138 $this->object->getKioskMode()
139 );
140 $this->global_screen->tool()->context()->current()->addAdditionalData(
142 $this->object->getTitle()
143 );
144 $this->global_screen->tool()->context()->current()->addAdditionalData(
146 $this->getTestPlayerTitle()
147 );
148
149 switch ($next_class) {
150 case 'ilassquestionpagegui':
151 $this->checkTestExecutable();
152
153 $question_id = $this->test_sequence->getQuestionForSequence($this->getCurrentSequenceElement());
154
155 $page_gui = new ilAssQuestionPageGUI($question_id);
156 $page_gui->setFileDownloadLink(
157 $this->ctrl->getLinkTargetByClass(ilObjTestGUI::class, 'downloadFile')
158 );
159 $ret = $this->ctrl->forwardCommand($page_gui);
160 break;
161
162 case 'iltestsubmissionreviewgui':
163 $this->checkTestExecutable();
164 $this->handleCheckTestPassValid(true);
165
166 $gui = new ilTestSubmissionReviewGUI($this, $this->object, $this->test_session);
167 $gui->setObjectiveOrientedContainer($this->getObjectiveOrientedContainer());
168 $ret = $this->ctrl->forwardCommand($gui);
169 break;
170
171 case 'ilassspecfeedbackpagegui':
172 case 'ilassgenfeedbackpagegui':
173 $id = $this->testrequest->int('pg_id');
174 if ($this->ctrl->getCmd() !== 'displayMediaFullscreen'
175 || $id === 0) {
176 break;
177 }
178
179 (new ilPageObjectGUI(
180 $next_class === 'ilassgenfeedbackpagegui' ? 'qfbg' : 'qfbs',
181 $id
182 ))->displayMediaFullscreen();
183 break;
184
185 case 'iltestpasswordprotectiongui':
186 $this->checkTestExecutable();
187
189 $this->ctrl,
190 $this->tpl,
191 $this->lng,
192 $this,
193 $this->password_checker,
194 $this->testrequest,
195 $this->global_screen
196 );
197 $ret = $this->ctrl->forwardCommand($gui);
198 break;
199
200 default:
201 if ($cmd !== 'autosave' && ilTestPlayerCommands::isTestExecutionCommand($cmd)) {
202 $this->checkTestExecutable();
203 }
204
205 if ($cmd === 'outQuestionSummary'
206 || $cmd === 'submitSolution') {
207 $this->handleCheckTestPassValid(true);
208 }
209
210 if ($cmd === 'showQuestion') {
211 $testPassesSelector = new ilTestPassesSelector($this->db, $this->object);
212 $testPassesSelector->setActiveId($this->test_session->getActiveId());
213 $testPassesSelector->setLastFinishedPass($this->test_session->getLastFinishedPass());
214
215 if (!$testPassesSelector->openPassExists()) {
216 $this->tpl->setOnScreenMessage('info', $this->lng->txt('tst_pass_finished'), true);
217 $this->ctrl->redirectByClass([ilRepositoryGUI::class, ilObjTestGUI::class, TestScreenGUI::class]);
218 }
219 }
220
221 $cmd .= 'Cmd';
222 $ret = $this->$cmd();
223 break;
224 }
225 return $ret;
226 }
227
228 abstract protected function buildTestPassQuestionList();
229 abstract protected function populateQuestionOptionalMessage();
230
231 protected function checkReadAccess(): bool|string
232 {
233 if (!$this->rbac_system->checkAccess('read', $this->object->getRefId())) {
234 return $this->lng->txt('cannot_execute_test');
235 }
236
237 $participant_access = (new ilTestAccess($this->object->getRefId()))->isParticipantAllowed(
238 $this->object->getId(),
239 $this->user->getId()
240 );
241 if ($participant_access !== ParticipantAccess::ALLOWED) {
242 return $participant_access->getAccessForbiddenMessage($this->lng);
243 }
244
245 return true;
246 }
247
248 protected function checkTestExecutable()
249 {
250 $executable = $this->object->isExecutable($this->test_session, $this->test_session->getUserId());
251
252 if (!$executable['executable']) {
253 $this->tpl->setOnScreenMessage('info', $executable['errormessage'], true);
254 $this->ctrl->redirectByClass([ilRepositoryGUI::class, ilObjTestGUI::class, TestScreenGUI::class]);
255 }
256 }
257
259 {
260 if ($test_session->getUserId() != $this->user->getId()) {
261 throw new ilTestException('active id given does not relate to current user!');
262 }
263 }
264
266 {
267 if ($test_session->getActiveId()) {
268 return;
269 }
270
271 $test_session->setUserId($this->user->getId());
272
273 if ($test_session->isAnonymousUser()) {
275 return;
276 }
277
279 }
280
282 }
283
284 protected function initProcessLocker($activeId)
285 {
287 $process_lockerFactory = new ilTestProcessLockerFactory($this->ass_settings, $ilDB);
288 $this->process_locker = $process_lockerFactory->withContextId((int) $activeId)->getLocker();
289 }
290
297 public function saveTagsCmd()
298 {
299 $tagging_gui = new ilTaggingGUI();
300 $tagging_gui->setObject($this->object->getId(), $this->object->getType());
301 $tagging_gui->saveInput();
302 $this->ctrl->redirectByClass([ilRepositoryGUI::class, ilObjTestGUI::class, ilInfoScreenGUI::class]);
303 }
304
308 public function updateWorkingTime()
309 {
310 if (ilSession::get("active_time_id") != null) {
311 $this->object->updateWorkingTime(ilSession::get("active_time_id"));
312 }
313
315 "active_time_id",
316 $this->object->startWorkingTime(
317 $this->test_session->getActiveId(),
318 $this->test_session->getPass()
319 )
320 );
321 }
322
323 public function removeIntermediateSolution(): void
324 {
325 $question_id = $this->getCurrentQuestionId();
326
327 $this->getQuestionInstance($question_id)->removeIntermediateSolution(
328 $this->test_session->getActiveId(),
329 $this->test_session->getPass()
330 );
331 }
332
333 public function saveQuestionSolution(
334 bool $authorized = true,
335 bool $force = false
336 ): bool {
337 $this->updateWorkingTime();
338
339 if (!$this->checkAndUpdateSaveAllowedByFormTimestamp($force)) {
340 return false;
341 }
342
343 /*
344 #21097 - exceed maximum passes
345 this is a battle of conditions; e.g. ilTestPlayerAbstractGUI::autosaveOnTimeLimitCmd forces saving of results.
346 However, if an admin has finished the pass in the meantime, a new pass should not be created.
347 */
348 if ($force && $this->isNrOfTriesReached()) {
349 $force = false;
350 }
351
352 $question_obj = $this->buildQuestionObject();
353
354 if ($question_obj === null) {
355 return false;
356 }
357
358 if ($this->canSaveResult() || $force) {
359 $saved = $this->save($question_obj, $authorized);
360 }
361
362 if (!$saved
363 || ($question_obj instanceof QuestionPartiallySaveable
364 && !$question_obj->validateSolutionSubmit())) {
365
366 $this->ctrl->setParameter($this, 'save_error', '1');
367 ilSession::set('previouspost', $this->testrequest->getParsedBody());
368 }
369
370 return $saved;
371 }
372
373 private function checkAndUpdateSaveAllowedByFormTimestamp(bool $force): bool
374 {
375 if ($force) {
376 return true;
377 }
378
379 $formtimestamp = $this->testrequest->int('formtimestamp');
380 if (ilSession::get('formtimestamp') !== null
381 && $formtimestamp === ilSession::get('formtimestamp')) {
382 return false;
383 }
384
385 ilSession::set('formtimestamp', $formtimestamp);
386 return true;
387 }
388
389 private function buildQuestionObject(): ?assQuestion
390 {
391 $q_id = $this->test_sequence->getQuestionForSequence($this->testrequest->int('sequence'));
392
393 if ($this->isParticipantsAnswerFixed($q_id)) {
394 // should only be reached by firebugging the disabled form in ui
395 throw new ilTestException('not allowed request');
396 }
397
398 if ($q_id === null) {
399 return null;
400 }
401
402 return $this->getQuestionInstance($q_id);
403 }
404
405 private function save(assQuestion $question_obj, bool $authorized): bool
406 {
407 $active_id = $this->test_session->getActiveId();
408 $pass = ilObjTest::_getPass($active_id);
409 if (!$question_obj->persistWorkingState(
410 $active_id,
411 $pass,
412 $authorized
413 )) {
414 return false;
415 }
416
417 if ($authorized && $this->test_session->isObjectiveOriented()) {
418 $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($this->test_session);
419 $objectivesAdapter->updateQuestionResult($this->test_session, $question_obj);
420 }
421
422 if ($authorized && $this->object->isSkillServiceToBeConsidered()) {
423 $this->handleSkillTriggering($this->test_session);
424 }
425
426 if ($authorized && $this->logger->isLoggingEnabled()
427 && !$this->getObject()->getAnonymity()
428 && ($interaction = $question_obj->answerToParticipantInteraction(
429 $this->logger->getAdditionalInformationGenerator(),
430 $this->getObject()->getRefId(),
431 $active_id,
432 $pass,
433 $this->logger->isIPLoggingEnabled() ? $_SERVER['REMOTE_ADDR'] : '',
434 TestParticipantInteractionTypes::ANSWER_SUBMITTED
435 )) !== null) {
436 $this->logger->logParticipantInteraction($interaction);
437 }
438 return true;
439 }
440
441 protected function canSaveResult(): bool
442 {
443 return !$this->object->endingTimeReached() && !$this->isMaxProcessingTimeReached() && !$this->isNrOfTriesReached();
444 }
445
446 public function suspendTestCmd()
447 {
448 $this->ctrl->redirectByClass(TestScreenGUI::class, TestScreenGUI::DEFAULT_CMD);
449 }
450
451 public function isMaxProcessingTimeReached(): bool
452 {
453 $active_id = $this->test_session->getActiveId();
454 $starting_time = $this->object->getStartingTimeOfUser($active_id);
455 if ($starting_time === false) {
456 return false;
457 } else {
458 return $this->object->isMaxProcessingTimeReached($starting_time, $active_id);
459 }
460 }
461
462 protected function determineInlineScoreDisplay(): bool
463 {
464 $show_question_inline_score = false;
465 if ($this->object->getAnswerFeedbackPoints()) {
466 $show_question_inline_score = true;
467 return $show_question_inline_score;
468 }
469 return $show_question_inline_score;
470 }
471
472 protected function populateTestNavigationToolbar(ilTestNavigationToolbarGUI $toolbar_gui): void
473 {
474 $this->tpl->setCurrentBlock('test_nav_toolbar');
475 $this->tpl->setVariable('TEST_NAV_TOOLBAR', $toolbar_gui->getHTML());
476 $this->tpl->parseCurrentBlock();
477
478 if ($this->finish_test_modal === null) {
479 return;
480 }
481
482 $this->tpl->setCurrentBlock('finish_test_modal');
483 $this->tpl->setVariable(
484 'FINISH_TEST_MODAL',
485 $this->ui_renderer->render(
486 $this->finish_test_modal->withOnLoad($this->finish_test_modal->getShowSignal())
487 )
488 );
489 $this->tpl->parseCurrentBlock();
490 }
491
492 protected function populateQuestionNavigation($sequence_element, $primary_next): void
493 {
494 if (!$this->isFirstQuestionInSequence($sequence_element)) {
495 $this->populatePreviousButtons();
496 }
497
498 if (!$this->isLastQuestionInSequence($sequence_element)) {
499 $this->populateNextButtons($primary_next);
500 }
501 }
502
503 protected function populatePreviousButtons(): void
504 {
505 $this->populateUpperPreviousButtonBlock();
506 $this->populateLowerPreviousButtonBlock();
507 }
508
509 protected function populateNextButtons($primary_next): void
510 {
511 $this->populateUpperNextButtonBlock($primary_next);
512 $this->populateLowerNextButtonBlock($primary_next);
513 }
514
515 protected function populateLowerNextButtonBlock($primary_next): void
516 {
517 $button = $this->buildNextButtonInstance($primary_next);
518
519 $this->tpl->setCurrentBlock("next_bottom");
520 $this->tpl->setVariable("BTN_NEXT_BOTTOM", $this->ui_renderer->render($button));
521 $this->tpl->parseCurrentBlock();
522 }
523
524 protected function populateUpperNextButtonBlock($primaryNext)
525 {
526 $button = $this->buildNextButtonInstance($primaryNext);
527
528 $this->tpl->setCurrentBlock("next");
529 $this->tpl->setVariable("BTN_NEXT", $this->ui_renderer->render($button));
530 $this->tpl->parseCurrentBlock();
531 }
532
534 {
535 $button = $this->buildPreviousButtonInstance();
536
537 $this->tpl->setCurrentBlock("prev_bottom");
538 $this->tpl->setVariable("BTN_PREV_BOTTOM", $this->ui_renderer->render($button));
539 $this->tpl->parseCurrentBlock();
540 }
541
543 {
544 $button = $this->buildPreviousButtonInstance();
545
546 $this->tpl->setCurrentBlock("prev");
547 $this->tpl->setVariable("BTN_PREV", $this->ui_renderer->render($button));
548 $this->tpl->parseCurrentBlock();
549 }
550
555 private function buildNextButtonInstance($primaryNext)
556 {
557 $target = $this->ctrl->getLinkTarget($this, ilTestPlayerCommands::NEXT_QUESTION);
558 if ($primaryNext) {
559 $button = $this->ui_factory->button()->primary(
560 $this->lng->txt('next_question') . $this->ui_renderer->render($this->ui_factory->symbol()->glyph()->next()),
561 ''
562 )->withUnavailableAction(true)
563 ->withOnLoadCode($this->getOnLoadCodeForNavigationButtons($target, ilTestPlayerCommands::NEXT_QUESTION));
564 } else {
565 $button = $this->ui_factory->button()->standard(
566 $this->lng->txt('next_question') . $this->ui_renderer->render($this->ui_factory->symbol()->glyph()->next()),
567 ''
568 )->withUnavailableAction(true)
569 ->withOnLoadCode($this->getOnLoadCodeForNavigationButtons($target, ilTestPlayerCommands::NEXT_QUESTION));
570 }
571 return $button;
572 }
573
579 {
580 $target = $this->ctrl->getLinkTarget($this, ilTestPlayerCommands::PREVIOUS_QUESTION);
581 $button = $this->ui_factory->button()->standard(
582 $this->ui_renderer->render($this->ui_factory->symbol()->glyph()->back()) . $this->lng->txt('previous_question'),
583 ''
584 )->withUnavailableAction(true)
585 ->withOnLoadCode($this->getOnLoadCodeForNavigationButtons($target, ilTestPlayerCommands::PREVIOUS_QUESTION));
586 return $button;
587 }
588
589 private function getOnLoadCodeForNavigationButtons(string $target, string $cmd): Closure
590 {
591 return static function (string $id) use ($target, $cmd): string {
592 return "document.getElementById('{$id}').addEventListener('click', "
593 . "(e) => {il.TestPlayerQuestionEditControl.checkNavigation('{$target}', '{$cmd}', e);}"
594 . "); "
595 . "document.getElementById('{$id}').removeAttribute('disabled');";
596 };
597 }
598
602 protected function populateSpecificFeedbackBlock(assQuestionGUI $question_gui): bool
603 {
604 $solutionValues = $question_gui->getObject()->getSolutionValues(
605 $this->test_session->getActiveId(),
606 null
607 );
608
609 $feedback = $question_gui->getSpecificFeedbackOutput(
610 $question_gui->getObject()->fetchIndexedValuesFromValuePairs($solutionValues)
611 );
612
613 if (!empty($feedback)) {
614 $this->tpl->setCurrentBlock("specific_feedback");
615 $this->tpl->setVariable("SPECIFIC_FEEDBACK", $feedback);
616 $this->tpl->parseCurrentBlock();
617 return true;
618 }
619 return false;
620 }
621
625 protected function populateGenericFeedbackBlock(assQuestionGUI $question_gui, $solutionCorrect): bool
626 {
627 // fix #031263: add pass
628 $feedback = $question_gui->getGenericFeedbackOutput($this->test_session->getActiveId(), $this->test_session->getPass());
629
630 if (strlen($feedback)) {
631 $cssClass = (
632 $solutionCorrect ?
634 );
635
636 $this->tpl->setCurrentBlock("answer_feedback");
637 $this->tpl->setVariable("ANSWER_FEEDBACK", $feedback);
638 $this->tpl->setVariable("ILC_FB_CSS_CLASS", $cssClass);
639 $this->tpl->parseCurrentBlock();
640 return true;
641 }
642 return false;
643 }
644
645 protected function populateScoreBlock($reachedPoints, $maxPoints)
646 {
647 $scoreInformation = sprintf(
648 $this->lng->txt("you_received_a_of_b_points"),
649 $reachedPoints,
650 $maxPoints
651 );
652
653 $this->tpl->setCurrentBlock("received_points_information");
654 $this->tpl->setVariable("RECEIVED_POINTS_INFORMATION", $scoreInformation);
655 $this->tpl->parseCurrentBlock();
656 }
657
658 protected function populateSolutionBlock($solutionoutput)
659 {
660 if (strlen($solutionoutput)) {
661 $this->tpl->setCurrentBlock("solution_output");
662 $this->tpl->setVariable("CORRECT_SOLUTION", $this->lng->txt("tst_best_solution_is"));
663 $this->tpl->setVariable("QUESTION_FEEDBACK", $solutionoutput);
664 $this->tpl->parseCurrentBlock();
665 }
666 }
667
668 protected function populateSyntaxStyleBlock()
669 {
670 $this->tpl->setCurrentBlock("SyntaxStyle");
671 $this->tpl->setVariable(
672 "LOCATION_SYNTAX_STYLESHEET",
674 );
675 $this->tpl->parseCurrentBlock();
676 }
677
678 protected function populateContentStyleBlock()
679 {
680 $this->tpl->setCurrentBlock("ContentStyle");
681 $this->tpl->setVariable(
682 "LOCATION_CONTENT_STYLESHEET",
684 );
685 $this->tpl->parseCurrentBlock();
686 }
687
693 public function setAnonymousIdCmd(): void
694 {
695 if ($this->test_session->isAnonymousUser()) {
696 $this->test_session->setAccessCodeToSession($this->testrequest->strVal('anonymous_id'));
697 }
698
699 $this->ctrl->redirectByClass([ilRepositoryGUI::class, ilObjTestGUI::class, ilInfoScreenGUI::class]);
700 }
701
708 protected function startPlayerCmd()
709 {
710 $testStartLock = $this->getLockParameter();
711 $isFirstTestStartRequest = false;
712
713 $this->process_locker->executeTestStartLockOperation(function () use ($testStartLock, &$isFirstTestStartRequest) {
714 if ($this->test_session->lookupTestStartLock() !== $testStartLock) {
715 $this->test_session->persistTestStartLock($testStartLock);
716 $isFirstTestStartRequest = true;
717 }
718 });
719
720 if ($isFirstTestStartRequest) {
721 $this->handleUserSettings();
722 $this->ctrl->redirect($this, ilTestPlayerCommands::INIT_TEST);
723 }
724
725 $this->ctrl->setParameterByClass('ilObjTestGUI', 'lock', $testStartLock);
726 $this->ctrl->redirectByClass([ilRepositoryGUI::class, ilObjTestGUI::class, ilInfoScreenGUI::class]);
727 }
728
729 public function getLockParameter()
730 {
731 if ($this->testrequest->isset('lock') && strlen($this->testrequest->raw('lock'))) {
732 return $this->testrequest->raw('lock');
733 }
734
735 return null;
736 }
737
738 protected function resumePlayerCmd()
739 {
740 $this->handleUserSettings();
741
742 $active_id = $this->test_session->getActiveId();
743 $this->ctrl->setParameter($this, "active_id", $active_id);
744
745 $active_time_id = $this->object->startWorkingTime($active_id, $this->test_session->getPass());
746 ilSession::set("active_time_id", $active_time_id);
747 ilSession::set('tst_pass_finish', 0);
748
749 if ($this->object->isRandomTest()) {
750 if (!$this->test_sequence->hasRandomQuestionsForPass($active_id, $this->test_session->getPass())) {
751 // create a new set of random questions
752 $this->generateRandomTestPassForActiveUser();
753 }
754 }
755
756 $shuffle = $this->object->getShuffleQuestions();
757 if ($this->object->isRandomTest()) {
758 $shuffle = false;
759 }
760
761 $this->test_result_repository->updateTestAttemptResult(
762 $active_id,
763 $this->test_session->getPass(),
764 null,
765 $this->object->getId()
766 );
767
768 // ensure existing test sequence
769 if (!$this->test_sequence->hasSequence()) {
770 $this->test_sequence->createNewSequence($this->object->getQuestionCount(), $shuffle);
771 $this->test_sequence->saveToDb();
772 }
773
774 if ($this->object->getListOfQuestionsStart()) {
775 $this->ctrl->redirect($this, ilTestPlayerCommands::QUESTION_SUMMARY);
776 }
777
778 $this->ctrl->setParameter($this, 'sequence', $this->test_session->getLastSequence());
779 $this->ctrl->setParameter($this, 'pmode', '');
780 $this->ctrl->redirect($this, ilTestPlayerCommands::SHOW_QUESTION);
781 }
782
786 protected function initTestCmd()
787 {
788 if ($this->test_session->isAnonymousUser()
789 && !$this->test_session->doesAccessCodeInSessionExists()) {
790 $access_code = $this->test_session->createNewAccessCode();
791
792 $this->test_session->setAccessCodeToSession($access_code);
793 $this->test_session->setAnonymousId($access_code);
794 $this->test_session->saveToDb();
795
796 $this->ctrl->redirect($this, ilTestPlayerCommands::DISPLAY_ACCESS_CODE);
797 }
798
799 if (!$this->test_session->isAnonymousUser()) {
800 $this->test_session->unsetAccessCodeInSession();
801 }
802 $this->ctrl->redirect($this, ilTestPlayerCommands::START_TEST);
803 }
804
805 public function displayAccessCodeCmd()
806 {
807 $this->tpl->addBlockFile($this->getContentBlockName(), "adm_content", "tpl.il_as_tst_anonymous_code_presentation.html", "components/ILIAS/Test");
808 $this->tpl->setCurrentBlock("adm_content");
809 $this->tpl->setVariable("TEXT_ANONYMOUS_CODE_CREATED", $this->lng->txt("tst_access_code_created"));
810 $this->tpl->setVariable("TEXT_ANONYMOUS_CODE", $this->test_session->getAccessCodeFromSession());
811 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
812 $this->tpl->setVariable("CMD_CONFIRM", ilTestPlayerCommands::ACCESS_CODE_CONFIRMED);
813 $this->tpl->setVariable("TXT_CONFIRM", $this->lng->txt("continue_work"));
814 $this->tpl->parseCurrentBlock();
815 }
816
817 public function accessCodeConfirmedCmd()
818 {
819 $this->ctrl->redirect($this, ilTestPlayerCommands::START_TEST);
820 }
821
825 public function handleUserSettings()
826 {
827 if ($this->object->getNrOfTries() != 1
828 && $this->object->getUsePreviousAnswers() == 1
829 ) {
830 $chb_use_previous_answers = 0;
831 if ($this->post_wrapper->has('chb_use_previous_answers')) {
832 $chb_use_previous_answers = $this->post_wrapper->retrieve(
833 'chb_use_previous_answers',
834 $this->refinery->kindlyTo()->int()
835 );
836 }
837 $this->user->writePref("tst_use_previous_answers", (string) $chb_use_previous_answers);
838 }
839 }
840
845 public function redirectAfterAutosaveCmd(): void
846 {
847 $this->performTestPassFinishedTasks(StatusOfAttempt::FINISHED_BY_DURATION);
848
849 $this->redirectAfterFinish();
850 }
851
852 public function redirectAfterQuestionListCmd(): void
853 {
854 $this->performTestPassFinishedTasks(StatusOfAttempt::FINISHED_BY_DURATION);
855
856 $this->redirectAfterFinish();
857 }
858
859 protected function redirectAfterFinish(): void
860 {
861 $url = $this->ctrl->getLinkTarget($this, ilTestPlayerCommands::AFTER_TEST_PASS_FINISHED, '', false, false);
862
863 $this->tpl->addBlockFile($this->getContentBlockName(), "adm_content", "tpl.il_as_tst_redirect_autosave.html", "components/ILIAS/Test");
864 $this->tpl->setVariable("TEXT_REDIRECT", $this->lng->txt("redirectAfterSave"));
865 $this->tpl->setVariable("URL", $url);
866 }
867
868 protected function getCurrentQuestionId(): int
869 {
870 return $this->test_sequence->getQuestionForSequence($this->testrequest->int('sequence'));
871 }
872
877 public function autosaveCmd(): void
878 {
879 if (!$this->access->checkAccess('read', '', $this->ref_id)) {
880 echo $this->lng->txt('autosave_failed') . ': ' . $this->lng->txt('msg_no_perm_read_item');
881 exit;
882 }
883 $test_can_run = $this->object->isExecutable($this->test_session, $this->test_session->getUserId());
884 if (!$test_can_run['executable']) {
885 echo $test_can_run['errormessage'];
886 exit;
887 }
888 if ($this->testrequest->getPostKeys() === []) {
889 echo '';
890 exit;
891 }
892
893 if (!$this->canSaveResult() || $this->isParticipantsAnswerFixed($this->getCurrentQuestionId())) {
894 echo '-IGNORE-';
895 exit;
896 }
897
898 if ($this->saveQuestionSolution(!$this->getAnswerChangedParameter(), true)) {
899 echo $this->lng->txt('autosave_success');
900 exit;
901 }
902
903 echo $this->lng->txt('autosave_failed');
904 exit;
905 }
906
911 public function autosaveOnTimeLimitCmd()
912 {
913 if (!$this->isParticipantsAnswerFixed($this->getCurrentQuestionId())) {
914 $this->saveQuestionSolution(false, true);
915 }
916 $this->ctrl->redirect($this, ilTestPlayerCommands::REDIRECT_ON_TIME_LIMIT);
917 }
918
919
920 // fau: testNav - new function detectChangesCmd()
926 protected function detectChangesCmd()
927 {
928 $question_id = $this->getCurrentQuestionId();
929 $state = $this->getQuestionInstance($question_id)->lookupForExistingSolutions(
930 $this->test_session->getActiveId(),
931 $this->test_session->getPass()
932 );
933 $result = [];
934 $result['isAnswered'] = $state['authorized'];
935 $result['isAnswerChanged'] = $state['intermediate'];
936
937 echo json_encode($result);
938 exit;
939 }
940 // fau.
941
942 protected function submitIntermediateSolutionCmd()
943 {
944 $this->saveQuestionSolution(false, true);
945 // fau: testNav - set the 'answer changed' parameter when an intermediate solution is submitted
946 $this->setAnswerChangedParameter(true);
947 // fau.
948 $this->ctrl->redirect($this, ilTestPlayerCommands::SHOW_QUESTION);
949 }
950
951 protected function markQuestionAndSaveIntermediateCmd(): void
952 {
953 $this->handleIntermediateSubmit();
954 $this->markQuestionCmd();
955 }
956
960 protected function markQuestionCmd(): void
961 {
962 $question_id = $this->test_sequence->getQuestionForSequence(
963 $this->getCurrentSequenceElement()
964 );
965
966 $this->object->setQuestionSetSolved(1, $question_id, $this->test_session->getUserId());
967
968 $this->ctrl->redirect($this, ilTestPlayerCommands::SHOW_QUESTION);
969 }
970
972 {
973 // fau: testNav - handle intermediate submit when unmarking the question
974 $this->handleIntermediateSubmit();
975 // fau.
976 $this->unmarkQuestionCmd();
977 }
978
982 protected function unmarkQuestionCmd()
983 {
984 $question_id = $this->test_sequence->getQuestionForSequence(
985 $this->getCurrentSequenceElement()
986 );
987
988 $this->object->setQuestionSetSolved(0, $question_id, $this->test_session->getUserId());
989
990 $this->ctrl->redirect($this, ilTestPlayerCommands::SHOW_QUESTION);
991 }
992
993 public function finishTestCmd()
994 {
995 $this->handleCheckTestPassValid();
996 ilSession::clear('tst_next');
997
998 if ($this->testrequest->strVal('finalization_confirmed') !== 'confirmed') {
999 $this->finish_test_modal = $this->buildFinishTestModal();
1000 $this->showQuestionCmd();
1001 return;
1002 }
1003
1004 // Non-last try finish
1005 if (ilSession::get('tst_pass_finish') === null) {
1006 ilSession::set('tst_pass_finish', 1);
1007 }
1008
1009 $this->performTestPassFinishedTasks(StatusOfAttempt::FINISHED_BY_PARTICIPANT);
1010
1011 if ($this->logger->isLoggingEnabled()
1012 && !$this->getObject()->getAnonymity()
1013 && ($interaction = $this->logger->getInteractionFactory()->buildParticipantInteraction(
1014 $this->ref_id,
1015 null,
1016 $this->user->getId(),
1017 $this->logger->isIPLoggingEnabled() ? $_SERVER['REMOTE_ADDR'] : '',
1019 []
1020 )) !== null) {
1021 $this->logger->logParticipantInteraction($interaction);
1022 }
1023
1025 }
1026
1027 protected function performTestPassFinishedTasks(StatusOfAttempt $status_of_attempt): void
1028 {
1030 $this->test_session,
1031 $this->object,
1032 $this->test_result_repository
1033 ))->performFinishTasks($this->process_locker, $status_of_attempt);
1034 $this->test_result_repository->updateTestResultCache($this->test_session->getActiveId());
1035
1036 $this->sendNewPassFinishedNotificationEmailIfActivated(
1037 $this->test_session->getActiveId(),
1038 $this->test_session->getPass()
1039 );
1040 }
1041
1042 protected function sendNewPassFinishedNotificationEmailIfActivated(int $active_id, int $pass)
1043 {
1044 $notification_type = $this->object->getMainSettings()->getFinishingSettings()->getMailNotificationContentType();
1045
1046 if ($notification_type === 0
1047 || !$this->object->getMainSettings()->getFinishingSettings()->getAlwaysSendMailNotification()
1048 && $pass !== $this->object->getNrOfTries() - 1) {
1049 return;
1050 }
1051
1052 switch ($this->object->getMainSettings()->getFinishingSettings()->getMailNotificationContentType()) {
1053 case 1:
1054 $this->object->sendSimpleNotification($active_id);
1055 break;
1056 case 2:
1057 $this->object->sendAdvancedNotification($active_id);
1058 break;
1059 }
1060 }
1061
1062 protected function afterTestPassFinishedCmd()
1063 {
1064 // show final statement
1065 if (!$this->testrequest->isset('skipfinalstatement')) {
1066 if ($this->object->getMainSettings()->getFinishingSettings()->getConcludingRemarksEnabled()) {
1067 $this->ctrl->redirect($this, ilTestPlayerCommands::SHOW_FINAL_STATMENT);
1068 }
1069 }
1070
1071 // redirect after test
1072 $redirection_mode = $this->object->getMainSettings()->getFinishingSettings()->getRedirectionMode();
1073 $redirection_url = $this->object->getMainSettings()->getFinishingSettings()->getRedirectionUrl();
1074 if (empty($redirection_url)
1075 || $this->object->canShowTestResults($this->test_session)
1076 || $redirection_mode === RedirectionModes::NONE
1077 || $redirection_mode === RedirectionModes::IF_KIOSK_ACTIVATED && !$this->object->getKioskMode()) {
1078 $this->redirectBackCmd();
1079 }
1080
1081 if ($redirection_mode === RedirectionModes::ALWAYS_TO_LOGOUT) {
1082 $redirection_url = ilStartUpGUI::logoutUrl();
1083 }
1084
1085 ilUtil::redirect($redirection_url);
1086 }
1087
1088 public function buildFinishTestModal(): InterruptiveModal
1089 {
1090 $class = get_class($this);
1091 $this->ctrl->setParameterByClass($class, 'finalization_confirmed', 'confirmed');
1092 $next_url = $this->ctrl->getLinkTargetByClass($class, ilTestPlayerCommands::FINISH_TEST);
1093 $this->ctrl->clearParameterByClass($class, 'finalization_confirmed');
1094
1095 $message = $this->lng->txt('tst_finish_confirmation_question');
1096 if (($this->object->getNrOfTries() - 1) === $this->test_session->getPass()) {
1097 $message = $this->lng->txt('tst_finish_confirmation_question_no_attempts_left');
1098 }
1099
1100 return $this->ui_factory->modal()->interruptive(
1101 $this->lng->txt('finish_test'),
1102 $message,
1103 $next_url
1104 )->withActionButtonLabel($this->lng->txt('tst_finish_confirm_button'));
1105 }
1106
1107 public function redirectBackCmd(): void
1108 {
1109 $testPassesSelector = new ilTestPassesSelector($this->db, $this->object);
1110 $testPassesSelector->setActiveId($this->test_session->getActiveId());
1111 $testPassesSelector->setLastFinishedPass($this->test_session->getLastFinishedPass());
1112
1113 if (count($testPassesSelector->getReportablePasses())) {
1114 if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
1115 $this->ctrl->redirectByClass(['ilTestResultsGUI', 'ilTestEvalObjectiveOrientedGUI']);
1116 }
1117
1118 $this->ctrl->redirectByClass([ilTestResultsGUI::class, ilMyTestResultsGUI::class, ilTestEvaluationGUI::class]);
1119 }
1120
1121 $this->ctrl->redirectByClass(TestScreenGUI::class, TestScreenGUI::DEFAULT_CMD);
1122 }
1123
1124 /*
1125 * Presents the final statement of a test
1126 */
1127 public function showFinalStatementCmd()
1128 {
1129 $this->global_screen->tool()->context()->current()->getAdditionalData()->replace(
1131 $this->object->getTitle() . ' - ' . $this->lng->txt('final_statement')
1132 );
1133
1134 $this->content_style->gui()->addCss($this->tpl, $this->ref_id);
1135 $this->ctrl->setParameterByClass(ilTestPageGUI::class, 'page_type', 'concludingremarkspage');
1136 $this->ctrl->setParameterByClass(static::class, 'skipfinalstatement', 1);
1137 $this->tpl->setVariable(
1138 $this->getContentBlockName(),
1139 $this->ui_renderer->render([
1140 $this->ui_factory->legacy()->content(
1141 $this->object->prepareTextareaOutput($this->object->getFinalStatement(), true)
1142 ),
1143 $this->ui_factory->button()->standard(
1144 $this->lng->txt('btn_next'),
1145 $this->ctrl->getLinkTargetByClass(static::class, ilTestPlayerCommands::AFTER_TEST_PASS_FINISHED)
1146 )
1147 ])
1148 );
1149 }
1150
1151 protected function prepareTestPage($presentationMode, $sequenceElement, $question_id)
1152 {
1153 $this->navigation_history->addItem(
1154 $this->test_session->getRefId(),
1155 $this->ctrl->getLinkTarget($this, ilTestPlayerCommands::RESUME_PLAYER),
1156 'tst'
1157 );
1158
1159 $this->initTestPageTemplate();
1160 $this->populateContentStyleBlock();
1161 $this->populateSyntaxStyleBlock();
1162
1163 if ($this->isMaxProcessingTimeReached()) {
1164 $this->max_processing_time_reached();
1165 return;
1166 }
1167
1168 if ($this->object->endingTimeReached()) {
1169 $this->endingTimeReached();
1170 return;
1171 }
1172
1173 if ($this->isOptionalQuestionAnsweringConfirmationRequired($sequenceElement)) {
1174 $this->ctrl->setParameter($this, "sequence", $sequenceElement);
1175 $this->showAnswerOptionalQuestionsConfirmation();
1176 return;
1177 }
1178
1179 $this->tpl->setVariable("TEST_ID", (string) $this->object->getTestId());
1180 $this->tpl->setVariable("LOGIN", $this->user->getLogin());
1181
1182 $this->tpl->setVariable("SEQ_ID", $sequenceElement);
1183 $this->tpl->setVariable("QUEST_ID", $question_id);
1184
1185 if ($this->object->getEnableProcessingTime()) {
1186 $this->outProcessingTime($this->test_session->getActiveId(), false);
1187 }
1188
1189 $this->tpl->setVariable("PAGETITLE", "- " . $this->object->getTitle());
1190
1191 if ($this->object->isShowExamIdInTestPassEnabled() && !$this->object->getKioskMode()) {
1192 $this->tpl->setCurrentBlock('exam_id_footer');
1193 $this->tpl->setVariable('EXAM_ID_VAL', ilObjTest::lookupExamId(
1194 $this->test_session->getActiveId(),
1195 $this->test_session->getPass(),
1196 $this->object->getId()
1197 ));
1198 $this->tpl->setVariable('EXAM_ID_TXT', $this->lng->txt('exam_id'));
1199 $this->tpl->parseCurrentBlock();
1200 }
1201
1202 if ($this->object->getListOfQuestions()) {
1203 $this->showSideList($sequenceElement);
1204 }
1205 }
1206
1207 protected function isOptionalQuestionAnsweringConfirmationRequired(int $sequence_key): bool
1208 {
1209 if ($this->test_sequence->isAnsweringOptionalQuestionsConfirmed()) {
1210 return false;
1211 }
1212
1213 $question_id = $this->test_sequence->getQuestionForSequence($sequence_key);
1214
1215 if (!$this->test_sequence->isQuestionOptional($question_id)) {
1216 return false;
1217 }
1218
1219 return true;
1220 }
1221
1222 protected function isShowingPostponeStatusReguired(int $question_id): bool
1223 {
1224 return $this->test_sequence->isPostponedQuestion($question_id);
1225 }
1226
1227 protected function showQuestionViewable(
1228 assQuestionGUI $question_gui,
1229 string $form_action,
1230 bool $is_question_worked_through,
1231 bool $instant_response
1232 ): void {
1233 $question_navigation_gui = $this->buildReadOnlyStateQuestionNavigationGUI($question_gui->getObject()->getId());
1234 $question_navigation_gui->setQuestionWorkedThrough($is_question_worked_through);
1235 $question_gui->setNavigationGUI($question_navigation_gui);
1236 $question_gui->getQuestionHeaderBlockBuilder()->setQuestionAnswered($is_question_worked_through);
1237
1238 $solutionoutput = $question_gui->getSolutionOutput(
1239 $this->test_session->getActiveId(),
1240 $this->test_session->getPass(),
1241 false,
1242 false,
1243 true,
1244 $instant_response && $this->object->getSpecificAnswerFeedback(),
1245 false,
1246 false,
1247 true
1248 );
1249
1250 $pageoutput = $question_gui->outQuestionPage(
1251 '',
1252 $this->isShowingPostponeStatusReguired($question_gui->getObject()->getId()),
1253 $this->test_session->getActiveId(),
1254 $solutionoutput
1255 );
1256
1257 $this->tpl->setVariable(
1258 'LOCKSTATE_INFOBOX',
1259 $this->ui_renderer->render(
1260 $this->ui_factory->messageBox()->info($this->lng->txt('tst_player_answer_saved_and_locked'))
1261 )
1262 );
1263 $this->tpl->parseCurrentBlock();
1264 $this->tpl->setVariable('QUESTION_OUTPUT', $pageoutput);
1265 $this->tpl->setVariable('FORMACTION', $form_action);
1266 $this->tpl->setVariable('ENCTYPE', 'enctype="' . $question_gui->getFormEncodingType() . '"');
1267 $this->tpl->setVariable('FORM_TIMESTAMP', time());
1268 $this->populateQuestionEditControl($question_gui);
1269 }
1270
1271 protected function showQuestionEditable(
1272 assQuestionGUI $question_gui,
1273 string $form_action,
1274 bool $is_question_worked_through,
1275 bool $instant_response
1276 ): void {
1277 $question_navigation_gui = $this->buildEditableStateQuestionNavigationGUI($question_gui->getObject()->getId());
1278 $question_navigation_gui->setQuestionWorkedThrough($is_question_worked_through);
1279 if ($is_question_worked_through) {
1280 $question_navigation_gui->setDiscardSolutionButtonEnabled(true);
1281 $question_gui->getQuestionHeaderBlockBuilder()->setQuestionAnswered(true);
1282 } elseif ($this->object->isPostponingEnabled()) {
1283 $question_navigation_gui->setSkipQuestionLinkTarget(
1284 $this->ctrl->getLinkTarget($this, ilTestPlayerCommands::SKIP_QUESTION)
1285 );
1286 }
1287 $question_gui->setNavigationGUI($question_navigation_gui);
1288
1289 $user_post_solution = false;
1290 if ($this->testrequest->isset('save_error')
1291 && $this->testrequest->int('save_error') === 1
1292 && ilSession::get('previouspost') !== null) {
1293 $user_post_solution = ilSession::get('previouspost');
1294 ilSession::clear('previouspost');
1295 }
1296
1297 $question_config = $question_gui->getObject()->getTestPresentationConfig();
1298
1299 if ($question_gui instanceof assMultipleChoiceGUI) {
1300 $question_config->setWorkedThrough($is_question_worked_through);
1301 }
1302
1303 if ($question_config->isPreviousPassSolutionReuseAllowed()) {
1304 $pass_index = $this->determineSolutionPassIndex($question_gui);
1305 if ($pass_index < $this->test_session->getPass()) {
1306 $question_config->setSolutionInitiallyPrefilled(true);
1307 }
1308 } else {
1309 $pass_index = $this->test_session->getPass();
1310 }
1311
1312
1313 $this->modal_signals = $this->populateModals();
1314 $question_navigation_gui->setShowDiscardModalSignal($this->modal_signals[self::DISCARD_MODAL]);
1315
1316 $question_gui->outQuestionForTest(
1317 $form_action,
1318 $this->test_session->getActiveId(),
1319 $pass_index,
1320 $this->isShowingPostponeStatusReguired($question_gui->getObject()->getId()),
1321 $user_post_solution,
1322 $instant_response && $this->object->getSpecificAnswerFeedback()
1323 );
1324
1325 $this->populateQuestionEditControl($question_gui);
1326 }
1327
1328 protected function determineSolutionPassIndex(assQuestionGUI $question_gui): int
1329 {
1330 if ($this->object->isPreviousSolutionReuseEnabled($this->test_session->getActiveId())) {
1331 $currentSolutionAvailable = $question_gui->getObject()->authorizedOrIntermediateSolutionExists(
1332 $this->test_session->getActiveId(),
1333 $this->test_session->getPass()
1334 );
1335
1336 if (!$currentSolutionAvailable) {
1337 $previousPass = $question_gui->getObject()->getSolutionMaxPass(
1338 $this->test_session->getActiveId()
1339 );
1340
1341 $previousSolutionAvailable = $question_gui->getObject()->authorizedSolutionExists(
1342 $this->test_session->getActiveId(),
1343 $previousPass
1344 );
1345
1346 if ($previousSolutionAvailable) {
1347 return $previousPass;
1348 }
1349
1350 }
1351 }
1352
1353 return $this->test_session->getPass();
1354 }
1355
1356 protected function showQuestionCmd(): void
1357 {
1358 ilSession::set('tst_pass_finish', 0);
1359
1361 "active_time_id",
1362 $this->object->startWorkingTime(
1363 $this->test_session->getActiveId(),
1364 $this->test_session->getPass()
1365 )
1366 );
1367
1368 $this->help->setScreenIdComponent('tst');
1369 $this->help->setScreenId('assessment');
1370 $this->help->setSubScreenId('question');
1371
1372 $sequence_element = $this->getCurrentSequenceElement();
1373
1374 if (!$this->isValidSequenceElement($sequence_element)) {
1375 $sequence_element = $this->test_sequence->getFirstSequence();
1376 }
1377
1378 $this->test_session->setLastSequence($sequence_element ?? 0);
1379 $this->test_session->saveToDb();
1380
1381 $question_id = $this->test_sequence->getQuestionForSequence($sequence_element ?? 0);
1382 if ($question_id === null && $this->test_session->isObjectiveOriented()) {
1383 $this->handleTearsAndAngerNoObjectiveOrientedQuestion();
1384 }
1385
1386 if ($question_id !== null && !$this->test_sequence->isQuestionPresented($question_id)) {
1387 $this->test_sequence->setQuestionPresented($question_id);
1388 $this->test_sequence->saveToDb();
1389 }
1390
1391 $question_worked_through = $this->questionrepository->lookupResultRecordExist(
1392 $this->test_session->getActiveId(),
1393 $question_id,
1394 $this->test_session->getPass()
1395 );
1396
1397 $instant_response = false;
1398 if ($this->isParticipantsAnswerFixed($question_id)) {
1400 $s = $this->object->getMainSettings()->getQuestionBehaviourSettings();
1401 if ($s->getInstantFeedbackGenericEnabled()
1402 || $s->getInstantFeedbackPointsEnabled()
1403 || $s->getInstantFeedbackSolutionEnabled()
1404 || $s->getInstantFeedbackSpecificEnabled()) {
1405 $instant_response = true;
1406 }
1407 } else {
1409 if (!$this->object->isInstantFeedbackAnswerFixationEnabled()) {
1410 $instant_response = $this->getInstantResponseParameter();
1411 }
1412 }
1413
1414 $question_gui = $this->getQuestionGuiInstance($question_id);
1415
1416 if (!($question_gui instanceof assQuestionGUI)) {
1417 $this->handleTearsAndAngerQuestionIsNull($question_id, $sequence_element);
1418 }
1419
1420 $question_gui->setSequenceNumber($this->test_sequence->getPositionOfSequence($sequence_element));
1421 $question_gui->setQuestionCount($this->test_sequence->getUserQuestionCount());
1422
1423 $header_block_builder = new ilTestQuestionHeaderBlockBuilder($this->lng);
1424 $header_block_builder->setHeaderMode($this->object->getTitleOutput());
1425 $header_block_builder->setQuestionTitle($question_gui->getObject()->getTitleForHTMLOutput());
1426 $header_block_builder->setQuestionPoints($question_gui->getObject()->getPoints());
1427 $header_block_builder->setQuestionPosition($this->test_sequence->getPositionOfSequence($sequence_element));
1428 $header_block_builder->setQuestionCount($this->test_sequence->getUserQuestionCount());
1429 $header_block_builder->setQuestionPostponed($this->test_sequence->isPostponedQuestion($question_id));
1430 if ($this->test_session->isObjectiveOriented()) {
1431 $objectives_adapter = ilLOTestQuestionAdapter::getInstance($this->test_session);
1432 $objectives_adapter->buildQuestionRelatedObjectiveList($this->test_sequence, $this->question_related_objectives_list);
1433 $this->question_related_objectives_list->loadObjectivesTitles();
1434
1435 $header_block_builder->setQuestionRelatedObjectives(
1436 $this->question_related_objectives_list->getQuestionRelatedObjectiveTitles($question_id)
1437 );
1438 }
1439 $question_gui->setQuestionHeaderBlockBuilder($header_block_builder);
1440
1441 $this->prepareTestPage($presentation_mode, $sequence_element, $question_id);
1442
1443 $navigation_toolbar_gui = $this->getTestNavigationToolbarGUI();
1444 $navigation_toolbar_gui->setFinishTestButtonEnabled(true);
1445
1446 $is_next_primary = $this->handlePrimaryButton($navigation_toolbar_gui, $question_id);
1447
1448 $this->ctrl->setParameter($this, 'sequence', $sequence_element);
1449 $this->ctrl->setParameter($this, 'pmode', $presentation_mode);
1450 $form_action = $this->ctrl->getFormAction($this, ilTestPlayerCommands::SUBMIT_INTERMEDIATE_SOLUTION);
1451
1452 switch ($presentation_mode) {
1454 $navigation_toolbar_gui->setDisabledStateEnabled(false);
1455 $this->showQuestionEditable(
1456 $question_gui,
1457 $form_action,
1458 $question_worked_through,
1459 $instant_response
1460 );
1461
1462 if ($this->ctrl->getCmd() !== self::FINISH_TEST_CMD
1463 && $this->logger->isLoggingEnabled()
1464 && !$this->getObject()->getAnonymity()) {
1465 $this->logger->logParticipantInteraction(
1466 $this->logger->getInteractionFactory()->buildParticipantInteraction(
1467 $this->object->getRefId(),
1468 $question_id,
1469 $this->user->getId(),
1470 $this->logger->isIPLoggingEnabled() ? $_SERVER['REMOTE_ADDR'] : '',
1471 TestParticipantInteractionTypes::QUESTION_SHOWN,
1472 []
1473 )
1474 );
1475 }
1476 break;
1477
1479 if ($this->test_sequence->isQuestionOptional($question_gui->getObject()->getId())) {
1480 $this->populateQuestionOptionalMessage();
1481 }
1482
1483 $this->showQuestionViewable(
1484 $question_gui,
1485 $form_action,
1486 $question_worked_through,
1487 $instant_response
1488 );
1489 break;
1490
1491 default:
1492 throw new ilTestException('no presentation mode given');
1493 }
1494
1495 $navigation_toolbar_gui->build();
1496 $this->populateTestNavigationToolbar($navigation_toolbar_gui);
1497 $this->populateQuestionNavigation($sequence_element, $is_next_primary);
1498
1499 if ($instant_response) {
1500 $this->populateInstantResponseBlocks(
1501 $question_gui,
1502 true
1503 );
1504 }
1505
1506 if ($this->isForcedFeedbackNavUrlRegistered()) {
1507 $this->populateInstantResponseModal($question_gui, $this->getRegisteredForcedFeedbackNavUrl());
1508 $this->unregisterForcedFeedbackNavUrl();
1509 }
1510 }
1511
1512 protected function editSolutionCmd()
1513 {
1514 $this->ctrl->setParameter($this, 'pmode', ilTestPlayerAbstractGUI::PRESENTATION_MODE_EDIT);
1515 $this->ctrl->redirect($this, ilTestPlayerCommands::SHOW_QUESTION);
1516 }
1517
1518 protected function submitSolutionCmd()
1519 {
1520 if ($this->saveQuestionSolution(true, false)) {
1521 $question_id = $this->test_sequence->getQuestionForSequence(
1522 $this->getCurrentSequenceElement()
1523 );
1524
1525 $this->removeIntermediateSolution();
1526
1527 if ($this->object->isForceInstantFeedbackEnabled()) {
1528 $this->ctrl->setParameter($this, 'instresp', 1);
1529
1530 $this->test_sequence->setQuestionChecked($question_id);
1531 $this->test_sequence->saveToDb();
1532 }
1533
1534 if ($this->getNextCommandParameter()) {
1535 if ($this->getNextSequenceParameter()) {
1536 $this->ctrl->setParameter($this, 'sequence', $this->getNextSequenceParameter());
1537 $this->ctrl->setParameter($this, 'pmode', '');
1538 }
1539
1540 $this->ctrl->redirect($this, $this->getNextCommandParameter());
1541 }
1542
1543 $this->ctrl->setParameter($this, 'pmode', ilTestPlayerAbstractGUI::PRESENTATION_MODE_VIEW);
1544 } else {
1545 $this->ctrl->redirect($this, ilTestPlayerCommands::SHOW_QUESTION);
1546 }
1547
1548 // fau: testNav - remember to prevent the navigation confirmation
1549 $this->saveNavigationPreventConfirmation();
1550 // fau.
1551
1552 // fau: testNav - handle navigation after saving
1553 if ($this->getNavigationUrlParameter()) {
1554 ilUtil::redirect($this->getNavigationUrlParameter());
1555 } else {
1556 $this->ctrl->saveParameter($this, 'sequence');
1557 }
1558 // fau.
1559 $this->ctrl->redirect($this, ilTestPlayerCommands::SHOW_QUESTION);
1560 }
1561
1562 // fau: testNav - new function to revert probably auto-saved changes and show the last submitted question state
1563 protected function revertChangesCmd()
1564 {
1565 $this->removeIntermediateSolution();
1566 $this->setAnswerChangedParameter(false);
1567 $this->ctrl->saveParameter($this, 'sequence');
1568 $this->ctrl->redirect($this, ilTestPlayerCommands::SHOW_QUESTION);
1569 }
1570 // fau.
1571
1572 protected function discardSolutionCmd()
1573 {
1574 $current_sequence_element = $this->getCurrentSequenceElement();
1575
1576 $current_question_obj = $this->getQuestionInstance(
1577 $this->test_sequence->getQuestionForSequence($current_sequence_element)
1578 );
1579 $current_question_obj->setTestId($this->object->getId());
1580
1581 $current_question_obj->resetUsersAnswer(
1582 $this->test_session->getActiveId(),
1583 $this->test_session->getPass()
1584 );
1585
1586 if ($this->logger->isLoggingEnabled()
1587 && !$this->getObject()->getAnonymity()) {
1588 $this->logger->logParticipantInteraction(
1589 $this->logger->getInteractionFactory()->buildParticipantInteraction(
1590 $this->object->getRefId(),
1591 $this->test_sequence->getQuestionForSequence($current_sequence_element),
1592 $this->user->getId(),
1593 $this->logger->isIPLoggingEnabled() ? $_SERVER['REMOTE_ADDR'] : '',
1594 TestParticipantInteractionTypes::ANSWER_DELETED,
1595 []
1596 )
1597 );
1598 }
1599
1600 $this->ctrl->saveParameter($this, 'sequence');
1601
1602 $this->ctrl->setParameter($this, 'pmode', ilTestPlayerAbstractGUI::PRESENTATION_MODE_VIEW);
1603
1604 $this->ctrl->redirect($this, ilTestPlayerCommands::SHOW_QUESTION);
1605 }
1606
1607 protected function skipQuestionCmd()
1608 {
1609 $current_sequence_element = $this->getCurrentSequenceElement();
1610 $next_sequence_element = $this->test_sequence->getNextSequence($current_sequence_element);
1611
1612 if (!$this->isValidSequenceElement($next_sequence_element)) {
1613 $next_sequence_element = $this->test_sequence->getFirstSequence();
1614 }
1615
1616 if ($this->object->isPostponingEnabled()) {
1617 $this->test_sequence->postponeSequence($current_sequence_element);
1618 $this->test_sequence->saveToDb();
1619 }
1620
1621 if ($this->logger->isLoggingEnabled()
1622 && !$this->getObject()->getAnonymity()) {
1623 $this->logger->logParticipantInteraction(
1624 $this->logger->getInteractionFactory()->buildParticipantInteraction(
1625 $this->object->getRefId(),
1626 $this->test_sequence->getQuestionForSequence($current_sequence_element),
1627 $this->user->getId(),
1628 $this->logger->isIPLoggingEnabled() ? $_SERVER['REMOTE_ADDR'] : '',
1629 TestParticipantInteractionTypes::QUESTION_SKIPPED,
1630 []
1631 )
1632 );
1633 }
1634
1635 $this->ctrl->setParameter($this, 'sequence', $next_sequence_element);
1636 $this->ctrl->setParameter($this, 'pmode', '');
1637
1638 $this->ctrl->redirect($this, ilTestPlayerCommands::SHOW_QUESTION);
1639 }
1640
1641 protected function startTestCmd()
1642 {
1643 ilSession::set('tst_pass_finish', 0);
1644
1645 // ensure existing test session
1646 $this->test_session->setUserId($this->user->getId());
1647 $access_code = ilSession::get('tst_access_code');
1648 if ($access_code != null && isset($access_code[$this->object->getTestId()])) {
1649 $this->test_session->setAnonymousId($access_code[$this->object->getTestId()]);
1650 }
1651 if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
1652 $this->test_session->setObjectiveOrientedContainerId($this->getObjectiveOrientedContainer()->getObjId());
1653 }
1654 $this->test_session->saveToDb();
1655
1656 $active_id = $this->test_session->getActiveId();
1657 $this->ctrl->setParameter($this, "active_id", $active_id);
1658
1659 $shuffle = $this->object->getShuffleQuestions();
1660 if ($this->object->isRandomTest()) {
1661 $this->generateRandomTestPassForActiveUser();
1662
1663 $this->object->loadQuestions();
1664 $shuffle = false; // shuffle is already done during the creation of the random questions
1665 }
1666
1667 $this->test_result_repository->updateTestAttemptResult(
1668 $active_id,
1669 $this->test_session->getPass(),
1670 null,
1671 $this->object->getId()
1672 );
1673
1674 // ensure existing test sequence
1675 if (!$this->test_sequence->hasSequence()) {
1676 $this->test_sequence->createNewSequence($this->object->getQuestionCount(), $shuffle);
1677 $this->test_sequence->saveToDb();
1678 }
1679
1680 $this->test_sequence->loadFromDb();
1681 $this->test_sequence->loadQuestions();
1682
1683 if ($this->test_session->isObjectiveOriented()) {
1684 $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($this->test_session);
1685
1686 $objectivesAdapter->notifyTestStart($this->test_session, $this->object->getId());
1687 $objectivesAdapter->prepareTestPass($this->test_session, $this->test_sequence);
1688
1689 $objectivesAdapter->buildQuestionRelatedObjectiveList(
1690 $this->test_sequence,
1691 $this->question_related_objectives_list
1692 );
1693
1694 if ($this->test_sequence->hasOptionalQuestions()) {
1695 $this->adoptUserSolutionsFromPreviousPass();
1696
1697 $this->test_sequence->reorderOptionalQuestionsToSequenceEnd();
1698 $this->test_sequence->saveToDb();
1699 }
1700 }
1701
1702 $active_time_id = $this->object->startWorkingTime(
1703 $this->test_session->getActiveId(),
1704 $this->test_session->getPass()
1705 );
1706 ilSession::set("active_time_id", $active_time_id);
1707
1708 $this->updateLearningProgressOnTestStart();
1709
1710 $sequence_element = $this->test_sequence->getFirstSequence();
1711
1712 $this->ctrl->setParameter($this, 'sequence', $sequence_element);
1713 $this->ctrl->setParameter($this, 'pmode', '');
1714
1715 if ($this->logger->isLoggingEnabled()
1716 && !$this->getObject()->getAnonymity()) {
1717 $this->logger->logParticipantInteraction(
1718 $this->logger->getInteractionFactory()->buildParticipantInteraction(
1719 $this->object->getRefId(),
1720 null,
1721 $this->user->getId(),
1722 $this->logger->isIPLoggingEnabled() ? $_SERVER['REMOTE_ADDR'] : '',
1723 TestParticipantInteractionTypes::TEST_RUN_STARTED,
1724 []
1725 )
1726 );
1727 }
1728
1729 if ($this->object->getListOfQuestionsStart()) {
1730 $this->ctrl->setParameterByClass(static::class, 'first', '1');
1731 $this->ctrl->redirect($this, ilTestPlayerCommands::QUESTION_SUMMARY);
1732 }
1733
1734 $this->ctrl->redirect($this, ilTestPlayerCommands::SHOW_QUESTION);
1735 }
1736
1740 public function isTestAccessible(): bool
1741 {
1742 return !$this->isNrOfTriesReached()
1743 and !$this->isMaxProcessingTimeReached()
1744 and $this->object->startingTimeReached()
1745 and !$this->object->endingTimeReached();
1746 }
1747
1751 public function isNrOfTriesReached(): bool
1752 {
1753 return $this->object->hasNrOfTriesRestriction() && $this->object->isNrOfTriesReached($this->test_session->getPass());
1754 }
1755
1761 public function endingTimeReached()
1762 {
1763 $this->tpl->setOnScreenMessage('info', sprintf($this->lng->txt("detail_ending_time_reached"), ilDatePresentation::formatDate(new ilDateTime($this->object->getEndingTime(), IL_CAL_UNIX))));
1764 $this->test_session->increasePass();
1765 $this->test_session->setLastSequence(0);
1766 $this->test_session->saveToDb();
1767
1768 $this->redirectBackCmd();
1769 }
1770
1779 {
1780 $this->suspendTestCmd();
1781 }
1782
1788 public function confirmSubmitAnswers()
1789 {
1790 $this->tpl->addBlockFile($this->getContentBlockName(), "adm_content", "tpl.il_as_tst_submit_answers_confirm.html", "components/ILIAS/Test");
1791 $this->tpl->setCurrentBlock("adm_content");
1792 if ($this->object->isTestFinished($this->test_session->getActiveId())) {
1793 $this->tpl->setCurrentBlock("not_submit_allowed");
1794 $this->tpl->setVariable("TEXT_ALREADY_SUBMITTED", $this->lng->txt("tst_already_submitted"));
1795 $this->tpl->setVariable("BTN_OK", $this->lng->txt("tst_show_answer_sheet"));
1796 } else {
1797 $this->tpl->setCurrentBlock("submit_allowed");
1798 $this->tpl->setVariable("TEXT_CONFIRM_SUBMIT_RESULTS", $this->lng->txt("tst_confirm_submit_answers"));
1799 $this->tpl->setVariable("BTN_OK", $this->lng->txt("tst_submit_results"));
1800 }
1801 $this->tpl->setVariable("BTN_BACK", $this->lng->txt("back"));
1802 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this, "finalSubmission"));
1803 $this->tpl->parseCurrentBlock();
1804 }
1805
1806 private function outProcessingTime(int $active_id, bool $verbose): void
1807 {
1808 $starting_time = $this->object->getStartingTimeOfUser($active_id);
1809 $working_time = new WorkingTime(
1810 $this->lng,
1811 $this->ui_factory,
1812 $this->ui_renderer,
1813 $starting_time,
1814 $this->object->getProcessingTimeInSeconds($active_id)
1815 );
1816
1817 $this->tpl->setCurrentBlock('enableprocessingtime');
1818 $this->tpl->setVariable('USER_WORKING_TIME_MESSAGE_BOX', $working_time->getMessageBox($verbose));
1819 $this->tpl->parseCurrentBlock();
1820
1821 $working_time_js_template = $working_time->prepareWorkingTimeJsTemplate(
1822 $this->getObject(),
1823 getdate($starting_time),
1824 $this->ctrl->getLinkTarget($this, 'checkWorkingTime', '', true),
1825 $this->ctrl->getFormAction($this, ilTestPlayerCommands::REDIRECT_AFTER_QUESTION_LIST)
1826 );
1827
1828 $this->tpl->addOnLoadCode($working_time_js_template->get());
1829 }
1830
1838 public function checkWorkingTimeCmd(): void
1839 {
1840 $active_id = $this->test_session->getActiveId();
1841 echo (string) $this->object->getProcessingTimeInSeconds($active_id);
1842 exit;
1843 }
1844
1845 protected function showSideList($current_sequence_element): void
1846 {
1847 $question_summary_data = $this->service->getQuestionSummaryData($this->test_sequence);
1848 $questions = [];
1849 $active = 0;
1850
1851 foreach ($question_summary_data as $idx => $row) {
1852 $title = htmlspecialchars($row['title'], ENT_QUOTES, null, false);
1853 $description = '';
1854 if ($row['description'] !== '') {
1855 $description = htmlspecialchars($row['description'], ENT_QUOTES, null, false);
1856 }
1857
1858 if (!$row['disabled']) {
1859 $this->ctrl->setParameter($this, 'pmode', '');
1860 $this->ctrl->setParameter($this, 'sequence', $row['sequence']);
1861 $action = $this->ctrl->getLinkTarget($this, ilTestPlayerCommands::SHOW_QUESTION);
1862 $this->ctrl->setParameter($this, 'pmode', ilTestPlayerAbstractGUI::PRESENTATION_MODE_VIEW);
1863 $this->ctrl->setParameter($this, 'sequence', $this->getCurrentSequenceElement($current_sequence_element));
1864 }
1865
1867
1868 if (
1869 ($row['worked_through'] || $row['isAnswered'])
1870 && $row['has_authorized_answer']
1871 ) {
1873 }
1874
1875 $questions[] = $this->ui_factory->listing()->workflow()
1876 ->step($title, $description, $action)
1877 ->withStatus($status);
1878 $active = $row['sequence'] == $current_sequence_element ? $idx : $active;
1879 }
1880
1881 $question_listing = $this->ui_factory->listing()->workflow()->linear(
1882 $this->lng->txt('mainbar_button_label_questionlist'),
1883 $questions
1884 )->withActive($active);
1885
1886
1887 $this->global_screen->tool()->context()->current()->addAdditionalData(
1889 $question_listing
1890 );
1891 }
1892
1896 public function outQuestionSummaryCmd()
1897 {
1898 $this->help->setScreenIdComponent('tst');
1899 $this->help->setScreenId('assessment');
1900 $this->help->setSubScreenId('question_summary');
1901
1902 $is_first_page = $this->testrequest->strVal('first') === '1';
1903
1904 $this->tpl->addBlockFile(
1905 $this->getContentBlockName(),
1906 'adm_content',
1907 'tpl.il_as_tst_question_summary.html',
1908 'components/ILIAS/Test'
1909 );
1910
1911 $this->global_screen->tool()->context()->current()->getAdditionalData()->replace(
1913 $this->getObject()->getTitle() . ' - ' . $this->lng->txt('question_summary')
1914 );
1915
1916 $active_id = $this->test_session->getActiveId();
1917 $question_summary_data = $this->service->getQuestionSummaryData($this->test_sequence);
1918
1919 $this->ctrl->setParameter($this, 'sequence', $this->testrequest->raw('sequence'));
1920
1921 $table = new QuestionsOfAttemptTable(
1922 $this->lng,
1923 $this->ctrl,
1924 $this->ui_factory,
1925 new DataFactory(),
1926 $this->http,
1927 $this,
1928 $this->object,
1929 $question_summary_data
1930 );
1931 $this->tpl->setVariable('TABLE_LIST_OF_QUESTIONS', $this->ui_renderer->render($table->buildComponents($is_first_page)));
1932
1933 if ($this->object->getEnableProcessingTime()) {
1934 $this->outProcessingTime($active_id, true);
1935 }
1936
1937 if ($this->object->isShowExamIdInTestPassEnabled()) {
1938 $this->tpl->setCurrentBlock('exam_id_footer');
1939 $this->tpl->setVariable('EXAM_ID_VAL', ilObjTest::lookupExamId(
1940 $this->test_session->getActiveId(),
1941 $this->test_session->getPass(),
1942 $this->object->getId()
1943 ));
1944 $this->tpl->setVariable('EXAM_ID_TXT', $this->lng->txt('exam_id'));
1945 $this->tpl->parseCurrentBlock();
1946 }
1947 }
1948
1949 public function backFromFinishingCmd()
1950 {
1951 $this->ctrl->redirect($this, ilTestPlayerCommands::SHOW_QUESTION);
1952 }
1953
1957 public function outCorrectSolution(): void
1958 {
1959 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_as_tst_correct_solution.html", "components/ILIAS/Test");
1960
1961 $this->tpl->setCurrentBlock("ContentStyle");
1962 $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", ilObjStyleSheet::getContentStylePath(0));
1963 $this->tpl->parseCurrentBlock();
1964
1965 $this->tpl->setCurrentBlock("SyntaxStyle");
1966 $this->tpl->setVariable("LOCATION_SYNTAX_STYLESHEET", ilObjStyleSheet::getSyntaxStylePath());
1967 $this->tpl->parseCurrentBlock();
1968
1969 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css"), "print");
1970 if ($this->object->getShowSolutionAnswersOnly()) {
1971 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css"), "print");
1972 }
1973
1974 $this->tpl->setCurrentBlock("adm_content");
1975 $solution = $this->getCorrectSolutionOutput($this->testrequest->raw("evaluation"), $this->testrequest->raw("active_id"), $this->testrequest->raw("pass"));
1976 $this->tpl->setVariable("OUTPUT_SOLUTION", $solution);
1977 $this->tpl->setVariable("TEXT_BACK", $this->lng->txt("back"));
1978 $this->ctrl->saveParameter($this, "pass");
1979 $this->ctrl->saveParameter($this, "active_id");
1980 $this->tpl->setVariable("URL_BACK", $this->ctrl->getLinkTarget($this, "outUserResultsOverview"));
1981 $this->tpl->parseCurrentBlock();
1982 }
1983
1993 public function showListOfAnswers($active_id, $pass = null, $top_data = "", $bottom_data = "")
1994 {
1995 $this->tpl->addBlockFile($this->getContentBlockName(), "adm_content", "tpl.il_as_tst_finish_list_of_answers.html", "components/ILIAS/Test");
1996
1997 $result_array = $this->object->getTestResult(
1998 $active_id,
1999 $pass,
2000 false,
2001 !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()
2002 );
2003
2004 $counter = 1;
2005 // output of questions with solutions
2006 foreach ($result_array as $question_data) {
2007 $question = $question_data["qid"];
2008 if (is_numeric($question)) {
2009 $this->tpl->setCurrentBlock("printview_question");
2010 $question_gui = $this->object->createQuestionGUI("", $question);
2011 $template = new ilTemplate("tpl.il_as_qpl_question_printview.html", true, true, "components/ILIAS/TestQuestionPool");
2012 $template->setVariable("COUNTER_QUESTION", $counter . ". ");
2013 $template->setVariable("QUESTION_TITLE", $question_gui->getObject()->getTitleForHTMLOutput());
2014
2015 $show_question_only = ($this->object->getShowSolutionAnswersOnly()) ? true : false;
2016 $result_output = $question_gui->getSolutionOutput(
2017 $active_id,
2018 $pass,
2019 false,
2020 false,
2021 $show_question_only,
2022 $this->object->getShowSolutionFeedback()
2023 );
2024 $template->setVariable("SOLUTION_OUTPUT", $result_output);
2025 $this->tpl->setVariable("QUESTION_OUTPUT", $template->get());
2026 $this->tpl->parseCurrentBlock();
2027 $counter++;
2028 }
2029 }
2030
2031 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print.css"), "print");
2032 if ($this->object->getShowSolutionAnswersOnly()) {
2033 $this->tpl->addCss(ilUtil::getStyleSheetLocation("output", "test_print_hide_content.css"), "print");
2034 }
2035 if (strlen($top_data)) {
2036 $this->tpl->setCurrentBlock("top_data");
2037 $this->tpl->setVariable("TOP_DATA", $top_data);
2038 $this->tpl->parseCurrentBlock();
2039 }
2040
2041 if (strlen($bottom_data)) {
2042 $this->tpl->setCurrentBlock("bottom_data");
2043 $this->tpl->setVariable("FORMACTION", $this->ctrl->getFormAction($this));
2044 $this->tpl->setVariable("BOTTOM_DATA", $bottom_data);
2045 $this->tpl->parseCurrentBlock();
2046 }
2047
2048 $this->tpl->setCurrentBlock("adm_content");
2049 $this->tpl->setVariable("TXT_ANSWER_SHEET", $this->lng->txt("tst_list_of_answers"));
2050 $user_data = $this->getAdditionalUsrDataHtmlAndPopulateWindowTitle($this->test_session, $active_id, true);
2051 $signature = $this->getResultsSignature();
2052 $this->tpl->setVariable("USER_DETAILS", $user_data);
2053 $this->tpl->setVariable("SIGNATURE", $signature);
2054 $this->tpl->setVariable("TITLE", $this->object->getTitle());
2055 $this->tpl->setVariable("TXT_TEST_PROLOG", $this->lng->txt("tst_your_answers"));
2056 $invited_user = &$this->object->getInvitedUsers($this->user->getId());
2057 $pagetitle = $this->object->getTitle() . ' - ' . $this->lng->txt('clientip') .
2058 ': ' . $_SERVER['REMOTE_ADDR'] . ' - ' .
2059 $this->lng->txt('matriculation') . ': ' .
2060 $invited_user[$this->user->getId()]['matriculation'];
2061 $this->tpl->setVariable('PAGETITLE', $pagetitle);
2062 $this->tpl->parseCurrentBlock();
2063 }
2064
2070 public function getContentBlockName(): string
2071 {
2072 return "ADM_CONTENT";
2073
2074 if ($this->object->getKioskMode()) {
2075 $this->tpl->setBodyClass("kiosk");
2076 $this->tpl->hideFooter();
2077 return "CONTENT";
2078 } else {
2079 return "ADM_CONTENT";
2080 }
2081 }
2082
2084 {
2085 $this->ctrl->redirectByClass(
2086 [ilRepositoryGUI::class, ilObjTestGUI::class, ilTestEvaluationGUI::class],
2087 "outUserResultsOverview"
2088 );
2089 }
2090
2091
2092 protected function isFirstQuestionInSequence($sequence_element): bool
2093 {
2094 return $sequence_element == $this->test_sequence->getFirstSequence();
2095 }
2096
2097 protected function isLastQuestionInSequence($sequence_element): bool
2098 {
2099 return $sequence_element == $this->test_sequence->getLastSequence();
2100 }
2101
2102 protected function handleQuestionActionCmd()
2103 {
2104 $question_id = $this->test_sequence->getQuestionForSequence(
2105 $this->getCurrentSequenceElement()
2106 );
2107
2108 if (!$this->isParticipantsAnswerFixed($question_id)) {
2109 $this->updateWorkingTime();
2110 $this->saveQuestionSolution(false);
2111 // fau: testNav - add changed status of the question
2112 $this->setAnswerChangedParameter(true);
2113 // fau.
2114 }
2115
2116 $this->ctrl->redirect($this, ilTestPlayerCommands::SHOW_QUESTION);
2117 }
2118
2119 protected function showInstantResponseCmd()
2120 {
2121 $question_id = $this->test_sequence->getQuestionForSequence(
2122 $this->getCurrentSequenceElement()
2123 );
2124
2125 if (!$this->isParticipantsAnswerFixed($question_id)) {
2126 if ($this->saveQuestionSolution(true)) {
2127 $this->removeIntermediateSolution();
2128 $this->setAnswerChangedParameter(false);
2129 } else {
2130 $this->ctrl->redirect($this, ilTestPlayerCommands::SHOW_QUESTION);
2131 }
2132 $this->test_sequence->setQuestionChecked($question_id);
2133 $this->test_sequence->saveToDb();
2134 } elseif ($this->object->isForceInstantFeedbackEnabled()) {
2135 $this->test_sequence->setQuestionChecked($question_id);
2136 $this->test_sequence->saveToDb();
2137 }
2138
2139 $this->ctrl->setParameter($this, 'instresp', 1);
2140
2141 // fau: testNav - handle navigation after feedback
2142 if ($this->getNavigationUrlParameter()) {
2143 $this->saveNavigationPreventConfirmation();
2144 $this->registerForcedFeedbackNavUrl($this->getNavigationUrlParameter());
2145 }
2146 // fau.
2147 $this->ctrl->redirectByClass(static::class, ilTestPlayerCommands::SHOW_QUESTION);
2148 }
2149
2150 protected function nextQuestionCmd()
2151 {
2152 $this->handleCheckTestPassValid();
2153 $last_sequence_element = $this->getCurrentSequenceElement();
2154 $next_sequence_element = $this->test_sequence->getNextSequence($last_sequence_element);
2155
2156 $question_id = $this->test_sequence->getQuestionForSequence($last_sequence_element);
2157 $is_worked_through = $this->questionrepository->lookupResultRecordExist(
2158 $this->test_session->getActiveId(),
2159 $question_id,
2160 $this->test_session->getPass()
2161 );
2162
2163 if (!$is_worked_through) {
2164 if ($this->logger->isLoggingEnabled()
2165 && !$this->getObject()->getAnonymity()) {
2166 $this->logger->logParticipantInteraction(
2167 $this->logger->getInteractionFactory()->buildParticipantInteraction(
2168 $this->object->getRefId(),
2169 $question_id,
2170 $this->user->getId(),
2171 $this->logger->isIPLoggingEnabled() ? $_SERVER['REMOTE_ADDR'] : '',
2172 TestParticipantInteractionTypes::QUESTION_SKIPPED,
2173 []
2174 )
2175 );
2176 }
2177 if ($this->object->isPostponingEnabled()) {
2178 $this->handleQuestionPostponing($question_id);
2179 }
2180 }
2181
2182 if (!$this->isValidSequenceElement($next_sequence_element)) {
2183 $next_sequence_element = $this->test_sequence->getFirstSequence();
2184 }
2185
2186 $this->ctrl->setParameter($this, 'sequence', $next_sequence_element);
2187 $this->ctrl->setParameter($this, 'pmode', '');
2188
2189 $this->ctrl->redirect($this, ilTestPlayerCommands::SHOW_QUESTION);
2190 }
2191
2192 protected function previousQuestionCmd()
2193 {
2194 $this->handleCheckTestPassValid();
2195
2196 $sequence_element = $this->test_sequence->getPreviousSequence(
2197 $this->getCurrentSequenceElement()
2198 );
2199
2200 if (!$this->isValidSequenceElement($sequence_element)) {
2201 $sequence_element = $this->test_sequence->getLastSequence();
2202 }
2203
2204 $this->ctrl->setParameter($this, 'sequence', $sequence_element);
2205 $this->ctrl->setParameter($this, 'pmode', '');
2206
2207 $this->ctrl->redirect($this, ilTestPlayerCommands::SHOW_QUESTION);
2208 }
2209
2210 protected function prepareSummaryPage()
2211 {
2212 $this->tpl->addBlockFile(
2213 $this->getContentBlockName(),
2214 'adm_content',
2215 'tpl.il_as_tst_question_summary.html',
2216 'components/ILIAS/Test'
2217 );
2218 }
2219
2220 protected function initTestPageTemplate()
2221 {
2222 $onload_js = <<<JS
2223 let key_event = (event) => {
2224 if( event.key === 13 && event.target.tagName.toLowerCase() === "a" ) {
2225 return;
2226 }
2227 if (event.key === 13 &&
2228 event.target.tagName.toLowerCase() !== "textarea" &&
2229 (event.target.tagName.toLowerCase() !== "input" || event.target.type.toLowerCase() !== "submit")) {
2230 event.preventDefault();
2231 }
2232 };
2233
2234 let form = document.getElementById('taForm');
2235 form.onkeyup = key_event;
2236 form.onkeydown = key_event;
2237 form.onkeypress = key_event;
2238JS;
2239 $this->tpl->addOnLoadCode($onload_js);
2240 $this->tpl->addBlockFile(
2241 $this->getContentBlockName(),
2242 'adm_content',
2243 'tpl.il_as_tst_output.html',
2244 'components/ILIAS/Test'
2245 );
2246 }
2247
2249 {
2256 if ($this->test_session->isPasswordChecked() === true) {
2257 return;
2258 }
2259
2260 if ($this->ctrl->getNextClass() === 'iltestpasswordprotectiongui') {
2261 return;
2262 }
2263
2264 if (!$this->password_checker->isPasswordProtectionPageRedirectRequired()) {
2265 $this->test_session->setPasswordChecked(true);
2266 return;
2267 }
2268
2269 $this->ctrl->setParameterByClass(self::class, 'lock', $this->getLockParameter());
2270
2271 $next_command = $this->ctrl->getCmdClass() . '::' . ilTestPlayerCommands::START_TEST;
2272 $this->ctrl->setParameterByClass(ilTestPasswordProtectionGUI::class, 'nextCommand', $next_command);
2273 $this->ctrl->redirectByClass(ilTestPasswordProtectionGUI::class, 'showPasswordForm');
2274 }
2275
2276 protected function isParticipantsAnswerFixed($question_id): bool
2277 {
2278 if ($this->object->isInstantFeedbackAnswerFixationEnabled()) {
2279 return $this->test_sequence->isQuestionChecked($question_id);
2280 }
2281
2282 if ($this->object->isFollowupQuestionAnswerFixationEnabled()) {
2283 return $this->isForcedFeedbackNavUrlRegistered() || $this->test_sequence->isNextQuestionPresented($question_id);
2284 }
2285
2286 return false;
2287 }
2288
2292 protected function getIntroductionPageButtonLabel(): string
2293 {
2294 return $this->lng->txt("save_introduction");
2295 }
2296
2297 protected function initAssessmentSettings()
2298 {
2299 $this->ass_settings = new ilSetting('assessment');
2300 }
2301
2305 protected function handleSkillTriggering(ilTestSession $test_session): void
2306 {
2307 $skill_evaluation = new ilTestSkillEvaluation(
2308 $this->db,
2309 $this->logger,
2310 $this->object->getTestId(),
2311 $this->object->getRefId(),
2312 $this->skills_service->profile(),
2313 $this->skills_service->personal()
2314 );
2315
2316 $skill_evaluation->setUserId($test_session->getUserId());
2317 $skill_evaluation->setActiveId($test_session->getActiveId());
2318 $skill_evaluation->setPass($test_session->getPass());
2319
2320 $skill_evaluation->setNumRequiredBookingsForSkillTriggering(
2321 $this->object->getGlobalSettings()->getSkillTriggeringNumberOfAnswers()
2322 );
2323
2324 $question_list = $this->buildTestPassQuestionList();
2325 $question_list->load();
2326 $skill_evaluation->init($question_list);
2327 $skill_evaluation->evaluate(
2328 $this->object->getTestResult(
2329 $test_session->getActiveId(),
2330 $test_session->getPass(),
2331 true
2332 )
2333 );
2334
2335 $skill_evaluation->handleSkillTriggering();
2336 }
2337
2339 {
2340 $confirmation = new ilTestAnswerOptionalQuestionsConfirmationGUI($this->lng);
2341
2342 $confirmation->setFormAction($this->ctrl->getFormAction($this));
2343 $confirmation->setCancelCmd('cancelAnswerOptionalQuestions');
2344 $confirmation->setConfirmCmd('confirmAnswerOptionalQuestions');
2345
2346 $confirmation->build($this->object->isFixedTest());
2347
2348 $this->populateHelperGuiContent($confirmation);
2349 }
2350
2352 {
2353 $this->test_sequence->setAnsweringOptionalQuestionsConfirmed(true);
2354 $this->test_sequence->saveToDb();
2355
2356 $this->ctrl->setParameter($this, 'activecommand', 'gotoquestion');
2357 $this->ctrl->redirect($this, 'redirectQuestion');
2358 }
2359
2361 {
2362 if ($this->object->getListOfQuestions()) {
2363 $this->ctrl->setParameter($this, 'activecommand', 'summary');
2364 } else {
2365 $this->ctrl->setParameter($this, 'activecommand', 'previous');
2366 }
2367
2368 $this->ctrl->redirect($this, 'redirectQuestion');
2369 }
2370
2374 protected function populateHelperGuiContent($helperGui)
2375 {
2376 $this->tpl->setVariable($this->getContentBlockName(), $this->ctrl->getHTML($helperGui));
2377 }
2378
2380 {
2381 $navigation_toolbar = new ilTestNavigationToolbarGUI($this->ctrl, $this);
2382 $navigation_toolbar->setSuspendTestButtonEnabled($this->object->getShowCancel());
2383 $navigation_toolbar->setUserPassOverviewEnabled($this->object->getUsrPassOverviewEnabled());
2384 $navigation_toolbar->setFinishTestCommand($this->getFinishTestCommand());
2385 return $navigation_toolbar;
2386 }
2387
2389 {
2390 $navigationGUI = new ilTestQuestionNavigationGUI(
2391 $this->lng,
2392 $this->ui_factory,
2393 $this->ui_renderer
2394 );
2395
2396 if (!$this->isParticipantsAnswerFixed($question_id)) {
2397 $navigationGUI->setEditSolutionCommand(ilTestPlayerCommands::EDIT_SOLUTION);
2398 }
2399
2400 if ($this->object->getShowMarker()) {
2401 $solved_array = ilObjTest::_getSolvedQuestions($this->test_session->getActiveId(), $question_id);
2402 $solved = 0;
2403
2404 if (count($solved_array) > 0) {
2405 $solved = array_pop($solved_array);
2406 $solved = $solved["solved"];
2407 }
2408 // fau: testNav - change question mark command to link target
2409 if ($solved == 1) {
2410 $navigationGUI->setQuestionMarkLinkTarget($this->ctrl->getLinkTarget($this, ilTestPlayerCommands::UNMARK_QUESTION));
2411 $navigationGUI->setQuestionMarked(true);
2412 } else {
2413 $navigationGUI->setQuestionMarkLinkTarget($this->ctrl->getLinkTarget($this, ilTestPlayerCommands::MARK_QUESTION));
2414 $navigationGUI->setQuestionMarked(false);
2415 }
2416 }
2417 // fau.
2418
2419 return $navigationGUI;
2420 }
2421
2423 {
2424 $navigation_gui = new ilTestQuestionNavigationGUI(
2425 $this->lng,
2426 $this->ui_factory,
2427 $this->ui_renderer
2428 );
2429
2430 // fau: testNav - add a 'revert changes' link for editable question
2431 $navigation_gui->setRevertChangesLinkTarget($this->ctrl->getLinkTarget($this, ilTestPlayerCommands::REVERT_CHANGES));
2432
2433 if ($this->object->getSpecificAnswerFeedback()
2434 || $this->object->getGenericAnswerFeedback()
2435 || $this->object->getAnswerFeedbackPoints()
2436 || $this->object->getInstantFeedbackSolution()) {
2437 $navigation_gui->setAnswerFreezingEnabled($this->object->isInstantFeedbackAnswerFixationEnabled());
2438
2439 if ($this->object->isForceInstantFeedbackEnabled()) {
2440 $navigation_gui->setForceInstantResponseEnabled(true);
2441 $navigation_gui->setInstantFeedbackCommand(ilTestPlayerCommands::SUBMIT_SOLUTION);
2442 } else {
2443 $navigation_gui->setInstantFeedbackCommand(ilTestPlayerCommands::SHOW_INSTANT_RESPONSE);
2444 }
2445 }
2446
2447 if ($this->object->getShowMarker()) {
2448 $solved_array = ilObjTest::_getSolvedQuestions($this->test_session->getActiveId(), $question_id);
2449 $solved = 0;
2450
2451 if (count($solved_array) > 0) {
2452 $solved = array_pop($solved_array);
2453 $solved = $solved['solved'];
2454 }
2455
2456 if ($solved === 1) {
2457 $navigation_gui->setQuestionMarkLinkTarget($this->ctrl->getLinkTarget($this, ilTestPlayerCommands::UNMARK_QUESTION_SAVE));
2458 $navigation_gui->setQuestionMarked(true);
2459 } else {
2460 $navigation_gui->setQuestionMarkLinkTarget($this->ctrl->getLinkTarget($this, ilTestPlayerCommands::MARK_QUESTION_SAVE));
2461 $navigation_gui->setQuestionMarked(false);
2462 }
2463 }
2464 return $navigation_gui;
2465 }
2466
2467 protected function getFinishTestCommand(): string
2468 {
2469 if (!$this->object->getListOfQuestionsEnd()) {
2471 }
2472
2474 }
2475
2476 protected function populateInstantResponseModal(assQuestionGUI $question_gui, $nav_url): void
2477 {
2478 $question_gui->setNavigationGUI(null);
2479 $question_gui->getQuestionHeaderBlockBuilder()->setQuestionAnswered(true);
2480
2481 $answer_feedback_enabled = $this->object->getSpecificAnswerFeedback();
2482
2483 $solutionoutput = $question_gui->getSolutionOutput(
2484 $this->test_session->getActiveId(), #active_id
2485 $this->test_session->getPass(), #pass
2486 false, #graphical_output
2487 false, #result_output
2488 true, #show_question_only
2489 $answer_feedback_enabled, #show_feedback
2490 false, #show_correct_solution
2491 false, #show_manual_scoring
2492 true #show_question_text
2493 );
2494
2495 $pageoutput = $question_gui->outQuestionPage(
2496 "",
2497 $this->isShowingPostponeStatusReguired($question_gui->getObject()->getId()),
2498 $this->test_session->getActiveId(),
2499 $solutionoutput
2500 );
2501
2502 $tpl = new ilTemplate('tpl.tst_player_response_modal.html', true, true, 'components/ILIAS/Test');
2503
2504 // populate the instant response blocks in the
2505 $saved_tpl = $this->tpl;
2506 $this->tpl = $tpl;
2507 $this->populateInstantResponseBlocks($question_gui, true);
2508 $this->tpl = $saved_tpl;
2509
2510 $tpl->setVariable('QUESTION_OUTPUT', $pageoutput);
2511 $this->tpl->setVariable('INSTANT_RESPONSE_MODAL', $this->getQuestionFeedbackModalHtml($tpl, $nav_url));
2512 }
2513
2514 private function getQuestionFeedbackModalHtml(ilTemplate $tpl, string $nav_url): string
2515 {
2516 $modal = $this->ui_factory->modal()->roundtrip(
2517 $this->lng->txt('tst_instant_feedback'),
2518 $this->ui_factory->legacy()->content($tpl->get()),
2519 []
2520 )->withActionButtons([
2521 $this->ui_factory->button()->standard($this->lng->txt('proceed'), $nav_url)
2522 ]);
2523
2524 return $this->ui_renderer->render([
2525 $modal->withOnLoad($modal->getShowSignal())
2526 ]);
2527 }
2528 // fau;
2529
2533 protected function populateInstantResponseBlocks(assQuestionGUI $question_gui, $authorizedSolution)
2534 {
2535 $response_available = false;
2536 $jump_to_response = false;
2537
2538 // This controls if the solution should be shown.
2539 // It gets the parameter "Scoring and Results" -> "Instant Feedback" -> "Show Solutions"
2540 if ($this->object->getInstantFeedbackSolution()) {
2541 $show_question_inline_score = $this->determineInlineScoreDisplay();
2542
2543 // Notation of the params prior to getting rid of this crap in favor of a class
2544 $solutionoutput = $question_gui->getSolutionOutput(
2545 $this->test_session->getActiveId(), #active_id
2546 $this->test_session->getPass(), #pass
2547 false, #graphical_output
2548 $show_question_inline_score, #result_output
2549 true, #show_question_only
2550 false, #show_feedback
2551 true, #show_correct_solution
2552 false, #show_manual_scoring
2553 false #show_question_text
2554 );
2555 $solutionoutput = str_replace('<h1 class="ilc_page_title_PageTitle"></h1>', '', $solutionoutput);
2556 $this->populateSolutionBlock($solutionoutput);
2557 $response_available = true;
2558 $jump_to_response = true;
2559 }
2560
2561 $reachedPoints = $question_gui->getObject()->getAdjustedReachedPoints(
2562 $this->test_session->getActiveId(),
2563 ilObjTest::_getPass($this->test_session->getActiveId()),
2564 $authorizedSolution
2565 );
2566
2567 $maxPoints = $question_gui->getObject()->getMaximumPoints();
2568
2569 $solutionCorrect = ($reachedPoints == $maxPoints);
2570
2571 // This controls if the score should be shown.
2572 // It gets the parameter "Scoring and Results" -> "Instant Feedback" -> "Show Results (Only Points)"
2573 if ($this->object->getAnswerFeedbackPoints()) {
2574 $this->populateScoreBlock($reachedPoints, $maxPoints);
2575 $response_available = true;
2576 $jump_to_response = true;
2577 }
2578
2579 // This controls if the generic feedback should be shown.
2580 // It gets the parameter "Scoring and Results" -> "Instant Feedback" -> "Show Solutions"
2581 if ($this->object->getGenericAnswerFeedback()) {
2582 if ($this->populateGenericFeedbackBlock($question_gui, $solutionCorrect)) {
2583 $response_available = true;
2584 $jump_to_response = true;
2585 }
2586 }
2587
2588 // This controls if the specific feedback should be shown.
2589 // It gets the parameter "Scoring and Results" -> "Instant Feedback" -> "Show Answer-Specific Feedback"
2590 if ($this->object->getSpecificAnswerFeedback()) {
2591 if ($question_gui->hasInlineFeedback()) {
2592 // Don't jump to the feedback below the question if some feedback is shown within the question
2593 $jump_to_response = false;
2594 } elseif ($this->populateSpecificFeedbackBlock($question_gui)) {
2595 $response_available = true;
2596 $jump_to_response = true;
2597 }
2598 }
2599
2600 $this->populateFeedbackBlockHeader($jump_to_response);
2601 if (!$response_available) {
2602 if ($question_gui->hasInlineFeedback()) {
2603 $this->populateFeedbackBlockMessage($this->lng->txt('tst_feedback_is_given_inline'));
2604 } else {
2605 $this->populateFeedbackBlockMessage($this->lng->txt('tst_feedback_not_available_for_answer'));
2606 }
2607 }
2608 }
2609
2610 protected function populateFeedbackBlockHeader($withFocusAnchor)
2611 {
2612 if ($withFocusAnchor) {
2613 $this->tpl->setCurrentBlock('inst_resp_id');
2614 $this->tpl->setVariable('INSTANT_RESPONSE_FOCUS_ID', 'focus');
2615 $this->tpl->parseCurrentBlock();
2616 }
2617
2618 $this->tpl->setCurrentBlock('instant_response_header');
2619 $this->tpl->setVariable('INSTANT_RESPONSE_HEADER', $this->lng->txt('tst_feedback'));
2620 $this->tpl->parseCurrentBlock();
2621 }
2622
2623 protected function populateFeedbackBlockMessage(string $a_message)
2624 {
2625 $this->tpl->setCurrentBlock('instant_response_message');
2626 $this->tpl->setVariable('INSTANT_RESPONSE_MESSAGE', $a_message);
2627 $this->tpl->parseCurrentBlock();
2628 }
2629
2630
2631 protected function getCurrentSequenceElement(): int
2632 {
2633 if ($this->getSequenceElementParameter()) {
2634 return $this->getSequenceElementParameter();
2635 }
2636
2637 return $this->test_session->getLastSequence();
2638 }
2639
2640 protected function getSequenceElementParameter(): ?int
2641 {
2642 if ($this->testrequest->isset('sequence')) {
2643 return $this->testrequest->int('sequence');
2644 }
2645
2646 return null;
2647 }
2648
2649 protected function getPresentationModeParameter()
2650 {
2651 if ($this->testrequest->isset('pmode')) {
2652 return $this->testrequest->raw('pmode');
2653 }
2654
2655 return null;
2656 }
2657
2658 protected function getInstantResponseParameter(): bool
2659 {
2660 return $this->testrequest->isInstanceResponseRequested();
2661 }
2662
2663 protected function getNextCommandParameter()
2664 {
2665 $nextcmd = '';
2666 if ($this->testrequest->isset('nextcmd')) {
2667 $nextcmd = $this->testrequest->strVal('nextcmd');
2668 }
2669
2670 return $nextcmd !== '' ? $nextcmd : null;
2671 }
2672
2673 protected function getNextSequenceParameter(): int
2674 {
2675 return $this->testrequest->int('nextseq');
2676 }
2677
2678 protected function getNavigationUrlParameter(): string
2679 {
2680 $navigation_url = $this->testrequest->strVal('test_player_navigation_url');
2681 if ($navigation_url !== '') {
2682 $navigation_url_parts = parse_url($navigation_url);
2683 $ilias_url_parts = parse_url(ilUtil::_getHttpPath());
2684
2685 if (!isset($navigation_url_parts['host']) || ($ilias_url_parts['host'] === $navigation_url_parts['host'])) {
2686 return $navigation_url;
2687 }
2688 }
2689 return '';
2690 }
2691
2692 protected function getAnswerChangedParameter(): bool
2693 {
2694 return !empty($this->testrequest->raw('test_answer_changed'));
2695 }
2696
2697 protected function setAnswerChangedParameter(bool $changed = true)
2698 {
2699 $this->ctrl->setParameter($this, 'test_answer_changed', $changed ? '1' : '0');
2700 }
2701
2702 protected function handleIntermediateSubmit()
2703 {
2704 if ($this->getAnswerChangedParameter()) {
2705 $this->saveQuestionSolution(false);
2706 } else {
2707 $this->removeIntermediateSolution();
2708 }
2709 $this->setAnswerChangedParameter($this->getAnswerChangedParameter());
2710 }
2711
2712 protected function saveNavigationPreventConfirmation(): void
2713 {
2714 if ($this->testrequest->retrieveBoolFromPost('save_on_navigation_prevent_confirmation')) {
2715 ilSession::set('save_on_navigation_prevent_confirmation', true);
2716 }
2717
2718 if ($this->testrequest->retrieveBoolFromPost(self::FOLLOWUP_QST_LOCKS_PREVENT_CONFIRMATION_PARAM)) {
2719 ilSession::set(self::FOLLOWUP_QST_LOCKS_PREVENT_CONFIRMATION_PARAM, true);
2720 }
2721 }
2722
2723 protected function getQuestionGuiInstance(int $question_id, bool $from_cache = true): object
2724 {
2725 $tpl = $this->tpl;
2726
2727 if (!$from_cache || !isset($this->cached_question_guis[$question_id])) {
2728 $question_gui = $this->object->createQuestionGUI("", $question_id);
2729 $question_gui->setTargetGui($this);
2731 $question = $question_gui->getObject();
2732 $question->setShuffler($this->shuffler->getAnswerShuffleFor(
2733 $question_id,
2734 $this->test_session->getActiveId(),
2735 $this->test_session->getPass()
2736 ));
2737 $question_gui->setObject($question);
2738 $question_gui->populateJavascriptFilesRequiredForWorkForm($tpl);
2739
2740 // hey: prevPassSolutions - determine solution pass index and configure gui accordingly
2741 $this->initTestQuestionConfig($question_gui->getObject());
2742 // hey.
2743
2744 $this->cached_question_guis[$question_id] = $question_gui;
2745 }
2746
2747 return $this->cached_question_guis[$question_id];
2748 }
2749
2750 protected function getQuestionInstance(int $question_id, bool $from_cache = true): assQuestion
2751 {
2752 if ($from_cache && isset($this->cached_question_objects[$question_id])) {
2753 return $this->cached_question_objects[$question_id];
2754 }
2755 $question = assQuestion::instantiateQuestion($question_id);
2756 $ass_settings = new ilSetting('assessment');
2757
2758 $process_locker_factory = new ilAssQuestionProcessLockerFactory($ass_settings, $this->db);
2759 $process_locker_factory->setQuestionId($question->getId());
2760 $process_locker_factory->setUserId($this->user->getId());
2761 $question->setProcessLocker($process_locker_factory->getLocker());
2762
2763 $this->initTestQuestionConfig($question);
2764
2765 $this->cached_question_objects[$question_id] = $question;
2766 return $question;
2767 }
2768
2769 protected function initTestQuestionConfig(assQuestion $question_obj)
2770 {
2771 $question_obj->getTestPresentationConfig()->setPreviousPassSolutionReuseAllowed(
2772 $this->object->isPreviousSolutionReuseEnabled($this->test_session->getActiveId())
2773 );
2774 }
2775
2776 protected function handleTearsAndAngerQuestionIsNull(int $question_id, $sequence_element): void
2777 {
2778 $this->logger->error(
2779 "INV SEQ:"
2780 . "active={$this->test_session->getActiveId()} "
2781 . "qId=$question_id seq=$sequence_element "
2782 . serialize($this->test_sequence)
2783 );
2784
2785 $this->ctrl->setParameter($this, 'sequence', $this->test_sequence->getFirstSequence());
2786 $this->ctrl->redirect($this, ilTestPlayerCommands::SHOW_QUESTION);
2787 }
2788
2789 protected function populateMessageContent(string $content_html): void
2790 {
2791 if ($this->object->getKioskMode()) {
2792 $this->tpl->addBlockfile($this->getContentBlockName(), 'content', "tpl.il_as_tst_kiosk_mode_content.html", "components/ILIAS/Test");
2793 $this->tpl->setContent($content_html);
2794 return;
2795 }
2796 $this->tpl->setVariable($this->getContentBlockName(), $content_html);
2797 }
2798
2802 protected function populateModals(): array
2803 {
2804 $signals = [self::DISCARD_MODAL => $this->populateDiscardSolutionModal()];
2805
2806 if ($this->object->isFollowupQuestionAnswerFixationEnabled()) {
2807 $signals[self::LOCKS_CHANGED_MODAL] = $this->populateNextLocksChangedModal();
2808 $signals[self::LOCKS_UNCHANGED_MODAL] = $this->populateNextLocksUnchangedModal();
2809 }
2810
2811 return $signals;
2812 }
2813
2815 {
2816 $modal = $this->ui_factory->modal()->interruptive(
2817 $this->lng->txt('discard_answer'),
2818 $this->lng->txt('discard_answer_confirmation'),
2819 $this->ctrl->getLinkTarget($this, ilTestPlayerCommands::DISCARD_SOLUTION)
2820 )->withActionButtonLabel($this->lng->txt('discard_answer'));
2821
2822 $this->tpl->setCurrentBlock('discard_solution_modal');
2823 $this->tpl->setVariable('DISCARD_SOLUTION_MODAL', $this->ui_renderer->render($modal));
2824 $this->tpl->parseCurrentBlock();
2825 return $modal->getShowSignal();
2826 }
2827
2829 {
2830 $modal = $this->ui_factory->modal()->interruptive(
2831 $this->lng->txt('tst_nav_next_locks_empty_answer_header'),
2832 $this->lng->txt('tst_nav_next_locks_empty_answer_confirm'),
2833 'javascript:il.TestPlayerQuestionEditControl.confirmNextLocksUnchanged()'
2834 )->withActionButtonLabel($this->lng->txt('tst_proceed'));
2835
2836 $this->tpl->setCurrentBlock('next_locks_unchanged_modal');
2837 $this->tpl->setVariable('NEXT_LOCKS_UNCHANGED_MODAL', $this->ui_renderer->render($modal));
2838 $this->tpl->parseCurrentBlock();
2839 return $modal->getShowSignal();
2840 }
2841
2843 {
2844 $empty_signal = new \ILIAS\UI\Implementation\Component\Signal('');
2845 if ($this->isFollowUpQuestionLocksConfirmationPrevented()) {
2846 return $empty_signal;
2847 }
2848
2849 $modal_message = $this->ui_factory->messageBox()->confirmation(
2850 $this->lng->txt('tst_nav_next_locks_current_answer_confirm')
2851 );
2852 $modal_checkbox = $this->ui_factory->input()->field()->checkbox(
2853 $this->lng->txt('tst_dont_show_msg_again_in_current_session')
2854 )->withDedicatedName(self::FOLLOWUP_QST_LOCKS_PREVENT_CONFIRMATION_PARAM);
2855
2856 $modal = $this->ui_factory->modal()->roundtrip(
2857 $this->lng->txt('tst_nav_next_locks_current_answer_header'),
2858 $modal_message,
2859 [ $modal_checkbox ],
2860 'javascript:il.TestPlayerQuestionEditControl.confirmNextLocksChanged()'
2861 )->withSubmitLabel($this->lng->txt('tst_proceed'));
2862
2863 $this->tpl->setCurrentBlock('next_locks_changed_modal');
2864 $this->tpl->setVariable('NEXT_LOCKS_CHANGED_MODAL', $this->ui_renderer->render($modal));
2865 $this->tpl->parseCurrentBlock();
2866 return $modal->getShowSignal();
2867 }
2868
2869 public const FOLLOWUP_QST_LOCKS_PREVENT_CONFIRMATION_PARAM = 'followup_qst_locks_prevent_confirmation';
2870
2872 {
2873 ilSession::set(self::FOLLOWUP_QST_LOCKS_PREVENT_CONFIRMATION_PARAM, true);
2874 }
2875
2877 {
2878 if (ilSession::get(self::FOLLOWUP_QST_LOCKS_PREVENT_CONFIRMATION_PARAM) == null) {
2879 return false;
2880 }
2881
2882 return ilSession::get(self::FOLLOWUP_QST_LOCKS_PREVENT_CONFIRMATION_PARAM);
2883 }
2884
2885 protected function populateQuestionEditControl(assQuestionGUI $question_gui): void
2886 {
2887 $config = [];
2888 $state = $question_gui->getObject()->lookupForExistingSolutions($this->test_session->getActiveId(), $this->test_session->getPass());
2889 $config['isAnswered'] = $state['authorized'];
2890 $config['isAnswerChanged'] = $state['intermediate'] || $this->getAnswerChangedParameter();
2891 $config['isAnswerFixed'] = $this->isParticipantsAnswerFixed($question_gui->getObject()->getId());
2892 $config['saveOnTimeReachedUrl'] = str_replace('&amp;', '&', $this->ctrl->getFormAction($this, ilTestPlayerCommands::AUTO_SAVE_ON_TIME_LIMIT));
2893
2894 $config['autosaveUrl'] = '';
2895 $config['autosaveInterval'] = 0;
2896 if ($question_gui->getObject() instanceof QuestionAutosaveable && $this->object->getAutosave()) {
2897 $config['autosaveUrl'] = $this->ctrl->getLinkTarget($this, ilTestPlayerCommands::AUTO_SAVE, '', true);
2898 $config['autosaveInterval'] = $this->object->getMainSettings()->getQuestionBehaviourSettings()->getAutosaveInterval();
2899 }
2900
2901 $question_config = $question_gui->getObject()->getTestPresentationConfig();
2902
2903 $config['withFormChangeDetection'] = $question_config->isFormChangeDetectionEnabled();
2904
2905 // Flash and Java questions: changes are directly sent to ilias and have to be polled from there
2906 $config['withBackgroundChangeDetection'] = $question_config->isBackgroundChangeDetectionEnabled();
2907 $config['backgroundDetectorUrl'] = $this->ctrl->getLinkTarget($this, ilTestPlayerCommands::DETECT_CHANGES, '', true);
2908
2909 // Forced feedback will change the navigation saving command
2910 $config['forcedInstantFeedback'] = $this->object->isForceInstantFeedbackEnabled();
2911 $config['questionLocked'] = $this->isParticipantsAnswerFixed($question_gui->getObject()->getId());
2912 $config['nextQuestionLocks'] = $this->object->isFollowupQuestionAnswerFixationEnabled();
2913 $config['autosaveFailureMessage'] = $this->lng->txt('autosave_failed');
2914
2915 // Add the modal signals and parameter name for the follow-up question locks confirmation
2916 $config['modalSignals'] = array_map(fn(Signal $signal) => $signal->getId(), $this->modal_signals);
2917 $config['preventConfirmationParam'] = self::FOLLOWUP_QST_LOCKS_PREVENT_CONFIRMATION_PARAM;
2918
2919 $this->tpl->addJavascript('assets/js/ilTestPlayerQuestionEditControl.js');
2920 $this->tpl->addOnLoadCode('il.TestPlayerQuestionEditControl.init(' . json_encode($config) . ')');
2921 }
2922 // fau.
2923
2924 protected function getQuestionsDefaultPresentationMode(): string
2925 {
2926 return self::PRESENTATION_MODE_EDIT;
2927 }
2928
2929 protected function registerForcedFeedbackNavUrl(string $forced_feedback_nav_url): void
2930 {
2931 if (ilSession::get('forced_feedback_navigation_url') == null) {
2932 ilSession::set('forced_feedback_navigation_url', []);
2933 }
2934 $forced_feeback_navigation_url = ilSession::get('forced_feedback_navigation_url');
2935 $forced_feeback_navigation_url[$this->test_session->getActiveId()] = $forced_feedback_nav_url;
2936 ilSession::set('forced_feedback_navigation_url', $forced_feeback_navigation_url);
2937 }
2938
2939 protected function getRegisteredForcedFeedbackNavUrl(): ?string
2940 {
2941 if (ilSession::get('forced_feedback_navigation_url') === null) {
2942 return null;
2943 }
2944 $forced_feedback_navigation_url = ilSession::get('forced_feedback_navigation_url');
2945 if (!isset($forced_feedback_navigation_url[$this->test_session->getActiveId()])) {
2946 return null;
2947 }
2948
2949 return $forced_feedback_navigation_url[$this->test_session->getActiveId()];
2950 }
2951
2952 protected function isForcedFeedbackNavUrlRegistered(): bool
2953 {
2954 return $this->getRegisteredForcedFeedbackNavUrl() !== null;
2955 }
2956
2957 protected function unregisterForcedFeedbackNavUrl(): void
2958 {
2959 $forced_feedback_navigation_url = ilSession::get('forced_feedback_navigation_url');
2960 if (isset($forced_feedback_navigation_url[$this->test_session->getActiveId()])) {
2961 unset($forced_feedback_navigation_url[$this->test_session->getActiveId()]);
2962 ilSession::set('forced_feedback_navigation_url', $forced_feedback_navigation_url);
2963 }
2964 }
2965
2966 protected function handleFileUploadCmd(): void
2967 {
2968 $this->updateWorkingTime();
2969 $this->saveQuestionSolution(false);
2970 $this->ctrl->redirect($this, ilTestPlayerCommands::SUBMIT_SOLUTION);
2971 }
2972
2973 protected function updateLearningProgressOnTestStart(): void
2974 {
2975 ilLPStatusWrapper::_updateStatus($this->object->getId(), $this->user->getId());
2976 }
2977
2978 private function isValidSequenceElement($sequence_element): bool
2979 {
2980 if ($sequence_element === false) {
2981 return false;
2982 }
2983
2984 if ($sequence_element < 1) {
2985 return false;
2986 }
2987
2988 if (!$this->test_sequence->getPositionOfSequence($sequence_element)) {
2989 return false;
2990 }
2991
2992 return true;
2993 }
2994
2995 protected function submitSolutionAndNextCmd(): void
2996 {
2997 if ($this->object->isForceInstantFeedbackEnabled()) {
2998 $this->submitSolutionCmd();
2999 return;
3000 }
3001
3002 if ($this->saveQuestionSolution(true, false)) {
3003 $this->test_sequence->getQuestionForSequence(
3004 $this->getCurrentSequenceElement()
3005 );
3006
3007 $this->removeIntermediateSolution();
3008
3009 $next_sequence_element = $this->test_sequence->getNextSequence($this->getCurrentSequenceElement());
3010
3011 if (!$this->isValidSequenceElement($next_sequence_element)) {
3012 $next_sequence_element = $this->test_sequence->getFirstSequence();
3013 }
3014
3015 $this->test_session->setLastSequence($next_sequence_element ?? 0);
3016 $this->test_session->saveToDb();
3017
3018 $this->ctrl->setParameter($this, 'sequence', $next_sequence_element);
3019 $this->ctrl->setParameter($this, 'pmode', '');
3020 }
3021
3022 $this->ctrl->redirect($this, ilTestPlayerCommands::SHOW_QUESTION);
3023 }
3024
3025 protected function handleQuestionPostponing(
3026 int $question_id
3027 ): void {
3028 $this->test_sequence->postponeQuestion($question_id);
3029 $this->test_sequence->saveToDb();
3030 }
3031
3032 protected function handleCheckTestPassValid(bool $with_redirect = false): void
3033 {
3034 $testObj = new ilObjTest($this->ref_id, true);
3035
3036 $participants = $testObj->getActiveParticipantList();
3037 $participant = $participants->getParticipantByActiveId($this->testrequest->getActiveId());
3038 if ($participant && $participant->hasUnfinishedPasses()) {
3039 return;
3040 }
3041 $this->tpl->setOnScreenMessage('failure', $this->lng->txt('tst_current_run_no_longer_valid'), true);
3042 if ($with_redirect) {
3043 $this->ctrl->redirectByClass([
3044 ilRepositoryGUI::class,
3045 ilObjTestGUI::class,
3046 TestScreenGUI::class
3047 ]);
3048 }
3049 }
3050
3052 {
3053 if ($this->test_session->getActiveId() > 0) {
3054 if ($this->test_sequence->hasRandomQuestionsForPass($this->test_session->getActiveId(), $this->test_session->getPass()) > 0) {
3055 $this->logger->info(
3056 __METHOD__ . ' Random Questions allready exists for user ' .
3057 $this->user->getId() . ' in test ' . $this->object->getTestId()
3058 );
3059
3060 return true;
3061 }
3062 } else {
3063 $this->logger->info(__METHOD__ . ' ' . sprintf(
3064 $this->lng->txt("error_random_question_generation"),
3065 $this->user->getId(),
3066 $this->object->getTestId()
3067 ));
3068
3069 return true;
3070 };
3071
3072 return false;
3073 }
3074
3075 protected function generateRandomTestPassForActiveUser(): void
3076 {
3077 $questionSetConfig = new ilTestRandomQuestionSetConfig(
3078 $this->tree,
3079 $this->db,
3080 $this->lng,
3081 $this->logger,
3082 $this->component_repository,
3083 $this->object,
3084 $this->questionrepository
3085 );
3086 $questionSetConfig->loadFromDb();
3087
3088 $sourcePoolDefinitionFactory = new ilTestRandomQuestionSetSourcePoolDefinitionFactory($this->db, $this->object);
3089
3090 $sourcePoolDefinitionList = new ilTestRandomQuestionSetSourcePoolDefinitionList($this->db, $this->object, $sourcePoolDefinitionFactory);
3091 $sourcePoolDefinitionList->loadDefinitions();
3092
3093 $this->process_locker->executeRandomPassBuildOperation(function () use ($questionSetConfig, $sourcePoolDefinitionList) {
3094 if (!$this->performTearsAndAngerBrokenConfessionChecks()) {
3095 $stagingPoolQuestionList = new ilTestRandomQuestionSetStagingPoolQuestionList($this->db, $this->component_repository);
3096
3097 $questionSetBuilder = ilTestRandomQuestionSetBuilder::getInstance(
3098 $this->db,
3099 $this->lng,
3100 $this->logger,
3101 $this->object,
3102 $questionSetConfig,
3103 $sourcePoolDefinitionList,
3104 $stagingPoolQuestionList
3105 );
3106
3107 $questionSetBuilder->performBuild($this->test_session);
3108 }
3109 }, $sourcePoolDefinitionList->hasTaxonomyFilters());
3110 }
3111
3112 protected function adoptUserSolutionsFromPreviousPass(): void
3113 {
3114 $ass_settings = new ilSetting('assessment');
3115
3116 $userSolutionAdopter = new ilAssQuestionUserSolutionAdopter($this->db, $ass_settings);
3117 $userSolutionAdopter->setUserId($this->user->getId());
3118 $userSolutionAdopter->setActiveId($this->test_session->getActiveId());
3119 $userSolutionAdopter->setTargetPass($this->test_sequence->getPass());
3120 $userSolutionAdopter->setQuestionIds($this->test_sequence->getOptionalQuestions());
3121
3122 $userSolutionAdopter->perform();
3123 }
3124
3126 {
3127 $this->tpl->setOnScreenMessage('failure', sprintf($this->lng->txt('tst_objective_oriented_test_pass_without_questions'), $this->object->getTitle()), true);
3128 $this->ctrl->redirectByClass(ilObjTestGUI::class);
3129 }
3130
3131 protected function handlePrimaryButton(ilTestNavigationToolbarGUI $navigation_toolbar_gui, int $current_question_id): bool
3132 {
3133 $is_next_primary = true;
3134
3135 if ($this->object->isForceInstantFeedbackEnabled()) {
3136 $is_next_primary = false;
3137 }
3138
3139 $questions_missing_result = $this->questionrepository->getQuestionsMissingResultRecord(
3140 $this->test_session->getActiveId(),
3141 $this->test_session->getPass(),
3142 $this->test_sequence->getOrderedSequenceQuestions()
3143 );
3144
3145 if ($questions_missing_result === []) {
3146 $navigation_toolbar_gui->setFinishTestButtonPrimary(true);
3147 return false;
3148 }
3149
3150 if (count($questions_missing_result) === 1
3151 && $current_question_id === current($questions_missing_result)) {
3152 $navigation_toolbar_gui->setFinishTestButtonPrimary(true);
3153 return false;
3154 }
3155
3156 return $is_next_primary;
3157 }
3158
3159 protected function getTestPlayerTitle(): string
3160 {
3161 $title_content = $this->ui_factory->listing()->property();
3162
3163 if ($this->object->getShowKioskModeParticipant()) {
3164 $pax_name_label = $this->lng->txt("conf_user_name");
3165 // this is a placeholder solution with inline html tags to differentiate the different elements
3166 // should be removed when a title component with grouping and visual weighting is available
3167 // see: https://github.com/ILIAS-eLearning/ILIAS/pull/7311
3168 $pax_name_value = "<span class='il-test-kiosk-head__participant-name'>"
3169 . $this->user->getFullname() . "</span>";
3170 $title_content = $title_content->withProperty($pax_name_label, $pax_name_value, false);
3171 }
3172
3173 if ($this->object->isShowExamIdInTestPassEnabled()) {
3174 $exam_id_label = $this->lng->txt("exam_id_label");
3175 $exam_id_value = ilObjTest::buildExamId(
3176 $this->test_session->getActiveId(),
3177 $this->test_session->getPass(),
3178 $this->object->getId()
3179 );
3180 $title_content = $title_content->withProperty($exam_id_label, $exam_id_value);
3181 }
3182
3183 if ($this->object->getShowKioskModeTitle()) {
3184 $test_title_label = $this->lng->txt("test");
3185 $test_title_value = $this->object->getTitle();
3186 $title_content = $title_content->withProperty($test_title_label, $test_title_value, false);
3187 }
3188
3189 return $this->ui_renderer->render($title_content);
3190 }
3191}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Builds data types.
Definition: Factory.php:36
const IL_CAL_UNIX
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
outQuestionForTest(string $formaction, int $active_id, ?int $pass, bool $is_question_postponed=false, array|bool $user_post_solutions=false, bool $show_specific_inline_feedback=false)
setPresentationContext(string $presentationContext)
setTargetGui($linkTargetGui)
setQuestionHeaderBlockBuilder(\ilQuestionHeaderBlockBuilder $questionHeaderBlockBuilder)
setObject(assQuestion $question)
outQuestionPage($a_temp_var, $a_postponed=false, $active_id="", $html="", $inlineFeedbackEnabled=false)
getGenericFeedbackOutput(int $active_id, ?int $pass)
getSpecificFeedbackOutput(array $userSolution)
Returns the answer specific feedback for the question.
populateJavascriptFilesRequiredForWorkForm(ilGlobalTemplateInterface $tpl)
setQuestionCount(int $a_question_count)
getSolutionOutput(int $active_id, ?int $pass=null, bool $graphical_output=false, bool $result_output=false, bool $show_question_only=true, bool $show_feedback=false, bool $show_correct_solution=false, bool $show_manual_scoring=false, bool $show_question_text=true, bool $show_inline_feedback=true)
setNavigationGUI(?ilTestQuestionNavigationGUI $navigationGUI)
answerToParticipantInteraction(AdditionalInformationGenerator $additional_info, int $test_ref_id, int $active_id, int $pass, string $source_ip, TestParticipantInteractionTypes $interaction_type)
persistWorkingState(int $active_id, $pass, bool $authorized=true)
persists the working state for current testactive and testpass
static instantiateQuestion(int $question_id)
Question page GUI class.
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ?ilObjUser $user=null,)
@classDescription Date and time handling
static getInstance(ilTestSession $a_test_session)
static _updateStatus(int $a_obj_id, int $a_usr_id, ?object $a_obj=null, bool $a_percentage=false, bool $a_force_raise=false)
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
static lookupExamId($active_id, $pass)
static _getPass($active_id)
Retrieves the actual pass of a given user for a given test.
static buildExamId($active_id, $pass, $test_obj_id=null)
static _getSolvedQuestions($active_id, $question_fi=null)
get solved questions
Class ilPageObjectGUI.
static get(string $a_var)
static clear(string $a_var)
static set(string $a_var, $a_val)
Set a value.
ILIAS Setting Class.
static logoutUrl(array $parameters=[])
Return the logout URL with a valid CSRF token.
Class ilTaggingGUI.
special template class to simplify handling of ITX/PEAR
get(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
Returns a block with all replacements done.
Base Exception for all Exceptions relating to Modules/Test.
setFinishTestButtonPrimary($finishTestButtonPrimary)
Class ilTestPassFinishTasks.
outQuestionSummaryCmd()
Output of a summary of all test questions for test participants.
redirectAfterAutosaveCmd()
Redirect the user after an automatic save when the time limit is reached.
getQuestionFeedbackModalHtml(ilTemplate $tpl, string $nav_url)
populateMessageContent(string $content_html)
saveTagsCmd()
Save tags for tagging gui.
ilTestQuestionRelatedObjectivesList $question_related_objectives_list
checkWorkingTimeCmd()
This is asynchronously called by tpl.workingtime.js to check for changes in the user's processing tim...
registerForcedFeedbackNavUrl(string $forced_feedback_nav_url)
initTestQuestionConfig(assQuestion $question_obj)
autosaveOnTimeLimitCmd()
Automatically save a user answer when the limited duration of a test run is reached (called by synchr...
populateInstantResponseModal(assQuestionGUI $question_gui, $nav_url)
startPlayerCmd()
Start a test for the first time.
showQuestionViewable(assQuestionGUI $question_gui, string $form_action, bool $is_question_worked_through, bool $instant_response)
prepareTestPage($presentationMode, $sequenceElement, $question_id)
handleCheckTestPassValid(bool $with_redirect=false)
max_processing_time_reached()
Outputs a message when the maximum processing time is reached.
populateQuestionNavigation($sequence_element, $primary_next)
outProcessingTime(int $active_id, bool $verbose)
handleTearsAndAngerQuestionIsNull(int $question_id, $sequence_element)
populateGenericFeedbackBlock(assQuestionGUI $question_gui, $solutionCorrect)
unmarkQuestionCmd()
Set a question unsolved.
initTestCmd()
Start a test for the first time after a redirect.
save(assQuestion $question_obj, bool $authorized)
endingTimeReached()
handle endingTimeReached
populateQuestionEditControl(assQuestionGUI $question_gui)
confirmSubmitAnswers()
confirm submit results if confirm then results are submitted and the screen will be redirected to the...
autosaveCmd()
Automatically save a user answer while working on the test (called repeatedly by asynchronous posts i...
showSideList($current_sequence_element)
populateScoreBlock($reachedPoints, $maxPoints)
updateWorkingTime()
updates working time and stores state saveresult to see if question has to be stored or not
getQuestionInstance(int $question_id, bool $from_cache=true)
handleUserSettings()
Handles some form parameters on starting and resuming a test.
checkTestSessionUser(ilTestSession $test_session)
saveQuestionSolution(bool $authorized=true, bool $force=false)
handleSkillTriggering(ilTestSession $test_session)
outCorrectSolution()
Creates an output of the solution of an answer compared to the correct solution.
detectChangesCmd()
Detect changes sent in the background to the server This is called by ajax from ilTestPlayerQuestionE...
markQuestionCmd()
Set a question solved.
populateTestNavigationToolbar(ilTestNavigationToolbarGUI $toolbar_gui)
isOptionalQuestionAnsweringConfirmationRequired(int $sequence_key)
ensureExistingTestSession(ilTestSession $test_session)
populateInstantResponseBlocks(assQuestionGUI $question_gui, $authorizedSolution)
populateSpecificFeedbackBlock(assQuestionGUI $question_gui)
getOnLoadCodeForNavigationButtons(string $target, string $cmd)
handlePrimaryButton(ilTestNavigationToolbarGUI $navigation_toolbar_gui, int $current_question_id)
determineSolutionPassIndex(assQuestionGUI $question_gui)
sendNewPassFinishedNotificationEmailIfActivated(int $active_id, int $pass)
setAnonymousIdCmd()
Sets a session variable with the test access code for an anonymous test user.
getQuestionGuiInstance(int $question_id, bool $from_cache=true)
isTestAccessible()
test accessible returns true if the user can perform the test
showQuestionEditable(assQuestionGUI $question_gui, string $form_action, bool $is_question_worked_through, bool $instant_response)
getContentBlockName()
Returns the name of the current content block (depends on the kiosk mode setting)
performTestPassFinishedTasks(StatusOfAttempt $status_of_attempt)
showListOfAnswers($active_id, $pass=null, $top_data="", $bottom_data="")
Creates an output of the list of answers for a test participant during the test (only the actual pass...
static getInstance(ilDBInterface $db, ilLanguage $lng, TestLogger $logger, ilObjTest $testOBJ, ilTestRandomQuestionSetConfig $questionSetConfig, ilTestRandomQuestionSetSourcePoolDefinitionList $sourcePoolDefinitionList, ilTestRandomQuestionSetStagingPoolQuestionList $stagingPoolQuestionList)
getSequenceByTestSession($testSession)
creates and returns an instance of a test sequence that corresponds to the current test mode and the ...
Test sequence handler.
Service GUI class for tests.
ilTestSequenceFactory $test_sequence_factory
readonly ilDBInterface $db
Test session handler.
setAnonymousId(string $anonymous_id)
setUserId(int $user_id)
Class ilTestSubmissionReviewGUI.
static getStyleSheetLocation(string $mode="output", string $a_css_name="")
get full style sheet file name (path inclusive) of current user
static _getHttpPath()
static redirect(string $a_script)
static initjQuery(?ilGlobalTemplateInterface $a_tpl=null)
inits and adds the jQuery JS-File to the global or a passed template
exit
getId()
Get the ID of this signal.
static http()
Fetches the global http state from ILIAS.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
form( $class_path, string $cmd, string $submit_caption="")
$_SERVER['HTTP_HOST']
Definition: raiseError.php:26
$url
Definition: shib_logout.php:68
$counter
$message
Definition: xapiexit.php:31