60 lines
2.0 KiB
PHP
60 lines
2.0 KiB
PHP
<?php
|
|
session_start();
|
|
require_once 'db/config.php';
|
|
|
|
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'psychologist') {
|
|
header('Location: login.php');
|
|
exit();
|
|
}
|
|
|
|
$pdo = db();
|
|
$stmt = $pdo->query("
|
|
SELECT u.username, t.title, ut.score, ut.completed_at
|
|
FROM user_tests ut
|
|
JOIN users u ON ut.user_id = u.id
|
|
JOIN tests t ON ut.test_id = t.id
|
|
ORDER BY ut.completed_at DESC
|
|
");
|
|
$results = $stmt->fetchAll();
|
|
|
|
require_once 'includes/header.php';
|
|
?>
|
|
|
|
<div class="container">
|
|
<h1 class="mt-5">Панель психолога</h1>
|
|
<p class="lead">Добро пожаловать, <?php echo htmlspecialchars($_SESSION['username']); ?>!</p>
|
|
|
|
<h2 class="mt-4">Результаты тестов</h2>
|
|
|
|
<?php if (empty($results)): ?>
|
|
<div class="alert alert-info mt-3" role="alert">
|
|
Пока нет ни одного пройденного теста.
|
|
</div>
|
|
<?php else: ?>
|
|
<div class="table-responsive mt-3">
|
|
<table class="table table-bordered table-hover">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th scope="col">Пользователь</th>
|
|
<th scope="col">Тест</th>
|
|
<th scope="col">Баллы</th>
|
|
<th scope="col">Дата</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($results as $result): ?>
|
|
<tr>
|
|
<td><?php echo htmlspecialchars($result['username']); ?></td>
|
|
<td><?php echo htmlspecialchars($result['title']); ?></td>
|
|
<td><?php echo htmlspecialchars($result['score']); ?></td>
|
|
<td><?php echo date('d.m.Y H:i', strtotime($result['completed_at'])); ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
</div>
|
|
|
|
<?php require_once 'includes/footer.php'; ?>
|