| Server IP : 202.61.199.114 / Your IP : 216.73.217.139 Web Server : nginx/1.22.1 System : Linux de.arni-solutions.de 6.1.0-49-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64 User : web20 ( 1018) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/clients/client2/web31/web/test/ |
Upload File : |
<?php
declare(strict_types=1);
require __DIR__ . '/includes/bootstrap.php';
$user = require_user();
$slug = trim((string)($_GET['slug'] ?? ''));
$test = load_test_by_slug($slug);
if (!$test || empty($test['meta']['active'])) {
set_flash('danger', 'Der gewünschte Test wurde nicht gefunden oder ist nicht aktiv.');
redirect_to('dashboard.php');
}
$existing = load_submission($slug, $user['email']);
$oldAnswers = $_SESSION['old_answers'][$slug] ?? [];
unset($_SESSION['old_answers'][$slug]);
$prefill = $oldAnswers ?: ($existing['answers'] ?? []);
render_header((string)$test['meta']['title']);
?>
<div class="mb-4">
<h1 class="h2 mb-2"><?= e((string)$test['meta']['title']) ?></h1>
<p class="text-muted mb-0"><?= e((string)($test['meta']['description'] ?? '')) ?></p>
</div>
<form method="post" action="save_test.php">
<input type="hidden" name="slug" value="<?= e($slug) ?>">
<?php foreach ($test['questions'] as $index => $question): ?>
<div class="card card-soft mb-4">
<div class="card-body p-4">
<div class="d-flex justify-content-between align-items-start mb-3">
<h2 class="h5 mb-0"><?= ($index + 1) ?>. <?= e((string)$question['text']) ?></h2>
<span class="badge text-bg-secondary"><?= e((string)$question['type']) ?></span>
</div>
<?php foreach ($question['options'] as $option): ?>
<?php
$questionId = (string)$question['id'];
$optionId = (string)$option['id'];
$inputId = $questionId . '_' . $optionId;
$type = (string)$question['type'] === 'multiple' ? 'checkbox' : 'radio';
$isChecked = false;
if ($type === 'checkbox') {
$saved = $prefill[$questionId] ?? [];
if (is_array($saved)) {
$isChecked = in_array($optionId, array_map('strval', $saved), true);
}
} else {
$isChecked = (($prefill[$questionId] ?? '') === $optionId);
}
?>
<div class="form-check ps-0 mb-3">
<input
class="form-check-input d-none choice-input"
type="<?= e($type) ?>"
id="<?= e($inputId) ?>"
name="answers[<?= e($questionId) ?>]<?= $type === 'checkbox' ? '[]' : '' ?>"
value="<?= e($optionId) ?>"
<?= $isChecked ? 'checked' : '' ?>
>
<label class="option-label" for="<?= e($inputId) ?>">
<?= e((string)$option['text']) ?>
</label>
</div>
<?php endforeach; ?>
</div>
</div>
<?php endforeach; ?>
<div class="d-flex gap-2">
<a class="btn btn-outline-secondary btn-lg" href="dashboard.php">Zurück</a>
<button type="submit" class="btn btn-primary btn-lg">Speichern und auswerten</button>
</div>
</form>
<?php render_footer(); ?>