Skip to content

San-43/Web-Quiz-Engine-with-Java-and-Spring-Boot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Web Quiz Engine (Java + Spring Boot)

Backend project for managing quizzes through a REST API.
It supports user registration, quiz creation, solving quizzes, and paginated quiz retrieval.

This repository is meant to be a clean, practical Spring Boot project that can be extended over time.

What it does

  • User registration
  • Authentication
  • Quiz creation
  • Paginated quiz listing
  • Quiz retrieval by ID
  • Quiz solving with immediate feedback
  • Database persistence

Tech stack

  • Java
  • Spring Boot
  • Spring Web
  • Spring Data JPA
  • Spring Security
  • Bean Validation
  • H2 / PostgreSQL (depending on configuration)
  • Gradle or Maven

Getting started

Requirements

  • Java 17+
  • Git
  • Gradle or Maven

Clone the repository

git clone https://github.com/San-43/Web-Quiz-Engine-with-Java-and-Spring-Boot.git
cd Web-Quiz-Engine-with-Java-and-Spring-Boot

Configure the database

Edit src/main/resources/application.properties.

Example using H2:

spring.datasource.url=jdbc:h2:file:./quizdb
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.hibernate.ddl-auto=update
spring.h2.console.enabled=true

Example using PostgreSQL:

spring.datasource.url=jdbc:postgresql://localhost:5432/quizdb
spring.datasource.username=postgres
spring.datasource.password=your_password
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect

Run the application

With Gradle:

./gradlew bootRun

With Maven:

./mvnw spring-boot:run

Default address:

http://localhost:8889

API overview

Auth

POST /api/register

{
  "email": "user@example.com",
  "password": "strongPassword123"
}

Quizzes

POST /api/quizzes
Create a quiz

{
  "title": "The Java Logo",
  "text": "What is depicted on the Java logo?",
  "options": ["Robot", "Tea leaf", "Cup of coffee", "Bug"],
  "answer": [2]
}

GET /api/quizzes?page={number}
Get paginated quizzes

GET /api/quizzes/{id}
Get quiz details by ID

GET /api/quizzes/completed?page={number}
Get paginated completed quizzes by the authenticated user

POST /api/quizzes/{id}/solve
Submit an answer

{
  "answer": [2]
}

Correct answer response:

{
  "success": true,
  "feedback": "Congratulations, you're right!"
}

Wrong answer response:

{
  "success": false,
  "feedback": "Wrong answer! Please, try again."
}

DELETE /api/quizzes/{id}
Delete a quiz by its id. The authenticated user must be the author of the target quiz.

Validation notes (typical)

  • title and text: must not be blank
  • options: at least 2 options
  • answer: optional (can default to an empty list)
  • email: valid format
  • password: minimum length defined in the project

Running tests

With Gradle:

./gradlew test

With Maven:

./mvnw test

Acknowledgment

Thanks to Hyperskill for the learning path and project structure that inspired this implementation.

Project page: https://hyperskill.org/projects/91

Contributing

Contributions are welcome.

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Open a pull request

If this project helped you, consider leaving a ⭐.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages