!set n=$teller
VLINE=$empty
HLINE=$empty
HTEXT=$empty
VTEXT=$empty
BALK=$empty
soort=0
bewerking=bewerking1.proc
!if $graad=0
    R=$teller
!else
    R=$graad
!endif        
woordmax=10
!if $taal=nl 
    eiland=!randitem Texel,Vlieland,Ameland,Schiermonnikoog,Terschelling,Helgoland,Rottummeroog,de Shetland Eilanden,de Kaaiman eilanden,de Kaapverdische eilanden,De Azoren,het Paaseiland
    artikelen=!randitem bierblikjes,tennisballen,schoenen,zonnebrillen,flessen,lege vaten,lege oliedrums,kapotte roeiboten,kapotte visnetten,containers,stukken piepschuim,koelkasten,lege jerrycans
    mensen=!randitem vakantiegangers,dagjesmensen,toeristen,strandjutters,wadlopers,eilandbewoners
    aantal=aantal
!else
    eiland=!randitem the Isle of Mann,Guernsey,Jersey,the Shetland islands,Orkney,Texel,Hawaii,the Fiji islands,Easter Island,the Maldiven,Falklands,Corsica,Ibiza,Mallorca
    artikelen=!randitem beercans,beerbottles,bottles,empty barrels,oil drums,broken sunglasses,refrigerators,jerrycans,shoes
    mensen=!randitem day-trippers,holliday makers,tourists,inhabitants,beachcombers
    aantal=amount of 
!endif

aantal_jaren=!randint 6,14
eind_jaar=!randint 1955,2004
begin_jaar=$[$eind_jaar - $aantal_jaren]

factor=!randint 2,5
!for p=1 to $aantal_jaren
    getallen=!append item $[$p*$factor] to $getallen
    alles_bijelkaar=$[$alles_bijelkaar+ $p*$factor]
!next p
max_getal=!item -1 of $getallen 
min_getal=!item 1 of $getallen 
getallen=!shuffle $getallen
r=0
totaal=0
bewegen=0
    HLINE=hline 0,0,blue
    VTEXT=text black,$[$begin_jaar-1],0,normal,0
    kleur=!randitem red:rood:rode,blue:blauw:blauwe,green:groen:groene,orange:oranje:oranje
    kleur=!replace internal : by , in $kleur
    kleur_en=!item 1 of $kleur
    !if $taal=nl
	kleur_nl=!item 2 of $kleur
    !else
	kleur_nl=$kleur_en
    !endif	
    kleurig=!item 3 of $kleur
    !if $printbaar=0
	white=white
    !else
	white=cyan
	kleur_en=grey
    !endif        

    !for p=1 to $aantal_jaren
	jaar=$[$begin_jaar+$r]
	getal=!item $p of $getallen
	lijst=!append item $jaar:$getal to $lijst
	!if $getal=$min_getal
	    min_jaar=$jaar
	!endif
	!if $getal=$max_getal
    	    max_jaar=$jaar	
	!endif
	totaal=$[$totaal+$getal]
        VLINE=!append line segment $jaar,0,$jaar,$[$max_getal+2],blue to $VLINE
	HLINE=!append line dhline 0,$getal,blue to $HLINE 
	HTEXT=!append line text black,$[$jaar-0.3],-1,normal,$jaar to $HTEXT
	VTEXT=!append line text black,$[$begin_jaar-1],$getal,normal,$getal to $VTEXT
        BALK=!append line frect $[$jaar-0.35],0,$[$jaar+0.35],$getal,$kleur_en to $BALK
        !increase r
    !next p
insdraw_size=500,500
plaatje$n=400,400\
transparent $white\
xrange $[$begin_jaar-1],$[$eind_jaar+1]\
yrange -5,$[$max_getal+5]\
$VTEXT\
$HTEXT\
$HLINE\
$VLINE\
$BALK\
textup black,$begin_jaar-0.5,0.6*$max_getal,normal,$aantal $artikelen

