The sketch question type displays introductory text accompanied by a set of axes. The student draws a graph on the axes by clicking points to be used as interpolation nodes.
Use the sketch environment to configure the applet, declaring the ranges of the axes, a sample correct response, and a list of criteria that the student answer must meet. The \begin{sketch} command takes one option and four required arguments, in the following order:
gridlines option - number of horizontal and vertical gridlines in addition to the axes (default is 10)
xMin - minimum x value on the x-axis
xMax - maximum x value on the x-axis
yMin - minimum y value on the y-axis
yMax - maximum y value on the y-axis
The following commands must appear in the sketch environment.
\example{<point-list>} describes a sample correct answer that is displayed if the student gives an incorrect response. The sketch is given as <point-list>, a space-delimited set of coordinates of the form x,y. The resulting sketch is a single curve interpolated from these points.
\check{criterion} sets a criterion that the student's sketch must satisfy. Available criteria are:
goes_through(xcoord, ycoord) - sketched function must pass through the point (xcoord, ycoord)
increasing - sketched function must be increasing
decreasing - sketched function must be decreasing
concave_up - sketched function must be concave up
concave_down - sketched function must be concave down
linear - sketched function must be linear
To restrict a criterion to an interval [a,b], use \check[a,b]{criterion}. (This option is ignored for goes_through.)
The criterion can also be a boolean expression; useful statements in this case are:
slope_at(xval) - return the slope of the curve at the x value xval
value(xval) - return the y value for the x value xval
expr1 == expr2 - return true if expr1 is equal to expr2. Otherwise, it returns false.
expr1 < expr2 - return true if expr1 is less than expr2. Otherwise, it returns false.
expr1 > expr2 - return true if expr1 is greater than expr2. Otherwise, it returns false.
true - boolean constant
false - boolean constant
bool1 && bool2 - return true if bool1 and bool2 evaluate to true. Otherwise, it returns false.
bool1 || bool2 - return true if bool1 or bool2 (or both) evaluate to true. Otherwise, it returns false.
For example, value(xcoord) == ycoord is equivalent to goes_through(xcoord, ycoord).
More than one \check statement can appear, in which case every criterion must be satisfied. That is,
\check{criterion1}
\check{criterion2}
\check{criterion3}
is equivalent to
\check{criterion1 && criterion2 && criterion3}
\begin{question}{sketch}
\qutext{Sketch the graph of the function $y=x+1$.}
\begin{sketch}[4]{-2}{2}{-2}{2}
\example{-2,-1 1,2}
\check{linear}
\check{goes_through(0,1)}
\end{sketch}
\end{question}
This example uses randomized variables.
\begin{question}{sketch}
\code{$a = int(rand(2,6));
$a2 = int($a*$a);
$xmax = int(2*$a);
$x = sqrt(2)*$a;}
\qutext{Sketch the graph of the function $y=x^2/\var{a2}$.}
\begin{sketch}[4]{-\var{xmax}}{\var{xmax}}{-4}{4}
\example{-\var{x},2 -\var{a},1 0,0 \var{a},1 \var{x},2}
\check{goes_through(0,0) && goes_through(-\var{a},1)
&& goes_through(\var{a},1)}
\check{slope_at(0) == 0}
\check[-\var{x},0]{decreasing}
\check[0,\var{x}]{increasing}
\check{concave_up}
\end{sketch}
\end{question}