!if $rounding<1
    rounding=100
!readproc $remarkdir/rounding.$taal
!endif
checkfile=exos/checkfile2.proc
n=$counter
!if $level=0    
    R=$counter
!else
    R=$level
!endif
inputs=0
question$n=!record 42 of lang/remarks.$taal
#@ Vul de tabel in aan de hand van de onderstaande formule
VAR1=!record 43 of lang/remarks.$taal
#@ x,tijd,minuten,dagen,maanden,seconden
VAR2=!record 44 of lang/remarks.$taal
#@ y,hoeveelheid,afstand,opbrengst,omzet,hoogte

r=!randitem 1,2,3,4,5,6
TIJD=!item $r of $VAR1
H=!item $r of $VAR2

tabel1=$empty
tabel2=$empty    
tabel3=$empty
tot=$empty    
helptext=$empty
!if $options < 4 or $options>9
    options=4
!endif

!if $wims_user=supervisor
    readonly=$empty
!else
    readonly=readonly
!endif

keuze=!randitem 1,0
getal=!randint 5,200
p=!randint 80,220
!if $p=100
    p=120
!endif
p=$[$p/100]
!if $R=1
    !for s=1 to $options
	getal$s=$[$s-1]
	tabel1=!append line <th>$(getal$s)</th> to $tabel1
    	tot=!append item $[round($rounding*$getal*$p^($(getal$s)))/(1.0*$rounding)] to $tot
    !next s	
 !goto READY
!endif
    
!if $R=2 
    r=!randitem 2,3,4
    !for s=1 to $options
	getal$s=$[$r*$s-$r]
	tabel1=!append line <th>$(getal$s)</th> to $tabel1
	tot=!append item $[round($rounding*$getal*$p^($(getal$s)))/(1.0*$rounding)] to $tot
    !next s	
 !goto READY
!endif
    
!if $R=3
    r=!randitem 1,2,3,4
    q=!randitem -8,-7,-6,-5,-4,-3,-2
    !for s=1 to $options
	getal$s=$[$q+$r*($s-1)]
	tabel1=!append line <th>$(getal$s)</th> to $tabel1
	tot=!append item $[round($rounding*$getal*$p^($(getal$s)))/(1.0*$rounding)] to $tot
    !next s	
 !goto READY
!endif

!if $R >3
    t=!randitem 1/2,1/3,1/4,3/4,2/3,5/3,7/4,7/3,8/5,9/4,3/8,5/8,7/8,8/9
    !for s=1 to $options
	G=($s*($t))
	pari_vraag=!append line $G to $pari_vraag
	tot=!append item $[round($rounding*$getal*$p^($G))/(1.0*$rounding)] to $tot	
    !next s	
    pari_antwoord=!exec pari $pari_vraag
    !for s=1 to $options
	getal=!line $s of $pari_antwoord
	ans=!item $s of $tot
	answer$n=!append item $ans to $(answer$n)
	tabel1=!append line <th>$getal</th> to $tabel1
	tabel2=!append line <th><input size="8" name="reply$n"></th> to $tabel2
	tabel3=!append line <th><input size="8" name="reply$n" value="$ans" $readonly></th> to $tabel3
    !next s	   
    formula$n= \begin{bf} $H \end{bf} \,\, =\,\, $getal \cdot $p^{^{\begin{bf} $TIJD \end{bf} } }
    textanswer$n=<table border="1" width=50% cellpadding="8" $paperbg><th>$TIJD</th>$tabel1<tr><th>$H</th>$tabel3</table>
    !if $wims_user=supervisor
	exotext=$(textanswer$n)<center><input type="submit" style="$mybuttonstyle" value="$send">
    !else
	exotext=<table border="1" width=50% cellpadding="8" $paperbg><th>$TIJD</th>$tabel1<tr><th>$H</th>$tabel2</table><center><input type="submit" style="$mybuttonstyle" value="$send"> 
    !endif
# important exit !!
 !exit
!endif

# this is only for $R<3
:READY    
!for s=1 to $options
    ans=!item $s of $tot
    answer$n=!append item $ans to $(answer$n)
    texanswer=!append line $TIJD\,=\,$(getal$s) \rightarrow $H\,=\,$ans\\ to $texanswer
    tabel2=!append line <th><input size="8" name="reply$n"></th> to $tabel2
    tabel3=!append line <th><input size="8" name="reply$n" value="$ans" $readonly></th> to $tabel3 
!next s
texanswer$n=\left[ \begin{array}{l} $texanswer \end{array}
formula$n= \begin{bf} $H \end{bf} \,\, =\,\, $getal \cdot $p^{^{\begin{bf} $TIJD \end{bf} } }
textanswer$n=<table border="1" width=50% cellpadding="8" $paperbg ><th>$TIJD</th>$tabel1<tr><th>$H</th>$tabel3</table>
!if $wims_user=supervisor
    exotext=$(textanswer$n)<center><input type="submit" style="$mybuttonstyle" value="$send">
!else
    exotext=<table border="1" width=50% cellpadding="8" $paperbg><th>$TIJD</th>$tabel1<tr><th>$H</th>$tabel2</table><center><input type="submit" style="$mybuttonstyle" value="$send">
!endif

!exit
