ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilTestSubmissionReviewGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
23 
33 {
35 
36  public function __construct(
37  protected ilTestOutputGUI $test_output_gui,
38  ilObjTest $testOBJ,
39  protected ilTestSession $testSession
40  ) {
41  parent::__construct($testOBJ);
42  }
43 
44  public function executeCommand(): string
45  {
46  if (!$this->object->getEnableExamview()) {
47  return '';
48  }
49 
50  switch ($this->ctrl->getNextClass($this)) {
51  default:
52  $this->dispatchCommand();
53  break;
54  }
55 
56  return '';
57  }
58 
59  protected function dispatchCommand()
60  {
61  switch ($this->ctrl->getCmd()) {
62  case 'show':
63  default:
64  $this->show();
65  }
66  }
67 
74  private function getContentBlockName(): string
75  {
76  if ($this->object->getKioskMode()) {
77  // See: https://mantis.ilias.de/view.php?id=27784
78  //$this->tpl->setBodyClass("kiosk");
79  $this->tpl->hideFooter();
80  return "CONTENT";
81  } else {
82  return "ADM_CONTENT";
83  }
84  }
85 
89  protected function buildToolbar($toolbarId): ilToolbarGUI
90  {
91  $toolbar = new ilToolbarGUI();
92  $toolbar->setId($toolbarId);
93 
94  $back_url = $this->ctrl->getLinkTarget(
95  $this->test_output_gui,
96  $this->object->getListOfQuestionsEnd() ?
98  );
99 
101  $this->ui_factory->button()->standard($this->lng->txt('tst_resume_test'), $back_url)
102  );
103 
104  if ($this->finish_test_modal === null) {
105  $class = get_class($this->test_output_gui);
106  $this->ctrl->setParameterByClass($class, 'reviewed', 1);
107  $this->finish_test_modal = $this->test_output_gui->buildFinishTestModal();
108  $this->ctrl->setParameterByClass($class, 'reviewed', 0);
109  }
110 
112  $this->ui_factory->button()->primary($this->lng->txt('finish_test'), $this->finish_test_modal->getShowSignal())
113  );
114 
115  return $toolbar;
116  }
117 
118  protected function buildUserReviewOutput(): string
119  {
120  $testResultHeaderLabelBuilder = new ilTestResultHeaderLabelBuilder($this->lng, $this->obj_cache);
121 
122  $objectivesList = null;
123 
124  if ($this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()) {
125  $testSequence = $this->testSequenceFactory->getSequenceByActiveIdAndPass($this->testSession->getActiveId(), $this->testSession->getPass());
126  $testSequence->loadFromDb();
127  $testSequence->loadQuestions();
128 
129  $objectivesAdapter = ilLOTestQuestionAdapter::getInstance($this->testSession);
130 
131  $objectivesList = $this->buildQuestionRelatedObjectivesList($objectivesAdapter, $testSequence);
132  $objectivesList->loadObjectivesTitles();
133 
134  $testResultHeaderLabelBuilder->setObjectiveOrientedContainerId($this->testSession->getObjectiveOrientedContainerId());
135  $testResultHeaderLabelBuilder->setUserId($this->testSession->getUserId());
136  $testResultHeaderLabelBuilder->setTestObjId($this->object->getId());
137  $testResultHeaderLabelBuilder->setTestRefId($this->object->getRefId());
138  $testResultHeaderLabelBuilder->initObjectiveOrientedMode();
139  }
140 
141  $results = $this->object->getTestResult(
142  $this->testSession->getActiveId(),
143  $this->testSession->getPass(),
144  false,
145  !$this->getObjectiveOrientedContainer()->isObjectiveOrientedPresentationRequired()
146  );
147 
148  $testevaluationgui = new ilTestEvaluationGUI($this->object);
149  $testevaluationgui->setContextResultPresentation(false);
150 
151  $results_output = $testevaluationgui->getPassListOfAnswers(
152  $results,
153  $this->testSession->getActiveId(),
154  $this->testSession->getPass(),
155  false,
156  false,
157  false,
158  false,
159  false,
160  $objectivesList,
161  $testResultHeaderLabelBuilder
162  );
163 
164  return $results_output;
165  }
166 
167  protected function show(): void
168  {
169  $this->global_screen->tool()->context()->current()->getAdditionalData()->replace(
171  $this->object->getTitle() . ' - ' . $this->lng->txt('tst_results_overview')
172  );
173 
174  $html = '';
175  if ($this->object->getEnableProcessingTime()) {
176  $active_id = $this->testSession->getActiveId();
177  $starting_time = $this->object->getStartingTimeOfUser($active_id);
178  $working_time = new WorkingTime(
179  $this->lng,
180  $this->ui_factory,
181  $this->ui_renderer,
182  $starting_time,
183  $this->object->getProcessingTimeInSeconds($active_id)
184  );
185 
186  $html .= $working_time->getMessageBox(true);
187 
188  $class = $this->getObject()->isFixedTest()
189  ? ilTestPlayerFixedQuestionSetGUI::class
190  : ilTestPlayerRandomQuestionSetGUI::class;
191 
192  $working_time_js_template = $working_time->prepareWorkingTimeJsTemplate(
193  $this->getObject(),
194  getdate($starting_time),
195  $this->ctrl->getLinkTargetByClass($class, 'checkWorkingTime', '', true),
196  $this->ctrl->getFormActionByClass($class, ilTestPlayerCommands::REDIRECT_AFTER_QUESTION_LIST)
197  );
198 
199  $this->tpl->addOnLoadCode($working_time_js_template->get());
200  }
201 
202  $html .= $this->buildToolbar('review_nav_top')->getHTML();
203  $html .= $this->buildUserReviewOutput() . '<br />';
204  $html .= $this->buildToolbar('review_nav_bottom')->getHTML();
205 
206  if ($this->object->isShowExamIdInTestPassEnabled() && !$this->object->getKioskMode()) {
207  $examIdTpl = new ilTemplate('tpl.exam_id_block.html', true, true, 'Modules/Test');
208  $examIdTpl->setVariable('EXAM_ID_VAL', ilObjTest::lookupExamId(
209  $this->testSession->getActiveId(),
210  $this->testSession->getPass(),
211  ));
212  $examIdTpl->setVariable('EXAM_ID_TXT', $this->lng->txt('exam_id'));
213  $html .= $examIdTpl->get();
214  }
215 
216  $html .= $this->ui_renderer->render($this->finish_test_modal);
217 
218  $this->tpl->setVariable($this->getContentBlockName(), $html);
219  }
220 }
Output class for assessment test execution.
addComponent(\ILIAS\UI\Component\Component $a_comp)
getContentBlockName()
Returns the name of the current content block (depends on the kiosk mode setting) ...
setId(string $a_val)
static getInstance(ilTestSession $a_test_session)
__construct(VocabulariesInterface $vocabularies)
__construct(protected ilTestOutputGUI $test_output_gui, ilObjTest $testOBJ, protected ilTestSession $testSession)
Class ilTestSubmissionReviewGUI.
Output class for assessment test evaluation.
$results
buildQuestionRelatedObjectivesList(ilLOTestQuestionAdapter $objectives_adapter, ilTestQuestionSequence $test_sequence)
Service GUI class for tests.
static lookupExamId($active_id, $pass)