19 declare(strict_types=1);
66 if (!$this->testAccess->checkCorrectionsAccess()) {
67 ilObjTestGUI::accessViolationRedirect();
70 $this->testrequest->isset(
'eqid') && (
int) $this->testrequest->raw(
'eqid')
71 && $this->testrequest->isset(
'eqpl') && (
int) $this->testrequest->raw(
'eqpl')
73 $this->
ctrl->setParameter($this,
'qid', (
int) $this->testrequest->raw(
'eqid'));
74 $this->
ctrl->redirect($this,
'showQuestion');
76 if ($this->testrequest->isset(
'removeQid') && (
int) $this->testrequest->raw(
'removeQid')) {
77 $this->
ctrl->setParameter($this,
'qid', (
int) $this->testrequest->raw(
'removeQid'));
78 $this->
ctrl->redirect($this,
'confirmQuestionRemoval');
81 if ((
int) $this->testrequest->raw(
'qid')
82 && !$this->
checkQuestion((
int) $this->testrequest->raw(
'qid'))) {
83 ilObjTestGUI::accessViolationRedirect();
86 $this->
ctrl->saveParameter($this,
'qid');
88 switch ($this->
ctrl->getNextClass($this)) {
91 $command = $this->
ctrl->getCmd(
'showQuestionList');
100 if ($this->testOBJ->isFixedTest()) {
104 $this->testOBJ->getRefId(),
116 $rendered_gui_component = $table_gui->getHTML();
118 $lng = $this->language;
119 $txt =
$lng->txt(
'tst_corrections_incompatible_question_set_type');
121 $infoBox = $this->ui_factory->messageBox()->info(
$txt);
123 $rendered_gui_component = $this->ui_renderer->render($infoBox);
126 $this->main_tpl->setContent($rendered_gui_component);
131 $questionGUI = $this->
getQuestion((
int) $this->testrequest->raw(
'qid'));
138 $this->main_tpl->setContent($form->getHTML());
143 $questionGUI = $this->
getQuestion((
int) $this->testrequest->raw(
'qid'));
147 $form->setValuesByPost();
149 if (!$form->checkInput()) {
150 $questionGUI->prepareReprintableCorrectionsForm($form);
156 $questionGUI->saveCorrectionsFormProperties($form);
157 $questionGUI->object->setPoints($questionGUI->object->getMaximumPoints());
158 $questionGUI->object->saveToDb();
160 $scoring =
new ilTestScoring($this->testOBJ, $this->database);
161 $scoring->setPreserveManualScores(
false);
162 $scoring->setQuestionId($questionGUI->object->getId());
163 $scoring->recalculateSolutions();
165 $this->main_tpl->setOnScreenMessage(
'success', $this->
language->txt(
'saved_successfully'),
true);
166 $this->
ctrl->redirect($this,
'showQuestion');
172 $form->setFormAction($this->
ctrl->getFormAction($this));
173 $form->setId(
'tst_question_correction');
175 $form->setTitle($this->
language->txt(
'tst_corrections_qst_form'));
178 $hiddenQid->setValue((
string) $questionGUI->object->getId());
179 $form->addItem($hiddenQid);
183 $scoring =
new ilTestScoring($this->testOBJ, $this->database);
184 $scoring->setQuestionId($questionGUI->object->getId());
186 if ($scoring->getNumManualScorings()) {
187 $form->addCommandButton(
'confirmManualScoringReset', $this->
language->txt(
'save'));
189 $form->addCommandButton(
'saveQuestion', $this->
language->txt(
'save'));
197 foreach ($array as $name => $value) {
198 if ($name ==
'cmd' && !count($curPath)) {
202 if (count($curPath)) {
206 if (is_array($value)) {
207 $nextPath = array_merge($curPath, array($name));
210 $postVar = implode(
'', $curPath) . $name;
218 $questionGUI = $this->
getQuestion((
int) $this->testrequest->raw(
'qid'));
222 $scoring =
new ilTestScoring($this->testOBJ, $this->database);
223 $scoring->setQuestionId($questionGUI->object->getId());
225 $confirmation = sprintf(
226 $this->
language->txt(
'tst_corrections_manscore_reset_warning'),
227 $scoring->getNumManualScorings(),
228 $questionGUI->object->getTitleForHTMLOutput(),
229 $questionGUI->object->getId()
233 $gui->setHeaderText($confirmation);
234 $gui->setFormAction($this->
ctrl->getFormAction($this));
235 $gui->setCancel($this->
language->txt(
'cancel'),
'showQuestion');
236 $gui->setConfirm($this->
language->txt(
'confirm'),
'saveQuestion');
240 $this->main_tpl->setContent($gui->getHTML());
245 $questionGUI = $this->
getQuestion((
int) $this->testrequest->raw(
'qid'));
250 $pageGUI->setEditPreview(
true);
251 $pageGUI->setEnabledTabs(
false);
253 $solutionHTML = $questionGUI->getSolutionOutput(
265 $pageGUI->setQuestionHTML(array($questionGUI->object->getId() => $solutionHTML));
266 $pageGUI->setPresentationTitle($questionGUI->object->getTitleForHTMLOutput());
268 $tpl =
new ilTemplate(
'tpl.tst_corrections_solution_presentation.html',
true,
true,
'Modules/Test');
269 $tpl->setVariable(
'SOLUTION_PRESENTATION', $pageGUI->preview());
273 $this->main_tpl->setContent($tpl->get());
275 $this->main_tpl->setCurrentBlock(
"ContentStyle");
277 $this->main_tpl->setVariable(
"LOCATION_CONTENT_STYLESHEET", $stylesheet);
278 $this->main_tpl->parseCurrentBlock();
280 $this->main_tpl->setCurrentBlock(
"SyntaxStyle");
282 $this->main_tpl->setVariable(
"LOCATION_SYNTAX_STYLESHEET", $stylesheet);
283 $this->main_tpl->parseCurrentBlock();
292 $questionGUI = $this->
getQuestion((
int) $this->testrequest->raw(
'qid'));
293 $solutions = $participant_results
301 foreach ($questionGUI->getSubQuestionsIndex() as $subQuestionIndex) {
302 $table = $questionGUI->getAnswerFrequencyTableGUI(
304 'showAnswerStatistic',
309 $tablesHtml .= $table->getHTML() . $table->getAdditionalHtml();
313 $this->main_tpl->setContent($tablesHtml);
320 $form = $form_builder->buildAddAnswerForm()
321 ->withRequest($this->request);
323 $data = $form->getData();
324 $question_id =
$data[
'question_id'];
327 $this->main_tpl->setOnScreenMessage(
'failure', $this->
language->txt(
'form_input_not_valid'));
334 $question_index =
$data[
'question_index'];
335 $answer_value =
$data[
'answer_value'];
336 $points =
$data[
'points'];
339 $this->main_tpl->setOnScreenMessage(
'failure', $this->
language->txt(
'err_no_numeric_value'));
344 if ($question_gui->object->isAddableAnswerOptionValue($question_index, $answer_value)) {
345 $question_gui->object->addAnswerOptionValue($question_index, $answer_value, $points);
346 $question_gui->object->saveToDb();
349 $scoring =
new ilTestScoring($this->testOBJ, $this->database);
350 $scoring->setPreserveManualScores(
true);
351 $scoring->setQuestionId($question_id);
352 $results = $scoring->recalculateSolutions();
354 $this->main_tpl->setOnScreenMessage(
'success', $this->
language->txt(
'saved_successfully'));
362 $questionGUI = $this->
getQuestion((
int) $this->testrequest->raw(
'qid'));
364 $confirmation = sprintf(
365 $this->
language->txt(
'tst_corrections_qst_remove_confirmation'),
366 $questionGUI->object->getTitleForHTMLOutput(),
367 $questionGUI->object->getId()
371 $this->ui_factory->button()->standard(
373 $this->
ctrl->getLinkTarget($this,
'performQuestionRemoval')
375 $this->ui_factory->button()->standard(
377 $this->
ctrl->getLinkTarget($this,
'showQuestionList')
381 $this->main_tpl->setContent($this->ui_renderer->render(
382 $this->ui_factory->messageBox()->confirmation($confirmation)->withButtons($buttons)
388 $questionGUI = $this->
getQuestion((
int) $this->testrequest->raw(
'qid'));
389 $scoring =
new ilTestScoring($this->testOBJ, $this->database);
392 $participantData->load($this->testOBJ->getTestId());
395 $questionGUI->object->removeAllExistingSolutions();
398 $scoring->removeAllQuestionResults($questionGUI->object->getId());
401 $this->testOBJ->removeQuestion($questionGUI->object->getId());
402 $reindexedSequencePositionMap = $this->testOBJ->reindexFixedQuestionOrdering();
403 $this->testOBJ->loadQuestions();
406 $this->testOBJ->removeQuestionFromSequences(
407 $questionGUI->object->getId(),
408 $participantData->getActiveIds(),
409 $reindexedSequencePositionMap
413 $scoring->updatePassAndTestResults($participantData->getActiveIds());
419 $questionGUI->object->delete($questionGUI->object->getId());
422 if (!count($this->testOBJ->getTestQuestions())) {
423 $object_properties = $this->testOBJ->getObjectProperties();
424 $object_properties->storePropertyIsOnline(
425 $object_properties->getPropertyIsOnline()->withOffline()
429 $this->
ctrl->setParameter($this,
'qid',
'');
430 $this->
ctrl->redirect($this,
'showQuestionList');
435 $this->
tabs->clearTargets();
436 $this->
tabs->clearSubTabs();
438 $this->
help->setScreenIdComponent(
"tst");
439 $this->
help->setScreenId(
"scoringadjust");
440 $this->
help->setSubScreenId($activeTabId);
443 $this->
tabs->setBackTarget(
445 $this->
ctrl->getLinkTarget($this,
'showQuestionList')
450 $this->
language->txt(
'tst_corrections_tab_question'),
451 $this->
ctrl->getLinkTarget($this,
'showQuestion')
456 $this->
language->txt(
'tst_corrections_tab_solution'),
457 $this->
ctrl->getLinkTarget($this,
'showSolution')
463 $this->
language->txt(
'tst_corrections_tab_statistics'),
464 $this->
ctrl->getLinkTarget($this,
'showAnswerStatistic')
468 $this->
tabs->activateTab($activeTabId);
476 $this->main_tpl->setTitle($questionGUI->object->getTitleForHTMLOutput());
486 if (!$this->testOBJ->isTestQuestion($qId)) {
510 $question->object->setObjId($this->testOBJ->getId());
517 $solutionRows = array();
519 foreach ($this->testOBJ->getParticipants() as $activeId => $participantData) {
521 $passesSelector->setActiveId($activeId);
522 $passesSelector->loadLastFinishedPass();
524 foreach ($passesSelector->getClosedPasses() as $pass) {
526 $solutionRows[] = $row;
531 return $solutionRows;
541 foreach ($participant_results as $active_id => $result) {
542 foreach ($result->getPasses() as $pass) {
557 $questions = array();
559 foreach ($this->testOBJ->getTestQuestions() as $questionData) {
560 $questionGUI = $this->
getQuestion($questionData[
'question_id']);
570 $questions[] = $questionData;
600 foreach (explode(
',', (
new ilSetting(
'assessment'))->
get(
'assessment_scoring_adjustment',
'')) as $type) {
getSolutionValues($active_id, $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...
buildQuestionCorrectionForm(assQuestionGUI $questionGUI)
addHiddenItemsFromArray(ilConfirmationGUI $gui, $array, $curPath=array())
Abstract basic class which is to be extended by the concrete assessment question type classes...
static getQuestionTypeByTypeId($type_id)
getTestId()
Gets the database id of the additional test data.
showAnswerStatistic(?array $participant_results=null)
addHiddenItem(string $a_post_var, string $a_value)
setQuestionRemoveRowButtonEnabled(bool $questionRemoveRowButtonEnabled)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
isAnswerFrequencyStatisticSupported()
static instantiateQuestionGUI(int $a_question_id)
populateCorrectionsFormProperties(ilPropertyFormGUI $form)
setCorrectionTabsContext(assQuestionGUI $questionGUI, $activeTabId)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setRenderPageContainer(bool $a_val)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getSolutions(assQuestion $question)
static _refreshStatus(int $a_obj_id, ?array $a_users=null)
allowedInAdjustment(\assQuestionGUI $question_object)
Returns if the question type is allowed for adjustments in the global test administration.
static getSyntaxStylePath()
Basic GUI class for assessment questions.
confirmManualScoringReset()
static getContentStylePath(int $a_style_id, bool $add_random=true, bool $add_token=true)
get content style path static (to avoid full reading)
supportsAdjustment(\assQuestionGUI $question_object)
Returns if the given question object support scoring adjustment.
populatePageTitleAndDescription(assQuestionGUI $questionGUI)
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...
getSolutionsByParticipantResults(assQuestion $question, array $participant_results)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
showQuestion(ilPropertyFormGUI $form=null)
__construct(protected ilDBInterface $database, protected ilCtrl $ctrl, protected ilAccessHandler $access, protected ilLanguage $language, protected ilTabsGUI $tabs, protected ilHelpGUI $help, protected UIFactory $ui_factory, protected UIRenderer $ui_renderer, protected ilGlobalTemplateInterface $main_tpl, protected RefineryFactory $refinery, protected RequestInterface $request, private InternalRequestService $testrequest, protected ilObjTest $testOBJ, protected QuestionInfoService $questioninfo)
ilTestCorrectionsGUI constructor.
Refinery Factory $refinery