Skip to main content
POST
/
source
/
generateQuiz
/
{sourceId}
Generate Quiz
curl --request POST \
  --url https://api.example.com/source/generateQuiz/{sourceId} \
  --header 'Content-Type: application/json' \
  --header 'api-key: <api-key>' \
  --data '
{
  "userId": "<string>",
  "numberOfQuestions": 123,
  "difficulty": "<string>"
}
'

Description

This endpoint generates a quiz based on a previously ingested learning source. By providing the sourceId of the ingested material, you can specify the number of questions and the desired difficulty level. The API will return a quiz tailored to the content of the source, which can be used for assessment or practice purposes.

Example Request

curl -X POST \
  'https://b2b-api-backend-95487.ondigitalocean.app/source/generateQuiz/{sourceId}' \
  -H 'accept: application/json' \
  -H 'Content-Type: application/json' \
  -H 'api-key: <your-api-key>' \
  -d '{
    "userId": "user-123",
    "numberOfQuestions": 8,
    "difficulty": "medium"
  }'

Example Value (Response)

{
  "quiz": {
    "quiz_name": "Algebra Basics Quiz",
    "quiz": [
      {
        "question_text": "What is the value of x in the equation 2x + 5 = 15?",
        "options": ["2", "5", "10", "15"],
        "correct_answer_index": 1
      },
      {
        "question_text": "Which of the following is a quadratic equation?",
        "options": ["x + 2 = 0", "x² + 2x + 1 = 0", "2x = 4", "x³ = 8"],
        "correct_answer_index": 1
      }
    ],
    "quiz_id": "65f3..."
  }
}

Response Fields

  • quiz.quiz_name: Name of the generated quiz
  • quiz.quiz: Array of quiz questions
    • question_text: The question text
    • options: Array of answer options
    • correct_answer_index: Index of the correct answer (0-based)
  • quiz.quiz_id: ID of the created quiz

Authentication

api-key
string
required
Your organisation’s API key

Path Parameters

sourceId
string
required
The ID of the source to generate quiz from

Request Body

userId
string
required
User identifier
numberOfQuestions
integer
default:"5"
Number of questions to generate
difficulty
string
Difficulty level: easy, medium, or hard

Endpoint Details

  • Method: POST
  • Path: /source/generateQuiz/{sourceId}
  • Authentication: Required
  • Response Status: 200 OK

Request Parameters

  • Path:
    • sourceId: The ID of the source to generate quiz from
  • Headers:
    • api-key: <your-api-key>
  • Body:
    {
      "userId": "user-123",
      "numberOfQuestions": 8,
      "difficulty": "medium"
    }
    

Further Explanation

  • The number of questions and difficulty can be customized in the request body.
  • The response contains the generated quiz, including all questions and answer options.