From d09360e587c8c6c7f552b40b986598fffdf148f9 Mon Sep 17 00:00:00 2001 From: Wojtek Date: Thu, 15 Oct 2026 16:39:00 +0200 Subject: [PATCH] Fix set question saving and add previews --- README.md | 2 +- .../language/en-GB/com_testquestions.ini | 1 + .../com_testquestions/sql/updates/mysql/1.9.2.sql | 1 + .../com_testquestions/src/Model/SetModel.php | 5 +++-- .../components/com_testquestions/tmpl/set/edit.php | 14 ++++++++++++++ com_testquestions.xml | 2 +- 6 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 administrator/components/com_testquestions/sql/updates/mysql/1.9.2.sql diff --git a/README.md b/README.md index 32db2f8..5373cc5 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,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.9.1). +W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.9.2). Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**. diff --git a/administrator/components/com_testquestions/language/en-GB/com_testquestions.ini b/administrator/components/com_testquestions/language/en-GB/com_testquestions.ini index db5955a..f74d53c 100644 --- a/administrator/components/com_testquestions/language/en-GB/com_testquestions.ini +++ b/administrator/components/com_testquestions/language/en-GB/com_testquestions.ini @@ -56,3 +56,4 @@ COM_TESTQUESTIONS_SET_SEARCH="Szukaj zestawów..." COM_TESTQUESTIONS_SET_CATEGORY_FILTER="Filtruj pytania według kategorii" COM_TESTQUESTIONS_SET_ALL_CATEGORIES="Wszystkie kategorie" COM_TESTQUESTIONS_UNCATEGORIZED="Bez kategorii" +COM_TESTQUESTIONS_SET_SHOW_DETAILS="Pokaż pytanie i odpowiedzi" diff --git a/administrator/components/com_testquestions/sql/updates/mysql/1.9.2.sql b/administrator/components/com_testquestions/sql/updates/mysql/1.9.2.sql new file mode 100644 index 0000000..e0ac6a4 --- /dev/null +++ b/administrator/components/com_testquestions/sql/updates/mysql/1.9.2.sql @@ -0,0 +1 @@ +-- No database changes required for version 1.9.2. diff --git a/administrator/components/com_testquestions/src/Model/SetModel.php b/administrator/components/com_testquestions/src/Model/SetModel.php index 5cf1102..8d23a12 100644 --- a/administrator/components/com_testquestions/src/Model/SetModel.php +++ b/administrator/components/com_testquestions/src/Model/SetModel.php @@ -50,7 +50,7 @@ class SetModel extends AdminModel return $db->setQuery( $db->getQuery(true) - ->select(['q.id', 'q.question', 'q.category_id', 'c.title AS category_title']) + ->select(['q.id', 'q.question', 'q.question_type', 'q.answer_a', 'q.answer_b', 'q.answer_c', 'q.answer_d', 'q.answer_open', 'q.correct_answer', 'q.category_id', 'c.title AS category_title']) ->from($db->quoteName('#__testquestions_questions', 'q')) ->leftJoin($db->quoteName('#__testquestions_categories', 'c') . ' ON c.id = q.category_id') ->order('c.title ASC, q.ordering ASC, q.id ASC') @@ -71,7 +71,8 @@ class SetModel extends AdminModel public function save($data) { - $questionIds = array_values(array_unique(array_filter(array_map('intval', (array) ($data['question_ids'] ?? []))))); + $formData = Factory::getApplication()->getInput()->post->get('jform', [], 'array'); + $questionIds = array_values(array_unique(array_filter(array_map('intval', (array) ($formData['question_ids'] ?? $data['question_ids'] ?? []))))); unset($data['question_ids']); if (!parent::save($data)) { diff --git a/administrator/components/com_testquestions/tmpl/set/edit.php b/administrator/components/com_testquestions/tmpl/set/edit.php index c5f54e2..3bd7666 100644 --- a/administrator/components/com_testquestions/tmpl/set/edit.php +++ b/administrator/components/com_testquestions/tmpl/set/edit.php @@ -31,6 +31,20 @@ HTMLHelper::_('behavior.formvalidator'); escape($question->category_title ?: \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_UNCATEGORIZED')); ?> escape(trim(strip_tags($question->question))); ?> +
+ +
+
question; ?>
+ question_type === 'open') : ?> +
: escape($question->answer_open); ?>
+ +
A: answer_a; ?>correct_answer === 1 ? ' ✓' : ''; ?>
+
B: answer_b; ?>correct_answer === 2 ? ' ✓' : ''; ?>
+
C: answer_c; ?>correct_answer === 3 ? ' ✓' : ''; ?>
+
D: answer_d; ?>correct_answer === 4 ? ' ✓' : ''; ?>
+ +
+
diff --git a/com_testquestions.xml b/com_testquestions.xml index a929c2e..2d749d5 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.9.1 + 1.9.2 COM_TESTQUESTIONS_DESCRIPTION com_testquestions Komponent\Component\Testquestions