Subversion Repositories wimsdev

Rev

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

Rev Author Line No. Line
3134 bpr 1
 
10249 obado 2
!! This script handle OEF embed{t, inputsize, [prompt]} instruction
3
 
11068 obado 4
!! replace oef variables by their associated value
5
!set parm=!replace internal \ by $$m_ in $wims_read_parm
10249 obado 6
 
11068 obado 7
!set t_=!item 1 of $parm
8
!set inputsize=!item 2 of $parm
9
!! To let LaTeX instructions working, "\" must not be replaced in prompt.
10
!set prompt_=!item 3 of $wims_read_parm
10249 obado 11
 
2054 bpr 12
!if $(replytype$i) iswordof flashcard
13
  !set inputsize1=!word 1 of $inputsize
14
!else
15
  !set inputsize1=$inputsize
16
!endif
13793 bpr 17
!set cnt_$i= !linecnt $(Rg$i)
20 reyssat 18
!if $printing=yes or $cmd=hint
13798 bpr 19
  !! i__ is the question number
20
  !! i is the exercise number (print version)
13723 bpr 21
  !! does not exist in case cmd=hint
13804 bpr 22
  !reset prompt___
12348 bpr 23
  !set i__=!replace internal reply by in $t_
24
  !set i__=!replace internal r by in $i__
25
  !set i__=!trim $i__
13723 bpr 26
  !if $cmd!=hint
27
    !set replytype$i__=!item $i__ of $(Replytype$i)
28
    !set replystyle$i__=!item $i__ of $(Replystyle$i)
29
  !endif
13891 bpr 30
  !reset anstyle
12348 bpr 31
  !readproc anstype/$(replytype$i__).input def
13891 bpr 32
  !set replystyle$i__=$anstyle
33
  !default replystyle$i__=$(replytype$i__)
13880 bpr 34
  !!  mc=checkbox click flashcard mark menu radio
35
  !if mc iswordof $(replystyle$i__) \
36
      or $(replytype$i__) iswordof dragfill clickfill coord
13894 bpr 37
    !if $inputsize1>0
12348 bpr 38
      !if $prompt_=$empty
13723 bpr 39
        !if $cmd=hint
40
          !set g_=!rows2lines $(replygood$i__)
41
          !set prompt_=!line 2 of $g_
42
        !else
43
          !set prompt_=!line $i__ of $(Rg$i)
44
        !endif
12348 bpr 45
        !set prompt_=!item $inputsize1 of $prompt_
13891 bpr 46
        !set prompt_=<span style="display:inline-block;">$prompt_</span>
12348 bpr 47
      !endif
48
    !else
49
      !if $prompt_=$empty
13799 bpr 50
        !set prompt_=!line $i__ of $(Rg$i)
51
        !set prompt_=!items2lines $prompt_
52
        !set prompt__=$prompt_
13880 bpr 53
        !if $(replytype$i__) iswordof menu checkbox radio click
13793 bpr 54
          !set prompt_=!replace internal $\
13799 bpr 55
$ by  </li>$ $<li> in <div class="inline"><ul><li>$prompt_</li></ul></div>
13793 bpr 56
        !else replytype with labels
57
          !set prompt_$i=!append line $prompt__ to $(prompt_$i)
58
          !set inputsize1_=!replace internal x by , in $inputsize1
59
          !if $(inputsize1_[4])!=$empty and $(inputsize1_[4])>1
60
            !set prompt_=<table class="wimsborder">
61
            !for j=1 to $(inputsize1_[4])
62
              !set prompt_=$prompt_<tr>
63
              !for h=1 to $[ceil($(inputsize1_[3])/$(inputsize1_[4]))]
64
                !set prompt_=$prompt_<td>&nbsp;</td>
65
              !next
66
              !set prompt_=$prompt_ </tr>
67
            !next
68
            !set prompt_=$prompt_</table>
69
          !endif
13880 bpr 70
          !! regroupe les prompts des dragfill et de clickfill
13793 bpr 71
          !if $i__>=$(cnt_$i)
72
            !set prompt_$i=!lines2items $(prompt_$i)
73
            !set prompt_$i=!listuniq $(prompt_$i)
