Skip to content

Computation Task JSON Message

A computation task is the result of a possibly manipulated computation template. It contains the changes made on the template. Together with the template, a computation task forms a computation that is sent to the backend.

In the context of a learning environment, a computation task can be seen as a Solution.

Example (informal)

Computation Task Message Example
{ 
  "template" : "11483f23-95bf-424a-98a5-ee5868c85c3e", // uuid of corresponding computation template
  "arguments" : {
     "__STEPWIDTH__" : "0.5" // parameter values from template, filled out by frontend
  },
  "metadata" : {
      "comment" : "Die war aber schwer!",
  },
  "parts" : 
    [
      { 
        "identifier": "codeFromStudent", // must: identifier of template part that has changed
        "content"   : "dm9pZCBiYXIoKSB7IHByaW50ZigiYmFyIQoiKTsKfQo" // changed source from user 
                                               // decoded: void bar() { printf(\"bar!\\n\");\n}\n
        // other fields defining this (text) element must *not* be repeated here.
      }
      // unchanged elements needn't be repeated here
    ]
}

Explaining the JSON Format

Key [--Subkey] Type Opt / Must Description Comment AS
template string (UUID) must computation template identifier
arguments {PARAM_ID: value, ..., PARAM_ID: value} opt arguments of, e.g., configuration.commandLineArguments extracted by the frontend see computation template
metadata struct opt contains information for frontend
metadata --comment string opt comment from user implemented in frontend?
parts [{...}, {...}, ...] opt array containing modified part objects. Only identifier- and content-attributes are allowed. Only "modifiable" or "template" parts can be referenced here (see access-attribute). The frontend creates the content for "template" parts. See notes.

Notes for template parts

The frontend will encode parts with access-value "template" as JSON messages with the following structure:

{ 
  "PARAM_ID1" : "value",
  "PARAM_ID2" : "value_2",
  ...
  "PARAM_IDn" : "value_n"
}
PARAM_ID is the reference (key) to a parameter name inside the mustache template. "value" is the selected value of the user in the frontend.

Parameters: What is input into the Handlebars.js-Template?

