Welcome to the QuizMasterAPI, a simple Node.js-based quiz application that allows users to register, login, take quizzes, view their quiz history and compare to others in the leaderboard. Additionally, administrators can register, login, add quizzes, and view the leaderboard. This documentation provides an overview of the project structure, functionality, and usage.
This project is developed by our team, XtraDrill, for the Software Project Lab (SWE 4304) during the 3rd semester at the Islamic University of Technology. It represents one of the initial projects undertaken by our team during the early stages of our academic journey.
The QuizMasterAPI adopts the Model-View-Controller (MVC) design pattern, a widely employed architectural principle in software development. This pattern partitions the application into three cohesive elements:
Model: Manages data handling and encapsulates the core business logic of the application.
View: Concerned with the presentation layer and the user interface, ensuring that data is displayed appropriately to users.
Controller: Acts as an intermediary, processing user inputs, modifying the model as necessary, and updating the view accordingly.
-
Model:
- adminModel.js, quizModel.js, userModel.js
-
View:
- adminView.js, quizView.js, userView.js
-
Controller:
- adminController.js, userController.js
-
Database:
- admins.json, users.json, chemistry.json, english.json, math.json, physics.json, quiz.json, leaderboard.json, mistakes.json
-
Others:
- node_modules (dependencies folder), package-lock.json, package.json, server.js
Before you begin, make sure you have the following installed on your machine:
-
Node.js: The QuizMasterAPI is built using Node.js. Download and install it from https://nodejs.org/.
-
Git: You'll need Git to clone the repository. Install it from https://git-scm.com/.
Open your terminal (Command Prompt, PowerShell, or Terminal) and run the following command to clone the repository to your local machine:
git clone https://github.com/codenim34/QuizMasterApi.git
Move into the project directory using the cd
command:
cd QuizMasterApi
Use npm (Node Package Manager) to install the required dependencies:
npm install
Run the following command to start the QuizMasterAPI server:
npm start
This command will launch the server, and you should see output indicating that the server is running.
You can access the API at http://localhost:3000
by default. Open your web browser and navigate to http://localhost:3000 to interact with the QuizMasterAPI.
While you can use any text editor for working with Node.js projects, here are some popular Integrated Development Environments (IDEs) that you might find useful:
-
Visual Studio Code (VSCode): Download and install from https://code.visualstudio.com/.
-
Atom: Download and install from https://atom.io/.
-
WebStorm: A powerful IDE for JavaScript, you can find it at https://www.jetbrains.com/webstorm/.
You can test the endpoints with this Postman Collection: QuizMasterAPI-Postman-Collection.
To register a new user, send a POST request to /register
with the user's information in the request body.
To log in as a user, send a POST request to /login
with the user's credentials in the request body. Successful login returns an access token.
- Get 10 random quizzes: Send a GET request to
/user/takeQuiz
. - Get 10 random quizzes for a specific subject (e.g., physics): Send a GET request to
/user/takeQuiz/physics
. - Submit Quiz: Send a POST request to
/user/submitQuiz
with the user's quiz responses.
To view randomly fetched mistaken questions, send a GET request to /user/mistakes
.
To view the quiz history, send a GET request to /user/quizhistory
.
To view the leaderboard, send a GET request to /leaderboard
.
To register a new admin, send a POST request to /admin/register
with the admin's information in the request body.
To log in as an admin, send a POST request to /admin/login
with the admin's credentials in the request body. Successful login returns an access token.
To add a quiz for a specific subject (e.g., physics), send a POST request to /admin/addQuiz/physics
with the quiz details in the request body. Admin authentication is required.
To view the leaderboard, send a GET request to /leaderboard
.
-
User Endpoints:
POST /register
: User registration.POST /login
: User login.GET /user/takeQuiz
: Get 10 random quizzes.GET /user/takeQuiz/{subject}
: Get 10 random quizzes for a specific subject.POST /user/submitQuiz
: Submit a quiz.GET /user/mistakes
: View mistaken questions.GET /user/quizhistory
: View quiz history.GET /leaderboard
: View the leaderboard.
-
Admin Endpoints:
POST /admin/register
: Admin registration.POST /admin/login
: Admin login.POST /admin/addQuiz/{subject}
: Add a quiz for a specific subject.GET /leaderboard
: View the leaderboard.
The QuizMasterAPI project is developed and maintained by @codenim34, @takitajwar17 & @imtiaz-risat.