62 lines
1.7 KiB
PHP
62 lines
1.7 KiB
PHP
<?php
|
|
require_once 'db/config.php';
|
|
|
|
try {
|
|
$db = db();
|
|
|
|
// Create exams table
|
|
$db->exec("CREATE TABLE IF NOT EXISTS exams (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
title VARCHAR(255) NOT NULL,
|
|
description TEXT,
|
|
teacher_id INT,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (teacher_id) REFERENCES users(id) ON DELETE SET NULL
|
|
)");
|
|
|
|
// Create exam_questions table
|
|
$db->exec("CREATE TABLE IF NOT EXISTS exam_questions (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
exam_id INT,
|
|
question TEXT NOT NULL,
|
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
|
FOREIGN KEY (exam_id) REFERENCES exams(id) ON DELETE CASCADE
|
|
)");
|
|
|
|
// Create student_exams table
|
|
$db->exec("CREATE TABLE IF NOT EXISTS student_exams (
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
student_id INT,
|
|
exam_id INT,
|
|
score INT,
|
|
completed_at TIMESTAMP,
|
|
FOREIGN KEY (student_id) REFERENCES users(id) ON DELETE CASCADE,
|
|
FOREIGN KEY (exam_id) REFERENCES exams(id) ON DELETE CASCADE
|
|
)");
|
|
|
|
} catch (PDOException $e) {
|
|
die("Error: " . $e->getMessage());
|
|
}
|
|
?>
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Exams</title>
|
|
</head>
|
|
<body>
|
|
<h1>Exams</h1>
|
|
<nav>
|
|
<a href="index.php">Home</a>
|
|
<a href="users.php">Users</a>
|
|
<a href="roles.php">Roles</a>
|
|
<a href="activities.php">Activities</a>
|
|
<a href="exams.php">Exams</a>
|
|
<a href="attendance.php">Attendance</a>
|
|
</nav>
|
|
<p>Exam management page.</p>
|
|
</body>
|
|
</html>
|