questiontype=1
checkfile=$checkdir/multiplechoice.proc
insplot_data=$empty
n=$counter                                                                                                     
!if $level=0
    R=$counter
!else
    R=$level
!endif

!if $options<3 or $options>8
    options=4
!endif
choice=!randint 1,$options
answer$n=$choice
question$n=!record 23 of lang/remarks.$taal
#@ Welke functietabel komt overeen met het <b>toenamendiagram</b> ?
exotext=!record 2 of lang/remarks.$taal
#@ Klik hier</a> voor de <b>grafiek</b>
exotext=<a href="javascript:showimage();">$exotext
helptext=$empty
num=5
image=0
math=0
multiimage=0
xmin=!randitem 0,1,2,-1,-2
xmax=$[$xmin +$num]
ansdx=$empty
ansdy=$empty

!if $R isin 1,2
    image=0
    math=0
    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 -,+
    insplot_set=size 0.8,0.8; noautoscale; border 3;zeroaxis ;linetype 4 lw 3 ; tmargin 1 ; rmargin 1 ; grid linetype 2 ; xtics 1 ; ytics 1
    !for p=1 to $options
	Y$p=$empty
	ex$p=$empty
	xtabel=$empty
	ytabel=$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
	    # set functie x/y waarden van xmin-xmax
	    y=!replace internal x by $s in $f
	    y=$[$y]
	    Y$p=!append item $y to $(Y$p)
	    xtabel=!append line <td>$s</td> to $xtabel
	    ytabel=!append line <td>$y</td> to $ytabel    
	!next s
	ex$p=<table cellpadding="8" border="1" width="100%"><td>x</td>$xtabel<tr><td>y</td>$ytabel</table>
    !next p
    insplot_data=$empty
    x=$[$xmin+1]
    !for s=1 to $num
	y1=!item $s of $(Y$choice)
	y2=!item $[$s+1] of $(Y$choice)
	dy=$[$y2-$y1]
	tot=$[$y1 + $y2]
	insplot_data=!append line $x 0 $dy $dy $dy $tot to $insplot_data
	
	!increase x
	ansdx=!append line <td>1<td> to $ansdx
	ansdy=!append line <td>$dy<td> to $ansdy
    !next s
    ans=<table border="1" cellpadding="8" width="100%"><td>$m_Delta x</td>$ansdx<tr><td>$m_Delta y</td>$ansdy</table>
    insplot_set=size 0.8,0.8; title ;autoscale y ; border 3;zeroaxis ;linetype 4 lw 3 ; tmargin 1 ; rmargin 1 ; grid linetype 2 ; xtics 1 ; ytics 1
    !insplot [$[$xmin-1] : $[$xmax+1]]  "insplot_data" notitle with candlesticks lt 1
    textanswer$n=<table><td>$(ex$choice)</td><tr><td>$ans</td></table>
!endif
!if $R>2
    image=0
    math=0
    draw=0
    plot=0
    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
        x=$xmin
	xtabel=$empty
	ytabel=$empty
	ex$p=$empty
	!for k=1 to $num
	    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)
	    xtabel=!append line <td>$x</td> to $xtabel
	    ytabel=!append line <td>$y</td> to $ytabel
	    !increase x
	!next k
	ex$p=<table cellpadding="8" border="1" width="100%"><td>x</td>$xtabel<tr><td>y</td>$ytabel</table>
    !next p
    tot=$empty
    x=$[$xmin+1]
    !for s=1 to $num
	y1=!item $s of $(Y$choice)
	y2=!item $[$s+1] of $(Y$choice)
	dy=$[$y2-$y1]
	tot=$[$y1 + $y2]    
	insplot_data=!append line $x 0 $dy $dy $dy $tot to $insplot_data
	!increase x
	ansdx=!append line <td>1<td> to $ansdx
	ansdy=!append line <td>$dy<td> to $ansdy
    !next s
    ans=<table border="1" cellpadding="8" width="100%"><td>$m_Delta x</td>$ansdx<tr><td>$m_Delta y</td>$ansdy</table>
    insplot_set=size 0.8,0.8; title ; autoscale y ; border 3;zeroaxis ;linetype 4 lw 3 ; tmargin 1 ; rmargin 1 ; grid linetype 2 ; xtics 1 ; ytics 1
    !insplot [$[$xmin-1] : $[$xmax+1]] "insplot_data" notitle with candlesticks lt 1
    textanswer$n=<table><td>$(ex$choice)</td><tr><td>$ans</td></table>
!endif

