Skip to content

Latest commit

 

History

History
336 lines (274 loc) · 8.08 KB

File metadata and controls

336 lines (274 loc) · 8.08 KB
description
This API is used to create Questions on the Sunbird-inQuiry Platform.

Create Question

{% swagger method="post" path="/question/v1/create" baseUrl="" summary="This API is used to create Question on the Sunbird-inQuiry Platform." expanded="true" %} {% swagger-description %} • It points to inquiry-api-service (assessment service) -

/question/v4/create

\

• It is mandatory to provide values for parameters marked with

*

.

\

• Mandatory fields cannot be null or empty.

\

• Question schema check

here

\

• Appropriate fields need to be passed to work questions functionally well. {% endswagger-description %}

{% swagger-parameter in="body" name="request" type="object" required="true" %}

request

is the representation of the resource object for creating questions, which is an object of parameters that describes the question

\

{% endswagger-parameter %}

{% swagger-parameter in="header" name="Content-Type" type="String" required="true" %} The Content-Type entity is the media type of the resource. It should be

Application/json

{% endswagger-parameter %}

{% swagger-parameter in="header" name="Authorization" type="String" required="true" %} You require authorization to make use of the API. Raise a request to the administrator for the use of the API. You will receive the authorization key. Specify the key received, here.

\

Set

Bearer {{api_key}}

{% endswagger-parameter %}

{% swagger-parameter in="header" name="x-channel-id" type="String" %} Unique identification number associated with a root organization. {% endswagger-parameter %}

{% swagger-response status="200: OK" description="The Create Question operation was successful!" %} {% code overflow="wrap" %}

{
  "id": "api.question.create",
  "ver": "3.0",
  "ts": "2021-02-02T19:28:24ZZ",
  "params": {
    "resmsgid": "8b75d237-1028-4e38-a94a-9ff4ca784d76",
    "msgid": null,
    "err": null,
    "status": "successful",
    "errmsg": null
  },
  "responseCode": "OK",
  "result": {
    "identifier": "do_11320791330308096015",
    "versionKey": "1612294104382"
  }
}

{% endcode %} {% endswagger-response %}

{% swagger-response status="400: Bad Request" description="The Create Question operation failed. You may have missed providing input for a mandatory parameter.'" %}

{
  "id": "api.question.create",
  "ver": "3.0",
  "ts": "2021-02-02T19:41:56ZZ",
  "params": {
    "resmsgid": "86481a2f-513e-4fd4-a1dd-46a7ebcb1e65",
    "msgid": null,
    "err": "CLIENT_ERROR",
    "status": "failed",
    "errmsg": "Validation Errors"
  },
  "responseCode": "CLIENT_ERROR",
  "result": {
    "messages": [
      "Metadata mimeType should be one of: [application/vnd.sunbird.question]"
    ]
  }
}

{% endswagger-response %}

{% swagger-response status="500: Internal Server Error" description="We track these errors automatically and try to set it right at the earliest. Try refreshing the page." %}

{
  "id": "api.question.create",
  "ver": "1.0",
  "ts": "2020-12-10T08:51:51.647Z",
  "params": {
    "resmsgid": "f234a6f0-3ac4-11eb-b0a2-8d5c9f561887",
    "msgid": null,
    "status": "failed",
    "err": null,
    "errmsg": null
  },
  "responseCode": "SERVER_ERROR",
  "result": {}
}

{% endswagger-response %} {% endswagger %}

Sample Request

{
    "request": {
        "question": {
            "name": "string",
            "code": "string",
            "mimeType": "string",
            "primaryCategory": "string"
        }
    }

Request Schema

Attribute Type Description Required
name String Represents the name of the question Yes
code String Represents the unique code for the question Yes
mimeType String Question mime type Yes
primaryCategory String PrimaryCategory agains which question schema will be validated Yes

Success Result Schema

Attribute Type Description
identifier String Unique Question Identifier
versionKey String Unique version key of Question

cURL:

curl --location -g --request POST '{{host}}/question/v1/create' \
--header 'Content-Type: application/json' \
--header 'X-Channel-Id: {{channel_id}}' \
--header 'Authorization: Bearer {{api_key}}' \
--data-raw '{
    "request": {
        "question": {
            "name": "Question 1",
            "code": "question.code",
            "mimeType": "application/vnd.sunbird.question",
            "primaryCategory": "Subjective Question"
        }
    }
}'

Full Request Example

Following is the complete request example of creating Multiple Choice Questions (MCQ).

This includes all the required fields to create a question object, as well as to work this question functionally some other fields were also added such as editorState, responseDeclaration, qType etc.

{
  "question": {
    "code": "f23d981a-e1db-2753-ebf3-f2a20c1578e3",
    "mimeType": "application/vnd.sunbird.question",
    "media": [],
    "editorState": {
      "options": [
        {
          "answer": true,
          "value": {
            "body": "<p>answer1</p>",
            "value": 0
          }
        },
        {
          "answer": false,
          "value": {
            "body": "<p>answer2</p>",
            "value": 1
          }
        },
        {
          "answer": false,
          "value": {
            "body": "<p>answer3</p>",
            "value": 2
          }
        },
        {
          "answer": false,
          "value": {
            "body": "<p>answer4</p>",
            "value": 3
          }
        }
      ],
      "question": "<p>question</p>"
    },
    "templateId": "mcq-vertical",
    "answer": "0",
    "bloomsLevel": "application",
    "maxScore": 1,
    "name": "1",
    "responseDeclaration": {
      "response1": {
        "maxScore": 1,
        "cardinality": "single",
        "type": "integer",
        "correctResponse": {
          "value": "0",
          "outcomes": {
            "SCORE": 1
          }
        },
        "mapping": []
      }
    },
    "interactionTypes": [
      "choice"
    ],
    "interactions": {
      "response1": {
        "type": "choice",
        "options": [
          {
            "label": "<p>answer1</p>",
            "value": 0
          },
          {
            "label": "<p>answer2</p>",
            "value": 1
          },
          {
            "label": "<p>answer3</p>",
            "value": 2
          },
          {
            "label": "<p>answer4</p>",
            "value": 3
          }
        ]
      }
    },
    "qType": "MCQ",
    "primaryCategory": "Multiple Choice Question",
    "body": "<div class='question-body' tabindex='-1'><div class='mcq-title' tabindex='0'><p>question</p></div><div data-choice-interaction='response1' class='mcq-vertical'></div></div>",
    "solutions": [],
    "creator": "N118",
    "createdBy": "b6640bfe-e294-4a54-8c75-589472324624",
    "board": "CBSE",
    "medium": [
      "English"
    ],
    "gradeLevel": [
      "Class 2"
    ],
    "subject": [
      "Mathematics"
    ],
    "author": "n11@yopmail.com",
    "channel": "01309282781705830427",
    "framework": "ekstep_ncert_k-12",
    "copyright": "NIT123",
    "audience": [
      "Student"
    ],
    "license": "CC BY 4.0",
    "programId": "18730310-5144-11ed-be8b-9962d8844469",
    "collectionId": "do_11365081180508160011559",
    "organisationId": "e7328d77-42a7-44c8-84f4-8cfea235f07d",
    "topic": [
      "Grouping and Counting"
    ],
    "isReviewModificationAllowed": false
  }
}