Online Learning Platform in PHP and MySQL
Project Title:
Online Learning Platform
Objective:
The goal of this project
is to develop a web-based platform that facilitates seamless learning and
teaching by providing tools to manage courses, assignments, quizzes, and
student progress. The platform caters to three main types of users: Admins,
Instructors, and Students, each with specific roles and
permissions.
This project combines
robust backend development using PHP and MySQL with an intuitive
frontend interface enhanced by Bootstrap for responsive design.
This project aims to deliver a comprehensive Online Learning Platform that simplifies and enhances the teaching and learning experience. By leveraging PHP and MySQL, it provides a scalable and efficient solution to educational needs while maintaining user-friendly and responsive designs.
Features and Functionality of the Online Learning Platform
1. User Management
- Authentication
and Authorization:
- Secure
login and registration with password encryption.
- Role-based
access control for Admins, Instructors, and Students.
- Profile
Management:
- Users
can update their profiles with personal details, including name, email,
and password.
2. Admin Features
- User
Management:
- Add,
edit, and delete instructor and student accounts.
- Assign
roles to users during registration or update roles.
- Course
Management:
- Create,
update, and delete courses.
- Assign
instructors to specific courses.
- Reporting
and Analytics:
- View
platform-wide statistics, such as the number of courses, enrolled
students, and instructor performance.
- Generate
progress reports for students and courses.
- Notification
Management:
- Send
platform-wide announcements or notifications to instructors and students.
3. Instructor Features
- Course
Creation and Management:
- Create
and manage courses with detailed descriptions, syllabus, and media files.
- Upload
materials such as PDFs, videos, or presentations.
- Assignment
and Quiz Management:
- Create,
update, and delete assignments and quizzes.
- Set
deadlines and provide instructions for each task.
- Student
Progress Monitoring:
- View
and track the performance of enrolled students.
- Grade
assignments and provide feedback.
- Communication:
- Post
announcements or messages for enrolled students.
- Respond
to student queries through a messaging feature.
4. Student Features
- Course
Enrollment:
- Browse
and enroll in available courses.
- View
course details, syllabus, and announcements.
- Assignment
Submission:
- Download
and review assignment instructions.
- Upload
completed assignments before deadlines.
- Quiz
Participation:
- Take
quizzes associated with courses.
- View
immediate results (if auto-graded) or wait for instructor feedback.
- Progress
Tracking:
- View
personal progress in enrolled courses.
- Access
grades and instructor feedback for assignments and quizzes.
- Communication:
- Ask
questions or seek clarifications through messaging features.
5. Course Management
- Dynamic
Course Catalog:
- Centralized
listing of all courses with search and filter options.
- Content
Organization:
- Courses
can include multiple modules, each with associated resources,
assignments, and quizzes.
- Enrollment
Tracking:
- Track
which students are enrolled in which courses.
- Course
Feedback:
- Allow
students to provide feedback or ratings for courses.
6. Assignments and
Quizzes
- Instructor
Functionality:
- Add
detailed instructions for assignments.
- Create
quizzes with various question types (e.g., multiple choice, true/false,
short answer).
- Student
Functionality:
- View
pending assignments and quizzes in the dashboard.
- Upload
assignment files directly through the portal.
- Participate
in quizzes and view results.
- Grading
and Feedback:
- Auto-grade
quizzes with pre-set answers.
- Allow
instructors to manually review and grade assignments or quizzes.
7. Dashboards
- Admin
Dashboard:
- Overview
of platform activity (e.g., total users, active courses, ongoing
assignments).
- Shortcut
actions for managing users, courses, and notifications.
- Instructor
Dashboard:
- List
of courses managed by the instructor.
- Notifications
for upcoming deadlines or student submissions.
- Overview
of student progress and performance.
- Student
Dashboard:
- Personalized
course list and progress tracker.
- Notifications
for pending assignments and quizzes.
- Quick
access to grades and feedback.
8. Notifications and
Alerts
- System
Notifications:
- Automatic
reminders for assignment deadlines, quiz schedules, and course updates.
- Manual
Notifications:
- Admins
and instructors can send custom notifications to targeted users.
- Real-Time
Alerts:
- Notify
users of new announcements or messages via email or in-app alerts.
9. Progress and Reporting
- Progress
Tracking for Students:
- View
completed, pending, and overdue tasks.
- Access
performance metrics like grades and feedback history.
- Reporting
for Admins and Instructors:
- Generate
course-wise or user-specific reports.
- Visualize
data through charts or tables for better insights.
- Export
Options:
- Export
reports to PDF or Excel for record-keeping.
10. File Management
- Upload
and download resources, assignments, and materials.
- Ensure
secure file storage and retrieval for all roles.
11. Communication Tools
- Messaging
System:
- Instructors
and students can communicate directly through the platform.
- Announcements:
- Admins
and instructors can broadcast important updates or messages.
12. Responsive Design
- Mobile-Friendly:
- Fully
responsive layout designed using Bootstrap to ensure compatibility
across devices.
- User-Friendly
Interface:
- Clean
navigation tailored for each user role.
13. Security
- Data
Protection:
- Secure
database connections using prepared statements in PHP to prevent SQL
injection.
- Password
Hashing:
- Store
user passwords securely using hashing algorithms like bcrypt.
- Role-Based
Permissions:
- Prevent
unauthorized access to restricted features.
14. Scalability and
Customization
- Modular
architecture allows easy addition of new features or roles.
- Support
for multiple instructors per course and unlimited student enrollments.
Modules in the project
1. User Management Module
- Handles
user authentication (login, registration, password management).
- Implements
role-based access control for Admins, Instructors, and Students.
- Manages
user profiles (view, edit, and update personal details).
2. Admin Module
- Features:
- Dashboard
for an overview of platform activities.
- Management
of users (add, edit, delete instructors and students).
- Manage
and assign instructors to courses.
- Generate
and export reports.
- Acts
as the control center for the entire platform.
3. Course Management
Module
- Features:
- Create,
edit, and delete courses.
- Organize
course content into modules (e.g., chapters, lessons, or topics).
- Upload
course resources like videos, PDFs, and presentations.
- Assign
instructors to courses.
- Instructors:
- Manage
course-specific materials, assignments, and quizzes.
4. Assignment Management
Module
- Features:
- Create,
manage, and delete assignments for courses.
- Set
deadlines and provide instructions for assignments.
- Allow
students to upload submissions.
- Enable
instructors to grade submissions and provide feedback.
- Student
Interface:
- View
assignments and submit files.
5. Quiz Management Module
- Features:
- Create
quizzes with multiple question types (e.g., multiple choice, true/false,
and short answer).
- Set
quiz rules, such as time limits or passing criteria.
- Auto-Grading:
- Automatically
grade quizzes where applicable.
- Student
Interface:
- View
upcoming quizzes, participate, and review results.
6. Student Progress
Tracking Module
- Features:
- Track
student progress in enrolled courses.
- Monitor
completed assignments, quizzes, and feedback.
- Generate
detailed progress reports.
- Instructor
Interface:
- View
student performance metrics.
- Generate
course-wide or individual student reports.
7. Notifications and
Alerts Module
- Features:
- Manage
platform-wide notifications and alerts.
- Send
reminders for assignments, quizzes, or announcements.
- Provide
real-time alerts via email or in-app notifications.
8. Communication Module
- Features:
- Messaging
system for direct communication between instructors and students.
- Announcement
system for course updates or important notifications.
- Enables
seamless interaction and query resolution.
9. Dashboard Module
- Features:
- Custom
dashboards for Admins, Instructors, and Students.
- Summarized
views of relevant information for each role:
- Admin:
Platform stats and management shortcuts.
- Instructor:
Course lists, pending grading, and student queries.
- Student:
Enrolled courses, pending tasks, and progress.
10. Reporting and
Analytics Module
- Features:
- Generate
detailed reports for courses, instructors, and students.
- Visualize
platform data through charts or tables.
- Export
reports for offline use (e.g., PDF, Excel).
11. File Management
Module
- Features:
- Upload
and manage course resources (videos, PDFs, etc.).
- Store
student submissions securely.
- Provide
download access to resources and materials.
12. Authentication and
Security Module
- Features:
- Manage
user sessions securely.
- Implement
password hashing for secure storage.
- Enforce
role-based access control to restrict unauthorized access.
13. Responsive Design
Module
- Features:
- Ensure
the application is mobile-friendly.
- Use
Bootstrap for a responsive layout that adapts to different screen
sizes.
14. Search and Filtering
Module
- Features:
- Enable
users to search for courses by keywords.
- Filter
courses based on criteria such as category, instructor, or level.
15. Feedback and Rating
Module
- Features:
- Allow
students to provide feedback on courses and instructors.
- Collect
ratings to improve course quality.
16. Payment Integration
Module (Optional, Advanced)
- Features:
- Enable
payment functionality for paid courses.
- Integrate
payment gateways (e.g., PayPal, Stripe).
Technologies Used in the Online Learning Platform
The Online Learning Platform is built using a combination of backend, frontend, database, and supportive technologies.
1. Backend Technologies
- PHP:
- Core
language for server-side scripting and handling business logic.
- Frameworks
(Optional for scalability and better structure):
- Laravel:
For MVC architecture, routing, and advanced features.
- MySQL:
- Relational
database management system for storing and managing data such as users,
courses, assignments, and progress.
- XAMPP
or WAMP:
- Local
development environment for testing PHP and MySQL functionality.
2. Frontend Technologies
- HTML5:
- Structure
and content of web pages.
- CSS3:
- Styling
and layout of the platform for a visually appealing design.
- JavaScript:
- Adding
interactivity to the platform, such as form validation and dynamic
content loading.
- Bootstrap:
- Responsive
design framework for ensuring compatibility across devices.
- AJAX:
- Asynchronous
requests for dynamic updates without refreshing the page.
3. Database
- MySQL:
- Primary
database for storing structured data:
- User
details (admins, instructors, students).
- Course
information and materials.
- Assignments,
quizzes, and grades.
- Progress
tracking and reports.
4. Version Control
- Git:
- Version
control for managing code changes.
- GitHub/GitLab/Bitbucket:
- Remote
repositories for team collaboration and code management.
5. Tools for Development
- Code
Editor/IDE:
- Popular
choices:
- Visual
Studio Code: Lightweight and feature-rich for
PHP, JavaScript, and HTML.
- PHPStorm:
Advanced IDE for PHP development.
- Browser
Developer Tools:
- Debugging
and testing frontend elements across different browsers.
- Postman:
- API
testing tool for ensuring smooth interaction between frontend and
backend.
6. Security
- HTTPS:
- For
secure communication between the server and clients.
- Prepared
Statements in PHP:
- Prevents
SQL injection by securely handling database queries.
- bcrypt:
- Hashing
library for secure password storage.
7. Optional Advanced
Technologies
- Frameworks:
- Laravel
or CodeIgniter: For better structure and scalability.
- JavaScript
Libraries:
- jQuery:
Simplifies DOM manipulation and AJAX calls.
- Charts.js
or Google Charts:
- For
visualizing data in reports and dashboards.
- Payment
Gateways:
- Stripe
or PayPal: For integrating payment systems (if implementing paid
courses).
- Cloud
Storage:
- Amazon
S3 or Google Drive API: For storing large
files like videos and presentations.
8. Deployment
- Web
Server:
- Apache
or Nginx: For hosting the PHP application.
- Hosting
Platform:
- Shared
hosting (e.g., Bluehost, HostGator) or cloud hosting (e.g., AWS,
DigitalOcean).
- Domain
and SSL:
- For
deploying the application with a secure URL.
9. Testing
- PHPUnit:
- For
writing and running unit tests for backend logic.
- Selenium:
- For
automated testing of the frontend interface.
Summary of Key
Technologies
Category |
Technologies |
Backend |
PHP, Laravel
(optional), XAMPP/WAMP |
Database |
MySQL |
Frontend |
HTML5, CSS3,
JavaScript, Bootstrap, AJAX |
Version Control |
Git, GitHub/GitLab |
Development |
Visual Studio Code,
PHPStorm, Postman |
Security |
HTTPS, Prepared
Statements, bcrypt |
Optional |
Stripe, PayPal, Amazon
S3, Charts.js |
Deployment |
Apache/Nginx, AWS,
DigitalOcean, SSL |
Testing |
PHPUnit, Selenium |
Entity-Relationship (ER) Diagram
Entities and Attributes
1. Users
- id
(Primary Key)
- name
- email
- password
- role
(Admin, Instructor, Student)
- created_at
- updated_at
2. Courses
- id
(Primary Key)
- title
- description
- instructor_id
(Foreign Key from Users)
- created_at
- updated_at
3. Modules
- id
(Primary Key)
- course_id
(Foreign Key from Courses)
- title
- content
(text or file)
- created_at
- updated_at
4. Assignments
- id
(Primary Key)
- course_id
(Foreign Key from Courses)
- title
- description
- deadline
- created_at
- updated_at
5. Quizzes
- id
(Primary Key)
- course_id
(Foreign Key from Courses)
- title
- description
- created_at
- updated_at
6. Questions
- id
(Primary Key)
- quiz_id
(Foreign Key from Quizzes)
- question_text
- question_type
(e.g., MCQ, True/False)
- options
(if applicable, as JSON)
- correct_answer
- created_at
- updated_at
7. Submissions
- id
(Primary Key)
- assignment_id
(Foreign Key from Assignments)
- student_id
(Foreign Key from Users)
- submission_file
- submitted_at
- grade
(nullable)
- feedback
(nullable)
8. Enrollments
- id
(Primary Key)
- course_id
(Foreign Key from Courses)
- student_id
(Foreign Key from Users)
- enrolled_at
Relationships
1.
Users and Courses:
o A
user (instructor) can create multiple courses (1-to-Many).
o A
course is managed by one instructor (Many-to-1).
2.
Courses and Modules:
o A
course can have multiple modules (1-to-Many).
o A
module belongs to one course (Many-to-1).
3.
Courses and Assignments:
o A
course can have multiple assignments (1-to-Many).
o An
assignment belongs to one course (Many-to-1).
4.
Courses and Quizzes:
o A
course can have multiple quizzes (1-to-Many).
o A
quiz belongs to one course (Many-to-1).
5.
Quizzes and Questions:
o A
quiz can have multiple questions (1-to-Many).
o A
question belongs to one quiz (Many-to-1).
6.
Assignments and Submissions:
o An
assignment can have multiple submissions (1-to-Many).
o A
submission belongs to one assignment (Many-to-1).
7.
Users and Submissions:
o A
student can submit multiple assignments (1-to-Many).
o A
submission is submitted by one student (Many-to-1).
8.
Users and Enrollments:
o A
student can enroll in multiple courses (Many-to-Many via Enrollments).
o A
course can have multiple students enrolled (Many-to-Many via Enrollments).
ER Diagram
While the ER diagram cannot draw directly , you can follow these steps to create it in a tool
like Lucidchart, Draw.io, or MySQL Workbench:
1.
Place Entities:
o Add
the above entities (Users, Courses, Modules, Assignments, Quizzes, Questions, Submissions,
Enrollments) as rectangles.
2.
Add Attributes:
o Inside
each entity, include the attributes listed above.
3.
Define Relationships:
o Use
lines to connect entities with appropriate relationship symbols:
§ 1-to-Many:
A single entity connects to multiple instances of another.
§ Many-to-Many:
Requires a linking table like Enrollments.
DFD for this project
A Data Flow Diagram (DFD) illustrates the flow of data within a system, detailing how data is processed, stored, and transferred between different entities and processes.
Below is a step-by-step
breakdown for creating the DFD for the Online Learning Platform:
DFD Level 0 (Context
Diagram)
The context diagram
provides an overview of the entire system. It contains:
- External
Entities:
- Admin
- Instructor
- Student
- System:
- Online
Learning Platform
- Data
Flows:
- Admin
manages users, courses, and quizzes.
- Instructor
manages courses, modules, assignments, and quizzes.
- Students
interact with courses, submit assignments, take quizzes, and view
progress.
DFD Level 1 (Detailed
System Breakdown)
Processes:
1.
User Management
(Admin):
o Admin
adds, updates, or deletes users.
o System
authenticates and authorizes users.
2.
Course Management
(Admin & Instructor):
o Admin
creates course categories.
o Instructor
adds course details, modules, and materials.
3.
Content Management
(Instructor):
o Instructor
uploads modules, assignments, and quizzes.
4.
Student Enrollment:
o Students
enroll in courses.
o System
validates course availability.
5.
Assignment Submission:
o Students
submit assignments.
o System
stores submissions and tracks deadlines.
6.
Quiz Management:
o Instructors
create quizzes.
o Students
take quizzes.
o System
evaluates and stores quiz results.
7.
Progress Tracking:
o System
generates progress reports for students and instructors.
Data Stores:
- User
Database: Stores user credentials, roles, and
details.
- Course
Database: Stores course information.
- Assignment
Database: Stores assignment details and
submissions.
- Quiz
Database: Stores quizzes, questions, and
results.
- Enrollment
Database: Tracks student enrollments.
- Progress
Database: Stores student progress and
performance data.
DFD Level 2
(Process-Specific Flows)
Example: Assignment
Submission
1.
Input:
o Student
uploads an assignment.
2.
Processes:
o Validate
file format and deadline.
o Save
the submission in the database.
o Notify
the instructor of new submissions.
3.
Output:
o Store
submission details in the Assignment Database.
Diagram
1. DFD Level 0 (Context Diagram)
2. DFD Level 1 (Detailed Breakdown):
Database Table
Database tables for the Online Learning Platform project. These tables are designed to manage courses, users, assignments, quizzes, enrollments, and student progress.
1. Users Table
This table stores the
details of users, including students, instructors, and admins.
Column Name |
Data Type |
Description |
id |
INT |
Primary Key, Auto
Increment |
name |
VARCHAR(255) |
Name of the user |
email |
VARCHAR(255) |
Email address (unique) |
password |
VARCHAR(255) |
Password (hashed) |
role |
ENUM |
Role of the user (e.g.,
student, instructor, admin) |
created_at |
TIMESTAMP |
Timestamp when the user
was created |
updated_at |
TIMESTAMP |
Timestamp when the user
details were last updated |
2. Courses Table
This table stores the
information about the courses offered.
Column Name |
Data Type |
Description |
id |
INT |
Primary Key, Auto
Increment |
title |
VARCHAR(255) |
Course title |
description |
TEXT |
Brief description of
the course |
instructor_id |
INT |
Foreign Key to users
table (references id of instructor) |
created_at |
TIMESTAMP |
Timestamp when the
course was created |
updated_at |
TIMESTAMP |
Timestamp when the
course details were last updated |
3. Modules Table
This table stores
information about the modules in each course.
Column Name |
Data Type |
Description |
id |
INT |
Primary Key, Auto
Increment |
course_id |
INT |
Foreign Key to courses
table (references id of course) |
title |
VARCHAR(255) |
Title of the module |
content |
TEXT |
Module content (could
be text, video, or links) |
created_at |
TIMESTAMP |
Timestamp when the
module was created |
updated_at |
TIMESTAMP |
Timestamp when the
module was last updated |
4. Assignments Table
This table stores
information about assignments given in each course.
Column Name |
Data Type |
Description |
id |
INT |
Primary Key, Auto
Increment |
course_id |
INT |
Foreign Key to courses table
(references id of course) |
title |
VARCHAR(255) |
Assignment title |
description |
TEXT |
Description of the
assignment |
deadline |
DATETIME |
Deadline for assignment
submission |
created_at |
TIMESTAMP |
Timestamp when the
assignment was created |
updated_at |
TIMESTAMP |
Timestamp when the
assignment details were last updated |
5. Quizzes Table
This table stores
information about quizzes for each course.
Column Name |
Data Type |
Description |
id |
INT |
Primary Key, Auto
Increment |
course_id |
INT |
Foreign Key to courses table
(references id of course) |
title |
VARCHAR(255) |
Quiz title |
description |
TEXT |
Description of the quiz |
created_at |
TIMESTAMP |
Timestamp when the quiz
was created |
updated_at |
TIMESTAMP |
Timestamp when the quiz
details were last updated |
6. Questions Table
This table stores the
questions for quizzes.
Column Name |
Data Type |
Description |
id |
INT |
Primary Key, Auto
Increment |
quiz_id |
INT |
Foreign Key to quizzes
table (references id of quiz) |
question_text |
TEXT |
The question text |
question_type |
ENUM |
Type of the question
(e.g., multiple choice, true/false) |
options |
TEXT |
Options for multiple
choice questions (JSON format) |
correct_answer |
VARCHAR(255) |
Correct answer for the
question |
created_at |
TIMESTAMP |
Timestamp when the
question was created |
updated_at |
TIMESTAMP |
Timestamp when the
question details were last updated |
7. Submissions Table
This table stores student
submissions for assignments.
Column Name |
Data Type |
Description |
id |
INT |
Primary Key, Auto
Increment |
assignment_id |
INT |
Foreign Key to assignments
table (references id of assignment) |
student_id |
INT |
Foreign Key to users
table (references id of student) |
submission_file |
VARCHAR(255) |
File path or name of
the submitted file |
submitted_at |
DATETIME |
Timestamp when the
assignment was submitted |
grade |
VARCHAR(10) |
Grade awarded for the
assignment |
feedback |
TEXT |
Feedback given to the
student |
8. Enrollments Table
This table stores the
relationship between students and the courses they are enrolled in.
Column Name |
Data Type |
Description |
id |
INT |
Primary Key, Auto
Increment |
course_id |
INT |
Foreign Key to courses table
(references id of course) |
student_id |
INT |
Foreign Key to users
table (references id of student) |
enrolled_at |
DATETIME |
Timestamp when the
student enrolled in the course |
9. Progress Table
This table stores the
progress of students in courses, tracking completed modules, assignments, and
quizzes.
Column Name |
Data Type |
Description |
id |
INT |
Primary Key, Auto
Increment |
student_id |
INT |
Foreign Key to users
table (references id of student) |
course_id |
INT |
Foreign Key to courses table
(references id of course) |
completed_modules |
TEXT |
JSON list of completed
module IDs |
completed_assignments |
TEXT |
JSON list of completed
assignment IDs |
completed_quizzes |
TEXT |
JSON list of completed
quiz IDs |
created_at |
TIMESTAMP |
Timestamp when the
progress record was created |
updated_at |
TIMESTAMP |
Timestamp when the
progress record was last updated |
10. Notifications Table
This table stores
notifications for users (students, instructors, admins).
Column Name |
Data Type |
Description |
id |
INT |
Primary Key, Auto
Increment |
user_id |
INT |
Foreign Key to users
table (references id of user) |
message |
TEXT |
Notification message |
status |
ENUM |
Status of the
notification (unread, read) |
created_at |
TIMESTAMP |
Timestamp when the
notification was created |
Summary of Relationships:
- Users
can be students, instructors, or admins.
- Courses
are created by instructors and can have multiple modules, assignments,
and quizzes.
- Assignments
can have multiple submissions by students.
- Quizzes
can have multiple questions that students answer.
- Students
enroll in courses and progress is tracked in the Progress
table.
- Notifications
can be sent to users for updates.
SQL queries to create all the database tables for the Online Learning Platform project.
1. Users Table
CREATE TABLE users (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL UNIQUE,
password VARCHAR(255) NOT NULL,
role ENUM('student', 'instructor', 'admin')
NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP
);
2. Courses Table
CREATE TABLE courses (
id INT AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(255) NOT NULL,
description TEXT,
instructor_id INT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (instructor_id) REFERENCES
users(id) ON DELETE CASCADE
);
3. Modules Table
CREATE TABLE modules (
id INT AUTO_INCREMENT PRIMARY KEY,
course_id INT NOT NULL,
title VARCHAR(255) NOT NULL,
content TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (course_id) REFERENCES
courses(id) ON DELETE CASCADE
);
4. Assignments Table
CREATE TABLE assignments (
id INT AUTO_INCREMENT PRIMARY KEY,
course_id INT NOT NULL,
title VARCHAR(255) NOT NULL,
description TEXT,
deadline DATETIME NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (course_id) REFERENCES
courses(id) ON DELETE CASCADE
);
5. Quizzes Table
CREATE TABLE quizzes (
id INT AUTO_INCREMENT PRIMARY KEY,
course_id INT NOT NULL,
title VARCHAR(255) NOT NULL,
description TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (course_id) REFERENCES
courses(id) ON DELETE CASCADE
);
6. Questions Table
CREATE TABLE questions (
id INT AUTO_INCREMENT PRIMARY KEY,
quiz_id INT NOT NULL,
question_text TEXT NOT NULL,
question_type ENUM('multiple choice', 'true/false',
'short answer') NOT NULL,
options TEXT, -- JSON format for options if the question is
multiple choice
correct_answer VARCHAR(255) NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (quiz_id) REFERENCES
quizzes(id) ON DELETE CASCADE
);
7. Submissions Table
CREATE TABLE submissions (
id INT AUTO_INCREMENT PRIMARY KEY,
assignment_id INT NOT NULL,
student_id INT NOT NULL,
submission_file VARCHAR(255),
submitted_at DATETIME DEFAULT CURRENT_TIMESTAMP,
grade VARCHAR(10),
feedback TEXT,
FOREIGN KEY (assignment_id) REFERENCES
assignments(id) ON DELETE CASCADE,
FOREIGN KEY (student_id) REFERENCES
users(id) ON DELETE CASCADE
);
8. Enrollments Table
CREATE TABLE enrollments (
id INT AUTO_INCREMENT PRIMARY KEY,
course_id INT NOT NULL,
student_id INT NOT NULL,
enrolled_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (course_id) REFERENCES
courses(id) ON DELETE CASCADE,
FOREIGN KEY (student_id) REFERENCES
users(id) ON DELETE CASCADE
);
9. Progress Table
CREATE TABLE progress (
id INT AUTO_INCREMENT PRIMARY KEY,
student_id INT NOT NULL,
course_id INT NOT NULL,
completed_modules TEXT, -- JSON format of completed module IDs
completed_assignments TEXT, -- JSON format of completed assignment IDs
completed_quizzes TEXT, -- JSON format of completed quiz IDs
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY (student_id) REFERENCES
users(id) ON DELETE CASCADE,
FOREIGN KEY (course_id) REFERENCES
courses(id) ON DELETE CASCADE
);
10. Notifications Table
CREATE TABLE notifications (
id INT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
message TEXT NOT NULL,
status ENUM('unread', 'read') DEFAULT 'unread',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (user_id) REFERENCES users(id) ON
DELETE CASCADE
);
Summary of Relationships:
- Users
Table: Stores information about all users (students,
instructors, admins).
- Courses
Table: Stores course details; linked to the Users
table for the instructor.
- Modules
Table: Stores the modules for each course.
- Assignments
Table: Stores assignments related to each course.
- Quizzes
Table: Stores quizzes related to each course.
- Questions
Table: Stores the questions related to each quiz.
- Submissions
Table: Stores student assignment submissions.
- Enrollments
Table: Tracks student enrollments in courses.
- Progress
Table: Stores the progress of students in courses.
- Notifications
Table: Stores notifications for users.
Project Structure:
/online-learning-platform
│
├── /assets # Static files like
images, CSS, and JS
│ ├── /css # CSS files
│ ├── /img # Image files
│ ├── /js # JavaScript files
│ └── /fonts # Font files
│
├── /config # Configuration files
│ └── config.php # Database connection
configuration and other global settings
│
├── /controllers # PHP classes to handle
requests
│ ├── CourseController.php # Handles course-related functionality
│ ├── AssignmentController.php # Handles
assignment-related functionality
│ ├── QuizController.php # Handles quiz-related functionality
│ ├── UserController.php # Handles user-related functionality
(signup, login, profile)
│ └── AdminController.php # Handles admin-specific functionality
│
├── /core # Core functionality of
the platform
│ ├── Database.php # Database connection and query
handling
│ └── Auth.php # Authentication and session
handling
│
├── /models # PHP classes representing
database tables (models)
│ ├── Course.php # Represents the Course table
│ ├── Module.php # Represents the Module table
│ ├── Assignment.php # Represents the Assignment table
│ ├── Quiz.php # Represents the Quiz table
│ ├── Question.php # Represents the Question table
│ ├── Submission.php # Represents the Submission table
│ ├── Enrollment.php # Represents the Enrollment table
│ ├── Progress.php # Represents the Progress table
│ ├── Notification.php # Represents the Notification table
│ └── User.php # Represents the User table
│
├── /views # HTML and PHP files for the frontend (views)
│ ├── /admin # Admin dashboard views
│ │ ├── dashboard.php # Admin dashboard page
│ │ ├──
manage_courses.php # Admin course
management page
│ │ ├── manage_users.php # Admin user management page
│ │
└── settings.php # Admin
settings page
│ │
│ ├── /student # Student dashboard views
│ │ ├── dashboard.php # Student dashboard page
│ │ ├──
course_details.php # Student course
detail page
│ │ ├── assignments.php # Student assignments page
│ │ ├── quizzes.php # Student quizzes page
│ │
└── progress.php # Student
progress page
│ │
│ ├── /instructor # Instructor dashboard views
│ │ ├── dashboard.php # Instructor dashboard page
│ │ ├──
manage_modules.php # Instructor module
management page
│ │ ├── manage_assignments.php
# Instructor assignment management page
│ │
└── manage_quizzes.php #
Instructor quiz management page
│ │
│ ├── login.php # Login page (shared for all
users)
│ ├── signup.php # Signup page
│ └── 404.php # Error page (404)
│
├── /includes # Reusable components and
templates
│ ├── header.php # Header file (includes navbar,
common assets)
│ ├── footer.php # Footer file (common footer
elements)
│ ├── sidebar.php # Sidebar for admin and user
panels
│ └── message.php # Message notification system
(display alerts)
│
├── /uploads # Directory for file
uploads (assignments, course materials)
│ ├── assignments # Directory for uploaded
assignment files
│ ├── course_materials # Directory for course content files
(PDFs, docs, etc.)
│ └── profile_pictures # Directory for user profile pictures
│
├── /routes # Routing files (handling
user requests)
│ ├── web.php # Routes for various
functionalities (courses, assignments, etc.)
│
├── /tests # Unit tests for various
modules
│ └── UserTest.php # Tests for user registration,
login, etc.
│
├── index.php # Main entry point of the
project
├── .htaccess # Apache configuration file
for URL rewriting
└── README.md # Project documentation
Description of
Directories and Files:
1. /assets:
- /css:
Contains all the CSS files for styling the platform.
- /img:
Stores images used throughout the platform.
- /js:
Contains JavaScript files for front-end interactivity.
- /fonts:
Stores font files used in the platform.
2. /config:
- config.php:
Contains database connection settings and other global configuration
variables.
3. /controllers:
- Each
file here corresponds to a module in the platform (e.g., UserController,
CourseController, AssignmentController, etc.).
- These
controllers handle user input, interact with the models, and return
appropriate views.
4. /core:
- Database.php:
A class for handling database connections and queries.
- Auth.php:
A class for user authentication (login, signup, and session management).
5. /models:
- Each
file here corresponds to a database table (e.g., User.php, Course.php,
Module.php, etc.).
- These
files define the structure and interaction with the respective database
tables, using object-oriented programming principles.
6. /views:
- Contains
HTML files (mixed with PHP) that render the user interface.
- /admin,
/student, /instructor: Each directory contains views
specific to the type of user.
- Common
views like login.php, signup.php, and 404.php are
available for general use.
7. /includes:
- Reusable
components (header, footer, sidebar, etc.) that are included in various
pages to avoid redundancy.
8. /uploads:
- Stores
files uploaded by users, such as assignment submissions, course materials,
and profile pictures.
9. /routes:
- web.php:
Defines routes that handle different requests (GET, POST, etc.) and map
them to corresponding controller functions.
10. /tests:
- Unit
tests for the platform to ensure that key functionalities are working as
expected.
11. index.php:
- The
entry point of the application where the request is routed, often through
a controller or main router.
12. .htaccess:
- Apache
configuration file that allows URL rewriting for clean and user-friendly
URLs (e.g., /courses instead of /index.php?page=courses).
13. README.md:
- Project
documentation, including setup instructions, feature explanations, and
contribution guidelines.
Explanation of File
Workflow:
1.
index.php:
o The
main entry point that loads the necessary controllers and routes based on user
requests.
2.
Routing:
o web.php
defines the routes to various functions within the controllers. For example,
when a user visits /courses, the corresponding controller (CourseController.php)
will handle that request.
3.
Controller:
o The
controller receives user input (via GET/POST), processes it, and interacts with
models (e.g., retrieving or saving data from the database).
4.
Model:
o Each
model corresponds to a table in the database and provides methods to interact
with that table, such as inserting data, fetching records, updating, and
deleting entries.
5.
View:
o After
the controller processes the data, it sends it to the view, which is
responsible for rendering the HTML output to the user. The view also includes
partials like headers, footers, and sidebars from the /includes directory.
6.
Database:
o The
models interact with the MySQL database to fetch and manipulate data. The config.php
file sets up the database connection.
By following this
structure, the project will remain organized, and it will be easier to maintain
and scale the platform as new features are added.