Introduction

There are some challenges which we face currently with the QuML Spec. Existing spec restricts how the Question will look in UI and lots of CSS is needed to manage the look and feel.

How Questions with Plain Text Get Stored in DB

If we want to add a question with simple text: What is the Capital of India?

It gets stored as:

1<div class='question-body' tabindex='-1'> 2 <div class='mcq-title' tabindex='0'> 3 <p>What is the Capital of India?&nbsp;</p> 4 </div> 5 <div data-choice-interaction='response1' class='mcq-vertical'></div> 6</div>

How Questions with Images Get Stored in DB

If we want to add a question with simple text + image: What is the Capital of India? + IndiaGate.jpg

It gets stored as:

1<div class='question-body' tabindex='-1'> 2 <div class='mcq-title' tabindex='0'> 3 <p>What is the Capital of India?&nbsp;</p> 4 <figure class="image"><img src="/assets/public/content/assets/do_21408871175179468812/indiagate.jpeg" 5 alt="indiaGate" data-asset-variable="do_21408871175179468812"></figure> 6 </div> 7 <div data-choice-interaction='response1' class='mcq-vertical'></div> 8</div>

Since the data in the database gets stored in the form of HTML markup, it creates a problem in UI handling images of different sizes and resolutions.

Storing Images in Options

Similar to questions, the images in options get stored in the form of HTML markup as:

Option 1 - New Delhi + indiaGate.jpg It gets stored as:

1<p>New Delhi</p> 2<figure class="image"> 3 <img src="/assets/public/content/assets/do_21408871212497305613/indiagate.jpeg" alt="indiaGate" 4 data-asset-variable="do_21408871212497305613"> 5</figure>

Option 2 - Mumbai + gateway-of-india.jpg It gets stored as:

1<p>Mumbai&nbsp;</p> 2<figure class="image resize-25"> 3 <img src="/assets/public/content/assets/do_21408871227163443214/gateway-of-india.jpg" alt="gateway-of-india" 4 data-asset-variable="do_21408871227163443214"> 5</figure>

MCQ metadata example:

