Docs home

MCQ - Single Correct Answer Create Question

Creates a single-correct multiple-choice question in a question bank. Use this to load your own question bank before attaching it to a test or exercise. All question types use this same endpoint; only `input_type` and `options` change.

POST/questions
MCQ - Single Correct Answer Create Question
curl --request POST \
  --url 'https://<your-api-host>/nuSource/api/v1/questions' \
  --header 'APIKEY: <your-api-key>' \
  --header 'ORGID: <your-org-id>' \
  --form 'JSONString={"question_list_id":12,"question_JSON":[" "],"input_JSON":[{"input_type":0,"question_string":"<p>dwemo&nbsp;&nbsp;&nbsp;&nbsp;</p>","options":[{"index":0,"option_string":"<p>e</p>","is_correct":true},{"index":1,"option_string":"<p>e</p>"},{"index":2,"option_string":"<p>t</p>"},{"index":3,"option_string":"<p>3</p>"}],"marks":"1.00","neg_mark":0,"hint":"","explanation":"","opposite_marking":0}],"sound_play_times":-1,"difficulty":1}'
{
  "code": 200,
  "message": "Question Created",
  "question": {
    "question_id": 1504,
    "question_JSON": "[\" \"]",
    "input_JSON": "[{\"input_type\":0,\"question_string\":\"<p>dwemo&nbsp;&nbsp;&nbsp;&nbsp;<\\/p>\",\"options\":[{\"index\":0,\"option_string\":\"<p>e<\\/p>\",\"is_correct\":true},{\"index\":1,\"option_string\":\"<p>e<\\/p>\"},{\"index\":2,\"option_string\":\"<p>t<\\/p>\"},{\"index\":3,\"option_string\":\"<p>3<\\/p>\"}],\"marks\":\"1.00\",\"neg_mark\":0,\"hint\":\"\",\"explanation\":\"\",\"opposite_marking\":0}]",
    "answer_JSON": "[{\"answer\":[[0]],\"explanation\":\"\"}]",
    "question_list_id": 12,
    "sound_asset": ""
  }
}

Example input_JSON for this type: [{"input_type": 0, "question_string": "<p>Capital of India?</p>", "options": [{"index": 0, "option_string": "<p>Delhi</p>", "is_correct": true}, {"index": 1, "option_string": "<p>Mumbai</p>"}], "marks": 1, "neg_mark": 0}]

Access: Institute admins, admins and tutors, plus custom roles with question bank or curriculum manage permission.

Request body: form-data with one field, JSONString, containing this JSON:

BodyJSONString
question_list_idintegerrequired
Question bank to add the question to. Must be a bank you created or one shared with your organization.
question_JSONarrayrequired
Common text shown with the question, as a one-item array of HTML (for example a passage). Send [" "] if not needed.
input_JSONarrayrequired
The question itself: one object per input (fields below). Most questions have one.
difficultyinteger
1 Easy, 2 Medium, 3 Hard. Defaults to the bank's difficulty.
Topic tag. Defaults to the bank's topic.
Sub-topic tag. Default 1.
Values for your institute's question custom fields: objects with custom_field_id and field_value. Unknown field IDs and empty values are ignored.
Audio attached to the question. Purpose of the exact format unclear from code.
How many times the audio can be played. Default -1 (no limit).
Video attached to the question. Format unclear from code.
Image attached to the question. Format unclear from code.
1 marks the question as AI-generated. Default 0.

Fields in each input_JSON object:

Name Required Type Description
input_type Yes integer 0 Single correct, 1 Multiple correct, 2 Fill in the blanks, 3 English transcription, 4 Multiple inputs, 5 Subjective, 6 True/False, 7 Psychological (1 to 5 scale).
question_string Yes string Question text, HTML allowed. Cannot be empty.
options Yes array Answer options; shape depends on input_type (see Notes).
marks No number Marks for a correct answer. Must be 0 or more. Default 1. Rounded to 2 decimals.
neg_mark No number Marks deducted for a wrong answer, e.g. -0.25. Default 0.
hint No string Hint shown to the learner, HTML allowed.
explanation No string Explanation of the answer, HTML allowed. Stored with the answer key.
opposite_marking No integer Purpose unclear from code; the app sends 0.
Response200application/json
codeinteger
Example: 200
messagestring
Example: Question Created
questionobject
Show child attributesHide child attributes
The new question
Example: 1504
Example: [" "]
Both as JSON-encoded strings
The answer key the server built from your options, as a JSON string
Example: [{"answer":[[0]],"explanation":""}]
Example: 12

Notes:

  • Options by type. Single correct (0), Multiple correct (1) and True/False (6): an array of { "index": 0, "option_string": "<p>…</p>", "is_correct": true }, at least 2 options, every option_string non-empty, and at least one marked is_correct. Fill in the blanks (2): one array of accepted answers per blank, e.g. [["Delhi", "New Delhi"]]. Subjective (5): [[]].
  • The is_correct flags are moved out of the options into the answer key, so learners never receive them.
  • Errors: "Invalid question format." when the text or options fail the checks above; "You do not have permission to access this question bank" when the bank is not yours; "The marks should be numeric." / "The marks should be a positive number."
  • Rate limit: 30 requests per minute; going over locks you out for 30 minutes.

Updated yesterday

Ask AI