Skip to content
Classroom

Drawing

Answer type: draw

The student draws on a canvas — plots points, sketches a line, shades a region.

The minimum

Common Control:

$answer = "2,3"
$answerformat = "dot"

$answerformat is what tells the canvas which tools the student gets. Without it the student gets the default tools: line, dot and open dot.

Options

Variable Effect
$answers the elements the student must draw: a string for one element, an array for several. Every element must be drawn. A dot is "x,y"; a curve is an expression in x such as "2x+3"
$answer read only when $answers is not set, as a fallback
$answerformat which drawing tool, and what shape is expected
$reltolerance multiplies the default closeness tolerance (default 1; larger is more lenient)
$abstolerance a score threshold, not a distance: a drawing scoring at least this fraction (0–1) gets full credit, below it gets 0
$grid the drawing window, as "xmin,xmax,ymin,ymax,xscl,yscl,width,height" (default "-5,5,-5,5,1,1,300,300"); xscl/yscl set the label and grid spacing
$snaptogrid snap drawn points to the grid
$background graphs drawn under the canvas, in showplot entry syntax (a string or array such as "x^2,red"); or "draw:" followed by asciisvg commands, ending in alt: and a text description (students using keyboard drawing entry with text-alternative graph display see that description; without alt: they are shown the raw commands); or "none" / "transparent". Pass function strings, not the output of showplot()
$partweights weight of each drawn element
$scoremethod grading variants: "takeanything" (any drawing gets full credit), "ignoreextradots" (polygon), "direction" / "relativelength" (vectors), "ignoreoverlap"

$answerformat values

Value Student draws
"dot" a filled point
"opendot" an open point
"line" a line through clicked points, joined by straight segments and graded against an expression in x; for a straight line through two points use "twopoint,line"
"lineseg" a line segment
"numberline" on a number line
"polygon" a path joining points; it is graded as closed only if the last point in $answers repeats the first
"twopoint" graphs fixed by two clicks. List the tools after it, e.g. "twopoint,line,parab,abs,dot"; on its own it gives line, parabola, absolute value, circle and dot
"parab", "abs" parabola / absolute-value tools, only after "twopoint" (or "inequality"); as the first entry they give no such tool
"inequality" a shaded inequality
"freehand" an unconstrained sketch

$snaptogrid

Turn it on for anything graded on exact coordinates. Without snapping, a student who has understood the problem perfectly can still miss the tolerance by a pixel — and mouse precision is not what the question is assessing.

Accessibility

Students who set the Drawing Entry preference to "Keyboard and text-based drawing entry alternative" get a keyboard form in place of the mouse drawing tools: they add elements with the "Add new drawing element" menu and its Add button, and each element then appears under "Elements to draw". If they have also set Graph Display to text alternatives, the graphing window is described in text instead of drawn. Set $readerlabel to give the part a screen-reader label. Where the underlying skill can also be assessed another way, consider an alternative part — an N-Tuple for the coordinates, or a Function for the equation of the line.

Example

Common Control — setup:

$m = nonzerorand(-3, 3)
$b = rand(-5, 5)
$eqn = makexxpretty("$m x + $b")

Question Text:

<p>Sketch the line `y = $eqn`.</p>

Common Control, continued — answer and options:

$answers = "$m x + $b"
$answerformat = "twopoint,line"
$grid = "-10,10,-10,10,1,1,300,300"
$snaptogrid = 1

See Also