Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1da3149e2f |
@@ -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.43.22).
|
||||
W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.43.23).
|
||||
|
||||
Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**.
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
-- Wydanie 1.43.23: zachowano w wyniku kolejność pytań z wylosowanego testu.
|
||||
@@ -4,7 +4,7 @@
|
||||
<creationDate>2026-10-14</creationDate>
|
||||
<author>Komponent</author>
|
||||
<license>GNU General Public License version 2 or later</license>
|
||||
<version>1.43.22</version>
|
||||
<version>1.43.23</version>
|
||||
<description>COM_TESTQUESTIONS_DESCRIPTION</description>
|
||||
<element>com_testquestions</element>
|
||||
<namespace path="src">Komponent\Component\Testquestions</namespace>
|
||||
|
||||
@@ -25,6 +25,26 @@ class HtmlView extends BaseHtmlView
|
||||
$this->items = $this->get('Items');
|
||||
$this->sets = $this->get('Sets');
|
||||
$input = Factory::getApplication()->getInput();
|
||||
if ($input->getCmd('task') === 'check' && $input->getMethod() === 'POST' && $this->items) {
|
||||
$submittedQuestionOrder = array_map('intval', (array) $input->post->get('question_order', [], 'array'));
|
||||
$expectedQuestionIds = array_map(static function ($item) {
|
||||
return (int) $item->id;
|
||||
}, $this->items);
|
||||
$sortedSubmittedOrder = $submittedQuestionOrder;
|
||||
$sortedExpectedIds = $expectedQuestionIds;
|
||||
sort($sortedSubmittedOrder);
|
||||
sort($sortedExpectedIds);
|
||||
|
||||
if ($sortedSubmittedOrder === $sortedExpectedIds) {
|
||||
$itemsById = [];
|
||||
foreach ($this->items as $item) {
|
||||
$itemsById[(int) $item->id] = $item;
|
||||
}
|
||||
$this->items = array_values(array_map(static function ($questionId) use ($itemsById) {
|
||||
return $itemsById[$questionId];
|
||||
}, $submittedQuestionOrder));
|
||||
}
|
||||
}
|
||||
$this->started = $input->getMethod() === 'POST'
|
||||
&& $input->post->getString('participant_name', '') !== ''
|
||||
&& $input->post->getInt('set_id', 0) > 0;
|
||||
|
||||
@@ -84,6 +84,9 @@ $resolveImageUrl = static function ($path) {
|
||||
<?php endif; ?>
|
||||
<?php if ($this->items) : ?>
|
||||
<form action="<?php echo htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES, 'UTF-8'); ?>" method="post" id="test-form">
|
||||
<?php if (!$this->results) : ?>
|
||||
<?php foreach ($this->items as $item) : ?><input type="hidden" name="question_order[]" value="<?php echo (int) $item->id; ?>"><?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
<?php foreach ($this->items as $number => $item) : ?>
|
||||
<?php
|
||||
$answerOrder = $this->results && !empty($this->results['items'][$item->id]['answer_order'])
|
||||
|
||||
Reference in New Issue
Block a user