Rev 11557 | Rev 13715 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4137 | bpr | 1 | type=game |
2 | textarea="data" |
||
3 | |||
4 | :Hangman |
||
5 | Find the words by selecting letters from the list provided. To win, the word must be found |
||
6 | before the man is hanged. |
||
13477 | obado | 7 | <p class="wims_credits"> |
4137 | bpr | 8 | Author of the model : Bernadette Perrin-Riou <bpr@math.u-psud.fr> |
9 | </p> |
||
10 | :%%%%%%%%%%%%%%%%% ATTENTION %%%%%%%%%%%%%%%%%%%% |
||
11 | |||
12 | Remove the above header if you destroy the model tags i.e. the lines starting |
||
13 | with a ':'. Otherwise the exercise might not be recognised by Createxo. |
||
14 | |||
5722 | bpr | 15 | :%%%%%%%% Example parameters to be redefined %%%%%%%%%%%%%%%%% |
4137 | bpr | 16 | :\title{Hangman} |
5147 | bpr | 17 | :\author{Csilla, Ducrocq} |
5724 | bpr | 18 | :\email{} |
19 | :\credits{} |
||
13477 | obado | 20 | |
4137 | bpr | 21 | :Instruction |
22 | Instruction |
||
23 | \text{instruction=Select the letters one by one and write the missing word.} |
||
24 | |||
25 | :Text of the feedback. This can be changed as you wish. |
||
26 | |||
27 | \text{feedback=That's right!} |
||
5722 | bpr | 28 | |
29 | :Feedback d'echec |
||
30 | Texte affiché à la fin de l'exercice, quand le mot n'a pas été trouvé. |
||
31 | \text{echec=Perdu !} |
||
32 | |||
33 | :Message sur le nombre d'essais restant |
||
34 | |||
35 | \text{message=Vous avez droit à XXXX erreurs} |
||
36 | |||
8512 | bpr | 37 | :Type of drawing |
4137 | bpr | 38 | Choix du dessin. 1: hangman, 2: rectangles with changing colours, 3: skull and crossbones |
5722 | bpr | 39 | \text{type=item(2,3 (skull and crossbones), |
40 | 2 (rectangles with changing colours), |
||
41 | 1 (hangman))} |
||
42 | |||
4137 | bpr | 43 | :Main data. |
44 | Write the missing words in the first column in lower case, write helps in the second column. |
||
45 | The words and the helps are separated by a comma. |
||
46 | |||
47 | \text{data=whale,the biggest mammal on Earth |
||
48 | rabbit,an animal with long ears |
||
49 | mouse,can refer to an animal or a computer device |
||
50 | hedgehog,an animal with prickles |
||
51 | giraffe, an animal with a very long neck |
||
52 | lion, is also called the king of the animals} |
||
53 | |||
54 | :%%%%%%%%%%%%%% Nothing to modify before the statement %%%%%%%%%%%%%%%% |
||
5722 | bpr | 55 | \text{Indication=Hint} |
56 | \text{motatrouver=Word to find} |
||
57 | \text{proposer=Select a letter (small)} |
||
58 | \text{typename=wims(declosing wims(word 2 to -1 of \type))} |
||
59 | \text{type=wims(word 1 of \type)} |
||
60 | \text{typename=wims(words2items wims(nospace \typename))} |
||
8512 | bpr | 61 | \text{typename=slib(oef/blank _,,\typename)} |
4137 | bpr | 62 | \text{mot=randrow(\data)} |
63 | \text{indication=\mot[2..-1]} |
||
64 | \text{mot=\mot[1]} |
||
5722 | bpr | 65 | \text{jok=—} |
4137 | bpr | 66 | \css{<style type="text/css"> |
5722 | bpr | 67 | .centrer{text-align:center;} |
68 | .seen {opacity:0.5;font-weight: bold;} |
||
69 | .lettres span{background-color:orange;font-size:20px;font-family:monospace;padding:0 0.5em;} |
||
70 | .w {padding : 0 2px;} |
||
71 | .word {background-color:orange;font-size:20px;white-space: nowrap;} |
||
72 | .forget {background-color:red;color:white;font-size:20px;} |
||
73 | .good {color:green;} |
||
74 | .bad {color:red;} |
||
75 | .indication {font-size:16px;font-weight:bold;} |
||
76 | .pendu {background-color:#CCC;width:80%;margin:auto;min-height:54px;padding:3px;} |
||
77 | .reponse, .lettres, .question {margin:1em;} |
||
78 | |||
79 | .dessin{border-right:1px dashed gray;} |
||
80 | .small_col{width:25%;} |
||
81 | .large_col{max-width:75%;} |
||
82 | .floating{float:left;} |
||
83 | |||
84 | .type2 span {background-color:green;color:green; display: inline-block; min-height: 40px;width: 40px;padding:0 0.5em;margin:2px;} |
||
85 | .type2 span.red {background-color:red;color:red;} |
||
86 | .type1 {min-width:210px;} |
||
87 | .type2,.type3 {min-width:80px;} |
||
4137 | bpr | 88 | </style> |
89 | } |
||
90 | \if{\type=1}{ |
||
5722 | bpr | 91 | \text{dessin=xrange 0,10 |
4137 | bpr | 92 | yrange 0,10 |
93 | lines black, 0,1,2,1 |
||
94 | lines black,1,1,1,8,5,8,5,6.5 |
||
95 | linewidth 3} |
||
5722 | bpr | 96 | |
4137 | bpr | 97 | \matrix{pendu=ellipse 5,6,1.5,1.5,red |
98 | lines red, 5,5.4,5,3 |
||
99 | lines red,4,4,5,5 |
||
100 | lines red,6,4,5,5 |
||
101 | lines red,6,2,5,3 |
||
102 | lines red,4,2,5,3} |
||
5722 | bpr | 103 | |
104 | \text{Dessin=<img src="draw(200,200 |
||
105 | \dessin)" alt="\typename[1]"/>} |
||
106 | |||
4137 | bpr | 107 | } |
5722 | bpr | 108 | |
109 | \text{contenu= } |
||
4137 | bpr | 110 | \if{\type=2}{ |
5722 | bpr | 111 | \text{contenu=\typename[2]} |
4137 | bpr | 112 | } |
5722 | bpr | 113 | |
114 | \if{\type>1}{ |
||
115 | \text{order=shuffle(6)} |
||
116 | \text{dessin= |
||
117 | <div class="pendu"> |
||
118 | <span id="essai_4">\contenu</span><span id="essai_5">\contenu</span> |
||
119 | <span id="essai_6">\contenu</span><span id="essai_1">\contenu</span> |
||
120 | <span id="essai_2">\contenu</span><span id="essai_3">\contenu</span> |
||
121 | </div> |
||
122 | } |
||
123 | \text{Dessin=\dessin} |
||
4137 | bpr | 124 | } |
125 | |||
126 | \text{nb=wims(charcnt \mot)} |
||
127 | \text{mot1=wims(words2items wims(singlespace \mot))} |
||
128 | \text{mot=wims(replace internal , by _ in \mot1)} |
||
129 | \text{mot=wims(text expand \mot using 10)} |
||
130 | \text{mot=wims(words2items \mot)} |
||
4755 | bpr | 131 | \text{blanc=position(_,\mot)} |
4137 | bpr | 132 | \text{MOT=wims(makelist \jok for x=1 to \nb)} |
4755 | bpr | 133 | \for{a in \blanc}{ |
134 | \text{MOT=wims(replace item number \a by _ in \MOT)} |
||
135 | } |
||
5722 | bpr | 136 | \text{MOT1=wims(makelist <span class="w">x</span> for x in \MOT) } |
4137 | bpr | 137 | \text{MOT2=wims(items2words \MOT1)} |
4755 | bpr | 138 | \text{MOT2=wims(replace internal _ by in \MOT2)} |
4137 | bpr | 139 | |
140 | \text{nstep=r1} |
||
141 | |||
5722 | bpr | 142 | \text{lettre1=a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z} |
143 | \text{accents=à,ä,â,é,è,ê,ë,î,ï,ô,ö,û,ù,-,!,?} |
||
144 | \text{lettre1=\lettre1,\accents} |
||
145 | \text{lettre=wims(makelist <span class="notseen">x</span> for x in \lettre1)} |
||
4137 | bpr | 146 | \text{lettre2=\lettre} |
147 | \text{lettre2=\lettre2[1..10] |
||
5722 | bpr | 148 | <br/>\lettre2[11..20] |
149 | <br/>\lettre2[21..30] |
||
150 | <br/>\lettre2[31..-1]} |
||
4137 | bpr | 151 | \text{lettre2=wims(replace internal , by in \lettre2)} |
152 | \nextstep{\nstep} |
||
153 | \text{cnt=0} |
||
154 | |||
5722 | bpr | 155 | \integer{reste=6 - \cnt} |
156 | \text{message=wims(replace internal XXXX by <strong>\reste</strong> in \message0)} |
||
157 | \statement{ |
||
8512 | bpr | 158 | <p class="instruction">\instruction</p> |
5722 | bpr | 159 | <p ><em>\Indication : <span class="indication">\indication</span></em></p> |
160 | <div class="floating small_col centrer type\type"> |
||
161 | <div class="dessin"><p>\message</p> |
||
162 | \Dessin</div> |
||
163 | </div> |
||
164 | <div class="floating large_col centrer"> |
||
165 | <div class="question">\motatrouver :<span class="word"> \MOT2</span></div> |
||
166 | <div class="reponse"> |
||
167 | <label for="reply\step">\proposer : </label> |
||
168 | \embed{r\step,1 |
||
169 | default |
||
11557 | bpr | 170 | autocomplete="off" maxlength="1" style="text-align:center;"} |
5722 | bpr | 171 | </div> |
172 | <div class="lettres">\lettre2</div> |
||
173 | </div> |
||
4137 | bpr | 174 | |
5722 | bpr | 175 | <br style="clear:both;"/> |
4137 | bpr | 176 | } |
177 | |||
178 | \answer{}{\rep1}{type=case}{option=noanalyzeprint} |
||
179 | \answer{}{\rep2}{type=case}{option=noanalyzeprint} |
||
180 | \answer{}{\rep3}{type=case}{option=noanalyzeprint} |
||
181 | \answer{}{\rep4}{type=case}{option=noanalyzeprint} |
||
182 | \answer{}{\rep5}{type=case}{option=noanalyzeprint} |
||
183 | \answer{}{\rep6}{type=case}{option=noanalyzeprint} |
||
184 | \answer{}{\rep7}{type=case}{option=noanalyzeprint} |
||
185 | \answer{}{\rep8}{type=case}{option=noanalyzeprint} |
||
186 | \answer{}{\rep9}{type=case}{option=noanalyzeprint} |
||
187 | \answer{}{\rep10}{type=case}{option=noanalyzeprint} |
||
188 | \answer{}{\rep11}{type=case}{option=noanalyzeprint} |
||
189 | \answer{}{\rep12}{type=case}{option=noanalyzeprint} |
||
190 | \answer{}{\rep13}{type=case}{option=noanalyzeprint} |
||
191 | \answer{}{\rep14}{type=case}{option=noanalyzeprint} |
||
192 | \answer{}{\rep15}{type=case}{option=noanalyzeprint} |
||
193 | \answer{}{\rep16}{type=case}{option=noanalyzeprint} |
||
194 | \answer{}{\rep17}{type=case}{option=noanalyzeprint} |
||
195 | \answer{}{\rep18}{type=case}{option=noanalyzeprint} |
||
196 | \answer{}{\rep19}{type=case}{option=noanalyzeprint} |
||
197 | \answer{}{\rep20}{type=case}{option=noanalyzeprint} |
||
198 | \answer{}{\rep21}{type=case}{option=noanalyzeprint} |
||
199 | \answer{}{\rep22}{type=case}{option=noanalyzeprint} |
||
200 | \answer{}{\rep23}{type=case}{option=noanalyzeprint} |
||
201 | \answer{}{\rep24}{type=case}{option=noanalyzeprint} |
||
202 | \answer{}{\rep25}{type=case}{option=noanalyzeprint} |
||
203 | \answer{}{\rep26}{type=case}{option=noanalyzeprint} |
||
204 | \answer{}{\rep27}{type=case}{option=noanalyzeprint} |
||
205 | \answer{}{\rep28}{type=case}{option=noanalyzeprint} |
||
206 | \answer{}{\rep29}{type=case}{option=noanalyzeprint} |
||
207 | \answer{}{\rep30}{type=case}{option=noanalyzeprint} |
||
208 | |||
209 | \text{rep=\rep1,\rep2,\rep3,\rep4,\rep5,\rep6,\rep7,\rep8,\rep9,\rep10,\rep11,\rep12,\rep13,\rep14, |
||
4754 | bpr | 210 | \rep15,\rep16,\rep17,\rep18,\rep19,\rep20,\rep21,\rep22,\rep23,\rep24, |
211 | \rep25,\rep26,\rep27,\rep28,\rep29,\rep30} |
||
4137 | bpr | 212 | |
5722 | bpr | 213 | |
214 | \text{w_class=good} |
||
215 | |||
216 | \if{\rep[\step-1] notitemof \mot }{ |
||
217 | \integer{cnt=\cnt+1} |
||
218 | \integer{reste=6 - \cnt} |
||
219 | \text{w_class=bad} |
||
220 | |||
221 | \if {\reste > 0}{ |
||
222 | \text{message=wims(replace internal XXXX by <strong>\reste</strong> in \message0)} |
||
223 | } |
||
224 | \if {\reste <= 0} { |
||
225 | \text{message=<strong class="oef_condbad">\echec</strong>} |
||
226 | } |
||
227 | |||
228 | \if{\type = 1}{ |
||
229 | \text{dessin=\dessin |
||
230 | \pendu[\cnt;]} |
||
231 | \text{Dessin=<img src="draw(200,200 |
||
232 | \dessin)" alt="Vous avez fait \cnt erreur(s). Vous avancez vers la pendaison..."/>} |
||
233 | } |
||
234 | |||
235 | \if{\type>1}{ |
||
236 | \integer{h=\order[\cnt]} |
||
237 | \text{jj=<span id="essai_\h">\contenu</span>} |
||
238 | \if{\type=2}{ |
||
239 | \text{dessin=wims(replace internal \jj by <span class="red">\typename[1]</span> in \dessin)} |
||
240 | } |
||
241 | \if{\type=3}{ |
||
242 | \text{dessin=wims(replace internal \jj by <img src="gifs/images/skull_and_crossbones50.png" alt="\typename[1]"/> in \dessin)} |
||
243 | } |
||
8512 | bpr | 244 | \text{Dessin=\dessin} |
5722 | bpr | 245 | } |
246 | } |
||
247 | |||
248 | # On affiche differement les lettres deja tapées |
||
4137 | bpr | 249 | \text{z=position(\rep[\step-1],\lettre1)} |
5722 | bpr | 250 | \text{lettre=wims(replace internal item number \z by <span class="seen \w_class">\rep[\step-1]</span> in \lettre)} |
251 | |||
252 | # On repartit les lettres par groupes de 10 maxi par ligne |
||
4137 | bpr | 253 | \text{lettre2=\lettre[1..10] |
5722 | bpr | 254 | <br/>\lettre[11..20] |
255 | <br/>\lettre[21..30] |
||
256 | <br/>\lettre[31..-1]} |
||
4137 | bpr | 257 | \text{lettre2=wims(replace internal , by in \lettre2)} |
5722 | bpr | 258 | |
259 | |||
4137 | bpr | 260 | \text{z=position(\rep[\step-1],\mot)} |
261 | \for{k in \z}{ |
||
262 | \text{MOT=wims(replace internal item number \k by \rep[\step-1] in \MOT)} |
||
263 | } |
||
5722 | bpr | 264 | |
265 | \text{MOT1=wims(makelist <span class="w">x</span> for x in \MOT)} |
||
4137 | bpr | 266 | \text{MOT2=wims(items2words \MOT1)} |
4755 | bpr | 267 | \text{MOT2=wims(replace internal _ by in \MOT2)} |
4137 | bpr | 268 | \text{nstep=} |
269 | \text{nstep=\jok isitemof \MOT and \step<30 and \cnt<6 ? r \step} |
||
270 | \if{\step>30 or \cnt>=6}{ |
||
271 | \text{w=position(\jok,\MOT)} |
||
272 | \for{a in \w}{ |
||
5722 | bpr | 273 | \text{MOT1=wims(replace internal item number \a by <span class="w forget">\mot[\a]</span> in \MOT1)} |
4137 | bpr | 274 | } |
275 | \text{MOT2=wims(items2words \MOT1)} |
||
4755 | bpr | 276 | \text{MOT2=wims(replace internal _ by in \MOT2)} |
4137 | bpr | 277 | } |
278 | |||
279 | \condition{Vous avez trouvé le mot ?}{\jok notitemof \MOT} |
||
280 | \condition{}{\cnt<=3}{option=hide} |
||
281 | \condition{}{\cnt<=4}{option=hide} |