Git Product home page Git Product logo

basharkhan6 / web_quiz_engine Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 45 KB

This is a JetBrains Academy Project. Where I develop a multi-user web service for creating and solving quizzes using REST API, an embedded database, security, and other technologies. This is a server side ("engine") without a user interface at all.

License: MIT License

Java 100.00%
rest-api spring-boot h2 spring-boot-security

web_quiz_engine's Introduction

Web Quiz Engine


Java Spring

official JetBrains project Build Status Website cv.lbesson.qc.to MIT license

This is a JetBrains Academy Project. Where I develop a multi-user web service for creating and solving quizzes using REST API, an embedded database, security, and other technologies. This is a server side ("engine") without a user interface at all.

Usage

Register a user

To register a new user, the client needs to send a JSON with email and password via POST request to /api/register:

{
  "email": "[email protected]",
  "password": "secret"
}

*The service returns 200 (OK) status code if the registration has been completed successfully.

*If the email is already taken by another user, the service will return the 400 (Bad request) status code.

Accessing Service

*User need to pass Basic Authorization header containing email and password to access any service.

Create a new quiz

To create a new quiz, the client needs to send a JSON as the request's body via POST to /api/quizzes.

The JSON should contain the four fields:

  • title a string, required;
  • text a string, required;
  • options an array of strings, required, should contain at least 2 items;
  • answer integer index of the correct option, optional, since all options can be wrong.

Here is a new JSON quiz as an example:

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

*The answer equals [0,2] corresponds to the first and the third item from the options array ("Americano" and "Cappuccino"). The server response is a JSON with four fields: id, title, text and options. Here is an example:

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

*If the request JSON does not contain title or text, or they are empty strings (""), then the server should respond with the 400 (Bad request) status code. If the number of options in the quiz is less than 2, the server returns the same status code.

Get a quiz by id

To get a quiz by id, the client sends the GET request to /api/quizzes/{id}. Here is a response example:

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

*If the specified quiz does not exist, the server should return the 404 (Not found) status code.

Get all quizzes

To get all existing quizzes in the service, the client sends the GET request to /api/quizzes. The response contains a JSON array of quizzes like the following:

[
  {
    "id": 1,
    "title": "The Java Logo",
    "text": "What is depicted on the Java logo?",
    "options": ["Robot","Tea leaf","Cup of coffee","Bug"]
  },
  {
    "id": 2,
    "title": "The Ultimate Question",
    "text": "What is the answer to the Ultimate Question of Life, the Universe and Everything?",
    "options": ["Everything goes right","42","2+2=4","11011100"]
  }
]

*If there are no quizzes, the service returns an empty JSON array: [].

*In both cases, the status code is 200 (OK).

*The API should support the navigation through pages by passing the page parameter ( /api/quizzes?page=1).

Solve a quiz

To solve a quiz, the client sends the POST request to /api/quizzes/{id}/ solve with a JSON that contains the indexes of all chosen options as the answer. This looks like a regular JSON object with key "answer" and value as the array: Example: {"answer": [0,2]}. *Indexes start from 0.

It is also possible to send an empty array [] since some quizzes may not have correct options. The service returns a JSON with two fields: success (true or false) and feedback (just a string). There are three possible responses.

1. If the passed answer is correct: {"success":true,"feedback":"Congratulations, you're right!"}

2. If the answer is incorrect: {"success":false,"feedback":"Wrong answer! Please, try again."}

3. If the specified quiz does not exist, the server returns the 404 (Not found) status code.

Delete a quiz

A user can delete their quiz by sending the DELETE request to /api/quizzes/{id}.

*If the operation was successful, the service returns the 204 (No content) status code without any content.

*If the specified quiz does not exist, the server returns 404 (Not found).

*If the specified user is not the author of this quiz, the response is the 403 (Forbidden) status code.

Get all completions of quizzes

To getting all completions of quizzes for a specified user by sending the GET request to /api/quizzes/completed together with the user auth data.

Technologies

Here I use Spring Boot freamework of Java.

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Ask Me Anything !

Abul Basar - @basharkhan6 - [email protected]

Project Link: https://github.com/basharkhan6/Web_Quiz_Engine

Linkedin Stackoverflow

web_quiz_engine's People

Contributors

basharkhan6 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.