Rev 5715 | Rev 5857 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
# 11/11/2011...
# incompatible met oude number.proc !!!
# answer: x=123 --> arglist=x
# reply$n: x1=3 en x2=sqrt(e^ pi),x3=4 en x4=sqrt(e/ pi),x5=5 en x6=5 + sqrt(e + pi),x7=6 en x8=1 - sqrt(e - pi)
# bewerken van antwoord:
# invulveld 1: x1=3 en x2=sqrt(e^ pi)
# invulveld 2: x3=4 en x4=sqrt(e/ pi)
# invulveld 3: x5=5 en x6=5 + sqrt(e + pi)
# invulveld 4: x7=6 en x8=1 - sqrt(e - pi)
#
# filtered_rep wordt dan
# 3,sqrt(e^ pi)\
# 4,sqrt(e/pi)\
# 5,5+sqrt(e+pi)
# 6,1-sqrt(e-pi)
# meerdere antwoorden in 3 invulvelden:(lines per invulveld)
# answer$n=ans1,ans2,ans3\
# ans4\
# ans5,ans6
# binnen een regel / invulveld is volgorde onbelangrijk <---
# tussen invulvelden / regels is volgorde wel belangrijk <---
# getallen kunnen per invulveld / antwoordregel een range hebben
# var1=range1,0,0,range5,0,range6 .... dus 6 invulvelden...
# answer - range1 <= reply <= answer + range1
# bijv:
# var1=0,0,0.01,0.5
# answer1=123\ # geen range
# 456, 7899,4534535\ # geen range
# 0.789 0.324\ # wel range +/- 0.01
# 12.5 # wel range +/- 0.5
# var2 --> rounding per invulveld...analoog aan var1...meerdere antwoorden in 1 invulveld gelijke afronding
# var2=-1,-1,100,100000,0
# Let op:
# bij complexe getallen i=10 ...
# vervang i door 10 in answer$n !!! anders problemen met nakijken...
# 2/2012 arglist=x : x=123 and x_2=344 and x3=134
# echo "x=pi en x1=234432 en x_2=2345424 en x12345=453535" | sed 's/x[_0-9]*=//g' --> pi en 234432 en 2345424 en 453535
goback=0
errortext=$empty
n=$counter
!if $(reply$n)=?
reply$n=$dontknow
remark$n=$NOK
goback=0
maxscore=0
!exit
!endif
ta=!itemcnt $(reply$n)
reply$n=!replace internal @ by $empty in $(reply$n)
reply$n=!replace internal # by $empty in $(reply$n)
filtered_rep=$empty
extra=$empty
!for p=1 to $ta
rep=!item $p of $(reply$n)
!if ? isin $rep
filtered_rep=!append line ? to $filtered_rep
!else
rep=!tolower $rep
rep=!singlespace $rep
# x1 = 4 en x2 = 3 + sqrt(e ^3)
# nospace ( ... ) -> words2items geeft anders problemen sin( pi + 3 ) -> sin(,pi+3,)
test=!replace internal ( by @ in $rep
# x1 = 4 en x2 = 3 + sqrt( e ^3 )
!if @ isin $test
test=!replace internal ) by % in $test
tot=!charcnt $test
wait=0
got=0
end=0
a=0
first=0
!for s=1 to $tot
ch=!char $s of $test
!if $ch=@
!if $first=0
begin=$s
first=1
!endif
!increase wait
!endif
!if $ch=%
!increase got
!endif
!if $got !=0
!if $wait=$got
!increase a
match$a=!char $begin to $s of $rep
first=0
!endif
!endif
!next s
!for s=1 to $a
nospace_match=!nospace $(match$s)
rep=!replace internal $(match$s) by $nospace_match in $rep
!next s
!endif
# x1 = 4 en x2 = 3 + sqrt(e ^3)
!for a in +,-,*,/,^
A=$ $a
rep=!replace internal $A by $a in $rep
A=$a $
rep=!replace internal $A by $a in $rep
!next a
# x1 = 4 en x2 = 3+sqrt(e^3)
rep=!words2items $rep
# x1,=,4,en,x2,=,3+sqrt(e^3)
# 2/2012 problemen met x_1= moet met maar met sed :(
# x1,,,4,,,x2,,,3+sqrt(e^3)
!if $arglist != $empty
!for a in $arglist
a=!lower $a
rep=!replace $a[_0-9]*= by , in $rep
#rep=!replace internal $a by , in $rep
!next a
!endif
!for a in =>,->,==>,-->,=,is,est,en
rep=!replace internal $a by , in $rep
!next a
# ,,,,4,,,,,,,3+sqrt(e^3)
!for a=1 to 5
rep=!replace internal ,, by , in $rep
!next a
# ,4,3+sqrt(e^3)
!for a in pi,abs,sin,cos,tan,atan,acos,asin,sqrt,log,ln
A=!toupper $a
rep=!replace internal $a by $A in $rep
!next a
!if e isin $rep
!for a in *e,e*,+e,e+, e,e ,-e,e-,/e,e/,^e,e^
A=!toupper $a
rep=!replace internal $a by $A in $rep
!next a
!endif
!if i isin $rep
# vervang i door een getal...geen problemen met "afronden" en met pari "I"
list1=*10,10*,+10,10+, 10,10 ,-10,10-,/10,10/,^10,10^
list2=*i,i*,+i,i+, i,i ,-i,i-,/i,i/,^i,i^
!for a=1 to 12
rep=!replace internal $(list2[$a]) by $(list1[$a]) in $rep
!next a
!endif
rep=!replace [a-z\~\!\@\#\$\%\&\_\;] by $empty in $rep
rep=!lower $rep
rep=!nospace $rep
t_tmp=!itemcnt $rep
tmp=$empty
tc_tmp=0
!for a=1 to $t_tmp
A=!item $a of $rep
!if NaN notin $[1*($A)]
A=!rawmath $A
tc_tmp=1
tmp=!append item $A to $tmp
!else
extra=!append line <strike> <font color="red"><b>$A</b></font> </strike> <br /> to $extra
!endif
!next a
!if $tc_tmp=0
ex=!record 36 of $remarkdir/commonremarks.$taal
!if $teaching=1
errortext=$ex
goback=1
maxscore=$[$P3*$maxscore]
!else
maxscore=0
remark$n=$NOK<br />$ex
goback=0
!endif
!exit
!endif
# bewaar de hoeveelheid items in rep
filtered_rep=!append line $tmp to $filtered_rep
!endif
!next p
# nakijken
#errortext=filtered_rep=$filtered_rep
#goback=1
#!exit
lg=!linecnt $(answer$n)
!if $var1 != $empty
lv=!itemcnt $var1
!if $lg != $lv
errortext=<b>var1</b> is itemlist reserverd for an acuracy range<ul><li> answer − range1 ≤ reply &le answer + range1</li><li>1 range per inputfield !!</li><li>answer$n format:<br />1 line per inputfield<br />multiple answers allowed per inputfield<br />however the range will be the same for all answers.</li><li>use -1 for no range</li><li>declare var1=0.125,-1,2.5,-1</li></ul>
goback=1
!exit
!endif
use_range=1
!else
use_range=0
!endif
!if $var2 != $empty
lv=!itemcnt $var2
!if $lg != $lv
errortext=<b>var2</b> is itemlist reserved for rounding<br />use var2=100,-1,1000
goback=1
!exit
!endif
multiple_rounding=$var2
!else
!for p=1 to $lg
multiple_rounding=!append item $rounding to $multiple_rounding
!next p
!endif
!if $lg>1
begin_ul=<ol>
end_ul=</ol>
!else
begin_ul=<ul>
end_ul=</ul>
!endif
la=!linecnt $filtered_rep
checks=0
!if $lg != $la
errortext=!record 38 of $remarkdir/commonremarks.$taal
#errortext=la=$la lg=$lg answer$n=$(answer$n) filtered_rep=$filtered_rep
goback=1
!exit
!endif
wims_exec_error=$empty
score=0
!for a=1 to $la
#lines in answer$n
# range per answer-line/inputfield
!if $use_range=1
range=!item $a of $var1
!else
range=0
!endif
# rounding per answer-line/inputfield
rnd=!item $a of $multiple_rounding
show_reply=!append word <li> to $show_reply
replies=!line $a of $filtered_rep
answers=!line $a of $(answer$n)
testvar2=!itemcnt $replies
testvar1=!itemcnt $answers
!if $testvar1>1
# needed for checking combined (single inputfield) answers like 1,-1 != replies -1,1
# !sort numeric : will preserve sqrt(2),sin(pi)
answers=!sort numeric item $answers
!endif
!if $testvar2>1
# needed for checking answers like -1,1 != replies 1,-1
replies=!sort numeric item $replies
!endif
checks=$[$checks + $testvar1]
rem1=$empty
!if $testvar2!=$testvar1
maxscore=$[$maxscore*(min($testvar1,$testvar2))/(max($testvar1,$testvar2))]
rem1=!record 50 of $remarkdir/commonremarks.$taal
rem1=<br />$rem1
#Je hebt $testvar2 antwoord(en) ingeleverd in plaats van $testvar1
!endif
!for p=1 to $testvar1
A=!item $p of $replies
!if $A != $empty
org=$A
k=red
!if ? notin $A
found=0
!for g=1 to $testvar1
!if $found=0
G=!item $g of $answers
!if $rnd>0
# geen exact antwoord verwacht
A=$[(round($rnd*($A)))/$rnd]
G=$[(round($rnd*($G)))/$rnd]
!if $[$A+$range] >= $G and $[$A-$range] <= $G
!increase score
k=green
found=1
!if $range != 0
!if $A!=$G
# antwoord is dus correct dankzij +/-range
rem2=!record 96 of $remarkdir/commonremarks.$taal
rem2=!append word $ ( +/− $range ) $ to $rem2
!endif
!endif
!else
!if $teaching=1
!if $[$A+$range]>=$[-1*($G)] and $[$A-$range]<=$[-1*($G)]
score=$[$score+0.1]
#je antwoord × -1 was wel goed geweest...
!if $range != 0
rem2=<font color=red>−1 × ( $A +/- $range )</font> ≈ <font color=green>$G</font>
!else
rem2=<font color=red>−1 × $A</font> = <font color=green>$G</font>
!endif
k=red
found=1
!else
!for f in 10,100,1000,100000,0.1,0.01,0.001,0.0001,0.00001
!if $fnd=0
!if $[($A)*$f]=$G
found=1
rem2=!record 90 of $remarkdir/commonremarks.$taal
#je antwoord × $f was wel goed geweest...
!endif
!endif
!next f
!if $found=0
!if $[1/($A)]=$G
score=$[$score+0.1]
rem2=<font color=red>1 / $A</font> = <font color=green>$G</font> :(
#de reciproce van je antwoord was wel goed geweest...
found=1
!endif
!endif
!endif
!endif
!endif
!else
#rnd=-1 of rnd=0
!if $range=0
f=!exec pari if( abs(($A) - ($G)) < 10^(-15) || 1.0*($A) == 1.0*($G) , 1 , v=[-1,10,100,1000,10000,100000,1/10,1/100,1/1000,1/10000,1/100000] ; for( a = 1, 10 , if( v[a]*($A) == 1.0*($G), print(v[a]) , 0 ) ))
!else
# exact...range is dus een beetje onzin...
f=!exec pari if( 1.0*($A)+$range >= 1.0*($G) && 1.0*($A)-$range <= 1.0*($G) , 1 , v=[-1,10,100,1000,10000,100000,1/10,1/100,1/1000,1/10000,1/100000] ; for( a = 1, 10 , if( v[a]*($A) == 1.0*($G), print(v[a]) , 0 ) ))
!endif
!if $wims_exec_error = $empty
!if $f=1
found=1
k=green
score=$[$score+1]
!if $range != 0
!if $A!=$G
rem2=!record 96 of $remarkdir/commonremarks.$taal
rem2=!append word $ (+/− $range) $ to $tem2
#Je antwoord ligt binnen de nauwkeurigheids grenzen (+/- $range)
!endif
!endif
!else
!if $teaching=1
!if $f != $empty
score=$[$score+$P9]
found=1
rem2=!record 90 of $remarkdir/commonremarks.$taal
#je antwoord × $f was wel goed geweest...
!else
!if $[1/($A)]=$G
found=1
score=$[$score+$P8]
rem2=<font color=green> 1/</font><font color=red>$A</font> = <font color=green>$G</font> :(
#de reciproce van je antwoord was wel goed geweest...
!endif
!endif
!endif
!endif
!else
errortext=$wims_exec_error
#!record 26 of $remarkdir/commonremarks.$taal
goback=1
!exit
!endif
!endif
!if $found=1
!if $rnd>0 or $range!=0
show_reply=!append line <font color="$k"><b>$org ≈ $A</b></font><em><br />$rem2</em><br /> to $show_reply
!else
show_reply=!append line <font color="$k"><b>$org</b></font><em><br />$rem2</em><br /> to $show_reply
!endif
rem2=$empty
!endif
!endif
!next g
!if $found=0
!if $rnd>0 or $range!=0
show_reply=!append line <font color="red"><b>$org ≈ $A</b></font> to $show_reply
!else
show_reply=!append line <font color="red"><b>$org</b></font> to $show_reply
!endif
rem2=$empty
!endif
!endif
!endif
!next p
show_reply=!append word $rem1</li> to $show_reply
!next a
maxscore=$[$maxscore*$score/$checks]
modulescore=$[$modulescore + $maxscore]
reply$n=$(reply$n) $begin_ul $show_reply $end_ul
!if $maxscore>0.9
remark$n=$OK
!else
!if $maxscore >0.45
remark$n=$BOK
!else
remark$n=$NOK
!endif
!endif
math=0
!exit