96 lines
2.6 KiB
PHP
96 lines
2.6 KiB
PHP
<?php
|
|
require_once '../db/config.php';
|
|
require_once 'partials/header.php';
|
|
|
|
$pdo = db();
|
|
$participant_id = $_GET['id'] ?? null;
|
|
|
|
if (!$participant_id) {
|
|
header("Location: results.php");
|
|
exit;
|
|
}
|
|
|
|
// Fetch participant details
|
|
$stmt = $pdo->prepare('SELECT * FROM participants WHERE id = ?');
|
|
$stmt->execute([$participant_id]);
|
|
$participant = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
|
|
if (!$participant) {
|
|
echo "<p>Partecipante non trovato.</p>";
|
|
require_once 'partials/footer.php';
|
|
exit;
|
|
}
|
|
|
|
// Fetch submission details
|
|
$query = <<<SQL
|
|
SELECT
|
|
q.question_text,
|
|
q.score,
|
|
their_a.answer_text as chosen_answer,
|
|
their_a.is_correct as was_correct,
|
|
correct_a.answer_text as correct_answer
|
|
FROM submissions s
|
|
JOIN questions q ON s.question_id = q.id
|
|
JOIN answers their_a ON s.answer_id = their_a.id
|
|
LEFT JOIN answers correct_a ON q.id = correct_a.question_id AND correct_a.is_correct = 1
|
|
WHERE s.participant_id = ?
|
|
ORDER BY q.id ASC
|
|
SQL;
|
|
|
|
$stmt = $pdo->prepare($query);
|
|
$stmt->execute([$participant_id]);
|
|
$submission_details = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
|
|
|
|
?>
|
|
|
|
<div class="content-block">
|
|
<h2>Dettaglio Risposte - <?php echo htmlspecialchars($participant['nickname']); ?></h2>
|
|
<p><strong>Email:</strong> <?php echo htmlspecialchars($participant['email']); ?></p>
|
|
<a href="results.php">« Torna alla lista dei risultati</a>
|
|
|
|
<div class="submission-list">
|
|
<?php foreach ($submission_details as $detail): ?>
|
|
<div class="submission-item <?php echo $detail['was_correct'] ? 'correct' : 'incorrect'; ?>">
|
|
<h4><?php echo htmlspecialchars($detail['question_text']); ?></h4>
|
|
<p>
|
|
<strong>Risposta data:</strong> <?php echo htmlspecialchars($detail['chosen_answer']); ?>
|
|
(Punti: <?php echo $detail['was_correct'] ? '+' : '-'; echo htmlspecialchars($detail['score']); ?>)
|
|
</p>
|
|
<?php if (!$detail['was_correct']): ?>
|
|
<p><strong>Risposta corretta:</strong> <?php echo htmlspecialchars($detail['correct_answer']); ?></p>
|
|
<?php endif; ?>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
|
|
<style>
|
|
.content-block {
|
|
background-color: #16213e;
|
|
padding: 20px;
|
|
border-radius: 8px;
|
|
}
|
|
.submission-list {
|
|
margin-top: 20px;
|
|
}
|
|
.submission-item {
|
|
border-left: 5px solid;
|
|
padding: 15px;
|
|
margin-bottom: 15px;
|
|
background-color: #1f2a4a;
|
|
}
|
|
.submission-item.correct {
|
|
border-left-color: #28a745;
|
|
}
|
|
.submission-item.incorrect {
|
|
border-left-color: #dc3545;
|
|
}
|
|
.submission-item h4 {
|
|
margin: 0 0 10px 0;
|
|
}
|
|
</style>
|
|
|
|
<?php require_once 'partials/footer.php'; ?>
|
|
|