Compare commits

..
7 Commits
10 changed files with 49 additions and 7 deletions
+1 -1
View File
@@ -30,6 +30,6 @@ Szkielet komponentu Joomla 6 do gromadzenia pytań testowych.
## Instalacja ## Instalacja
W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.43.35). W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.43.42).
Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**. Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**.
@@ -0,0 +1 @@
-- Brak zmian w schemacie bazy danych w wersji 1.43.36.
@@ -0,0 +1 @@
-- Brak zmian w schemacie bazy danych w wersji 1.43.37.
@@ -0,0 +1 @@
-- Brak zmian w schemacie bazy danych w wersji 1.43.38.
@@ -0,0 +1 @@
-- Brak zmian w schemacie bazy danych w wersji 1.43.39.
@@ -0,0 +1 @@
-- Brak zmian w schemacie bazy danych w wersji 1.43.40.
@@ -0,0 +1 @@
-- Brak zmian w schemacie bazy danych w wersji 1.43.41.
@@ -0,0 +1 @@
-- Brak zmian w schemacie bazy danych w wersji 1.43.42.
@@ -21,6 +21,7 @@ $resolveImageUrl = static function ($path) {
</button> </button>
</div> </div>
<style> <style>
.result-pdf-comment { display: none !important; }
@media print { @media print {
@page { size: A4; margin: 15mm; } @page { size: A4; margin: 15mm; }
.no-print, .toolbar, #toolbar, .subhead, .sidebar-wrapper, #sidebar, .navbar, .no-print, .toolbar, #toolbar, .subhead, .sidebar-wrapper, #sidebar, .navbar,
@@ -31,6 +32,13 @@ $resolveImageUrl = static function ($path) {
article { break-inside: auto; border-color: #aaa !important; } article { break-inside: auto; border-color: #aaa !important; }
img { max-width: 100% !important; max-height: 150mm; object-fit: contain; } img { max-width: 100% !important; max-height: 150mm; object-fit: contain; }
.alert { print-color-adjust: exact; -webkit-print-color-adjust: exact; } .alert { 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; }
} }
</style> </style>
<script> <script>
@@ -39,6 +47,23 @@ $resolveImageUrl = static function ($path) {
window.print(); window.print();
}); });
}); });
window.addEventListener('beforeprint', function () {
document.querySelectorAll('.result-pdf-comment').forEach(function (commentBlock) {
const questionId = commentBlock.dataset.questionId;
let manualComment = document.getElementById('result-comment-' + questionId)?.value.trim() || '';
if (manualComment === '-' || manualComment === '—') {
manualComment = '';
}
const output = commentBlock.querySelector('.result-pdf-comment-text');
const aiSource = document.querySelector('.ai-feedback-print-source[data-question-id="' + questionId + '"]');
commentBlock.classList.toggle('has-print-comment', Boolean(manualComment));
aiSource?.classList.toggle('print-ai-hidden', Boolean(manualComment));
if (output && manualComment) {
output.textContent = manualComment;
}
});
});
</script> </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;"' : ''; ?>>
@@ -70,7 +95,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>
@@ -91,7 +116,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'; ?>
@@ -112,6 +137,10 @@ $resolveImageUrl = static function ($path) {
$answerStatusCorrect = $awardedPoints > 0 && $awardedPoints >= $maximumPoints; $answerStatusCorrect = $awardedPoints > 0 && $awardedPoints >= $maximumPoints;
$answerStatusPartial = $awardedPoints > 0 && !$answerStatusCorrect; $answerStatusPartial = $awardedPoints > 0 && !$answerStatusCorrect;
} }
$manualComment = trim((string) ($answer['comment'] ?? ''));
if ($manualComment === '-' || $manualComment === '—') {
$manualComment = '';
}
?> ?>
<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>
@@ -123,6 +152,12 @@ $resolveImageUrl = static function ($path) {
<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 $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> <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; ?>">
<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>
</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">
@@ -132,7 +167,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 ·
@@ -147,11 +182,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"><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 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>
<?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); ?>">
+1 -1
View File
@@ -4,7 +4,7 @@
<creationDate>2026-10-14</creationDate> <creationDate>2026-10-14</creationDate>
<author>Komponent</author> <author>Komponent</author>
<license>GNU General Public License version 2 or later</license> <license>GNU General Public License version 2 or later</license>
<version>1.43.35</version> <version>1.43.42</version>
<description>COM_TESTQUESTIONS_DESCRIPTION</description> <description>COM_TESTQUESTIONS_DESCRIPTION</description>
<element>com_testquestions</element> <element>com_testquestions</element>
<namespace path="src">Komponent\Component\Testquestions</namespace> <namespace path="src">Komponent\Component\Testquestions</namespace>