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