Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c9076d4a22 |
@@ -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.15).
|
||||
W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.43.16).
|
||||
|
||||
Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**.
|
||||
|
||||
@@ -87,6 +87,7 @@ COM_TESTQUESTIONS_PREVIEW_READONLY="Tryb podglądu — odpowiedzi są nieaktywne
|
||||
COM_TESTQUESTIONS_PREVIEW_EMPTY="Nie znaleziono pytań do wyświetlenia."
|
||||
COM_TESTQUESTIONS_PREVIEW_SELECT_QUESTIONS="Zaznacz pytania, które chcesz podejrzeć."
|
||||
COM_TESTQUESTIONS_PREVIEW_BACK="Wróć do listy pytań"
|
||||
COM_TESTQUESTIONS_PREVIEW_SET="Podgląd zestawu"
|
||||
COM_TESTQUESTIONS_AI_SETTINGS_MENU="Konfiguracja AI"
|
||||
COM_TESTQUESTIONS_AI_SETTINGS_SAVED="Ustawienia AI zapisano."
|
||||
COM_TESTQUESTIONS_AI_SAVE_FAILED="Nie udało się zapisać ustawień AI."
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
-- No database changes required for version 1.43.16.
|
||||
@@ -9,16 +9,47 @@ use Joomla\CMS\MVC\Model\BaseDatabaseModel;
|
||||
|
||||
class PreviewModel extends BaseDatabaseModel
|
||||
{
|
||||
public function getSet()
|
||||
{
|
||||
$setId = Factory::getApplication()->getInput()->getInt('set_id');
|
||||
if ($setId < 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$db = Factory::getContainer()->get('DatabaseDriver');
|
||||
|
||||
return $db->setQuery(
|
||||
$db->getQuery(true)
|
||||
->select(['id', 'title', 'test_content', 'image'])
|
||||
->from($db->quoteName('#__testquestions_sets'))
|
||||
->where($db->quoteName('id') . ' = ' . $setId)
|
||||
)->loadObject();
|
||||
}
|
||||
|
||||
public function getItems(): array
|
||||
{
|
||||
$input = Factory::getApplication()->getInput();
|
||||
$setId = $input->getInt('set_id');
|
||||
$db = Factory::getContainer()->get('DatabaseDriver');
|
||||
|
||||
if ($setId > 0) {
|
||||
return $db->setQuery(
|
||||
$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.image'])
|
||||
->from($db->quoteName('#__testquestions_set_questions', 'sq'))
|
||||
->innerJoin($db->quoteName('#__testquestions_questions', 'q') . ' ON q.id = sq.question_id')
|
||||
->where('sq.set_id = ' . $setId)
|
||||
->where('q.published = 1')
|
||||
->order('sq.ordering ASC, q.id ASC')
|
||||
)->loadObjectList();
|
||||
}
|
||||
|
||||
$ids = array_values(array_unique(array_filter(array_map('intval', explode(',', $input->getString('ids', ''))))));
|
||||
|
||||
if (!$ids) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$db = Factory::getContainer()->get('DatabaseDriver');
|
||||
$rows = $db->setQuery(
|
||||
$db->getQuery(true)
|
||||
->select(['id', 'question_type', 'question', 'answer_a', 'answer_b', 'answer_c', 'answer_d', 'answer_open', 'correct_answer', 'image'])
|
||||
|
||||
@@ -7,11 +7,13 @@ defined('_JEXEC') or die;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
protected $items = [];
|
||||
protected $set;
|
||||
|
||||
public function display($tpl = null)
|
||||
{
|
||||
@@ -21,12 +23,19 @@ class HtmlView extends BaseHtmlView
|
||||
}
|
||||
|
||||
$this->items = $this->get('Items');
|
||||
$this->set = $this->get('Set');
|
||||
$this->getDocument()->getWebAssetManager()->registerAndUseStyle(
|
||||
'com_testquestions.exam',
|
||||
'media/com_testquestions/egzamin.css'
|
||||
);
|
||||
ToolbarHelper::title(Text::_('COM_TESTQUESTIONS_PREVIEW_TITLE'));
|
||||
ToolbarHelper::link('index.php?option=com_testquestions&view=questions', 'COM_TESTQUESTIONS', 'arrow-left');
|
||||
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',
|
||||
'arrow-left'
|
||||
);
|
||||
|
||||
return parent::display($tpl);
|
||||
}
|
||||
|
||||
@@ -47,6 +47,13 @@ class HtmlView extends BaseHtmlView
|
||||
protected function addToolbar()
|
||||
{
|
||||
ToolbarHelper::title($this->item->id ? Text::_('COM_TESTQUESTIONS_EDIT_SET') : Text::_('COM_TESTQUESTIONS_NEW_SET'));
|
||||
if (!empty($this->item->id) && ((string) $this->item->set_type !== 'multi' || $this->isVariant)) {
|
||||
ToolbarHelper::link(
|
||||
'index.php?option=com_testquestions&view=preview&set_id=' . (int) $this->item->id,
|
||||
'COM_TESTQUESTIONS_PREVIEW_SET',
|
||||
'eye'
|
||||
);
|
||||
}
|
||||
ToolbarHelper::custom('set.save', 'save', 'save', 'COM_TESTQUESTIONS_SET_SAVE', false);
|
||||
ToolbarHelper::custom('set.saveandclose', 'save', 'save', 'COM_TESTQUESTIONS_SET_SAVE_AND_CLOSE', false);
|
||||
ToolbarHelper::cancel('set.cancel', 'JTOOLBAR_CANCEL');
|
||||
|
||||
@@ -17,6 +17,15 @@ $resolveImageUrl = static function ($path) {
|
||||
?>
|
||||
<div class="com-testquestions egzamin">
|
||||
<p class="alert alert-info"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_PREVIEW_READONLY'); ?></p>
|
||||
<?php if ($this->set) : ?>
|
||||
<header class="test-set-header">
|
||||
<h1><?php echo htmlspecialchars($this->set->title, ENT_QUOTES, 'UTF-8'); ?></h1>
|
||||
<?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 endif; ?>
|
||||
<?php if (!$this->items) : ?>
|
||||
<div class="alert alert-warning"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_PREVIEW_EMPTY'); ?></div>
|
||||
<?php else : ?>
|
||||
@@ -54,7 +63,7 @@ $resolveImageUrl = static function ($path) {
|
||||
</article>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
<a class="btn btn-secondary" href="<?php echo Route::_('index.php?option=com_testquestions&view=questions'); ?>">
|
||||
<?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_PREVIEW_BACK'); ?>
|
||||
<a class="btn btn-secondary" href="<?php echo $this->set ? Route::_('index.php?option=com_testquestions&task=set.edit&id=' . (int) $this->set->id) : Route::_('index.php?option=com_testquestions&view=questions'); ?>">
|
||||
<?php echo $this->set ? \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_EDIT_SET') : \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_PREVIEW_BACK'); ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -40,8 +40,13 @@ HTMLHelper::_('behavior.formvalidator');
|
||||
<ul class="list-group mb-3">
|
||||
<?php foreach ($this->variants as $variant) : ?>
|
||||
<li class="list-group-item d-flex justify-content-between align-items-center">
|
||||
<a href="<?php echo Route::_('index.php?option=com_testquestions&task=set.edit&id=' . (int) $variant->id); ?>"><?php echo $this->escape($variant->title); ?></a>
|
||||
<span class="badge <?php echo (int) $variant->published ? 'bg-success' : 'bg-secondary'; ?>"><?php echo (int) $variant->published ? \Joomla\CMS\Language\Text::_('JPUBLISHED') : \Joomla\CMS\Language\Text::_('JUNPUBLISHED'); ?></span>
|
||||
<span>
|
||||
<a href="<?php echo Route::_('index.php?option=com_testquestions&task=set.edit&id=' . (int) $variant->id); ?>"><?php echo $this->escape($variant->title); ?></a>
|
||||
<span class="badge <?php echo (int) $variant->published ? 'bg-success' : 'bg-secondary'; ?>"><?php echo (int) $variant->published ? \Joomla\CMS\Language\Text::_('JPUBLISHED') : \Joomla\CMS\Language\Text::_('JUNPUBLISHED'); ?></span>
|
||||
</span>
|
||||
<a class="btn btn-sm btn-outline-secondary" href="<?php echo Route::_('index.php?option=com_testquestions&view=preview&set_id=' . (int) $variant->id); ?>">
|
||||
<?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_PREVIEW_SET'); ?>
|
||||
</a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
||||
@@ -54,7 +54,12 @@ HTMLHelper::_('behavior.multiselect');
|
||||
<?php foreach ($this->items as $i => $item) : ?>
|
||||
<tr>
|
||||
<td><?php echo HTMLHelper::_('grid.id', $i, $item->id); ?></td>
|
||||
<th scope="row"><a href="<?php echo Route::_('index.php?option=com_testquestions&task=set.edit&id=' . (int) $item->id); ?>"><?php echo (int) $item->parent_id > 0 ? '↳ ' : ''; ?><?php echo $this->escape($item->title); ?></a><?php if ((int) $item->parent_id > 0 && $item->parent_title) : ?> <small class="text-muted">(<?php echo $this->escape($item->parent_title); ?>)</small><?php endif; ?></th>
|
||||
<th scope="row">
|
||||
<a href="<?php echo Route::_('index.php?option=com_testquestions&task=set.edit&id=' . (int) $item->id); ?>"><?php echo (int) $item->parent_id > 0 ? '↳ ' : ''; ?><?php echo $this->escape($item->title); ?></a><?php if ((int) $item->parent_id > 0 && $item->parent_title) : ?> <small class="text-muted">(<?php echo $this->escape($item->parent_title); ?>)</small><?php endif; ?>
|
||||
<?php if ($item->set_type === 'ordinary') : ?>
|
||||
<a class="btn btn-sm btn-outline-secondary ms-2" href="<?php echo Route::_('index.php?option=com_testquestions&view=preview&set_id=' . (int) $item->id); ?>"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_PREVIEW_SET'); ?></a>
|
||||
<?php endif; ?>
|
||||
</th>
|
||||
<td><?php echo $this->escape($item->set_type === 'multi' ? \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_SET_TYPE_MULTI') : ($item->set_type === 'variant' ? \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_SET_TYPE_VARIANT') : \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_SET_TYPE_ORDINARY'))); ?></td>
|
||||
<td><?php echo $this->escape($item->subject_title ?: '—'); ?></td>
|
||||
<td><?php echo (int) $item->question_count; ?></td>
|
||||
|
||||
@@ -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.15</version>
|
||||
<version>1.43.16</version>
|
||||
<description>COM_TESTQUESTIONS_DESCRIPTION</description>
|
||||
<element>com_testquestions</element>
|
||||
<namespace path="src">Komponent\Component\Testquestions</namespace>
|
||||
|
||||
Reference in New Issue
Block a user