Subversion Repositories wimsdev

Rev

Rev 13715 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
11375 bpr 1
type=classify
13715 obado 2
textarea="data pre post"
3
iEdit="pre post"
23 reyssat 4
 
5
:Classify objects according to their properties, drag-and-drop.
6
 
4131 bpr 7
The exercise presents a list of items to be classified
8
according to their properties. Drag each item beside the corresponding property.
23 reyssat 9
<p>
13704 obado 10
To make an exercise with this model,
11
 type the list of items and their properties.
12
</p><p>
4131 bpr 13
With a slight modification, a variant of this model can accept images as items.
13704 obado 14
</p><p class="wims_credits">
15179 lemaire 15
Author of the model: <a href="mailto:qualite@wimsedu.info">Gang Xiao</a></p>
23 reyssat 16
 
17
:%%%%%%%%%%%%%%%%%      ATTENTION      %%%%%%%%%%%%%%%%%%%%
18
 
4131 bpr 19
Remove the above header if you destroy the model tags i.e the lines starting
20
with a ':'. Otherwise the exercise might not be recognised by Createxo.
23 reyssat 21
 
22
:%%%%%%%% Example parameters to be redefined %%%%%%%%%%%%%%%%%
23
 
4131 bpr 24
:\title{Classification: drag and drop}
5147 bpr 25
:\author{XIAO, Gang}
8002 bpr 26
:\email{qualite@wimsedu.info}
5724 bpr 27
:\credits{}
23 reyssat 28
 
4131 bpr 29
:Number of items to classify by exercise: up to 20.
23 reyssat 30
\integer{tot=8}
31
 
13704 obado 32
:Maximum number of items with the same property
4174 bpr 33
This number must be greater than 1.
23 reyssat 34
\integer{max1=4}
35
 
4131 bpr 36
:The size of labels to drag, in pixels, x times y.
4135 bpr 37
Think of people who have to increase the font size of their browsers to see well! Don't make the labels too small!
23 reyssat 38
\text{size1=100x40}
39
 
4131 bpr 40
:List of properties: up to 10, separated by commas.
7137 bpr 41
\text{prop=Insect,Bird,Mammal}
23 reyssat 42
 
13704 obado 43
:Amount of properties to display (by default the number of properties)
44
If the amount of properties to display is strictly less than the total number of properties,
45
a distractor will be chosen from undrawn properties.
46
\text{prop_cnt=}
47
 
23 reyssat 48
:Main data.
4131 bpr 49
Define one item per line, first the name of the item, then the property,
13705 obado 50
separated by a comma.<p>
10949 bpr 51
It is best to provide lot of data for each category and at least two items for
52
each properties.</p><p>
8002 bpr 53
Be careful to use exactly the same spelling and case when you type
10949 bpr 54
the properties (e.g. <b>Bird</b> and <b>bird</b> will be counted as two different properties)!
55
Otherwise the exercise may not work properly.</p>
23 reyssat 56
\matrix{data=
57
Eagle,Bird
58
Albatross,Bird
59
Spider,Insect
7137 bpr 60
Duck,Bird
61
Cat,Mammal
23 reyssat 62
Horse,Mammal
63
Dog,Mammal
64
Pig,Mammal
65
Corbel,Bird
66
Locust,Insect
67
Elephant,Mammal
68
Falcon,Bird
69
Seagull,Bird
70
Gueppe,Insect
71
Bee,Insect
72
Lion,Mammal
73
Sparrow,Bird
74
Fly,Insect
75
Mosquito,Insect
76
Sheep,Mammal
77
Goose,Bird
78
Butterfly,Insect
79
Pigeon,Bird
80
Fox,Mammal
81
Nightingale,Bird
82
Scorpion,Insect
83
Monkey,Mammal
84
tiger,Mammal
85
Cow,Mammal
86
}
87
 
4131 bpr 88
:Optional words.
11319 bpr 89
Add <ul><li> the word <span class="wims_code_words">shuffle</span>
90
if you want the order of properties to be randomized,</li>
91
 <li>the word <span class="wims_code_words">vertical</span> if you wish a vertical disposition.</li></ul>
23 reyssat 92
\text{option=}
93
 
94
:Text before the table. html tags allowed.
7169 bpr 95
\text{pre=Classify the following animals according to which category they fall into.}
23 reyssat 96
 
97
:Text after the table. html tags allowed.
98
\text{post=}
99
 
100
:Verb and article to post before the classified category.
101
\text{estun=is}
102
 
