81 lines
7.2 KiB
PHP
81 lines
7.2 KiB
PHP
<?php defined('_JEXEC') or die; ?>
|
|
<?php use Joomla\CMS\HTML\HTMLHelper; ?>
|
|
<?php use Joomla\CMS\Router\Route; ?>
|
|
<div class="container-fluid">
|
|
<dl class="row">
|
|
<div class="row"<?php echo (int) $this->item->extra_time > 0 ? ' style="background-color: #fff3cd;"' : ''; ?>>
|
|
<dt class="col-sm-3"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULT_PARTICIPANT'); ?></dt>
|
|
<dd class="col-sm-9"><?php echo $this->escape($this->item->participant_name); ?></dd>
|
|
</div>
|
|
<dt class="col-sm-3"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_SET_TITLE'); ?></dt>
|
|
<dd class="col-sm-9"><?php echo $this->escape(($this->item->subject_title ? $this->item->subject_title . ' — ' : '') . $this->item->set_title); ?></dd>
|
|
<dt class="col-sm-3"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULT_SCORE'); ?></dt>
|
|
<dd class="col-sm-9"><?php echo (int) $this->item->correct_count; ?> / <?php echo (int) $this->item->total_count; ?> (<?php echo htmlspecialchars((string) $this->item->percentage, ENT_QUOTES, 'UTF-8'); ?>%)</dd>
|
|
<dt class="col-sm-3"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULT_POINTS_BEFORE_AFTER'); ?></dt>
|
|
<dd class="col-sm-9"><?php echo (int) $this->item->points_before; ?> / <?php echo (int) $this->item->points_after; ?></dd>
|
|
<?php $pointsTotal = (int) $this->item->points_total ?: (int) $this->item->total_count; ?>
|
|
<?php $pointsAfterPercentage = $pointsTotal ? round(((int) $this->item->points_after / $pointsTotal) * 100, 2) : 0; ?>
|
|
<?php $grade = 'NDST'; ?>
|
|
<?php foreach ([['CEL', 100], ['BDB', 90], ['BDB-', 80], ['DB+', 75], ['DB', 70], ['DB-', 65], ['DST+', 60], ['DST', 55], ['DST-', 50], ['DOP+', 45], ['DOP', 40], ['DOP-', 35], ['NDST+', 30], ['NDST', 0]] as $gradeScale) : ?>
|
|
<?php if ($pointsAfterPercentage >= $gradeScale[1]) { $grade = $gradeScale[0]; break; } ?>
|
|
<?php endforeach; ?>
|
|
<dt class="col-sm-3"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULT_GRADE'); ?></dt>
|
|
<dd class="col-sm-9"><?php echo $this->escape($grade); ?></dd>
|
|
<dt class="col-sm-3"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULT_EXECUTION_TIME'); ?></dt>
|
|
<dd class="col-sm-9"><?php echo floor((int) $this->item->execution_time / 60); ?>:<?php echo str_pad((string) ((int) $this->item->execution_time % 60), 2, '0', STR_PAD_LEFT); ?></dd>
|
|
</dl>
|
|
<form action="<?php echo Route::_('index.php?option=com_testquestions&view=result&id=' . (int) $this->item->id); ?>" method="post" name="adminForm" id="adminForm">
|
|
<?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 endforeach; ?>
|
|
<?php if ($pendingAiCount > 0) : ?>
|
|
<div class="mb-3">
|
|
<button type="submit" class="btn btn-primary" formaction="<?php echo Route::_('index.php?option=com_testquestions&task=result.aiAll&id=' . (int) $this->item->id); ?>" onclick="this.form.task.value='result.aiAll';">
|
|
<?php echo \Joomla\CMS\Language\Text::sprintf('COM_TESTQUESTIONS_AI_EVALUATE_ALL', $pendingAiCount); ?>
|
|
</button>
|
|
</div>
|
|
<?php endif; ?>
|
|
<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; ?>
|
|
<article class="mb-4 border rounded p-3">
|
|
<div class="mb-2"><?php echo $question->question; ?></div>
|
|
<?php if ($question->question_type === 'open') : ?>
|
|
<div><strong><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_YOUR_ANSWER'); ?>:</strong> <?php echo htmlspecialchars($answer['selected'] ?: '—', ENT_QUOTES, 'UTF-8'); ?></div>
|
|
<div><strong><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_CORRECT_PATTERN'); ?>:</strong> <?php echo htmlspecialchars($question->answer_open, ENT_QUOTES, 'UTF-8'); ?></div>
|
|
<?php else : ?>
|
|
<div><strong><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_SELECTED_ANSWER'); ?>:</strong> <?php echo $answer['selected'] ? chr(64 + (int) $answer['selected']) : '—'; ?></div>
|
|
<?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') : ?>
|
|
<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'); ?>
|
|
</button>
|
|
</div>
|
|
<?php if (!empty($answer['ai_feedback'])) : ?>
|
|
<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; ?>
|
|
<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>
|
|
<input type="number" min="0" max="<?php echo (int) ($question->points ?? 0); ?>" name="awarded_points[<?php echo (int) $questionId; ?>]" id="awarded-points-<?php echo (int) $questionId; ?>" class="form-control" value="<?php echo (int) ($answer['awarded_points'] ?? 0); ?>">
|
|
</div>
|
|
<div class="col-md-9">
|
|
<label for="result-comment-<?php echo (int) $questionId; ?>" class="form-label"><?php echo \Joomla\CMS\Language\Text::_('COM_TESTQUESTIONS_RESULT_COMMENT'); ?></label>
|
|
<textarea name="comments[<?php echo (int) $questionId; ?>]" id="result-comment-<?php echo (int) $questionId; ?>" class="form-control" rows="2"><?php echo htmlspecialchars((string) ($answer['comment'] ?? ''), ENT_QUOTES, 'UTF-8'); ?></textarea>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
</article>
|
|
<?php endforeach; ?>
|
|
<input type="hidden" name="task" value="result.save">
|
|
<input type="hidden" name="id" value="<?php echo (int) $this->item->id; ?>">
|
|
<?php echo HTMLHelper::_('form.token'); ?>
|
|
</form>
|
|
</div>
|