Subversion Repositories wimsdev

Rev

Rev 13728 | Rev 15695 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
11269 bpr 1
option:align=" " noorder transparent
20 reyssat 2
 
13276 obado 3
!! ClickFill generic anstype (also used by Dragfill)
4
 
13848 obado 5
!!!!!!
6
!! After changes made, please test these exercices:
7
 
8
!! for dragfill:
9
!! *    http://127.0.0.1/wims/wims.cgi?module=H1/geometry/OEFtriang5.fr&exo=demo1&cmd=new
10
!!!!!!
11
 
20 reyssat 12
good=!singlespace $(replygood$i)
13
good=!trim $good
14
good=!rows2lines $good
15
good=!line 1 of $good
16
good=!translate | to $\
17
$ in $good
18
good=!nonempty lines $good
11255 bpr 19
replyGood$i=!line 1 of $good
20
 
11197 bpr 21
!distribute items $(oef_answer_option$i) into sizeh,sizev,sizei,sizej
22
!set rightcolor=#87ceeb
23
!set align_option=!getopt align in $(replyoption$i)
24
!set align_option=!tolower $align_option
25
!bound align_option within left,right,center default center
26
 
11448 bpr 27
# padding of each label in px
28
!set label_padding=1
29
# border width of each label in px
30
!set label_border_width=1
31
# margin of each label in px
32
!set label_margin=1
33
 
13727 obado 34
!set sizegood=!itemcnt $(replyGood$i)
11448 bpr 35
 
11253 bpr 36
# sizej represent the number of objects per line
11448 bpr 37
# $sizeh+... represent an object width + its padding+margin+border in px
11255 bpr 38
!if $sizei=$sizej
12533 bpr 39
  !! case of 1 line.
11255 bpr 40
  !set sizerep=!itemcnt $(reply$i)
11448 bpr 41
  !set container_width_g = $[($sizeh+2*$label_padding+2*$label_border_width+2*$label_margin) * $sizegood]
42
  !set container_width_r = $[($sizeh+2*$label_padding+2*$label_border_width+2*$label_margin) * $sizerep]
11255 bpr 43
!else
11448 bpr 44
  !set container_width_g = $[($sizeh+2*$label_padding+2*$label_border_width+2*$label_margin) * $sizej]
11255 bpr 45
  !set container_width_r = $container_width_g
46
!endif
47
 
48
!set container_width_g = class="fill_container" style="width:$(container_width_g)px"
49
!set container_width_r = class="fill_container" style="width:$(container_width_r)px"
50
 
11448 bpr 51
!set label_width=$[$(sizeh) + 2*$label_padding + 2*$label_border_width]
52
!set label_height=$[$(sizev) + 2*$label_padding + 2*$label_border_width]
53
 
54
!if $(sizeh)<30 or $(sizev)<30
55
  !set label_overflow = overflow:hidden;
56
!else
57
  !reset label_overflow
58
!endif
59
 
13727 obado 60
!reset rGood$i
61
!for a=1 to $sizegood
62
  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;">\
63
    <div class="drag_content 3" style="text-align:$align_option">$(replyGood$i[$a])</div>\
64
  </div>
65
!next
66
replyGood$i=<div $container_width_g>$(rGood$i)</div>
11197 bpr 67
 
20 reyssat 68
dd=$(reply$i)
69
 
70
!if r$i notitemof $thisstep
11208 obado 71
  !goto nocheck
20 reyssat 72
!endif
73
 
74
!if $i notitemof $fill_checked
11208 obado 75
  fill_checked=!append item $i to $fill_checked
76
  dd2=
77
  !for d_ in $dd
78
    !if $d_ isitemof $fill_check
79
      dd2=!append item $d_ to $dd2
80
      !if $(replytype$i)=dragfill
81
        pos=!positionof item $d_ in $fill_check
82
        pos=!item 1 of $pos
83
        !if $pos!=$empty
84
          fill_check=!replace item number $pos by $ in $fill_check
85
        !endif
86
      !endif
87
    !else
11376 bpr 88
      !set default_$i=!replace internal &nbsp by &nbsp; in $(default_$i)
11208 obado 89
      dd2=!append item $(default_$i) to $dd2
20 reyssat 90
    !endif
11208 obado 91
  !next d_
92
  dd=$dd2
93
  !if $(replytype$i)=dragfill
94
    fill_check=!nonempty items $fill_check
20 reyssat 95
  !endif
96
!endif
97
 
