Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ef5410689d | ||
|
|
b774f0d94d |
@@ -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.12).
|
||||
W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.43.14).
|
||||
|
||||
Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**.
|
||||
|
||||
@@ -65,6 +65,7 @@ COM_TESTQUESTIONS_SET_REORDER_INFO="Przeciągnij pytania, aby zmienić ich kolej
|
||||
COM_TESTQUESTIONS_SET_SAVE="Zapisz"
|
||||
COM_TESTQUESTIONS_SET_SAVE_AND_CLOSE="Zapisz i zamknij"
|
||||
COM_TESTQUESTIONS_SET_VARIANT_DURATION_INFO="Czas testu jest pobierany z zestawu nadrzędnego."
|
||||
COM_TESTQUESTIONS_SET_VARIANT_STATUS_INHERITED="Status publikacji wariantu jest taki sam jak status zestawu nadrzędnego i zmienia się razem z nim."
|
||||
COM_TESTQUESTIONS_AI_SETTINGS="Ustawienia AI"
|
||||
COM_TESTQUESTIONS_AI_PROVIDER="Dostawca AI"
|
||||
COM_TESTQUESTIONS_AI_API_KEY="Klucz API"
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
-- No database changes required for version 1.43.13.
|
||||
@@ -0,0 +1 @@
|
||||
-- No database changes required for version 1.43.14.
|
||||
@@ -9,6 +9,26 @@ use Joomla\CMS\MVC\Model\AdminModel;
|
||||
|
||||
class SetModel extends AdminModel
|
||||
{
|
||||
public function publish(&$pks, $value = 1)
|
||||
{
|
||||
$ids = array_values(array_unique(array_filter(array_map('intval', (array) $pks))));
|
||||
if (!parent::publish($pks, $value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($ids) {
|
||||
$db = Factory::getContainer()->get('DatabaseDriver');
|
||||
$db->setQuery(
|
||||
$db->getQuery(true)
|
||||
->update($db->quoteName('#__testquestions_sets'))
|
||||
->set($db->quoteName('published') . ' = ' . (int) $value)
|
||||
->where($db->quoteName('parent_id') . ' IN (' . implode(',', $ids) . ')')
|
||||
)->execute();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getTable($name = 'Set', $prefix = 'Administrator', $config = [])
|
||||
{
|
||||
return $this->getMVCFactory()->createTable($name, $prefix, $config);
|
||||
@@ -136,6 +156,7 @@ class SetModel extends AdminModel
|
||||
$parent = $this->getItem($parentId);
|
||||
if ($parent) {
|
||||
$data['duration'] = (int) $parent->duration;
|
||||
$data['published'] = (int) $parent->published;
|
||||
}
|
||||
} elseif (!in_array(($data['set_type'] ?? 'ordinary'), ['ordinary', 'multi'], true)) {
|
||||
$data['set_type'] = 'ordinary';
|
||||
@@ -151,6 +172,15 @@ class SetModel extends AdminModel
|
||||
|
||||
$setId = (int) $this->getState($this->getName() . '.id');
|
||||
$db = Factory::getContainer()->get('DatabaseDriver');
|
||||
if ($parentId === 0) {
|
||||
$db->setQuery(
|
||||
$db->getQuery(true)
|
||||
->update($db->quoteName('#__testquestions_sets'))
|
||||
->set($db->quoteName('published') . ' = ' . (int) ($data['published'] ?? 1))
|
||||
->where($db->quoteName('parent_id') . ' = ' . $setId)
|
||||
)->execute();
|
||||
}
|
||||
|
||||
$db->setQuery(
|
||||
$db->getQuery(true)
|
||||
->delete($db->quoteName('#__testquestions_set_questions'))
|
||||
|
||||
@@ -28,7 +28,11 @@ HTMLHelper::_('behavior.formvalidator');
|
||||
<?php echo $this->form->renderField('test_content'); ?>
|
||||
<?php echo $this->form->renderField('image'); ?>
|
||||
<?php echo $this->form->renderField('description'); ?>
|
||||
<?php echo $this->form->renderField('published'); ?>
|
||||
<?php if ($this->isVariant) : ?>
|
||||
<div class="alert alert-info"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_SET_VARIANT_STATUS_INHERITED'); ?></div>
|
||||
<?php else : ?>
|
||||
<?php echo $this->form->renderField('published'); ?>
|
||||
<?php endif; ?>
|
||||
<?php if ((int) $this->item->id > 0 && (string) $this->item->set_type === 'multi') : ?>
|
||||
<fieldset class="mb-3">
|
||||
<legend><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_SET_VARIANTS'); ?></legend>
|
||||
|
||||
@@ -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.12</version>
|
||||
<version>1.43.14</version>
|
||||
<description>COM_TESTQUESTIONS_DESCRIPTION</description>
|
||||
<element>com_testquestions</element>
|
||||
<namespace path="src">Komponent\Component\Testquestions</namespace>
|
||||
|
||||
@@ -3,6 +3,17 @@
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
|
||||
$resolveImageUrl = static function ($path) {
|
||||
$path = trim((string) $path);
|
||||
|
||||
if ($path === '' || preg_match('#^https?://#i', $path)) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
return Uri::root() . ltrim($path, '/');
|
||||
};
|
||||
?>
|
||||
<div class="com-testquestions egzamin">
|
||||
<h1><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS'); ?></h1>
|
||||
@@ -43,7 +54,7 @@ use Joomla\CMS\HTML\HTMLHelper;
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($item->image) : ?>
|
||||
<div class="foto_pyt"><img src="<?php echo htmlspecialchars($item->image, ENT_QUOTES, 'UTF-8'); ?>" alt="" loading="lazy"></div>
|
||||
<div class="foto_pyt"><img src="<?php echo htmlspecialchars($resolveImageUrl($item->image), ENT_QUOTES, 'UTF-8'); ?>" alt="" loading="lazy"></div>
|
||||
<?php endif; ?>
|
||||
<?php if ($item->question_type === 'open') : ?>
|
||||
<div class="<?php echo $this->results ? ($this->results['items'][$item->id]['correct'] ? 'odpup' : 'odpu') : 'odp'; ?>">
|
||||
|
||||
@@ -3,6 +3,17 @@
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
|
||||
$resolveImageUrl = static function ($path) {
|
||||
$path = trim((string) $path);
|
||||
|
||||
if ($path === '' || preg_match('#^https?://#i', $path)) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
return Uri::root() . ltrim($path, '/');
|
||||
};
|
||||
?>
|
||||
<div class="com-testquestions egzamin">
|
||||
<?php if (!$this->started) : ?>
|
||||
@@ -44,7 +55,7 @@ use Joomla\CMS\Factory;
|
||||
<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 ($this->set->image) : ?><div class="foto_pyt"><img src="<?php echo htmlspecialchars($this->set->image, ENT_QUOTES, 'UTF-8'); ?>" alt="" loading="lazy"></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) : ?>
|
||||
@@ -64,7 +75,7 @@ use Joomla\CMS\Factory;
|
||||
<?php foreach ($this->items as $number => $item) : ?>
|
||||
<article class="testquestion mb-4">
|
||||
<div class="pyt"><div class="question-header"><span class="question-number"><?php echo ($number + 1) . '.'; ?></span><div class="question-text"><?php echo $item->question; ?></div></div></div>
|
||||
<?php if ($item->image) : ?><div class="foto_pyt"><img src="<?php echo htmlspecialchars($item->image, ENT_QUOTES, 'UTF-8'); ?>" alt="" loading="lazy"></div><?php endif; ?>
|
||||
<?php if ($item->image) : ?><div class="foto_pyt"><img src="<?php echo htmlspecialchars($resolveImageUrl($item->image), ENT_QUOTES, 'UTF-8'); ?>" alt="" loading="lazy"></div><?php endif; ?>
|
||||
<?php if ($item->question_type === 'open') : ?>
|
||||
<div class="<?php echo $this->results ? ($this->results['items'][$item->id]['correct'] ? 'odpup' : 'odpu') : 'odp'; ?>">
|
||||
<?php if ($this->results) : ?>
|
||||
|
||||
Reference in New Issue
Block a user