diff --git a/README.md b/README.md index c58c79f..2ec0faa 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.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**. 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 1cb9fe1..5a5f107 100644 --- a/administrator/components/com_testquestions/language/en-GB/com_testquestions.ini +++ b/administrator/components/com_testquestions/language/en-GB/com_testquestions.ini @@ -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ź" diff --git a/administrator/components/com_testquestions/sql/updates/mysql/1.31.0.sql b/administrator/components/com_testquestions/sql/updates/mysql/1.31.0.sql new file mode 100644 index 0000000..4894a54 --- /dev/null +++ b/administrator/components/com_testquestions/sql/updates/mysql/1.31.0.sql @@ -0,0 +1 @@ +-- No database changes required for version 1.31.0. diff --git a/administrator/components/com_testquestions/src/Model/ResultsModel.php b/administrator/components/com_testquestions/src/Model/ResultsModel.php index e6f240f..903d649 100644 --- a/administrator/components/com_testquestions/src/Model/ResultsModel.php +++ b/administrator/components/com_testquestions/src/Model/ResultsModel.php @@ -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(); + } } diff --git a/administrator/components/com_testquestions/src/View/Results/HtmlView.php b/administrator/components/com_testquestions/src/View/Results/HtmlView.php index 2530a7a..872bc3a 100644 --- a/administrator/components/com_testquestions/src/View/Results/HtmlView.php +++ b/administrator/components/com_testquestions/src/View/Results/HtmlView.php @@ -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'); diff --git a/administrator/components/com_testquestions/tmpl/results/default.php b/administrator/components/com_testquestions/tmpl/results/default.php index b24a0f3..fe0cafd 100644 --- a/administrator/components/com_testquestions/tmpl/results/default.php +++ b/administrator/components/com_testquestions/tmpl/results/default.php @@ -11,7 +11,13 @@ use Joomla\CMS\Router\Route;
- + +
diff --git a/com_testquestions.xml b/com_testquestions.xml index dcf8d00..3ca60f3 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.30.0 + 1.31.0 COM_TESTQUESTIONS_DESCRIPTION com_testquestions Komponent\Component\Testquestions