Implemented a simple RESTful API that simulates basic backend functionality for a quiz application.
This Quiz API contains 3 entities: Quiz
, Question
, and Answer
. Each have an auto-generated numerical primary key. The Quiz
entity has a name and maintains a collection of Question
entities that are part of the the Quiz
using an @OneToMany
annotation, provided by JPA, to denote the relationship between the two tables in the database. The Question
entity has a text field, the Quiz
that it belongs to annotated with @ManyToOne
representing the opposite side of the relationship stored in the Quiz
class, and a collection of Answer
objects annotated with @OneToMany
. Finally, the Answer
entity also has a text field, a boolean to denote if the given Answer
is the correct one for the Question
it belongs to, and the Question
object that it belongs to annotated with @ManyToOne
.
An entity relationship diagram is provided below that represents the database used by the Quiz API:
Created the following endpoints and implemented their functionality in the Controller, Service, and Repositories.
-
GET quiz
- Returns the collection of
Quiz
elements
- Returns the collection of
-
POST quiz
Creates a quiz and adds to collection- Returns the
Quiz
that it created
- Returns the
-
DELETE quiz/{id}
Deletes the specified quiz from collection- Returns the deleted
Quiz
- Returns the deleted
-
PATCH quiz/{id}/rename/{newName}
Rename the specified quiz using the new name given- Returns the renamed
Quiz
- Returns the renamed
-
GET quiz/{id}/random
- Returns a random
Question
from the specified quiz
- Returns a random
-
PATCH quiz/{id}/add
Adds a question to the specified quiz- Receives a
Question
- Returns the modified
Quiz
- Receives a
-
DELETE quiz/{id}/delete/{questionID}
Deletes the specified question from the specified quiz- Returns the deleted
Question
- Returns the deleted