ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ilTestCorrectionsGUI Class Reference
+ Collaboration diagram for ilTestCorrectionsGUI:

Public Member Functions

 __construct (private readonly ilDBInterface $database, private readonly ilCtrlInterface $ctrl, private readonly ilLanguage $language, private readonly ilTabsGUI $tabs, private readonly ilHelpGUI $help, private readonly UIFactory $ui_factory, private readonly ilGlobalTemplateInterface $main_tpl, private readonly RefineryFactory $refinery, private readonly TestLogger $logger, private readonly RequestDataCollector $testrequest, private readonly ilObjTest $test_obj, private readonly ilObjUser $scorer, private readonly TestResultRepository $test_result_repository,)
 
 executeCommand ()
 
 getRefId ()
 

Protected Member Functions

 showQuestion (?ilPropertyFormGUI $form=null)
 
 buildQuestionCorrectionForm (assQuestionGUI $question_gui)
 
 confirmManualScoringReset ()
 
 saveQuestion ()
 
 showSolution ()
 
 showAnswerStatistic (?array $participant_results=null)
 
 addAnswer ()
 
 addHiddenItemsFromArray (ilConfirmationGUI $gui, $array, $curPath=[])
 
 setCorrectionTabsContext (assQuestionGUI $question_gui, string $active_tab_id)
 
 populatePageTitleAndDescription (assQuestionGUI $question_gui)
 
 checkQuestion ()
 
 getQuestionGUI (int $question_id)
 
 getSolutions (assQuestion $question)
 
 getQuestions ()
 

Private Member Functions

 getSolutionsByParticipantResults (assQuestion $question, array $participant_results)
 

Private Attributes

assQuestionGUI $question_gui = null
 
ilTestAccess $test_access
 

Detailed Description

Definition at line 37 of file class.ilTestCorrectionsGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilTestCorrectionsGUI::__construct ( private readonly ilDBInterface  $database,
private readonly ilCtrlInterface  $ctrl,
private readonly ilLanguage  $language,
private readonly ilTabsGUI  $tabs,
private readonly ilHelpGUI  $help,
private readonly UIFactory  $ui_factory,
private readonly ilGlobalTemplateInterface  $main_tpl,
private readonly RefineryFactory  $refinery,
private readonly TestLogger  $logger,
private readonly RequestDataCollector  $testrequest,
private readonly ilObjTest  $test_obj,
private readonly ilObjUser  $scorer,
private readonly TestResultRepository  $test_result_repository 
)

Definition at line 42 of file class.ilTestCorrectionsGUI.php.

56 {
57 $question_id = $this->testrequest->getQuestionId();
58 if ($question_id !== 0) {
59 $this->question_gui = $this->getQuestionGUI($question_id);
60 }
61 $this->test_access = new ilTestAccess($test_obj->getRefId());
62 }

References getQuestionGUI().

+ Here is the call graph for this function:

Member Function Documentation

◆ addAnswer()

ilTestCorrectionsGUI::addAnswer ( )
protected

Definition at line 272 of file class.ilTestCorrectionsGUI.php.

273 {
274 $form = (new ilAddAnswerFormBuilder(
275 $this->ui_factory,
276 $this->refinery,
277 $this->language,
278 $this->ctrl
279 ))->buildAddAnswerModal('')
280 ->withRequest($this->testrequest->getRequest());
281
282 $data = $form->getData();
283
284 $question_index = $data['question_index'];
285 $answer_value = $data['answer_value'];
286 $points = $data['points'];
287
288 if (!$points) {
289 $this->main_tpl->setOnScreenMessage('failure', $this->language->txt('err_no_numeric_value'));
290 $this->showAnswerStatistic();
291 return;
292 }
293
294 $question = $this->question_gui->getObject();
295 if ($question->isAddableAnswerOptionValue($question_index, $answer_value)) {
296 $question->addAnswerOptionValue($question_index, $answer_value, $points);
297 $question->saveToDb();
298 }
299
300 $participant_results = (new TestScoring(
301 $this->test_obj,
302 $this->scorer,
303 $this->database,
304 $this->test_result_repository
305 ))->recalculateSolutions(true, $question->getId());
306
307 if ($this->logger->isLoggingEnabled()) {
308 $this->logger->logQuestionAdministrationInteraction(
309 $question->toQuestionAdministrationInteraction(
310 $this->logger->getAdditionalInformationGenerator(),
311 $this->test_obj->getRefId(),
313 )
314 );
315 }
316
317 $this->main_tpl->setOnScreenMessage('success', $this->language->txt('saved_successfully'));
318 $this->showAnswerStatistic($participant_results);
319 }
showAnswerStatistic(?array $participant_results=null)
$data
Definition: storeScorm.php:45

