Summary



Exercise

Data Schema

Ref: Sheet: Python Implementation

{
    "_id": INT,
    "level": ENUM,
    "difficulty": INT,
    "number": INT,
    "language": "python",
    "topic": VARCHAR,
    "questionNumber": INT,
    "questions": [
        {
            "inputLines": {
                "minLines": INT,
                "maxLines": INT
            },
            "type": ENUM,
            "content": [
                {
                    "type": ENUM,
                    "payload": [],
                    "payloadType": ENUM
                }
            ],
            "hasSecondColumn": BOOLEAN,
            "textInputSize": INT,
			
		/* additional fields */
        }
    ],
}

Key definitions

  • 🔑 _id: see Lesson ID
  • 🔑 level: (G | H | I)
  • 🔑 difficulty:
    • For level G: 0 - 8
    • For level H: 0 - 5
    • For level I: 0 - 5
  • 🔑 number: story (last 3 digits). See Lesson ID
  • 🔑 topic: see About the curriculum
  • 🔑 questions.type: see Exercise types
  • 🔑 questions.inputLines.minLines/maxLines: minimum/maximum number of lines for code input area. (currently not implemented in the codebase)
  • 🔑 questions.textInputSize: size of text input (currently not implemented in the codebase)
  • 🔑 questions.content.type: ENUM
    • instructions : renders markdown payload only using <p> tags
    • listExplanation: renders list items
    • codeLine: renders one code line
    • codeAreaTitle: renders code snippet with title: “Code:”
    • codeArea: renders code snippet
    • outputAreaTitle: renders output snippet with title: “Output:”
    • expectedOutput: renders expected output block
    • story-blue: renders context/background content (blue text)
    • hint: renders ‘hint’ block
    • explanation: renders ‘explanation’ block
    • image: renders image from link
  • 🔑 questions.content.payloadType: ENUM
    • markdown (default renderer)
    • html
  • 🔑 questions.hasSecondColumn: use two-column layout

Exercise types

Multiple choice

Core settings
"questions": [
	{
		"dragDrop": {
			"cards": []
		},
		"type": "multi-choice",
		"content": [
			{
				"type": "instructions",
				"payload": [
					"Python is a programming language?"
				],
				"payloadType": "markdown"
			}
		],
		"hasSecondColumn": false,
		"textInput": []
	}		
],
Additional fields
"questions": [
	{ 
		"choices": [
			"Yes",
			"No"
		],
		"choiceFormat": "html",
	}
]

Code Input

Core settings
"questions": [
	{ 
		"dragDrop": {
			"cards": []
		},
		"type": "code-input",
		"content": [
			{
				"type": "instructions",
				"payload": [
					"Write the Python code to display \"A computer program is a list of instructions.\""
				],
				"payloadType": "markdown"
			},
			{
				"type": "expectedOutput",
				"payload": {
					"code": "A computer program is a list of instructions.",
					"mode": "python"
				},
				"payloadType": "markdown"
			}
		],
		"hasSecondColumn": false,
		"choiceFormat": "html",
		"textInput": []
	}
]
Additional fields
"questions": [
	{
		"secondColumnContent": [],
	}
]

Drag-and-Drop

Core settings
"questions": [
	{
		"type": "drag-drop-text",
		"content": [
			{
				"type": "instructions",
				"payload": [
					"I want to get 60 from these ints, which operator do I use? Drag and drop the correct operator into the equation."
				],
				"payloadType": "markdown"
			}
		],
		"hasSecondColumn": false,
		"choices": [],
		"choiceFormat": "html",
		"textInputSize": 20,
	}
],
Additional fields
"questions": [
	"dragDrop": {
		"cards": [
			{
				"id": 0,
				"value": "+"
			},
			{
				"id": 1,
				"value": "-"
			},
			{
				"id": 2,
				"value": "*"
			},
			{
				"id": 3,
				"value": "/"
			},
			{
				"id": 4,
				"value": "**"
			},
			{
				"id": 5,
				"value": "%"
			}
		]
	},
	"textInput": [
		[
			{
				"type": "text",
				"value": "12"
			},
			{
				"type": "input"
			},
			{
				"type": "text",
				"value": "5 = 60"
			}
		]
	]
]

Fill-in-the-blank

Core settings
"questions": [
	{
		"dragDrop": {
			"cards": []
		},
		"type": "text-boxes",
		"content": [
			{
				"type": "story-blue",
				"payload": [
					"A farmer has traded his vegetables to many customers. In return, the customers must give him seeds to complete the trade. The farmer has used equations to keep track of who owes how many seeds. He wants you to match the equations to the correct customer."
				],
				"payloadType": "markdown"
			},
			{
				"type": "instructions",
				"payload": [
					"Write equations for the following people in the list below."
				],
				"payloadType": "markdown"
			},
			{
				"type": "listExplanation",
				"payload": [
					"Timmy owes two plus six",
					"Jim owes the remainder of eight divided by five"
				],
				"payloadType": "markdown"
			},
			{
				"type": "instructions",
				"payload": [
					"Write your equations in the space provided."
				],
				"payloadType": "markdown"
			}
		],
		"hasSecondColumn": false,
		"choices": [],
		"choiceFormat": "html",
		"textInputSize": 20,
	}
],
Additional fields
"questions": [
	{ 
		"textInput": [
			[
				{
					"type": "text",
					"value": "timmy = "
				},
				{
					"type": "input"
				}
			],
			[
				{
					"type": "text",
					"value": "jim = "
				},
				{
					"type": "input"
				}
			]
		]
	}
]

True/False

Core settings
"questions": [
	{ 
		"dragDrop": {
			"cards": []
		},
		"type": "true-false",
		"content": [
			{
				"payloadType": "markdown",
				"type": "codeAreaTitle",
				"payload": {
					"code": "product =  \"Soap \"\nprice = 10\r\n",
					"mode": "python"
				}
			},
			{
				"payloadType": "markdown",
				"type": "instructions",
				"payload": [
					"The value of **product + price** is **\"Soap 10\"**"
				]
			},
			{
				"payloadType": "markdown",
				"type": "explanation",
				"payload": [
					"Note: product is a string and price is an int, combining the two will give TypeError."
				]
			}
		],
		"hasSecondColumn": false,
		"choiceFormat": "html",
		"textInputSize": 20,
		"textInput": []
	}
]
Additional fields
null

APIs

Check Exercise

  • Response: {exercise}

Post Exercise

  • Request Body: {exercise}
  • Response: {exercise}

Delete exercise

  • Request Body:
{
	"_id": "exercise_id"
}
  • Response: {exercise}