Initial Joomla test questions component

This commit is contained in:
Wojtek
2026-10-14 22:29:10 +02:00
commit 9b093b278d
44 changed files with 964 additions and 0 deletions
@@ -0,0 +1,24 @@
<?php defined('_JEXEC') or die; ?>
<form action="index.php?option=com_testquestions&view=categories" method="post" name="adminForm" id="adminForm">
<table class="table table-striped">
<thead><tr>
<th><?php echo Joomla\CMS\HTML\HTMLHelper::_('grid.checkall'); ?></th>
<th><?php echo Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_CATEGORY_TITLE'); ?></th>
<th><?php echo Joomla\CMS\Language\Text::_('JSTATUS'); ?></th>
<th><?php echo Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_COLUMN_ID'); ?></th>
</tr></thead>
<tbody>
<?php foreach ($this->items as $i => $item) : ?>
<tr>
<td><?php echo Joomla\CMS\HTML\HTMLHelper::_('grid.id', $i, $item->id); ?></td>
<th><a href="index.php?option=com_testquestions&task=category.edit&id=<?php echo (int) $item->id; ?>"><?php echo htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8'); ?></a></th>
<td><?php echo $item->published ? Joomla\CMS\Language\Text::_('JPUBLISHED') : Joomla\CMS\Language\Text::_('JUNPUBLISHED'); ?></td>
<td><?php echo (int) $item->id; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<input type="hidden" name="boxchecked" value="0">
<input type="hidden" name="task" value="">
<?php echo Joomla\CMS\HTML\HTMLHelper::_('form.token'); ?>
</form>
@@ -0,0 +1,13 @@
<?php defined('_JEXEC') or die; ?>
<form action="index.php?option=com_testquestions&layout=edit&id=<?php echo (int) $this->item->id; ?>" method="post" name="adminForm" id="category-form">
<?php echo $this->form->renderField('title'); ?>
<?php echo $this->form->renderField('published'); ?>
<?php echo $this->form->renderField('id'); ?>
<div class="mt-3">
<a class="btn btn-secondary" href="<?php echo Joomla\CMS\Router\Route::_('index.php?option=com_testquestions&view=questions'); ?>">
<?php echo Joomla\CMS\Language\Text::_('JTOOLBAR_CANCEL'); ?>
</a>
</div>
<input type="hidden" name="task" value="category.save">
<?php echo Joomla\CMS\HTML\HTMLHelper::_('form.token'); ?>
</form>
@@ -0,0 +1,33 @@
<?php
defined('_JEXEC') or die;
?>
<form action="<?php echo Joomla\CMS\Router\Route::_('index.php?option=com_testquestions&layout=edit&id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="question-form">
<div class="row">
<div class="col-lg-8">
<?php echo $this->form->renderField('question_type'); ?>
<?php echo $this->form->renderField('question'); ?>
<?php echo $this->form->renderField('answer_a'); ?>
<?php echo $this->form->renderField('answer_b'); ?>
<?php echo $this->form->renderField('answer_c'); ?>
<?php echo $this->form->renderField('answer_d'); ?>
<?php echo $this->form->renderField('correct_answer'); ?>
<?php echo $this->form->renderField('answer_open'); ?>
</div>
<div class="col-lg-4">
<?php echo $this->form->renderField('category_id'); ?>
<?php echo $this->form->renderField('time_limit'); ?>
<?php echo $this->form->renderField('points'); ?>
<?php echo $this->form->renderField('image'); ?>
<?php echo $this->form->renderField('published'); ?>
</div>
</div>
<?php echo $this->form->renderField('id'); ?>
<div class="mt-3">
<a class="btn btn-secondary" href="<?php echo Joomla\CMS\Router\Route::_('index.php?option=com_testquestions&view=questions'); ?>">
<?php echo Joomla\CMS\Language\Text::_('JTOOLBAR_CANCEL'); ?>
</a>
</div>
<input type="hidden" name="task" value="question.save">
<?php echo Joomla\CMS\HTML\HTMLHelper::_('form.token'); ?>
</form>
@@ -0,0 +1,73 @@
<?php
defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Router\Route;
HTMLHelper::_('behavior.multiselect');
?>
<form action="<?php echo Route::_('index.php?option=com_testquestions&view=questions'); ?>" method="post" name="adminForm" id="adminForm">
<div class="row mb-3">
<div class="col-md-4">
<input type="text" name="filter_search" id="filter_search" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" class="form-control" placeholder="<?php echo $this->escape(\Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_SEARCH_PLACEHOLDER')); ?>">
</div>
<div class="col-md-2">
<select name="filter_published" class="form-select" onchange="this.form.submit();">
<option value=""><?php echo \Joomla\CMS\Language\Text::_('JOPTION_SELECT_PUBLISHED'); ?></option>
<option value="1" <?php echo $this->state->get('filter.published') === '1' ? 'selected' : ''; ?>><?php echo \Joomla\CMS\Language\Text::_('JPUBLISHED'); ?></option>
<option value="0" <?php echo $this->state->get('filter.published') === '0' ? 'selected' : ''; ?>><?php echo \Joomla\CMS\Language\Text::_('JUNPUBLISHED'); ?></option>
</select>
</div>
<div class="col-md-2">
<select name="filter_category_id" class="form-select" onchange="this.form.submit();">
<option value=""><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_FILTER_CATEGORY'); ?></option>
<?php foreach ($this->categories as $category) : ?>
<option value="<?php echo (int) $category->id; ?>" <?php echo (int) $this->state->get('filter.category_id') === (int) $category->id ? 'selected' : ''; ?>>
<?php echo $this->escape($category->title); ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="col-md-2">
<button type="submit" class="btn btn-primary"><?php echo \Joomla\CMS\Language\Text::_('JSEARCH_FILTER_SUBMIT'); ?></button>
<a href="<?php echo Route::_('index.php?option=com_testquestions&view=questions'); ?>" class="btn btn-secondary"><?php echo \Joomla\CMS\Language\Text::_('JSEARCH_FILTER_CLEAR'); ?></a>
</div>
</div>
<table class="table table-striped" id="questionList">
<caption class="visually-hidden"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS'); ?></caption>
<thead>
<tr>
<th scope="col" class="w-1"><?php echo HTMLHelper::_('grid.checkall'); ?></th>
<th scope="col"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_COLUMN_QUESTION'); ?></th>
<th scope="col" class="w-10"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_COLUMN_TYPE'); ?></th>
<th scope="col" class="w-10"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_COLUMN_CORRECT'); ?></th>
<th scope="col" class="w-10"><?php echo \Joomla\CMS\Language\Text::_('JSTATUS'); ?></th>
<th scope="col" class="w-10"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_COLUMN_ID'); ?></th>
</tr>
</thead>
<tbody>
<?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=question.edit&id=' . (int) $item->id); ?>">
<?php echo $this->escape(strip_tags($item->question)); ?>
</a>
<?php if ($item->image) : ?><span class="icon-image ms-2" title="<?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_HAS_IMAGE'); ?>"></span><?php endif; ?>
</th>
<td><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_TYPE_' . strtoupper($item->question_type)); ?></td>
<td><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_ANSWER_' . chr(64 + (int) $item->correct_answer)); ?></td>
<td><?php echo HTMLHelper::_('jgrid.published', $item->published, $i, 'questions.', true, 'cb'); ?></td>
<td><?php echo (int) $item->id; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php echo $this->pagination->getListFooter(); ?>
<input type="hidden" name="boxchecked" value="0">
<input type="hidden" name="task" value="">
<?php echo HTMLHelper::_('form.token'); ?>
</form>