Order multi-variant questions without frontend randomization
This commit is contained in:
@@ -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**.
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
-- No database changes required for version 1.41.0.
|
||||
@@ -8,7 +8,7 @@ use Joomla\CMS\Router\Route;
|
||||
HTMLHelper::_('behavior.formvalidator');
|
||||
?>
|
||||
<form action="<?php echo Route::_('index.php?option=com_testquestions&view=set&layout=edit&id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="adminForm" class="form-validate">
|
||||
<?php $canOrderQuestions = !$this->isVariant && (string) $this->item->set_type === 'ordinary'; ?>
|
||||
<?php $canOrderQuestions = $this->isVariant || (string) $this->item->set_type === 'ordinary'; ?>
|
||||
<fieldset class="adminform">
|
||||
<?php echo $this->form->renderField('parent_id'); ?>
|
||||
<?php if ($this->isVariant) : ?>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<creationDate>2026-10-14</creationDate>
|
||||
<author>Komponent</author>
|
||||
<license>GNU General Public License version 2 or later</license>
|
||||
<version>1.40.0</version>
|
||||
<version>1.41.0</version>
|
||||
<description>COM_TESTQUESTIONS_DESCRIPTION</description>
|
||||
<element>com_testquestions</element>
|
||||
<namespace path="src">Komponent\Component\Testquestions</namespace>
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user