Rev 4177 | Rev 5272 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
type=datalist
textarea="data"
: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>
With a slight modification, a variant of this model can accept images as items.
<p>
Author of the model: Gang Xiao <xiao@unice.fr>
:%%%%%%%%%%%%%%%%% 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{xiao@unice.fr}
:Number of items to classify by exercise: up to 20.
\integer{tot=8}
: The 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}
: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. <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.
\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 the word "shuffle" if you want the order of properties to be randomized.
\text{option=}
:Text before the table. html tags allowed.
\text{pre=Classify the following animals according to which category they fall into. <p>}
: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{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=}
\for{i=1 to \pcnt}{
\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)}
}
}
\if{\tot>\pcnt}{
\integer{scnt=items(\second)}
\integer{secnt=min(\tot-\pcnt,\scnt)}
\integer{tot=\pcnt+\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}
}
\integer{acnt=items(\all)}
\text{sh=shuffle(\acnt)}
\text{all=item(\sh,\all)}
\text{alli=item(\sh,\alli)}
\text{props=wims(tolower \prop)}
\text{alls=wims(tolower \all)}
\text{size=\size1 x \max2}
\text{rep=item(1..\pcnt,wims(makelist r x for x=1 to 10))}
\steps{\rep}
\conditions{wims(makelist x for x=1 to \tot)}
:%%%%%%%%%%%%% 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{\pre
<table border="0">
\for{k=1 to \pcnt}{
<tr><td align="right">\prop[\k]</td>
<td>\embed{reply \k, \size}
</td></tr>
}
</table>
\post
}
:%%%%%%%%%%%%% Nothing to modify after. %%%%%%%%%%%%%%%%%5
\answer{\prop[1]}{\r1;\all}{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..\pcnt,
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 \tot}{
\integer{cat=0}
\for{r=1 to \pcnt}{
\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,}
}
}
\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}