!if $taal=nl
    somtekst$n=Elk jaar wordt op $eiland geturft hoeveel $artikelen er <br>op het strand worden gevonden door $mensen.<br>
    <small>de aantallen zijn mooie ronde getallen...</small>
    meest=!randitem meest,minst
    !if $HINT=1
	hint=wil je weten hoeveel $artikelen er zijn aangespoeld in een bepaald jaar,<br>\
	dan zoek je eerst op de <em>horizontale-as</em> het goede jaartal...<br>\
	vervolgens ga je recht naarboven tot waar de <font color=$kleur_en>$kleurig balk</font> eindigt<br>\
	en lees dan op de linker vertikale as de hoeveelheden $artikelen af.<br>\
	Lijkt me wel te doen, $voornaam
    !endif
    nivo_title=Bekijk de grafiek (staafdiagram).<br>Bereken en vul in.	

!else
    somtekst$n=On $eiland every year the amount $artikelen washed ashore are counted...<br>\
    <small><em>the figures are round numbers</em></small>
    meest=!randitem most,least
    !if $HINT=1
	hint=If you want to now how many $artikelen were washed ashore in a particular year;<br>\
	first try to find the correct year on the horizontal axis<br>\
	the next thing is to folow the <font color=$kleur_en>$kleurig bar</font> until it ends<br>\
	then look to the left axis and read the amount of $artikelen...
    !endif
    nivo_title=Examine the graph (barchart).<br>Calculate and fill in the blanc.	
!endif

soort=$empty

!if $R=1
    soort=1
    !if $taal=nl
        opgave$n=In welk jaar waren dat er het $meest ?
	!if $meest=meest
    	    GOED$n=$max_jaar
	    zoveel=$max_getal
	!else
	    GOED$n=$min_jaar
	    zoveel=$min_getal
	!endif
	antwoord$n=Dat was dus in het jaar $(GOED$n) en er zijn wel $zoveel $artikelen <br>gevonden langs het strand.
    !else
        opgave$n=In what year the $meest ?    
	!if $meest=most
    	    GOED$n=$max_jaar
	    zoveel=$max_getal
	!else
	    GOED$n=$min_jaar
	    zoveel=$min_getal
	!endif
	antwoord$n=that was the year $(GOED$n) <br>and there were $zoveel $artikelen washed ashore.
    !endif
 !exit
!endif

!if $R=2
    soort=2
    keuze=!randitem 1,2
    !if $taal=nl
	!if $keuze=1
    	    opgave$n=Hoe groot is volgens de grafiek het verschil tussen <br>de meeste en de minste gevonden $artikelen ?
    	    GOED$n=$[$max_getal-$min_getal]
	    antwoord$n=Het verschil tussen het maximale aantal $artikelen en het minimale aantal is dus<br>\
	    $max_getal-$min_getal = $(GOED$n) .
	!else
    	    opgave$n=Hoeveel $artikelen  zijn er in't totaal gevonden op $eiland <br>in de getoonde periode? (van $begin_jaar tot $eind_jaar )
    	    GOED$n=$alles_bijelkaar
	    antwoord$n=Het totaal aan " $artikelen " op $eiland is dus $(GOED$n) stuks (gewoon alle kolommen optellen)
	!endif
    !else
	!if $keuze=1
    	    opgave$n=What is the difference between the most and the least amount of $artikelen ?
    	    GOED$n=$[$max_getal-$min_getal]
	    antwoord$n=The difference between the maximum amount of $artikelen and the least amount is<br>\
	    $max_getal-$min_getal = $(GOED$n) .
	!else
    	    opgave$n=How many $artikelen in total were washed ashore in the shown period<br>\
	    (from the year $begin_jaar to $eind_jaar ) .
    	    GOED$n=$alles_bijelkaar
	    antwoord$n=The total amount of  " $artikelen " on $eiland is $(GOED$n) "pieces" (just adding up all bars).
	!endif
    !endif
 !exit    
