
good=!singlespace $(replygood$i)
good=!trim $good
good=!rows2lines $good
good=!line 1 of $good
good=!translate | to $\
$ in $good
good=!nonempty lines $good
replyGood$i=!line 1 of $good
replyGood$i=!items2words $(replyGood$i)
dd=$(reply$i)

!if r$i notitemof $thisstep
 !goto nocheck
!endif

!if $i notitemof $fill_checked
 fill_checked=!append item $i to $fill_checked
 dd2=
 !for d_ in $dd
  !if $d_ isitemof $fill_check
   dd2=!append item $d_ to $dd2
   !if $(replytype$i)=dragfill
    pos=!positionof item $d_ in $fill_check
    pos=!item 1 of $pos
    !if $pos!=$empty
     fill_check=!replace item number $pos by $ in $fill_check
    !endif
   !endif
  !else
   dd2=!append item ?????? to $dd2
  !endif
 !next d_
 dd=$dd2
 !if $(replytype$i)=dragfill
  fill_check=!nonempty items $fill_check
 !endif
!endif

:nocheck
reply$i=$dd
m_reply$i=$dd
reply_$i=!items2words $dd

!if $wims_read_parm=nocompare
 !exit
!endif

!if $good=$empty
 Test=bad $i
 !exit
!endif

diag=
diaratio=-1
t_=!linecnt $good
good=!replace internal , $ by , in $good
dd=!replace internal , $ by , in $dd
ddo=!sort items $dd
!for n=1 to $t_
 g=!line $n of $good
 g=!trim $g
 !if $dd issametext $g
  diag=yes
 !endif
 !if noorder iswordof $(replyoption$i)
   go=!sort items $g
   !if $ddo issametext $go
     diag=yes
   !endif
   !if $diag notwordof yes and (split iswordof $(replyoption$i) or partialscore iswordof $(replyoption$i))
!! nombre de reponses
       poscnt1=!itemcnt $ddo
       lint=!listintersect $ddo and $go
!! nombre de bonnes reponses
       poscnt2=!itemcnt $lint
!! nombre demand de bonnes rponses
       poscnt3=!itemcnt $go
       !if eqweight iswordof $(replyoption$i)
         diaratio_=$[2*$poscnt2 - $poscnt1]
       !else
         diaratio_=$[3*$poscnt2 - 2*$poscnt1]
       !endif
       !if $diaratio_ > 0
        diaratio=$[max($diaratio,$[$diaratio_/max($poscnt3,1)])]
       !endif 
   !endif split
 !endif noorder
!next n
       
!if $diag=yes
 diareply$i=good
 !advance freegot
!else
  !if $diaratio > 0 and (split iswordof $(replyoption$i) or partialscore iswordof $(replyoption$i))
    diareply$i=good
    partialgood$i=yes
    freegot=$[$freegot+ max(0,$diaratio)]
  !else
    diareply$i=bad
  !endif
!endif