diff --git a/README.md b/README.md index a12dd7a..81695a4 100644 --- a/README.md +++ b/README.md @@ -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.42.5). +W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.42.6). Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**. diff --git a/administrator/components/com_testquestions/sql/updates/mysql/1.42.6.sql b/administrator/components/com_testquestions/sql/updates/mysql/1.42.6.sql new file mode 100644 index 0000000..76a0f3f --- /dev/null +++ b/administrator/components/com_testquestions/sql/updates/mysql/1.42.6.sql @@ -0,0 +1 @@ +-- No database changes required for version 1.42.6. diff --git a/administrator/components/com_testquestions/src/Service/AiService.php b/administrator/components/com_testquestions/src/Service/AiService.php index 6b13b35..287da2d 100644 --- a/administrator/components/com_testquestions/src/Service/AiService.php +++ b/administrator/components/com_testquestions/src/Service/AiService.php @@ -11,14 +11,19 @@ class AiService public function evaluate(string $provider, string $apiKey, string $question, string $answer, string $pattern): string { $provider = strtolower(trim($provider)); + $provider = preg_replace('/[^a-z]/', '', $provider); $config = $provider === 'grok' ? ['url' => 'https://api.x.ai/v1/responses', 'model' => 'grok-4.7'] : ['url' => 'https://api.openai.com/v1/responses', 'model' => 'gpt-4.1-mini']; - if (!in_array($provider, ['openai', 'grok'], true) || trim($apiKey) === '') { + if (trim($apiKey) === '') { throw new \RuntimeException('AI_NOT_CONFIGURED'); } + if (!in_array($provider, ['openai', 'grok'], true)) { + throw new \RuntimeException('Nieprawidłowy dostawca AI: ' . $provider); + } + $input = "Oceń odpowiedź ucznia na pytanie otwarte.\n\n" . "Pytanie:\n" . $question . "\n\n" . "Wzorzec odpowiedzi:\n" . $pattern . "\n\n" diff --git a/com_testquestions.xml b/com_testquestions.xml index ea0150f..1a56bee 100644 --- a/com_testquestions.xml +++ b/com_testquestions.xml @@ -4,7 +4,7 @@ 2026-10-14 Komponent GNU General Public License version 2 or later - 1.42.5 + 1.42.6 COM_TESTQUESTIONS_DESCRIPTION com_testquestions Komponent\Component\Testquestions