Subversion Repositories wimsdev

Rev

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