References $data, ILIAS\Repository\ctrl(), ILIAS\Repository\database(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), ILIAS\Repository\logger(), ILIAS\Test\Logging\QUESTION_MODIFIED_IN_CORRECTIONS, ILIAS\Repository\refinery(), and showAnswerStatistic().

+ Here is the call graph for this function:

◆ addHiddenItemsFromArray()

ilTestCorrectionsGUI::addHiddenItemsFromArray ( ilConfirmationGUI  $gui,
  $array,
  $curPath = [] 
)
protected

Definition at line 321 of file class.ilTestCorrectionsGUI.php.

322 {
323 foreach ($array as $name => $value) {
324 if ($name == 'cmd' && !count($curPath)) {
325 continue;
326 }
327
328 if (count($curPath)) {
329 $name = "[{$name}]";
330 }
331
332 if (is_array($value)) {
333 $nextPath = array_merge($curPath, [$name]);
334 $this->addHiddenItemsFromArray($gui, $value, $nextPath);
335 } else {
336 $postVar = implode('', $curPath) . $name;
337 $gui->addHiddenItem($postVar, $value);
338 }
339 }
340 }
addHiddenItem(string $a_post_var, string $a_value)
addHiddenItemsFromArray(ilConfirmationGUI $gui, $array, $curPath=[])

References ilConfirmationGUI\addHiddenItem(), and addHiddenItemsFromArray().

Referenced by addHiddenItemsFromArray(), and confirmManualScoringReset().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildQuestionCorrectionForm()

ilTestCorrectionsGUI::buildQuestionCorrectionForm ( assQuestionGUI  $question_gui)
protected

Definition at line 93 of file class.ilTestCorrectionsGUI.php.

94 {
95 $form = new ilPropertyFormGUI();
96 $form->setFormAction($this->ctrl->getFormAction($this));
97 $form->setId('tst_question_correction');
98
99 $form->setTitle($this->language->txt('tst_corrections_qst_form'));
100
101 $question_gui->populateCorrectionsFormProperties($form);
102
103 $scoring = new TestScoring(
104 $this->test_obj,
105 $this->scorer,
106 $this->database,
107 $this->test_result_repository
108 );
109
110 if ($scoring->getNumManualScorings(
111 $question_gui->getObject()->getId()
112 )) {
113 $form->addCommandButton('confirmManualScoringReset', $this->language->txt('save'));
114 } else {
115 $form->addCommandButton('saveQuestion', $this->language->txt('save'));
116 }
117
118 return $form;
119 }
populateCorrectionsFormProperties(ilPropertyFormGUI $form)
This class represents a property form user interface.

References $question_gui, ILIAS\Repository\ctrl(), ILIAS\Repository\database(), assQuestionGUI\getObject(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), and assQuestionGUI\populateCorrectionsFormProperties().

Referenced by saveQuestion(), and showQuestion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkQuestion()

ilTestCorrectionsGUI::checkQuestion ( )
protected

Definition at line 386 of file class.ilTestCorrectionsGUI.php.

386 : bool
387 {
388 if (!$this->test_obj->isTestQuestion($this->question_gui->getObject()->getId())) {
389 return false;
390 }
391
392 if (!$this->question_gui?->supportsAdjustment()) {
393 return false;
394 }
395
396 return true;
397 }

