From 7a3409404cfe8f45ef0e40f61b2c29124d524d33 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Thu, 23 Oct 2025 20:44:05 +0000 Subject: [PATCH] v01 --- admin.php | 27 +++ admin_courses.php | 143 +++++++++++++ admin_institutions.php | 117 ++++++++++ admin_learning_outcomes.php | 202 ++++++++++++++++++ admin_mission_statements.php | 197 +++++++++++++++++ admin_programs.php | 143 +++++++++++++ admin_schools.php | 143 +++++++++++++ contact.php | 74 +++++++ dashboard.php | 30 +++ db/migrations/001_create_initial_tables.sql | 16 ++ .../002_create_institutions_table.sql | 5 + db/migrations/003_create_schools_table.sql | 7 + db/migrations/004_create_programs_table.sql | 7 + db/migrations/005_create_courses_table.sql | 7 + ...006_create_assessment_documents_tables.sql | 34 +++ .../007_create_users_and_roles_tables.sql | 27 +++ index.php | 160 +------------- login.php | 89 ++++++++ logout.php | 23 ++ migrate.php | 46 ++++ register.php | 129 +++++++++++ templates/footer.php | 4 + templates/header.php | 40 ++++ 23 files changed, 1521 insertions(+), 149 deletions(-) create mode 100644 admin.php create mode 100644 admin_courses.php create mode 100644 admin_institutions.php create mode 100644 admin_learning_outcomes.php create mode 100644 admin_mission_statements.php create mode 100644 admin_programs.php create mode 100644 admin_schools.php create mode 100644 contact.php create mode 100644 dashboard.php create mode 100644 db/migrations/001_create_initial_tables.sql create mode 100644 db/migrations/002_create_institutions_table.sql create mode 100644 db/migrations/003_create_schools_table.sql create mode 100644 db/migrations/004_create_programs_table.sql create mode 100644 db/migrations/005_create_courses_table.sql create mode 100644 db/migrations/006_create_assessment_documents_tables.sql create mode 100644 db/migrations/007_create_users_and_roles_tables.sql create mode 100644 login.php create mode 100644 logout.php create mode 100644 migrate.php create mode 100644 register.php create mode 100644 templates/footer.php create mode 100644 templates/header.php diff --git a/admin.php b/admin.php new file mode 100644 index 0000000..d0baa6e --- /dev/null +++ b/admin.php @@ -0,0 +1,27 @@ + + +

Admin Dashboard

+

Welcome to the admin area. Here you can manage the application settings and data.

+ +
+ Manage Institutions + Manage Schools + Manage Programs + Manage Courses +
+ +

Assessment Documents

+
+ Manage Mission Statements + Manage Learning Outcomes +
+ + diff --git a/admin_courses.php b/admin_courses.php new file mode 100644 index 0000000..f96f7b2 --- /dev/null +++ b/admin_courses.php @@ -0,0 +1,143 @@ +query('SELECT id, name FROM programs ORDER BY name'); +$programs = $programs_stmt->fetchAll(); + +// Handle form submissions +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $name = trim($_POST['name']); + $program_id = $_POST['program_id']; + + if (isset($_POST['add_course'])) { + if (!empty($name) && !empty($program_id)) { + $stmt = $pdo->prepare('INSERT INTO courses (name, program_id) VALUES (?, ?)'); + $stmt->execute([$name, $program_id]); + } + } elseif (isset($_POST['update_course'])) { + if (!empty($name) && !empty($program_id) && !empty($id)) { + $stmt = $pdo->prepare('UPDATE courses SET name = ?, program_id = ? WHERE id = ?'); + $stmt->execute([$name, $program_id, $id]); + } + header('Location: admin_courses.php'); + exit; + } elseif (isset($_POST['delete_course'])) { + if (!empty($id)) { + $stmt = $pdo->prepare('DELETE FROM courses WHERE id = ?'); + $stmt->execute([$id]); + } + header('Location: admin_courses.php'); + exit; + } +} + +?> + +

Assessment Planning: Courses

+ +

