Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0c70396a5 | ||
|
|
344c1b42a2 | ||
|
|
9af456989a | ||
|
|
887b27f30b |
@@ -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.16).
|
||||
W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.43.20).
|
||||
|
||||
Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**.
|
||||
|
||||
@@ -105,6 +105,10 @@ COM_TESTQUESTIONS_SET_QUESTIONS="Pytania w zestawie"
|
||||
COM_TESTQUESTIONS_SET_QUESTION_COUNT="Liczba pytań"
|
||||
COM_TESTQUESTIONS_SET_SEARCH="Szukaj zestawów..."
|
||||
COM_TESTQUESTIONS_SET_CATEGORY_FILTER="Filtruj pytania według kategorii"
|
||||
COM_TESTQUESTIONS_SET_CHOOSE_CATEGORY="Wybierz kategorię"
|
||||
COM_TESTQUESTIONS_SET_ID_FILTER="Filtruj pytania według ID"
|
||||
COM_TESTQUESTIONS_SET_ID_FILTER_HINT="Wpisz ID, np. 12, 34, 56"
|
||||
COM_TESTQUESTIONS_SET_SELECT_ALL_VISIBLE="Zaznacz wszystkie widoczne pytania"
|
||||
COM_TESTQUESTIONS_SET_ALL_CATEGORIES="Wszystkie kategorie"
|
||||
COM_TESTQUESTIONS_UNCATEGORIZED="Bez kategorii"
|
||||
COM_TESTQUESTIONS_SET_SHOW_DETAILS="Pokaż odpowiedzi"
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
-- Wydanie 1.43.17: zmieniono przyciski paska narzędzi podglądu zestawu.
|
||||
@@ -0,0 +1 @@
|
||||
-- Wydanie 1.43.18: dodano filtrowanie dostępnych pytań po ID podczas edycji zestawu.
|
||||
@@ -0,0 +1 @@
|
||||
-- Wydanie 1.43.19: usprawniono filtrowanie i zaznaczanie pytań w edycji zestawu.
|
||||
@@ -0,0 +1 @@
|
||||
-- Wydanie 1.43.20: czas testu bez ustawionego limitu zestawu jest sumowany z czasów pytań.
|
||||
@@ -29,13 +29,25 @@ class HtmlView extends BaseHtmlView
|
||||
'media/com_testquestions/egzamin.css'
|
||||
);
|
||||
ToolbarHelper::title(Text::_('COM_TESTQUESTIONS_PREVIEW_TITLE'));
|
||||
|
||||
if ($this->set) {
|
||||
ToolbarHelper::link(
|
||||
$this->set
|
||||
? Route::_('index.php?option=com_testquestions&task=set.edit&id=' . (int) $this->set->id)
|
||||
: Route::_('index.php?option=com_testquestions&view=questions'),
|
||||
$this->set ? 'COM_TESTQUESTIONS_EDIT_SET' : 'COM_TESTQUESTIONS',
|
||||
Route::_('index.php?option=com_testquestions&view=sets'),
|
||||
'COM_TESTQUESTIONS_SETS',
|
||||
'arrow-left'
|
||||
);
|
||||
ToolbarHelper::link(
|
||||
Route::_('index.php?option=com_testquestions&task=set.edit&id=' . (int) $this->set->id),
|
||||
'COM_TESTQUESTIONS_EDIT_SET',
|
||||
'edit'
|
||||
);
|
||||
} else {
|
||||
ToolbarHelper::link(
|
||||
Route::_('index.php?option=com_testquestions&view=questions'),
|
||||
'COM_TESTQUESTIONS',
|
||||
'arrow-left'
|
||||
);
|
||||
}
|
||||
|
||||
return parent::display($tpl);
|
||||
}
|
||||
|
||||
@@ -96,16 +96,25 @@ HTMLHelper::_('behavior.formvalidator');
|
||||
<div class="mb-3">
|
||||
<label for="set-question-category" class="form-label"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_SET_CATEGORY_FILTER'); ?></label>
|
||||
<select id="set-question-category" class="form-select">
|
||||
<option value="__choose" selected><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_SET_CHOOSE_CATEGORY'); ?></option>
|
||||
<option value=""><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_SET_ALL_CATEGORIES'); ?></option>
|
||||
<?php foreach ($this->categories as $category) : ?>
|
||||
<option value="<?php echo (int) $category->id; ?>"><?php echo $this->escape($category->title); ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="set-question-ids" class="form-label"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_SET_ID_FILTER'); ?></label>
|
||||
<input type="text" id="set-question-ids" class="form-control" placeholder="<?php echo $this->escape(\Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_SET_ID_FILTER_HINT')); ?>" inputmode="numeric">
|
||||
</div>
|
||||
<div class="form-check mb-2">
|
||||
<input class="form-check-input" type="checkbox" id="set-question-select-visible">
|
||||
<label class="form-check-label" for="set-question-select-visible"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_SET_SELECT_ALL_VISIBLE'); ?></label>
|
||||
</div>
|
||||
<div id="set-available-question-list" class="border rounded p-3">
|
||||
<?php foreach ($this->questions as $question) : ?>
|
||||
<?php if (in_array((int) $question->id, array_map('intval', (array) $this->item->question_ids), true)) continue; ?>
|
||||
<div class="form-check set-available-question-row" data-category="<?php echo (int) $question->category_id; ?>">
|
||||
<div class="form-check set-available-question-row" data-category="<?php echo (int) $question->category_id; ?>" data-id="<?php echo (int) $question->id; ?>">
|
||||
<input class="form-check-input" type="checkbox" name="jform[question_ids][]" value="<?php echo (int) $question->id; ?>" id="set-question-<?php echo (int) $question->id; ?>">
|
||||
<label class="form-check-label" for="set-question-<?php echo (int) $question->id; ?>">
|
||||
<span class="badge bg-secondary"><?php echo $this->escape($question->category_title ?: \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_UNCATEGORIZED')); ?></span>
|
||||
@@ -181,17 +190,52 @@ document.addEventListener('DOMContentLoaded', function () {
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const filter = document.getElementById('set-question-category');
|
||||
const idFilter = document.getElementById('set-question-ids');
|
||||
const selectVisible = document.getElementById('set-question-select-visible');
|
||||
const rows = document.querySelectorAll('.set-available-question-row');
|
||||
|
||||
if (!filter) {
|
||||
if (!filter || !idFilter || !selectVisible) {
|
||||
return;
|
||||
}
|
||||
|
||||
filter.addEventListener('change', function () {
|
||||
const visibleRows = function () {
|
||||
return Array.from(rows).filter(function (row) { return !row.classList.contains('d-none'); });
|
||||
};
|
||||
|
||||
const updateSelectVisible = function () {
|
||||
const checkboxes = visibleRows().map(function (row) { return row.querySelector('input[type="checkbox"]'); });
|
||||
const checkedCount = checkboxes.filter(function (checkbox) { return checkbox.checked; }).length;
|
||||
selectVisible.checked = checkboxes.length > 0 && checkedCount === checkboxes.length;
|
||||
selectVisible.indeterminate = checkedCount > 0 && checkedCount < checkboxes.length;
|
||||
selectVisible.disabled = checkboxes.length === 0;
|
||||
};
|
||||
|
||||
const applyFilters = function () {
|
||||
const requestedIds = idFilter.value
|
||||
.split(',')
|
||||
.map(function (value) { return value.trim(); })
|
||||
.filter(function (value) { return value !== ''; });
|
||||
|
||||
rows.forEach(function (row) {
|
||||
row.classList.toggle('d-none', filter.value !== '' && row.dataset.category !== filter.value);
|
||||
const matchesCategory = filter.value !== '__choose' && (filter.value === '' || row.dataset.category === filter.value);
|
||||
const matchesId = requestedIds.length === 0 || requestedIds.includes(row.dataset.id);
|
||||
row.classList.toggle('d-none', !matchesCategory || !matchesId);
|
||||
});
|
||||
updateSelectVisible();
|
||||
};
|
||||
|
||||
filter.addEventListener('change', applyFilters);
|
||||
idFilter.addEventListener('input', applyFilters);
|
||||
selectVisible.addEventListener('change', function () {
|
||||
visibleRows().forEach(function (row) {
|
||||
row.querySelector('input[type="checkbox"]').checked = selectVisible.checked;
|
||||
});
|
||||
updateSelectVisible();
|
||||
});
|
||||
rows.forEach(function (row) {
|
||||
row.querySelector('input[type="checkbox"]').addEventListener('change', updateSelectVisible);
|
||||
});
|
||||
applyFilters();
|
||||
});
|
||||
</script>
|
||||
<script>
|
||||
|
||||
@@ -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.16</version>
|
||||
<version>1.43.20</version>
|
||||
<description>COM_TESTQUESTIONS_DESCRIPTION</description>
|
||||
<element>com_testquestions</element>
|
||||
<namespace path="src">Komponent\Component\Testquestions</namespace>
|
||||
|
||||
@@ -77,7 +77,7 @@ class SetModel extends BaseDatabaseModel
|
||||
}
|
||||
|
||||
$query = $db->getQuery(true)
|
||||
->select(['q.id', 'q.question_type', 'q.question', 'q.answer_a', 'q.answer_b', 'q.answer_c', 'q.answer_d', 'q.answer_open', 'q.correct_answer', 'q.points', 'q.image'])
|
||||
->select(['q.id', 'q.question_type', 'q.question', 'q.answer_a', 'q.answer_b', 'q.answer_c', 'q.answer_d', 'q.answer_open', 'q.correct_answer', 'q.points', 'q.image', 'q.time_limit'])
|
||||
->from($db->quoteName('#__testquestions_set_questions', 'sq'))
|
||||
->innerJoin($db->quoteName('#__testquestions_questions', 'q') . ' ON q.id = sq.question_id')
|
||||
->where('sq.set_id = ' . $setId)
|
||||
|
||||
@@ -5,6 +5,8 @@ defined('_JEXEC') or die;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
|
||||
$testDurationSeconds = 0;
|
||||
|
||||
$resolveImageUrl = static function ($path) {
|
||||
$path = trim((string) $path);
|
||||
|
||||
@@ -50,16 +52,26 @@ $resolveImageUrl = static function ($path) {
|
||||
<?php elseif (!$this->set) : ?>
|
||||
<div class="alert alert-info"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_SET_NOT_FOUND'); ?></div>
|
||||
<?php else : ?>
|
||||
<?php
|
||||
$extraTime = Factory::getApplication()->getInput()->post->getInt('extra_time', 0);
|
||||
$baseDurationSeconds = (int) $this->set->duration > 0
|
||||
? (int) $this->set->duration * 60
|
||||
: array_sum(array_map(static function ($item) {
|
||||
return max(0, (int) ($item->time_limit ?? 0));
|
||||
}, $this->items));
|
||||
$testDurationSeconds = $baseDurationSeconds + ($extraTime * 60);
|
||||
$durationMinutes = intdiv($testDurationSeconds, 60);
|
||||
$durationRemainder = $testDurationSeconds % 60;
|
||||
?>
|
||||
<header class="test-set-header">
|
||||
<?php if ($this->set->subject_title) : ?><div class="text-muted"><?php echo htmlspecialchars($this->set->subject_title, ENT_QUOTES, 'UTF-8'); ?></div><?php endif; ?>
|
||||
<h1><?php echo htmlspecialchars($this->set->title, ENT_QUOTES, 'UTF-8'); ?></h1>
|
||||
<?php $extraTime = Factory::getApplication()->getInput()->post->getInt('extra_time', 0); ?>
|
||||
<?php if ((int) $this->set->duration > 0) : ?><div class="small text-muted"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_SET_DURATION'); ?>: <?php echo (int) $this->set->duration + $extraTime; ?> min</div><?php endif; ?>
|
||||
<?php if ($testDurationSeconds > 0) : ?><div class="small text-muted"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_SET_DURATION'); ?>: <?php echo $durationMinutes; ?> min<?php if ($durationRemainder > 0) : ?> <?php echo $durationRemainder; ?> s<?php endif; ?></div><?php endif; ?>
|
||||
<?php if ($this->set->image) : ?><div class="foto_pyt"><img src="<?php echo htmlspecialchars($resolveImageUrl($this->set->image), ENT_QUOTES, 'UTF-8'); ?>" alt="" loading="lazy"></div><?php endif; ?>
|
||||
<?php if ($this->set->test_content) : ?><div class="test-set-content"><?php echo $this->set->test_content; ?></div><?php endif; ?>
|
||||
</header>
|
||||
<?php if (!$this->results && ((int) $this->set->duration + $extraTime) > 0) : ?>
|
||||
<div class="timer-container mb-4" id="test-timer-container" data-duration="<?php echo ((int) $this->set->duration + $extraTime) * 60; ?>" aria-live="polite">
|
||||
<?php if (!$this->results && $testDurationSeconds > 0) : ?>
|
||||
<div class="timer-container mb-4" id="test-timer-container" data-duration="<?php echo $testDurationSeconds; ?>" aria-live="polite">
|
||||
<svg width="120" height="120" viewBox="0 0 120 120" aria-hidden="true">
|
||||
<circle cx="60" cy="60" r="54" fill="none" stroke="#dfe3e7" stroke-width="8"></circle>
|
||||
<circle id="test-timer-ring" class="progress-ring__circle" cx="60" cy="60" r="54" fill="none" stroke="#4a86cf" stroke-width="8" stroke-linecap="round"></circle>
|
||||
@@ -118,7 +130,7 @@ $resolveImageUrl = static function ($path) {
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php if ($this->started && !$this->results && ((int) $this->set->duration + $extraTime) > 0) : ?>
|
||||
<?php if ($this->started && !$this->results && $testDurationSeconds > 0) : ?>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const container = document.getElementById('test-timer-container');
|
||||
|
||||
Reference in New Issue
Block a user