A production-ready online examination system built with Core PHP and MySQL. Features include multi-language support (English, Marathi, Hindi), PDF certificate generation, and a comprehensive admin panel.
- Exam Management: Create and manage exams with customizable settings
- Question Types: Multiple choice (single/multiple answer), True/False, Short Answer
- Multi-language Support: English, Marathi, and Hindi translations
- PDF Certificates: Auto-generated certificates for passing candidates
- Timer & Auto-save: Real-time countdown with automatic answer saving
- Admin Panel: Full CRUD for exams, questions, and viewing attempts
- Security: CSRF protection, prepared statements, password hashing, rate limiting
- Responsive Design: Bootstrap 5 for mobile-friendly interface
- PHP 7.4 or higher (compatible with PHP 8.x)
- MySQL 5.7+ or MySQL 8.0+
- Apache with mod_rewrite enabled
- Composer (for PDF library installation)
Copy all files to your web server directory:
htdocs/OnlineExamModule/
Install TCPDF for PDF certificate generation:
cd OnlineExamModule
composer installIf you don't have Composer, download it here.
Note: The system will work without TCPDF, but will generate HTML certificates instead of PDF.
Create a MySQL database for the exam module:
CREATE DATABASE exam_module CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;Import the database schema:
mysql -u root -p exam_module < sql/schema.sqlOr use phpMyAdmin to import sql/schema.sql.
Import sample exam data for testing:
mysql -u root -p exam_module < sql/seed_sample_data.sqlEdit includes/db.php and update the database credentials:
define('DB_HOST', 'localhost');
define('DB_NAME', 'exam_module');
define('DB_USER', 'root');
define('DB_PASS', ''); // Your MySQL passwordEnsure the web server can write to the uploads directory (if you add file uploads):
chmod 755 -R OnlineExamModule- Student Interface:
http://localhost/OnlineExamModule/public/ - Admin Panel:
http://localhost/OnlineExamModule/admin/
After running the schema, the default admin account is:
- Email: admin@example.com
- Password: admin123
OnlineExamModule/
├── admin/ # Admin panel files
│ ├── index.php # Dashboard
│ ├── exams.php # Exam management
│ ├── questions.php # Question management
│ ├── attempts.php # View exam attempts
│ ├── settings.php # System settings
│ ├── login.php # Admin login
│ └── logout.php # Admin logout
├── includes/ # Core PHP includes (protected)
│ ├── db.php # Database connection
│ ├── auth.php # Authentication functions
│ ├── csrf.php # CSRF protection
│ ├── translator.php # Translation functions
│ ├── exam_helper.php # Exam business logic
│ └── pdf_generator.php # Certificate generation
├── locale/ # Translation files (protected)
│ ├── en.json # English
│ ├── mr.json # Marathi
│ └── hi.json # Hindi
├── public/ # Public-facing files
│ ├── css/style.css # Custom styles
│ ├── js/app.js # JavaScript
│ ├── index.php # Exam listing
│ ├── exam.php # Exam details
│ ├── start_exam.php # Start exam
│ ├── take_exam.php # Exam interface
│ ├── submit_exam.php # Submit exam
│ ├── result.php # Results page
│ ├── generate_certificate.php # PDF certificate
│ ├── verify.php # Certificate verification
│ ├── login.php # User login
│ ├── register.php # User registration
│ └── logout.php # User logout
├── sql/ # Database files (protected)
│ ├── schema.sql # Database schema
│ └── seed_sample_data.sql # Sample data
├── templates/ # HTML templates (protected)
│ ├── header.php # Public header
│ ├── footer.php # Public footer
│ ├── admin_header.php # Admin header
│ └── admin_footer.php # Admin footer
├── vendor/ # Composer packages (after install)
├── .htaccess # Apache configuration
├── composer.json # Composer configuration
└── README.md # This file
Edit includes/db.php:
define('DB_HOST', 'localhost');
define('DB_NAME', 'exam_module');
define('DB_USER', 'your_username');
define('DB_PASS', 'your_password');Access the admin panel at /admin/settings.php to configure:
- Site name and logo
- Default language
- Guest exam permissions
- Certificate customization
- Email (SMTP) settings
- Rate limiting
- Create a new JSON file in
/locale/(e.g.,fr.jsonfor French) - Copy structure from
en.json - Translate all strings
- Update the language selector in templates
POST /public/ajax_save_answer.php
Parameters:
csrf_token- CSRF tokenattempt_id- Attempt IDquestion_id- Question IDanswer- User's answer
Response:
{
"success": true,
"message": "Answer saved"
}- CSRF Protection: All forms include CSRF tokens
- SQL Injection Prevention: Prepared statements via PDO
- XSS Prevention: Output escaping with
htmlspecialchars() - Password Security:
password_hash()with bcrypt - Session Security: HTTP-only cookies, session regeneration
- Rate Limiting: Configurable login attempt limits
- Directory Protection:
.htaccessfiles block direct access
- Student browses available exams on index page
- Student views exam details (duration, questions, passing score)
- Student enters name/email (guest) or logs in
- Timer starts, questions load one at a time
- Answers auto-save on selection
- Student navigates using question buttons
- Student submits exam
- System calculates score and determines pass/fail
- If passed, certificate is generated with unique ID
- Certificate can be verified via
/public/verify.php
Edit public/css/style.css to customize the appearance. The module uses Bootstrap 5 CSS variables for easy theming.
The system supports:
mcq_single- Multiple choice, single answermcq_multiple- Multiple choice, multiple answerstrue_false- True/Falseshort_answer- Text input
- Add type to the
questionstabletypeenum - Update
exam_helper.phpcalculateScore()function - Update
take_exam.phpquestion rendering - Update admin
questions.phpform
- Clear browser cookies and try again
- Ensure session storage is working
- Install TCPDF:
composer install - Check write permissions
- Falls back to HTML if TCPDF unavailable
- Verify credentials in
db.php - Ensure MySQL is running
- Check database exists
- Check
.htaccessconfiguration - Ensure mod_rewrite is enabled
- Database connection works
- Admin login functional
- Can create/edit/delete exams
- Can create/edit/delete questions
- Student can browse exams
- Student can start exam (guest mode)
- Timer counts down correctly
- Answers auto-save
- Exam submits successfully
- Score calculated correctly
- Certificate generates (if passed)
- Certificate verification works
- Language switching works (EN/MR/HI)
- Mobile responsive layout
- All forms protected with CSRF
MIT License - feel free to use and modify for your projects.
For issues or feature requests, please create an issue in the repository.