Skip to content

GET api questions random

Kherld edited this page Sep 11, 2023 · 2 revisions

Get Random Questions

This endpoint allows you to retrieve random quiz questions.

Endpoint URL

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

Query Parameters

  • limit (integer, optional): Specifies the maximum number of random questions to retrieve. Defaults to no limit.

Responses

  • 200 OK: Returns a list of random quiz questions.

    Example Response:

    [
      {
        "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 limit parameter is invalid.
  • 404 Not Found: If there are no random questions available.
  • 500 Internal Server Error: If there's an issue with retrieving the random questions from the server

Example Usage

Request: GET /api/questions/random?limit=5

Retrieves 5 random quiz questions.

Request: GET /api/questions/random

Retrieves random quiz questions without a specified limit.

Notes

  • The limit parameter is optional and allows you to specify the maximum number of random questions to retrieve. If not provided, all available random questions will be returned.
  • This endpoint provides a way to get random questions from the quiz question pool.