19declare(strict_types=1);
48 private readonly UIFactory $ui_factory,
50 private readonly RefineryFactory
$refinery,
55 private readonly TestResultRepository $test_result_repository,
57 $question_id = $this->testrequest->getQuestionId();
58 if ($question_id !== 0) {
61 $this->test_access =
new ilTestAccess($test_obj->getRefId());
66 if (!$this->test_obj->getGlobalSettings()->isAdjustingQuestionsWithResultsAllowed()
67 || !$this->test_access->checkCorrectionsAccess()
68 || $this->question_gui !==
null
69 && !$this->checkQuestion()) {
70 ilObjTestGUI::accessViolationRedirect();
73 if ($this->testrequest->isset(
'removeQid') && (
int) $this->testrequest->raw(
'removeQid')) {
74 $this->confirmQuestionRemoval();
78 $this->
ctrl->saveParameterByClass(self::class,
'q_id');
79 $command = $this->
ctrl->getCmd(
'showQuestionList');
90 $this->main_tpl->setContent($form->getHTML());
96 $form->setFormAction($this->
ctrl->getFormAction($this));
97 $form->setId(
'tst_question_correction');
99 $form->setTitle($this->
language->txt(
'tst_corrections_qst_form'));
107 $this->test_result_repository
111 if ($scoring->getNumManualScorings()) {
112 $form->addCommandButton(
'confirmManualScoringReset', $this->
language->txt(
'save'));
114 $form->addCommandButton(
'saveQuestion', $this->
language->txt(
'save'));
128 $this->test_result_repository
130 $scoring->setQuestionId($this->question_gui->getObject()->getId());
132 $confirmation = sprintf(
133 $this->
language->txt(
'tst_corrections_manscore_reset_warning'),
134 $scoring->getNumManualScorings(),
135 $this->question_gui->getObject()->getTitleForHTMLOutput(),
136 $this->question_gui->getObject()->getId()
140 $gui->setHeaderText($confirmation);
141 $gui->setFormAction($this->
ctrl->getFormAction($this));
142 $gui->setCancel($this->
language->txt(
'cancel'),
'showQuestion');
143 $gui->setConfirm($this->
language->txt(
'confirm'),
'saveQuestion');
147 $this->main_tpl->setContent($gui->getHTML());
154 $form->setValuesByPost();
156 if (!$form->checkInput()) {
173 $this->test_result_repository
175 $scoring->setPreserveManualScores(
false);
177 $scoring->recalculateSolutions();
179 if ($this->
logger->isLoggingEnabled()) {
180 $this->
logger->logQuestionAdministrationInteraction(
181 $question_gui->
getObject()->toQuestionAdministrationInteraction(
182 $this->logger->getAdditionalInformationGenerator(),
183 $this->test_obj->getRefId(),
189 $this->main_tpl->setOnScreenMessage(
'success', $this->
language->txt(
'saved_successfully'),
true);
190 $this->
ctrl->redirectByClass([ilObjTestGUI::class, self::class],
'showQuestion');
197 $page_gui->setFileDownloadLink(
198 $this->
ctrl->getLinkTargetByClass(ilObjTestGUI::class,
'downloadFile')
200 $page_gui->setRenderPageContainer(
false);
201 $page_gui->setEditPreview(
true);
202 $page_gui->setEnabledTabs(
false);
219 $tpl =
new ilTemplate(
'tpl.tst_corrections_solution_presentation.html',
true,
true,
'components/ILIAS/Test');
220 $tpl->setVariable(
'SOLUTION_PRESENTATION', $page_gui->preview());
225 $this->main_tpl->setContent($tpl->get());
227 $this->main_tpl->setCurrentBlock(
"ContentStyle");
228 $this->main_tpl->setVariable(
229 "LOCATION_CONTENT_STYLESHEET",
232 $this->main_tpl->parseCurrentBlock();
234 $this->main_tpl->setCurrentBlock(
"SyntaxStyle");
235 $this->main_tpl->setVariable(
236 "LOCATION_SYNTAX_STYLESHEET",
239 $this->main_tpl->parseCurrentBlock();
247 $solutions = $participant_results
249 : $this->
getSolutions($this->question_gui->getObject());
255 foreach ($this->question_gui->getSubQuestionsIndex() as $subQuestionIndex) {
256 $table = $this->question_gui->getAnswerFrequencyTableGUI(
258 'showAnswerStatistic',
263 $tablesHtml .= $table->getHTML() . $table->getAdditionalHtml();
267 $this->main_tpl->setContent($tablesHtml);
277 ))->buildAddAnswerModal(
'')
278 ->withRequest($this->testrequest->getRequest());
280 $data = $form->getData();
282 $question_index =
$data[
'question_index'];
283 $answer_value =
$data[
'answer_value'];
284 $points =
$data[
'points'];
287 $this->main_tpl->setOnScreenMessage(
'failure', $this->
language->txt(
'err_no_numeric_value'));
292 $question = $this->question_gui->getObject();
293 if ($question->isAddableAnswerOptionValue($question_index, $answer_value)) {
294 $question->addAnswerOptionValue($question_index, $answer_value, $points);
295 $question->saveToDb();
302 $this->test_result_repository
304 $scoring->setPreserveManualScores(
true);
305 $scoring->setQuestionId($question_index);
306 $participant_results = $scoring->recalculateSolutions();
308 if ($this->
logger->isLoggingEnabled()) {
309 $this->
logger->logQuestionAdministrationInteraction(
310 $question->toQuestionAdministrationInteraction(
311 $this->logger->getAdditionalInformationGenerator(),
312 $this->test_obj->getRefId(),
318 $this->main_tpl->setOnScreenMessage(
'success', $this->
language->txt(
'saved_successfully'));
324 foreach ($array as $name => $value) {
325 if ($name ==
'cmd' && !count($curPath)) {
329 if (count($curPath)) {
333 if (is_array($value)) {
334 $nextPath = array_merge($curPath, [$name]);
337 $postVar = implode(
'', $curPath) . $name;
345 $this->
tabs->clearTargets();
346 $this->
tabs->clearSubTabs();
348 $this->
help->setScreenIdComponent(
'tst');
349 $this->
help->setScreenId(
'scoringadjust');
350 $this->
help->setSubScreenId($active_tab_id);
355 $this->
language->txt(
'tst_corrections_tab_question'),
356 $this->ctrl->getLinkTargetByClass([ilObjTestGUI::class, self::class],
'showQuestion')
361 $this->
language->txt(
'tst_corrections_tab_solution'),
362 $this->ctrl->getLinkTargetByClass([ilObjTestGUI::class, self::class],
'showSolution')
368 $this->
language->txt(
'tst_corrections_tab_statistics'),
369 $this->ctrl->getLinkTargetByClass([ilObjTestGUI::class, self::class],
'showAnswerStatistic')
373 $this->
tabs->setBackTarget(
375 $this->ctrl->getLinkTargetByClass(ilObjTestGUI::class,
'showQuestions')
378 $this->
tabs->activateTab($active_tab_id);
389 if (!$this->test_obj->isTestQuestion($this->question_gui->getObject()->getId())) {
402 return $this->test_obj->getRefId();
407 $question_gui = assQuestion::instantiateQuestionGUI($question_id);
421 foreach (array_keys($this->test_obj->getParticipants()) as $active_id) {
423 $passes_selector->setActiveId($active_id);
424 $passes_selector->loadLastFinishedPass();
426 foreach ($passes_selector->getClosedPasses() as $pass) {
428 $solution_rows[] = $row;
433 return $solution_rows;
443 foreach ($participant_results as $active_id => $result) {
444 foreach ($result->getPasses() as $pass) {
457 if (!$this->test_obj->getGlobalSettings()->isAdjustingQuestionsWithResultsAllowed()) {
462 $this->test_obj->getTestQuestions(),
463 function (array
$c, array $v): array {
Builds a Color from either hex- or rgb values.
saveCorrectionsFormProperties(ilPropertyFormGUI $form)
populateCorrectionsFormProperties(ilPropertyFormGUI $form)
prepareReprintableCorrectionsForm(ilPropertyFormGUI $form)
setObject(assQuestion $question)
isAnswerFrequencyStatisticSupported()
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)
getSolutionValues(int $active_id, ?int $pass=null, bool $authorized=true)
Loads solutions of a given user from the database an returns it.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addHiddenItem(string $a_post_var, string $a_value)
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
static getSyntaxStylePath()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
special template class to simplify handling of ITX/PEAR
buildQuestionCorrectionForm(assQuestionGUI $question_gui)
getSolutionsByParticipantResults(assQuestion $question, array $participant_results)
getQuestionGUI(int $question_id)
supportsAdjustment(\assQuestionGUI $question_object)
Returns if the given question object support scoring adjustment.
confirmManualScoringReset()
addHiddenItemsFromArray(ilConfirmationGUI $gui, $array, $curPath=[])
getSolutions(assQuestion $question)
__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,)
populatePageTitleAndDescription(assQuestionGUI $question_gui)
showQuestion(?ilPropertyFormGUI $form=null)
showAnswerStatistic(?array $participant_results=null)
assQuestionGUI $question_gui
ilTestAccess $test_access
setCorrectionTabsContext(assQuestionGUI $question_gui, string $active_tab_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
TestQuestionAdministrationInteractionTypes
@ QUESTION_MODIFIED_IN_CORRECTIONS