questiontype=1
checkfile=$checkdir/multiplechoice.proc
n=$counter                                                                                                     
!if $level=0
    R=$counter
!else
    R=$level
!endif
insplot_data=$empty
!if $options<3 or $options>8
    options=4
!endif
choice=!randint 1,$options
answer$n=$choice
question$n=!record 21 of lang/remarks.$taal
#@ Welke toenametabel komt overeen met het getoonde grafiek ?
#@ Klik hier</a> voor de <b>grafiek</b>
image=0
math=0
xmin=0
xmax=6
delta=1
!if $R isin 1,2
    exotext=$empty
    helptext=!record 22 of lang/remarks.$taal
    #@Klik hier</a> voor de grafiek <em>(gebruikt een java applet)</em>
    # met JCM applet als functionplotter
    sometext=!record 7 of lang/remarks.$taal
    #@ De tabel is gemaakt met deze functie
    aa=!shuffle 0.25,0.5,0.75,1,1.25,1.5,1.75,2,2.25,2.5,2.75,3,3.25
    b=!randitem 0,1,2,3,4,5
    r=!randitem -1,1
    pm=!randitem -,+
    !for p=1 to $options
	Y$p=$empty
	a=!item $p of $aa
	a=$[$a*$r]
	!if $R=1
	    f=$a*x $pm $b
	!else
	    f=$a*x^2 $pm $b
	!endif
	!if $p=$choice
	    plotfunctie=$f
	!endif
	!for s=$xmin to $xmax
	    y=!evalsubst x=$s in $f
	    Y$p=!append item $y to $(Y$p)
	!next s
    !next p

    !for p=1 to $options
	ex$p=$empty
	xtabel=$empty
	ytabel=$empty
	!for s=1 to $[$xmax-1]
	    y1=!item $s of $(Y$p)
	    y2=!item $[$s+1] of $(Y$p)
	    xtabel=!append line <td>$s</td> to $xtabel
	    ytabel=!append line <td>$[$y2-$y1]</td> to $ytabel
	!next s
	ex$p=<table cellpadding="8" border="1" bgcolor="white"><td>x</td>$xtabel<tr><td>$m_Delta y</td>$ytabel</table>
    !next p

    niceplot=!htmlmath f(x)=$plotfunctie
    textanswer$n=<table cellpadding="10"><td>$(ex$choice)</td><td>$sometext<p>$niceplot</td></table>
    object$n=<applet codebase="$appletdir" archive="jcm1.0-config.jar" code="SimpleGraph.class" width="640" height="480">\
    <param name="UseFunctionInput" value="no">\
    <param name="CanvasColor" value="255 255 224">\
    <param name="PanelBackground" value="255 255 224">\
    <param name="BackgroundColor" value="255 255 224">\
    <param name="UseGrid" value="yes">\
    <param name="Function" value="$plotfunctie">\
    <param name="GraphColor" value="red">\
    <param name="UsePanner" value="yes">\
    <param name="UseZoomButtons" value="yes">\
    <param name="UseMouseZoom" value="yes">\
    <param name="UseLimitsPanel" value="yes">\
    <param name="Limits" value="-20 20 -20 20">\
    <param name="Xlabel" value="x-axis">\
    <param name="Ylabel" value="y-axis">\
    $nojava</applet>
!endif
!if $R>2
    # met GNUplot als dataplotter
    sometext=!record 8 of lang/remarks.$taal
    #@ De tabel is gemaakt van deze randomdata
    aa=!shuffle 0.25,0.5,0.75,1,1.25,1.5,1.75,2,2.25,2.5,2.75,3,3.25
    !for p=1 to $options
	Y$p=$empty
	!for x=$xmin to $xmax
	    pm=!randitem +,-
	    r=!randitem -1,1
	    a=!randitem 1,2,3
	    y=!item $p of $aa
	    y=$[$r*$y $pm $a]
	    Y$p=!append item $y to $(Y$p)
	    !if $p=$choice
		# de grafiek
		insplot_data=!append line $x $y to $insplot_data
		showx=!append line <td>$x</td> to $showx
		showy=!append line <td>$y</td> to $showy
	    !endif
	!next x
    !next p
    !for p=1 to $options
	ex$p=$empty
	xtabel=$empty
	ytabel=$empty
	!for s=1 to $[$xmax-1]
	    y1=!item $s of $(Y$p)
	    y2=!item $[$s+1] of $(Y$p)
	    xtabel=!append line <td>$s</td> to $xtabel
	    ytabel=!append line <td>$[$y2-$y1]</td> to $ytabel
	!next s
	ex$p=<table cellpadding="8" border="1" bgcolor="white"><td>x</td>$xtabel<tr><td>$m_Delta y</td>$ytabel</table>
    !next p
    
    insplot_set=size 0.8,0.8; autoscale y ; border 3;zeroaxis linetype 4 lw 3 ; tmargin 1 ; rmargin 1 ; grid linetype 2 ; xtics 1 ; ytics 1
    !insplot [$[$xmin-$delta] : $[$xmax+$delta]] "insplot_data" notitle  with lines lt 1
    textanswer$n=<table cellpadding="10"><td>$(ex$choice)<br>&nbsp;<br><br></td><td><table cellpadding="1" border="1" bgcolor="white"><td>x</td>$showx<tr><td>y</td>$showy</table><br>$sometext</td></table>
    helptext=$empty
    exotext=!record 2 of lang/remarks.$taal
    #@ Klik hier</a> voor de <b>grafiek</b>
    exotext=<a href="javascript:showimage();">$exotext 
!endif

