The Prosnokorta is a robust Java-based web application developed as part of the Object-Oriented Programming (OOP) course project. It serves as the backbone for managing quizzes, questions, students, and results, adhering to strict software engineering principles.
We follow a Layered Architecture (MVC-inspired) to ensure separation of concerns and maintainability.
graph TD
Controller[Controller Layer] --> Service[Service Layer]
Service --> Repository[Repository Layer]
Repository --> Database[(Database)]
Each layer has a distinct responsibility:
- Controller Layer: Handles HTTP requests and responses.
- Service Layer: Contains business logic and transactional boundaries.
- Repository Layer: Abstraction for data access (talks to the database).
- Database: Persistent storage.
The project follows a standard industry-grade package structure:
com.quiz
βββ controller # REST Endpoints
βββ service # Business Logic Interfaces
β βββ impl # Service Implementations
βββ repository # Data Access Interfaces
βββ model # JPA Entities (Domain Model)
βββ dto # Data Transfer Objects
βββ config # Configuration Classes
- Responsibility: Accept HTTP requests, validate input, call service methods, and return responses.
- Characteristics: Thin, no business logic.
@RestController
@RequestMapping("/api/student")
public class StudentController {
// Delegates to Service Layer
}- Responsibility: Core business logic, transactional management.
- OOP Principles: Heavy use of Abstraction and Polymorphism.
public interface QuizService {
int calculateScore(...);
}
@Service
public class QuizServiceImpl implements QuizService {
// Implementation details
}- Responsibility: Database communication. (No business logic here).
- Technology: Spring Data JPA.
public interface QuizRepository extends JpaRepository<Quiz, Long> {
}Entities represent real-world objects and use Inheritance and Encapsulation effectively.
- User (Abstract Base Class)
- Admin (Extends User)
- Student (Extends User)
- Subject
- Quiz
- Question
- Result
- Abstraction:
Useris abstract; cannot be instantiated directly. - Inheritance:
AdminandStudentinherit common fields (id, name, email) fromUser. - Encapsulation: All fields are
privatewith public getters/setters. - Polymorphism: Used in service interfaces and potential user processing.
- Ensures no duplicate data.
- Maintains data integrity.
- One Subject β Many Quizzes
- One Quiz β Many Questions
- One Student β Many Results
Mapped using JPA annotations:
@OneToMany(mappedBy = "...")
@ManyToOneWe adhere to SOLID principles to ensure code quality.
- Controller handles HTTP.
- Service handles Logic.
- Repository handles Data.
- Result: No "God Classes".
The system is designed to be extended without modifying existing code.
- Example: Adding a new
QuizTypeorUserRoledoes not break the core logic.
We use Spring's Inversion of Control (IoC) to manage dependencies, promoting loose coupling.
@Autowired
private final QuizService quizService; // Constructor Injection- Shared logic is centralized in Service methods.
- Base classes reduce code duplication in Entities.
Even without complex security frameworks like Spring Security (in the initial phase), the design is secure:
- Server-Side Validation: Never trust the client.
- Secure Data Flow: Correct answers are calculated on the backend and never sent to the frontend during the quiz.
- Base URL:
/api - Style: RESTful, JSON-based, Stateless
- Architecture: Backend-controlled logic
Mandatory endpoints for user access.
| Method | Endpoint | Purpose |
|---|---|---|
POST |
/api/auth/register |
Create a new student account (Used by Frontend Register page) |
POST |
/api/auth/login |
Authenticate user & identify role (Admin/Student) |
POST |
/api/auth/logout |
End session (Logical logout) |
Admin controls content (subjects, quizzes, questions), not usersβ answers.
| Method | Endpoint | Purpose |
|---|---|---|
POST |
/api/admin/subjects |
Add new quiz subject (e.g., Math, ICT) |
GET |
/api/admin/subjects |
View all subjects (Needed before creating quizzes) |
| Method | Endpoint | Purpose |
|---|---|---|
POST |
/api/admin/quizzes |
Create a quiz under a subject & set duration |
GET |
/api/admin/quizzes/{subjectId} |
View quizzes of a specific subject |
| Method | Endpoint | Purpose |
|---|---|---|
POST |
/api/admin/quizzes/{quizId}/questions |
Add MCQ question to quiz |
GET |
/api/admin/quizzes/{quizId}/questions |
Preview quiz questions (Admin view) |
| Method | Endpoint | Purpose |
|---|---|---|
GET |
/api/admin/results |
View all student quiz results |
GET |
/api/admin/results/quiz/{quizId} |
View performance of students for one quiz |
Students consume quizzes and view their own results.
| Method | Endpoint | Purpose |
|---|---|---|
GET |
/api/student/subjects |
Show subject list on dashboard |
GET |
/api/student/quizzes/{subjectId} |
Student selects quiz to attempt |
| Method | Endpoint | Purpose |
|---|---|---|
GET |
/api/student/quiz/{quizId} |
Start Quiz: Fetch metadata & questions (WITHOUT correct answers) |
POST |
/api/student/quiz/{quizId}/submit |
Submit Quiz: Backend calculates score & stores result |
| Method | Endpoint | Purpose |
|---|---|---|
GET |
/api/student/results |
Student views past quiz scores |
GET |
/api/student/results/{resultId} |
View detailed performance of one quiz |
PUT /api/student/profile- Update ProfileDELETE /api/admin/quizzes/{quizId}- Delete Quiz
- Global Exception Handling using
@ControllerAdvice. - Returns proper HTTP Status Codes (200, 400, 404, 500).
- Friendly error messages, avoiding stack trace exposure to clients.
"We followed a layered backend architecture with strong separation of concerns, ensuring clean OOP design, testability, and maintainability."
This architecture demonstrates a strong grasp of:
- Software Architecture (Layered/MVC)
- Object-Oriented Design (Inheritance, Polymorphism, Encapsulation)
- Clean Code Principles (SOLID, DRY)
- Clone the repository
git clone https://github.com/your-username/online-quiz-system.git
- Configuration
- Create a
.envfile from the.env.exampletemplate:- Windows:
copy .env.example .env - Linux/macOS:
cp .env.example .env
- Windows:
- Update
.envwith your MySQL database credentials.
- Create a
- Build & Run
- Option 1: Terminal (Maven Wrapper)
- Windows:
.\mvnw spring-boot:run - Linux/macOS:
./mvnw spring-boot:run
- Windows:
- Option 2: IDE
- Import into IntelliJ IDEA / Eclipse.
- Run
OnlineQuizApplication.java.
- Option 1: Terminal (Maven Wrapper)
- Test Credentials
The database is automatically seeded with these test accounts:
- Admin:
admin@quiz.com/admin123 - Admin:
mahadifardin@quiz.com/admin123 - Student:
student@quiz.com/student123 - Student:
fardin@quiz.com/student123
- Admin:
- Web Frontend: https://github.com/FardinMahadi/Prosnokorta-Web
- Mobile Frontend (React Native): https://github.com/FardinMahadi/Prosnokorta-Mobile
- Backend (API): https://github.com/FardinMahadi/Prosnokorta-API
- Mahadi Hasan Fardin (@FardinMahadi) β Team Leader
Department: ICT
University: Comilla University