Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bf05c9515c |
@@ -30,6 +30,6 @@ Szkielet komponentu Joomla 6 do gromadzenia pytań testowych.
|
||||
|
||||
## Instalacja
|
||||
|
||||
W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.43.10).
|
||||
W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.43.11).
|
||||
|
||||
Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**.
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
-- No database changes required for version 1.43.11.
|
||||
@@ -18,6 +18,7 @@ class ResultsModel extends ListModel
|
||||
$item->ai_output_tokens = 0;
|
||||
$item->ai_total_tokens = 0;
|
||||
$item->ai_cost_usd = 0.0;
|
||||
$item->ai_tokens_by_provider = ['openai' => 0, 'grok' => 0];
|
||||
|
||||
$answers = json_decode((string) ($item->answers ?? ''), true);
|
||||
if (!is_array($answers)) {
|
||||
@@ -41,6 +42,10 @@ class ResultsModel extends ListModel
|
||||
$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);
|
||||
$provider = (string) ($usage['provider'] ?? '');
|
||||
if (isset($item->ai_tokens_by_provider[$provider])) {
|
||||
$item->ai_tokens_by_provider[$provider] += (int) ($usage['total_tokens'] ?? 0);
|
||||
}
|
||||
if (is_numeric($usage['cost_usd'] ?? null)) {
|
||||
$item->ai_cost_usd += (float) $usage['cost_usd'];
|
||||
}
|
||||
@@ -57,7 +62,14 @@ class ResultsModel extends ListModel
|
||||
$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];
|
||||
$emptyProviderTotals = ['input_tokens' => 0, 'output_tokens' => 0, 'total_tokens' => 0, 'cost_usd' => 0.0];
|
||||
$totals = [
|
||||
'input_tokens' => 0,
|
||||
'output_tokens' => 0,
|
||||
'total_tokens' => 0,
|
||||
'cost_usd' => 0.0,
|
||||
'providers' => ['openai' => $emptyProviderTotals, 'grok' => $emptyProviderTotals],
|
||||
];
|
||||
|
||||
foreach ($answersRows as $answersJson) {
|
||||
$answers = json_decode((string) $answersJson, true);
|
||||
@@ -82,6 +94,15 @@ class ResultsModel extends ListModel
|
||||
if (is_numeric($usage['cost_usd'] ?? null)) {
|
||||
$totals['cost_usd'] += (float) $usage['cost_usd'];
|
||||
}
|
||||
$provider = (string) ($usage['provider'] ?? '');
|
||||
if (isset($totals['providers'][$provider])) {
|
||||
$totals['providers'][$provider]['input_tokens'] += (int) ($usage['input_tokens'] ?? 0);
|
||||
$totals['providers'][$provider]['output_tokens'] += (int) ($usage['output_tokens'] ?? 0);
|
||||
$totals['providers'][$provider]['total_tokens'] += (int) ($usage['total_tokens'] ?? 0);
|
||||
if (is_numeric($usage['cost_usd'] ?? null)) {
|
||||
$totals['providers'][$provider]['cost_usd'] += (float) $usage['cost_usd'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,13 +34,22 @@ use Joomla\CMS\Router\Route;
|
||||
<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 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; ?>
|
||||
<strong><?php echo $this->escape(\Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULTS_AI_TOKENS_TOTAL')); ?>:</strong>
|
||||
<span class="d-block">
|
||||
<strong>OpenAI:</strong>
|
||||
<?php echo number_format((int) $this->aiUsageTotals['providers']['openai']['total_tokens'], 0, ',', ' '); ?> tokenów
|
||||
(<?php echo number_format((int) $this->aiUsageTotals['providers']['openai']['input_tokens'], 0, ',', ' '); ?> wej. /
|
||||
<?php echo number_format((int) $this->aiUsageTotals['providers']['openai']['output_tokens'], 0, ',', ' '); ?> wyj.)
|
||||
<?php if ($this->aiUsageTotals['providers']['openai']['cost_usd'] > 0) : ?> · <?php echo number_format((float) $this->aiUsageTotals['providers']['openai']['cost_usd'], 8, ',', ' '); ?> USD<?php endif; ?>
|
||||
</span>
|
||||
<span class="d-block">
|
||||
<strong>Grok:</strong>
|
||||
<?php echo number_format((int) $this->aiUsageTotals['providers']['grok']['total_tokens'], 0, ',', ' '); ?> tokenów
|
||||
(<?php echo number_format((int) $this->aiUsageTotals['providers']['grok']['input_tokens'], 0, ',', ' '); ?> wej. /
|
||||
<?php echo number_format((int) $this->aiUsageTotals['providers']['grok']['output_tokens'], 0, ',', ' '); ?> wyj.)
|
||||
<?php if ($this->aiUsageTotals['providers']['grok']['cost_usd'] > 0) : ?> · <?php echo number_format((float) $this->aiUsageTotals['providers']['grok']['cost_usd'], 8, ',', ' '); ?> USD<?php endif; ?>
|
||||
</span>
|
||||
<span class="d-block"><strong>Łącznie:</strong> <?php echo number_format((int) $this->aiUsageTotals['total_tokens'], 0, ',', ' '); ?> tokenów</span>
|
||||
</div>
|
||||
<table class="table table-striped">
|
||||
<thead><tr>
|
||||
@@ -70,10 +79,12 @@ use Joomla\CMS\Router\Route;
|
||||
<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
|
||||
OpenAI: <?php echo number_format((int) $item->ai_tokens_by_provider['openai'], 0, ',', ' '); ?> ·
|
||||
Grok: <?php echo number_format((int) $item->ai_tokens_by_provider['grok'], 0, ',', ' '); ?>
|
||||
</small>
|
||||
<small class="d-block text-muted">
|
||||
<?php echo number_format((int) $item->ai_total_tokens, 0, ',', ' '); ?> łącznie
|
||||
<?php if ($item->ai_cost_usd > 0) : ?> · <?php echo number_format((float) $item->ai_cost_usd, 8, ',', ' '); ?> USD<?php endif; ?>
|
||||
</small>
|
||||
<?php else : ?>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<creationDate>2026-10-14</creationDate>
|
||||
<author>Komponent</author>
|
||||
<license>GNU General Public License version 2 or later</license>
|
||||
<version>1.43.10</version>
|
||||
<version>1.43.11</version>
|
||||
<description>COM_TESTQUESTIONS_DESCRIPTION</description>
|
||||
<element>com_testquestions</element>
|
||||
<namespace path="src">Komponent\Component\Testquestions</namespace>
|
||||
|
||||
Reference in New Issue
Block a user