Subversion Repositories wimsdev

Rev

Rev 10581 | Blame | Compare with Previous | Last modification | View Log | RSS feed

# denk aan reply$n = z=sqrt(x) and z=sin(pi*x)
# denk aan sqrt(i),-sqrt(i),5i
# z=arglist i=varlist
# check op meerdere dezelfde antwoorden
# kijkt ook numeriek na... vervang variabele door getal...misschien niet altijd verstandig
# 3/6/2016 : added "pm" as option:  y = ± 5*t (also in mathinput html5 app)

n=$counter
goback=0
errortext=$empty
# questionmark escape
!if ? isin $(reply$n)
 remark$n=$NOK
 goback=0
 maxscore=0
 !exit
!endif

# !if $wims_user=supervisor or ~ isin $module
#  test=!itemcnt $(answer$n)
#  !if $test=0 
#   errortext=Supervisor, the good answer should be a comma-list like<br />\
#   z=sqrt(x),sin(pi*x)<br />\
#   z=sqrt(i),-sqrt(i),5i\
#   <br />Use: arglist=z <br />varlist=i
#   goback=1
#   !exit
#  !endif
# !endif

factor=1
check=0
wims_rawmath_variables=$varlist
# check on too long answers 
test1=!wordcnt $(reply$n)
test2=!itemcnt $(reply$n)
!if $test1 > $wordmax or $test2>$wordmax
 maxscore=$[$maxscore*$P3]
 goback=1
 errortext=!record 48 of $remarkdir/commonremarks.$taal
!endif

# caseinsensitive    
AAA=!lower $(reply$n)
    
# antwoord z=123*i en z=-123*i
test=!replace internal = by @ in $AAA
!if @ notin $test
 byv=1
 !for p in $arglist
  random=!randint -100,100
  testvar=!append line <br />$p<sub>$byv</sub>=$random<br /> to $testvar
  !increase byv
 !next p
 errortext=!record 53 of $remarkdir/commonremarks.$taal
 goback=1
 maxscore=$[$maxscore*$P4]
 !exit
!endif
    
testvar=$empty
varcnt=!itemcnt $varlist
!for p in $varlist
 !if $p isin $AAA
  !increase check
 !else
  testvar=!append word $p to $testvar
 !endif
!next p

!if $check != $varcnt
 !if $complex=1
  ex=!record 86 of $remarkdir/commonremarks.$taal
 !else
  ex=!record 54 of $remarkdir/commonremarks.$taal
 !endif
 !if $teaching=1
  maxscore=$[$P4*$maxscore]
  errortext=$ex
  goback=1
  !exit
 !else
  extra=$ex
  maxscore=$[$P6*$maxscore]
 !endif
!endif

# not needed if mathinput app is used 6/2016    
!if pm isin $AAA
 # y= pm 5*x
 # y = ±5*x
 A1=!replace internal pm by + in $AAA
 A2=!replace internal pm by -1* in $AAA
 AAA=$A1 and $A2
 # mathml
 reply$n=!replace internal pm by $ \pm $ in $(reply$n)
!endif

# dus het leerling antwoord is "x=-5y or x=-y+4" enz
AAA=!nospace $AAA
!for p in or,and,en,of,et,ou
 AAA=!replace internal $p by , in $AAA
!next p
# dus het leerling antwoord is "x=-5y,x=-y+4" enz
!for p in $arglist
 AAA=!replace $p[_0-9]*= by , in $AAA
!next p
# dus het leerling antwoord is ",-5y,,-y+4" enz
AAA=!replace internal ,, by , in $AAA
# dus het leerling antwoord is ",-5y,-y+4" enz
t=!char 1 of $AAA
!if $t=,
 AAA=!char 2 to -1 of $AAA
!endif    
t=!char -1 of $AAA
!if $t=,
 AAA=!char 1 to -2 of $AAA
!endif    
# dus het leerling antwoord is "-5y,-y+4" enz

