
\text{qcm_prompt1=}
\text{qcm_prompt2=}
\text{good_answer_text=}
\text{bad_answer_text=}
\text{incomplete_answer_text=}
\text{option=}
\matrix{question=}
\matrix{explication=}
\matrix{rep=}
\text{CNT_choix= }
\matrix{CHOIX=}
\text{PRELIMINAIRE=}
\for{i= 1 to \MAX}{
 \text{QUEST=wims(record \battage[\i] of \file)}
 \text{QUEST=wims(\QUEST)}
 \text{preliminaire_test=\QUEST}
 \text{preliminaire_test=row(1,\preliminaire_test)}
 \text{inst_audio=wims(getopt audio in \preliminaire_test)}
 \text{inst_image=wims(getopt image in \preliminaire_test)}
 \text{inst_title=wims(getopt title in \preliminaire_test)}
 \text{inst_intro=wims(getopt intro in \preliminaire_test)}
 \text{test_inst=\inst_audio\inst_image\inst_title\inst_intro  notsametext ? 1 : 0}
 \text{rab_inst=}
 \text{rab_inst=\inst_title notsametext ?\rab_inst<p align="center">\inst_title</p>}
 \text{rab_inst=\inst_intro notsametext ?\rab_inst \inst_intro}
 \text{rab_inst=\inst_image notsametext ? \rab_inst <p align="center"><img src="\imagedir/\inst_image" alt=""></p>}
 \if{\inst_audio notsametext }{
     \text{rab_inst1= . isin \inst_audio or \packs= ? 
       slib(media/audio \imagedir/\inst_audio,\player_option,player=\player):slib(lang/swac \inst_audio,\packs,player=\player,\player_option)}
     \text{rab_inst=\rab_inst <p align="center">\rab_inst1[1;1]</p>}
   }
 \text{preliminaire=\test_inst=1  ? \rab_inst:&nbsp;}
 \text{QUEST=\test_inst=1 ? wims(line 2 to -1 of \QUEST)}
  \matrix{QUEST=wims(embraced randitem \QUEST)}
  \matrix{question = \question
  \QUEST[1;]}
  \matrix{PRELIMINAIRE=\PRELIMINAIRE
  \preliminaire}
  \text{expl=\QUEST[2;]}
  \text{ligne=wims(upper \expl)}
  \text{ligne=wims(text select ABCDEFGHIJKLMNOPQRSTUVWXYZ in \ligne)}
  \if{\ligne issametext and \expl notsametext }{
  \matrix{explication = \explication ;
  }
  \integer{debut = 2}
 }
 \if{\ligne issametext and \expl issametext }{
  \matrix{explication = \explication ;
  }
  \integer{debut = 3}
  }
  \if{\ligne notsametext}{
     \matrix{explication = \explication
  \expl}
  \integer{debut = 3}
 }
  \integer{cnt_choix=rows(\QUEST)-\debut}
  \text{CNT_choix=\CNT_choix,\cnt_choix}
   \text{Choix=}
   \text{mix=shuffle(\cnt_choix)}
   \for{ j=\debut+1 to \cnt_choix + \debut+1}{
     \text{choix= \QUEST[\j;]}
     \text{choix=wims(replace internal , by  &#44; in \choix)}
     \matrix{Choix = \Choix, \choix[1;]}
   }
   \text{Choix=wims(nonempty items \Choix)}
   \text{Choix= \Choix[\mix]}
   \matrix{CHOIX=\CHOIX
     \Choix}
   \text{H = wims(nospace \QUEST[\debut;])}
   \text{cnt_c=items(\H)}
   \text{Rep = }
   \for{ k = 1 to \cnt_c}{ 
     \text{Rep = \Rep, position(\H[\k],\mix)}
   }
   \text{Rep = wims(sort items wims(nonempty items \Rep))}
   \matrix{rep = \rep
    \Rep}
}

\text{CNT_choix=wims(nonempty items \CNT_choix)}

\text{U = pari(divrem(\MAX,\N)~)}
\integer{cnt_step = \U[1] + 1}
\matrix{STEPS = }
\matrix{CNT = }
\text{CONDSTEP=}
\for{ u = 1 to \cnt_step -1}{
   \matrix{STEPS =\STEPS
wims(makelist r x for x = \N*\u -\N+1 to \N*\u)}
   \matrix{CNT =\CNT
wims(makelist x for x = \N*\u -\N+1 to \N*\u)}
   \text{condstep= wims(values \u+1 for x = (\u-1)*\N +1 to \u*\N)}
   \text{CONDSTEP= wims(append item \condstep to \CONDSTEP)}
}
 \matrix{STEPS = \STEPS
 wims(makelist r x  for x = \N*\cnt_step-\N+1 to \MAX)
}
\matrix{CNT = \CNT
 wims(makelist x  for x = \N*\cnt_step-\N+1 to \MAX)
}
\text{CONDSTEP=\CONDSTEP, wims(values \cnt_step+1  for x = \N*\cnt_step-\N+1 to \MAX)}

\text{nstep=\STEPS[1;]}
\text{TEST=}
text{testexp=wims(rows2lines \explication)}
text{testexp=wims(lines2items \testexp)}
text{testexp=wims(items2words \testexp)}
text{testexp=wims(nospace \testexp)}
\nextstep{\nstep}
\text{REP=}
\text{etape=wims(values x * \N for x = 1 to \cnt_step+1)}
\text{CONDITION = wims(makelist x for x = 1 to 2*\MAX)}
\text{CONDITION =wims(items2words \CONDITION)}
\conditions{\CONDITION}
\integer{cnt_juste=0}
\real{v = 10}
\statement{\nopaste
\instruction
\if{\reading notsametext }{\special{help reading,READING}}
\if{\image notsametext }{\special{help image,IMAGES}}
\audio\video
 \for{h=1 to \etape[\step]}{
   \if{(\h <= \etape[\step] - \N or r \h isitemof \nstep) and \question[\h;] notsametext }{
     <p>
     \if{\cnt_step > 1  and \MAX > 1}{\h : } \PRELIMINAIRE[\h;]
     \question[\h;]</p>
   }
   \if{\h <= \etape[\step] - \N and \question[\h;] notsametext}{
    <div class="reponse">
      \qcm_prompt1
       \for{ a in \REP[\h;]}{
         \if{ \a  isitemof \CHOIX[\h;\rep[\h;]]}{
           \if{\TEST[\h;2]>0 and \TEST[\h;3]=0}{
           <span class="oef_indforget">\a</span>}
           {<span class="oef_indgood">\a</span>}
           }
         {
         <span class="oef_indbad"><strike>\a</strike></span>} - }
         \if{\TEST[\h;2]>0 and \TEST[\h;3]=0}{
                   <font color="navy">\incomplete_answer_text
          </font>}
         \if{\TEST[\h;3]>0}{<span class="oef_indbad">\bad_answer_text</span>}
         \if{\TEST[\h;3]=0 and \TEST[\h;2]=0}{<span class="oef_indgood">\good_answer_text</span>}
         \if{\answer_given=yes}{
         <br> \qcm_prompt2 <span class="oef_indgood">\CHOIX[\h;\rep[\h;]]</span>}
      \if{\explication[\h;] notsametext }{<br>\explication[\h;]}     
     </div>
   }
   { \if{ r \h isitemof \nstep}{
      <div class="question">
   <ol>
      \for{s=1 to \CNT_choix[\h]}{ <li>\embed{reply \h , \s}</li> }
      </ol>
      </div>
      }
   }
     </ol>
  }
 }
\answer{}{\REP1;\CHOIX[1;]}{type=\format}{option=\option}
\answer{}{\REP2;\CHOIX[2;]}{type=\format}{option=\option}
\answer{}{\REP3;\CHOIX[3;]}{type=\format}{option=\option}
\answer{}{\REP4;\CHOIX[4;]}{type=\format}{option=\option}
\answer{}{\REP5;\CHOIX[5;]}{type=\format}{option=\option}
\answer{}{\REP6;\CHOIX[6;]}{type=\format}{option=\option}
\answer{}{\REP7;\CHOIX[7;]}{type=\format}{option=\option}
\answer{}{\REP8;\CHOIX[8;]}{type=\format}{option=\option}
\answer{}{\REP9;\CHOIX[9;]}{type=\format}{option=\option}
\answer{}{\REP10;\CHOIX[10;]}{type=\format}{option=\option}
\answer{}{\REP11;\CHOIX[11;]}{type=\format}{option=\option}
\answer{}{\REP12;\CHOIX[12;]}{type=\format}{option=\option}
\answer{}{\REP13;\CHOIX[13;]}{type=\format}{option=\option}
\answer{}{\REP14;\CHOIX[14;]}{type=\format}{option=\option}
\answer{}{\REP15;\CHOIX[15;]}{type=\format}{option=\option}
\answer{}{\REP16;\CHOIX[16;]}{type=\format}{option=\option}
\answer{}{\REP17;\CHOIX[17;]}{type=\format}{option=\option}
\answer{}{\REP18;\CHOIX[18;]}{type=\format}{option=\option}
\answer{}{\REP19;\CHOIX[19;]}{type=\format}{option=\option}
\answer{}{\REP20;\CHOIX[20;]}{type=\format}{option=\option}

\matrix{REP = \REP1
\REP2
\REP3
\REP4
\REP5
\REP6
\REP7
\REP8
\REP9
\REP10
\REP11
\REP12
\REP13
\REP14
\REP15
\REP16
\REP17
\REP18
\REP19
\REP20}
\if{\format=radio}{
 \text{REP=wims(replace internal , by  &#44; in \REP)}
}
\matrix{explication2 = \explication2}

\for{u = 1 to \N}{
   \text{H = \CNT[\step-1;\u]}
   \text{test1 = wims(listuniq \REP[\H;],\CHOIX[\H;\rep[\H;]])}
   \integer{test1 = items(\test1)-items(\CHOIX[\H;\rep[\H;]])}
   \text{test2 = wims(listcomplement \REP[\H;] in \CHOIX[\H;\rep[\H;]])}
   \text{test3 = wims(listcomplement \CHOIX[\H;\rep[\H;]] in \REP[\H;])}
  %%% \integer{test4=items(\REP[\H;]) - items(\CHOIX[\H;])}
   \text{test_cnt=\test1, items(\test2),items(\test3)}    
   \integer{cnt_juste= \test_cnt[1]+\test_cnt[2]+\test_cnt[3] =0 ? \cnt_juste + 1}
   \matrix{TEST=\TEST
   \test_cnt}
}

test1 = 0 rep < juste
test2  nombre de rponses dites justes et en fait fausses
test3  nombre de rponses dites fausses et en fait justes

totalement justes : test1=0, test2=0 test3=0
partiellement justes : 

\real{v=\cnt_juste/\CNT[\step-1;\N]}

\text{nstep = \v >= \percent ? \STEPS[\step;]:}

\condition{Question 1 : \REP1}{\TEST[1;3]=0}{option=hide}
\condition{Question 1 : \REP1}{\TEST[1;1]=0 and \TEST[1;2]=0 and \TEST[1;3]=0}{option=hide}
\condition{Question 2 : \REP2}{\TEST[2;3]=0 and \step >=\CONDSTEP[2]}{option=hide}
\condition{Question 2 : \REP2}{\TEST[2;1]=0 and \TEST[2;2]=0 and \TEST[2;3]=0 and \step >=\CONDSTEP[2]}{option=hide}
\condition{Question 3 : \REP3}{\TEST[3;3]=0 and \step >=\CONDSTEP[3]}{option=hide}
\condition{Question 3 : \REP3}{\TEST[3;1]=0 and \TEST[3;2]=0 and \TEST[3;3]=0 and \step >=\CONDSTEP[3]}{option=hide}
\condition{Question 4 : \REP4}{\TEST[4;3]=0 and \step >=\CONDSTEP[4]}{option=hide}
\condition{Question 4 : \REP4}{\TEST[4;1]=0 and \TEST[4;2]=0 and \TEST[4;3]=0 and \step >=\CONDSTEP[4]}{option=hide}
\condition{Question 5 : \REP5}{\TEST[5;3]=0 and \step >=\CONDSTEP[5]}{option=hide}
\condition{Question 5 : \REP5}{\TEST[5;1]=0 and \TEST[5;2]=0 and \TEST[5;3]=0 and \step >=\CONDSTEP[5]}{option=hide}
\condition{Question 6 : \REP6}{\TEST[6;3]=0 and \step >=\CONDSTEP[6]}{option=hide}
\condition{Question 6 : \REP6}{\TEST[6;1]=0 and \TEST[6;2]=0 and \TEST[6;3]=0 and \step >=\CONDSTEP[6]}{option=hide}
\condition{Question 7 : \REP7}{\TEST[7;3]=0 and \step >=\CONDSTEP[7]}{option=hide}
\condition{Question 7 : \REP7}{\TEST[7;1]=0 and \TEST[7;2]=0 and \TEST[7;3]=0 and \step >=\CONDSTEP[7]}{option=hide}
\condition{Question 8 : \REP8}{\TEST[8;3]=0 and \step >=\CONDSTEP[8]}{option=hide}
\condition{Question 8 : \REP8}{\TEST[8;1]=0 and \TEST[8;2]=0 and \TEST[8;3]=0 and \step >=\CONDSTEP[8]}{option=hide}
\condition{Question 9 : \REP9}{\TEST[9;3]=0 and \step >=\CONDSTEP[9]}{option=hide}
\condition{Question 9 : \REP9}{\TEST[9;1]=0 and \TEST[9;2]=0 and \TEST[9;3]=0 and \step >=\CONDSTEP[9]}{option=hide}
\condition{Question 10 : \REP10}{\TEST[10;3]=0 and \step >=\CONDSTEP[10]}{option=hide}
\condition{Question 10 : \REP10}{\TEST[10;1]=0 and \TEST[10;2]=0 and \TEST[10;3]=0 and \step >=\CONDSTEP[10]}{option=hide}
\condition{Question 11 : \REP11}{\TEST[11;3]=0 and \step >=\CONDSTEP[11]}{option=hide}
\condition{Question 11 : \REP11}{\TEST[11;1]=0 and \TEST[11;2]=0 and \TEST[11;3]=0 and \step >=\CONDSTEP[11]}{option=hide}
\condition{Question 12 : \REP12}{\TEST[12;3]=0 and \step >=\CONDSTEP[12]}{option=hide}
\condition{Question 12 : \REP12}{\TEST[12;1]=0 and \TEST[12;2]=0 and \TEST[12;3]=0 and \step >=\CONDSTEP[12]}{option=hide}
\condition{Question 13 : \REP13}{\TEST[13;3]=0 and \step >=\CONDSTEP[13]}{option=hide}
\condition{Question 13 : \REP13}{\TEST[13;1]=0 and \TEST[13;2]=0 and \TEST[13;3]=0 and \step >=\CONDSTEP[13]}{option=hide}
\condition{Question 14 : \REP14}{\TEST[14;3]=0 and \step >=\CONDSTEP[14]}{option=hide}
\condition{Question 14 : \REP14}{\TEST[14;1]=0 and \TEST[14;2]=0 and \TEST[14;3]=0 and \step >=\CONDSTEP[14]}{option=hide}
\condition{Question 15 : \REP15}{\TEST[15;3]=0 and \step >=\CONDSTEP[15]}{option=hide}
\condition{Question 15 : \REP15}{\TEST[15;1]=0 and \TEST[15;2]=0 and \TEST[15;3]=0 and \step >=\CONDSTEP[15]}{option=hide}
\condition{Question 16 : \REP16}{\TEST[16;3]=0 and \step >=\CONDSTEP[16]}{option=hide}
\condition{Question 16 : \REP16}{\TEST[16;1]=0 and \TEST[16;2]=0 and \TEST[16;3]=0 and \step >=\CONDSTEP[16]}{option=hide}
\condition{Question 17 : \REP17}{\TEST[17;3]=0 and \step >=\CONDSTEP[17]}{option=hide}
\condition{Question 17 : \REP17}{\TEST[17;1]=0 and \TEST[17;2]=0 and \TEST[17;3]=0 and \step >=\CONDSTEP[17]}{option=hide}
\condition{Question 18 : \REP18}{\TEST[18;3]=0 and \step >=\CONDSTEP[18]}{option=hide}
\condition{Question 18 : \REP18}{\TEST[18;1]=0 and \TEST[18;2]=0 and \TEST[18;3]=0 and \step >=\CONDSTEP[18]}{option=hide}
\condition{Question 19 : \REP19}{\TEST[19;3]=0 and \step >=\CONDSTEP[19]}{option=hide}
\condition{Question 19 : \REP19}{\TEST[19;1]=0 and \TEST[19;2]=0 and \TEST[19;3]=0 and \step >=\CONDSTEP[19]}{option=hide}
\condition{Question 20 : \REP20}{\TEST[20;3]=0 and \step >=\CONDSTEP[20]}{option=hide}
\condition{Question 20 : \REP20}{\TEST[20;1]=0 and \TEST[20;2]=0 and \TEST[20;3]=0 and \step >=\CONDSTEP[20]}{option=hide}


\text{test=wims(rows2lines \explication)}
\text{test=wims(lines2items \test)}
\text{test=wims(items2words \test)}
\text{test=wims(nospace \test)}
feedback{1=1}{
   \if{\test notsametext}{
     <div class="reponse"><ol>
      \for{w = 1 to \MAX}{
        \if{\explication[\w;] notsametext }
         {<li style="list-style:decimal;" value="\w">\explication[\w;] </li>}
     }
     </ol>
    </div>
  }
}
{<ol>
  \for{ t = 1 to \N}{
    \if{\CNT[\step;\t] != }{
  <li style="list-style:decimal;" value="\CNT[\step;\t]"> <b>\question[\N*(\step-1) + \t;]</b>
  <div class="question"><ol>
   \for{s=1 to \CNT_choix[\N*(\step-1) + \t]}{
   <li>\embed{\STEPS[\step;\t] , \s }</li>
    }
   </ol>
   </div>
   </li>}
 }
</ol>
}
