Tuesday, May 19, 2026
PHP Projects

Online Examination System - Full-Stack PHP & MySQL - Free Source Code

Lav 5 min read
Online Examination System - Full-Stack PHP & MySQL - Free Source Code

What is this project?

A complete Online Examination System that allows institutions, coaching centres, and educators to create and conduct exams online. Students can register, browse available exams, attempt them in a secure proctored environment, and view instant results.

Most open-source exam systems are either too heavy (WordPress plugins, Laravel monoliths) or too minimal. This system hits the sweet spot — lightweight, self-contained, easy to deploy, and feature-complete enough for real-world use.

Who is it for?

Audience

Use Case

Educators & Schools

Conduct class tests and final exams online

Coaching Institutes

Create mock exams and track student performance

HR Departments

Screening tests for job applicants

Developers

Learn MVC architecture with pure PHP

YouTubers / Bloggers

Build & showcase as a portfolio project

FEATURES - What's included

The system ships with three distinct portals and a full admin & student toolset.

Public Homepage

  • Lists all published exams with live status indicators

  • Smart buttons based on user role and exam status (Live / Upcoming / Ended)

  • Exam details: duration, marks, pass criteria, negative marking info

Admin Panel

  • Dashboard with stats overview (total exams, users, submissions, pass rate, avg score)

  • Exam management: card grid view with live badge, pass rate, attempt count

  • Question management: add MCQ with dynamic options, image upload, bulk CSV import, AJAX pagination

  • Student management: view all students, toggle status, profile modal with exam history

  • Results analytics: pass/fail donut chart, score distribution bar chart, answer review modal

  • User management: full CRUD for all roles with role-coloured badges

Student Portal

  • Browse available exams and start with fullscreen enforcement

  • Auto-save answers via AJAX on every selection

  • Tab-switch and focus-loss detection — violations logged to database

  • Countdown timer with auto-submit when time expires

  • Instant result page with score, correct/incorrect breakdown, pass/fail verdict

Tech stack

Layer

Technology

Notes

Backend Language

PHP 8.1+

No framework required

Architecture

Custom MVC

Pure PHP, front controller pattern

Database

MySQL 8.0+

PDO with prepared statements

Frontend

Bootstrap 5.3 + Vanilla JS

Responsive, no build step

Charts

Chart.js 4.4

Pass/fail donut + score distribution

Icons

Bootstrap Icons 1.11

Icon font, no SVG bloat

Fonts

Google Fonts — Inter

Clean, readable body font

Production

Apache / Nginx

Dev: PHP built-in server

Project architecture

The project uses a custom MVC pattern with a single front controller (index.php) that routes requests to the appropriate controller.

Online Examination System/
├── index.php                    # Front controller & router
├── database.sql                 # Complete DB schema + seed data

├── app/
│   ├── Config/Database.php      # PDO connection config
│   ├── Controllers/
│   │   ├── HomeController.php   # Public homepage
│   │   ├── AuthController.php   # Login / Register / Logout
│   │   ├── AdminController.php  # All admin operations
│   │   └── StudentController.php# Exam engine, results
│   ├── Models/
│   │   ├── User.php  Exam.php  Question.php  Attempt.php
│   ├── Views/
│   │   ├── home.php  layouts/  auth/  admin/  student/
│   └── Helpers/AuthHelper.php   # Session-based role guard

└── public/uploads/questions/    # Uploaded question images

Database: Schema — 5 core tables

All tables use foreign key constraints and ON DELETE CASCADE for data integrity.

Table

Key Columns

Purpose

users

id, name, email, password, role, status

All roles in one table

exams

id, title, duration, start_time, end_time, passing_marks

Exam configuration & scheduling

questions

id, exam_id, question_text, image_url, marks

MCQ questions with optional image

options

id, question_id, option_text, is_correct

MCQ choices with correct-answer flag

exam_attempts

id, user_id, exam_id, score, status, tab_switches

Attempts + proctoring data

student_answers

id, attempt_id, question_id, selected_option_id, marks_obtained

Per-answer scoring for review

Module breakdown

1. Authentication System

  • Session-based login / logout

  • bcrypt password hashing

  • Role-based access guard via AuthHelper::requireRole()

  • Duplicate email check on registration

2. Exam Management

  • Create, Edit, Delete exams with draft/published/completed states

  • Set duration, marks, passing marks, negative marking ratio, start/end times

  • Real-time LIVE badge when exam is currently active

3. Question Management

  • Add MCQ questions with 2 to unlimited options (dynamic JS)

  • Upload an image per question (PNG/JPG/GIF)

  • Bulk import via CSV — import hundreds of questions at once

  • AJAX-powered question list with pagination and live search

4. Exam Engine (Student Side)

  • Fullscreen enforcement on exam start

  • Auto-save answers via AJAX on every selection

  • Tab-switch / focus-loss detection — violation logged to DB

  • Countdown timer with auto-submit when time expires

  • Instant result page with score, correct/incorrect breakdown

DEPLOYMENT: Three ways to deploy

Option

Difficulty

Description

Shared Hosting (cPanel)

Easiest

Upload via File Manager, create MySQL DB in cPanel, import SQL via phpMyAdmin, add .htaccess rewrite rule.

VPS / Ubuntu Server

Recommended

Apache + MySQL + PHP 8.1 stack. Configure a virtual host, enable mod_rewrite, add SSL via Let's Encrypt.

Docker

Dev-friendly

Use the included docker-compose.yml — PHP-Apache + MySQL 8 with schema auto-imported on first start.

CSV question import format

Bulk-import hundreds of questions with a single CSV file. Download the sample template from Admin > Questions > Import CSV.

question_text,marks,option_a,option_b,option_c,option_d,correct_option
What is the capital of France?,1,Berlin,Paris,Rome,Madrid,B
Which planet is closest to the sun?,2,Earth,Venus,Mercury,Mars,C
True or False: Water is H2O.,1,True,False,,,A
PHP stands for?,1,Personal Home Page,Hypertext Preprocessor,...,B

Rules

  • First row is the header and is always skipped

  • correct_option must be A, B, C, or D

  • option_c and option_d can be empty (for True/False questions)

  • marks defaults to 1.0 if left empty or invalid

  • Blank question rows are silently skipped

ACCESS: Default credentials

Role

Email

Password

Admin

admin@example.com

password

Student

Register via the public homepage

Warning: Change the default admin password immediately after first login in any production environment.

What's done & what's next

Completed

  • [x]  MVC architecture with custom router

  • [x]  Role-based authentication (Admin / Examiner / Student)

  • [x]  Full exam CRUD with draft / published / completed states

  • [x]  MCQ questions with dynamic options (2 to unlimited)

  • [x]  Bulk CSV question import

  • [x]  Real-time exam engine with AJAX auto-save

  • [x]  Tab-switch proctoring & violation logging

  • [x]  Results analytics with Chart.js charts

  • [x]  Per-attempt answer review modal

Planned

  • [ ]  Email notifications (exam reminders, result emails)

  • [ ]  Exportable result reports (PDF / Excel)

  • [ ]  Question bank with tag-based pools

  • [ ]  Randomised question order per student

  • [ ]  Multi-language support

  • [ ]  REST API for mobile app integration

Download File OnlineExaminationSystem.zip

Related Articles

0 Comments

Leave a Comment