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
|
option:align=" " noorder transparent
!! ClickFill generic anstype (also used by Dragfill)
!!!!!!
!! After changes made, please test these exercices:
!! for dragfill:
!! * http://127.0.0.1/wims/wims.cgi?module=H1/geometry/OEFtriang5.fr&exo=demo1&cmd=new
!!!!!!
!! for clickfill H5/algebra/OEFevalwimssecdeg.fr (espace)
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
!distribute items $(oef_answer_option$i) into sizeh,sizev,sizei,sizej
!set rightcolor=#87ceeb
!set align_option=!getopt align in $(replyoption$i)
!set align_option=!tolower $align_option
!bound align_option within left,right,center default center
# padding of each label in px
!set label_padding=1
# border width of each label in px
!set label_border_width=1
# margin of each label in px
!set label_margin=1
!set sizegood=!itemcnt $(replyGood$i)
# sizej represent the number of objects per line
# $sizeh+... represent an object width + its padding+margin+border in px
!if $sizei=$sizej
!! case of 1 line.
!set sizerep=!itemcnt $(reply$i)
!set container_width_g = $[($sizeh+2*$label_padding+2*$label_border_width+2*$label_margin) * $sizegood]
!set container_width_r = $[($sizeh+2*$label_padding+2*$label_border_width+2*$label_margin) * $sizerep]
!else
!set container_width_g = $[($sizeh+2*$label_padding+2*$label_border_width+2*$label_margin) * $sizej]
!set container_width_r = $container_width_g
!endif
!set container_width_g = class="fill_container" style="width:$(container_width_g)px"
!set container_width_r = class="fill_container" style="width:$(container_width_r)px"
!set label_width=$[$(sizeh) + 2*$label_padding + 2*$label_border_width]
!set label_height=$[$(sizev) + 2*$label_padding + 2*$label_border_width]
!if $(sizeh)<30 or $(sizev)<30
!set label_overflow = overflow:hidden;
!else
!reset label_overflow
!endif
!reset rGood$i
!for a=1 to $sizegood
rGood$i=$(rGood$i)<div class="drag_label oef_indgood" style="$(label_overflow)justify-content:$align_option;width:$(label_width)px;height:$(label_height)px;">\
<div class="drag_content 3" style="text-align:$align_option">$(replyGood$i[$a])</div>\
</div>
!next
replyGood$i=<div $container_width_g>$(rGood$i)</div>
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
!set default_$i=!replace internal   by in $(default_$i)
dd2=!append item $(default_$i) 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
!set style=.drag_label{\
padding:$(label_padding)px;\
border-width:$(label_border_width)px;\
background-color:$rightcolor;\
}
!if $style notin $oef_anstype_css
!set oef_anstype_css=!append line $style to $oef_anstype_css
!endif
!!reply_$i=!items2words $dd
!set dd_cnt=!itemcnt $dd
!set reply_$i=<div $container_width_r>
!if $wims_read_parm=nocompare
!for a=1 to $dd_cnt
reply_$i=$(reply_$i)<div\
class="drag_label" style="$(label_overflow)justify-content:$align_option;width:$(label_width)px;height:$(label_height)px;">\
<div class="drag_content" style="text-align:$align_option">$(dd[$a])</div>\
</div>
!next
reply_$i=$(reply_$i)</div>
!exit
!endif
!if $good=$empty
default=!getopt default in $(replyoption$i)
good=$default
good=!replace internal   $ by in $good
!endif
!if $good=
Test=bad $i
!exit
!endif
diag=
diaratio=-1
t_=!linecnt $good
good=!replace internal , $ by , in $good
dd=!replace internal , $ by , in $dd
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
!else
!! more precisely, but will used only if there is only one good answer)
!if $t_=1
!reset gr
!for j=1 to $dd_cnt
!if $(dd[$j]) isitemof $g
!set gr=!append item oef_indgood to $gr
!else
!set gr=!append item oef_indbad to $gr
!endif
!next j
!endif
!endif
!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 demande de bonnes reponses
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
!next n
!for a=1 to $dd_cnt
reply_$i=$(reply_$i)<div\
class="drag_label $(gr[$a])" style="$(label_overflow)justify-content:$align_option;width:$(label_width)px;height:$(label_height)px;">\
<div class="drag_content" style="text-align:$align_option">$(dd[$a])</div>\
</div>
!next
reply_$i=$(reply_$i)</div>
!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
|