◆ confirmManualScoringReset()

ilTestCorrectionsGUI::confirmManualScoringReset ( )
protected

Definition at line 121 of file class.ilTestCorrectionsGUI.php.

122 {
123 $this->setCorrectionTabsContext($this->question_gui, 'question');
124
125 $scoring = new TestScoring(
126 $this->test_obj,
127 $this->scorer,
128 $this->database,
129 $this->test_result_repository
130 );
131
132 $confirmation = sprintf(
133 $this->language->txt('tst_corrections_manscore_reset_warning'),
134 $scoring->getNumManualScorings(
135 $this->question_gui->getObject()->getId()
136 ),
137 $this->question_gui->getObject()->getTitleForHTMLOutput(),
138 $this->question_gui->getObject()->getId()
139 );
140
141 $gui = new ilConfirmationGUI();
142 $gui->setHeaderText($confirmation);
143 $gui->setFormAction($this->ctrl->getFormAction($this));
144 $gui->setCancel($this->language->txt('cancel'), 'showQuestion');
145 $gui->setConfirm($this->language->txt('confirm'), 'saveQuestion');
146
147 $this->addHiddenItemsFromArray($gui, $this->testrequest->getParsedBody());
148
149 $this->main_tpl->setContent($gui->getHTML());
150 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setCorrectionTabsContext(assQuestionGUI $question_gui, string $active_tab_id)

References addHiddenItemsFromArray(), ILIAS\Repository\ctrl(), ILIAS\Repository\database(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), and setCorrectionTabsContext().

+ Here is the call graph for this function:

◆ executeCommand()

ilTestCorrectionsGUI::executeCommand ( )

Definition at line 64 of file class.ilTestCorrectionsGUI.php.

65 {
66 if (!$this->test_obj->getGlobalSettings()->isAdjustingQuestionsWithResultsAllowed()
67 || !$this->test_access->checkCorrectionsAccess()
68 || $this->question_gui !== null
69 && !$this->checkQuestion()) {
70 ilObjTestGUI::accessViolationRedirect();
71 }
72
73 if ($this->testrequest->isset('removeQid') && (int) $this->testrequest->raw('removeQid')) {
74 $this->confirmQuestionRemoval();
75 return;
76 }
77
78 $this->ctrl->saveParameterByClass(self::class, 'q_id');
79 $command = $this->ctrl->getCmd('showQuestionList');
80 $this->{$command}();
81 }

References ILIAS\Repository\ctrl().

+ Here is the call graph for this function:

◆ getQuestionGUI()

ilTestCorrectionsGUI::getQuestionGUI ( int  $question_id)
protected

Definition at line 404 of file class.ilTestCorrectionsGUI.php.

405 {
406 $question_gui = assQuestion::instantiateQuestionGUI($question_id);
407 if ($question_gui === null) {
408 return null;
409 }
410 $question = $question_gui->getObject();
411 $question->setPoints($question_gui->getObject()->getMaximumPoints());
412 $question_gui->setObject($question);
413 return $question_gui;
414 }
setObject(assQuestion $question)

References $question_gui, assQuestionGUI\getObject(), and assQuestionGUI\setObject().

Referenced by __construct(), and getQuestions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getQuestions()

ilTestCorrectionsGUI::getQuestions ( )
protected

Definition at line 453 of file class.ilTestCorrectionsGUI.php.

453 : array
454 {
455
456 if (!$this->test_obj->getGlobalSettings()->isAdjustingQuestionsWithResultsAllowed()) {
457 return [];
458 }
459
460 return array_reduce(
461 $this->test_obj->getTestQuestions(),
462 function (array $c, array $v): array {
463 if (!$this->getQuestionGUI($v['question_id'])?->supportsAdjustment()) {
464 return $c;
465 }
466
467 $c[] = $v;
468 return $c;
469 },
470 []
471 );
472 }

References Vendor\Package\$c, and getQuestionGUI().

+ Here is the call graph for this function:

◆ getRefId()

ilTestCorrectionsGUI::getRefId ( )

Definition at line 399 of file class.ilTestCorrectionsGUI.php.

399 : int
400 {
401 return $this->test_obj->getRefId();
402 }

◆ getSolutions()

ilTestCorrectionsGUI::getSolutions ( assQuestion  $question)
protected

Definition at line 416 of file class.ilTestCorrectionsGUI.php.

416 : array
417 {
418 $solution_rows = [];
419
420 foreach (array_keys($this->test_obj->getParticipants()) as $active_id) {
421 $passes_selector = new ilTestPassesSelector($this->database, $this->test_obj);
422 $passes_selector->setActiveId($active_id);
423 $passes_selector->loadLastFinishedPass();
424
425 foreach ($passes_selector->getClosedPasses() as $pass) {
426 foreach ($question->getSolutionValues($active_id, $pass) as $row) {
427 $solution_rows[] = $row;
428 }
429 }
430 }
431
432 return $solution_rows;
433 }
getSolutionValues(int $active_id, ?int $pass=null, bool $authorized=true)
Loads solutions of a given user from the database an returns it.

References ILIAS\Repository\database(), and assQuestion\getSolutionValues().

Referenced by showAnswerStatistic().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSolutionsByParticipantResults()

ilTestCorrectionsGUI::getSolutionsByParticipantResults ( assQuestion  $question,
array  $participant_results 
)
private
Parameters
list<ilTestEvaluationUserData>$participant_results

Definition at line 438 of file class.ilTestCorrectionsGUI.php.

438 : array
439 {
440 $solutions = [];
441
442 foreach ($participant_results as $active_id => $result) {
443 foreach ($result->getPasses() as $pass) {
444 foreach ($question->getSolutionValues($active_id, $pass->getPass()) as $row) {
445 $solutions[] = $row;
446 }
447 }
448 }
449
450 return $solutions;
451 }

References assQuestion\getSolutionValues().

Referenced by showAnswerStatistic().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ populatePageTitleAndDescription()

ilTestCorrectionsGUI::populatePageTitleAndDescription ( assQuestionGUI  $question_gui)
protected

Definition at line 380 of file class.ilTestCorrectionsGUI.php.

380 : void
381 {
382 $this->main_tpl->setTitle($question_gui->getObject()->getTitleForHTMLOutput());
383 $this->main_tpl->setDescription($question_gui->outQuestionType());
384 }

References $question_gui, assQuestionGUI\getObject(), and assQuestionGUI\outQuestionType().

Referenced by showAnswerStatistic(), showQuestion(), and showSolution().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveQuestion()

ilTestCorrectionsGUI::saveQuestion ( )
protected

Definition at line 152 of file class.ilTestCorrectionsGUI.php.

153 {
156 $form->setValuesByPost();
157
158 if (!$form->checkInput()) {
160
161 $this->showQuestion($form);
162 return;
163 }
164
166 $question = $question_gui->getObject();
167 $question->setPoints($question_gui->getObject()->getMaximumPoints());
168 $question_gui->setObject($question);
169 $question_gui->getObject()->saveToDb();
170
171 (new TestScoring(
172 $this->test_obj,
173 $this->scorer,
174 $this->database,
175 $this->test_result_repository
176 ))->recalculateSolutions(
177 false,
178 $question_gui->getObject()->getId()
179 );
180
181 if ($this->logger->isLoggingEnabled()) {
182 $this->logger->logQuestionAdministrationInteraction(
183 $question_gui->getObject()->toQuestionAdministrationInteraction(
184 $this->logger->getAdditionalInformationGenerator(),
185 $this->test_obj->getRefId(),
187 )
188 );
189 }
190
191 $this->main_tpl->setOnScreenMessage('success', $this->language->txt('saved_successfully'), true);
192 $this->ctrl->redirectByClass([ilObjTestGUI::class, self::class], 'showQuestion');
193 }
saveCorrectionsFormProperties(ilPropertyFormGUI $form)
prepareReprintableCorrectionsForm(ilPropertyFormGUI $form)
buildQuestionCorrectionForm(assQuestionGUI $question_gui)
showQuestion(?ilPropertyFormGUI $form=null)

References $question_gui, buildQuestionCorrectionForm(), ILIAS\Repository\ctrl(), ILIAS\Repository\database(), assQuestionGUI\getObject(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), ILIAS\Repository\logger(), assQuestionGUI\prepareReprintableCorrectionsForm(), ILIAS\Test\Logging\QUESTION_MODIFIED_IN_CORRECTIONS, assQuestionGUI\saveCorrectionsFormProperties(), assQuestionGUI\setObject(), and showQuestion().

+ Here is the call graph for this function:

◆ setCorrectionTabsContext()

ilTestCorrectionsGUI::setCorrectionTabsContext ( assQuestionGUI  $question_gui,
string  $active_tab_id 
)
protected

Definition at line 342 of file class.ilTestCorrectionsGUI.php.

342 : void
343 {
344 $this->tabs->clearTargets();
345 $this->tabs->clearSubTabs();
346
347 $this->help->setScreenIdComponent('tst');
348 $this->help->setScreenId('scoringadjust');
349 $this->help->setSubScreenId($active_tab_id);
350
351 $this->ctrl->setParameterByClass(self::class, 'q_id', $question_gui->getObject()->getId());
352 $this->tabs->addTab(
353 'question',
354 $this->language->txt('tst_corrections_tab_question'),
355 $this->ctrl->getLinkTargetByClass([ilObjTestGUI::class, self::class], 'showQuestion')
356 );
357
358 $this->tabs->addTab(
359 'solution',
360 $this->language->txt('tst_corrections_tab_solution'),
361 $this->ctrl->getLinkTargetByClass([ilObjTestGUI::class, self::class], 'showSolution')
362 );
363
365 $this->tabs->addTab(
366 'answers',
367 $this->language->txt('tst_corrections_tab_statistics'),
368 $this->ctrl->getLinkTargetByClass([ilObjTestGUI::class, self::class], 'showAnswerStatistic')
369 );
370 }
371
372 $this->tabs->setBackTarget(
373 $this->language->txt('back'),
374 $this->ctrl->getLinkTargetByClass(ilObjTestGUI::class, 'showQuestions')
375 );
376
377 $this->tabs->activateTab($active_tab_id);
378 }

