70 lines
3.8 KiB
PHP
70 lines
3.8 KiB
PHP
<?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->set) : ?>
|
|
<header class="test-set-header">
|
|
<h1><?php echo htmlspecialchars($this->set->title, ENT_QUOTES, 'UTF-8'); ?></h1>
|
|
<?php if ($this->set->test_content) : ?><div class="test-set-content"><?php echo $this->set->test_content; ?></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; ?>
|
|
</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 : ?>
|
|
<?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 $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>
|