Skip to content

lnderjeet29/Quiz-Backend-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quiz Backend - REST API Controllers

Welcome to Quiz Backend, a backend service built using Spring Boot with Java, designed to manage quiz sessions, questions, and user performance. This repository contains the REST controllers for managing the core application features like quiz management and performance tracking.


🚀 Features

  • Quiz session management with total questions and correct answers tracking.
  • Question management including creation, retrieval, and random selection.
  • Performance tracking with the ability to submit answers and calculate correct answers.
  • Standardized error handling with meaningful response messages.

📂 API Endpoints

1. Start Quiz

Starts a new quiz session for the user.

Endpoint:

  • POST /api/quiz/start
    Starts a new quiz session.
    • Request Parameter: userId - The ID of the user starting the quiz.
    • Response:
      • 200 OK: Returns the quizSessionId for the session.

2. Get Quiz Questions

Fetches a shuffled list of questions for the specified session.

Endpoint:

  • GET /api/quiz/questions
    Retrieves a list of random quiz questions for a session.
    • Request Parameter: sessionId - The ID of the quiz session to fetch questions for.
    • Response:
      • 200 OK: Returns a list of shuffled questions.
      • 404 Not Found: If the session is invalid or not found.

Response of Random Question list API

3. Submit Answer

Submits an answer for a specific question in the quiz session.

Endpoint:

  • POST /api/quiz/answer
    Submits the selected answer for a quiz question.
    • Request Parameters:
      • quizSessionId - The ID of the quiz session.
      • questionId - The ID of the question being answered.
      • selectedOption - The option selected by the user (e.g., "a", "b", "c", or "d").
    • Response:
      • 204 No Content: Successfully submitted the answer.

4. Get User Performance

Fetches the performance details for a specific quiz session, including the number of correct answers and total questions.

Endpoint:

  • GET /api/quiz/performance
    Retrieves the performance details for a user’s quiz session.
    • Request Parameter: quizSessionId - The ID of the quiz session for which the performance is requested.
    • Response:
      • 200 OK: Returns the performance data including the number of correct answers and total questions answered.

Response of Performance API


Using H2 DB

💬 Contact

Feel free to reach out for any questions or contributions:

About

A backend service for Quiz App

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages