The Examination Management System is a comprehensive backend solution designed to handle all aspects of educational institution operations. Built with modern Node.js and Express.js, this API provides secure, efficient, and scalable endpoints for managing:
| Feature | Description |
|---|---|
| ๐ Authentication | Secure login/register for students and instructors |
| ๐ Course Management | Full CRUD operations with instructor assignment |
| ๐จโ๐ Student Management | Track assignment, enrollment, and progress tracking |
| ๐จโ๐ซ Instructor Management | Department association and course management |
| ๐ Dynamic Exams | Auto-generated exams with MCQ and True/False questions |
| โฑ๏ธ Time Tracking | Real-time exam timer with auto-submission on timeout |
| โ Auto-Grading | Instant result calculation upon submission |
| ๐ Exam Review | Detailed review with correct/incorrect answers |
| ๐ก๏ธ Validation | Request validation using express-validator |
| ๐ Pagination | Efficient data retrieval with pagination support |
| Technology | Version | Purpose |
|---|---|---|
| Node.js | 18+ | JavaScript Runtime |
| Express.js | 5.2.1 | Web Application Framework |
| Sequelize | 6.37.7 | ORM for SQL Server |
| Tedious | 19.2.0 | MS SQL Server Driver |
| express-validator | 7.3.1 | Input Validation Middleware |
| Morgan | 1.10.1 | HTTP Request Logger |
| CORS | 2.8.5 | Cross-Origin Resource Sharing |
| dotenv | 17.2.3 | Environment Configuration |
| Nodemon | 3.1.11 | Development Hot Reload |
Back_sql_project/
โ
โโโ ๐ index.js # Application entry point
โโโ ๐ package.json # Dependencies & scripts
โโโ ๐ .env # Environment variables
โโโ ๐ .gitignore # Git ignore rules
โ
โโโ ๐ Auth/
โ โโโ auth.js # Authentication routes & logic
โ
โโโ โ๏ธ Configuration/
โ โโโ Sequelize.js # Database connection config
โ
โโโ ๐ฎ controllers/
โ โโโ Courses.js # Course business logic
โ โโโ Exams.js # Exam generation & grading
โ โโโ instructors.js # Instructor operations
โ โโโ Students.js # Student auth logic
โ โโโ StudentsController.js # Student CRUD operations
โ
โโโ ๐ models/
โ โโโ init-models.js # Model initialization & relations
โ โโโ choice.js # Answer choices model
โ โโโ course.js # Course model
โ โโโ department.js # Department model
โ โโโ exam.js # Exam model
โ โโโ examquestion.js # Exam-Question junction
โ โโโ instructor.js # Instructor model
โ โโโ question.js # Question model
โ โโโ student.js # Student model
โ โโโ studentquestionanswer.js # Student answers model
โ โโโ topic.js # Topic/Subject model
โ โโโ track.js # Learning track model
โ
โโโ ๐ค๏ธ Routes/
โ โโโ Courses.js # /api/v1/course routes
โ โโโ ExamsRoute.js # /api/v1/exams routes
โ โโโ instructor.js # /api/v1/instructor routes
โ โโโ StudentRoute.js # /api/v1/student routes
โ
โโโ โ
validators/
โโโ coursesValidators.js # Course input validation
โโโ validationSchemaForExams.js # Exam input validation
โโโ validationSchemaForInstructors.js # Instructor validation
โโโ ValidationSchemaForStudent.js # Student validation
Before you begin, ensure you have the following installed:
git clone https://github.com/your-username/examination-system.git
cd Back_sql_project
npm install
Configure environment variables
Create a .env file in the root directory:
PORT=3000
API_VERSION=api/v1
# Database Configuration
DB_NAME=ExaminationDB
DB_USER=sa
DB_PASSWORD=your_secure_password
DB_HOST=localhost
Restore the database
Use SQL Server Management Studio (SSMS) to restore one of the backup files:
dbafterstored.bak - Database with stored proceduresdbveido.bak - Alternative backup# Development mode (with hot reload)
npm run dev
# Production mode
npm start
Verify the installation
Open your browser and navigate to:
http://localhost:3000
| Variable | Description | Default | Required |
|---|---|---|---|
PORT |
Server port number | 3000 |
No |
API_VERSION |
API version prefix | api/v1 |
No |
DB_NAME |
SQL Server database name | - | โ Yes |
DB_USER |
Database username | - | โ Yes |
DB_PASSWORD |
Database password | - | โ Yes |
DB_HOST |
Database host address | localhost |
No |
http://localhost:3000/api/v1
| Method | Endpoint | Description |
|---|---|---|
POST |
/auth/student/login |
Student login |
POST |
/auth/student/register |
Student registration |
POST |
/auth/instructor/login |
Instructor login |
| Method | Endpoint | Description |
|---|---|---|
GET |
/student |
Get all students (paginated) |
GET |
/student/:id |
Get student by ID |
POST |
/student |
Create new student |
PATCH |
/student/:id |
Update student |
DELETE |
/student/:id |
Delete student |
PATCH |
/student/:id/track |
Assign student to track |
| Method | Endpoint | Description |
|---|---|---|
GET |
/instructor |
Get all instructors |
GET |
/instructor/:id |
Get instructor by ID |
POST |
/instructor |
Create new instructor |
PATCH |
/instructor/:id |
Update instructor |
DELETE |
/instructor/:id |
Delete instructor |
| Method | Endpoint | Description |
|---|---|---|
GET |
/course |
Get all courses |
GET |
/course/:id |
Get course by ID |
POST |
/course |
Create new course |
PATCH |
/course/:id |
Update course |
DELETE |
/course/:id |
Delete course |
| Method | Endpoint | Description |
|---|---|---|
POST |
/exams/generate |
Generate new exam |
POST |
/exams/submit |
Submit exam answers |
GET |
/exams/review/:examId/:studentId |
Get exam review |
GET |
/exams/student/:studentId |
Get studentโs exam history |
GET |
/exams/status/:examId/:studentId |
Check exam status |
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ Department โโโโโ<โ Instructor โ>โโโโโ Course โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ
โ Track โโโโโ<โ Student โ>โโโโโโโโโโโค
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ
โ โ
โ โโโโโโดโโโโโ
โ โ Topic โ
โ โโโโโโฌโโโโโ
โ โ
โโโโโโโดโโโโโโ โโโโโโโดโโโโโโ
โ Exam โ>โโโโโโโ Question โ
โโโโโโโฌโโโโโโ โโโโโโโฌโโโโโโ
โ โ
โโโโโโโดโโโโโโโโโโโโโโ โโดโโโโโโโโโ
โ StudentQuestion โ โ Choice โ
โ Answer โ โโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโ
| Table | Description |
|---|---|
Student |
Student information and credentials |
Instructor |
Instructor details and department |
Course |
Course catalog with instructor assignment |
Track |
Learning paths/specializations |
Department |
Academic departments |
Question |
Question bank (MCQ, True/False) |
Choice |
Answer choices for questions |
Exam |
Generated exam instances |
ExamQuestion |
Exam-Question mapping |
StudentQuestionAnswer |
Student responses |
Topic |
Subject/Topic categorization |
The system leverages SQL Server stored procedures for complex operations:
| Procedure | Description |
|---|---|
GenerateExam |
Creates exam with random questions |
SubmitExamAnswers |
Processes and grades submissions |
GetExamReview |
Retrieves detailed exam results |
GetStudentExams |
Fetches exam history |
CheckExamStatus |
Validates exam state and timing |
{
"success": false,
"message": "Error description",
"error": "Detailed error message (development only)"
}
| Code | Description |
|---|---|
200 |
Success |
201 |
Created |
400 |
Bad Request (validation error) |
401 |
Unauthorized |
404 |
Not Found |
500 |
Internal Server Error |
{
"success": false,
"data": [
{
"msg": "Field is required",
"param": "fieldName",
"location": "body"
}
]
}
For detailed API documentation with request/response examples:
Contributions are welcome! Please follow these steps:
git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)# Start production server
npm start
# Start development server with hot reload
npm run dev
# Run tests
npm test
.env files to version controlThis project is licensed under the ISC License - see the LICENSE file for details.
CrossITI Team