diff --git a/README.md b/README.md index f3d82a7..c3c8da5 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.38.0). +W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.39.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 8c9f437..75fdc3a 100644 --- a/administrator/components/com_testquestions/language/en-GB/com_testquestions.ini +++ b/administrator/components/com_testquestions/language/en-GB/com_testquestions.ini @@ -60,6 +60,7 @@ 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_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_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.39.0.sql b/administrator/components/com_testquestions/sql/updates/mysql/1.39.0.sql new file mode 100644 index 0000000..f6d000a --- /dev/null +++ b/administrator/components/com_testquestions/sql/updates/mysql/1.39.0.sql @@ -0,0 +1 @@ +-- No database changes required for version 1.39.0. diff --git a/administrator/components/com_testquestions/src/Model/SetModel.php b/administrator/components/com_testquestions/src/Model/SetModel.php index 7ae6d5b..6ad56cc 100644 --- a/administrator/components/com_testquestions/src/Model/SetModel.php +++ b/administrator/components/com_testquestions/src/Model/SetModel.php @@ -133,6 +133,10 @@ class SetModel extends AdminModel if ($parentId > 0) { $data['set_type'] = 'variant'; + $parent = $this->getItem($parentId); + if ($parent) { + $data['duration'] = (int) $parent->duration; + } } elseif (!in_array(($data['set_type'] ?? 'ordinary'), ['ordinary', 'multi'], true)) { $data['set_type'] = 'ordinary'; } diff --git a/administrator/components/com_testquestions/src/View/Set/HtmlView.php b/administrator/components/com_testquestions/src/View/Set/HtmlView.php index 6787456..a1b02bc 100644 --- a/administrator/components/com_testquestions/src/View/Set/HtmlView.php +++ b/administrator/components/com_testquestions/src/View/Set/HtmlView.php @@ -4,6 +4,7 @@ namespace Komponent\Component\Testquestions\Administrator\View\Set; defined('_JEXEC') or die; +use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; use Joomla\CMS\Toolbar\ToolbarHelper; @@ -15,6 +16,8 @@ class HtmlView extends BaseHtmlView protected $questions; protected $categories; protected $variants; + protected $isVariant; + protected $parentTitle = ''; public function display($tpl = null) { @@ -23,6 +26,14 @@ class HtmlView extends BaseHtmlView $this->questions = $this->get('Questions'); $this->categories = $this->get('Categories'); $this->variants = $this->item && (int) $this->item->id > 0 ? $this->get('Variants') : []; + $parentId = Factory::getApplication()->getInput()->getInt('parent_id'); + $this->isVariant = (int) ($this->item->parent_id ?? 0) > 0 || $parentId > 0; + $this->parentTitle = (string) ($this->item->parent_title ?? ''); + + if ($this->isVariant && $this->parentTitle === '' && $parentId > 0) { + $parent = $this->getModel()->getItem($parentId); + $this->parentTitle = (string) ($parent->title ?? ''); + } 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 a7f2f0f..c670476 100644 --- a/administrator/components/com_testquestions/tmpl/set/edit.php +++ b/administrator/components/com_testquestions/tmpl/set/edit.php @@ -10,16 +10,20 @@ HTMLHelper::_('behavior.formvalidator');