Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c1720e1e1 | ||
|
|
1da3149e2f |
@@ -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.22).
|
||||
W Joomla wybierz **System → Install → Install from Folder** i wskaż ten katalog. Manifestem instalacyjnym jest `com_testquestions.xml` (wersja 1.43.24).
|
||||
|
||||
Po instalacji komponent jest dostępny w panelu administratora jako **Pytania testowe**.
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
-- Wydanie 1.43.23: zachowano w wyniku kolejność pytań z wylosowanego testu.
|
||||
@@ -0,0 +1 @@
|
||||
-- Wydanie 1.43.24: ukryto ocenę AI i korektę punktów dla pustych odpowiedzi.
|
||||
@@ -202,7 +202,7 @@ class ResultModel extends BaseDatabaseModel
|
||||
$questionIds = [];
|
||||
foreach ($item->answers as $questionId => $answer) {
|
||||
$question = $item->questions[(int) $questionId] ?? null;
|
||||
if ($question && $question->question_type === 'open' && empty($answer['correct'])) {
|
||||
if ($question && $question->question_type === 'open' && empty($answer['correct']) && trim((string) ($answer['selected'] ?? '')) !== '') {
|
||||
$questionIds[] = (int) $questionId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ $resolveImageUrl = static function ($path) {
|
||||
<?php $pendingAiCount = 0; ?>
|
||||
<?php foreach ($this->item->answers as $questionId => $answer) : ?>
|
||||
<?php $candidate = $this->item->questions[(int) $questionId] ?? null; ?>
|
||||
<?php if ($candidate && $candidate->question_type === 'open' && empty($answer['correct'])) { $pendingAiCount++; } ?>
|
||||
<?php if ($candidate && $candidate->question_type === 'open' && empty($answer['correct']) && trim((string) ($answer['selected'] ?? '')) !== '') { $pendingAiCount++; } ?>
|
||||
<?php endforeach; ?>
|
||||
<?php if ($pendingAiCount > 0) : ?>
|
||||
<div class="mb-3">
|
||||
@@ -72,6 +72,7 @@ $resolveImageUrl = static function ($path) {
|
||||
<h2><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULT_ANSWERS'); ?></h2>
|
||||
<?php foreach ($this->item->answers as $questionId => $answer) : ?>
|
||||
<?php $question = $this->item->questions[(int) $questionId] ?? null; if (!$question) continue; ?>
|
||||
<?php $hasResponse = trim((string) ($answer['selected'] ?? '')) !== ''; ?>
|
||||
<article class="mb-4 border rounded p-3">
|
||||
<div class="mb-2"><?php echo $question->question; ?></div>
|
||||
<?php if (!empty($question->image)) : ?><div class="mb-3"><img src="<?php echo htmlspecialchars($resolveImageUrl($question->image), ENT_QUOTES, 'UTF-8'); ?>" alt="" loading="lazy" style="max-width: 100%; height: auto;"></div><?php endif; ?>
|
||||
@@ -83,7 +84,7 @@ $resolveImageUrl = static function ($path) {
|
||||
<?php endif; ?>
|
||||
<div class="mt-2 <?php echo !empty($answer['correct']) ? 'text-success' : 'text-danger'; ?>"><?php echo !empty($answer['correct']) ? '✓ ' . \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_ANSWER_CORRECT') : '✗ ' . \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_ANSWER_INCORRECT'); ?></div>
|
||||
<?php if (empty($answer['correct'])) : ?>
|
||||
<?php if ($question->question_type === 'open') : ?>
|
||||
<?php if ($question->question_type === 'open' && $hasResponse) : ?>
|
||||
<div class="mt-3">
|
||||
<button type="submit" name="ai_question_id" value="<?php echo (int) $questionId; ?>" onclick="this.form.task.value='result.ai';" formaction="<?php echo Route::_('index.php?option=com_testquestions&task=result.ai&id=' . (int) $this->item->id); ?>" class="btn btn-outline-primary">
|
||||
<?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_AI_EVALUATE'); ?>
|
||||
@@ -104,7 +105,7 @@ $resolveImageUrl = static function ($path) {
|
||||
<div class="alert alert-info mt-3"><strong><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_AI_RESULT'); ?>:</strong><br><?php echo nl2br(htmlspecialchars((string) $answer['ai_feedback'], ENT_QUOTES, 'UTF-8')); ?></div>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php if ($question->question_type === 'open') : ?>
|
||||
<?php if ($question->question_type === 'open' && $hasResponse) : ?>
|
||||
<div class="row mt-3">
|
||||
<div class="col-md-3">
|
||||
<label for="awarded-points-<?php echo (int) $questionId; ?>" class="form-label"><?php echo \Joomla\CMS\Language\Text::sprintf('COM_TESTQUESTIONS_RESULT_AWARDED_POINTS', (int) ($question->points ?? 0)); ?></label>
|
||||
|
||||
@@ -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.22</version>
|
||||
<version>1.43.24</version>
|
||||
<description>COM_TESTQUESTIONS_DESCRIPTION</description>
|
||||
<element>com_testquestions</element>
|
||||
<namespace path="src">Komponent\Component\Testquestions</namespace>
|
||||
|
||||
@@ -25,6 +25,26 @@ class HtmlView extends BaseHtmlView
|
||||
$this->items = $this->get('Items');
|
||||
$this->sets = $this->get('Sets');
|
||||
$input = Factory::getApplication()->getInput();
|
||||
if ($input->getCmd('task') === 'check' && $input->getMethod() === 'POST' && $this->items) {
|
||||
$submittedQuestionOrder = array_map('intval', (array) $input->post->get('question_order', [], 'array'));
|
||||
$expectedQuestionIds = array_map(static function ($item) {
|
||||
return (int) $item->id;
|
||||
}, $this->items);
|
||||
$sortedSubmittedOrder = $submittedQuestionOrder;
|
||||
$sortedExpectedIds = $expectedQuestionIds;
|
||||
sort($sortedSubmittedOrder);
|
||||
sort($sortedExpectedIds);
|
||||
|
||||
if ($sortedSubmittedOrder === $sortedExpectedIds) {
|
||||
$itemsById = [];
|
||||
foreach ($this->items as $item) {
|
||||
$itemsById[(int) $item->id] = $item;
|
||||
}
|
||||
$this->items = array_values(array_map(static function ($questionId) use ($itemsById) {
|
||||
return $itemsById[$questionId];
|
||||
}, $submittedQuestionOrder));
|
||||
}
|
||||
}
|
||||
$this->started = $input->getMethod() === 'POST'
|
||||
&& $input->post->getString('participant_name', '') !== ''
|
||||
&& $input->post->getInt('set_id', 0) > 0;
|
||||
|
||||
@@ -84,6 +84,9 @@ $resolveImageUrl = static function ($path) {
|
||||
<?php endif; ?>
|
||||
<?php if ($this->items) : ?>
|
||||
<form action="<?php echo htmlspecialchars($_SERVER['REQUEST_URI'], ENT_QUOTES, 'UTF-8'); ?>" method="post" id="test-form">
|
||||
<?php if (!$this->results) : ?>
|
||||
<?php foreach ($this->items as $item) : ?><input type="hidden" name="question_order[]" value="<?php echo (int) $item->id; ?>"><?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
<?php foreach ($this->items as $number => $item) : ?>
|
||||
<?php
|
||||
$answerOrder = $this->results && !empty($this->results['items'][$item->id]['answer_order'])
|
||||
|
||||
Reference in New Issue
Block a user