diff --git a/administrator/components/com_testquestions/tmpl/sets/default.php b/administrator/components/com_testquestions/tmpl/sets/default.php
index da884bb..5dc8b0b 100644
--- a/administrator/components/com_testquestions/tmpl/sets/default.php
+++ b/administrator/components/com_testquestions/tmpl/sets/default.php
@@ -38,6 +38,7 @@ HTMLHelper::_('behavior.multiselect');
|
|
+ |
|
|
|
@@ -48,7 +49,8 @@ HTMLHelper::_('behavior.multiselect');
items as $i => $item) : ?>
| id); ?> |
- escape($item->title); ?> |
+ parent_id > 0 ? '↳ ' : ''; ?>escape($item->title); ?>parent_id > 0 && $item->parent_title) : ?> (escape($item->parent_title); ?>) |
+ escape($item->set_type === 'multi' ? \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_SET_TYPE_MULTI') : ($item->set_type === 'variant' ? \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_SET_TYPE_VARIANT') : \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_SET_TYPE_ORDINARY'))); ?> |
escape($item->subject_title ?: '—'); ?> |
question_count; ?> |
published, $i, 'sets.', true, 'cb'); ?> |
diff --git a/com_testquestions.xml b/com_testquestions.xml
index 76d873e..45ba0db 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.33.0
+ 1.34.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 76305dc..24fdbf2 100644
--- a/components/com_testquestions/src/Model/SetModel.php
+++ b/components/com_testquestions/src/Model/SetModel.php
@@ -9,6 +9,8 @@ use Joomla\CMS\MVC\Model\BaseDatabaseModel;
class SetModel extends BaseDatabaseModel
{
+ protected $resolvedSetId;
+
protected function getSetId(): int
{
$application = Factory::getApplication();
@@ -27,20 +29,46 @@ class SetModel extends BaseDatabaseModel
return null;
}
- return $db->setQuery(
+ $set = $db->setQuery(
$db->getQuery(true)
->select(['s.*', 'sub.title AS subject_title'])
->from($db->quoteName('#__testquestions_sets', 's'))
->leftJoin($db->quoteName('#__testquestions_subjects', 'sub') . ' ON sub.id = s.subject_id')
->where('s.id = ' . $setId)
+ ->where('s.parent_id = 0')
->where('s.published = 1')
)->loadObject();
+
+ if (!$set) {
+ return null;
+ }
+
+ $this->resolvedSetId = $setId;
+
+ if ($set->set_type === 'multi') {
+ $variantId = (int) $db->setQuery(
+ $db->getQuery(true)
+ ->select('id')
+ ->from($db->quoteName('#__testquestions_sets'))
+ ->where('parent_id = ' . $setId)
+ ->where('published = 1')
+ ->order('RAND()')
+ ->setLimit(1)
+ )->loadResult();
+
+ $this->resolvedSetId = $variantId;
+ }
+
+ return $set;
}
public function getItems()
{
$db = Factory::getContainer()->get('DatabaseDriver');
- $setId = $this->getSetId();
+ if ($this->resolvedSetId === null) {
+ $this->getSet();
+ }
+ $setId = (int) $this->resolvedSetId;
if ($setId < 1) {
return [];
@@ -67,6 +95,7 @@ class SetModel extends BaseDatabaseModel
->from($db->quoteName('#__testquestions_sets', 's'))
->leftJoin($db->quoteName('#__testquestions_subjects', 'sub') . ' ON sub.id = s.subject_id')
->where('s.published = 1')
+ ->where('s.parent_id = 0')
->order('sub.title ASC, s.title ASC')
)->loadObjectList();
}