|
|
@@ -47,11 +47,15 @@ $resolveImageUrl = static function ($path) {
|
|
|
|
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() || '';
|
|
|
|
const manualComment = document.getElementById('result-comment-' + questionId)?.value.trim() || '';
|
|
|
|
const aiComment = commentBlock.dataset.aiComment || '';
|
|
|
|
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 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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
@@ -146,6 +150,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'])) : ?>
|
|
|
@@ -172,11 +177,11 @@ $resolveImageUrl = static function ($path) {
|
|
|
|
$maxPoints = (int) ($question->points ?? 0);
|
|
|
|
$maxPoints = (int) ($question->points ?? 0);
|
|
|
|
$aiAlertClass = $aiPoints <= 0 ? 'alert-danger' : ($aiPoints >= $maxPoints ? 'alert-success' : 'alert-info');
|
|
|
|
$aiAlertClass = $aiPoints <= 0 ? 'alert-danger' : ($aiPoints >= $maxPoints ? 'alert-success' : 'alert-info');
|
|
|
|
?>
|
|
|
|
?>
|
|
|
|
<div class="alert <?php echo $aiAlertClass; ?> mt-3 ai-feedback-screen"><strong><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_AI_RESULT'); ?>:</strong><br><?php echo nl2br(htmlspecialchars((string) $answer['ai_feedback'], ENT_QUOTES, 'UTF-8')); ?></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 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); ?>">
|
|
|
|