Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
33783399f9 | ||
|
|
3fd488e19e | ||
|
|
301f322017 |
@@ -30,6 +30,6 @@ Szkielet komponentu Joomla 6 do gromadzenia pytań testowych.
|
|||||||
|
|
||||||
## Instalacja
|
## Instalacja
|
||||||
|
|
||||||
W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.28.2).
|
W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.31.0).
|
||||||
|
|
||||||
Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**.
|
Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**.
|
||||||
|
|||||||
@@ -77,6 +77,10 @@ COM_TESTQUESTIONS_RESULT_SAVED="Dane wyniku zostały zapisane."
|
|||||||
COM_TESTQUESTIONS_RESULT_SAVE="Zapisz"
|
COM_TESTQUESTIONS_RESULT_SAVE="Zapisz"
|
||||||
COM_TESTQUESTIONS_RESULT_SAVE_AND_CLOSE="Zapisz i zamknij"
|
COM_TESTQUESTIONS_RESULT_SAVE_AND_CLOSE="Zapisz i zamknij"
|
||||||
COM_TESTQUESTIONS_RESULTS_SEARCH="Szukaj po użytkowniku lub zestawie..."
|
COM_TESTQUESTIONS_RESULTS_SEARCH="Szukaj po użytkowniku lub zestawie..."
|
||||||
|
COM_TESTQUESTIONS_RESULTS_TEST_NAME="Nazwa testu"
|
||||||
|
COM_TESTQUESTIONS_RESULTS_ALL_TESTS="Wszystkie zestawy"
|
||||||
|
COM_TESTQUESTIONS_RESULTS_DATE_FROM="Data od"
|
||||||
|
COM_TESTQUESTIONS_RESULTS_DATE_TO="Data do"
|
||||||
COM_TESTQUESTIONS_YOUR_ANSWER="Twoja odpowiedź"
|
COM_TESTQUESTIONS_YOUR_ANSWER="Twoja odpowiedź"
|
||||||
COM_TESTQUESTIONS_SELECTED_ANSWER="Zaznaczona odpowiedź"
|
COM_TESTQUESTIONS_SELECTED_ANSWER="Zaznaczona odpowiedź"
|
||||||
COM_TESTQUESTIONS_ANSWER_CORRECT="Poprawna odpowiedź"
|
COM_TESTQUESTIONS_ANSWER_CORRECT="Poprawna odpowiedź"
|
||||||
|
|||||||
@@ -84,6 +84,7 @@ CREATE TABLE IF NOT EXISTS `#__testquestions_results` (
|
|||||||
`correct_count` smallint unsigned NOT NULL DEFAULT 0,
|
`correct_count` smallint unsigned NOT NULL DEFAULT 0,
|
||||||
`total_count` smallint unsigned NOT NULL DEFAULT 0,
|
`total_count` smallint unsigned NOT NULL DEFAULT 0,
|
||||||
`percentage` decimal(5,2) NOT NULL DEFAULT 0.00,
|
`percentage` decimal(5,2) NOT NULL DEFAULT 0.00,
|
||||||
|
`points_total` int unsigned NOT NULL DEFAULT 0,
|
||||||
`points_before` int unsigned NOT NULL DEFAULT 0,
|
`points_before` int unsigned NOT NULL DEFAULT 0,
|
||||||
`points_after` int unsigned NOT NULL DEFAULT 0,
|
`points_after` int unsigned NOT NULL DEFAULT 0,
|
||||||
`answers` longtext NULL,
|
`answers` longtext NULL,
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
ALTER TABLE `#__testquestions_results`
|
||||||
|
ADD COLUMN `points_total` int unsigned NOT NULL DEFAULT 0 AFTER `percentage`;
|
||||||
|
|
||||||
|
UPDATE `#__testquestions_results`
|
||||||
|
SET `points_total` = `total_count`
|
||||||
|
WHERE `points_total` = 0;
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
-- No database changes required for version 1.30.0.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
-- No database changes required for version 1.31.0.
|
||||||
@@ -13,6 +13,9 @@ class ResultsModel extends ListModel
|
|||||||
{
|
{
|
||||||
parent::populateState($ordering, $direction);
|
parent::populateState($ordering, $direction);
|
||||||
$this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string'));
|
$this->setState('filter.search', $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search', '', 'string'));
|
||||||
|
$this->setState('filter.set_id', $this->getUserStateFromRequest($this->context . '.filter.set_id', 'filter_set_id', 0, 'int'));
|
||||||
|
$this->setState('filter.date_from', $this->getUserStateFromRequest($this->context . '.filter.date_from', 'filter_date_from', '', 'string'));
|
||||||
|
$this->setState('filter.date_to', $this->getUserStateFromRequest($this->context . '.filter.date_to', 'filter_date_to', '', 'string'));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getListQuery()
|
protected function getListQuery()
|
||||||
@@ -30,6 +33,34 @@ class ResultsModel extends ListModel
|
|||||||
$query->where('(r.participant_name LIKE ' . $needle . ' OR s.title LIKE ' . $needle . ')');
|
$query->where('(r.participant_name LIKE ' . $needle . ' OR s.title LIKE ' . $needle . ')');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$setId = (int) $this->getState('filter.set_id');
|
||||||
|
if ($setId > 0) {
|
||||||
|
$query->where('r.set_id = ' . $setId);
|
||||||
|
}
|
||||||
|
|
||||||
|
$dateFrom = (string) $this->getState('filter.date_from');
|
||||||
|
if (preg_match('/^\d{4}-\d{2}-\d{2}$/', $dateFrom)) {
|
||||||
|
$query->where('r.created >= ' . $db->quote($dateFrom . ' 00:00:00'));
|
||||||
|
}
|
||||||
|
|
||||||
|
$dateTo = (string) $this->getState('filter.date_to');
|
||||||
|
if (preg_match('/^\d{4}-\d{2}-\d{2}$/', $dateTo)) {
|
||||||
|
$query->where('r.created <= ' . $db->quote($dateTo . ' 23:59:59'));
|
||||||
|
}
|
||||||
|
|
||||||
return $query->order('r.created DESC, r.id DESC');
|
return $query->order('r.created DESC, r.id DESC');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getSets(): array
|
||||||
|
{
|
||||||
|
$db = Factory::getContainer()->get('DatabaseDriver');
|
||||||
|
|
||||||
|
return $db->setQuery(
|
||||||
|
$db->getQuery(true)
|
||||||
|
->select(['s.id', 's.title', 's.published', 'sub.title AS subject_title'])
|
||||||
|
->from($db->quoteName('#__testquestions_sets', 's'))
|
||||||
|
->leftJoin($db->quoteName('#__testquestions_subjects', 'sub') . ' ON sub.id = s.subject_id')
|
||||||
|
->order('sub.title ASC, s.title ASC, s.id ASC')
|
||||||
|
)->loadObjectList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,12 +14,14 @@ class HtmlView extends BaseHtmlView
|
|||||||
protected $items;
|
protected $items;
|
||||||
protected $pagination;
|
protected $pagination;
|
||||||
protected $state;
|
protected $state;
|
||||||
|
protected $sets;
|
||||||
|
|
||||||
public function display($tpl = null)
|
public function display($tpl = null)
|
||||||
{
|
{
|
||||||
$this->items = $this->get('Items');
|
$this->items = $this->get('Items');
|
||||||
$this->pagination = $this->get('Pagination');
|
$this->pagination = $this->get('Pagination');
|
||||||
$this->state = $this->get('State');
|
$this->state = $this->get('State');
|
||||||
|
$this->sets = $this->get('Sets');
|
||||||
ToolbarHelper::title(Text::_('COM_TESTQUESTIONS_RESULTS'));
|
ToolbarHelper::title(Text::_('COM_TESTQUESTIONS_RESULTS'));
|
||||||
ToolbarHelper::link('index.php?option=com_testquestions&view=sets', 'COM_TESTQUESTIONS_SETS', 'back');
|
ToolbarHelper::link('index.php?option=com_testquestions&view=sets', 'COM_TESTQUESTIONS_SETS', 'back');
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,26 @@ use Joomla\CMS\Router\Route;
|
|||||||
<div class="col-md-6">
|
<div class="col-md-6">
|
||||||
<input type="text" name="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_RESULTS_SEARCH')); ?>">
|
<input type="text" name="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_RESULTS_SEARCH')); ?>">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3"><button type="submit" class="btn btn-primary"><?php echo \Joomla\CMS\Language\Text::_('JSEARCH_FILTER_SUBMIT'); ?></button></div>
|
<div class="col-md-6">
|
||||||
|
<label for="filter-set-id" class="form-label"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULTS_TEST_NAME'); ?></label>
|
||||||
|
<select name="filter_set_id" id="filter-set-id" class="form-select">
|
||||||
|
<option value="0"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULTS_ALL_TESTS'); ?></option>
|
||||||
|
<?php foreach ($this->sets as $set) : ?>
|
||||||
|
<option value="<?php echo (int) $set->id; ?>" <?php echo (int) $this->state->get('filter.set_id') === (int) $set->id ? 'selected' : ''; ?>><?php echo $this->escape(($set->subject_title ? $set->subject_title . ' — ' : '') . $set->title . (!(int) $set->published ? ' (nieopublikowany)' : '')); ?></option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row mb-3">
|
||||||
|
<div class="col-md-3">
|
||||||
|
<label for="filter-date-from" class="form-label"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULTS_DATE_FROM'); ?></label>
|
||||||
|
<input type="date" name="filter_date_from" id="filter-date-from" value="<?php echo $this->escape($this->state->get('filter.date_from')); ?>" class="form-control">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3">
|
||||||
|
<label for="filter-date-to" class="form-label"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULTS_DATE_TO'); ?></label>
|
||||||
|
<input type="date" name="filter_date_to" id="filter-date-to" value="<?php echo $this->escape($this->state->get('filter.date_to')); ?>" class="form-control">
|
||||||
|
</div>
|
||||||
|
<div class="col-md-3 align-self-end"><button type="submit" class="btn btn-primary"><?php echo \Joomla\CMS\Language\Text::_('JSEARCH_FILTER_SUBMIT'); ?></button></div>
|
||||||
</div>
|
</div>
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead><tr>
|
<thead><tr>
|
||||||
@@ -25,7 +44,10 @@ use Joomla\CMS\Router\Route;
|
|||||||
<tr class="<?php echo (int) $item->extra_time > 0 ? 'table-warning' : ''; ?>">
|
<tr class="<?php echo (int) $item->extra_time > 0 ? 'table-warning' : ''; ?>">
|
||||||
<th><a href="<?php echo Route::_('index.php?option=com_testquestions&view=result&id=' . (int) $item->id); ?>"><?php echo $this->escape($item->participant_name); ?></a></th>
|
<th><a href="<?php echo Route::_('index.php?option=com_testquestions&view=result&id=' . (int) $item->id); ?>"><?php echo $this->escape($item->participant_name); ?></a></th>
|
||||||
<td><?php echo $this->escape(($item->subject_title ? $item->subject_title . ' — ' : '') . $item->set_title); ?></td>
|
<td><?php echo $this->escape(($item->subject_title ? $item->subject_title . ' — ' : '') . $item->set_title); ?></td>
|
||||||
<td><?php echo (int) $item->points_before; ?> / <?php echo (int) $item->points_after; ?></td>
|
<?php $pointsTotal = (int) $item->points_total ?: (int) $item->total_count; ?>
|
||||||
|
<?php $pointsBeforePercentage = $pointsTotal ? round(((int) $item->points_before / $pointsTotal) * 100, 2) : 0; ?>
|
||||||
|
<?php $pointsAfterPercentage = $pointsTotal ? round(((int) $item->points_after / $pointsTotal) * 100, 2) : 0; ?>
|
||||||
|
<td><?php echo (int) $item->points_before; ?> (<?php echo $pointsBeforePercentage; ?>%) / <?php echo (int) $item->points_after; ?> (<?php echo $pointsAfterPercentage; ?>%)</td>
|
||||||
<td><?php echo floor((int) $item->execution_time / 60); ?>:<?php echo str_pad((string) ((int) $item->execution_time % 60), 2, '0', STR_PAD_LEFT); ?></td>
|
<td><?php echo floor((int) $item->execution_time / 60); ?>:<?php echo str_pad((string) ((int) $item->execution_time % 60), 2, '0', STR_PAD_LEFT); ?></td>
|
||||||
<td><?php echo HTMLHelper::_('date', $item->created, 'Y-m-d H:i'); ?></td>
|
<td><?php echo HTMLHelper::_('date', $item->created, 'Y-m-d H:i'); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<creationDate>2026-10-14</creationDate>
|
<creationDate>2026-10-14</creationDate>
|
||||||
<author>Komponent</author>
|
<author>Komponent</author>
|
||||||
<license>GNU General Public License version 2 or later</license>
|
<license>GNU General Public License version 2 or later</license>
|
||||||
<version>1.28.2</version>
|
<version>1.31.0</version>
|
||||||
<description>COM_TESTQUESTIONS_DESCRIPTION</description>
|
<description>COM_TESTQUESTIONS_DESCRIPTION</description>
|
||||||
<element>com_testquestions</element>
|
<element>com_testquestions</element>
|
||||||
<namespace path="src">Komponent\Component\Testquestions</namespace>
|
<namespace path="src">Komponent\Component\Testquestions</namespace>
|
||||||
|
|||||||
@@ -82,7 +82,9 @@ class SetModel extends BaseDatabaseModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
$pointsBefore = 0;
|
$pointsBefore = 0;
|
||||||
|
$pointsTotal = 0;
|
||||||
foreach (($result['items'] ?? []) as $item) {
|
foreach (($result['items'] ?? []) as $item) {
|
||||||
|
$pointsTotal += (int) ($item['points'] ?? 0);
|
||||||
if (!empty($item['correct'])) {
|
if (!empty($item['correct'])) {
|
||||||
$pointsBefore += (int) ($item['points'] ?? 0);
|
$pointsBefore += (int) ($item['points'] ?? 0);
|
||||||
}
|
}
|
||||||
@@ -97,6 +99,7 @@ class SetModel extends BaseDatabaseModel
|
|||||||
'correct_count' => (int) ($result['correct'] ?? 0),
|
'correct_count' => (int) ($result['correct'] ?? 0),
|
||||||
'total_count' => (int) ($result['total'] ?? 0),
|
'total_count' => (int) ($result['total'] ?? 0),
|
||||||
'percentage' => (float) ($result['percentage'] ?? 0),
|
'percentage' => (float) ($result['percentage'] ?? 0),
|
||||||
|
'points_total' => $pointsTotal,
|
||||||
'points_before' => $pointsBefore,
|
'points_before' => $pointsBefore,
|
||||||
'points_after' => $pointsBefore,
|
'points_after' => $pointsBefore,
|
||||||
'answers' => json_encode($result['items'] ?? [], JSON_UNESCAPED_UNICODE),
|
'answers' => json_encode($result['items'] ?? [], JSON_UNESCAPED_UNICODE),
|
||||||
|
|||||||
@@ -85,6 +85,9 @@ class HtmlView extends BaseHtmlView
|
|||||||
'items' => $results,
|
'items' => $results,
|
||||||
'correct' => $correct,
|
'correct' => $correct,
|
||||||
'total' => count($items),
|
'total' => count($items),
|
||||||
|
'points_total' => array_sum(array_map(static function ($item) {
|
||||||
|
return (int) ($item->points ?? 0);
|
||||||
|
}, $items)),
|
||||||
'percentage' => count($items) ? round(($correct / count($items)) * 100, 2) : 0,
|
'percentage' => count($items) ? round(($correct / count($items)) * 100, 2) : 0,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user