Authoring Questions with Embedded Plots Example Script

To author applet graphing questions, you must use a text or HTML editor, or LaTeX to produce script files. For details on using LaTeX to generate questions that display graphs, see Graph Plotting in LaTeX.

 

You can also embed Maple plots in questions using the Question Bank Editor.

 

The following example script creates a question that generates graphs using algorithmically-driven data.

 

qu.4.7.mode=Formula@
qu.4.7.name=Algorithmically generated graph@
qu.4.7.comment=
The correct answer is
<math>
<msup><mi>x</mi><mn>2</mn></msup>
<mo>-</mo>
<mn>$B</mn> <mi>x</mi>
<mo>-</mo>
<mn>$C</mn>
</math>
@
qu.4.7.editing=useHTML@
qu.4.7.algorithm=
$a=int(rand(-8,5));
$b=int(rand(-$a+2, 10));
$yMin=5*int((-0.25($b-$a)^2)/5) - 5;
$yMax=-$yMin;
$B=int($a+$b);
$C=int(-$a*$b);
@
qu.4.7.question=
Give a formula for the quadratic equation shown in the graph below:
<p>
<center>
  <applet code="applets.grapher.Graph" archive="graphing.jar" width="250" height="250">
  <param name="xMin" value="-10">
  <param name="xMax" value="10">
  <param name="yMin" value="$yMin">
  <param name="gridLines" value="10">
  <param name="yMax" value="$yMax">
  <param name="y1" value="(x-$a)(x-$b)">
  </applet>
</center>
@
qu.4.7.answer=(x-$a)(x-$b)@