Rev 13715 | Blame | Compare with Previous | Last modification | View Log | RSS feed
type=classify
textarea="data pre post"
iEdit="pre post"
:Classify objects according to their properties, drag-and-drop.
The exercise presents a list of items to be classified
according to their properties. Drag each item beside the corresponding property.
<p>
To make an exercise with this model,
type the list of items and their properties.
</p><p>
With a slight modification, a variant of this model can accept images as items.
</p><p class="wims_credits">
Author of the model: <a href="mailto:qualite@wimsedu.info">Gang Xiao</a></p>
:%%%%%%%%%%%%%%%%% ATTENTION %%%%%%%%%%%%%%%%%%%%
Remove the above header if you destroy the model tags i.e the lines starting
with a ':'. Otherwise the exercise might not be recognised by Createxo.
:%%%%%%%% Example parameters to be redefined %%%%%%%%%%%%%%%%%
:\title{Classification: drag and drop}
:\author{XIAO, Gang}
:\email{qualite@wimsedu.info}
:\credits{}
:Number of items to classify by exercise: up to 20.
\integer{tot=8}
:Maximum number of items with the same property
This number must be greater than 1.
\integer{max1=4}
:The size of labels to drag, in pixels, x times y.
Think of people who have to increase the font size of their browsers to see well! Don't make the labels too small!
\text{size1=100x40}
:List of properties: up to 10, separated by commas.
\text{prop=Insect,Bird,Mammal}
:Amount of properties to display (by default the number of properties)
If the amount of properties to display is strictly less than the total number of properties,
a distractor will be chosen from undrawn properties.
\text{prop_cnt=}
:Main data.
Define one item per line, first the name of the item, then the property,
separated by a comma.<p>
It is best to provide lot of data for each category and at least two items for
each properties.</p><p>
Be careful to use exactly the same spelling and case when you type
the properties (e.g. <b>Bird</b> and <b>bird</b> will be counted as two different properties)!
Otherwise the exercise may not work properly.</p>
\matrix{data=
Eagle,Bird
Albatross,Bird
Spider,Insect
Duck,Bird
Cat,Mammal
Horse,Mammal
Dog,Mammal
Pig,Mammal
Corbel,Bird
Locust,Insect
Elephant,Mammal
Falcon,Bird
Seagull,Bird
Gueppe,Insect
Bee,Insect
Lion,Mammal
Sparrow,Bird
Fly,Insect
Mosquito,Insect
Sheep,Mammal
Goose,Bird
Butterfly,Insect
Pigeon,Bird
Fox,Mammal
Nightingale,Bird
Scorpion,Insect
Monkey,Mammal
tiger,Mammal
Cow,Mammal
}
:Optional words.
Add <ul><li> the word <span class="wims_code_words">shuffle</span>
if you want the order of properties to be randomized,</li>
<li>the word <span class="wims_code_words">vertical</span> if you wish a vertical disposition.</li></ul>
\text{option=}
:Text before the table. html tags allowed.
\text{pre=Classify the following animals according to which category they fall into.}
:Text after the table. html tags allowed.
\text{post=}
:Verb and article to post before the classified category.
\text{estun=is}
:What message to display if an item cannot be classified?
\text{noclass=does not belong to any category}
:%%%%%%%%%%%%%% Nothing to modify before the statement %%%%%%%%%%%%%%%%
\integer{pcnt=items(\prop)}
\integer{prop_cnt=\prop_cnt=? \pcnt}
\integer{prop_cnt=min(\prop_cnt,\pcnt)}
\integer{datacnt=rows(\data)}
\integer{max2=\max1+1}
\integer{tot=\tot<\pcnt?\pcnt}
\text{prop=\pcnt>1 and shuffle iswordof \option?shuffle(\prop)}
\text{first=}
\text{firsti=}
\text{second=}
\text{secondi=}
\text{dist=}
\text{disti=}
\for{i=1 to \prop_cnt}{
\text{t=shuffle(column(1,wims(select \data where column 2 issametext \prop[\i])))}
\integer{s=min(\max1,items(\t))}
\text{first=wims(append item \t[1] to \first)}
\text{firsti=wims(append item \i to \firsti)}
\if{\s > 1}{
\text{second=wims(append item \t[2..\s] to \second)}
\text{secondi=wims(append item wims(makelist \i for x=2 to \s) to \secondi)}
}
}
# distractor
\if{\prop_cnt<\pcnt}{
\text{t=shuffle(column(1,wims(select \data where column 2 issametext \prop[\prop_cnt+1])))}
\integer{s=min(\max1,items(\t))}
\text{dist=wims(append item \t[1] to \dist)}
\text{disti=wims(append item \i to \disti)}
}
\if{\tot>\prop_cnt}{
\integer{scnt=items(\second)}
\integer{secnt=min(\tot-\prop_cnt,\scnt)}
\integer{tot=\prop_cnt+\secnt}
\text{sh2=shuffle(\scnt)}
\text{sh2=\sh2[1..\secnt]}
\text{second=item(\sh2,\second)}
\text{secondi=item(\sh2,\secondi)}
\text{all=\first,\second}
\text{alli=\firsti,\secondi}
}{
\text{all=\first}
\text{alli=\firsti}
}
\text{all=wims(nonempty items \all)}
\text{all=wims(listuniq \all)}
\integer{acnt=items(\all)}
\text{sh=shuffle(\acnt)}
\text{all=item(\sh,\all)}
\text{alli=item(\sh,\alli)}
\text{prop=\prop[1..\prop_cnt]}
\text{props=wims(tolower \prop)}
\text{alls=wims(tolower \all)}
\text{size=\size1 x \max2}
\text{sizev=\size x \max2}
\text{rep=item(1..\prop_cnt,wims(makelist r x for x=1 to 10))}
\steps{\rep}
\integer{distc=\dist!= ? 1 : 0}
\conditions{wims(makelist x for x=1 to \acnt + \distc)}
:%%%%%%%%%%%%% Now the statement in html. %%%%%%%%%%%%%%%%%%%%
::This is the command that shows that reply field number 3 for example, is
#\embed{reply 3,\size} <p>
#And the name of the property number 4, is \prop[4] with the first letter
#in upper case, or \props[4] in lower case.
\statement{
<div class="instruction">\pre</div>
<table class="wimsnoborder">
\if{vertical iswordof \option}{
<tr>\for{k=1 to \prop_cnt}{<th>\prop[\k]</th>}</tr>
<tr>\for{k=1 to \prop_cnt}{
<td style="text-align:left;vertical-align:top">\embed{reply \k, \sizev}</td>}
</tr>
}{
\for{k=1 to \prop_cnt}{
<tr>
<th>\prop[\k]</th>
<td style="text-align:left">\embed{reply \k, \size}</td>
</tr>
}
}
</table>
<div class="post">\post</div>
}
:%%%%%%%%%%%%% Nothing to modify after. %%%%%%%%%%%%%%%%%
\answer{\prop[1]}{\r1;\all,\dist}{type=dragfill}
\answer{\prop[2]}{\r2}{type=dragfill}
\answer{\prop[3]}{\r3}{type=dragfill}
\answer{\prop[4]}{\r4}{type=dragfill}
\answer{\prop[5]}{\r5}{type=dragfill}
\answer{\prop[6]}{\r6}{type=dragfill}
\answer{\prop[7]}{\r7}{type=dragfill}
\answer{\prop[8]}{\r8}{type=dragfill}
\answer{\prop[9]}{\r9}{type=dragfill}
\answer{\prop[10]}{\r10}{type=dragfill}
\text{totans=item(1..\prop_cnt,
wims(items2words \r1),
wims(items2words \r2),
wims(items2words \r3),
wims(items2words \r4),
wims(items2words \r5),
wims(items2words \r6),
wims(items2words \r7),
wims(items2words \r8),
wims(items2words \r9),
wims(items2words \r10))}
text{totans=wims(replace internal ' to ' in \totans)}
\text{clean=}
\text{check=}
\for{t=1 to \acnt}{
\integer{cat=0}
\for{r=1 to \prop_cnt}{
\integer{cat=\all[\t] iswordof \totans[\r]?\r}
}
\if{\cat > 0}{
\text{clean=\clean \estun \props[\cat],}
\text{check=\alli[\t]=\cat?\check 1,:\check 0,}
}{
\text{clean=\clean \noclass,}
\text{check=\check 0,}
}
}
\if{\dist!=}{
\for{t=1 to 1}{
\integer{cat=0}
\for{r=1 to \prop_cnt}{
\integer{cat=\dist[\t] iswordof \totans[\r]?\r}
}
\if{\cat = 0}{
\text{clean=\clean \dist[\t] \noclass,}
\text{check=\check 1,}
}{
\text{clean=\clean \dist[\t] \estun \props[\cat],}
\text{check=\check 0,}
}
}
}
\condition{\all[1] \clean[1]}{\check[1]=1}
\condition{\all[2] \clean[2]}{\check[2]=1}
\condition{\all[3] \clean[3]}{\check[3]=1}
\condition{\all[4] \clean[4]}{\check[4]=1}
\condition{\all[5] \clean[5]}{\check[5]=1}
\condition{\all[6] \clean[6]}{\check[6]=1}
\condition{\all[7] \clean[7]}{\check[7]=1}
\condition{\all[8] \clean[8]}{\check[8]=1}
\condition{\all[9] \clean[9]}{\check[9]=1}
\condition{\all[10] \clean[10]}{\check[10]=1}
\condition{\all[11] \clean[11]}{\check[11]=1}
\condition{\all[12] \clean[12]}{\check[12]=1}
\condition{\all[13] \clean[13]}{\check[13]=1}
\condition{\all[14] \clean[14]}{\check[14]=1}
\condition{\all[15] \clean[15]}{\check[15]=1}
\condition{\all[16] \clean[16]}{\check[16]=1}
\condition{\all[17] \clean[17]}{\check[17]=1}
\condition{\all[18] \clean[18]}{\check[18]=1}
\condition{\all[19] \clean[19]}{\check[19]=1}
\condition{\all[20] \clean[20]}{\check[20]=1}