Subversion Repositories wimsdev

Rev

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