Use all sets in result filter
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.30.0).
|
||||
W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.31.0).
|
||||
|
||||
Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**.
|
||||
|
||||
@@ -78,6 +78,7 @@ COM_TESTQUESTIONS_RESULT_SAVE="Zapisz"
|
||||
COM_TESTQUESTIONS_RESULT_SAVE_AND_CLOSE="Zapisz i zamknij"
|
||||
COM_TESTQUESTIONS_RESULTS_SEARCH="Szukaj po użytkowniku lub zestawie..."
|
||||
COM_TESTQUESTIONS_RESULTS_TEST_NAME="Nazwa testu"
|
||||
COM_TESTQUESTIONS_RESULTS_ALL_TESTS="Wszystkie zestawy"
|
||||
COM_TESTQUESTIONS_RESULTS_DATE_FROM="Data od"
|
||||
COM_TESTQUESTIONS_RESULTS_DATE_TO="Data do"
|
||||
COM_TESTQUESTIONS_YOUR_ANSWER="Twoja odpowiedź"
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
-- No database changes required for version 1.31.0.
|
||||
@@ -13,7 +13,7 @@ class ResultsModel extends ListModel
|
||||
{
|
||||
parent::populateState($ordering, $direction);
|
||||
$this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string'));
|
||||
$this->setState('filter.test_name', $this->getUserStateFromRequest($this->context . '.filter.test_name', 'filter_test_name', '', 'string'));
|
||||
$this->setState('filter.set_id', $this->getUserStateFromRequest($this->context . '.filter.set_id', 'filter_set_id', 0, 'int'));
|
||||
$this->setState('filter.date_from', $this->getUserStateFromRequest($this->context . '.filter.date_from', 'filter_date_from', '', 'string'));
|
||||
$this->setState('filter.date_to', $this->getUserStateFromRequest($this->context . '.filter.date_to', 'filter_date_to', '', 'string'));
|
||||
}
|
||||
@@ -33,10 +33,9 @@ class ResultsModel extends ListModel
|
||||
$query->where('(r.participant_name LIKE ' . $needle . ' OR s.title LIKE ' . $needle . ')');
|
||||
}
|
||||
|
||||
$testName = trim((string) $this->getState('filter.test_name'));
|
||||
if ($testName !== '') {
|
||||
$needle = $db->quote('%' . $db->escape($testName, true) . '%', false);
|
||||
$query->where('s.title LIKE ' . $needle);
|
||||
$setId = (int) $this->getState('filter.set_id');
|
||||
if ($setId > 0) {
|
||||
$query->where('r.set_id = ' . $setId);
|
||||
}
|
||||
|
||||
$dateFrom = (string) $this->getState('filter.date_from');
|
||||
@@ -51,4 +50,17 @@ class ResultsModel extends ListModel
|
||||
|
||||
return $query->order('r.created DESC, r.id DESC');
|
||||
}
|
||||
|
||||
public function getSets(): array
|
||||
{
|
||||
$db = Factory::getContainer()->get('DatabaseDriver');
|
||||
|
||||
return $db->setQuery(
|
||||
$db->getQuery(true)
|
||||
->select(['s.id', 's.title', 's.published', 'sub.title AS subject_title'])
|
||||
->from($db->quoteName('#__testquestions_sets', 's'))
|
||||
->leftJoin($db->quoteName('#__testquestions_subjects', 'sub') . ' ON sub.id = s.subject_id')
|
||||
->order('sub.title ASC, s.title ASC, s.id ASC')
|
||||
)->loadObjectList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,12 +14,14 @@ class HtmlView extends BaseHtmlView
|
||||
protected $items;
|
||||
protected $pagination;
|
||||
protected $state;
|
||||
protected $sets;
|
||||
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$this->items = $this->get('Items');
|
||||
$this->pagination = $this->get('Pagination');
|
||||
$this->state = $this->get('State');
|
||||
$this->sets = $this->get('Sets');
|
||||
ToolbarHelper::title(Text::_('COM_TESTQUESTIONS_RESULTS'));
|
||||
ToolbarHelper::link('index.php?option=com_testquestions&view=sets', 'COM_TESTQUESTIONS_SETS', 'back');
|
||||
|
||||
|
||||
@@ -11,7 +11,13 @@ use Joomla\CMS\Router\Route;
|
||||
<input type="text" name="filter_search" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" class="form-control" placeholder="<?php echo $this->escape(\Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULTS_SEARCH')); ?>">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<input type="text" name="filter_test_name" value="<?php echo $this->escape($this->state->get('filter.test_name')); ?>" class="form-control" placeholder="<?php echo $this->escape(\Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULTS_TEST_NAME')); ?>">
|
||||
<label for="filter-set-id" class="form-label"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULTS_TEST_NAME'); ?></label>
|
||||
<select name="filter_set_id" id="filter-set-id" class="form-select">
|
||||
<option value="0"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULTS_ALL_TESTS'); ?></option>
|
||||
<?php foreach ($this->sets as $set) : ?>
|
||||
<option value="<?php echo (int) $set->id; ?>" <?php echo (int) $this->state->get('filter.set_id') === (int) $set->id ? 'selected' : ''; ?>><?php echo $this->escape(($set->subject_title ? $set->subject_title . ' — ' : '') . $set->title . (!(int) $set->published ? ' (nieopublikowany)' : '')); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<creationDate>2026-10-14</creationDate>
|
||||
<author>Komponent</author>
|
||||
<license>GNU General Public License version 2 or later</license>
|
||||
<version>1.30.0</version>
|
||||
<version>1.31.0</version>
|
||||
<description>COM_TESTQUESTIONS_DESCRIPTION</description>
|
||||
<element>com_testquestions</element>
|
||||
<namespace path="src">Komponent\Component\Testquestions</namespace>
|
||||
|
||||
Reference in New Issue
Block a user