diff --git a/README.md b/README.md index 5e34f9e..32db2f8 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.0). +W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.9.1). Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**. diff --git a/administrator/components/com_testquestions/forms/set.xml b/administrator/components/com_testquestions/forms/set.xml index c00c396..86c558d 100644 --- a/administrator/components/com_testquestions/forms/set.xml +++ b/administrator/components/com_testquestions/forms/set.xml @@ -8,6 +8,5 @@ - 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 3bcacb5..db5955a 100644 --- a/administrator/components/com_testquestions/language/en-GB/com_testquestions.ini +++ b/administrator/components/com_testquestions/language/en-GB/com_testquestions.ini @@ -53,3 +53,6 @@ COM_TESTQUESTIONS_SET_DESCRIPTION="Opis zestawu" COM_TESTQUESTIONS_SET_QUESTIONS="Pytania w zestawie" COM_TESTQUESTIONS_SET_QUESTION_COUNT="Liczba pytań" 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" diff --git a/administrator/components/com_testquestions/sql/updates/mysql/1.9.1.sql b/administrator/components/com_testquestions/sql/updates/mysql/1.9.1.sql new file mode 100644 index 0000000..b99a024 --- /dev/null +++ b/administrator/components/com_testquestions/sql/updates/mysql/1.9.1.sql @@ -0,0 +1 @@ +-- No database changes required for version 1.9.1. diff --git a/administrator/components/com_testquestions/src/Model/SetModel.php b/administrator/components/com_testquestions/src/Model/SetModel.php index 8541963..5cf1102 100644 --- a/administrator/components/com_testquestions/src/Model/SetModel.php +++ b/administrator/components/com_testquestions/src/Model/SetModel.php @@ -44,6 +44,31 @@ class SetModel extends AdminModel return Factory::getApplication()->getUserState('com_testquestions.edit.set.data', []) ?: $this->getItem(); } + public function getQuestions() + { + $db = Factory::getContainer()->get('DatabaseDriver'); + + return $db->setQuery( + $db->getQuery(true) + ->select(['q.id', 'q.question', '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') + )->loadObjectList(); + } + + public function getCategories() + { + $db = Factory::getContainer()->get('DatabaseDriver'); + + return $db->setQuery( + $db->getQuery(true) + ->select(['id', 'title']) + ->from($db->quoteName('#__testquestions_categories')) + ->order($db->quoteName('title') . ' ASC') + )->loadObjectList(); + } + public function save($data) { $questionIds = array_values(array_unique(array_filter(array_map('intval', (array) ($data['question_ids'] ?? []))))); diff --git a/administrator/components/com_testquestions/src/View/Set/HtmlView.php b/administrator/components/com_testquestions/src/View/Set/HtmlView.php index ec98694..4b740c0 100644 --- a/administrator/components/com_testquestions/src/View/Set/HtmlView.php +++ b/administrator/components/com_testquestions/src/View/Set/HtmlView.php @@ -12,11 +12,15 @@ class HtmlView extends BaseHtmlView { protected $form; protected $item; + protected $questions; + protected $categories; public function display($tpl = null) { $this->form = $this->get('Form'); $this->item = $this->get('Item'); + $this->questions = $this->get('Questions'); + $this->categories = $this->get('Categories'); if (count($errors = $this->get('Errors'))) { throw new \RuntimeException(implode("\n", $errors)); diff --git a/administrator/components/com_testquestions/tmpl/set/edit.php b/administrator/components/com_testquestions/tmpl/set/edit.php index df01429..c5f54e2 100644 --- a/administrator/components/com_testquestions/tmpl/set/edit.php +++ b/administrator/components/com_testquestions/tmpl/set/edit.php @@ -12,8 +12,46 @@ HTMLHelper::_('behavior.formvalidator'); form->renderField('title'); ?> form->renderField('description'); ?> form->renderField('published'); ?> - form->renderField('question_ids'); ?> +
+ + +
+
+ +
+ questions as $question) : ?> +
+ id, (array) $this->item->question_ids, true) ? 'checked' : ''; ?>> + +
+ +
+
+ diff --git a/com_testquestions.xml b/com_testquestions.xml index 8388d53..a929c2e 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.0 + 1.9.1 COM_TESTQUESTIONS_DESCRIPTION com_testquestions Komponent\Component\Testquestions