← Back to Admin Dashboard

+ + + prepare('SELECT * FROM courses WHERE id = ?'); + $stmt->execute([$id]); + $course = $stmt->fetch(); + ?> +

Edit Course

+
+
+ + +
+
+ + +
+ + + Cancel +
+ + + prepare('SELECT * FROM courses WHERE id = ?'); + $stmt->execute([$id]); + $course = $stmt->fetch(); + ?> +

Delete Course

+

Are you sure you want to delete the course ""?

+
+ + + Cancel +
+ + + +

Add New Course

+
+
+ + +
+
+ + +
+ +
+ +
+ +

Existing Courses

+ + + + + + + + + + + query('SELECT c.id, c.name, p.name AS program_name FROM courses c JOIN programs p ON c.program_id = p.id ORDER BY c.id'); + while ($row = $stmt->fetch()) { + echo ""; + echo ""; + echo ""; + echo ""; + echo ''; + echo ""; + } + ?> + +
IDNameProgramActions
" . htmlspecialchars($row['id']) . "" . htmlspecialchars($row['name']) . "" . htmlspecialchars($row['program_name']) . " + Edit + Delete +
+ + + + diff --git a/admin_institutions.php b/admin_institutions.php new file mode 100644 index 0000000..4bbfded --- /dev/null +++ b/admin_institutions.php @@ -0,0 +1,117 @@ +prepare('INSERT INTO institutions (name) VALUES (?)'); + $stmt->execute([$name]); + } + } elseif (isset($_POST['update_institution'])) { + $name = trim($_POST['name']); + if (!empty($name) && !empty($id)) { + $stmt = $pdo->prepare('UPDATE institutions SET name = ? WHERE id = ?'); + $stmt->execute([$name, $id]); + } + header('Location: admin_institutions.php'); + exit; + } elseif (isset($_POST['delete_institution'])) { + if (!empty($id)) { + $stmt = $pdo->prepare('DELETE FROM institutions WHERE id = ?'); + $stmt->execute([$id]); + } + header('Location: admin_institutions.php'); + exit; + } +} + +?> + +

Assessment Planning: Institutions

+ + + prepare('SELECT * FROM institutions WHERE id = ?'); + $stmt->execute([$id]); + $institution = $stmt->fetch(); + ?> +

Edit Institution

+
+
+ + +
+ + + Cancel +
+ + + prepare('SELECT * FROM institutions WHERE id = ?'); + $stmt->execute([$id]); + $institution = $stmt->fetch(); + ?> +

Delete Institution

+

Are you sure you want to delete the institution ""?

+
+ + + Cancel +
+ + + +

Add New Institution

+
+
+ + +
+ +
+ +
+ +

Existing Institutions

+ + + + + + + + + + query('SELECT * FROM institutions ORDER BY id'); + while ($row = $stmt->fetch()) { + echo ""; + echo ""; + echo ""; + echo ''; + echo ""; + } + ?> + +
IDNameActions
" . htmlspecialchars($row['id']) . "" . htmlspecialchars($row['name']) . " + Edit + Delete +
+ + + + diff --git a/admin_learning_outcomes.php b/admin_learning_outcomes.php new file mode 100644 index 0000000..c1aac4c --- /dev/null +++ b/admin_learning_outcomes.php @@ -0,0 +1,202 @@ +query('SELECT id, name FROM institutions ORDER BY name')->fetchAll(); +$programs = $pdo->query('SELECT id, name FROM programs ORDER BY name')->fetchAll(); +$courses = $pdo->query('SELECT id, name FROM courses ORDER BY name')->fetchAll(); + +// Handle form submissions +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $description = trim($_POST['description']); + $rel_type = $_POST['rel_type']; + $rel_id = $_POST['rel_id']; + + if (isset($_POST['add_outcome'])) { + if (!empty($description) && !empty($rel_type) && !empty($rel_id)) { + $stmt = $pdo->prepare('INSERT INTO learning_outcomes (description, rel_type, rel_id) VALUES (?, ?, ?)'); + $stmt->execute([$description, $rel_type, $rel_id]); + } + } elseif (isset($_POST['update_outcome'])) { + if (!empty($description) && !empty($rel_type) && !empty($rel_id) && !empty($id)) { + $stmt = $pdo->prepare('UPDATE learning_outcomes SET description = ?, rel_type = ?, rel_id = ? WHERE id = ?'); + $stmt->execute([$description, $rel_type, $rel_id, $id]); + } + header('Location: admin_learning_outcomes.php'); + exit; + } elseif (isset($_POST['delete_outcome'])) { + if (!empty($id)) { + $stmt = $pdo->prepare('DELETE FROM learning_outcomes WHERE id = ?'); + $stmt->execute([$id]); + } + header('Location: admin_learning_outcomes.php'); + exit; + } +} + +?> + +

