diff --git a/README.md b/README.md index 7a0cea3..c58c79f 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.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**. diff --git a/administrator/components/com_testquestions/language/en-GB/com_testquestions.ini b/administrator/components/com_testquestions/language/en-GB/com_testquestions.ini index ced467f..1cb9fe1 100644 --- a/administrator/components/com_testquestions/language/en-GB/com_testquestions.ini +++ b/administrator/components/com_testquestions/language/en-GB/com_testquestions.ini @@ -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ź" diff --git a/administrator/components/com_testquestions/sql/updates/mysql/1.30.0.sql b/administrator/components/com_testquestions/sql/updates/mysql/1.30.0.sql new file mode 100644 index 0000000..10ca5df --- /dev/null +++ b/administrator/components/com_testquestions/sql/updates/mysql/1.30.0.sql @@ -0,0 +1 @@ +-- No database changes required for version 1.30.0. diff --git a/administrator/components/com_testquestions/src/Model/ResultsModel.php b/administrator/components/com_testquestions/src/Model/ResultsModel.php index e22138b..e6f240f 100644 --- a/administrator/components/com_testquestions/src/Model/ResultsModel.php +++ b/administrator/components/com_testquestions/src/Model/ResultsModel.php @@ -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'); } } diff --git a/administrator/components/com_testquestions/tmpl/results/default.php b/administrator/components/com_testquestions/tmpl/results/default.php index c9fc5c4..b24a0f3 100644 --- a/administrator/components/com_testquestions/tmpl/results/default.php +++ b/administrator/components/com_testquestions/tmpl/results/default.php @@ -10,7 +10,20 @@ use Joomla\CMS\Router\Route;