!endif

!if $R=3
    soort=3
    !if $taal=nl
        opgave$n=Hoe veel jaar zit er tussen het tijdstip waarop het maximum aantal<br>\
	 wordt gevonden en het minimum aantal ?  ($artikelen)<br>\
	<br><small><em>voorbeeldje: stel in 1923 het maximum aantal en in 1928 het minimum<br>\
	dan is het goede antwoord 1998 - 1993 = 5 jaar, Ok?</em></small>
    	GOED$n=$[abs($max_jaar-$min_jaar)]
	antwoord$n=Er zit dus $max_jaar - $min_jaar = $(GOED$n) jaren tussen.
    !else
        opgave$n=How many year between the highest end lowest number (of $artikelen) ?<br>\
	<br><small><em>example: if 1593 has the maximum and 1598 has the minimum<br>\
	the answer is 1598 - 1593 = 5 year, Ok?</em></small>
    	GOED$n=$[abs($max_jaar - $min_jaar)]
	antwoord$n=So there are $max_jaar - $min_jaar = $(GOED$n) year.
    !endif
 !exit
!endif

!if $R=4 
    lijst=!shuffle $lijst
    testjaar1=!item 1 of $lijst
    testjaar2=!item 2 of $lijst
    testjaar1=!replace internal : by , in $testjaar1
    testjaar2=!replace internal : by , in $testjaar2
    jaar1=!item 1 of $testjaar1
    jaar2=!item 1 of $testjaar2
    aantallen1=!item 2 of $testjaar1
    aantallen2=!item 2 of $testjaar2
    !if $taal=nl
	opgave$n=Hoe groot is volgens de grafiek het verschil tussen de aantallen (<em>$artikelen</em>) in het jaar $jaar1 en $jaar2 .
	GOED$n=$[abs($aantallen2-$aantallen1)]
	antwoord$n=Er zijn volgens de grafiek in $jaar1 $aantallen1 $artikelen gevonden<br>\
	en in $jaar2 waren dat er $aantallen2 .<br>Het verschil is dus $aantallen2 - $aantallen1 = $(GOED$n) .
    !else
	opgave$n=What's the difference in the numbers (<em>$artikelen</em>) between the year $jaar1 and $jaar2 .
	GOED$n=$[abs($aantallen2-$aantallen1)]
	antwoord$n=According to the chart there were in the year $jaar1 $aantallen1 $artikelen washed ashore<br>\
	and in $jaar2 there were  $aantallen2 .<br>The difference is $aantallen2 - $aantallen1 = $(GOED$n) .
    !endif
 !exit    
!endif

!if $R>4
    !if $taal=nl
	opgave$n=Hoeveel $artikelen worden er volgens <br>de tabel gemiddeld per jaar op het strand gevonden ?
    	GOED$n=$[$totaal/($aantal_jaren)]
	antwoord$n=Wanneer we alle aantallen $artikelen bij elkaar optellen,<br>\
	krijgen we $totaal $artikelen. <br>Om het gemiddelde per jaar uit te rekenen,<br>\
	delen we dit dus over het totaal aantal jaren dus: $aantal_jaren<br>\
	$totaal/$aantal_jaren = $(GOED$n) aantal $artikelen gemiddeld.
    !else
	opgave$n=How many $artikelen <b>on average</b> <br>are there washed ashore each year ??
    	GOED$n=$[$totaal/($aantal_jaren)]
	antwoord$n=When we add up all " $artikelen "<br>\
	we get a total of  $totaal " $artikelen ". <br>\
	To calculate the yearly average we must divide the total numbers<br>\
	and the total amount of years<br>thus: $totaal/$aantal_jaren = $(GOED$n) " $artikelen " on average.    
    !endif	
!endif





