Skip to content

A quiz app with admin privileges using node js and mongodb. Here admin can be able to create a quiz with various instructions regarding the quiz, questions, answers, explanations and duration for the quiz. At any point of time admin can update, delete, enable or disable any quiz or question

nithintata/quiz-app-in-nodejs

Repository files navigation

Quiz App

A quiz app with admin privileges working on node js and mongodb

Problem Statement


Create a quiz app for an educational institute where they can do following.

Admin should be able to create quiz with various instructions regarding the quiz, questions, answers, explanations and duration for the quiz.

At any point of time admin can enable or disable the quiz itself.

At any point of time admin can enable or disable any question.

At any point of time admin can add, remove or edit the question for an existing quiz.

Apart from the admin rest of the users can only see the quiz and questions.

Implementation


1. The database schema for the above problem statement is located at models/quizes.js file

2. There are four different REST api's for performing various operations

  • localhost:3000/quizes --> for getting list of all quizes, creating a quiz, Removing all quizes
  • localhost:3000/quizes/:quizId --> for getting details of a quiz, updating content of a quiz, deleting a quiz
  • localhost:3000/quizes/:quizId/questions --> for getting questions of a quiz, adding a question, deleting all questions from quiz
  • localhost:3000/quizes/:quizId/questions/:questionId --> getting a question, updating a question, deleting a question

3. The implementation of these end points can be found in routes/quizRouter.js file.

4. All the Post, Put, Delete operations needs to be authorized by providing username and password (username: admin, Password: password). This means only admin can create, update or delete a quiz/question

5. The implementation of authorization step can be found in authenticate.js file in the root folder

6. Cookies are implemented to avoid the need of repeated authorization for admin

7. The user can only see the questions/quizes that are enabled by the admin. This is implemented by filtering the retrieved content from database by respective queries.

Deployment steps


  • Clone the entire repository to a new folder on desktop
  • Open the command prompt from the same folder and type npm install. This will download all the required dependencies which are present in package.json file
  • Now open the mongodb terminal and create a new database named quiz. All the quizes and questions will be stored here.
  • All the logs will be stored in logs/app.log file
  • For doing unit tests type the command npm run test. This will do the unit tests on different end points for sanity checking.
  • To start the server enter the command npm start

About

A quiz app with admin privileges using node js and mongodb. Here admin can be able to create a quiz with various instructions regarding the quiz, questions, answers, explanations and duration for the quiz. At any point of time admin can update, delete, enable or disable any quiz or question

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published