Subversion Repositories wimsdev

Rev

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