4135 bpr 103
:What message to display if an item cannot be classified?
23 reyssat 104
\text{noclass=does not belong to any category}
105
 
106
:%%%%%%%%%%%%%% Nothing to modify before the statement %%%%%%%%%%%%%%%%
107
 
108
\integer{pcnt=items(\prop)}
5272 bpr 109
\integer{prop_cnt=\prop_cnt=? \pcnt}
110
\integer{prop_cnt=min(\prop_cnt,\pcnt)}
23 reyssat 111
\integer{datacnt=rows(\data)}
112
\integer{max2=\max1+1}
113
\integer{tot=\tot<\pcnt?\pcnt}
114
\text{prop=\pcnt>1 and shuffle iswordof \option?shuffle(\prop)}
115
 
116
\text{first=}
117
\text{firsti=}
118
\text{second=}
119
\text{secondi=}
5272 bpr 120
\text{dist=}
121
\text{disti=}
122
\for{i=1 to \prop_cnt}{
23 reyssat 123
 \text{t=shuffle(column(1,wims(select \data where column 2 issametext \prop[\i])))}
124
 \integer{s=min(\max1,items(\t))}
125
 \text{first=wims(append item \t[1] to \first)}
126
 \text{firsti=wims(append item \i to \firsti)}
127
 \if{\s > 1}{
128
  \text{second=wims(append item \t[2..\s] to \second)}
129
  \text{secondi=wims(append item wims(makelist \i for x=2 to \s) to \secondi)}
130
 }
131
}
13704 obado 132
# distractor
5272 bpr 133
\if{\prop_cnt<\pcnt}{
134
 \text{t=shuffle(column(1,wims(select \data where column 2 issametext \prop[\prop_cnt+1])))}
135
 \integer{s=min(\max1,items(\t))}
136
 \text{dist=wims(append item \t[1] to \dist)}
137
 \text{disti=wims(append item \i to \disti)}
138
}
23 reyssat 139
 
5272 bpr 140
\if{\tot>\prop_cnt}{
23 reyssat 141
 \integer{scnt=items(\second)}
5272 bpr 142
 \integer{secnt=min(\tot-\prop_cnt,\scnt)}
143
 \integer{tot=\prop_cnt+\secnt}
23 reyssat 144
 \text{sh2=shuffle(\scnt)}
145
 \text{sh2=\sh2[1..\secnt]}
146
 \text{second=item(\sh2,\second)}
147
 \text{secondi=item(\sh2,\secondi)}
148
 \text{all=\first,\second}
149
 \text{alli=\firsti,\secondi}
150
}{
151
 \text{all=\first}
152
 \text{alli=\firsti}
153
}
5272 bpr 154
\text{all=wims(nonempty items \all)}
155
\text{all=wims(listuniq \all)}
23 reyssat 156
\integer{acnt=items(\all)}
157
\text{sh=shuffle(\acnt)}
158
\text{all=item(\sh,\all)}
159
\text{alli=item(\sh,\alli)}
5272 bpr 160
\text{prop=\prop[1..\prop_cnt]}
23 reyssat 161
\text{props=wims(tolower \prop)}
162
\text{alls=wims(tolower \all)}
163
\text{size=\size1 x \max2}
11169 bpr 164
\text{sizev=\size x \max2}
5272 bpr 165
\text{rep=item(1..\prop_cnt,wims(makelist r x for x=1 to 10))}
23 reyssat 166
\steps{\rep}
5272 bpr 167
\integer{distc=\dist!= ? 1 : 0}
168
\conditions{wims(makelist x for x=1 to \acnt + \distc)}
23 reyssat 169
 
170
:%%%%%%%%%%%%% Now the statement in html. %%%%%%%%%%%%%%%%%%%%
171
 
4177 bpr 172
::This is the command that shows that reply field number 3 for example, is
13704 obado 173
#\embed{reply 3,\size} <p>
174
#And the name of the property number 4, is \prop[4] with the first letter
175
#in upper case, or \props[4] in lower case.
23 reyssat 176
 
13704 obado 177
\statement{
178
<div class="instruction">\pre</div>
5723 bpr 179
<table class="wimsnoborder">
11169 bpr 180
\if{vertical iswordof \option}{
181
  <tr>\for{k=1 to \prop_cnt}{<th>\prop[\k]</th>}</tr>
182
  <tr>\for{k=1 to \prop_cnt}{
11319 bpr 183
    <td style="text-align:left;vertical-align:top">\embed{reply \k, \sizev}</td>}
11169 bpr 184
  </tr>
185
}{
186
  \for{k=1 to \prop_cnt}{
187
   <tr>
188
     <th>\prop[\k]</th>
189
     <td style="text-align:left">\embed{reply \k, \size}</td>
190
   </tr>
191
  }
192
 }
193
</table>
13704 obado 194
<div class="post">\post</div>
23 reyssat 195
}
196
 
