Subversion Repositories wimsdev

Rev

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