Parameter guiType Example Returns
checkbox
Checkbox Example
{
  "mode" : "fixed",
  "identifier" : "__checkbox__", 
  "metadata" : {
    "guiType": "checkbox",
    "name": "Things I like",
    "decription" : "Select things you like"
  },
  "options": [
    {
      "value" : "programming",
      "selected" : true
    },
    {
      "value" : "music"
      "selected" : true
    },
    {
      "value" : "books"
    }
  ],
  "validation": "anyof"
} 
Checkbox Returns
["programming", "music"] 
Array of Strings
radio
Radio Example
{
  "mode" : "fixed",
  "identifier" : "__radioButton__", 
  "metadata" : {
    "guiType": "radio",
    "name": "Favorite PL",
    "decription" : "Select your favorite programming language",
  },
  "options": [
    {
      "value" : "C"
    },
    {
      "value" : "Java",
      "selected" : true
    },
    {
      "value" : "Haskell",
      "disabled" : true
    },
    {
      "value" : "Python"
    }
  ],
  "validation": "oneof"
}
Radio Returns
"Java"
String
dropdown (single)
Dropdown (single) Example
{
  "mode" : "fixed",
  "identifier" : "__dropdownSingle__", 
  "metadata" : {
    "guiType": "dropdown",
    "name": "Fridge",
    "decription" : "How often do look into the fridge a day?"
  },
  "options": [
    {
      "value" : "Please choose one",
      "disabled" : true
    },
    {
      "value" : "never",
      "selected" : true
    },
    {
      "value" : "Once a day"
    },
    {
      "value" : "Twice a day"
    },
    {
      "value" : "Three times a day"
    },
    {
      "value" : "More than three times a day"
    }
  ],
  "validation": "oneof"
}
Dropdown (single) Returns
"never"
String
dropdown (multiple)
Dropdown (multiple) Example
{
  "mode" : "fixed",
  "identifier" : "__dropdownMultiple__", 
  "metadata" : {
    "guiType": "dropdown",
    "name": "Dance Time",
    "decription" : "To which songs would you dance in the kitchen?"
  },
  "options": [
    {
      "value" : "Please choose multiple",
      "disabled" : true
    },
    {
      "value" : "Last Christmas",
      "selected" : true
    },
    {
      "value" : "White Christmas"
    },
    {
      "value" : "Winter Woderland"
    },
    {
      "value" : "Thats Christmas To Me", 
      "selected" : true
    },
    {
      "value" : "O Come All Ye Faithful", 
      "disabled" : true
    }
  ], 
  "validation": "anyof"
}
Dropdown (multiple) Result
["Last Christmas", "Thats Christmas To Me"]
Array of Strings
toggle
Toggle Example
{
  "mode" : "fixed",
  "identifier" : "__toggle__", 
  "metadata" : {
    "guiType": "toggle",
    "name": "NO!",
    "decription" : "What do you dislike?"
  },
  "options": [
    {
      "value" : "Spiders",
      "selected" : true
    },
    {
      "value" : "All kinds of Bugs (also the ones living in your Computer)"
    },
    {
      "value" : "I never dislike anything!"
    }
  ], 
  "validation": "anyof"
}
Toggle Result
["Spiders"]
Array of Strings
slider (single)
Slider (single) Example
{
  "mode" : "any",
  "identifier" : "__sliderSingle__", 
  "metadata" : {
    "guiType" : "slider",
    "name": "Temperature",
    "vertical": false,
    "decription" : "How hot do you like your coffee? (in degrees Celsius)"
  },
  "default": [
    75
  ],
  "min": 0,
  "max": 90,
  "step": 10,
  "validation": "range"
}
Slider (single) Result
75
Number
slider (multiple)
Slider (multiple) Example
{
  "mode" : "any",
  "identifier" : "__sliderMultiple__", 
  "metadata" : {
    "guiType" : "slider",
    "name": "random numbers",
    "vertical": true,
    "decription" : "Choose three random numbers to be output by the container"
  },
  "default": [
    25,
    50,
    75
  ],
  "min": 0,
  "max": 100,
  "step": 5,
  "validation": "range"
}
Slider (multiple) Result
[25, 50, 75]
Array of Numbers
input_field
Input_field Example
{
  "mode" : "any",
  "identifier" : "__inputText__", 
  "metadata" : {
    "guiType" : "input_field",
    "type": "text",
    "name": "name",
    "decription" : "Enter your name"
  },
  "default" : [""],
  "validation": "none"
}
Input_field Result
"base64:S2F0aHJ5bg"
If the input_field is of type number: Number Else: Prefixed ("base64:") and Base64URL-encoded String - is decoded by Websocket API, before it is sent to Backend
editor
Editor Example
{
  "mode" : "any",
  "identifier" : "__default__", 
  "metadata" : {
    "guiType" : "editor", 
    "name": "code",
    "decription" : "Enter some code"
  },
  "default": ["aW50IG1haW4oaW50IGFyZ2MsIGNoYXIgKiphcmd2KSB7IC8vIFByaW50ICdIZWxsbyBXb3JsZCcgfQ"],
  "validation": "none"
}
Editor Result
"base64:aW50IG1haW4oaW50IGFyZ2MsIGNoYXIgKiphcmd2KSB7IC8vIFByaW50ICdIZWxsbyBXb3JsZCcgfQ"
Prefixed ("base64:") and Base64URL-encoded String - is decoded by Websocket API, before it is sent to Backend

Evaluation Task

The feature of ViPLab to automatically evaluate student code (correction service) is still possible in ViPLab 3.0. The code needed for evaluation is send to the correction server as a JSON message with the same structure as a Computation Task. The only difference is, that here all parts can be replaced, regardless of there access-settings.