From 8abee59a49d9fc4d43bedc0b0acdb71c1d0e86c6 Mon Sep 17 00:00:00 2001 From: Wojtek Date: Fri, 16 Oct 2026 10:21:52 +0200 Subject: [PATCH] Remove questions from parent multi-variant sets --- README.md | 2 +- .../com_testquestions/language/en-GB/com_testquestions.ini | 1 + .../com_testquestions/sql/updates/mysql/1.36.0.sql | 1 + .../components/com_testquestions/src/Model/SetModel.php | 4 ++++ .../components/com_testquestions/tmpl/set/edit.php | 6 ++++++ com_testquestions.xml | 2 +- 6 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 administrator/components/com_testquestions/sql/updates/mysql/1.36.0.sql diff --git a/README.md b/README.md index fdb8c78..c9769a6 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.35.0). +W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.36.0). 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 32a40df..4c4ce75 100644 --- a/administrator/components/com_testquestions/language/en-GB/com_testquestions.ini +++ b/administrator/components/com_testquestions/language/en-GB/com_testquestions.ini @@ -57,6 +57,7 @@ COM_TESTQUESTIONS_SET_VARIANTS="Warianty zestawu" COM_TESTQUESTIONS_SET_ADD_VARIANT="Dodaj wariant" COM_TESTQUESTIONS_SET_PARENT="Zestaw nadrzędny" COM_TESTQUESTIONS_SET_NO_VARIANTS="Brak wariantów" +COM_TESTQUESTIONS_SET_MULTI_QUESTIONS_INFO="Pytania są dodawane w poszczególnych wariantach zestawu." COM_TESTQUESTIONS_SET_DESCRIPTION="Opis zestawu" COM_TESTQUESTIONS_SET_QUESTIONS="Pytania w zestawie" COM_TESTQUESTIONS_SET_QUESTION_COUNT="Liczba pytań" diff --git a/administrator/components/com_testquestions/sql/updates/mysql/1.36.0.sql b/administrator/components/com_testquestions/sql/updates/mysql/1.36.0.sql new file mode 100644 index 0000000..d053447 --- /dev/null +++ b/administrator/components/com_testquestions/sql/updates/mysql/1.36.0.sql @@ -0,0 +1 @@ +-- No database changes required for version 1.36.0. diff --git a/administrator/components/com_testquestions/src/Model/SetModel.php b/administrator/components/com_testquestions/src/Model/SetModel.php index 6b31019..7ae6d5b 100644 --- a/administrator/components/com_testquestions/src/Model/SetModel.php +++ b/administrator/components/com_testquestions/src/Model/SetModel.php @@ -137,6 +137,10 @@ class SetModel extends AdminModel $data['set_type'] = 'ordinary'; } + if ($parentId === 0 && ($data['set_type'] ?? 'ordinary') === 'multi') { + $questionIds = []; + } + if (!parent::save($data)) { return false; } diff --git a/administrator/components/com_testquestions/tmpl/set/edit.php b/administrator/components/com_testquestions/tmpl/set/edit.php index 1c110a3..a7f2f0f 100644 --- a/administrator/components/com_testquestions/tmpl/set/edit.php +++ b/administrator/components/com_testquestions/tmpl/set/edit.php @@ -44,6 +44,7 @@ HTMLHelper::_('behavior.formvalidator'); + item->set_type === 'multi' && (int) $this->item->parent_id === 0)) : ?>
@@ -109,6 +110,11 @@ HTMLHelper::_('behavior.formvalidator');
+ +
+ +
+ diff --git a/com_testquestions.xml b/com_testquestions.xml index 995ee2c..b248fe7 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.35.0 + 1.36.0 COM_TESTQUESTIONS_DESCRIPTION com_testquestions Komponent\Component\Testquestions