Add result list date and test filters
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.29.0).
|
||||
W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.30.0).
|
||||
|
||||
Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**.
|
||||
|
||||
@@ -77,6 +77,9 @@ COM_TESTQUESTIONS_RESULT_SAVED="Dane wyniku zostały zapisane."
|
||||
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_DATE_FROM="Data od"
|
||||
COM_TESTQUESTIONS_RESULTS_DATE_TO="Data do"
|
||||
COM_TESTQUESTIONS_YOUR_ANSWER="Twoja odpowiedź"
|
||||
COM_TESTQUESTIONS_SELECTED_ANSWER="Zaznaczona odpowiedź"
|
||||
COM_TESTQUESTIONS_ANSWER_CORRECT="Poprawna odpowiedź"
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
-- No database changes required for version 1.30.0.
|
||||
@@ -13,6 +13,9 @@ 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.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'));
|
||||
}
|
||||
|
||||
protected function getListQuery()
|
||||
@@ -30,6 +33,22 @@ 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);
|
||||
}
|
||||
|
||||
$dateFrom = (string) $this->getState('filter.date_from');
|
||||
if (preg_match('/^\d{4}-\d{2}-\d{2}$/', $dateFrom)) {
|
||||
$query->where('r.created >= ' . $db->quote($dateFrom . ' 00:00:00'));
|
||||
}
|
||||
|
||||
$dateTo = (string) $this->getState('filter.date_to');
|
||||
if (preg_match('/^\d{4}-\d{2}-\d{2}$/', $dateTo)) {
|
||||
$query->where('r.created <= ' . $db->quote($dateTo . ' 23:59:59'));
|
||||
}
|
||||
|
||||
return $query->order('r.created DESC, r.id DESC');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,20 @@ use Joomla\CMS\Router\Route;
|
||||
<div class="col-md-6">
|
||||
<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-3"><button type="submit" class="btn btn-primary"><?php echo \Joomla\CMS\Language\Text::_('JSEARCH_FILTER_SUBMIT'); ?></button></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')); ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col-md-3">
|
||||
<label for="filter-date-from" class="form-label"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULTS_DATE_FROM'); ?></label>
|
||||
<input type="date" name="filter_date_from" id="filter-date-from" value="<?php echo $this->escape($this->state->get('filter.date_from')); ?>" class="form-control">
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label for="filter-date-to" class="form-label"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULTS_DATE_TO'); ?></label>
|
||||
<input type="date" name="filter_date_to" id="filter-date-to" value="<?php echo $this->escape($this->state->get('filter.date_to')); ?>" class="form-control">
|
||||
</div>
|
||||
<div class="col-md-3 align-self-end"><button type="submit" class="btn btn-primary"><?php echo \Joomla\CMS\Language\Text::_('JSEARCH_FILTER_SUBMIT'); ?></button></div>
|
||||
</div>
|
||||
<table class="table table-striped">
|
||||
<thead><tr>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<creationDate>2026-10-14</creationDate>
|
||||
<author>Komponent</author>
|
||||
<license>GNU General Public License version 2 or later</license>
|
||||
<version>1.29.0</version>
|
||||
<version>1.30.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