Data Format Returned By The Sketch Tool

The data returned by the sketch tool to the grader backend is formatted as a JSON string. The information contained in the JSON string is divided into two parts. The first part contains the apiVersion used to generate the data and configuration options from the grader script used to configure this instance of the sketch tool and is identical across the data returned for each plugin type. Refer to the Plugin Configuration to see what values are contained here.

The second part contains the actual data drawn using a sketch tool plugin and is dependent upon which plugin was used to generate it.

Common Part

The example below shows the common part of gradeable data. The apiVersion key shows the sketch tool version used to generate this data. The meta key contains the configuration options used to configure the sketch tool that generated this data, including: the width and height of the canvas, the ranges of the x and y axes, and the configuration options of the specific plugins used. Finally, the dataVersions key contains a list of version numbers for each plugin used, in case different plugins are updated at different rates.

{"apiVersion":"0.1","meta":{"config":{"width":420,"coordinates":"polar","yrange":[-4,4],"yscale":"linear","xscale":"linear","xrange":[-4,4],"plugins":[{"name":"axes"},{"color":"blue","label":"Function f(x)","name":"freeform","id":"f"},{"color":"blue","label":"Line Segment","name":"line-segment","id":"ls"}],"height":420},"dataVersions":{"f":"0.1","ls":"0.1"}}, "data": ...}

Plugin Specfic Part

The data key in the JSON string contains a dictionary of mappings from plugin ids to a list of data values generated by the specific plugin configured with that id. There are two types of data that can be returned: splines and points. Splines are lists of four or more points. Points are tuples containing an x and y value. For all data, the x and y values are given as pixel values with respect to the size of the canvas.

Asymptote Data

The data returned by the asymptote plugin is a list of dictionary objects containing lists of exactly four points. The four points are the start point of the spline, followed by the two control points, and finally the end point of the spline. Each spline defines a vertical or horizontal line that spans the entire height or width of the canvas. The example below is for a vertical asymptote.

{... "data": {"asym": [{u'spline': [[267.0028419494629, 0], [267.0028419494629, 140], [267.0028419494629, 280], [267.0028419494629, 420]]}]} ...}

Line Segment Data

The data returned by the line segment plugin is a list of dictionary objects containing lists of exactly four points. The four points are the start point of the spline, followed by the two control points, and finally the end point of the spline. Each dictionary object defines a single line segment.

{... "data": {"seg": [{"spline":[[159,314],[193.66666666666666,244.33333333333334],[228.33333333333334,174.66666666666666],[263,105]]}]} ...}

Point Data

The data returned by the point plugin is a list of dictionary objects containing lists of exactly two points. The two points are x and y coordinates of the point. Each dictionary object defines a single point.

{... "data": {"pt": [{u'point': [375.0028419494629, 256.4744338989258]}]} ...}

Polyline/Polygon Data

The data returned by the line segment plugin is a list of dictionary objects containing lists of at least three points. Unlike the other plugins that return dictionary objects, these points do not actually define splines. The points are vertices of the polyline/polygon. Each dictionary object defines a single polyline, or polygon. The example below defines either a polyline with 6 segments, or a polygon with 7 sides.

{... "data": { "pl": [{"spline":[[74,153],[189,32],[294,85],[185,167],[115,40],[250,17],[218,109]]}]} ...}

Spline Data

The data returned by the freeform or spline plugin is a list of dictionary objects containing lists of at least four points. The freeform/spline line is fit to a set of four point splines. The format of the point data for a line fit to two spline segments would look like: start point, control point, control point, end/start point, control point, control point, end point. Each dictionary object defines a unbroken line drawn by the plugin.

{... "data": {"spl": [{u'spline': [[6, 110], [62.4, 111.61], [122.03, 114.16], [174.42, 93.23], [214.4, 77.26], [246.23, 40.2], [265.57, 1.73]]}, {u'spline': [[492, 6], [508.96, 39.92], [539.76, 70.49], [575.44, 83.32], [618.54, 98.82], [666.46, 95.68], [712.25, 95.88]]}, {u'spline': [[302, 395], [317.22, 339.83], [336.76, 231.33], [391.37, 248.42], [449.46, 266.59], [453.09, 358.46], [455.78, 419.27]]}]} ...}

Tag Data

Tag data behaves slightly differently compared to line and point data. Each tag has to be associated with either line or point data. If a piece of data has an associated label, it will be found under the tag key within the same dictionary object as that data. The tag data itself is a string.

{... "data": {"pt": [{"point":[56,89],"tag":"tag"}]} ...}
{... "data": {"pl": [{"spline":[[55,282],[87,235],[121,278]],"tag":"tag"}]} ...}

results matching ""

    No results matching ""