Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save natandreeva/b02671308cc098ff9cec2542993354d3 to your computer and use it in GitHub Desktop.
Save natandreeva/b02671308cc098ff9cec2542993354d3 to your computer and use it in GitHub Desktop.
{
"$schema": "http://json-schema.org/draft-07/schema#",
"anyOf": [
{
"$ref": "#/definitions/OnesieInteractiveLayout"
},
{
"$ref": "#/definitions/ShirtPantsInteractiveLayout"
},
{
"$ref": "#/definitions/MatchLayout"
},
{
"$ref": "#/definitions/TypeFillLayout"
},
{
"$ref": "#/definitions/SelectOneLayout"
},
{
"$ref": "#/definitions/SelectAllLayout"
}
],
"definitions": {
"ButtonInteractiveElement": {
"description": "A button element that contains an interface element\n\nVariables:\n- Exposes { selected: boolean } indicating if the button is selected",
"properties": {
"child": {
"$ref": "#/definitions/StaticElement"
},
"id": {
"type": "string"
},
"type": {
"const": "button",
"type": "string"
}
},
"required": [
"child",
"id",
"type"
],
"type": "object"
},
"ImageStaticElement": {
"description": "An image element to display",
"properties": {
"type": {
"const": "image",
"type": "string"
},
"url": {
"type": "string"
}
},
"required": [
"type",
"url"
],
"type": "object"
},
"KeyboardInteractiveElement": {
"description": "A text input field that accepts keyboard input\n\nVariables:\n- Exposes { value: string } containing the user's input",
"properties": {
"id": {
"type": "string"
},
"placeholder": {
"type": "string"
},
"special_character": {
"type": "string"
},
"type": {
"const": "keyboard",
"type": "string"
}
},
"required": [
"id",
"type"
],
"type": "object"
},
"MatchLayout": {
"description": "A layout that presents pairs of elements to match\n\nGrading:\n- Calls grading_function when two buttons are selected (one from each column)",
"properties": {
"grading_function": {
"description": "A grading function as a javascript string.\n\nThe function will be called with a map of component IDs to their variables to their values.\n\nIt should return [boolean, string] where:\n- boolean indicates if the answer is correct\n- string is feedback to show the user",
"type": "string"
},
"hint": {
"type": "string"
},
"instruction": {
"type": "string"
},
"layout": {
"const": "match",
"type": "string"
},
"onesie": {
"items": {
"items": [
{
"$ref": "#/definitions/ButtonInteractiveElement"
},
{
"$ref": "#/definitions/ButtonInteractiveElement"
}
],
"maxItems": 2,
"minItems": 2,
"type": "array"
},
"type": "array"
}
},
"required": [
"grading_function",
"instruction",
"layout",
"onesie"
],
"type": "object"
},
"OnesieInteractiveLayout": {
"description": "A layout that presents a single prompt and expects user input\n\nGrading:\n- Calls grading_function when the user submits their answer",
"properties": {
"grading_function": {
"description": "A grading function as a javascript string.\n\nThe function will be called with a map of component IDs to their variables to their values.\n\nIt should return [boolean, string] where:\n- boolean indicates if the answer is correct\n- string is feedback to show the user",
"type": "string"
},
"hint": {
"type": "string"
},
"instruction": {
"type": "string"
},
"layout": {
"const": "onesie",
"type": "string"
},
"onesie": {
"$ref": "#/definitions/WebInteractiveElement"
}
},
"required": [
"grading_function",
"instruction",
"layout",
"onesie"
],
"type": "object"
},
"SelectAllLayout": {
"description": "A layout that presents a prompt and expects multiple selections from a list of options\n\nGrading:\n- Calls grading_function when the user submits their answer",
"properties": {
"grading_function": {
"description": "A grading function as a javascript string.\n\nThe function will be called with a map of component IDs to their variables to their values.\n\nIt should return [boolean, string] where:\n- boolean indicates if the answer is correct\n- string is feedback to show the user",
"type": "string"
},
"hint": {
"type": "string"
},
"instruction": {
"type": "string"
},
"layout": {
"const": "selectAll",
"type": "string"
},
"pants": {
"items": {
"$ref": "#/definitions/ButtonInteractiveElement"
},
"type": "array"
},
"shirt": {
"$ref": "#/definitions/StaticElement"
}
},
"required": [
"grading_function",
"instruction",
"layout",
"pants",
"shirt"
],
"type": "object"
},
"SelectOneLayout": {
"description": "A layout that presents a prompt and expects a single selection from a list of options\n\nGrading:\n- Calls grading_function when the user submits their answer",
"properties": {
"grading_function": {
"description": "A grading function as a javascript string.\n\nThe function will be called with a map of component IDs to their variables to their values.\n\nIt should return [boolean, string] where:\n- boolean indicates if the answer is correct\n- string is feedback to show the user",
"type": "string"
},
"hint": {
"type": "string"
},
"instruction": {
"type": "string"
},
"layout": {
"const": "selectOne",
"type": "string"
},
"pants": {
"items": {
"$ref": "#/definitions/ButtonInteractiveElement"
},
"type": "array"
},
"shirt": {
"$ref": "#/definitions/StaticElement"
}
},
"required": [
"grading_function",
"instruction",
"layout",
"pants",
"shirt"
],
"type": "object"
},
"ShirtPantsInteractiveLayout": {
"description": "A layout that presents a prompt and expects user input\n\nGrading:\n- Calls grading_function when the user submits their answer",
"properties": {
"grading_function": {
"description": "A grading function as a javascript string.\n\nThe function will be called with a map of component IDs to their variables to their values.\n\nIt should return [boolean, string] where:\n- boolean indicates if the answer is correct\n- string is feedback to show the user",
"type": "string"
},
"hint": {
"type": "string"
},
"instruction": {
"type": "string"
},
"layout": {
"const": "shirtPants",
"type": "string"
},
"pants": {
"$ref": "#/definitions/WebInteractiveElement"
}
},
"required": [
"grading_function",
"instruction",
"layout",
"pants",
"shirt"
],
"type": "object"
},
"StaticElement": {
"anyOf": [
{
"$ref": "#/definitions/TextStaticElement"
},
{
"$ref": "#/definitions/ImageStaticElement"
},
{
"$ref": "#/definitions/TableStaticElement"
},
{
"$ref": "#/definitions/WebStaticElement"
}
],
"description": "Base interface element that can be text, image, button, or table"
},
"TableStaticElement": {
"description": "A table element containing a grid of interface elements",
"properties": {
"children": {
"items": {
"items": {
"$ref": "#/definitions/StaticElement"
},
"type": "array"
},
"type": "array"
},
"type": {
"const": "table",
"type": "string"
}
},
"required": [
"children",
"type"
],
"type": "object"
},
"TextStaticElement": {
"description": "A text element to display",
"properties": {
"type": {
"const": "text",
"type": "string"
},
"value": {
"type": "string"
}
},
"required": [
"type",
"value"
],
"type": "object"
},
"TypeFillLayout": {
"description": "A layout that presents a prompt and expects keyboard input\n\nGrading:\n- Calls grading_function when the user submits their answer",
"properties": {
"grading_function": {
"description": "A grading function as a javascript string.\n\nThe function will be called with a map of component IDs to their variables to their values.\n\nIt should return [boolean, string] where:\n- boolean indicates if the answer is correct\n- string is feedback to show the user",
"type": "string"
},
"hint": {
"type": "string"
},
"instruction": {
"type": "string"
},
"layout": {
"const": "typeFill",
"type": "string"
},
"pants": {
"$ref": "#/definitions/KeyboardInteractiveElement"
},
"shirt": {
"$ref": "#/definitions/StaticElement"
}
},
"required": [
"grading_function",
"instruction",
"layout",
"pants",
"shirt"
],
"type": "object"
},
"WebInteractiveElement": {
"description": "A web input.\n\nVariables:\n- Determined by the WebView's `getOutputVariables()` function.",
"properties": {
"html": {
"description": "A web view to display.\n\nExposes output variables (if any) via a global function `getOutputVariables() -> Map<string, string>`.",
"type": "string"
},
"id": {
"type": "string"
},
"type": {
"const": "web",
"type": "string"
}
},
"required": [
"html",
"id",
"type"
],
"type": "object"
},
"WebStaticElement": {
"description": "A web view element to display HTML content",
"properties": {
"html": {
"description": "A web view to display.\n\nExposes output variables (if any) via a global function `getOutputVariables() -> Map<string, string>`.",
"type": "string"
},
"type": {
"const": "web",
"type": "string"
}
},
"required": [
"html",
"type"
],
"type": "object"
}
},
"description": "Base interface for all challenge layouts. A challenge's layout determines:\n- How the challenge's contents are arranged and styled\n- How challenge's state machine works, including when it is graded"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment