Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -513,9 +513,7 @@ public function getAnswersFrequency($relevant_answers, $question_index): array
$error_text_hashed = md5($error_text);

if (!isset($answers[$error_text_hashed])) {
$answers[$error_text_hashed] = [
'answer' => $error_text, 'frequency' => 0
];
$answers[$error_text_hashed] = ['answer' => $error_text, 'frequency' => 0, 'sanitized' => true];
}

$answers[$error_text_hashed]['frequency']++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -860,15 +860,14 @@ private function aggregateAnswers($rawSolutionData, $answers): array

public function getAnswersFrequency($relevantAnswers, $questionIndex): array
{
$agg = $this->aggregateAnswers($relevantAnswers, $this->object->getAnswers());

$answers = [];

foreach ($agg as $ans) {
foreach ($this->aggregateAnswers($relevantAnswers, $this->object->getAnswers()) as $ans) {
$answers[] = [
'answer' => $ans['answertext'],
'frequency_true' => $ans['count_true'],
'frequency_false' => $ans['count_false']
'frequency_false' => $ans['count_false'],
'sanitized' => true
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -988,15 +988,10 @@ protected function buildEditForm(bool $is_singleline = true): ilPropertyFormGUI

public function getAnswersFrequency($relevantAnswers, $questionIndex): array
{
$agg = $this->aggregateAnswers($relevantAnswers, $this->object->getAnswers());

$answers = [];

foreach ($agg as $ans) {
$answers[] = [
'answer' => $ans['answertext'],
'frequency' => $ans['count_checked']
];
foreach ($this->aggregateAnswers($relevantAnswers, $this->object->getAnswers()) as $ans) {
$answers[] = ['answer' => $ans['answertext'], 'frequency' => $ans['count_checked'], 'sanitized' => true];
}

return $answers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,7 @@ public function getAnswersFrequency($relevantAnswers, $questionIndex): array
$ans['value1']
);

$answers[$md5] = [
'answer' => $answer, 'frequency' => 0
];
$answers[$md5] = ['answer' => $answer, 'frequency' => 0, 'sanitized' => true];
}

$answers[$md5]['frequency']++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -666,37 +666,16 @@ protected function getAnswerStatisticOrderingElementHtml(ilAssOrderingElement $e

protected function getAnswerStatisticOrderingVariantHtml(ilAssOrderingElementList $list): string
{
$html = '<ul>';

$lastIndent = 0;
$firstElem = true;

foreach ($list as $elem) {
if ($elem->getIndentation() > $lastIndent) {
$html .= '<ul><li>';
} elseif ($elem->getIndentation() < $lastIndent) {
$html .= '</li></ul><li>';
} elseif (!$firstElem) {
$html .= '</li><li>';
} else {
$html .= '<li>';
}

$html .= $this->getAnswerStatisticOrderingElementHtml($elem);

$firstElem = false;
$lastIndent = $elem->getIndentation();
}

$html .= '</li>';

for ($i = $lastIndent; $i > 0; $i--) {
$html .= '</ul></li>';
}

$html .= '</ul>';
$list = array_map(
fn(ilAssOrderingElement $elem): string => htmlspecialchars(
$this->getAnswerStatisticOrderingElementHtml($elem) ?? '',
ENT_QUOTES | ENT_SUBSTITUTE,
'utf-8'
),
$list->getElements()
);

return $html;
return $this->ui->renderer()->render($this->ui->factory()->listing()->unordered($list));
}

public function getAnswersFrequency($relevantAnswers, $questionIndex): array
Expand Down Expand Up @@ -730,9 +709,7 @@ public function getAnswersFrequency($relevantAnswers, $questionIndex): array
$orderingElementList
);

$answers[$hash] = [
'answer' => $variantHtml, 'frequency' => 0
];
$answers[$hash] = ['answer' => $variantHtml, 'frequency' => 0, 'sanitized' => true];
}

$answers[$hash]['frequency']++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

declare(strict_types=1);

use ILIAS\DI\UIServices;
use ILIAS\TestQuestionPool\QuestionPoolDIC;
use ILIAS\TestQuestionPool\RequestDataCollector;
use ILIAS\TestQuestionPool\ilTestLegacyFormsHelper;
Expand Down Expand Up @@ -98,7 +99,7 @@ abstract class assQuestionGUI
'uploaddefintions'
];

private $ui;
protected UIServices $ui;
private ilObjectDataCache $ilObjDataCache;
private ilHelpGUI $ilHelp;
private ilAccessHandler $access;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -816,15 +816,10 @@ private function populateInlineFeedback($template, $answer_id, $user_solution):

public function getAnswersFrequency($relevantAnswers, $questionIndex): array
{
$agg = $this->aggregateAnswers($relevantAnswers, $this->object->getAnswers());

$answers = [];

foreach ($agg as $ans) {
$answers[] = [
'answer' => $ans['answertext'],
'frequency' => $ans['count_checked']
];
foreach ($this->aggregateAnswers($relevantAnswers, $this->object->getAnswers()) as $ans) {
$answers[] = ['answer' => $ans['answertext'], 'frequency' => $ans['count_checked'], 'sanitized' => true];
}

return $answers;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ public function initColumns(): void

public function fillRow(array $a_set): void
{
$a_set['answer'] = ilLegacyFormElementsUtil::prepareFormOutput((string) $a_set['answer']);
if (!isset($a_set['sanitized']) || !$a_set['sanitized']) {
$a_set['answer'] = ilLegacyFormElementsUtil::prepareFormOutput((string) $a_set['answer']);
}

$this->tpl->setCurrentBlock('answer');
$this->tpl->setVariable('ANSWER', $a_set['answer']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,12 @@ public function initColumns(): void

public function fillRow(array $a_set): void
{
if (!isset($a_set['sanitized']) || !$a_set['sanitized']) {
$a_set['answer'] = htmlspecialchars($a_set['answer'], ENT_QUOTES | ENT_SUBSTITUTE, 'utf-8');
}

$this->tpl->setCurrentBlock('answer');
$this->tpl->setVariable('ANSWER', ilLegacyFormElementsUtil::prepareFormOutput($a_set['answer']));
$this->tpl->setVariable('ANSWER', $a_set['answer']);
$this->tpl->parseCurrentBlock();

$this->tpl->setCurrentBlock('frequency');
Expand Down