Skip to content

GET api questions type

Kherld edited this page Sep 11, 2023 · 2 revisions

Filter Questions by Type

This endpoint allows you to filter quiz questions by their type.

Endpoint URL

GET http://localhost:8081/api/questions/type

Query Parameters

  • question_type (string, optional): Specifies the type of questions to filter by. Supported types include:
    • multiple-choice: Multiple choice questions.
    • true-false: True or false questions.
    • short-answer: Short answer questions.
    • fill-in-the-blanks: Fill the blank questions.

Responses

  • 200 OK: Returns a list of quiz questions that match the specified type.

Example Response:

  • Here is an example of a question object:

    [
      {
        "id": 1,
        "question": "What is the greatest worship?",
        "question_type": "multiple-choice",
        "answers": ["the prayer", "Zakat", "unification. -- Tawheed"],
        "correct_answer": "unification. -- Tawheed",
        "event_month": "null"
      },
      // ... (more questions)
    ]
    
  • 400 Bad Request: If the provided question_type parameter is missing or invalid.

  • 404 Not Found: If there are no questions available for the specified type.

  • 500 Internal Server Error: If there's an issue with retrieving the questions from the server.

Example Usage

Request: GET /api/questions/type?question_type=multiple-choice

Retrieves quiz questions of the "multiple-choice" type.

Request: GET /api/questions/type?question_type=true-false

Retrieves quiz questions of the "true-false" type.