# wetenschappelijke notatie
AAA=!replace internal ** by ^ in $AAA
AAA=!replace internal e+ by *10^ in $AAA
AAA=!replace internal e- by *10^- in $AAA
AAA=!replace internal ** by * in $AAA
# sinx --> sin(x) 
!for i in sin,cos,tan,log,ln,abs,sqrt,sec
 !if $i isin $AAA
  tt=!replace internal $i( by @ in $AAA
  !if @ notin $tt
   maxscore=$[$P1*$maxscore]
   getal=!randitem 1,2,3,4
   testvar1=!nospace $i ( $getal )
   testvar2=!nospace $i $getal
   goback=1
   errortext=!record 19 of $remarkdir/commonremarks.$taal
   !exit
  !else
   I=!toupper $i
   AAA=!replace internal $i by $I in $AAA
  !endif
 !endif 
!next i

!for i in pi,i,$varlist
 !if $i isin $AAA
  I=!toupper $i
  AAA=!replace internal $i by $I in $AAA
 !endif 
!next i

AAA=!replace [a-z\~\!\@\#\$\%\&\_\:\=\;\"\'\<\>] by $empty in $AAA
AAA=!lower $AAA

# rawmath op elk item van $AAA
!for p in $AAA
 p=!rawmath $p
 tot=!append item $p to $tot
!next p
AAA=!nospace $tot

testvar1=!itemcnt $(answer$n)    
testvar2=!itemcnt $AAA
!if $testvar2 != $testvar1
 !if $testvar2>$testvar1
  maxscore=$[$maxscore*$testvar1/($testvar2)]
 !else
  maxscore=$[$maxscore*$testvar2/($testvar1)]
 !endif    
 ex=!record 50 of $remarkdir/commonremarks.$taal
 !if $extra=$empty
  extra=$ex
 !else
  extra=$extra <br />$ex
 !endif
!endif

!if $rounding <=0
 # not applicable
 afr1=1000
 afr2=100
!else
 afr1=$rounding
 afr2=$[$rounding/10]
!endif

# we vervangen de -eventuele- variabele door een getal...       
parivraag1=$empty
parivraag2=$empty
parivraag3=$empty
GGG=$(answer$n)
cnt=0
omgedraaid=0
!if $varlist != $empty
 t1=!itemcnt $AAA
 g=$empty
 a=$empty
 num=2
 !for i in $varlist
  !for p in $GGG
   p=!replace internal $i by ($num) in $p
   p=$[$p]
   g=!append item $p to $g
  !next p
  !for p in $AAA
   p=!replace internal $i by ($num) in $p
   p=$[$p]
   a=!append item $p to $a
  !next p
 !next i
 GGG=$g
 AAA=!listuniq $a
 t2=!itemcnt $AAA
 !if $t1 != $t2
  testvar=$[$t1-$t2+1]
  ex=!record 51 of $remarkdir/commonremarks.$taal
  !if $extra=$empty
   extra=$ex
  !else
   extra=$extra <br />$ex
  !endif
 !endif
 !for p in $GGG
  p=!replace internal = by , in $p
  p1=!item -1 of $p
  p2=$[round($afr1*($p))]
  p3=$[round($afr2*($p))]
  !for q=1 to $t2
   s1=!item $q of $AAA
   s2=$[round($afr1*($s1))]
   s3=$[round($afr2*($s1))]
   parivraag1=!append line if( abs(($p1) - ($s1))<10^-15 ,1,0) to $parivraag1
   parivraag2=!append line if( abs(($p2) - ($s2))<1/(10*$afr1) ,1,0) to $parivraag2
   parivraag3=!append line if( abs(($p3) - ($s3))<1/(10*$afr2) ,1,0) to $parivraag3
   !increase cnt
  !next s
 !next p
!else
 # dus geen variabelen...
 t1=!itemcnt $AAA
 # twee of meer dezelfde antwoorden?
 AAA=!listuniq $AAA
 t2=!itemcnt $AAA
 !if $t1 != $t2
  ex=!record 51 of $remarkdir/commonremarks.$taal
  testvar=$[$t1-$t2+1]
  !if $extra=$empty
   extra=$ex
  !else
   extra=$extra <br />$ex
  !endif
 !endif
 !for p1 in $(answer$n)
  p2=$[round($afr1*($p1))]
  p3=$[round($afr2*($p1))]
  !for q=1 to $t2
   s1=!item $q of $AAA
   s2=$[round($afr1*($s1))]
   s3=$[round($afr2*($s1))]
   parivraag1=!append line if( abs(($p1) - ($s1))<10^-15 ,1,0) to $parivraag1
   parivraag2=!append line if( abs(($p2) - ($s2))<1/(10*$afr1) ,1,0) to $parivraag2
   parivraag3=!append line if( abs(($p3) - ($s3))<1/(10*$afr2) ,1,0) to $parivraag3
   !increase cnt
  !next s
 !next p            
!endif

# parivraag1 is altijd exact...
# parivraag2 is normaal
# parivraag3 is sloppy
    
!if NaN isin $parivraag1,$parivraag2,$parivraag3
 testvar=$(reply$n)
 goback=1
 maxscore=$[$P4*$maxscore]
 errortext=!record 26 of $remarkdir/commonremarks.$taal
 !exit
!endif

tot1=!exec pari $parivraag1
tot2=!exec pari $parivraag2
tot3=!exec pari $parivraag3

#exotext=AAA=$AAA<br />GGG=$GGG <br />$tot1=tot1=$parivraag1 <br />$tot2=tot2= $parivraag2 <br />$tot3=tot3=$parivraag3<br /> ccc=$ccc <br />ggg=$GGG<br /> AAA=$AAA
#goback=1
#!exit

!if $wims_exec_error != $empty
 testvar=$(reply$n)
 maxscore=$[$P4*$maxscore]
 goback=1
 errortext=!record 26 of $remarkdir/commonremarks.$taal
 !exit
!endif

tussenscore1=0
tussenscore2=0
tussenscore3=0
tussenscore=0
!for p=1 to $cnt
 tt1=!line $p of $tot1
 tt2=!line $p of $tot2
 tt3=!line $p of $tot3
 tussenscore1=$[$tt1+$tussenscore1]
 tussenscore2=$[$tt2+$tussenscore2]
 tussenscore3=$[$tt3+$tussenscore3]
!next  p

# rounding =0 --> 'exact' dus parivraag1
!if $rounding > 0
 tussenscore=$[(2*$tussenscore2+$tussenscore3)/3]
 !if $tussenscore3>$tussenscore2
  ex=!record 30 of $remarkdir/commonremarks.$taal
  extra=$extra<br /> $ex
 !endif
!else
 tussenscore=$[(4*$tussenscore1+2*$tussenscore2+$tussenscore3)/7]    
 !if $tussenscore2>$tussenscore1
  ex=!record 29 of $remarkdir/commonremarks.$taal
  extra=$extra<br /> $ex
 !endif
!endif

score=$[$tussenscore/($testvar1)]
maxscore=$[$maxscore*$score]
modulescore=$[$modulescore + $maxscore]

!if $maxscore>0.9
 remark$n=$OK
!else
 !if $maxscore>0.5
  remark$n=$BOK
 !else
  remark$n=$NOK
 !endif
!endif

!if $extra != $empty
 remark$n=!append line $ <br />$extra $ to $(remark$n)
!endif

goback=0
!exit