Compare commits

...
12 Commits
21 changed files with 114 additions and 17 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.29). W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.43.41).
Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**. Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**.
@@ -130,6 +130,8 @@ COM_TESTQUESTIONS_RESULTS_AI_TOKENS_TOTAL="Łączne wykorzystanie tokenów w wyn
COM_TESTQUESTIONS_RESULT_SCORE="Wynik" COM_TESTQUESTIONS_RESULT_SCORE="Wynik"
COM_TESTQUESTIONS_RESULT_POINTS_BEFORE_AFTER="Punkty przed / po korekcie" COM_TESTQUESTIONS_RESULT_POINTS_BEFORE_AFTER="Punkty przed / po korekcie"
COM_TESTQUESTIONS_RESULT_GRADE="Ocena" COM_TESTQUESTIONS_RESULT_GRADE="Ocena"
COM_TESTQUESTIONS_RESULT_NOT_ASSESSED="Nie sprawdzono"
COM_TESTQUESTIONS_RESULT_GENERATE_PDF="Generuj PDF / drukuj"
COM_TESTQUESTIONS_RESULT_DATE="Data zakończenia" COM_TESTQUESTIONS_RESULT_DATE="Data zakończenia"
COM_TESTQUESTIONS_RESULT_ANSWERS="Odpowiedzi" COM_TESTQUESTIONS_RESULT_ANSWERS="Odpowiedzi"
COM_TESTQUESTIONS_RESULT_EXECUTION_TIME="Czas wykonania" COM_TESTQUESTIONS_RESULT_EXECUTION_TIME="Czas wykonania"
@@ -149,6 +151,7 @@ COM_TESTQUESTIONS_YOUR_ANSWER="Twoja odpowiedź"
COM_TESTQUESTIONS_SELECTED_ANSWER="Zaznaczona odpowiedź" COM_TESTQUESTIONS_SELECTED_ANSWER="Zaznaczona odpowiedź"
COM_TESTQUESTIONS_ANSWER_CORRECT="Poprawna odpowiedź" COM_TESTQUESTIONS_ANSWER_CORRECT="Poprawna odpowiedź"
COM_TESTQUESTIONS_ANSWER_INCORRECT="Niepoprawna odpowiedź" COM_TESTQUESTIONS_ANSWER_INCORRECT="Niepoprawna odpowiedź"
COM_TESTQUESTIONS_ANSWER_PARTIALLY_CORRECT="Odpowiedź częściowo poprawna"
COM_TESTQUESTIONS_CORRECT_PATTERN="Wzorzec poprawnej odpowiedzi" COM_TESTQUESTIONS_CORRECT_PATTERN="Wzorzec poprawnej odpowiedzi"
COM_TESTQUESTIONS_SUBJECT="Przedmiot" COM_TESTQUESTIONS_SUBJECT="Przedmiot"
COM_TESTQUESTIONS_SUBJECT_TITLE="Nazwa przedmiotu" COM_TESTQUESTIONS_SUBJECT_TITLE="Nazwa przedmiotu"
@@ -0,0 +1 @@
-- Wydanie 1.43.30: odczyt tokenów Gemini z pola usageMetadata.
@@ -0,0 +1 @@
-- Brak zmian w schemacie bazy danych w wersji 1.43.31.
@@ -0,0 +1 @@
-- Brak zmian w schemacie bazy danych w wersji 1.43.32.
@@ -0,0 +1 @@
-- Brak zmian w schemacie bazy danych w wersji 1.43.33.
@@ -0,0 +1 @@
-- Brak zmian w schemacie bazy danych w wersji 1.43.34.
@@ -0,0 +1 @@
-- Brak zmian w schemacie bazy danych w wersji 1.43.35.
@@ -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.
@@ -14,6 +14,7 @@ class ResultsModel extends ListModel
$items = parent::getItems(); $items = parent::getItems();
foreach ($items as $item) { foreach ($items as $item) {
$item->has_assessment = false;
$item->ai_input_tokens = 0; $item->ai_input_tokens = 0;
$item->ai_output_tokens = 0; $item->ai_output_tokens = 0;
$item->ai_total_tokens = 0; $item->ai_total_tokens = 0;
@@ -30,6 +31,11 @@ class ResultsModel extends ListModel
continue; continue;
} }
// Manual assessment and AI both save awarded_points in the answer JSON.
if (array_key_exists('awarded_points', $answer)) {
$item->has_assessment = true;
}
$usages = $answer['ai_usage_history'] ?? (isset($answer['ai_usage']) ? [$answer['ai_usage']] : []); $usages = $answer['ai_usage_history'] ?? (isset($answer['ai_usage']) ? [$answer['ai_usage']] : []);
if (!is_array($usages)) { if (!is_array($usages)) {
continue; continue;
@@ -147,7 +147,9 @@ class AiService
private function getUsage(array $body, string $provider, string $model): ?array private function getUsage(array $body, string $provider, string $model): ?array
{ {
$usage = $body['usage'] ?? null; // Gemini uses camelCase UsageMetadata at the response root; the
// OpenAI-compatible providers return their counters in `usage`.
$usage = $body['usageMetadata'] ?? $body['usage'] ?? null;
if (!is_array($usage)) { if (!is_array($usage)) {
return null; return null;
} }
@@ -20,10 +20,10 @@ $resolveImageUrl = static function ($path) {
<?php if ($this->set) : ?> <?php if ($this->set) : ?>
<header class="test-set-header"> <header class="test-set-header">
<h1><?php echo htmlspecialchars($this->set->title, ENT_QUOTES, 'UTF-8'); ?></h1> <h1><?php echo htmlspecialchars($this->set->title, ENT_QUOTES, 'UTF-8'); ?></h1>
<?php if ($this->set->test_content) : ?><div class="test-set-content"><?php echo $this->set->test_content; ?></div><?php endif; ?>
<?php if ($this->set->image) : ?> <?php if ($this->set->image) : ?>
<div class="foto_pyt"><img src="<?php echo htmlspecialchars($resolveImageUrl($this->set->image), ENT_QUOTES, 'UTF-8'); ?>" alt="" loading="lazy"></div> <div class="foto_pyt"><img src="<?php echo htmlspecialchars($resolveImageUrl($this->set->image), ENT_QUOTES, 'UTF-8'); ?>" alt="" loading="lazy"></div>
<?php endif; ?> <?php endif; ?>
<?php if ($this->set->test_content) : ?><div class="test-set-content"><?php echo $this->set->test_content; ?></div><?php endif; ?>
</header> </header>
<?php endif; ?> <?php endif; ?>
<?php if (!$this->items) : ?> <?php if (!$this->items) : ?>
@@ -14,6 +14,55 @@ $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>
.result-pdf-comment { 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; }
.container-fluid .result-pdf-comment { display: block !important; }
.result-pdf-comment-text { white-space: pre-wrap; }
.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();
});
});
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 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 selectedComment = manualComment || aiComment;
// Keep the server-rendered AI fallback when no input/source is found in the DOM.
if (output && selectedComment) {
output.textContent = selectedComment;
}
});
});
</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 +93,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 +114,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 +126,22 @@ $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'] ?? ''));
if ($manualComment === '-' || $manualComment === '—') {
$manualComment = '';
}
$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 +151,14 @@ $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 ($question->question_type === 'open') : ?>
<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>
<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>
<?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 +168,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,11 +183,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" 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); ?>">
@@ -84,12 +84,14 @@ HTMLHelper::_('behavior.multiselect');
<?php $pointsTotal = (int) $item->points_total ?: (int) $item->total_count; ?> <?php $pointsTotal = (int) $item->points_total ?: (int) $item->total_count; ?>
<?php $pointsBeforePercentage = $pointsTotal ? round(((int) $item->points_before / $pointsTotal) * 100, 2) : 0; ?> <?php $pointsBeforePercentage = $pointsTotal ? round(((int) $item->points_before / $pointsTotal) * 100, 2) : 0; ?>
<?php $pointsAfterPercentage = $pointsTotal ? round(((int) $item->points_after / $pointsTotal) * 100, 2) : 0; ?> <?php $pointsAfterPercentage = $pointsTotal ? round(((int) $item->points_after / $pointsTotal) * 100, 2) : 0; ?>
<?php $grade = 'NDST'; ?> <?php if ($item->has_assessment) : ?>
<?php foreach ([['CEL', 100], ['BDB', 90], ['BDB-', 80], ['DB+', 75], ['DB', 70], ['DB-', 65], ['DST+', 60], ['DST', 55], ['DST-', 50], ['DOP+', 45], ['DOP', 40], ['DOP-', 35], ['NDST+', 30], ['NDST', 0]] as $gradeScale) : ?> <?php $grade = 'NDST'; ?>
<?php if ($pointsAfterPercentage >= $gradeScale[1]) { $grade = $gradeScale[0]; break; } ?> <?php foreach ([['CEL', 100], ['BDB', 90], ['BDB-', 80], ['DB+', 75], ['DB', 70], ['DB-', 65], ['DST+', 60], ['DST', 55], ['DST-', 50], ['DOP+', 45], ['DOP', 40], ['DOP-', 35], ['NDST+', 30], ['NDST', 0]] as $gradeScale) : ?>
<?php endforeach; ?> <?php if ($pointsAfterPercentage >= $gradeScale[1]) { $grade = $gradeScale[0]; break; } ?>
<td><?php echo (int) $item->points_before; ?> (<?php echo $pointsBeforePercentage; ?>%) / <?php echo (int) $item->points_after; ?> (<?php echo $pointsAfterPercentage; ?>%)</td> <?php endforeach; ?>
<td><?php echo $this->escape($grade); ?></td> <?php endif; ?>
<td><?php echo (int) $item->points_before; ?> (<?php echo $pointsBeforePercentage; ?>%) / <?php if ($item->has_assessment) : ?><?php echo (int) $item->points_after; ?> (<?php echo $pointsAfterPercentage; ?>%)<?php else : ?><span class="text-muted"><?php echo $this->escape(\Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULT_NOT_ASSESSED')); ?></span><?php endif; ?></td>
<td><?php echo $item->has_assessment ? $this->escape($grade) : '<span class="text-muted">' . $this->escape(\Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULT_NOT_ASSESSED')) . '</span>'; ?></td>
<td><?php echo floor((int) $item->execution_time / 60); ?>:<?php echo str_pad((string) ((int) $item->execution_time % 60), 2, '0', STR_PAD_LEFT); ?></td> <td><?php echo floor((int) $item->execution_time / 60); ?>:<?php echo str_pad((string) ((int) $item->execution_time % 60), 2, '0', STR_PAD_LEFT); ?></td>
<td><?php echo HTMLHelper::_('date', $item->created, 'Y-m-d H:i'); ?></td> <td><?php echo HTMLHelper::_('date', $item->created, 'Y-m-d H:i'); ?></td>
<td> <td>
+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.29</version> <version>1.43.41</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>
@@ -67,8 +67,8 @@ $resolveImageUrl = static function ($path) {
<?php if ($this->set->subject_title) : ?><div class="text-muted"><?php echo htmlspecialchars($this->set->subject_title, ENT_QUOTES, 'UTF-8'); ?></div><?php endif; ?> <?php if ($this->set->subject_title) : ?><div class="text-muted"><?php echo htmlspecialchars($this->set->subject_title, ENT_QUOTES, 'UTF-8'); ?></div><?php endif; ?>
<h1><?php echo htmlspecialchars($this->set->title, ENT_QUOTES, 'UTF-8'); ?></h1> <h1><?php echo htmlspecialchars($this->set->title, ENT_QUOTES, 'UTF-8'); ?></h1>
<?php if ($testDurationSeconds > 0) : ?><div class="small text-muted"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_SET_DURATION'); ?>: <?php echo $durationMinutes; ?> min<?php if ($durationRemainder > 0) : ?> <?php echo $durationRemainder; ?> s<?php endif; ?></div><?php endif; ?> <?php if ($testDurationSeconds > 0) : ?><div class="small text-muted"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_SET_DURATION'); ?>: <?php echo $durationMinutes; ?> min<?php if ($durationRemainder > 0) : ?> <?php echo $durationRemainder; ?> s<?php endif; ?></div><?php endif; ?>
<?php if ($this->set->image) : ?><div class="foto_pyt"><img src="<?php echo htmlspecialchars($resolveImageUrl($this->set->image), ENT_QUOTES, 'UTF-8'); ?>" alt="" loading="lazy"></div><?php endif; ?>
<?php if ($this->set->test_content) : ?><div class="test-set-content"><?php echo $this->set->test_content; ?></div><?php endif; ?> <?php if ($this->set->test_content) : ?><div class="test-set-content"><?php echo $this->set->test_content; ?></div><?php endif; ?>
<?php if ($this->set->image) : ?><div class="foto_pyt"><img src="<?php echo htmlspecialchars($resolveImageUrl($this->set->image), ENT_QUOTES, 'UTF-8'); ?>" alt="" loading="lazy"></div><?php endif; ?>
</header> </header>
<?php if (!$this->results && $testDurationSeconds > 0) : ?> <?php if (!$this->results && $testDurationSeconds > 0) : ?>
<div class="timer-container mb-4" id="test-timer-container" data-duration="<?php echo $testDurationSeconds; ?>" aria-live="polite"> <div class="timer-container mb-4" id="test-timer-container" data-duration="<?php echo $testDurationSeconds; ?>" aria-live="polite">