1{ 2 "copyright": "tn", 3 "code": "16752658-58f4-4c9a-be39-e7441aeba8ac", 4 "subject": [ 5 "English" 6 ], 7 "qumlVersion": 1.1, 8 "channel": "01269878797503692810", 9 "responseDeclaration": { 10 "response1": { 11 "cardinality": "single", 12 "type": "integer", 13 "correctResponse": { 14 "value": 0 15 }, 16 "mapping": [ 17 { 18 "value": 0, 19 "score": 1 20 } 21 ] 22 } 23 }, 24 "language": [ 25 "English" 26 ], 27 "medium": [ 28 "English" 29 ], 30 "mimeType": "application/vnd.sunbird.question", 31 "showHints": false, 32 "media": [ 33 { 34 "id": "do_21408871175179468812", 35 "type": "image", 36 "src": "/assets/public/content/assets/do_21408871175179468812/indiagate.jpeg", 37 "baseUrl": "https://staging.sunbirded.org" 38 }, 39 { 40 "id": "do_21408871212497305613", 41 "type": "image", 42 "src": "/assets/public/content/assets/do_21408871212497305613/indiagate.jpeg", 43 "baseUrl": "https://staging.sunbirded.org" 44 }, 45 { 46 "id": "do_21408871227163443214", 47 "type": "image", 48 "src": "/assets/public/content/assets/do_21408871227163443214/gateway-of-india.jpg", 49 "baseUrl": "https://staging.sunbirded.org" 50 } 51 ], 52 "body": "<div class='question-body' tabindex='-1'><div class='mcq-title' tabindex='0'><p>What is the Capital of India?&nbsp;</p><figure class=\"image\"><img src=\"/assets/public/content/assets/do_21408871175179468812/indiagate.jpeg\" alt=\"indiaGate\" data-asset-variable=\"do_21408871175179468812\"></figure></div><div data-choice-interaction='response1' class='mcq-vertical'></div></div>", 53 "editorState": { 54 "options": [ 55 { 56 "answer": true, 57 "value": { 58 "body": "<p>New Delhi</p><figure class=\"image\"><img src=\"/assets/public/content/assets/do_21408871212497305613/indiagate.jpeg\" alt=\"indiaGate\" data-asset-variable=\"do_21408871212497305613\"></figure>", 59 "value": 0 60 } 61 }, 62 { 63 "answer": false, 64 "value": { 65 "body": "<p>Mumbai&nbsp;</p><figure class=\"image resize-25\"><img src=\"/assets/public/content/assets/do_21408871227163443214/gateway-of-india.jpg\" alt=\"gateway-of-india\" data-asset-variable=\"do_21408871227163443214\"></figure>", 66 "value": 1 67 } 68 } 69 ], 70 "question": "<p>What is the Capital of India?&nbsp;</p><figure class=\"image\"><img src=\"/assets/public/content/assets/do_21408871175179468812/indiagate.jpeg\" alt=\"indiaGate\" data-asset-variable=\"do_21408871175179468812\"></figure>" 71 }, 72 "templateId": "mcq-vertical", 73 "createdOn": "2024-07-01T05:59:45.514+0000", 74 "objectType": "Question", 75 "interactions": { 76 "response1": { 77 "type": "choice", 78 "options": [ 79 { 80 "label": "<p>New Delhi</p><figure class=\"image\"><img src=\"/assets/public/content/assets/do_21408871212497305613/indiagate.jpeg\" alt=\"indiaGate\" data-asset-variable=\"do_21408871212497305613\"></figure>", 81 "value": 0, 82 "hint": "" 83 }, 84 { 85 "label": "<p>Mumbai&nbsp;</p><figure class=\"image resize-25\"><img src=\"/assets/public/content/assets/do_21408871227163443214/gateway-of-india.jpg\" alt=\"gateway-of-india\" data-asset-variable=\"do_21408871227163443214\"></figure>", 86 "value": 1, 87 "hint": "" 88 } 89 ], 90 "validation": { 91 "required": "Yes" 92 } 93 } 94 }, 95 "gradeLevel": [ 96 "Class 5" 97 ], 98 "primaryCategory": "Multiple Choice Question", 99 "contentDisposition": "inline", 100 "lastUpdatedOn": "2024-07-01T05:59:45.671+0000", 101 "contentEncoding": "gzip", 102 "showSolutions": false, 103 "allowAnonymousAccess": "Yes", 104 "identifier": "do_21408871289253068814", 105 "lastStatusChangedOn": "2024-07-01T05:59:45.514+0000", 106 "audience": [ 107 "Student" 108 ], 109 "schemaVersion": "1.1", 110 "visibility": "Parent", 111 "showTimer": false, 112 "author": "Guest new name", 113 "solutions": {}, 114 "hints": {}, 115 "outcomeDeclaration": { 116 "maxScore": { 117 "cardinality": "single", 118 "type": "integer", 119 "defaultValue": 1 120 }, 121 "hint": { 122 "cardinality": "single", 123 "type": "string", 124 "defaultValue": "d97eab22-93bb-4044-aa15-7def03d549a5" 125 } 126 }, 127 "qType": "MCQ", 128 "maxScore": 1, 129 "languageCode": [ 130 "en" 131 ], 132 "versionKey": "1719813585671", 133 "showFeedback": false, 134 "license": "CC BY 4.0", 135 "interactionTypes": [ 136 "choice" 137 ], 138 "framework": "tn_k-12_5", 139 "answer": "<div class='answer-container'><div class='answer-body'><p>New Delhi</p><figure class=\"image\"><img src=\"/assets/public/content/assets/do_21408871212497305613/indiagate.jpeg\" alt=\"indiaGate\" data-asset-variable=\"do_21408871212497305613\"></figure></div></div>", 140 "createdBy": "fca2925f-1eee-4654-9177-fece3fd6afc9", 141 "compatibilityLevel": 5, 142 "name": "MCQ", 143 "board": "State (Tamil Nadu)", 144 "status": "Draft" 145}

Editor UI



Player UI



To address the challenges there are few proposed format in which we can store the question and options

Format 1:

Example JSON:

1{ 2 "question": { 3 "text": "<p>2*5 = ?</p>", 4 "image": "/assets/image.png", 5 "audio": "/assets/audio.mp3", 6 "audioName": "audio file", 7 "hint": "" 8 }, 9 "options": [ 10 { 11 "text": "<p>5</p>", 12 "image": "", 13 "audio": "", 14 "audioName": "", 15 "hint": "", 16 "isCorrect": false 17 }, 18 { 19 "text": "<p>10</p>", 20 "image": "", 21 "audio": "", 22 "audioName": "", 23 "hint": "", 24 "isCorrect": true 25 } 26 ] 27}