Assessment Planning: Learning Outcomes

+ +

← Back to Admin Dashboard

+ + + prepare('SELECT * FROM learning_outcomes WHERE id = ?'); + $stmt->execute([$id]); + $outcome = $stmt->fetch(); + ?> +

Edit Learning Outcome

+
+
+ + +
+
+ + +
+
+ + +
+ + + Cancel +
+ + + +

Add New Learning Outcome

+
+
+ + +
+
+ + +
+
+ + +
+ +
+ +
+ +

Existing Learning Outcomes

+ + + + + + + + + + + query('SELECT * FROM learning_outcomes ORDER BY id DESC'); + while ($row = $stmt->fetch()) { + $rel_name = ''; + if ($row['rel_type'] == 'institution') { + $rel_stmt = $pdo->prepare("SELECT name FROM institutions WHERE id = ?"); + $rel_stmt->execute([$row['rel_id']]); + $rel_name = $rel_stmt->fetchColumn(); + } elseif ($row['rel_type'] == 'program') { + $rel_stmt = $pdo->prepare("SELECT name FROM programs WHERE id = ?"); + $rel_stmt->execute([$row['rel_id']]); + $rel_name = $rel_stmt->fetchColumn(); + } elseif ($row['rel_type'] == 'course') { + $rel_stmt = $pdo->prepare("SELECT name FROM courses WHERE id = ?"); + $rel_stmt->execute([$row['rel_id']]); + $rel_name = $rel_stmt->fetchColumn(); + } + + echo ""; + echo ""; + echo ""; + echo ''; + echo ''; + echo ""; + } + ?> + +
DescriptionLinked ToActionsManage
" . htmlspecialchars($row['description']) . "" . ucfirst($row['rel_type']) . ': ' . htmlspecialchars($rel_name) . " + Edit + Delete + + Success Criteria + Assessment Measures +
+ + + + + + diff --git a/admin_mission_statements.php b/admin_mission_statements.php new file mode 100644 index 0000000..a347951 --- /dev/null +++ b/admin_mission_statements.php @@ -0,0 +1,197 @@ +query('SELECT id, name FROM institutions ORDER BY name')->fetchAll(); +$programs = $pdo->query('SELECT id, name FROM programs ORDER BY name')->fetchAll(); +$courses = $pdo->query('SELECT id, name FROM courses ORDER BY name')->fetchAll(); + +// Handle form submissions +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $statement = trim($_POST['statement']); + $rel_type = $_POST['rel_type']; + $rel_id = $_POST['rel_id']; + + if (isset($_POST['add_statement'])) { + if (!empty($statement) && !empty($rel_type) && !empty($rel_id)) { + $stmt = $pdo->prepare('INSERT INTO mission_statements (statement, rel_type, rel_id) VALUES (?, ?, ?)'); + $stmt->execute([$statement, $rel_type, $rel_id]); + } + } elseif (isset($_POST['update_statement'])) { + if (!empty($statement) && !empty($rel_type) && !empty($rel_id) && !empty($id)) { + $stmt = $pdo->prepare('UPDATE mission_statements SET statement = ?, rel_type = ?, rel_id = ? WHERE id = ?'); + $stmt->execute([$statement, $rel_type, $rel_id, $id]); + } + header('Location: admin_mission_statements.php'); + exit; + } elseif (isset($_POST['delete_statement'])) { + if (!empty($id)) { + $stmt = $pdo->prepare('DELETE FROM mission_statements WHERE id = ?'); + $stmt->execute([$id]); + } + header('Location: admin_mission_statements.php'); + exit; + } +} + +?> + +

