|
|
@@ -14,6 +14,35 @@ $resolveImageUrl = static function ($path) {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
?>
|
|
|
|
?>
|
|
|
|
<div class="container-fluid">
|
|
|
|
<div class="container-fluid">
|
|
|
|
|
|
|
|
<div class="mb-3 no-print">
|
|
|
|
|
|
|
|
<button type="button" class="btn btn-outline-secondary" id="result-pdf-button">
|
|
|
|
|
|
|
|
<span class="icon-print" aria-hidden="true"></span>
|
|
|
|
|
|
|
|
<?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULT_GENERATE_PDF'); ?>
|
|
|
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
|
|
|
.pdf-only { display: none !important; }
|
|
|
|
|
|
|
|
@media print {
|
|
|
|
|
|
|
|
@page { size: A4; margin: 15mm; }
|
|
|
|
|
|
|
|
.no-print, .toolbar, #toolbar, .subhead, .sidebar-wrapper, #sidebar, .navbar,
|
|
|
|
|
|
|
|
#system-message-container, #adminForm input, #adminForm textarea,
|
|
|
|
|
|
|
|
#adminForm select, #adminForm button { display: none !important; }
|
|
|
|
|
|
|
|
body, .container-main, .container-fluid { background: #fff !important; width: 100% !important; margin: 0 !important; padding: 0 !important; }
|
|
|
|
|
|
|
|
.container-fluid { max-width: none !important; }
|
|
|
|
|
|
|
|
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; }
|
|
|
|
|
|
|
|
.pdf-only { display: block !important; }
|
|
|
|
|
|
|
|
.ai-feedback-screen, .ai-token-info { display: none !important; }
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
|
|
|
|
|
|
document.getElementById('result-pdf-button')?.addEventListener('click', function () {
|
|
|
|
|
|
|
|
window.print();
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
</script>
|
|
|
|
<dl class="row">
|
|
|
|
<dl class="row">
|
|
|
|
<div class="row"<?php echo (int) $this->item->extra_time > 0 ? ' style="background-color: #fff3cd;"' : ''; ?>>
|
|
|
|
<div class="row"<?php echo (int) $this->item->extra_time > 0 ? ' style="background-color: #fff3cd;"' : ''; ?>>
|
|
|
|
<dt class="col-sm-3"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULT_PARTICIPANT'); ?></dt>
|
|
|
|
<dt class="col-sm-3"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULT_PARTICIPANT'); ?></dt>
|
|
|
@@ -44,7 +73,7 @@ $resolveImageUrl = static function ($path) {
|
|
|
|
<?php if ($candidate && $candidate->question_type === 'open' && empty($answer['correct']) && trim((string) ($answer['selected'] ?? '')) !== '') { $pendingAiCount++; } ?>
|
|
|
|
<?php if ($candidate && $candidate->question_type === 'open' && empty($answer['correct']) && trim((string) ($answer['selected'] ?? '')) !== '') { $pendingAiCount++; } ?>
|
|
|
|
<?php endforeach; ?>
|
|
|
|
<?php endforeach; ?>
|
|
|
|
<?php if ($pendingAiCount > 0) : ?>
|
|
|
|
<?php if ($pendingAiCount > 0) : ?>
|
|
|
|
<div class="mb-3">
|
|
|
|
<div class="mb-3 no-print">
|
|
|
|
<button type="submit" class="btn btn-primary" formaction="<?php echo Route::_('index.php?option=com_testquestions&task=result.aiAll&id=' . (int) $this->item->id); ?>" onclick="this.form.task.value='result.aiAll';">
|
|
|
|
<button type="submit" class="btn btn-primary" formaction="<?php echo Route::_('index.php?option=com_testquestions&task=result.aiAll&id=' . (int) $this->item->id); ?>" onclick="this.form.task.value='result.aiAll';">
|
|
|
|
<?php echo \Joomla\CMS\Language\Text::sprintf('COM_TESTQUESTIONS_AI_EVALUATE_ALL', $pendingAiCount); ?>
|
|
|
|
<?php echo \Joomla\CMS\Language\Text::sprintf('COM_TESTQUESTIONS_AI_EVALUATE_ALL', $pendingAiCount); ?>
|
|
|
|
</button>
|
|
|
|
</button>
|
|
|
@@ -65,7 +94,7 @@ $resolveImageUrl = static function ($path) {
|
|
|
|
?>
|
|
|
|
?>
|
|
|
|
<?php if ($usageTotals['total_tokens'] > 0) : ?>
|
|
|
|
<?php if ($usageTotals['total_tokens'] > 0) : ?>
|
|
|
|
<?php $usageProviderLabels = array_map(static function ($usageProvider) { return ['openai' => 'OpenAI', 'grok' => 'Grok', 'groq' => 'Groq', 'gemini' => 'Gemini'][$usageProvider] ?? $usageProvider; }, array_keys($usageTotals['providers'])); ?>
|
|
|
|
<?php $usageProviderLabels = array_map(static function ($usageProvider) { return ['openai' => 'OpenAI', 'grok' => 'Grok', 'groq' => 'Groq', 'gemini' => 'Gemini'][$usageProvider] ?? $usageProvider; }, array_keys($usageTotals['providers'])); ?>
|
|
|
|
<span class="badge text-bg-light border ms-2" title="Suma dotychczasowych ocen AI">
|
|
|
|
<span class="badge text-bg-light border ms-2 ai-token-info" title="Suma dotychczasowych ocen AI">
|
|
|
|
✦ <?php echo implode(' + ', array_map('htmlspecialchars', $usageProviderLabels)); ?>:
|
|
|
|
✦ <?php echo implode(' + ', array_map('htmlspecialchars', $usageProviderLabels)); ?>:
|
|
|
|
<?php echo number_format($usageTotals['total_tokens'], 0, ',', ' '); ?> tokenów,
|
|
|
|
<?php echo number_format($usageTotals['total_tokens'], 0, ',', ' '); ?> tokenów,
|
|
|
|
<?php echo $usageTotals['cost_calls'] > 0 ? number_format($usageTotals['cost_usd'], 8, ',', ' ') . ' USD' : 'koszt niedostępny'; ?>
|
|
|
|
<?php echo $usageTotals['cost_calls'] > 0 ? number_format($usageTotals['cost_usd'], 8, ',', ' ') . ' USD' : 'koszt niedostępny'; ?>
|
|
|
@@ -77,6 +106,19 @@ $resolveImageUrl = static function ($path) {
|
|
|
|
<?php foreach ($this->item->answers as $questionId => $answer) : ?>
|
|
|
|
<?php foreach ($this->item->answers as $questionId => $answer) : ?>
|
|
|
|
<?php $question = $this->item->questions[(int) $questionId] ?? null; if (!$question) continue; ?>
|
|
|
|
<?php $question = $this->item->questions[(int) $questionId] ?? null; if (!$question) continue; ?>
|
|
|
|
<?php $hasResponse = trim((string) ($answer['selected'] ?? '')) !== ''; ?>
|
|
|
|
<?php $hasResponse = trim((string) ($answer['selected'] ?? '')) !== ''; ?>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
$answerStatusCorrect = !empty($answer['correct']);
|
|
|
|
|
|
|
|
$answerStatusPartial = false;
|
|
|
|
|
|
|
|
if ($question->question_type === 'open' && array_key_exists('awarded_points', $answer)) {
|
|
|
|
|
|
|
|
$awardedPoints = (int) $answer['awarded_points'];
|
|
|
|
|
|
|
|
$maximumPoints = (int) ($question->points ?? 0);
|
|
|
|
|
|
|
|
$answerStatusCorrect = $awardedPoints > 0 && $awardedPoints >= $maximumPoints;
|
|
|
|
|
|
|
|
$answerStatusPartial = $awardedPoints > 0 && !$answerStatusCorrect;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$manualComment = trim((string) ($answer['comment'] ?? ''));
|
|
|
|
|
|
|
|
$aiComment = trim((string) ($answer['ai_feedback'] ?? ''));
|
|
|
|
|
|
|
|
$printComment = $manualComment !== '' ? $manualComment : $aiComment;
|
|
|
|
|
|
|
|
?>
|
|
|
|
<article class="mb-4 border rounded p-3">
|
|
|
|
<article class="mb-4 border rounded p-3">
|
|
|
|
<div class="mb-2"><?php echo $question->question; ?></div>
|
|
|
|
<div class="mb-2"><?php echo $question->question; ?></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 (!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; ?>
|
|
|
@@ -86,7 +128,10 @@ $resolveImageUrl = static function ($path) {
|
|
|
|
<?php else : ?>
|
|
|
|
<?php else : ?>
|
|
|
|
<div><strong><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_SELECTED_ANSWER'); ?>:</strong> <?php echo $answer['selected'] ? chr(64 + (int) $answer['selected']) : '—'; ?></div>
|
|
|
|
<div><strong><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_SELECTED_ANSWER'); ?>:</strong> <?php echo $answer['selected'] ? chr(64 + (int) $answer['selected']) : '—'; ?></div>
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php endif; ?>
|
|
|
|
<div class="mt-2 <?php echo !empty($answer['correct']) ? 'text-success' : 'text-danger'; ?>"><?php echo !empty($answer['correct']) ? '✓ ' . \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_ANSWER_CORRECT') : '✗ ' . \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_ANSWER_INCORRECT'); ?></div>
|
|
|
|
<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 ($printComment !== '') : ?>
|
|
|
|
|
|
|
|
<div class="pdf-only mt-3"><strong><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULT_COMMENT'); ?>:</strong><br><?php echo nl2br(htmlspecialchars($printComment, ENT_QUOTES, 'UTF-8')); ?></div>
|
|
|
|
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php if (empty($answer['correct'])) : ?>
|
|
|
|
<?php if (empty($answer['correct'])) : ?>
|
|
|
|
<?php if ($question->question_type === 'open' && $hasResponse) : ?>
|
|
|
|
<?php if ($question->question_type === 'open' && $hasResponse) : ?>
|
|
|
|
<div class="mt-3">
|
|
|
|
<div class="mt-3">
|
|
|
@@ -96,7 +141,7 @@ $resolveImageUrl = static function ($path) {
|
|
|
|
<?php if (!empty($answer['ai_usage']) && is_array($answer['ai_usage'])) : ?>
|
|
|
|
<?php if (!empty($answer['ai_usage']) && is_array($answer['ai_usage'])) : ?>
|
|
|
|
<?php $usage = $answer['ai_usage']; ?>
|
|
|
|
<?php $usage = $answer['ai_usage']; ?>
|
|
|
|
<?php $usageProvider = (string) ($usage['provider'] ?? ''); ?>
|
|
|
|
<?php $usageProvider = (string) ($usage['provider'] ?? ''); ?>
|
|
|
|
<span class="badge text-bg-light border ms-2" title="<?php echo $usageProvider === 'grok' ? 'Koszt zwrócony przez dostawcę' : (in_array($usageProvider, ['groq', 'gemini'], true) ? 'Dostawca zwrócił wykorzystane tokeny; koszt nie jest zwracany przez to API' : 'Koszt obliczony z faktycznie wykorzystanych tokenów i stawek modelu'); ?>">
|
|
|
|
<span class="badge text-bg-light border ms-2 ai-token-info" title="<?php echo $usageProvider === 'grok' ? 'Koszt zwrócony przez dostawcę' : (in_array($usageProvider, ['groq', 'gemini'], true) ? 'Dostawca zwrócił wykorzystane tokeny; koszt nie jest zwracany przez to API' : 'Koszt obliczony z faktycznie wykorzystanych tokenów i stawek modelu'); ?>">
|
|
|
|
<?php echo $usageProvider === 'grok' ? '✦ Grok' : ($usageProvider === 'groq' ? '⚡ Groq' : ($usageProvider === 'gemini' ? '✧ Gemini' : '◉ OpenAI')); ?> ·
|
|
|
|
<?php echo $usageProvider === 'grok' ? '✦ Grok' : ($usageProvider === 'groq' ? '⚡ Groq' : ($usageProvider === 'gemini' ? '✧ Gemini' : '◉ OpenAI')); ?> ·
|
|
|
|
<?php echo number_format((int) ($usage['input_tokens'] ?? 0), 0, ',', ' '); ?> in /
|
|
|
|
<?php echo number_format((int) ($usage['input_tokens'] ?? 0), 0, ',', ' '); ?> in /
|
|
|
|
<?php echo number_format((int) ($usage['output_tokens'] ?? 0), 0, ',', ' '); ?> out ·
|
|
|
|
<?php echo number_format((int) ($usage['output_tokens'] ?? 0), 0, ',', ' '); ?> out ·
|
|
|
@@ -111,7 +156,7 @@ $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"><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"><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>
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php endif; ?>
|
|
|
|
<?php if ($question->question_type === 'open' && $hasResponse) : ?>
|
|
|
|
<?php if ($question->question_type === 'open' && $hasResponse) : ?>
|
|
|
|