Add read-only test question preview
This commit is contained in:
@@ -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>
|
||||
Reference in New Issue
Block a user