References $question_gui, ILIAS\Repository\ctrl(), assQuestionGUI\getObject(), ILIAS\Repository\help(), assQuestionGUI\isAnswerFrequencyStatisticSupported(), ILIAS\UI\examples\Symbol\Glyph\Language\language(), and ILIAS\Repository\tabs().

Referenced by confirmManualScoringReset(), showAnswerStatistic(), showQuestion(), and showSolution().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showAnswerStatistic()

ilTestCorrectionsGUI::showAnswerStatistic ( ?array  $participant_results = null)
protected
Parameters
null|list<ilTestEvaluationUserData>$participant_results

Definition at line 247 of file class.ilTestCorrectionsGUI.php.

247 : void
248 {
249 $solutions = $participant_results
250 ? $this->getSolutionsByParticipantResults($this->question_gui->getObject(), $participant_results)
251 : $this->getSolutions($this->question_gui->getObject());
252
253 $this->setCorrectionTabsContext($this->question_gui, 'answers');
254
255 $tablesHtml = '';
256
257 foreach ($this->question_gui->getSubQuestionsIndex() as $subQuestionIndex) {
258 $table = $this->question_gui->getAnswerFrequencyTableGUI(
259 $this,
260 'showAnswerStatistic',
261 $solutions,
262 $subQuestionIndex
263 );
264
265 $tablesHtml .= $table->getHTML() . $table->getAdditionalHtml();
266 }
267
268 $this->populatePageTitleAndDescription($this->question_gui);
269 $this->main_tpl->setContent($tablesHtml);
270 }
getSolutionsByParticipantResults(assQuestion $question, array $participant_results)
getSolutions(assQuestion $question)
populatePageTitleAndDescription(assQuestionGUI $question_gui)

