1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
|
option:color=" " precision=" " eqweight split default="empty"
!! how to get value of "precision" from canvas code?
!set precision=!getopt precision in $(replyoption$i)
!set tmp=!select $(oef_answer_option$i) where precision iswordof column 1
!default precision=!word 2 of $tmp
!if $precision=0
!reset precision
!endif
!default precision=1000
!set xysize=!line 1 of $(oef_answer_option$i)
!set replygood$i=!lines2rows $(replygood$i)
!set type=$(replygood$i[2;1])
!if $type iswordof polyline
replist=!lines2rows $(reply$i)
replist=!exec pari [$replist]~
replist=!replace internal ; by , in $replist
!else
replist=$(reply$i)
!endif
!if $wims_read_parm=nocompare
type=!line -1 of $(oef_answer_option$i)
type=!word 1 of $type
!set draw_reply_cnt=!itemcnt $replist
!if $type iswordof arrows arrows2 segments and $[$draw_reply_cnt%4]!=0 and $replist notsametext empty
test=NaN $i
error=draw_bad_object
!exit
!endif
!if $draw_reply_cnt <= 1
!set parm3=!line 1 to -2 of $(oef_answer_option$i)
!read oef/canvasdraw.phtml $parm3
!else
!set parm3=!line 1 to -2 of $(oef_answer_option$i)
!set parm3_=!line -1 of $(oef_answer_option$i)
!if $type iswordof poly3 poly4 poly5 poly6 poly7 poly8 poly9
!set parm3_=!replace internal $type by polygon in $parm3_
!endif
!if $type iswordof curvedarrows curvedarrows2
!set tmp=!itemcnt $replist
!set tmp_=!values 6*x+1,6*x+2,6*x+5,6*x+6,6*x+3,6*x+4 for x=0 to $[$tmp/6-1]
!set replist=$(replist[$tmp_])
!endif
!read oef/canvasdraw.phtml $parm3\
$parm3_ $replist
!endif
reply_$i=$canvasdraw_out
!exit
!endif
!set parm3=!line 1 to -2 of $(oef_answer_option$i)
!! first line : the code
!! second line : segments, list of segments
!set listtype1=segments arrows2 arrows rects circles points crosshairs curvedarrows curvedarrows2
!set listtype2=lines demilines
!!only one object
!set listtype3=polyline polygon
!set listtype=$listtype1 $listtype2
!set type=$(replygood$i[2;1])
!if $type iswordof poly3 poly4 poly5 poly6 poly7 poly8 poly9
!set type=polygon
!endif
!set rlist=!sort lines $replist
!set good=$(replygood$i[2;2..-1])
!if $type iswordof polygon
!set good=$good,$(good[1]),$(good[2])
!endif
!set good_cnt=!itemcnt $good
!if $type iswordof arrows arrows2
!set arrow_head=!getopt arrow_head in $(replyoption$i)
!default arrow_head=10
option=$arrow_head,
!endif
!if $type iswordof $listtype $listtype3
!set type_cnt=4
!if $type iswordof circles
!set type_cnt=3
!endif
!if $type iswordof points crosshairs $listtype3
!set type_cnt=2
!endif
!if $type iswordof curvedarrows curvedarrows2
!set type_cnt=6
!endif
!endif
!set type_cnt2=$type_cnt
!if $type iswordof $listtype3
!set type_cnt2=4
!endif
!if $[$good_cnt%$type_cnt]!=0
Test=bad $i
!exit
!endif
!reset g_cnt2 glist
!for s=1 to $[$good_cnt/$type_cnt]
rg=$[($s-1)*$type_cnt]
!if $rg+$type_cnt2 <= $good_cnt
!increase g_cnt2
!!need of the numero if we add some other tests
glist=!append line $s,$(good[$rg+1 ..$rg+$type_cnt2]) to $glist
!if $type iswordof segments arrows2 rects
glist=!append line $s,$(good[$rg+3,$rg+4,$rg+1,$rg+2]) to $glist
!endif
!if $type iswordof rects
glist=!append line $s,$(good[$rg+3,$rg+2,$rg+1,$rg+4]) to $glist
glist=!append line $s,$(good[$rg+1,$rg+4,$rg+3,$rg+2]) to $glist
!endif
!if $type iswordof curvedarrows2
glist=!append line $s,$(good[$rg+3,$rg+4,$rg+1,$rg+2,$rg+5,$rg+6]) to $glist
!endif
!endif
!next
!set g_cnt=$[$good_cnt/$type_cnt]
!set g_cnt1=$g_cnt
!if $type iswordof segments arrows2
g_cnt1=$[2*$g_cnt]
!endif
!if $type iswordof rects
g_cnt1=$[4*$g_cnt]
!endif
!set r_cnt=!itemcnt $rlist
!reset Rlist
!for s=1 to $r_cnt
Rlist=!append line $(rlist[($s-1)*$type_cnt+1 ..($s-1)*$type_cnt+$type_cnt2]) to $Rlist
!next
!if $type iswordof $listtype3
!if $type=polyline
Rlist=!line 1 to -2 of $Rlist
!else
Rlist=$Rlist,$(rlist[1]),$(rlist[2])
!endif
!else
glist=!sort lines $glist
!endif
rlist=!sort lines $Rlist
r_cnt=!linecnt $rlist
!!g_cnt=!linecnt $glist
rlist=!lines2rows $rlist
glist=!lines2rows $glist
glist=!exec pari [$glist]
!reset goodrg goodrr
!set parm3=$parm3\
linewidth 3
!read anstype/draw.inc
goodrg=!listuniq $goodrg
totalr=!makelist x for x=1 to $r_cnt
totalg=!makelist x for x=1 to $g_cnt2
badr=!listcomplement $goodrr in $totalr
missing_r=!listcomplement $goodrg in $totalg
goodr_cnt=!itemcnt $goodrr
badr_cnt=$[$r_cnt - $goodr_cnt]
missing_r_cnt=!itemcnt $missing_r
!if $badr!=$empty
!for u in $badr
!if $type iswordof curvedarrows curvedarrows2
parm3=!append line $type red,$option$(rlist[$u;1,2,5,6,3,4]) to $parm3
!else
parm3=!append line $type red,$option$(rlist[$u;1..$type_cnt2]) to $parm3
!endif
!next
!endif
!! display of good answer according to oef setup
!if $presentgood=1
!if $missing_r_cnt!=0
!for v in $missing_r
parm3=!append line dashed\
$type blue, $option$(glist[$v;2..$type_cnt2+1]) to $parm3
!next
!endif
!endif
!if split iswordof $(replyoption$i) or partialscore iswordof $(replyoption$i) or eqweight iswordof $(replyoption$i)
!if eqweight iswordof $(replyoption$i)
coeff=0.5
!else
coeff=1
!endif
!else
coeff=0
!endif
!if $coeff=0
!if $goodr_cnt=$g_cnt2 and $badr_cnt=0 and $missing_r_cnt=0
score=1
!else
score=0
!endif
!else
score=$[max(0,min(1,($goodr_cnt-$coeff*(max($badr_cnt,$missing_r_cnt)))/$g_cnt2))]
!endif
!if $score=1
diareply$i=good
!increase freegot
!else
!if $score>0.1
partialgood$i=yes
diareply$i=good
freegot=$[$freegot+$score]
!else
diareply$i=bad
!endif
!endif
!set parm3=!nonempty lines $parm3
!read oef/canvasdraw.phtml $xysize\
$parm3
reply_$i=$canvasdraw_out
reply__$i=
|