diff --git a/README.md b/README.md index 187a625..02d5929 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.40.0). +W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.41.0). Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**. diff --git a/administrator/components/com_testquestions/sql/updates/mysql/1.41.0.sql b/administrator/components/com_testquestions/sql/updates/mysql/1.41.0.sql new file mode 100644 index 0000000..1c95464 --- /dev/null +++ b/administrator/components/com_testquestions/sql/updates/mysql/1.41.0.sql @@ -0,0 +1 @@ +-- No database changes required for version 1.41.0. diff --git a/administrator/components/com_testquestions/tmpl/set/edit.php b/administrator/components/com_testquestions/tmpl/set/edit.php index 119169b..a24b079 100644 --- a/administrator/components/com_testquestions/tmpl/set/edit.php +++ b/administrator/components/com_testquestions/tmpl/set/edit.php @@ -8,7 +8,7 @@ use Joomla\CMS\Router\Route; HTMLHelper::_('behavior.formvalidator'); ?>
- isVariant && (string) $this->item->set_type === 'ordinary'; ?> + isVariant || (string) $this->item->set_type === 'ordinary'; ?>
form->renderField('parent_id'); ?> isVariant) : ?> diff --git a/com_testquestions.xml b/com_testquestions.xml index cf78334..e914112 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.40.0 + 1.41.0 COM_TESTQUESTIONS_DESCRIPTION com_testquestions Komponent\Component\Testquestions diff --git a/components/com_testquestions/src/Model/SetModel.php b/components/com_testquestions/src/Model/SetModel.php index 7d75d95..bf5a52b 100644 --- a/components/com_testquestions/src/Model/SetModel.php +++ b/components/com_testquestions/src/Model/SetModel.php @@ -10,6 +10,7 @@ use Joomla\CMS\MVC\Model\BaseDatabaseModel; class SetModel extends BaseDatabaseModel { protected $resolvedSetId; + protected $randomizeQuestions = true; protected function getSetId(): int { @@ -44,6 +45,7 @@ class SetModel extends BaseDatabaseModel } $this->resolvedSetId = $setId; + $this->randomizeQuestions = $set->set_type !== 'multi'; if ($set->set_type === 'multi') { $variantId = (int) $db->setQuery( @@ -74,15 +76,16 @@ class SetModel extends BaseDatabaseModel return []; } - return $db->setQuery( - $db->getQuery(true) + $query = $db->getQuery(true) ->select(['q.id', 'q.question_type', 'q.question', 'q.answer_a', 'q.answer_b', 'q.answer_c', 'q.answer_d', 'q.answer_open', 'q.correct_answer', 'q.points', 'q.image']) ->from($db->quoteName('#__testquestions_set_questions', 'sq')) ->innerJoin($db->quoteName('#__testquestions_questions', 'q') . ' ON q.id = sq.question_id') ->where('sq.set_id = ' . $setId) - ->where('q.published = 1') - ->order('RAND()') - )->loadObjectList(); + ->where('q.published = 1'); + + $query->order($this->randomizeQuestions ? 'RAND()' : 'sq.ordering ASC, q.id ASC'); + + return $db->setQuery($query)->loadObjectList(); } public function getSets()