Assessment Planning: Mission Statements

+ +

← Back to Admin Dashboard

+ + + prepare('SELECT * FROM mission_statements WHERE id = ?'); + $stmt->execute([$id]); + $statement = $stmt->fetch(); + ?> +

Edit Mission Statement

+
+
+ + +
+
+ + +
+
+ + +
+ + + Cancel +
+ + + +

Add New Mission Statement

+
+
+ + +
+
+ + +
+
+ + +
+ +
+ +
+ +

Existing Mission Statements

+ + + + + + + + + + query('SELECT * FROM mission_statements ORDER BY id DESC'); + while ($row = $stmt->fetch()) { + $rel_name = ''; + if ($row['rel_type'] == 'institution') { + $rel_stmt = $pdo->prepare("SELECT name FROM institutions WHERE id = ?"); + $rel_stmt->execute([$row['rel_id']]); + $rel_name = $rel_stmt->fetchColumn(); + } elseif ($row['rel_type'] == 'program') { + $rel_stmt = $pdo->prepare("SELECT name FROM programs WHERE id = ?"); + $rel_stmt->execute([$row['rel_id']]); + $rel_name = $rel_stmt->fetchColumn(); + } elseif ($row['rel_type'] == 'course') { + $rel_stmt = $pdo->prepare("SELECT name FROM courses WHERE id = ?"); + $rel_stmt->execute([$row['rel_id']]); + $rel_name = $rel_stmt->fetchColumn(); + } + + echo ""; + echo ""; + echo ""; + echo ''; + echo ""; + } + ?> + +
StatementLinked ToActions
" . htmlspecialchars($row['statement']) . "" . ucfirst($row['rel_type']) . ': ' . htmlspecialchars($rel_name) . " + Edit + Delete +
+ + + + + + diff --git a/admin_programs.php b/admin_programs.php new file mode 100644 index 0000000..9ff0eae --- /dev/null +++ b/admin_programs.php @@ -0,0 +1,143 @@ +query('SELECT id, name FROM schools ORDER BY name'); +$schools = $schools_stmt->fetchAll(); + +// Handle form submissions +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $name = trim($_POST['name']); + $school_id = $_POST['school_id']; + + if (isset($_POST['add_program'])) { + if (!empty($name) && !empty($school_id)) { + $stmt = $pdo->prepare('INSERT INTO programs (name, school_id) VALUES (?, ?)'); + $stmt->execute([$name, $school_id]); + } + } elseif (isset($_POST['update_program'])) { + if (!empty($name) && !empty($school_id) && !empty($id)) { + $stmt = $pdo->prepare('UPDATE programs SET name = ?, school_id = ? WHERE id = ?'); + $stmt->execute([$name, $school_id, $id]); + } + header('Location: admin_programs.php'); + exit; + } elseif (isset($_POST['delete_program'])) { + if (!empty($id)) { + $stmt = $pdo->prepare('DELETE FROM programs WHERE id = ?'); + $stmt->execute([$id]); + } + header('Location: admin_programs.php'); + exit; + } +} + +?> + +

Assessment Planning: Programs

+ +

← Back to Admin Dashboard

+ + + prepare('SELECT * FROM programs WHERE id = ?'); + $stmt->execute([$id]); + $program = $stmt->fetch(); + ?> +

Edit Program

+
+
+ + +
+
+ + +
+ + + Cancel +
+ + + prepare('SELECT * FROM programs WHERE id = ?'); + $stmt->execute([$id]); + $program = $stmt->fetch(); + ?> +

Delete Program

+

Are you sure you want to delete the program ""?

+
+ + + Cancel +
+ + + +

Add New Program