13911 bpr 74
            !set prompt_$i=!shuffle $(prompt_$i)
13793 bpr 75
            !set prompt___=!replace internal , \
13815 bpr 76
              by </div>$ $<div class="drag_label" style="display:inline-block;"> \
77
in <div class="drag_label" style="display:inline-block;">$(prompt_$i)</div>
13793 bpr 78
          !endif
13894 bpr 79
          !reset prompt_
13793 bpr 80
        !endif
12348 bpr 81
      !endif
82
    !endif
13276 obado 83
  !else
13801 bpr 84
    !set prompt_=!line $i__ of $(Rg$i)
13799 bpr 85
    !if $(replytype$i__) iswordof compose reorder
86
      !set prompt_=!shuffle $prompt_
13816 bpr 87
      !set prompt_=!replace internal , by </div>$  $ <div class="drag_label" style="display:inline-block;"> \
88
in <div class="drag_label" style="display:inline-block;">$prompt_</div>
12348 bpr 89
    !endif
2588 bpr 90
  !endif
13891 bpr 91
  !if $(replytype$i__) iswordof jsxgraph jsxgraphcurve clock
92
    !read anstype/$(replytype$i).input
93
    !exit
94
  !endif
13801 bpr 95
  !if $prompt_ issametext $empty
13809 bpr 96
    !set prompt_=$prompt_empty
13801 bpr 97
  !endif
13799 bpr 98
  $prompt_
12348 bpr 99
  !exit
20 reyssat 100
!endif
3134 bpr 101
!!end of print section
20 reyssat 102
 
103
!if $wims_read_parm=$empty
12348 bpr 104
  !exit
20 reyssat 105
!endif
106
 
107
!set n_=!char 2 to -1 of $t_
108
!set t_=!char 1 of $t_
109
!set t_=!lower $t_
110
!set t_=!translate a to r in $t_
111
!set n_=!text select 0123456789()+-* in $n_
112
!set n_=$[$n_]
113
!bound n_ between integer 1 and 100 default $
114
!if $t_ notitemof r,c or $n_=$empty
12348 bpr 115
  !exit
20 reyssat 116
!endif
117
 
118
!if $t_=c and $(choicelist$n_)=$empty or\
12348 bpr 119
          $t_=r and $(replygood$n_)=$empty
120
  !exit
20 reyssat 121
!endif
122
 
123
!if $t_$n_ notitemof $embedded
12348 bpr 124
  !set embedded=!append item $t_$n_ to $embedded
125
  !set embcnt=!itemcnt $embedded
20 reyssat 126
!endif
127
!set i=$n_
128
 
129
!if $q_form=yes
12348 bpr 130
  !if $t_=c
131
    !set p_=$ch_choose,$(choicelist$i)
132
    !if $idontknow>0 and noidontknow notwordof $(choiceoption$i)
133
      !set p_=$p_,$ch_noidea
134
    !endif
135
    !if $qcmgood<1
136
      !set p_=$p_,$ch_none
137
    !endif
138
    !set N_=!itemcnt $p_
139
    !set C_=$(choice$i)
140
    !if debug iswordof $m_oefenv
141
      !set replydefaulted=yes
142
      !if $oef_default=yes
143
        !set T_=!positionof item $(choicegood$i[1]) in $(choicelist$i)
144
        !default choice$i=$(T_[1])
145
      !endif
146
    !endif
147
    !formselect choice$i from 0 to $[$N_-1] prompt $p_
148
    !set choice$i=$C_
149
  !else
150
    !read anstype/$(replytype$i).input noprompt
20 reyssat 151
  !endif
152
!else
12348 bpr 153
  !distribute item oef_indgood, oef_indbad, oef_indforget, oef_indneutral, oef_empty, oef_indprec, oef_indpartial\
154
    into colorr_good, colorr_bad, colorr_forget, colorr_neutral, colorr_none, colorr_prec, colorr_partial
155
  !set cl=colorr_none
156
  !if $t_=c
157
    !set cl=$(colorr_$(diachoice$i))
158
    !set p_=!item $(choice$i) of $(choicelist$i),$ch_noidea,$ch_none
