-
Notifications
You must be signed in to change notification settings - Fork 1
GET api questions
Kherld edited this page Sep 11, 2023
·
2 revisions
This endpoint allows you to retrieve a list of quiz questions. You can either retrieve all questions or paginate through them to limit the number of results per page.
http://localhost:8081/api/questions
This endpoint retrieves all questions or paginated through them.
-
page
(optional, integer): Specifies the page number of the results. Defaults to page 1 if not provided. -
limit
(optional, integer): Limits the number of questions per page. Defaults to no limit if not provided. -
items_per_page
(optional, integer): Specifies the maximum number of items to display per page. Defaults to 100 items per page if not provided. -
month
(optional, string): Filters questions by the event month. If provided, only questions related to the specified month will be returned.
200 OK
: Returns a list of quiz questions. The response includes pagination information if applicable.
The response is a JSON object with the following properties:
-
questions
: An array of questions. -
page
: The current page number. -
per_page
: The number of results per page. -
total_pages
: The total number of pages.[ { "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
: If the provided pagination parameters (page, limit, or items_per_page) are invalid -
404
: If there are no questions available based on the provided filters. -
500
Internal Server Error: If there's an issue with retrieving the questions from the server.
Request: GET /api/questions
Response: Returns all available quiz questions.
Request: GET /api/questions?page=2&limit=10
Retrieves the second page of quiz questions with a limit of 10 questions per page.
Request: GET /api/questions?month=Muharram
Retrieves quiz questions related to the event month of Muharram.