nazim9873 / Quiz-API

The API should have the following endpoints: POST /quizzes - to create a new quiz GET /quizzes/active - to retrieve the active quiz (the quiz that is currently within its start and end time) GET /quizzes/:id/result - to retrieve the result of a quiz by its ID GET /quizzes/all - to retrieve the all quizes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Quiz-API

API Endpoints:

  • POST /quizzes - to create a new quiz

example: (body) {

"question" : "What is the capital of India?",
"option" : ["New Delhi", "Rajasthan", "Uttarakhand", "Goa"],
"right_answer" : 0,
"start_date" : "29/5/2023 18:56:33",
"end_date" : "30/5/2023 00:40:33"

}

  • GET /quizzes/active - to retrieve the active quiz (the quiz that is currently within its start and end time)
  • GET /quizzes/:id/result - to retrieve the result of a quiz by its ID
  • GET /quizzes/all - to retrieve the all quizes

Functionalities:

* status is changed using cron job every minute

* rate-limiting to prevent abuse of the API is done using throttling (2 or 3 requests per minute)

* filesystem caching is done (every 5 minutes) to reduce the response time of frequently accessed data

Create a Quiz: Users is able to create a quiz by sending a POST request to the API with the following fields:

  • question: the text of the question
  • options: an array of the answer options for the question
  • rightAnswer: the index of the correct answer in the options array
  • startDate: the date and time when the quiz should start
  • endDate: the date and time when the quiz should end

Get Active Quiz: Users is able to retrieve the active quiz (the quiz that is currently within its start and end time).

Get Quiz Result: After the 5 minute of end time of a quiz, users is able to retrieve the result of the quiz. The result is basically the right answer

About

The API should have the following endpoints: POST /quizzes - to create a new quiz GET /quizzes/active - to retrieve the active quiz (the quiz that is currently within its start and end time) GET /quizzes/:id/result - to retrieve the result of a quiz by its ID GET /quizzes/all - to retrieve the all quizes