|
|
|
@@ -32,13 +32,11 @@ $resolveImageUrl = static function ($path) {
|
|
|
|
|
article { break-inside: auto; border-color: #aaa !important; }
|
|
|
|
|
img { max-width: 100% !important; max-height: 150mm; object-fit: contain; }
|
|
|
|
|
.alert { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
|
|
|
|
|
.result-question-heading { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
|
|
|
|
|
.container-fluid .result-pdf-comment.has-print-comment { display: block !important; }
|
|
|
|
|
.result-pdf-comment-text { white-space: pre-wrap; }
|
|
|
|
|
.ai-token-info { display: none !important; }
|
|
|
|
|
.ai-feedback-screen.ai-feedback-print-source { display: block !important; }
|
|
|
|
|
.ai-feedback-screen.ai-feedback-print-source.print-ai-hidden { display: none !important; }
|
|
|
|
|
.ai-feedback-screen.ai-feedback-print-source > strong { display: none !important; }
|
|
|
|
|
.ai-feedback-screen.ai-feedback-print-source::before { content: "Komentarz:"; display: block; font-weight: bold; margin-bottom: .35em; }
|
|
|
|
|
.ai-feedback-screen { display: none !important; }
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
<script>
|
|
|
|
@@ -55,12 +53,12 @@ $resolveImageUrl = static function ($path) {
|
|
|
|
|
manualComment = '';
|
|
|
|
|
}
|
|
|
|
|
const output = commentBlock.querySelector('.result-pdf-comment-text');
|
|
|
|
|
const aiSource = document.querySelector('.ai-feedback-print-source[data-question-id="' + questionId + '"]');
|
|
|
|
|
const aiComment = commentBlock.dataset.aiComment || '';
|
|
|
|
|
const selectedComment = manualComment || aiComment;
|
|
|
|
|
|
|
|
|
|
commentBlock.classList.toggle('has-print-comment', Boolean(manualComment));
|
|
|
|
|
aiSource?.classList.toggle('print-ai-hidden', Boolean(manualComment));
|
|
|
|
|
if (output && manualComment) {
|
|
|
|
|
output.textContent = manualComment;
|
|
|
|
|
commentBlock.classList.toggle('has-print-comment', Boolean(selectedComment));
|
|
|
|
|
if (output && selectedComment) {
|
|
|
|
|
output.textContent = selectedComment;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@@ -125,8 +123,10 @@ $resolveImageUrl = static function ($path) {
|
|
|
|
|
</div>
|
|
|
|
|
<?php endif; ?>
|
|
|
|
|
<h2><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULT_ANSWERS'); ?></h2>
|
|
|
|
|
<?php $questionNumber = 0; ?>
|
|
|
|
|
<?php foreach ($this->item->answers as $questionId => $answer) : ?>
|
|
|
|
|
<?php $question = $this->item->questions[(int) $questionId] ?? null; if (!$question) continue; ?>
|
|
|
|
|
<?php $questionNumber++; ?>
|
|
|
|
|
<?php $hasResponse = trim((string) ($answer['selected'] ?? '')) !== ''; ?>
|
|
|
|
|
<?php
|
|
|
|
|
$answerStatusCorrect = !empty($answer['correct']);
|
|
|
|
@@ -141,9 +141,21 @@ $resolveImageUrl = static function ($path) {
|
|
|
|
|
if ($manualComment === '-' || $manualComment === '—') {
|
|
|
|
|
$manualComment = '';
|
|
|
|
|
}
|
|
|
|
|
$aiComment = trim((string) ($answer['ai_feedback'] ?? ''));
|
|
|
|
|
if ($aiComment === '' && (array_key_exists('ai_feedback', $answer) || !empty($answer['ai_usage']) || !empty($answer['ai_usage_history']))) {
|
|
|
|
|
$aiComment = \Joomla\CMS\Language\Text::sprintf(
|
|
|
|
|
'COM_TESTQUESTIONS_RESULT_AI_POINTS_COMMENT',
|
|
|
|
|
(int) ($answer['awarded_points'] ?? 0),
|
|
|
|
|
(int) ($question->points ?? 0)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
$printComment = $manualComment !== '' ? $manualComment : $aiComment;
|
|
|
|
|
?>
|
|
|
|
|
<article class="mb-4 border rounded p-3">
|
|
|
|
|
<div class="mb-2"><?php echo $question->question; ?></div>
|
|
|
|
|
<div class="result-question-heading d-flex align-items-start gap-2 mb-3 p-3 bg-light border-start border-4 border-primary rounded">
|
|
|
|
|
<span class="badge text-bg-primary flex-shrink-0"><?php echo $questionNumber; ?>.</span>
|
|
|
|
|
<div class="fw-semibold"><?php echo $question->question; ?></div>
|
|
|
|
|
</div>
|
|
|
|
|
<?php if (!empty($question->image)) : ?><div class="mb-3"><img src="<?php echo htmlspecialchars($resolveImageUrl($question->image), ENT_QUOTES, 'UTF-8'); ?>" alt="" loading="lazy" style="max-width: 100%; height: auto;"></div><?php endif; ?>
|
|
|
|
|
<?php if ($question->question_type === 'open') : ?>
|
|
|
|
|
<div><strong><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_YOUR_ANSWER'); ?>:</strong> <?php echo htmlspecialchars($answer['selected'] ?: '—', ENT_QUOTES, 'UTF-8'); ?></div>
|
|
|
|
@@ -153,9 +165,9 @@ $resolveImageUrl = static function ($path) {
|
|
|
|
|
<?php endif; ?>
|
|
|
|
|
<div class="mt-2 <?php echo $answerStatusCorrect ? 'text-success' : ($answerStatusPartial ? 'text-warning' : 'text-danger'); ?>"><?php echo $answerStatusCorrect ? '✓ ' . \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_ANSWER_CORRECT') : ($answerStatusPartial ? '◐ ' . \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_ANSWER_PARTIALLY_CORRECT') : '✗ ' . \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_ANSWER_INCORRECT')); ?></div>
|
|
|
|
|
<?php if ($question->question_type === 'open') : ?>
|
|
|
|
|
<div class="result-pdf-comment mt-3" data-question-id="<?php echo (int) $questionId; ?>">
|
|
|
|
|
<div class="result-pdf-comment mt-3<?php echo $printComment !== '' ? ' has-print-comment' : ''; ?>" data-question-id="<?php echo (int) $questionId; ?>" data-ai-comment="<?php echo htmlspecialchars($aiComment, ENT_QUOTES, 'UTF-8'); ?>">
|
|
|
|
|
<strong><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULT_COMMENT'); ?>:</strong><br>
|
|
|
|
|
<span class="result-pdf-comment-text"><?php echo htmlspecialchars($manualComment, ENT_QUOTES, 'UTF-8'); ?></span>
|
|
|
|
|
<span class="result-pdf-comment-text"><?php echo nl2br(htmlspecialchars($printComment, ENT_QUOTES, 'UTF-8')); ?></span>
|
|
|
|
|
</div>
|
|
|
|
|
<?php endif; ?>
|
|
|
|
|
<?php if ($question->question_type === 'open' && !empty($answer['ai_feedback'])) : ?>
|
|
|
|
@@ -164,7 +176,7 @@ $resolveImageUrl = static function ($path) {
|
|
|
|
|
$maxPoints = (int) ($question->points ?? 0);
|
|
|
|
|
$aiAlertClass = $aiPoints <= 0 ? 'alert-danger' : ($aiPoints >= $maxPoints ? 'alert-success' : 'alert-info');
|
|
|
|
|
?>
|
|
|
|
|
<div class="alert <?php echo $aiAlertClass; ?> mt-3 ai-feedback-screen ai-feedback-print-source" data-question-id="<?php echo (int) $questionId; ?>"><strong><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_AI_RESULT'); ?>:</strong><br><span class="ai-feedback-text"><?php echo nl2br(htmlspecialchars((string) $answer['ai_feedback'], ENT_QUOTES, 'UTF-8')); ?></span></div>
|
|
|
|
|
<div class="alert <?php echo $aiAlertClass; ?> mt-3 ai-feedback-screen" data-question-id="<?php echo (int) $questionId; ?>"><strong><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_AI_RESULT'); ?>:</strong><br><span class="ai-feedback-text"><?php echo nl2br(htmlspecialchars((string) $answer['ai_feedback'], ENT_QUOTES, 'UTF-8')); ?></span></div>
|
|
|
|
|
<?php endif; ?>
|
|
|
|
|
<?php if (empty($answer['correct'])) : ?>
|
|
|
|
|
<?php if ($question->question_type === 'open' && $hasResponse) : ?>
|
|
|
|
|