References getSolutions(), getSolutionsByParticipantResults(), populatePageTitleAndDescription(), and setCorrectionTabsContext().

Referenced by addAnswer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showQuestion()

ilTestCorrectionsGUI::showQuestion ( ?ilPropertyFormGUI  $form = null)
protected

Definition at line 83 of file class.ilTestCorrectionsGUI.php.

84 {
85 $this->setCorrectionTabsContext($this->question_gui, 'question');
86
87 $form ??= $this->buildQuestionCorrectionForm($this->question_gui);
88
89 $this->populatePageTitleAndDescription($this->question_gui);
90 $this->main_tpl->setContent($form->getHTML());
91 }

References buildQuestionCorrectionForm(), populatePageTitleAndDescription(), and setCorrectionTabsContext().

Referenced by saveQuestion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showSolution()

ilTestCorrectionsGUI::showSolution ( )
protected

Definition at line 195 of file class.ilTestCorrectionsGUI.php.

196 {
198 $page_gui = new ilAssQuestionPageGUI($question_gui->getObject()->getId());
199 $page_gui->setFileDownloadLink(
200 $this->ctrl->getLinkTargetByClass(ilObjTestGUI::class, 'downloadFile')
201 );
202 $page_gui->setRenderPageContainer(false);
203 $page_gui->setEditPreview(true);
204 $page_gui->setEnabledTabs(false);
205
206 $solution_html = $question_gui->getSolutionOutput(
207 0,
208 null,
209 false,
210 false,
211 true,
212 false,
213 true,
214 false,
215 true
216 );
217
218 $page_gui->setQuestionHTML([$question_gui->getObject()->getId() => $solution_html]);
219 $page_gui->setPresentationTitle($question_gui->getObject()->getTitle());
220
221 $tpl = new ilTemplate('tpl.tst_corrections_solution_presentation.html', true, true, 'components/ILIAS/Test');
222 $tpl->setVariable('SOLUTION_PRESENTATION', $page_gui->preview());
223
224 $this->setCorrectionTabsContext($question_gui, 'solution');
226
227 $this->main_tpl->setContent($tpl->get());
228
229 $this->main_tpl->setCurrentBlock("ContentStyle");
230 $this->main_tpl->setVariable(
231 "LOCATION_CONTENT_STYLESHEET",
233 );
234 $this->main_tpl->parseCurrentBlock();
235
236 $this->main_tpl->setCurrentBlock("SyntaxStyle");
237 $this->main_tpl->setVariable(
238 "LOCATION_SYNTAX_STYLESHEET",
240 );
241 $this->main_tpl->parseCurrentBlock();
242 }
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)
Question page GUI class.
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
special template class to simplify handling of ITX/PEAR
setVariable(string $variable, $value='')
Sets the given variable to the given value.
get(string $part=self::DEFAULT_BLOCK)
Renders the given block and returns the html string.
readonly ilGlobalTemplateInterface $tpl

References $question_gui, ILIAS\News\Common\Table\$tpl, ILIAS\Repository\ctrl(), ILIAS\UICore\GlobalTemplate\get(), ilObjStyleSheet\getContentStylePath(), assQuestionGUI\getObject(), assQuestionGUI\getSolutionOutput(), ilObjStyleSheet\getSyntaxStylePath(), populatePageTitleAndDescription(), setCorrectionTabsContext(), and ILIAS\UICore\GlobalTemplate\setVariable().

+ Here is the call graph for this function:

Field Documentation

◆ $question_gui

◆ $test_access

ilTestAccess ilTestCorrectionsGUI::$test_access
private

Definition at line 40 of file class.ilTestCorrectionsGUI.php.


The documentation for this class was generated from the following file: