Skip to content

chkarthik1729/WebQuizEngine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JetBrains Academy's Web Quiz Engine

Stage #6: Advanced queries

Description

At this last stage, your service will be improved to perform some trickier requests and return paginated responses. From the client's point of view, only a small part of API will be changed here.

Here are two articles worth reading before we begin:

Get all quizzes with paging (MODIFIED)

To get all existing quizzes in the service, the client sends the GET request to /api/quizzes as before. But here is the problem: the number of stored quizzes can be very large since your service is so popular among so many users.

In this regard, your API should return only 10 quizzes at once and supports the ability to specify which portion of quizzes is needed.

Please, use the standard libraries for the pagination.

The response contains a JSON with quizzes (inside content) and some additional metadata:

{
  "totalPages":1,
  "totalElements":3,
  "last":true,
  "first":true,
  "sort":{ },
  "number":0,
  "numberOfElements":3,
  "size":10,
  "empty":false,
  "pageable": { },
  "content":[
    {"id":102,"title":"Test 1","text":"Text 1","options":["a","b","c"]},
    {"id":103,"title":"Test 2","text":"Text 2","options":["a", "b", "c", "d"]},
    {"id":202,"title":"The Java Logo","text":"What is depicted on the Java logo?",
     "options":["Robot","Tea leaf","Cup of coffee","Bug"]}
  ]
}

We've simplified JSON a bit, but you can keep it in the same format it is generated by the framework. Our tests will validate only the essential fields.

The API should support the navigation through pages by passing the page parameter ( /api/quizzes?page=1). The first page is 0 since pages start from zero, just like our quizzes.

If there are no quizzes, content is empty []. If the user is authorized, the status code is 200 (OK); otherwise, it's 401 (Unauthorized).

Get all completions of quizzes with paging (NEW)

Your service must provide a new operation for getting all completions of quizzes for a specified user by sending the GET request to /api/quizzes/completed together with the user auth data. All the completions should be sorted from the most recent to the oldest.

A response is separated by pages since the service may return a lot of data. It contains a JSON with quizzes (inside content) and some additional metadata as in the previous operation.

Here is a response example:

{
  "totalPages":1,
  "totalElements":5,
  "last":true,
  "first":true,
  "empty":false,
  "content":[
    {"id":103,"completedAt":"2019-10-29T21:13:53.779542"},
    {"id":102,"completedAt":"2019-10-29T21:13:52.324993"},
    {"id":101,"completedAt":"2019-10-29T18:59:58.387267"},
    {"id":101,"completedAt":"2019-10-29T18:59:55.303268"},
    {"id":202,"completedAt":"2019-10-29T18:59:54.033801"}
  ]
}

Since it is allowed to solve a quiz multiple times, the response may contain duplicate quizzes, but with the different completion date.

We removed some metadata keys from the response to keep it comprehensible.

If there are no quizzes, content is empty []. If the user is authorized, the status code is 200 (OK); otherwise, it's 401 (Unauthorized).

A few words in the end

Good job! You can put this project on GitHub as an example of your work and your expertise. Just don't forget to write a clear description in the README and refer Hyperskill :) If may also be useful for you to get a code review, at least for the last stage of the project.

If you would like to continue the project, you can develop a web or mobile client for this web service.

About

A RESTful Quiz service developed using SpringBoot

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages