|
|
@@ -46,13 +46,19 @@ $resolveImageUrl = static function ($path) {
|
|
|
|
window.addEventListener('beforeprint', function () {
|
|
|
|
window.addEventListener('beforeprint', function () {
|
|
|
|
document.querySelectorAll('.result-pdf-comment').forEach(function (commentBlock) {
|
|
|
|
document.querySelectorAll('.result-pdf-comment').forEach(function (commentBlock) {
|
|
|
|
const questionId = commentBlock.dataset.questionId;
|
|
|
|
const questionId = commentBlock.dataset.questionId;
|
|
|
|
const manualComment = document.getElementById('result-comment-' + questionId)?.value.trim() || '';
|
|
|
|
let manualComment = document.getElementById('result-comment-' + questionId)?.value.trim() || '';
|
|
|
|
|
|
|
|
if (manualComment === '-' || manualComment === '—') {
|
|
|
|
|
|
|
|
manualComment = '';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
const storedAiFeedback = commentBlock.querySelector('.result-pdf-ai-source')?.textContent.trim() || '';
|
|
|
|
const visibleAiFeedback = document.querySelector('.ai-feedback-screen[data-question-id="' + questionId + '"] .ai-feedback-text')?.textContent.trim() || '';
|
|
|
|
const visibleAiFeedback = document.querySelector('.ai-feedback-screen[data-question-id="' + questionId + '"] .ai-feedback-text')?.textContent.trim() || '';
|
|
|
|
const aiComment = visibleAiFeedback || commentBlock.dataset.aiComment || '';
|
|
|
|
const aiComment = storedAiFeedback || visibleAiFeedback;
|
|
|
|
const output = commentBlock.querySelector('.result-pdf-comment-text');
|
|
|
|
const output = commentBlock.querySelector('.result-pdf-comment-text');
|
|
|
|
|
|
|
|
const selectedComment = manualComment || aiComment;
|
|
|
|
|
|
|
|
|
|
|
|
if (output) {
|
|
|
|
// Keep the server-rendered AI fallback when no input/source is found in the DOM.
|
|
|
|
output.textContent = manualComment || aiComment || '—';
|
|
|
|
if (output && selectedComment) {
|
|
|
|
|
|
|
|
output.textContent = selectedComment;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
@@ -130,6 +136,9 @@ $resolveImageUrl = static function ($path) {
|
|
|
|
$answerStatusPartial = $awardedPoints > 0 && !$answerStatusCorrect;
|
|
|
|
$answerStatusPartial = $awardedPoints > 0 && !$answerStatusCorrect;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$manualComment = trim((string) ($answer['comment'] ?? ''));
|
|
|
|
$manualComment = trim((string) ($answer['comment'] ?? ''));
|
|
|
|
|
|
|
|
if ($manualComment === '-' || $manualComment === '—') {
|
|
|
|
|
|
|
|
$manualComment = '';
|
|
|
|
|
|
|
|
}
|
|
|
|
$aiComment = trim((string) ($answer['ai_feedback'] ?? ''));
|
|
|
|
$aiComment = trim((string) ($answer['ai_feedback'] ?? ''));
|
|
|
|
$printComment = $manualComment !== '' ? $manualComment : $aiComment;
|
|
|
|
$printComment = $manualComment !== '' ? $manualComment : $aiComment;
|
|
|
|
?>
|
|
|
|
?>
|
|
|
@@ -147,6 +156,7 @@ $resolveImageUrl = static function ($path) {
|
|
|
|
<div class="result-pdf-comment mt-3" data-question-id="<?php echo (int) $questionId; ?>" data-ai-comment="<?php echo htmlspecialchars($aiComment, ENT_QUOTES, 'UTF-8'); ?>">
|
|
|
|
<div class="result-pdf-comment mt-3" 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>
|
|
|
|
<strong><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULT_COMMENT'); ?>:</strong><br>
|
|
|
|
<span class="result-pdf-comment-text"><?php echo htmlspecialchars($printComment !== '' ? $printComment : '—', ENT_QUOTES, 'UTF-8'); ?></span>
|
|
|
|
<span class="result-pdf-comment-text"><?php echo htmlspecialchars($printComment !== '' ? $printComment : '—', ENT_QUOTES, 'UTF-8'); ?></span>
|
|
|
|
|
|
|
|
<span class="result-pdf-ai-source" hidden><?php echo htmlspecialchars($aiComment, ENT_QUOTES, 'UTF-8'); ?></span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php if (empty($answer['correct'])) : ?>
|
|
|
|
<?php if (empty($answer['correct'])) : ?>
|
|
|
@@ -177,7 +187,7 @@ $resolveImageUrl = static function ($path) {
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php if ($question->question_type === 'open' && $hasResponse) : ?>
|
|
|
|
<?php if ($question->question_type === 'open' && $hasResponse) : ?>
|
|
|
|
<div class="row mt-3">
|
|
|
|
<div class="row mt-3 no-print">
|
|
|
|
<div class="col-md-3">
|
|
|
|
<div class="col-md-3">
|
|
|
|
<label for="awarded-points-<?php echo (int) $questionId; ?>" class="form-label"><?php echo \Joomla\CMS\Language\Text::sprintf('COM_TESTQUESTIONS_RESULT_AWARDED_POINTS', (int) ($question->points ?? 0)); ?></label>
|
|
|
|
<label for="awarded-points-<?php echo (int) $questionId; ?>" class="form-label"><?php echo \Joomla\CMS\Language\Text::sprintf('COM_TESTQUESTIONS_RESULT_AWARDED_POINTS', (int) ($question->points ?? 0)); ?></label>
|
|
|
|
<input type="number" min="0" max="<?php echo (int) ($question->points ?? 0); ?>" name="awarded_points[<?php echo (int) $questionId; ?>]" id="awarded-points-<?php echo (int) $questionId; ?>" class="form-control" value="<?php echo (int) ($answer['awarded_points'] ?? 0); ?>">
|
|
|
|
<input type="number" min="0" max="<?php echo (int) ($question->points ?? 0); ?>" name="awarded_points[<?php echo (int) $questionId; ?>]" id="awarded-points-<?php echo (int) $questionId; ?>" class="form-control" value="<?php echo (int) ($answer['awarded_points'] ?? 0); ?>">
|
|
|
|