Skip to content

Commit

Permalink
TA: QuestionList, discardSolution
Browse files Browse the repository at this point in the history
  • Loading branch information
nhaagen committed Oct 6, 2023
1 parent 87b2818 commit ba168f5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
25 changes: 22 additions & 3 deletions Modules/Test/classes/class.ilTestPlayerAbstractGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ protected function showQuestionEditable(assQuestionGUI $questionGui, $formAction
$questionNavigationGUI->setDiscardSolutionButtonEnabled(true);
// fau: testNav - set answere status in question header
$questionGui->getQuestionHeaderBlockBuilder()->setQuestionAnswered(true);
// fau.
// fau.
} elseif ($this->object->isPostponingEnabled()) {
$questionNavigationGUI->setSkipQuestionLinkTarget(
$this->ctrl->getLinkTarget($this, ilTestPlayerCommands::SKIP_QUESTION)
Expand Down Expand Up @@ -2263,12 +2263,31 @@ protected function populateDiscardSolutionModal()

$tpl->setVariable('CONFIRMATION_TEXT', $this->lng->txt('discard_answer_confirmation'));

$button = $this->ui_factory->button()->standard($this->lng->txt('discard_answer'), '#');
$button = $this->ui_factory->button()->standard($this->lng->txt('discard_answer'), '#')
->withAdditionalOnLoadCode(
fn($id) => "document.getElementById('$id').addEventListener(
'click',
(event)=>{
let i = document.createElement('input');
i.type = 'submit';
i.name='cmd[discardSolution]';
event.target.parentNode.appendChild(i);
i.click();
}
)"
);

$tpl->setCurrentBlock('buttons');
$tpl->setVariable('BUTTON', $this->ui_renderer->render($button));
$tpl->parseCurrentBlock();

$button = $this->ui_factory->button()->primary($this->lng->txt('cancel'), '#');
$button = $this->ui_factory->button()->primary($this->lng->txt('cancel'), '#')
->withAdditionalOnLoadCode(
fn($id) => "document.getElementById('$id').addEventListener(
'click',
()=>$('#tst_discard_solution_modal').modal('hide')
);"
);
$tpl->setCurrentBlock('buttons');
$tpl->setVariable('BUTTON', $this->ui_renderer->render($button));
$tpl->parseCurrentBlock();
Expand Down
15 changes: 11 additions & 4 deletions Modules/Test/classes/class.ilTestQuestionNavigationGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,14 @@ public function getActionsHTML(): string
$actions[] = $this->ui_factory->button()->shy(
$this->lng->txt('discard_answer'),
'#'
)->withUnavailableAction(!$this->isDiscardSolutionButtonEnabled());
)
->withUnavailableAction(!$this->isDiscardSolutionButtonEnabled())
->withAdditionalOnLoadCode(
fn($id) => "document.getElementById('$id').addEventListener(
'click',
()=>$('#tst_discard_solution_modal').modal('show')
)"
);

$list = $this->ui_factory->dropdown()->standard($actions)->withLabel($this->lng->txt("actions"));
$tpl->setVariable('ACTION_MENU', $this->ui_renderer->render($list));
Expand Down Expand Up @@ -579,7 +586,7 @@ private function parseButtonsBlock(ilTemplate $tpl)
private function renderButtonInstance(ilTemplate $tpl, Button $button)
{
$tpl->setCurrentBlock("button_instance");
$tpl->setVariable("BUTTON_INSTANCE", $this->ui->renderer()->render($button));
$tpl->setVariable("BUTTON_INSTANCE", $this->ui_renderer->render($button));
$tpl->parseCurrentBlock();

$this->parseButtonsBlock($tpl);
Expand All @@ -597,12 +604,12 @@ private function renderSubmitButton(ilTemplate $tpl, $command, $label, $primary
if ($primary) {
$this->renderButtonInstance(
$tpl,
$this->ui->factory()->button()->primary($label, $command)
$this->ui_factory->button()->primary($label, $command)
);
} else {
$this->renderButtonInstance(
$tpl,
$this->ui->factory()->button()->standard($label, $command)
$this->ui_factory->button()->standard($label, $command)
);
}
}
Expand Down

0 comments on commit ba168f5

Please sign in to comment.