Quiz Management App is a robust application designed to facilitate the creation, management, and tracking of quizzes. Developed using Next.js, Typescript, Redux, Express, PostgreSQL, and Prisma, this app provides a seamless and engaging experience for both admins and performers.
- Roles: Admin, Performer.
- Effortless sign-up, log-in, and account management.
- Admins can create, edit, and delete quizzes.
- Intuitive categorization (e.g., frontend, fullstack).
- Support for both single and multiple-choice questions.
- Performers select a category and answer 10 random questions.
- Instant feedback and real-time score calculation.
- Leaderboard showcasing top performers.
- Efficient storage and display of user scores.
- Utilizes PostgreSQL with Prisma ORM for optimal data handling.
- Robust mechanisms ensure a smooth user experience.
- Next.js and Redux contribute to a clean and intuitive UI.
+---------------------+ +------------------------+ +----------------------+
| User | | Profile | | Quiz |
+---------------------+ +------------------------+ +----------------------+
| id | | id | | id |
| email | | userId -----> | | title |
| password | | username <---- | | category |
| needsPasswordChange | | firstName | | creatorId |
| role | | lastName | | createdAt |
| createdAt | | dateOfBirth | | updatedAt |
| updatedAt | | phoneNumber | | |
| | | address | | |
| | | bio | | |
| | | profileImage | | |
| | | createdAt | | |
| | | updatedAt | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
+---------------------+ +------------------------+ +----------------------+
| |
| |
V V
+---------------------+ +---------------------+ +---------------------+
| Question | | Answer | | Score |
+---------------------+ +---------------------+ +---------------------+
| id | | id | | id |
| content | | content | | score |
| correctOptionId | | isCorrect | | userId |
| quizId -----> | | questionId -----> | | quizId -----> |
| | | | | createdAt |
| | | | | updatedAt |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
+---------------------+ +---------------------+ +---------------------+
Main Routes
- POST /api/v1/: Root route to include all sub-routes.
Auth Routes
- POST /api/v1/auth/register: Register a new user.
- POST /api/v1/auth/login: Log in a user.
- POST /api/v1/auth/refresh-token: Refresh the authentication token.
- POST /api/v1/auth/change-password: Change the password of a user.
Profile Routes
- GET /api/v1/profiles/all-profile: Get all profiles.
- GET /api/v1/profiles/specific-profile/:userId: Get a specific profile by userId.
- PATCH /api/v1/profiles/update-profile/:userId: Update a profile by userId.
- DELETE /api/v1/profiles/delete-profile/:userId: Delete a profile by userId.
Quiz Management Routes
- POST /api/v1/quizzes/: Create a new quiz.
- PUT /api/v1/quizzes/:id: Edit a quiz by ID.
- DELETE /api/v1/quizzes/:id: Delete a quiz by ID.
Score Routes
- GET /api/v1/scores/:userId: View scores for a user.
- GET /api/v1/scores/leaderboard/:category: Get the leaderboard for a specific category.
Quiz Tracking Routes
- GET /api/v1/quizzesTack/:id/start: Start a quiz by ID.
- POST /api/v1/quizzesTack/:id/submit: Submit answers for a quiz by ID.
User Routes
- GET /api/v1/users/all-users: Get all users.
- GET /api/v1/users/:id: Get a user by ID.
- PUT /api/v1/users/:id: Update a user by ID.
- DELETE /api/v1/users/:id: Delete a user by ID.
- Register a new user.
Request Body:
{
"email": "user@example.com",
"password": "securepassword"
}
- Log in a user.
Request Body:
{
"email": "user@example.com",
"password": "securepassword"
}
- Refresh the authentication token.
Request Body:
{
"refreshToken": "your_refresh_token"
}
- Change the password of a user.
Request Body:
{
"oldPassword": "old_securepassword",
"newPassword": "new_securepassword"
}
- Get all profiles.
- Get a specific profile by userId.
- Update a profile by userId.
Request Body:
{
"username": "new_username",
"firstName": "new_firstname",
"lastName": "new_lastname",
"dateOfBirth": "new_dateOfBirth",
"phoneNumber": "new_phoneNumber",
"address": "new_address",
"bio": "new_bio",
"profileImage": "new_profileImage"
}
- Delete a profile by userId.
- Create a new quiz.
Request Body:
{
"title": "New Quiz",
"category": "Science",
"questions": [
{
"content": "Question 1",
"options": [
{"content": "Option A", "isCorrect": true},
{"content": "Option B", "isCorrect": false}
],
"correctOptionId": 1
}
]
}
- Edit a quiz by ID.
Request Body:
{
"title": "Updated Quiz Title",
"category": "Updated Science",
"questions": [
{
"content": "Updated Question 1",
"options": [
{"content": "Updated Option A", "isCorrect": true},
{"content": "Updated Option B", "isCorrect": false}
],
"correctOptionId": 1
}
]
}
- Delete a quiz by ID.
- View scores for a user.
- Get the leaderboard for a specific category.
- Start a quiz by ID.
- Submit answers for a quiz by ID.
Request Body:
{
"answers": [
{"questionId": "question_id_1", "selectedOptionId": 1},
{"questionId": "question_id_2", "selectedOptionId": 2}
]
}
- Get all users.
- Get a user by ID.
- Update a user by ID.
Request Body:
{
"email": "new_email@example.com",
"password": "new_securepassword",
"role": "admin"
}
View the API documentation on Postman here.
-
Clone the repo:
git clone https://github.com/Hamed-Hasan/Quiz-management-backend.git
-
Install dependencies:
npm install
-
Configure PostgreSQL and Prisma:
- Set up a PostgreSQL database.
- Configure the connection details in the Prisma configuration file (
prisma/schema.prisma
).
-
Run the app seamlessly:
npm start
- Admins log in to effortlessly manage quizzes.
- Performers sign up or log in for a seamless quiz-taking experience.
- Create, manage, and partake in quizzes with ease.
- Fork the repository.
- Develop your feature in a dedicated branch.
- Submit a pull request for seamless integration.
MIT License - Details
Feel free to open issues for feedback or contribute to enhancing the quiz experience. Happy quizzing! π§ β¨