diff --git a/README.md b/README.md index df9968e..dbae1df 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,10 @@ Szkielet komponentu Joomla 6 do gromadzenia pytań testowych. - edytor formatowania treści pytania i odpowiedzi zamkniętych, - czas odpowiedzi, punktacja 1–9 oraz zarządzalne kategorie pytań, - filtrowanie listy pytań po kategorii, +- przełącznik widoku listy: same pytania albo pytania z odpowiedziami, +- frontendowy widok pytań filtrowany po symbolu arkusza egzaminacyjnego, +- pozycję menu „Arkusz egzaminacyjny” z opcjonalnym symbolem arkusza, +- listę wyboru dostępnych symboli arkuszy na stronie klienckiej, - opcjonalny symbol testu, rok egzaminu i numer pytania z arkusza, - wskazanie poprawnej odpowiedzi, - opcjonalne zdjęcie wybierane z Media Managera, @@ -17,6 +21,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.4.2). +W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.6.1). 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 414822f..1f9b436 100644 --- a/administrator/components/com_testquestions/language/en-GB/com_testquestions.ini +++ b/administrator/components/com_testquestions/language/en-GB/com_testquestions.ini @@ -12,6 +12,8 @@ COM_TESTQUESTIONS_FIELD_EXAM_YEAR="Rok egzaminu" COM_TESTQUESTIONS_FIELD_QUESTION_NUMBER="Numer pytania" COM_TESTQUESTIONS_MANAGE_CATEGORIES="Kategorie" COM_TESTQUESTIONS_FILTER_CATEGORY="Wszystkie kategorie" +COM_TESTQUESTIONS_VIEW_QUESTIONS_ONLY="Same pytania" +COM_TESTQUESTIONS_VIEW_WITH_ANSWERS="Pytania i odpowiedzi" COM_TESTQUESTIONS_CATEGORIES="Kategorie pytań" COM_TESTQUESTIONS_CATEGORY_TITLE="Nazwa kategorii" COM_TESTQUESTIONS_TYPE_CLOSED="Zamknięte — wybór odpowiedzi" diff --git a/administrator/components/com_testquestions/language/en-GB/com_testquestions.sys.ini b/administrator/components/com_testquestions/language/en-GB/com_testquestions.sys.ini index 1a2096b..843dca7 100644 --- a/administrator/components/com_testquestions/language/en-GB/com_testquestions.sys.ini +++ b/administrator/components/com_testquestions/language/en-GB/com_testquestions.sys.ini @@ -1,2 +1,4 @@ COM_TESTQUESTIONS="Pytania testowe" COM_TESTQUESTIONS_DESCRIPTION="Gromadzenie pytań testowych z czterema odpowiedziami i opcjonalnym zdjęciem." +COM_TESTQUESTIONS_MENU_ITEM_TITLE="Arkusz egzaminacyjny" +COM_TESTQUESTIONS_MENU_ITEM_DESCRIPTION="Wyświetla pytania z wybranego arkusza egzaminacyjnego." diff --git a/administrator/components/com_testquestions/sql/updates/mysql/1.4.4.sql b/administrator/components/com_testquestions/sql/updates/mysql/1.4.4.sql new file mode 100644 index 0000000..a03084a --- /dev/null +++ b/administrator/components/com_testquestions/sql/updates/mysql/1.4.4.sql @@ -0,0 +1 @@ +-- Administrator list view switch for showing answers. diff --git a/administrator/components/com_testquestions/sql/updates/mysql/1.5.0.sql b/administrator/components/com_testquestions/sql/updates/mysql/1.5.0.sql new file mode 100644 index 0000000..f071438 --- /dev/null +++ b/administrator/components/com_testquestions/sql/updates/mysql/1.5.0.sql @@ -0,0 +1 @@ +-- Frontend view for displaying questions from a selected exam sheet. diff --git a/administrator/components/com_testquestions/sql/updates/mysql/1.5.1.sql b/administrator/components/com_testquestions/sql/updates/mysql/1.5.1.sql new file mode 100644 index 0000000..26fe21e --- /dev/null +++ b/administrator/components/com_testquestions/sql/updates/mysql/1.5.1.sql @@ -0,0 +1 @@ +-- Add frontend menu item metadata for exam sheet view. diff --git a/administrator/components/com_testquestions/sql/updates/mysql/1.5.2.sql b/administrator/components/com_testquestions/sql/updates/mysql/1.5.2.sql new file mode 100644 index 0000000..2d2deb6 --- /dev/null +++ b/administrator/components/com_testquestions/sql/updates/mysql/1.5.2.sql @@ -0,0 +1 @@ +-- Ensure frontend menu item language metadata is available. diff --git a/administrator/components/com_testquestions/sql/updates/mysql/1.6.0.sql b/administrator/components/com_testquestions/sql/updates/mysql/1.6.0.sql new file mode 100644 index 0000000..5bd30a5 --- /dev/null +++ b/administrator/components/com_testquestions/sql/updates/mysql/1.6.0.sql @@ -0,0 +1 @@ +-- Use a selectable list of available exam sheet symbols on the frontend. diff --git a/administrator/components/com_testquestions/sql/updates/mysql/1.6.1.sql b/administrator/components/com_testquestions/sql/updates/mysql/1.6.1.sql new file mode 100644 index 0000000..8c34daf --- /dev/null +++ b/administrator/components/com_testquestions/sql/updates/mysql/1.6.1.sql @@ -0,0 +1 @@ +-- Remove temporary exam seed data from the installer. No data is imported by this release. diff --git a/administrator/components/com_testquestions/src/Model/QuestionsModel.php b/administrator/components/com_testquestions/src/Model/QuestionsModel.php index 1a96e3c..6cca35a 100644 --- a/administrator/components/com_testquestions/src/Model/QuestionsModel.php +++ b/administrator/components/com_testquestions/src/Model/QuestionsModel.php @@ -21,6 +21,9 @@ class QuestionsModel extends ListModel $this->setState('filter.category_id', $this->getUserStateFromRequest( $this->context . '.filter.category_id', 'filter_category_id', '', 'int' )); + $this->setState('filter.show_answers', $this->getUserStateFromRequest( + $this->context . '.filter.show_answers', 'filter_show_answers', '0', 'int' + )); } protected function getListQuery() diff --git a/administrator/components/com_testquestions/tmpl/questions/default.php b/administrator/components/com_testquestions/tmpl/questions/default.php index dc07454..4046b01 100644 --- a/administrator/components/com_testquestions/tmpl/questions/default.php +++ b/administrator/components/com_testquestions/tmpl/questions/default.php @@ -29,6 +29,12 @@ HTMLHelper::_('behavior.multiselect'); +
+ +
@@ -56,6 +62,18 @@ HTMLHelper::_('behavior.multiselect'); escape(strip_tags($item->question)); ?> image) : ?> + state->get('filter.show_answers') === 1) : ?> +
+ question_type === 'open') : ?> +
: answer_open; ?>
+ +
A: answer_a; ?>
+
B: answer_b; ?>
+
C: answer_c; ?>
+
D: answer_d; ?>
+ +
+ question_type)); ?> correct_answer)); ?> diff --git a/com_testquestions.xml b/com_testquestions.xml index 33a6eb1..00025e0 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.4.2 + 1.6.1 COM_TESTQUESTIONS_DESCRIPTION com_testquestions Komponent\Component\Testquestions diff --git a/components/com_testquestions/language/en-GB/com_testquestions.ini b/components/com_testquestions/language/en-GB/com_testquestions.ini index 2132320..aa75e78 100644 --- a/components/com_testquestions/language/en-GB/com_testquestions.ini +++ b/components/com_testquestions/language/en-GB/com_testquestions.ini @@ -1,2 +1,12 @@ COM_TESTQUESTIONS="Pytania testowe" +COM_TESTQUESTIONS_TEST_SYMBOL="Symbol arkusza egzaminacyjnego" +COM_TESTQUESTIONS_SELECT_TEST_SYMBOL="Wybierz arkusz egzaminacyjny" +COM_TESTQUESTIONS_SHOW_TEST="Pokaż pytania" +COM_TESTQUESTIONS_NO_TEST_QUESTIONS="Nie znaleziono pytań dla podanego arkusza." +COM_TESTQUESTIONS_TEST_SHEET="Arkusz" +COM_TESTQUESTIONS_TIME_LIMIT="Czas" +COM_TESTQUESTIONS_POINTS="Punkty" +COM_TESTQUESTIONS_MENU_ITEM_TITLE="Arkusz egzaminacyjny" +COM_TESTQUESTIONS_MENU_ITEM_DESCRIPTION="Wyświetla pytania z wybranego arkusza egzaminacyjnego." +COM_TESTQUESTIONS_MENU_TEST_SYMBOL_DESC="Opcjonalnie wybierz symbol arkusza, który ma być wyświetlany po wejściu z menu." COM_TESTQUESTIONS_ENTER_ANSWER="Wpisz odpowiedź" diff --git a/components/com_testquestions/language/en-GB/com_testquestions.sys.ini b/components/com_testquestions/language/en-GB/com_testquestions.sys.ini new file mode 100644 index 0000000..89e8afb --- /dev/null +++ b/components/com_testquestions/language/en-GB/com_testquestions.sys.ini @@ -0,0 +1,3 @@ +COM_TESTQUESTIONS="Pytania testowe" +COM_TESTQUESTIONS_MENU_ITEM_TITLE="Arkusz egzaminacyjny" +COM_TESTQUESTIONS_MENU_ITEM_DESCRIPTION="Wyświetla pytania z wybranego arkusza egzaminacyjnego." diff --git a/components/com_testquestions/src/Model/QuestionsModel.php b/components/com_testquestions/src/Model/QuestionsModel.php index 522a3c4..d8d906e 100644 --- a/components/com_testquestions/src/Model/QuestionsModel.php +++ b/components/com_testquestions/src/Model/QuestionsModel.php @@ -9,13 +9,50 @@ use Joomla\CMS\MVC\Model\ListModel; class QuestionsModel extends ListModel { + protected function populateState($ordering = 'ordering', $direction = 'asc') + { + parent::populateState($ordering, $direction); + $menu = Factory::getApplication()->getMenu()->getActive(); + $menuSymbol = $menu ? (string) $menu->getParams()->get('test_symbol', '') : ''; + $symbol = Factory::getApplication()->getInput()->getString('test_symbol', $menuSymbol); + $this->setState('filter.test_symbol', trim($symbol)); + } + protected function getListQuery() { $db = Factory::getContainer()->get('DatabaseDriver'); - return $db->getQuery(true) - ->select(['question_type', 'question', 'answer_a', 'answer_b', 'answer_c', 'answer_d', 'answer_open', 'correct_answer', 'image']) + $query = $db->getQuery(true) + ->select(['question_type', 'question', 'answer_a', 'answer_b', 'answer_c', 'answer_d', 'answer_open', 'correct_answer', 'image', 'time_limit', 'points']) ->from($db->quoteName('#__testquestions_questions')) ->where($db->quoteName('published') . ' = 1') ->order($db->quoteName('ordering') . ' ASC, ' . $db->quoteName('id') . ' ASC'); + + $symbol = $this->getState('filter.test_symbol'); + + if ($symbol !== '') { + $query->where($db->quoteName('test_symbol') . ' = ' . $db->quote($symbol)); + } else { + $query->where('1 = 0'); + } + + return $query; + } + + public function getTestSymbols() + { + $db = Factory::getContainer()->get('DatabaseDriver'); + + return $db->setQuery( + $db->getQuery(true) + ->select([ + $db->quoteName('test_symbol', 'value'), + $db->quoteName('test_symbol', 'text'), + ]) + ->from($db->quoteName('#__testquestions_questions')) + ->where($db->quoteName('published') . ' = 1') + ->where($db->quoteName('test_symbol') . ' <> ' . $db->quote('')) + ->group($db->quoteName('test_symbol')) + ->order($db->quoteName('test_symbol') . ' ASC') + )->loadObjectList(); } } diff --git a/components/com_testquestions/src/View/Questions/HtmlView.php b/components/com_testquestions/src/View/Questions/HtmlView.php index 32a1124..f5383bc 100644 --- a/components/com_testquestions/src/View/Questions/HtmlView.php +++ b/components/com_testquestions/src/View/Questions/HtmlView.php @@ -9,10 +9,14 @@ use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView; class HtmlView extends BaseHtmlView { protected $items; + protected $symbol; + protected $symbols; public function display($tpl = null) { $this->items = $this->get('Items'); + $this->symbol = $this->get('State')->get('filter.test_symbol'); + $this->symbols = $this->get('TestSymbols'); return parent::display($tpl); } } diff --git a/components/com_testquestions/tmpl/questions/default.php b/components/com_testquestions/tmpl/questions/default.php index 968a692..08862eb 100644 --- a/components/com_testquestions/tmpl/questions/default.php +++ b/components/com_testquestions/tmpl/questions/default.php @@ -6,12 +6,35 @@ use Joomla\CMS\HTML\HTMLHelper; ?>

+
+ +
+ + +
+
+ + symbol !== '' && !$this->items) : ?> +
+ symbol !== '') : ?> +

: symbol, ENT_QUOTES, 'UTF-8'); ?>

+ + items as $number => $item) : ?>

question; ?>

image) : ?> +

+ : time_limit; ?> s | + : points; ?> +

question_type === 'open') : ?> diff --git a/components/com_testquestions/tmpl/questions/default.xml b/components/com_testquestions/tmpl/questions/default.xml new file mode 100644 index 0000000..1404d68 --- /dev/null +++ b/components/com_testquestions/tmpl/questions/default.xml @@ -0,0 +1,13 @@ + + + + COM_TESTQUESTIONS_MENU_ITEM_DESCRIPTION + + +
+ +
+
+