Subversion Repositories wimsdev

Rev

Rev 14007 | Rev 14311 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

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