11169 bpr 197
:%%%%%%%%%%%%% Nothing to modify after. %%%%%%%%%%%%%%%%%
23 reyssat 198
 
7137 bpr 199
\answer{\prop[1]}{\r1;\all,\dist}{type=dragfill}
23 reyssat 200
\answer{\prop[2]}{\r2}{type=dragfill}
201
\answer{\prop[3]}{\r3}{type=dragfill}
202
\answer{\prop[4]}{\r4}{type=dragfill}
203
\answer{\prop[5]}{\r5}{type=dragfill}
204
\answer{\prop[6]}{\r6}{type=dragfill}
205
\answer{\prop[7]}{\r7}{type=dragfill}
206
\answer{\prop[8]}{\r8}{type=dragfill}
207
\answer{\prop[9]}{\r9}{type=dragfill}
208
\answer{\prop[10]}{\r10}{type=dragfill}
209
 
5272 bpr 210
\text{totans=item(1..\prop_cnt,
23 reyssat 211
	wims(items2words \r1),
212
	wims(items2words \r2),
213
	wims(items2words \r3),
214
	wims(items2words \r4),
215
	wims(items2words \r5),
216
	wims(items2words \r6),
217
	wims(items2words \r7),
218
	wims(items2words \r8),
219
	wims(items2words \r9),
220
	wims(items2words \r10))}
221
text{totans=wims(replace internal &#39; to ' in \totans)}
222
\text{clean=}
223
\text{check=}
5272 bpr 224
\for{t=1 to \acnt}{
23 reyssat 225
 \integer{cat=0}
5272 bpr 226
 \for{r=1 to \prop_cnt}{
23 reyssat 227
  \integer{cat=\all[\t] iswordof \totans[\r]?\r}
228
 }
229
 \if{\cat > 0}{
230
  \text{clean=\clean \estun \props[\cat],}
231
  \text{check=\alli[\t]=\cat?\check 1,:\check 0,}
232
 }{
233
  \text{clean=\clean \noclass,}
234
  \text{check=\check 0,}
235
 }
236
}
7137 bpr 237
 
5272 bpr 238
\if{\dist!=}{
239
 \for{t=1 to 1}{
7137 bpr 240
   \integer{cat=0}
241
   \for{r=1 to \prop_cnt}{
242
    \integer{cat=\dist[\t] iswordof \totans[\r]?\r}
243
   }
244
 \if{\cat = 0}{
5272 bpr 245
   \text{clean=\clean \dist[\t] \noclass,}
246
   \text{check=\check 1,}
247
  }{
7137 bpr 248
   \text{clean=\clean \dist[\t] \estun \props[\cat],}
5272 bpr 249
   \text{check=\check 0,}
250
  }
251
 }
252
}
23 reyssat 253
 
254
\condition{\all[1] \clean[1]}{\check[1]=1}
255
\condition{\all[2] \clean[2]}{\check[2]=1}
256
\condition{\all[3] \clean[3]}{\check[3]=1}
257
\condition{\all[4] \clean[4]}{\check[4]=1}
258
\condition{\all[5] \clean[5]}{\check[5]=1}
259
\condition{\all[6] \clean[6]}{\check[6]=1}
260
\condition{\all[7] \clean[7]}{\check[7]=1}
261
\condition{\all[8] \clean[8]}{\check[8]=1}
262
\condition{\all[9] \clean[9]}{\check[9]=1}
263
\condition{\all[10] \clean[10]}{\check[10]=1}
264
\condition{\all[11] \clean[11]}{\check[11]=1}
265
\condition{\all[12] \clean[12]}{\check[12]=1}
266
\condition{\all[13] \clean[13]}{\check[13]=1}
267
\condition{\all[14] \clean[14]}{\check[14]=1}
268
\condition{\all[15] \clean[15]}{\check[15]=1}
269
\condition{\all[16] \clean[16]}{\check[16]=1}
270
\condition{\all[17] \clean[17]}{\check[17]=1}
271
\condition{\all[18] \clean[18]}{\check[18]=1}
272
\condition{\all[19] \clean[19]}{\check[19]=1}
273
\condition{\all[20] \clean[20]}{\check[20]=1}