+
+
+ + +
+
+ + +
+ +
+ +
+ +

Existing Programs

+ + + + + + + + + + + query('SELECT p.id, p.name, s.name AS school_name FROM programs p JOIN schools s ON p.school_id = s.id ORDER BY p.id'); + while ($row = $stmt->fetch()) { + echo ""; + echo ""; + echo ""; + echo ""; + echo ''; + echo ""; + } + ?> + +
IDNameSchoolActions
" . htmlspecialchars($row['id']) . "" . htmlspecialchars($row['name']) . "" . htmlspecialchars($row['school_name']) . " + Edit + Delete +
+ + + + diff --git a/admin_schools.php b/admin_schools.php new file mode 100644 index 0000000..016a5ba --- /dev/null +++ b/admin_schools.php @@ -0,0 +1,143 @@ +query('SELECT id, name FROM institutions ORDER BY name'); +$institutions = $institutions_stmt->fetchAll(); + +// Handle form submissions +if ($_SERVER['REQUEST_METHOD'] === 'POST') { + $name = trim($_POST['name']); + $institution_id = $_POST['institution_id']; + + if (isset($_POST['add_school'])) { + if (!empty($name) && !empty($institution_id)) { + $stmt = $pdo->prepare('INSERT INTO schools (name, institution_id) VALUES (?, ?)'); + $stmt->execute([$name, $institution_id]); + } + } elseif (isset($_POST['update_school'])) { + if (!empty($name) && !empty($institution_id) && !empty($id)) { + $stmt = $pdo->prepare('UPDATE schools SET name = ?, institution_id = ? WHERE id = ?'); + $stmt->execute([$name, $institution_id, $id]); + } + header('Location: admin_schools.php'); + exit; + } elseif (isset($_POST['delete_school'])) { + if (!empty($id)) { + $stmt = $pdo->prepare('DELETE FROM schools WHERE id = ?'); + $stmt->execute([$id]); + } + header('Location: admin_schools.php'); + exit; + } +} + +?> + +

Assessment Planning: Schools

+ +

← Back to Admin Dashboard

+ + + prepare('SELECT * FROM schools WHERE id = ?'); + $stmt->execute([$id]); + $school = $stmt->fetch(); + ?> +

Edit School

+
+
+ + +
+
+ + +
+ + + Cancel +
+ + + prepare('SELECT * FROM schools WHERE id = ?'); + $stmt->execute([$id]); + $school = $stmt->fetch(); + ?> +

Delete School

+

Are you sure you want to delete the school ""?

+
+ + + Cancel +
+ + + +

Add New School

+
+
+ + +
+
+ + +
+ +
+ +
+ +

Existing Schools

+ + + + + + + + + + + query('SELECT s.id, s.name, i.name AS institution_name FROM schools s JOIN institutions i ON s.institution_id = i.id ORDER BY s.id'); + while ($row = $stmt->fetch()) { + echo ""; + echo ""; + echo ""; + echo ""; + echo ''; + echo ""; + } + ?> + +
IDNameInstitutionActions
" . htmlspecialchars($row['id']) . "" . htmlspecialchars($row['name']) . "" . htmlspecialchars($row['institution_name']) . " + Edit + Delete +
+ + + + diff --git a/contact.php b/contact.php new file mode 100644 index 0000000..edc6624 --- /dev/null +++ b/contact.php @@ -0,0 +1,74 @@ + + + + + + + Contact Us + + + +
+

Contact Us

+

Fill out the form below to get in touch with us.

+ + +
+ + +
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+

+ Back to Home +

+
+ + diff --git a/dashboard.php b/dashboard.php new file mode 100644 index 0000000..302cf71 --- /dev/null +++ b/dashboard.php @@ -0,0 +1,30 @@ + + +
+
+
+
+
+

Dashboard

+
+
+

Welcome, !

+

You are logged in as a(n) .

+

This is your dashboard. More features will be added soon.

