diff --git a/README.md b/README.md index 59ae10b..f75c8ad 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.43.21). +W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.43.22). Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**. diff --git a/administrator/components/com_testquestions/sql/updates/mysql/1.43.22.sql b/administrator/components/com_testquestions/sql/updates/mysql/1.43.22.sql new file mode 100644 index 0000000..45b22ee --- /dev/null +++ b/administrator/components/com_testquestions/sql/updates/mysql/1.43.22.sql @@ -0,0 +1 @@ +-- Wydanie 1.43.22: kolejność odpowiedzi zamkniętych jest losowana i zapisywana dla podejścia. diff --git a/com_testquestions.xml b/com_testquestions.xml index ce84d55..9a441e5 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.43.21 + 1.43.22 COM_TESTQUESTIONS_DESCRIPTION com_testquestions Komponent\Component\Testquestions diff --git a/components/com_testquestions/src/View/Set/HtmlView.php b/components/com_testquestions/src/View/Set/HtmlView.php index 7aa058d..1fd5c40 100644 --- a/components/com_testquestions/src/View/Set/HtmlView.php +++ b/components/com_testquestions/src/View/Set/HtmlView.php @@ -51,6 +51,7 @@ class HtmlView extends BaseHtmlView } $answers = (array) $input->post->get('answers', [], 'array'); + $submittedAnswerOrder = (array) $input->post->get('answer_order', [], 'array'); $results = []; $correct = 0; @@ -70,6 +71,14 @@ class HtmlView extends BaseHtmlView $isCorrect = (string) $item->correct_answer === $selected; } + $answerOrder = array_map('intval', explode(',', (string) ($submittedAnswerOrder[$item->id] ?? ''))); + sort($answerOrder); + if ($item->question_type !== 'closed' || $answerOrder !== [1, 2, 3, 4]) { + $answerOrder = [1, 2, 3, 4]; + } else { + $answerOrder = array_map('intval', explode(',', (string) $submittedAnswerOrder[$item->id])); + } + if ($isCorrect) { $correct++; } @@ -78,6 +87,7 @@ class HtmlView extends BaseHtmlView 'selected' => $selected, 'correct' => $isCorrect, 'points' => (int) ($item->points ?? 0), + 'answer_order' => $answerOrder, ]; } diff --git a/components/com_testquestions/tmpl/set/default.php b/components/com_testquestions/tmpl/set/default.php index 2ad74c5..5fb7395 100644 --- a/components/com_testquestions/tmpl/set/default.php +++ b/components/com_testquestions/tmpl/set/default.php @@ -85,6 +85,14 @@ $resolveImageUrl = static function ($path) { items) : ?>
items as $number => $item) : ?> + results && !empty($this->results['items'][$item->id]['answer_order']) + ? $this->results['items'][$item->id]['answer_order'] + : [1, 2, 3, 4]; + if (!$this->results && $item->question_type === 'closed') { + shuffle($answerOrder); + } + ?>
question; ?>
image) : ?>
@@ -99,12 +107,14 @@ $resolveImageUrl = static function ($path) { + results) : ?>
    - $answerField) : ?> - results && $this->results['items'][$item->id]['selected'] === (string) ($answerIndex + 1); ?> - results && (string) $item->correct_answer === (string) ($answerIndex + 1); ?> + $optionValue) : ?> + + results && $this->results['items'][$item->id]['selected'] === (string) $optionValue; ?> + results && (string) $item->correct_answer === (string) $optionValue; ?>
  1. - +