...
In the above request spec, a default language code (configured in the system at object level schema) will be injected and data will be transformed (as mentioned in request_2 ) to v2 format and then saved to database.
The data transformation will be done to support both formats mentioned in quml specification.
request_2:
Code Block | ||
---|---|---|
| ||
{ "request": { "question": { "name": "question_title", "code": "{{$randomUUID}}", "mimeType": "application/vnd.sunbird.question", "primaryCategory": "Multiple Choice Question", "body": { "language_code_1": "question body as string in specified language." }, "instructions": { "language_code": "instructions in HTML format." }, "answer": { "language_code": "answer in specified language" }, "hints": { "language_code": [ "hint-1", "hint-2" ] }, "feedback": { "feedback_id_1": { "language_code": "feedback-1" }, "feedback_id_2": { "language_code": "feedback-2" } }, "solutions": { "language_code": [ { "id": "bc6e4294-1a19-4e75-fb43-871f0e54b0e8", "type": "html", "value": "solution in HTML format" }, { "id": "bc6e4294-1a19-4e75-fb43-871f0e54b0e9", "type": "html", "value": "a question can have more than one solution. in such cases, another solution in HTML format" } ] }, "interactions": { "response1": { "type": "choice", "options": [ { "label": { "language_code": "<p>Floral organs</p>" }, "value": 0 }, { "label": { "language_code": "<p>Veins and veinlets in a lamina</p>" }, "value": 1 } ] }, "validation": { "required": "Yes" } } } } } |
Response:
Code Block | ||
---|---|---|
| ||
{ "id": "api.question.create", "ver": "5.0", "ts": "2023-01-30T19:43:43ZZ", "params": { "resmsgid": "ca1ed6b6-994d-487c-8ecd-0ca164a84c94", "msgid": null, "err": null, "status": "successful", "errmsg": null }, "responseCode": "OK", "result": { "identifier": "do_2137224832856555521270", "versionKey": "1675107822985" } } |
...
question read api will always return will data in below format:
Code Block | ||
---|---|---|
| ||
{ "id": "api.question.read", "ver": "5.0", "ts": "2023-01-30T03:28:23ZZ", "params": { "resmsgid": "db23eb9e-207c-488c-a45a-7da36a2084ee", "msgid": null, "err": null, "status": "successful", "errmsg": null }, "responseCode": "OK", "result": { "question": { "identifier": "do_213688205764337664161", "body": { "language_code_1": "question body as string in specified language." }, "instructions": { "language_code": "instructions in HTML format." }, "answer": { "language_code": "answer in specified language" }, "hints": { "language_code": [ "hint-1", "hint-2" ] }, "feedback": { "feedback_id_1": { "language_code": "feedback-1" }, "feedback_id_2": { "language_code": "feedback-2" } }, "solutions": { "language_code": [ { "id": "bc6e4294-1a19-4e75-fb43-871f0e54b0e8", "type": "html", "value": "solution in HTML format" }, { "id": "bc6e4294-1a19-4e75-fb43-871f0e54b0e9", "type": "html", "value": "a question can have more than one solution. in such cases, another solution in HTML format" } ] }, "interactions": { "response1": { "type": "choice", "options": [ { "label": { "language_code": "<p>Floral organs</p>" }, "value": 0 }, { "label": { "language_code": "<p>Veins and veinlets in a lamina</p>" }, "value": 1 } ] }, "validation": { "required": "Yes" } } } } } |
...
Question Update API also support both spec as mentioned in create api.
For older data (created with v1 api’s), on v2 api update call, data will be migrated to v2 api format as well as version will be set to 2.
Request_1:
Code Block | ||
---|---|---|
| ||
{ "request": { "question": { "name": "updated_question_title", "versionKey": "1234", "body": "question body as string when question can be used in only one language.", "instructions": { "language_code": "instructions in HTML format." }, "answer": "answer", "hints": [ "hint-1", "hint-2" ], "feedback": { "feedback_id_1": "feedback-1", "feedback_id_2": "feedback-2" }, "solutions": [ { "id": "bc6e4294-1a19-4e75-fb43-871f0e54b0e8", "type": "html", "value": "solution in HTML format" }, { "id": "bc6e4294-1a19-4e75-fb43-871f0e54b0e9", "type": "html", "value": "a question can have more than one solution. in such cases, another solution in HTML format" } ], "interactions": { "response1": { "type": "choice", "options": [ { "label": "<p>Floral organs</p>", "value": 0 }, { "label": "<p>Veins and veinlets in a lamina</p>", "value": 1 } ] }, "validation": { "required": "Yes" } } } } } |
Request_2:
Code Block | ||
---|---|---|
| ||
{ "request": { "question": { "name": "updated_question_title", "versionKey": "1234", "body": { "language_code_1": "question body as string in specified language." }, "instructions": { "language_code": "instructions in HTML format." }, "answer": { "language_code": "answer in specified language" }, "hints": { "language_code": [ "hint-1", "hint-2" ] }, "feedback": { "feedback_id_1": { "language_code": "feedback-1" }, "feedback_id_2": { "language_code": "feedback-2" } }, "solutions": { "language_code": [ { "id": "bc6e4294-1a19-4e75-fb43-871f0e54b0e8", "type": "html", "value": "solution in HTML format" }, { "id": "bc6e4294-1a19-4e75-fb43-871f0e54b0e9", "type": "html", "value": "a question can have more than one solution. in such cases, another solution in HTML format" } ] }, "interactions": { "response1": { "type": "choice", "options": [ { "label": { "language_code": "<p>Floral organs</p>" }, "value": 0 }, { "label": { "language_code": "<p>Veins and veinlets in a lamina</p>" }, "value": 1 } ] }, "validation": { "required": "Yes" } } } } } |
Response:
Code Block | ||
---|---|---|
| ||
{ "id": "api.question.update", "ver": "5.0", "ts": "2023-01-30T19:43:43ZZ", "params": { "resmsgid": "ca1ed6b6-994d-487c-8ecd-0ca164a84c94", "msgid": null, "err": null, "status": "successful", "errmsg": null }, "responseCode": "OK", "result": { "identifier": "do_2137224832856555521270", "versionKey": "1675107822985" } } |
...