I'm using Django Rest Framework for the following task (I'll write it in detail so that everything is clear):
- The service must implement a REST API that accepts POST requests as input with content like {"questions_num": integer} .
This item is done.
- After receiving the request, the service, in turn, requests the number of questions specified in the received request from the public API (English questions for quizzes) https://jservice.io/api/random?count=questions_num.
This is also done.
- Further, the received answers should be stored in the database (or Postgres or Sqlite) fields from the quiz: 1. Question ID, 2. Question text, 3. Answer text, 4. - Question creation date.
This is also done.
- And it's not clear how to normally do the following moment:
In the event that the database has the same question, additional requests must be made to the public API with quizzes until a unique question for the quiz is obtained.
It turned out to be a crutch, but I would like it to be beautiful, or at least normal.
Tell me how to implement this?
Thanks in advance.