Compare commits

..
5 Commits
Author SHA1 Message Date
Wojtek 08220dc6e8 Add aggregate AI tokens and move column 2026-10-16 19:46:10 +02:00
Wojtek 42b5006574 Show AI token usage per saved test 2026-10-16 19:43:15 +02:00
Wojtek 8693720b78 Replace AI balance with usage counters 2026-10-16 19:36:42 +02:00
Wojtek 37d8c6040c Show remaining API credits in AI settings 2026-10-16 15:12:33 +02:00
Wojtek 7ed00f95e6 Add GPT-6 Luna model option 2026-10-16 13:22:18 +02:00
16 changed files with 229 additions and 10 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.5). W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.43.10).
Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**. Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**.
@@ -70,6 +70,13 @@ COM_TESTQUESTIONS_AI_GROK_KEY="Klucz API Grok"
COM_TESTQUESTIONS_AI_OPENAI_MODEL="Model OpenAI" COM_TESTQUESTIONS_AI_OPENAI_MODEL="Model OpenAI"
COM_TESTQUESTIONS_AI_GROK_MODEL="Model Grok" COM_TESTQUESTIONS_AI_GROK_MODEL="Model Grok"
COM_TESTQUESTIONS_AI_MODEL_INVALID="Wybierz prawidłowy model dla każdego dostawcy AI." COM_TESTQUESTIONS_AI_MODEL_INVALID="Wybierz prawidłowy model dla każdego dostawcy AI."
COM_TESTQUESTIONS_AI_TOKEN_USAGE="Wykorzystanie tokenów API"
COM_TESTQUESTIONS_AI_TOKEN_USAGE_INFO="Suma użycia zapisanego przy ocenach AI we wszystkich wynikach testów. Powtórne oceny są zliczane, jeśli zostały wykonane po tej aktualizacji."
COM_TESTQUESTIONS_AI_USAGE_CALLS="Liczba ocen"
COM_TESTQUESTIONS_AI_USAGE_INPUT="Tokeny wejściowe"
COM_TESTQUESTIONS_AI_USAGE_OUTPUT="Tokeny wyjściowe"
COM_TESTQUESTIONS_AI_USAGE_TOTAL="Razem tokenów"
COM_TESTQUESTIONS_AI_USAGE_COST="Koszt zapisany"
COM_TESTQUESTIONS_AI_SETTINGS_MENU="Konfiguracja AI" COM_TESTQUESTIONS_AI_SETTINGS_MENU="Konfiguracja AI"
COM_TESTQUESTIONS_AI_SETTINGS_SAVED="Ustawienia AI zapisano." COM_TESTQUESTIONS_AI_SETTINGS_SAVED="Ustawienia AI zapisano."
COM_TESTQUESTIONS_AI_SAVE_FAILED="Nie udało się zapisać ustawień AI." COM_TESTQUESTIONS_AI_SAVE_FAILED="Nie udało się zapisać ustawień AI."
@@ -99,6 +106,8 @@ COM_TESTQUESTIONS_RESULTS="Zapisane testy"
COM_TESTQUESTIONS_RESULT_PREVIEW="Podgląd zapisanego testu" COM_TESTQUESTIONS_RESULT_PREVIEW="Podgląd zapisanego testu"
COM_TESTQUESTIONS_RESULT_NOT_FOUND="Nie znaleziono zapisanego testu." COM_TESTQUESTIONS_RESULT_NOT_FOUND="Nie znaleziono zapisanego testu."
COM_TESTQUESTIONS_RESULT_PARTICIPANT="Użytkownik" COM_TESTQUESTIONS_RESULT_PARTICIPANT="Użytkownik"
COM_TESTQUESTIONS_RESULT_AI_TOKENS="Tokeny AI"
COM_TESTQUESTIONS_RESULTS_AI_TOKENS_TOTAL="Łączne wykorzystanie tokenów w wynikach"
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"
@@ -0,0 +1 @@
-- No database changes required for version 1.43.10.
@@ -0,0 +1 @@
-- No database changes required for version 1.43.6.
@@ -0,0 +1 @@
-- No database changes required for version 1.43.7.
@@ -0,0 +1,5 @@
UPDATE `#__extensions`
SET `params` = JSON_REMOVE(`params`, '$.ai_grok_team_id', '$.ai_grok_management_key')
WHERE `type` = 'component'
AND `element` = 'com_testquestions'
AND JSON_VALID(`params`);
@@ -0,0 +1 @@
-- No database changes required for version 1.43.9.
@@ -14,6 +14,16 @@ use Komponent\Component\Testquestions\Administrator\Service\AiService;
class AiController extends BaseController class AiController extends BaseController
{ {
public function save(): void public function save(): void
{
$this->saveSettings();
$this->setRedirect(
Route::_('index.php?option=com_testquestions&view=ai', false),
Text::_('COM_TESTQUESTIONS_AI_SETTINGS_SAVED')
);
}
private function saveSettings(): array
{ {
if (!Session::checkToken()) { if (!Session::checkToken()) {
throw new \RuntimeException(Text::_('JINVALID_TOKEN'), 403); throw new \RuntimeException(Text::_('JINVALID_TOKEN'), 403);
@@ -56,38 +66,34 @@ class AiController extends BaseController
$settings = json_decode((string) $row->params, true); $settings = json_decode((string) $row->params, true);
$settings = is_array($settings) ? $settings : []; $settings = is_array($settings) ? $settings : [];
$legacyKey = trim((string) ($settings['ai_api_key'] ?? '')); $legacyKey = trim((string) ($settings['ai_api_key'] ?? ''));
$settings['ai_provider'] = $provider; $settings['ai_provider'] = $provider;
foreach ($selectedModels as $modelProvider => $model) { foreach ($selectedModels as $modelProvider => $model) {
$settings['ai_' . $modelProvider . '_model'] = $model; $settings['ai_' . $modelProvider . '_model'] = $model;
} }
foreach (['openai', 'grok'] as $keyProvider) { foreach (['openai', 'grok'] as $keyProvider) {
$fieldName = 'ai_' . $keyProvider . '_api_key'; $fieldName = 'ai_' . $keyProvider . '_api_key';
$apiKey = trim((string) $input->post->get($fieldName, '', 'RAW')); $apiKey = trim((string) $input->post->get($fieldName, '', 'RAW'));
if ($apiKey !== '') { if ($apiKey !== '') {
$settings[$fieldName] = $apiKey; $settings[$fieldName] = $apiKey;
} }
if ($keyProvider === $provider && empty($settings[$fieldName]) && $legacyKey !== '') { if ($keyProvider === $provider && empty($settings[$fieldName]) && $legacyKey !== '') {
$settings[$fieldName] = $legacyKey; $settings[$fieldName] = $legacyKey;
} }
} }
unset($settings['ai_api_key']); unset($settings['ai_api_key']);
unset($settings['ai_grok_team_id'], $settings['ai_grok_management_key']);
$extension = (object) [ $extension = (object) [
'extension_id' => (int) $row->extension_id, 'extension_id' => (int) $row->extension_id,
'params' => json_encode($settings, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES), 'params' => json_encode($settings, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),
]; ];
if (!$db->updateObject('#__extensions', $extension, 'extension_id')) { if (!$db->updateObject('#__extensions', $extension, 'extension_id')) {
throw new \RuntimeException(Text::_('COM_TESTQUESTIONS_AI_SAVE_FAILED')); throw new \RuntimeException(Text::_('COM_TESTQUESTIONS_AI_SAVE_FAILED'));
} }
$this->setRedirect( return $settings;
Route::_('index.php?option=com_testquestions&view=ai', false),
Text::_('COM_TESTQUESTIONS_AI_SETTINGS_SAVED')
);
} }
public function cancel(): void public function cancel(): void
@@ -161,6 +161,14 @@ class ResultModel extends BaseDatabaseModel
$item->answers[$questionId]['ai_feedback'] = $aiResult['feedback']; $item->answers[$questionId]['ai_feedback'] = $aiResult['feedback'];
$item->answers[$questionId]['awarded_points'] = $aiResult['awarded_points']; $item->answers[$questionId]['awarded_points'] = $aiResult['awarded_points'];
if ($aiResult['usage'] !== null) { if ($aiResult['usage'] !== null) {
$history = $item->answers[$questionId]['ai_usage_history'] ?? null;
if (!is_array($history)) {
$history = !empty($item->answers[$questionId]['ai_usage']) && is_array($item->answers[$questionId]['ai_usage'])
? [$item->answers[$questionId]['ai_usage']]
: [];
}
$history[] = $aiResult['usage'];
$item->answers[$questionId]['ai_usage_history'] = $history;
$item->answers[$questionId]['ai_usage'] = $aiResult['usage']; $item->answers[$questionId]['ai_usage'] = $aiResult['usage'];
} }
@@ -9,6 +9,86 @@ use Joomla\CMS\MVC\Model\ListModel;
class ResultsModel extends ListModel class ResultsModel extends ListModel
{ {
public function getItems()
{
$items = parent::getItems();
foreach ($items as $item) {
$item->ai_input_tokens = 0;
$item->ai_output_tokens = 0;
$item->ai_total_tokens = 0;
$item->ai_cost_usd = 0.0;
$answers = json_decode((string) ($item->answers ?? ''), true);
if (!is_array($answers)) {
continue;
}
foreach ($answers as $answer) {
if (!is_array($answer)) {
continue;
}
$usages = $answer['ai_usage_history'] ?? (isset($answer['ai_usage']) ? [$answer['ai_usage']] : []);
if (!is_array($usages)) {
continue;
}
foreach ($usages as $usage) {
if (!is_array($usage)) {
continue;
}
$item->ai_input_tokens += (int) ($usage['input_tokens'] ?? 0);
$item->ai_output_tokens += (int) ($usage['output_tokens'] ?? 0);
$item->ai_total_tokens += (int) ($usage['total_tokens'] ?? 0);
if (is_numeric($usage['cost_usd'] ?? null)) {
$item->ai_cost_usd += (float) $usage['cost_usd'];
}
}
}
}
return $items;
}
public function getAiUsageTotals(): array
{
$db = Factory::getContainer()->get('DatabaseDriver');
$query = clone $this->getListQuery();
$query->clear('select')->clear('order')->select($db->quoteName('r.answers'));
$answersRows = $db->setQuery($query)->loadColumn();
$totals = ['input_tokens' => 0, 'output_tokens' => 0, 'total_tokens' => 0, 'cost_usd' => 0.0];
foreach ($answersRows as $answersJson) {
$answers = json_decode((string) $answersJson, true);
if (!is_array($answers)) {
continue;
}
foreach ($answers as $answer) {
if (!is_array($answer)) {
continue;
}
$usages = $answer['ai_usage_history'] ?? (isset($answer['ai_usage']) ? [$answer['ai_usage']] : []);
if (!is_array($usages)) {
continue;
}
foreach ($usages as $usage) {
if (!is_array($usage)) {
continue;
}
$totals['input_tokens'] += (int) ($usage['input_tokens'] ?? 0);
$totals['output_tokens'] += (int) ($usage['output_tokens'] ?? 0);
$totals['total_tokens'] += (int) ($usage['total_tokens'] ?? 0);
if (is_numeric($usage['cost_usd'] ?? null)) {
$totals['cost_usd'] += (float) $usage['cost_usd'];
}
}
}
}
return $totals;
}
protected function populateState($ordering = 'r.created', $direction = 'desc') protected function populateState($ordering = 'r.created', $direction = 'desc')
{ {
parent::populateState($ordering, $direction); parent::populateState($ordering, $direction);
@@ -16,6 +16,7 @@ class AiService
'gpt-5.6-luna' => 'GPT-5.6 Luna', 'gpt-5.6-luna' => 'GPT-5.6 Luna',
'gpt-5.6-terra' => 'GPT-5.6 Terra', 'gpt-5.6-terra' => 'GPT-5.6 Terra',
'gpt-5.6-sol' => 'GPT-5.6 Sol', 'gpt-5.6-sol' => 'GPT-5.6 Sol',
'gpt-6-luna' => 'GPT-6 Luna',
], ],
'grok' => [ 'grok' => [
'grok-4.7' => 'Grok 4.7', 'grok-4.7' => 'Grok 4.7',
@@ -155,6 +156,7 @@ class AiService
'gpt-5.6-luna' => [0.20, 0.02, 1.20, 0.25], 'gpt-5.6-luna' => [0.20, 0.02, 1.20, 0.25],
'gpt-5.6-terra' => [2.00, 0.20, 12.00, 2.50], 'gpt-5.6-terra' => [2.00, 0.20, 12.00, 2.50],
'gpt-5.6-sol' => [4.00, 0.40, 20.00, 5.00], 'gpt-5.6-sol' => [4.00, 0.40, 20.00, 5.00],
'gpt-6-luna' => [0.10, 0.01, 0.50, 0.125],
]; ];
} }
@@ -12,6 +12,7 @@ use Joomla\CMS\Toolbar\ToolbarHelper;
class HtmlView extends BaseHtmlView class HtmlView extends BaseHtmlView
{ {
protected array $settings = []; protected array $settings = [];
protected array $usageTotals = [];
public function display($tpl = null) public function display($tpl = null)
{ {
@@ -24,6 +25,54 @@ class HtmlView extends BaseHtmlView
->where($db->quoteName('element') . ' = ' . $db->quote('com_testquestions')) ->where($db->quoteName('element') . ' = ' . $db->quote('com_testquestions'))
)->loadResult(); )->loadResult();
$this->settings = json_decode($raw, true) ?: []; $this->settings = json_decode($raw, true) ?: [];
$this->usageTotals = [
'openai' => ['calls' => 0, 'input_tokens' => 0, 'output_tokens' => 0, 'total_tokens' => 0, 'cost_usd' => 0.0, 'cost_calls' => 0],
'grok' => ['calls' => 0, 'input_tokens' => 0, 'output_tokens' => 0, 'total_tokens' => 0, 'cost_usd' => 0.0, 'cost_calls' => 0],
];
$usageRows = $db->setQuery(
$db->getQuery(true)
->select($db->quoteName('answers'))
->from($db->quoteName('#__testquestions_results'))
->where($db->quoteName('answers') . ' LIKE ' . $db->quote('%ai_usage%'))
)->loadColumn();
foreach ($usageRows as $answersJson) {
$answers = json_decode((string) $answersJson, true);
if (!is_array($answers)) {
continue;
}
foreach ($answers as $answer) {
if (!is_array($answer)) {
continue;
}
$usages = $answer['ai_usage_history'] ?? (isset($answer['ai_usage']) ? [$answer['ai_usage']] : []);
if (!is_array($usages)) {
continue;
}
foreach ($usages as $usage) {
if (!is_array($usage)) {
continue;
}
$provider = (string) ($usage['provider'] ?? '');
if (!isset($this->usageTotals[$provider])) {
continue;
}
$this->usageTotals[$provider]['calls']++;
$this->usageTotals[$provider]['input_tokens'] += (int) ($usage['input_tokens'] ?? 0);
$this->usageTotals[$provider]['output_tokens'] += (int) ($usage['output_tokens'] ?? 0);
$this->usageTotals[$provider]['total_tokens'] += (int) ($usage['total_tokens'] ?? 0);
if (is_numeric($usage['cost_usd'] ?? null)) {
$this->usageTotals[$provider]['cost_usd'] += (float) $usage['cost_usd'];
$this->usageTotals[$provider]['cost_calls']++;
}
}
}
}
ToolbarHelper::title(Text::_('COM_TESTQUESTIONS_AI_SETTINGS')); ToolbarHelper::title(Text::_('COM_TESTQUESTIONS_AI_SETTINGS'));
ToolbarHelper::link('index.php?option=com_testquestions&view=questions', 'COM_TESTQUESTIONS_QUESTIONS', 'arrow-left'); ToolbarHelper::link('index.php?option=com_testquestions&view=questions', 'COM_TESTQUESTIONS_QUESTIONS', 'arrow-left');
@@ -15,6 +15,7 @@ class HtmlView extends BaseHtmlView
protected $pagination; protected $pagination;
protected $state; protected $state;
protected $sets; protected $sets;
protected $aiUsageTotals;
public function display($tpl = null) public function display($tpl = null)
{ {
@@ -22,6 +23,7 @@ class HtmlView extends BaseHtmlView
$this->pagination = $this->get('Pagination'); $this->pagination = $this->get('Pagination');
$this->state = $this->get('State'); $this->state = $this->get('State');
$this->sets = $this->get('Sets'); $this->sets = $this->get('Sets');
$this->aiUsageTotals = $this->get('AiUsageTotals');
ToolbarHelper::title(Text::_('COM_TESTQUESTIONS_RESULTS')); ToolbarHelper::title(Text::_('COM_TESTQUESTIONS_RESULTS'));
ToolbarHelper::link('index.php?option=com_testquestions&view=sets', 'COM_TESTQUESTIONS_SETS', 'back'); ToolbarHelper::link('index.php?option=com_testquestions&view=sets', 'COM_TESTQUESTIONS_SETS', 'back');
@@ -2,6 +2,7 @@
<?php use Joomla\CMS\HTML\HTMLHelper; ?> <?php use Joomla\CMS\HTML\HTMLHelper; ?>
<?php use Joomla\CMS\Router\Route; ?> <?php use Joomla\CMS\Router\Route; ?>
<?php $availableModels = \Komponent\Component\Testquestions\Administrator\Service\AiService::availableModels(); ?> <?php $availableModels = \Komponent\Component\Testquestions\Administrator\Service\AiService::availableModels(); ?>
<?php $usageTotals = $this->usageTotals; ?>
<?php $provider = (string) ($this->settings['ai_provider'] ?? 'openai'); ?> <?php $provider = (string) ($this->settings['ai_provider'] ?? 'openai'); ?>
<?php $legacyKey = (string) ($this->settings['ai_api_key'] ?? ''); ?> <?php $legacyKey = (string) ($this->settings['ai_api_key'] ?? ''); ?>
<?php $openaiKey = (string) ($this->settings['ai_openai_api_key'] ?? ($provider === 'openai' ? $legacyKey : '')); ?> <?php $openaiKey = (string) ($this->settings['ai_openai_api_key'] ?? ($provider === 'openai' ? $legacyKey : '')); ?>
@@ -54,6 +55,37 @@
<?php endforeach; ?> <?php endforeach; ?>
</select> </select>
</div> </div>
<hr>
<h3><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_AI_TOKEN_USAGE'); ?></h3>
<p class="text-muted"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_AI_TOKEN_USAGE_INFO'); ?></p>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_AI_PROVIDER'); ?></th>
<th><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_AI_USAGE_CALLS'); ?></th>
<th><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_AI_USAGE_INPUT'); ?></th>
<th><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_AI_USAGE_OUTPUT'); ?></th>
<th><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_AI_USAGE_TOTAL'); ?></th>
<th><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_AI_USAGE_COST'); ?></th>
</tr>
</thead>
<tbody>
<?php foreach (['openai' => 'OpenAI', 'grok' => 'Grok'] as $usageProvider => $usageProviderLabel) : ?>
<?php $providerUsage = $usageTotals[$usageProvider]; ?>
<tr>
<th><?php echo $usageProviderLabel; ?></th>
<td><?php echo number_format($providerUsage['calls'], 0, ',', ' '); ?></td>
<td><?php echo number_format($providerUsage['input_tokens'], 0, ',', ' '); ?></td>
<td><?php echo number_format($providerUsage['output_tokens'], 0, ',', ' '); ?></td>
<td><?php echo number_format($providerUsage['total_tokens'], 0, ',', ' '); ?></td>
<td><?php echo $providerUsage['cost_calls'] > 0 ? number_format($providerUsage['cost_usd'], 8, ',', ' ') . ' USD' : '—'; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<hr>
<button type="submit" class="btn btn-primary" onclick="this.form.task.value='ai.save';"> <button type="submit" class="btn btn-primary" onclick="this.form.task.value='ai.save';">
<?php echo \Joomla\CMS\Language\Text::_('JTOOLBAR_SAVE'); ?> <?php echo \Joomla\CMS\Language\Text::_('JTOOLBAR_SAVE'); ?>
</button> </button>
@@ -33,6 +33,15 @@ use Joomla\CMS\Router\Route;
</div> </div>
<div class="col-md-3 align-self-end"><button type="submit" class="btn btn-primary"><?php echo \Joomla\CMS\Language\Text::_('JSEARCH_FILTER_SUBMIT'); ?></button></div> <div class="col-md-3 align-self-end"><button type="submit" class="btn btn-primary"><?php echo \Joomla\CMS\Language\Text::_('JSEARCH_FILTER_SUBMIT'); ?></button></div>
</div> </div>
<div class="alert alert-info" role="status">
<strong><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULTS_AI_TOKENS_TOTAL'); ?>:</strong>
<?php echo number_format((int) $this->aiUsageTotals['total_tokens'], 0, ',', ' '); ?> <?php echo $this->escape(\Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_AI_USAGE_TOTAL')); ?>
(<?php echo number_format((int) $this->aiUsageTotals['input_tokens'], 0, ',', ' '); ?> in /
<?php echo number_format((int) $this->aiUsageTotals['output_tokens'], 0, ',', ' '); ?> out)
<?php if ($this->aiUsageTotals['cost_usd'] > 0) : ?>
· <?php echo number_format((float) $this->aiUsageTotals['cost_usd'], 8, ',', ' '); ?> USD
<?php endif; ?>
</div>
<table class="table table-striped"> <table class="table table-striped">
<thead><tr> <thead><tr>
<th><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULT_PARTICIPANT'); ?></th> <th><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULT_PARTICIPANT'); ?></th>
@@ -41,6 +50,7 @@ use Joomla\CMS\Router\Route;
<th><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULT_GRADE'); ?></th> <th><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULT_GRADE'); ?></th>
<th><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULT_EXECUTION_TIME'); ?></th> <th><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULT_EXECUTION_TIME'); ?></th>
<th><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULT_DATE'); ?></th> <th><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULT_DATE'); ?></th>
<th><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULT_AI_TOKENS'); ?></th>
</tr></thead> </tr></thead>
<tbody> <tbody>
<?php foreach ($this->items as $item) : ?> <?php foreach ($this->items as $item) : ?>
@@ -58,6 +68,18 @@ use Joomla\CMS\Router\Route;
<td><?php echo $this->escape($grade); ?></td> <td><?php echo $this->escape($grade); ?></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>
<?php if ($item->ai_total_tokens > 0) : ?>
<?php echo number_format((int) $item->ai_total_tokens, 0, ',', ' '); ?> <?php echo $this->escape(\Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_AI_USAGE_TOTAL')); ?>
<small class="d-block text-muted">
<?php echo number_format((int) $item->ai_input_tokens, 0, ',', ' '); ?> in /
<?php echo number_format((int) $item->ai_output_tokens, 0, ',', ' '); ?> out
<?php if ($item->ai_cost_usd > 0) : ?> · <?php echo number_format((float) $item->ai_cost_usd, 8, ',', ' '); ?> USD<?php endif; ?>
</small>
<?php else : ?>
—
<?php endif; ?>
</td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>
</tbody> </tbody>
+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.5</version> <version>1.43.10</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>