POST /api/v1/exam/{id}/add-question

Add a new question (structured or unstructured) to an existing exam. Only admins and lecturers can add questions.

Path parameters

  • id string Required

    UUID of the exam

application/json

Body Required

Question data including type, text, options, and scoring

  • question string Required
  • type string Required

    Values are STRUCTURED or UNSTRUCTURED.

  • options array[string]
  • correctAnswers array[string]
  • maxScore number Required

Responses

  • 201 application/json

    Question added successfully

  • 400

    Invalid question data

  • 404

    Exam not found

POST /api/v1/exam/{id}/add-question
curl \
 --request POST 'http://localhost:3500/api/v1/exam/123e4567-e89b-12d3-a456-426614174000/add-question' \
 --header "Content-Type: application/json" \
 --data '{"options":["O(n)","O(log n)","O(n log n)","O(1)"],"maxScore":5,"orderIndex":1,"questionText":"What is the time complexity of binary search?","questionType":"STRUCTURED","correctAnswers":["O(log n)"]}'
Request examples
{
  "options": [
    "O(n)",
    "O(log n)",
    "O(n log n)",
    "O(1)"
  ],
  "maxScore": 5,
  "orderIndex": 1,
  "questionText": "What is the time complexity of binary search?",
  "questionType": "STRUCTURED",
  "correctAnswers": [
    "O(log n)"
  ]
}
{
  "maxScore": 10,
  "orderIndex": 2,
  "questionText": "Explain the difference between a stack and a queue with examples.",
  "questionType": "UNSTRUCTURED"
}
Response examples (201)
{
  "message": "Question added successfully",
  "question": {
    "id": "q123-456",
    "maxScore": 5,
    "questionText": "What is the time complexity of binary search?",
    "questionType": "STRUCTURED"
  }
}