Subversion Repositories wimsdev

Rev

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