Pros:

  • Simplicity: Each content type is stored in dedicated fields, ensuring straightforward data management.

  • Readability: Clear field names make parsing and understanding easy.

  • Efficiency: Direct access to content without needing to iterate through arrays.

Cons:

  • Scalability: Adding new content types requires modifying the schema and related code.

  • Redundancy: Options include all fields, potentially leading to empty or redundant data.

  • Flexibility: Limited in handling multiple instances of the same content type efficiently.

Format 2:

Example JSON:

1{ 2 "question": { 3 "content": [ 4 { 5 "type": "text", 6 "value": "<p>2*5 is ?</p>" 7 }, 8 { 9 "type": "image", 10 "src": "/assets/image.png", 11 "alt": "Image" 12 }, 13 { 14 "type": "audio", 15 "src": "/assets/audio.mp3", 16 "name": "audio file" 17 }, 18 { 19 "type": "hint", 20 "value": "" 21 } 22 ] 23 }, 24 "options": [ 25 { 26 "id": "option1", 27 "content": [ 28 { 29 "type": "text", 30 "value": "<p>5</p>" 31 }, 32 { 33 "type": "image", 34 "src": "", 35 "alt": "" 36 }, 37 { 38 "type": "audio", 39 "src": "", 40 "name": "" 41 }, 42 { 43 "type": "hint", 44 "value": "" 45 } 46 ], 47 "isCorrect": false 48 }, 49 { 50 "id": "option2", 51 "content": [ 52 { 53 "type": "text", 54 "value": "<p>10</p>" 55 }, 56 { 57 "type": "image", 58 "src": "", 59 "alt": "" 60 }, 61 { 62 "type": "audio", 63 "src": "", 64 "name": "" 65 }, 66 { 67 "type": "hint", 68 "value": "" 69 } 70 ], 71 "isCorrect": true 72 } 73 ] 74}

Pros:

  • Flexibility: Supports multiple instances of the same content type with an array-based structure.

  • Scalability: Easily accommodates new content types by adding objects to the content array.

  • Consistency: All content types are handled uniformly, aiding in processing and rendering.

Cons:

  • Complexity: Requires iterating over arrays to process different content types, adding parsing overhead.

  • Readability: Nested structure and type-checking can reduce immediate readability.

Format 3 (Recommended):

Example JSON:

1{ 2 "question": { 3 "id": "q1", 4 "text": "What is the Capital of India?", 5 "media": [ 6 { 7 "type": "image", 8 "src": "/assets/indiagate.jpeg", 9 "alt": "India Gate" 10 }, 11 { 12 "type": "audio", 13 "src": "/assets/question-audio.mp3", 14 "alt": "Question Audio" 15 }, 16 { 17 "type": "video", 18 "src": "/assets/question-video.mp4", 19 "alt": "Question Video" 20 } 21 ] 22 }, 23 "options": [ 24 { 25 "id": "option1", 26 "text": "New Delhi", 27 "media": [ 28 { 29 "type": "image", 30 "src": "/assets/indiagate.jpeg", 31 "alt": "India Gate" 32 } 33 ] 34 }, 35 { 36 "id": "option2", 37 "text": "Mumbai", 38 "media": [ 39 { 40 "type": "image", 41 "src": "/assets/gateway-of-india.jpg", 42 "alt": "Gateway of India" 43 } 44 ] 45 } 46 ] 47}

Pros:

  • Simplicity: Clearly separates text and media, enhancing clarity and ease of handling.

  • Readability: Explicit fields for text and media improve understanding.

  • Flexibility: Supports various content types within a structured format.

Cons:

  • Scalability: Introducing new content types may necessitate schema and code adjustments.

  • Redundancy: Potential for empty fields depending on the question's media requirements.

  • Specificity: Structured format may be less adaptable for multiple instances of the same content type.

Summary: Format 3 stands out as the preferred choice due to its balanced approach in terms of simplicity, readability, and flexibility. It efficiently manages different content types while maintaining a structured format suitable for question data storage and rendering.