159
    !set choicename$i=[$embcnt]
160
  !else
161
    !default reply_$i=$(reply$i)
162
    !set p_=$(reply_$i)
163
    !if dprompt iswordof $(replystyle$i)
164
      !set reply_$i=$(reply__$i)
165
    !endif
13591 bpr 166
    !if mc iswordof $(replystyle$i) and $inputsize1!=$empty and $[$inputsize1]!=NaN and $[$inputsize1] >= 1 and $[$inputsize1] <= 1000
12348 bpr 167
      !set tt=!rows2lines $(replygood$i)
168
      !distribute lines $tt into ts,tt
169
      !default prompt_=!item $inputsize1 of $tt
170
      !set p_=$prompt_
171
      !reset tv
172
      !if $(replytype$i) iswordof mark flashcard
173
        !set tv=$(reply$i)
174
      !else
175
        !for r_ in $(reply$i)
176
          !set tu=!positionof item $r_ in $tt
177
          !set tv=!append item $tu to $tv
178
        !next r_
179
      !endif
180
      !set p_=!replace internal &#59; by ; in $p_
181
      !if $inputsize1 notitemof $tv
182
        !if $presentgood=0
183
          !set cl= $colorr_none
13260 bpr 184
        !else
12348 bpr 185
          !if $inputsize1 isitemof $ts and $(replytype$i) iswordof mark flashcard checkbox
186
            !set cl = $colorr_forget
187
          !else
188
            !set cl = $colorr_neutral
189
          !endif
190
        !endif
13260 bpr 191
        !set p__=!detag $p_
192
        !if $p__!=$empty
13778 obado 193
          !imgrename <span class="$cl">$p_</span>
13260 bpr 194
        !else
195
          $p_
196
        !endif
12348 bpr 197
        !exit
198
      !endif
199
    !endif
200
    !if $(replytype$i) iswordof code
201
      !set p_=!replace internal & by &amp; in $p_
202
      !set p_=!replace internal &amp;#36; by &#36; in $p_
203
      !set p_=!replace internal < by &lt; in $p_
204
      !set p_=<pre>$p_</pre>
205
    !endif
206
    !set tt=!word 1 of $(replygood$i)
207
    !if $tt!=?analyze
208
      !set cl=$(colorr_$(diareply$i))
209
      !if $(replytype$i) iswordof mark flashcard checkbox
210
        !if $inputsize!=$empty
211
          !if $inputsize isitemof $ts
212
            !set cl = $colorr_good
213
          !else
214
            !set cl = $colorr_bad
215
          !endif
216
        !else
217
          !set cl=$(colorr_$(diareply$i))
218
          !default display_forget=no
219
        !endif
220
      !endif
221
      !if $(partialgood$i)=yes
222
        !set cl=$(colorr_partial)
223
      !endif
224
      !if $(precreply$i)=yes
225
        !set cl=$(colorr_prec)
226
      !endif
20 reyssat 227
    !else
12348 bpr 228
      !set embedded_analyze=!append item $i to $embedded_analyze
229
      !if noanalyzeprint notwordof $(replyoption$i)
230
        !set embedded_bracket=$embedded_bracket [$embcnt]
8700 obado 231
      !endif
20 reyssat 232
    !endif
12348 bpr 233
    !set replyname$i=[$embcnt]
20 reyssat 234
  !endif
12348 bpr 235
  !set embcnt1=&nbsp;<sup><small>[$embcnt]</small></sup>
236
  !if $(replytype$i) notwordof correspond crossword
237
    !if bad isin $cl
238
      !set instex_color=red
239
    !endif
240
    !if good isin $cl
241
      !set instex_color=green
242
    !endif
243
    !if forget isin $cl
244
      !set instex_color=blue
245
    !endif
13778 obado 246
    !imgrename <span class="$cl">$p_</span>$embcnt1
20 reyssat 247
  !else
12348 bpr 248
    !imgrename $p_ $embcnt1
20 reyssat 249
  !endif
12348 bpr 250
  !set instex_color=black
251
  !if $(replytype$i) iswordof correspond
252
    !set noshow$i=yes
253
  !endif
20 reyssat 254
!endif