Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
606612784c | ||
|
|
ef5410689d |
@@ -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.13).
|
||||
W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.43.15).
|
||||
|
||||
Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**.
|
||||
|
||||
@@ -81,6 +81,12 @@ COM_TESTQUESTIONS_AI_USAGE_INPUT="Tokeny wejściowe"
|
||||
COM_TESTQUESTIONS_AI_USAGE_OUTPUT="Tokeny wyjściowe"
|
||||
COM_TESTQUESTIONS_AI_USAGE_TOTAL="Razem tokenów"
|
||||
COM_TESTQUESTIONS_AI_USAGE_COST="Koszt zapisany"
|
||||
COM_TESTQUESTIONS_PREVIEW_SELECTED="Podgląd zaznaczonych"
|
||||
COM_TESTQUESTIONS_PREVIEW_TITLE="Podgląd pytań testowych"
|
||||
COM_TESTQUESTIONS_PREVIEW_READONLY="Tryb podglądu — odpowiedzi są nieaktywne, test nie ma limitu czasu ani przycisku zakończenia."
|
||||
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_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.14.
|
||||
@@ -0,0 +1 @@
|
||||
-- No database changes required for version 1.43.15.
|
||||
@@ -4,7 +4,11 @@ namespace Komponent\Component\Testquestions\Administrator\Controller;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\Controller\AdminController;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Session\Session;
|
||||
|
||||
class QuestionsController extends AdminController
|
||||
{
|
||||
@@ -14,4 +18,28 @@ class QuestionsController extends AdminController
|
||||
{
|
||||
return parent::getModel($name, $prefix, $config);
|
||||
}
|
||||
|
||||
public function preview(): void
|
||||
{
|
||||
if (!Session::checkToken()) {
|
||||
throw new \RuntimeException(Text::_('JINVALID_TOKEN'), 403);
|
||||
}
|
||||
|
||||
$user = Factory::getApplication()->getIdentity();
|
||||
if (!$user->authorise('core.edit', 'com_testquestions') && !$user->authorise('core.manage', 'com_testquestions')) {
|
||||
throw new \RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
|
||||
}
|
||||
|
||||
$ids = array_values(array_unique(array_filter(array_map('intval', (array) $this->input->post->get('cid', [], 'array')))));
|
||||
if (!$ids) {
|
||||
$this->setRedirect(
|
||||
Route::_('index.php?option=com_testquestions&view=questions', false),
|
||||
Text::_('COM_TESTQUESTIONS_PREVIEW_SELECT_QUESTIONS'),
|
||||
'warning'
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->setRedirect(Route::_('index.php?option=com_testquestions&view=preview&ids=' . implode(',', $ids), false));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Komponent\Component\Testquestions\Administrator\Model;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
|
||||
|
||||
class PreviewModel extends BaseDatabaseModel
|
||||
{
|
||||
public function getItems(): array
|
||||
{
|
||||
$input = Factory::getApplication()->getInput();
|
||||
$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'])
|
||||
->from($db->quoteName('#__testquestions_questions'))
|
||||
->where($db->quoteName('id') . ' IN (' . implode(',', $ids) . ')')
|
||||
)->loadObjectList('id');
|
||||
|
||||
$items = [];
|
||||
foreach ($ids as $id) {
|
||||
if (isset($rows[$id])) {
|
||||
$items[] = $rows[$id];
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace Komponent\Component\Testquestions\Administrator\View\Preview;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
|
||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||
|
||||
class HtmlView extends BaseHtmlView
|
||||
{
|
||||
protected $items = [];
|
||||
|
||||
public function display($tpl = null)
|
||||
{
|
||||
$user = Factory::getApplication()->getIdentity();
|
||||
if (!$user->authorise('core.edit', 'com_testquestions') && !$user->authorise('core.manage', 'com_testquestions')) {
|
||||
throw new \RuntimeException(Text::_('JERROR_ALERTNOAUTHOR'), 403);
|
||||
}
|
||||
|
||||
$this->items = $this->get('Items');
|
||||
$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');
|
||||
|
||||
return parent::display($tpl);
|
||||
}
|
||||
}
|
||||
@@ -41,6 +41,7 @@ class HtmlView extends BaseHtmlView
|
||||
}
|
||||
if ($user->authorise('core.edit', 'com_testquestions')) {
|
||||
ToolbarHelper::editList('question.edit', 'JTOOLBAR_EDIT');
|
||||
ToolbarHelper::custom('questions.preview', 'eye', 'eye', 'COM_TESTQUESTIONS_PREVIEW_SELECTED', true);
|
||||
}
|
||||
if ($user->authorise('core.delete', 'com_testquestions')) {
|
||||
ToolbarHelper::deleteList('', 'questions.delete', 'JTOOLBAR_DELETE');
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Router\Route;
|
||||
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">
|
||||
<p class="alert alert-info"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_PREVIEW_READONLY'); ?></p>
|
||||
<?php if (!$this->items) : ?>
|
||||
<div class="alert alert-warning"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_PREVIEW_EMPTY'); ?></div>
|
||||
<?php else : ?>
|
||||
<?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($resolveImageUrl($item->image), ENT_QUOTES, 'UTF-8'); ?>" alt="" loading="lazy"></div>
|
||||
<?php endif; ?>
|
||||
<?php if ($item->question_type === 'open') : ?>
|
||||
<div class="odp">
|
||||
<strong><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_CORRECT_PATTERN'); ?>:</strong>
|
||||
<?php echo htmlspecialchars((string) $item->answer_open, ENT_QUOTES, 'UTF-8'); ?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<ol type="A" class="answer-list">
|
||||
<?php foreach (['answer_a', 'answer_b', 'answer_c', 'answer_d'] as $answerIndex => $answerField) : ?>
|
||||
<?php $isCorrect = (int) $item->correct_answer === $answerIndex + 1; ?>
|
||||
<li class="<?php echo $isCorrect ? 'odpp' : 'odp'; ?>">
|
||||
<label>
|
||||
<input type="radio" disabled <?php echo $isCorrect ? 'checked' : ''; ?>>
|
||||
<strong><?php echo chr(65 + $answerIndex); ?>.</strong>
|
||||
<span class="answer-text"><?php echo $item->$answerField; ?></span>
|
||||
<?php if ($isCorrect) : ?><span class="text-success ms-1" title="<?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_CORRECT_ANSWER'); ?>">✓</span><?php endif; ?>
|
||||
</label>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ol>
|
||||
<?php endif; ?>
|
||||
</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>
|
||||
</div>
|
||||
@@ -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.13</version>
|
||||
<version>1.43.15</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