The WhoAreYou Quiz App is a web application that allows users to create and take quizzes.
- Spring Boot
- Spring Data JPA
- Spring Web
- Postgresql
- Clone the repository:
git clone https://github.com/AanisN10/Backend_Project_API- Navigate to the project directory
cd WhoAreYou- Ensure you have Java, Maven and PostgreSQL installed and running. Create the database:
createdb WhoAreYou- Build the project
mvn clean install- Start the application
mvn spring-boot:run- Access the application at https://localhost:8080
-
Randomize Quiz
- Method:
POST - URL:
localhost:8080/quizzes/random?userName=UserA&numberOfQuestions=3 - Created a quiz randomized with 3 questions for user UserA.
- Method:
-
Start quiz
- Method:
GET - URL:
localhost:8080/quizzes/startQuiz/2 - this will start the quiz with id 2.
- Method:
-
Display Question
- Method:
GET - URL:
localhost:8080/quizzes/displayQuestion/quizId/0 - this will display the first question of the quiz
- Method:
-
User answer to quiz
- Method:
POST - URL:
localhost:8080/quizzes/takeQuiz/2 - this allows the user to answer the first question of the quiz, continue until questions have been answered.
- Example:
{ "questionNumber": 0, "userAnswer": "B" }
- Method:
-
Finish Quiz
- Method:
GET - URL:
localhost:8080/quizzes/finishQuiz/2 - this will end quiz 2
- Method:
-
Check quiz
- Method:
GET - URL:
localhost:8080/quizzes/2 - this will show all the questions as well as the users response, the user would be allowed to change the answers to previous responses if the quiz is not finished.
- Method:
-
Display result
- Method:
GET - URL:
localhost:8080/quizzes/quizId/result?trainerName=Thibyaa - This will display the user's score for that given trainer and that trainer's bio.
- Method:
-
Display total
- Method:
GET - URL:
localhost:8080/quizzes/allResults?trainerName=Anna - This will display the accumulated scores for all finished quizzes for a specific trainer
- Method:
-
Display all quizzes for user
- Method:
GET - URL:
localhost:8080/quizzes/allQuizzes?userName=UserA - This will display the quizzes associated with UserA, can be used to allow the user to resume a quiz or look at completed ones
- Method:
-
Get All Questions:
- Method:
GET - URL:
/questions
- Method:
-
Get Question by ID:
- Method:
GET - URL:
/questions/{id}
- Method:
-
Create New Question:
- Method:
POST - URL:
/questions - Request Body: JSON with question details
- Example:
{ "question": "If you could be a biscuit, which one would you be and why?", "zsoltAnswer": "D", "annaAnswer": "A", "colinAnswer": "B", "thibyaaAnswer": "C", "optionA": "Hobnob (not chocolate, original only!)", "optionB": "Ginger Nut - A good all-rounder", "optionC": "Viennese w/Chocolate - I have no reason, I was just eating them the day before", "optionD": "Wagon wheels - crunchy on the outside, soft on the inside", "quizIds": [1] }
- Method:
-
Update Question by ID:
- Method:
PATCH - URL:
questions/{id} - Request Body: JSON with question details
- Method:
-
Delete Question by ID:
- Method:
DELETE - URL:
/questions/{id}
- Method:
-
Get All Quizzes:
- Method:
GET - URL:
/quizzes
- Method:
-
Get Quiz by ID:
- Method:
GET - URL:
/quizzes/{id}
- Method:
-
Delete Quiz by ID:
- Method:
DELETE - URL:
/quizzes/{id}
- Method:
-
Add Question To Quiz by ID:
- Method:
POST - URL:
quizzes/{id} - Request Body: JSON with question details
- Example:
{ "questionIds": [1, 10] } - Method:
-
Remove Question From Quiz by ID:
- Method:
POST - URL:
quizzes/removeQuestion/{id} - Request Body: JSON with question details
- Example:
{ "questionIds": [1, 10] } - Method:
-
Start Quiz by ID:
- Method:
GET - URL:
quizzes/startQuiz/{id}
- Method:
-
Get Random Quiz:
- Method:
POST - URL:
localhost:8080/quizzes/random?userName={}&numberOfQuestions={}
- Method:
-
Get All Quizzes for User:
- Method:
GET - URL:
localhost:8080/quizzes/allQuizzes?userName=
- Method:
-
Answer a Question in a Quiz by Quiz ID:
- Method:
POST - URL:
quizzes/takeQuiz/{quizID} - Request Body: JSON with question ID and user answer details
- Example:
{ "questionNumber": 1, "userAnswer": "B" } - Method:
-
Finish Quiz by Quiz ID:
- Method:
GET - URL:
quizzes/finishQuiz/{quizId}
- Method:
-
Get Trainer Result by Quiz ID:
- Method:
GET - URL:
quizzes/{quizId}/result
- Method:
-
Get Question By Question Number
- Method:
GET - URL:
quizzes/{quizID}/questionNumber
- Method:
-
Get Total Result by Trainer
- Method:
GET - URL:
quizzes/allResults
- Method:
-
The MVP includes basic CRUD operations for quizzes and questions.
- Add quiz questions
- Display all quiz questions
- Return a list of quiz questions with a shared property (provide “a quiz”)
- Implement this firstly as a hard-coded route and then in relation to a Quiz object
- Update a quiz question
- Delete a quiz question
- Provide a result/score based on the answers
-
Extensions include features like
- Starting a quiz
- Creating a random quiz
- Submitting answers
- Can change responses until submission