+
+
+
+
+
+ + \ No newline at end of file diff --git a/db/migrations/001_create_initial_tables.sql b/db/migrations/001_create_initial_tables.sql new file mode 100644 index 0000000..da6a32c --- /dev/null +++ b/db/migrations/001_create_initial_tables.sql @@ -0,0 +1,16 @@ +CREATE TABLE IF NOT EXISTS `roles` ( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `name` VARCHAR(50) NOT NULL UNIQUE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +INSERT INTO `roles` (name) VALUES ('Admin'), ('Faculty'), ('Program Coordinator'), ('Internal Reviewer'), ('External Evaluator'); + +CREATE TABLE IF NOT EXISTS `users` ( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `username` VARCHAR(50) NOT NULL UNIQUE, + `password` VARCHAR(255) NOT NULL, + `email` VARCHAR(100) NOT NULL UNIQUE, + `role_id` INT, + `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (`role_id`) REFERENCES `roles`(`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/db/migrations/002_create_institutions_table.sql b/db/migrations/002_create_institutions_table.sql new file mode 100644 index 0000000..1a0a743 --- /dev/null +++ b/db/migrations/002_create_institutions_table.sql @@ -0,0 +1,5 @@ +CREATE TABLE IF NOT EXISTS `institutions` ( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `name` VARCHAR(255) NOT NULL, + `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/db/migrations/003_create_schools_table.sql b/db/migrations/003_create_schools_table.sql new file mode 100644 index 0000000..f9acb14 --- /dev/null +++ b/db/migrations/003_create_schools_table.sql @@ -0,0 +1,7 @@ +CREATE TABLE IF NOT EXISTS `schools` ( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `name` VARCHAR(255) NOT NULL, + `institution_id` INT NOT NULL, + `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (`institution_id`) REFERENCES `institutions`(`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/db/migrations/004_create_programs_table.sql b/db/migrations/004_create_programs_table.sql new file mode 100644 index 0000000..96e1f20 --- /dev/null +++ b/db/migrations/004_create_programs_table.sql @@ -0,0 +1,7 @@ +CREATE TABLE IF NOT EXISTS `programs` ( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `name` VARCHAR(255) NOT NULL, + `school_id` INT NOT NULL, + `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (`school_id`) REFERENCES `schools`(`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/db/migrations/005_create_courses_table.sql b/db/migrations/005_create_courses_table.sql new file mode 100644 index 0000000..b77afea --- /dev/null +++ b/db/migrations/005_create_courses_table.sql @@ -0,0 +1,7 @@ +CREATE TABLE IF NOT EXISTS `courses` ( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `name` VARCHAR(255) NOT NULL, + `program_id` INT NOT NULL, + `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (`program_id`) REFERENCES `programs`(`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/db/migrations/006_create_assessment_documents_tables.sql b/db/migrations/006_create_assessment_documents_tables.sql new file mode 100644 index 0000000..cdaf0c6 --- /dev/null +++ b/db/migrations/006_create_assessment_documents_tables.sql @@ -0,0 +1,34 @@ +CREATE TABLE IF NOT EXISTS `mission_statements` ( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `rel_id` INT NOT NULL, + `rel_type` VARCHAR(50) NOT NULL, -- 'institution', 'program', 'course' + `statement` TEXT NOT NULL, + `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + INDEX `rel_index` (`rel_id`, `rel_type`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +CREATE TABLE IF NOT EXISTS `learning_outcomes` ( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `rel_id` INT NOT NULL, + `rel_type` VARCHAR(50) NOT NULL, -- 'institution', 'program', 'course' + `description` TEXT NOT NULL, + `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + INDEX `rel_index` (`rel_id`, `rel_type`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +CREATE TABLE IF NOT EXISTS `success_criteria` ( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `learning_outcome_id` INT NOT NULL, + `description` TEXT NOT NULL, + `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (`learning_outcome_id`) REFERENCES `learning_outcomes`(`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +CREATE TABLE IF NOT EXISTS `assessment_measures` ( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `learning_outcome_id` INT NOT NULL, + `measure_type` VARCHAR(50) NOT NULL, -- 'direct', 'indirect' + `description` TEXT NOT NULL, + `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + FOREIGN KEY (`learning_outcome_id`) REFERENCES `learning_outcomes`(`id`) ON DELETE CASCADE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/db/migrations/007_create_users_and_roles_tables.sql b/db/migrations/007_create_users_and_roles_tables.sql new file mode 100644 index 0000000..8c6a9d1 --- /dev/null +++ b/db/migrations/007_create_users_and_roles_tables.sql @@ -0,0 +1,27 @@ +-- Create roles table +CREATE TABLE IF NOT EXISTS `roles` ( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `name` VARCHAR(50) NOT NULL UNIQUE +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +-- Seed the roles table with the confirmed roles +INSERT INTO `roles` (`name`) VALUES +('Admin'), +('Faculty'), +('Program Coordinator'), +('Internal Reviewer'), +('External Evaluator') +ON DUPLICATE KEY UPDATE name=name; -- Avoid errors on re-running + +-- Create users table +CREATE TABLE IF NOT EXISTS `users` ( + `id` INT AUTO_INCREMENT PRIMARY KEY, + `email` VARCHAR(255) NOT NULL UNIQUE, + `password` VARCHAR(255) NOT NULL, + `first_name` VARCHAR(100), + `last_name` VARCHAR(100), + `role_id` INT, + `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + FOREIGN KEY (`role_id`) REFERENCES `roles`(`id`) ON DELETE SET NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/index.php b/index.php index 7205f3d..48cedfc 100644 --- a/index.php +++ b/index.php @@ -1,150 +1,12 @@ - -$phpVersion = PHP_VERSION; -$now = date('Y-m-d H:i:s'); -?> - - - - - - New Style - - - - - - - - - - - - - - - - - - - - - -
-
-

Analyzing your requirements and generating your website…

-
- Loading… -
-

AI is collecting your requirements and applying the first changes.

-

This page will update automatically as the plan is implemented.

-

Runtime: PHP — UTC

-
-
- - - +
+

Welcome to the Assessment Management System

+

Your solution for streamlined planning, assessment, and reporting.

+
+

To get started, you can register for a new account or log in if you already have one.

+ Register + Login +
+ + \ No newline at end of file diff --git a/login.php b/login.php new file mode 100644 index 0000000..9f3856c --- /dev/null +++ b/login.php @@ -0,0 +1,89 @@ +prepare("SELECT users.*, roles.name as role_name FROM users JOIN roles ON users.role_id = roles.id WHERE email = ?"); + $stmt->execute([$email]); + $user = $stmt->fetch(PDO::FETCH_ASSOC); + + if ($user && password_verify($password, $user['password'])) { + // Password is correct, start session + session_regenerate_id(); + $_SESSION['user_id'] = $user['id']; + $_SESSION['user_email'] = $user['email']; + $_SESSION['user_role'] = $user['role_name']; + $_SESSION['user_name'] = $user['first_name'] . ' ' . $user['last_name']; + + // Redirect to dashboard + header("Location: dashboard.php"); + exit; + } else { + $errors[] = "Invalid email or password."; + } + } catch (PDOException $e) { + $errors[] = "Database error: " . $e->getMessage(); + } + } +} + +include 'templates/header.php'; +?> + +
+
+
+
+
+

Login

+
+
+ +
+ +

+ +
+ +
+
+ + +
+
+ + +
+ +
+
+ +
+
+
+
+ + \ No newline at end of file diff --git a/logout.php b/logout.php new file mode 100644 index 0000000..b00d285 --- /dev/null +++ b/logout.php @@ -0,0 +1,23 @@ + \ No newline at end of file diff --git a/migrate.php b/migrate.php new file mode 100644 index 0000000..37592d3 --- /dev/null +++ b/migrate.php @@ -0,0 +1,46 @@ + PDO::ERRMODE_EXCEPTION, + ]); + $pdo_setup->exec('CREATE DATABASE IF NOT EXISTS `'.DB_NAME.'`'); + echo "Database `".DB_NAME."` ensured to exist.\n"; + + // Now connect to the database + $pdo = db(); + + // 1. Ensure migrations table exists + $pdo->exec("CREATE TABLE IF NOT EXISTS `migrations` ( `id` INT AUTO_INCREMENT PRIMARY KEY, `migration` VARCHAR(255) NOT NULL, `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"); + + // 2. Get all executed migrations + $executedMigrations = $pdo->query("SELECT migration FROM migrations")->fetchAll(PDO::FETCH_COLUMN); + + // 3. Get all migration files + $migrationsDir = __DIR__ . '/db/migrations'; + $migrationFiles = glob($migrationsDir . '/*.sql'); + sort($migrationFiles); + + // 4. Run pending migrations + foreach ($migrationFiles as $file) { + $migrationName = basename($file); + if (!in_array($migrationName, $executedMigrations)) { + echo "Running migration: " . $migrationName . "\n"; + $sql = file_get_contents($file); + $pdo->exec($sql); + + // 5. Log the migration + $stmt = $pdo->prepare("INSERT INTO migrations (migration) VALUES (?)"); + $stmt->execute([$migrationName]); + } + } + + echo "Migrations completed successfully.\n"; + +} catch (PDOException $e) { + die("Database setup or migration failed: " . $e->getMessage() . "\n"); +} \ No newline at end of file diff --git a/register.php b/register.php new file mode 100644 index 0000000..14209f1 --- /dev/null +++ b/register.php @@ -0,0 +1,129 @@ +query("SELECT id, name FROM roles ORDER BY name"); + $roles = $stmt->fetchAll(PDO::FETCH_ASSOC); +} catch (PDOException $e) { + // If roles table doesn't exist yet, we can proceed without it + // The migration will create it. +} + +$errors = []; +$success = ''; + +if ($_SERVER["REQUEST_METHOD"] == "POST") { + $email = trim($_POST['email']); + $password = $_POST['password']; + $first_name = trim($_POST['first_name']); + $last_name = trim($_POST['last_name']); + $role_id = $_POST['role_id']; + + if (empty($email) || !filter_var($email, FILTER_VALIDATE_EMAIL)) { + $errors[] = "A valid email is required."; + } + if (empty($password) || strlen($password) < 8) { + $errors[] = "Password must be at least 8 characters long."; + } + if (empty($first_name)) { + $errors[] = "First name is required."; + } + if (empty($last_name)) { + $errors[] = "Last name is required."; + } + if (empty($role_id)) { + $errors[] = "Please select a role."; + } + + if (empty($errors)) { + try { + $pdo = db(); + + // Check if user already exists + $stmt = $pdo->prepare("SELECT id FROM users WHERE email = ?"); + $stmt->execute([$email]); + if ($stmt->fetch()) { + $errors[] = "An account with this email already exists."; + } else { + // Insert new user + $hashed_password = password_hash($password, PASSWORD_DEFAULT); + $stmt = $pdo->prepare("INSERT INTO users (email, password, first_name, last_name, role_id) VALUES (?, ?, ?, ?, ?)"); + if ($stmt->execute([$email, $hashed_password, $first_name, $last_name, $role_id])) { + $success = "Registration successful! You can now log in."; + } else { + $errors[] = "Something went wrong. Please try again later."; + } + } + } catch (PDOException $e) { + $errors[] = "Database error: " . $e->getMessage(); + } + } +} + +include 'templates/header.php'; +?> + +
+
+
+
+
+

Register

+
+
+ +
+ +

+ +
+ + +
+

+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+ +
+ +
+ +
+
+
+
+ + \ No newline at end of file diff --git a/templates/footer.php b/templates/footer.php new file mode 100644 index 0000000..bb9d29a --- /dev/null +++ b/templates/footer.php @@ -0,0 +1,4 @@ + + + + diff --git a/templates/header.php b/templates/header.php new file mode 100644 index 0000000..0c7956e --- /dev/null +++ b/templates/header.php @@ -0,0 +1,40 @@ + + + + + + + Assessment Management System + + + + +