This project is a Quiz App API built using Spring Boot. It provides endpoints for creating quiz sessions, fetching random questions, submitting answers, and tracking quiz statistics. π
- Start a new quiz session π
- Fetch random multiple-choice questions π²
- Submit answers β β
- View statistics for correct and incorrect answers π
- Spring Boot for backend development
- H2 Database for in-memory data storage
- JPA for database interaction
- Postman for API testing
-
Start a Quiz Session
Endpoint:POST /quiz/start
Description: Starts a new quiz session. Clears previous session data. π -
Fetch a Random Question
Endpoint:GET /quiz/question
Description: Retrieves a random question that hasnβt been answered yet. π² -
Submit an Answer
Endpoint:POST /quiz/answer
Description: Submits an answer for a specific question ID. Returns whether the answer is correct or incorrect. β β -
Get Statistics
Endpoint:GET /quiz/stats
Description: Provides stats for the current quiz session, including total answered questions, correct answers, and incorrect answers. π
-
Clone the repository:
git clone https://github.com/your-repo/quiz-app-api.git
-
Navigate to the project directory:
cd quiz-app-api
-
Run the application:
./mvnw spring-boot:run
-
Access the H2 Database console:
URL:http://localhost:8080/h2-console
JDBC URL:jdbc:h2:mem:testdb
Username:sa
Password: (leave blank)
- Question Table
id
: Unique identifier for the questionquestion
: Text of the questionoptions
: List of answer choicescorrectAnswer
: Correct answer for the question
- The application seeds the database with a predefined set of questions. π
- A single user can participate in a quiz session at a time.
- No user authentication or authorization is implemented.
-
What is the size of
int
in Java?- Options:
2 bytes
,4 bytes
,8 bytes
,16 bytes
- Correct Answer:
4 bytes
- Options:
-
What is the default value of a boolean variable in Java?
- Options:
true
,false
,null
,0
- Correct Answer:
false
- Options:
This project is licensed under the MIT License. π