#list_of_things=['point','line','segment','circle','function','polygon','cone','ellipse','polynomial']
#customToolBar=0 , 1 , 10 , 16 , 6
# alleen integers in ggb file !! decimalen=0
n=$counter
R=$level
!if $level=0
    R=$counter
!endif
# van tabel naar geogebra
checkfile=exos/checkfile2.proc
# speciale geval voor rechte lijn als tekening/antwoord var1=1 : rechte var1=0 niks
var1=0

#GeoGebra
list_of_things=[ 'line','segment','point' ];
customToolBar=" 0 | 15 || 40 | 41 | 42 | 6 "
appletcommand=$empty
ggb=ggb/grid1.ggb
showToolBar=true
showMenuBar=false
framePossible=false
width=640
height=480
image=0
# GnuPlot
XSIZE=440
YSIZE=440
insplot_data=$empty
wordmax=300
math=0
questiontype=4
inputs=0
exotext=!record 26 of lang/remarks.$taal
#@ Klik hier</a> voor de <b>grafiek</b> van de tabel
exotext=<a href="javascript:showimage();">$exotext
helptext=!record 17 of lang/remarks.$taal
#@ <em>GeoGebra</a> help pagina's</em>

question$n=!record 18 of lang/remarks.$taal
#@ Gegeven is de onderstaande tabel.<br>Teken in de GeoGebra applet een <b>toenamendiagram<b> met stapgrootte <b>1</b> van deze tabel.<p>

!if $R=1
    xmin=0
    xmax=6
    segments=$[$xmax-$xmin]
    points=$[2*$segments]
    a=!randitem 0,1,2
    b=!randitem 3,4,5,6
    c=!randitem -2,-1,-1,2,3
    autoscale=noautoscale y
    functie=$c*(x-$a)*(x-$b)
    texanswer$n=!exec pari printtex($functie)
    texanswer$n=f(x)\,=\,$(texanswer$n)
    tabel=$empty
    !for x=0 to $xmax
	y=!evalsubst x=$x in $functie
	y=$[$y]
	YY=!append item $y to $YY
	xtabel=!append line <td>$x</td> to $xtabel
	ytabel=!append line <td>$y</td> to $ytabel
    !next x
    question$n=$(question$n)<p><table bgcolor="white" border="1" cellpadding="10"><td>x</td>$xtabel<tr><td>y</td>$ytabel</table>
    Y=0
    !for x=1 to $[$xmax] 
	y1=!item $x of $YY
	y2=!item $[$x+1] of $YY
	y=$[$y2-$y1]
	answer$n=!append item $x,0 to $(answer$n)
	answer$n=!append item $x,$y to $(answer$n)
	textanswer$n=!append line <li>Segment ($x:0) -- ($x:$y) - $m_Delta y=$y </li>  to $(textanswer$n)	
    !next x
!endif

!if $R>1
    a=!randitem 0,1,2,3
    b=!randitem 1,2,3,4,5,6
    c=!randitem -2,-1,-1,2,3
    d=!randitem 5,6,7
    xmin=$[-1*$a-2]
    xmax=$[$xmin + $d]
    segments=[$xmax-$xmin]
    points=$[2*$segments]
    autoscale=noautoscale y
    functie=$c*(x+$a)*(x-$b)
    texanswer$n=!exec pari printtex($functie)
    texanswer$n=f(x)\,=\,$(texanswer$n)\,\,\,met\,\,D_f=[$xmin,$xmax]
    !for x=$xmin to $xmax
	y=!evalsubst x=$x in $functie
	y=$[$y]
	YY=!append item $y to $YY
	xtabel=!append line <td>$x</td> to $xtabel
	ytabel=!append line <td>$y</td> to $ytabel
    !next x
    question$n=$(question$n)<p><table bgcolor="white" border="1" cellpadding="10"><td>x</td>$xtabel<tr><td>y</td>$ytabel</table>
    Y=0
    x=$[$xmin+1]
    !for p=1 to $[$xmax-$xmin] 
	y1=!item $p of $YY
	y2=!item $[$p+1] of $YY
	y=$[$y2-$y1]
	answer$n=!append item $x,0 to $(answer$n)
	answer$n=!append item $x,$y to $(answer$n)
	textanswer$n=!append line <li>Segment ($x:0) -- ($x:$y) - $m_Delta y=$y to $(textanswer$n)
	!increase x	
    !next p
!endif

# toename diagram plaatje voor bij de som via $session/insert-1.gif 
# alle !insmath hiervoor geven dus trouble
insplot_set=size 1.0,1.0; $autoscale ; border 3; zeroaxis linetype 4 lw 3 ; tmargin 1 ; rmargin 1 ; grid linetype 2 ; xtics 1 ; ytics 1 
!insplot [0:$xmax] $functie notitle lt 1

