diff --git a/README.md b/README.md index df36064..5a30495 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.12). +W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.43.13). 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 c11ada5..3927458 100644 --- a/administrator/components/com_testquestions/language/en-GB/com_testquestions.ini +++ b/administrator/components/com_testquestions/language/en-GB/com_testquestions.ini @@ -65,6 +65,7 @@ COM_TESTQUESTIONS_SET_REORDER_INFO="Przeciągnij pytania, aby zmienić ich kolej COM_TESTQUESTIONS_SET_SAVE="Zapisz" COM_TESTQUESTIONS_SET_SAVE_AND_CLOSE="Zapisz i zamknij" COM_TESTQUESTIONS_SET_VARIANT_DURATION_INFO="Czas testu jest pobierany z zestawu nadrzędnego." +COM_TESTQUESTIONS_SET_VARIANT_STATUS_INHERITED="Status publikacji wariantu jest taki sam jak status zestawu nadrzędnego i zmienia się razem z nim." COM_TESTQUESTIONS_AI_SETTINGS="Ustawienia AI" COM_TESTQUESTIONS_AI_PROVIDER="Dostawca AI" COM_TESTQUESTIONS_AI_API_KEY="Klucz API" diff --git a/administrator/components/com_testquestions/sql/updates/mysql/1.43.13.sql b/administrator/components/com_testquestions/sql/updates/mysql/1.43.13.sql new file mode 100644 index 0000000..c51e8bc --- /dev/null +++ b/administrator/components/com_testquestions/sql/updates/mysql/1.43.13.sql @@ -0,0 +1 @@ +-- No database changes required for version 1.43.13. diff --git a/administrator/components/com_testquestions/src/Model/SetModel.php b/administrator/components/com_testquestions/src/Model/SetModel.php index 6ad56cc..edbe6ce 100644 --- a/administrator/components/com_testquestions/src/Model/SetModel.php +++ b/administrator/components/com_testquestions/src/Model/SetModel.php @@ -9,6 +9,26 @@ use Joomla\CMS\MVC\Model\AdminModel; class SetModel extends AdminModel { + public function publish(&$pks, $value = 1) + { + $ids = array_values(array_unique(array_filter(array_map('intval', (array) $pks)))); + if (!parent::publish($pks, $value)) { + return false; + } + + if ($ids) { + $db = Factory::getContainer()->get('DatabaseDriver'); + $db->setQuery( + $db->getQuery(true) + ->update($db->quoteName('#__testquestions_sets')) + ->set($db->quoteName('published') . ' = ' . (int) $value) + ->where($db->quoteName('parent_id') . ' IN (' . implode(',', $ids) . ')') + )->execute(); + } + + return true; + } + public function getTable($name = 'Set', $prefix = 'Administrator', $config = []) { return $this->getMVCFactory()->createTable($name, $prefix, $config); @@ -136,6 +156,7 @@ class SetModel extends AdminModel $parent = $this->getItem($parentId); if ($parent) { $data['duration'] = (int) $parent->duration; + $data['published'] = (int) $parent->published; } } elseif (!in_array(($data['set_type'] ?? 'ordinary'), ['ordinary', 'multi'], true)) { $data['set_type'] = 'ordinary'; @@ -151,6 +172,15 @@ class SetModel extends AdminModel $setId = (int) $this->getState($this->getName() . '.id'); $db = Factory::getContainer()->get('DatabaseDriver'); + if ($parentId === 0) { + $db->setQuery( + $db->getQuery(true) + ->update($db->quoteName('#__testquestions_sets')) + ->set($db->quoteName('published') . ' = ' . (int) ($data['published'] ?? 1)) + ->where($db->quoteName('parent_id') . ' = ' . $setId) + )->execute(); + } + $db->setQuery( $db->getQuery(true) ->delete($db->quoteName('#__testquestions_set_questions')) diff --git a/administrator/components/com_testquestions/tmpl/set/edit.php b/administrator/components/com_testquestions/tmpl/set/edit.php index a24b079..25c76ce 100644 --- a/administrator/components/com_testquestions/tmpl/set/edit.php +++ b/administrator/components/com_testquestions/tmpl/set/edit.php @@ -28,7 +28,11 @@ HTMLHelper::_('behavior.formvalidator'); form->renderField('test_content'); ?> form->renderField('image'); ?> form->renderField('description'); ?> - form->renderField('published'); ?> + isVariant) : ?> +
+ + form->renderField('published'); ?> + item->id > 0 && (string) $this->item->set_type === 'multi') : ?>