98
:nocheck
99
reply$i=$dd
100
m_reply$i=$dd
11448 bpr 101
 
11376 bpr 102
!set style=.drag_label{\
13473 obado 103
    padding:$(label_padding)px;\
104
    border-width:$(label_border_width)px;\
105
    background-color:$rightcolor;\
106
  }
107
 
11376 bpr 108
!if $style notin $oef_anstype_css
13473 obado 109
  !set oef_anstype_css=!append line $style to $oef_anstype_css
11180 obado 110
!endif
111
 
11376 bpr 112
!!reply_$i=!items2words $dd
113
!set dd_cnt=!itemcnt $dd
114
!set reply_$i=<div $container_width_r>
20 reyssat 115
!if $wims_read_parm=nocompare
13727 obado 116
  !for a=1 to $dd_cnt
11320 bpr 117
    reply_$i=$(reply_$i)<div\
13280 obado 118
      class="drag_label" style="$(label_overflow)justify-content:$align_option;width:$(label_width)px;height:$(label_height)px;">\
13641 obado 119
      <div class="drag_content" style="text-align:$align_option">$(dd[$a])</div>\
11320 bpr 120
      </div>
121
  !next
122
  reply_$i=$(reply_$i)</div>
11208 obado 123
  !exit
20 reyssat 124
!endif
125
 
126
!if $good=$empty
11208 obado 127
  Test=bad $i
128
  !exit
20 reyssat 129
!endif
130
 
131
diag=
4849 bpr 132
diaratio=-1
20 reyssat 133
t_=!linecnt $good
134
good=!replace internal , $ by , in $good
135
dd=!replace internal , $ by , in $dd
1802 bpr 136
ddo=!sort items $dd
20 reyssat 137
!for n=1 to $t_
11208 obado 138
  g=!line $n of $good
139
  g=!trim $g
140
  !if $dd issametext $g
141
    diag=yes
142
  !endif
143
  !if noorder iswordof $(replyoption$i)
144
    go=!sort items $g
145
    !if $ddo issametext $go
146
      diag=yes
147
    !else
11253 bpr 148
      !! more precisely, but will used only if there is only one good answer)
149
      !if $t_=1
150
        !reset gr
151
        !for j=1 to $dd_cnt
152
          !if $(dd[$j]) isitemof $g
13473 obado 153
            !set gr=!append item oef_indgood to $gr
11253 bpr 154
          !else
13473 obado 155
            !set gr=!append item oef_indbad to $gr
11253 bpr 156
          !endif
157
        !next j
158
      !endif
11208 obado 159
    !endif
160
  !endif
161
  !if $diag notwordof yes and (split iswordof $(replyoption$i) or partialscore iswordof $(replyoption$i))
162
    !! nombre de reponses
163
    poscnt1=!itemcnt $ddo
164
    lint=!listintersect $ddo and $go
165
    !! nombre de bonnes reponses
166
    poscnt2=!itemcnt $lint
167
    !! nombre demande de bonnes reponses
168
    poscnt3=!itemcnt $go
169
    !if eqweight iswordof $(replyoption$i)
170
      diaratio_=$[2*$poscnt2 - $poscnt1]
171
    !else
172
      diaratio_=$[3*$poscnt2 - 2*$poscnt1]
173
    !endif
174
    !if $diaratio_ > 0
175
      diaratio=$[max($diaratio,$[$diaratio_/max($poscnt3,1)])]
176
    !endif
177
  !endif split
20 reyssat 178
!next n
7139 bpr 179
 
13727 obado 180
!for a=1 to $dd_cnt
11448 bpr 181
  reply_$i=$(reply_$i)<div\
13280 obado 182
    class="drag_label $(gr[$a])" style="$(label_overflow)justify-content:$align_option;width:$(label_width)px;height:$(label_height)px;">\
13641 obado 183
      <div class="drag_content" style="text-align:$align_option">$(dd[$a])</div>\
11448 bpr 184
    </div>
185
!next
186
reply_$i=$(reply_$i)</div>
11253 bpr 187
 
20 reyssat 188
!if $diag=yes
11208 obado 189
  diareply$i=good
190
  !advance freegot
20 reyssat 191
!else
4849 bpr 192
  !if $diaratio > 0 and (split iswordof $(replyoption$i) or partialscore iswordof $(replyoption$i))
193
    diareply$i=good
194
    partialgood$i=yes
195
    freegot=$[$freegot+ max(0,$diaratio)]
196
  !else
197
    diareply$i=bad
198
  !endif
7139 bpr 199
!endif