Rev 13716 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
13716 | obado | 1 | type=classify datalist |
2 | textarea="data pre post" |
||
3 | iEdit="pre post" |
||
134 | bpr | 4 | |
2071 | zjchen | 5 | :根据性质把对象分类, 鼠标拖放. |
134 | bpr | 6 | |
2071 | zjchen | 7 | 本练习展示了一些对象的表, 要求按它们的性质作分类, |
8 | 这是通过鼠标拖放来实现的. |
||
134 | bpr | 9 | <p> |
8002 | bpr | 10 | 为了构造这种类型的练习, |
2071 | zjchen | 11 | 只需给出对象以及它们的性质的表. |
13488 | obado | 12 | </p><p> |
13 | 只要稍作修改就能使用图像对象.</p> |
||
15179 | lemaire | 14 | <p class="wims_credits">模块作者: <a href="mailto:qualite@wimsedu.info">Gang Xiao</a></p> |
134 | bpr | 15 | |
2071 | zjchen | 16 | :%%%%%%%%%%%%%%%%% 注 意 %%%%%%%%%%%%%%%%%%%% |
134 | bpr | 17 | |
2071 | zjchen | 18 | 如果你删去了本范例中的标签 (即跟随在冒号 ':' 后面的那几行), |
19 | 那么也请删去这个头部, 否则有可能回不到 Createxo. |
||
134 | bpr | 20 | |
2071 | zjchen | 21 | :%%%%%%%%%%%%%%%%% 被重新定义的参数示例 %%%%%%%%%%%%%%%%%% |
134 | bpr | 22 | |
2071 | zjchen | 23 | :\title{按性质分类} |
134 | bpr | 24 | :\author{XIAO Gang} |
8002 | bpr | 25 | :\email{qualite@wimsedu.info} |
11319 | bpr | 26 | :\credits{} |
134 | bpr | 27 | |
2071 | zjchen | 28 | :在练习中需要分类的对象个数. 至多 20 个. |
134 | bpr | 29 | \integer{tot=8} |
30 | |||
2071 | zjchen | 31 | : 被展示的具有相同性质的对象的最大个数. |
32 | 这个数字应该严格大于 1. |
||
134 | bpr | 33 | \integer{max1=4} |
34 | |||
5321 | zjchen | 35 | : 欲展示的性质数 (默认就是性质数) |
36 | 若此数小于性质数, |
||
37 | 会在未提取的性质中选一个闲置项. |
||
5307 | bpr | 38 | \text{prop_cnt=} |
39 | |||
2071 | zjchen | 40 | :被拖放对象的大小, 以像素为单位, x 乘 y. |
41 | 考虑到用户可能会增大浏览器的字体, 因此不能取得太小. |
||
134 | bpr | 42 | \text{size1=100x40} |
43 | |||
2071 | zjchen | 44 | :性质的表. 最多 10, 用逗号分隔. |
45 | \text{prop=昆虫,鸟类,哺乳动物} |
||
134 | bpr | 46 | |
2071 | zjchen | 47 | :主要数据. |
48 | 每个对象占一行, 先是名称, 然后是性质, |
||
49 | 用逗号分隔. <p> |
||
50 | 最好每个范畴都含有足够数量的对象. |
||
51 | 注意在输入性质时不要出现打字错误! |
||
52 | 否则这个对象会使练习崩溃. |
||
134 | bpr | 53 | \matrix{data= |
2071 | zjchen | 54 | 鹰,鸟类 |
55 | 信天翁,鸟类 |
||
56 | 蜘蛛,昆虫 |
||
57 | 鸭, 鸟类 |
||
58 | 猫, 哺乳动物 |
||
59 | 马,哺乳动物 |
||
60 | 狗,哺乳动物 |
||
61 | 猪,哺乳动物 |
||
62 | 乌鸦,鸟类 |
||
63 | 蚱蜢,昆虫 |
||
64 | 象,哺乳动物 |
||
65 | 猎鹰,鸟类 |
||
66 | 海鸥,鸟类 |
||
67 | 蜈蚣,昆虫 |
||
68 | 蜂,昆虫 |
||
69 | 狮子,哺乳动物 |
||
70 | 燕子,鸟类 |
||
71 | 蝇,昆虫 |
||
72 | 蚊,昆虫 |
||
73 | 羊,哺乳动物 |
||
74 | 鹅,鸟类 |
||
75 | 蝴蝶,昆虫 |
||
76 | 鸽,鸟类 |
||
77 | 狐狸,哺乳动物 |
||
78 | 夜莺,鸟类 |
||
79 | 蝎,昆虫 |
||
80 | 猴,哺乳动物 |
||
81 | 虎,哺乳动物 |
||
82 | 牛,哺乳动物 |
||
134 | bpr | 83 | } |
84 | |||
2071 | zjchen | 85 | :选项. |
86 | 如果你想随机排列性质的次序, 可使用选项 "shuffle". |
||
134 | bpr | 87 | \text{option=} |
88 | |||
2071 | zjchen | 89 | :表格前面的文字. 可以使用 html 标注. |
11319 | bpr | 90 | \text{pre=请根据所给范畴分类下列动物.} |
134 | bpr | 91 | |
2071 | zjchen | 92 | :表格后面的文字. 可以使用 html 标注. |
134 | bpr | 93 | \text{post=} |
94 | |||
2071 | zjchen | 95 | :在范畴前的系词. |
96 | \text{estun=是} |
||
134 | bpr | 97 | |
2071 | zjchen | 98 | :如何称呼不能分类的对象? |
99 | \text{noclass=不属于任何范畴} |
||
134 | bpr | 100 | |
2071 | zjchen | 101 | :%%%%%%%%%%%%%% 不要改动下面这段命令 %%%%%%%%%%%%%%%% |
134 | bpr | 102 | |
103 | \integer{pcnt=items(\prop)} |
||
5272 | bpr | 104 | \integer{prop_cnt=\prop_cnt=? \pcnt} |
105 | \integer{prop_cnt=min(\prop_cnt,\pcnt)} |
||
134 | bpr | 106 | \integer{datacnt=rows(\data)} |
107 | \integer{max2=\max1+1} |
||
108 | \integer{tot=\tot<\pcnt?\pcnt} |
||
109 | \text{prop=\pcnt>1 and shuffle iswordof \option?shuffle(\prop)} |
||
110 | |||
111 | \text{first=} |
||
112 | \text{firsti=} |
||
113 | \text{second=} |
||
114 | \text{secondi=} |
||
5272 | bpr | 115 | \text{dist=} |
116 | \text{disti=} |
||
117 | \for{i=1 to \prop_cnt}{ |
||
134 | bpr | 118 | \text{t=shuffle(column(1,wims(select \data where column 2 issametext \prop[\i])))} |
119 | \integer{s=min(\max1,items(\t))} |
||
120 | \text{first=wims(append item \t[1] to \first)} |
||
121 | \text{firsti=wims(append item \i to \firsti)} |
||
122 | \if{\s > 1}{ |
||
123 | \text{second=wims(append item \t[2..\s] to \second)} |
||
124 | \text{secondi=wims(append item wims(makelist \i for x=2 to \s) to \secondi)} |
||
125 | } |
||
126 | } |
||
5272 | bpr | 127 | distracteur |
128 | \if{\prop_cnt<\pcnt}{ |
||
129 | \text{t=shuffle(column(1,wims(select \data where column 2 issametext \prop[\prop_cnt+1])))} |
||
130 | \integer{s=min(\max1,items(\t))} |
||
131 | \text{dist=wims(append item \t[1] to \dist)} |
||
132 | \text{disti=wims(append item \i to \disti)} |
||
133 | } |
||
134 | bpr | 134 | |
5272 | bpr | 135 | \if{\tot>\prop_cnt}{ |
134 | bpr | 136 | \integer{scnt=items(\second)} |
5272 | bpr | 137 | \integer{secnt=min(\tot-\prop_cnt,\scnt)} |
138 | \integer{tot=\prop_cnt+\secnt} |
||
134 | bpr | 139 | \text{sh2=shuffle(\scnt)} |
140 | \text{sh2=\sh2[1..\secnt]} |
||
141 | \text{second=item(\sh2,\second)} |
||
142 | \text{secondi=item(\sh2,\secondi)} |
||
143 | \text{all=\first,\second} |
||
144 | \text{alli=\firsti,\secondi} |
||
145 | }{ |
||
146 | \text{all=\first} |
||
147 | \text{alli=\firsti} |
||
148 | } |
||
5272 | bpr | 149 | \text{all=wims(nonempty items \all)} |
150 | \text{all=wims(listuniq \all)} |
||
134 | bpr | 151 | \integer{acnt=items(\all)} |
152 | \text{sh=shuffle(\acnt)} |
||
153 | \text{all=item(\sh,\all)} |
||
154 | \text{alli=item(\sh,\alli)} |
||
5272 | bpr | 155 | \text{prop=\prop[1..\prop_cnt]} |
134 | bpr | 156 | \text{props=wims(tolower \prop)} |
157 | \text{alls=wims(tolower \all)} |
||
158 | \text{size=\size1 x \max2} |
||
11169 | bpr | 159 | \text{sizev=\size x \max2} |
5272 | bpr | 160 | \text{rep=item(1..\prop_cnt,wims(makelist r x for x=1 to 10))} |
134 | bpr | 161 | \steps{\rep} |
5272 | bpr | 162 | \integer{distc=\dist!= ? 1 : 0} |
163 | \conditions{wims(makelist x for x=1 to \acnt + \distc)} |
||
134 | bpr | 164 | |
2071 | zjchen | 165 | :%%%%%%%%%%%%% 现在可以用 html 格式填入问题的陈述 %%%%%%%%%%%%%%%%%%%%%%%%% |
134 | bpr | 166 | |
2071 | zjchen | 167 | ::在文中可使用 \embed{reply 3,\size} 表示第 3 个回答栏 <p> |
168 | 用 \prop[4] 或 \props[4] 指第 4 个性质, 前者表示首字母大写, |
||
169 | 后者表示首字母小写. |
||
134 | bpr | 170 | |
11165 | bpr | 171 | \statement{<div class="instruction"> |
172 | \pre |
||
173 | </div> |
||
174 | <table class="wimsnoborder"> |
||
11169 | bpr | 175 | \if{vertical iswordof \option}{ |
176 | <tr>\for{k=1 to \prop_cnt}{<th>\prop[\k]</th>}</tr> |
||
177 | <tr>\for{k=1 to \prop_cnt}{ |
||
11319 | bpr | 178 | <td style="text-align:left;vertical-align:top">\embed{reply \k, \sizev}</td>} |
11169 | bpr | 179 | </tr> |
180 | }{ |
||
181 | \for{k=1 to \prop_cnt}{ |
||
182 | <tr> |
||
183 | <th>\prop[\k]</th> |
||
184 | <td style="text-align:left">\embed{reply \k, \size}</td> |
||
185 | </tr> |
||
186 | } |
||
187 | } |
||
188 | </table> |
||
189 | \post |
||
134 | bpr | 190 | } |
191 | |||
2071 | zjchen | 192 | :%%%%%%%%%%%%% 不要改动以下的命令 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
134 | bpr | 193 | |
11169 | bpr | 194 | \answer{\prop[1]}{\r1;\all,\dist}{type=dragfill} |
134 | bpr | 195 | \answer{\prop[2]}{\r2}{type=dragfill} |
196 | \answer{\prop[3]}{\r3}{type=dragfill} |
||
197 | \answer{\prop[4]}{\r4}{type=dragfill} |
||
198 | \answer{\prop[5]}{\r5}{type=dragfill} |
||
199 | \answer{\prop[6]}{\r6}{type=dragfill} |
||
200 | \answer{\prop[7]}{\r7}{type=dragfill} |
||
201 | \answer{\prop[8]}{\r8}{type=dragfill} |
||
202 | \answer{\prop[9]}{\r9}{type=dragfill} |
||
203 | \answer{\prop[10]}{\r10}{type=dragfill} |
||
204 | |||
5272 | bpr | 205 | \text{totans=item(1..\prop_cnt, |
206 | wims(items2words \r1), |
||
207 | wims(items2words \r2), |
||
208 | wims(items2words \r3), |
||
209 | wims(items2words \r4), |
||
210 | wims(items2words \r5), |
||
211 | wims(items2words \r6), |
||
212 | wims(items2words \r7), |
||
213 | wims(items2words \r8), |
||
214 | wims(items2words \r9), |
||
215 | wims(items2words \r10))} |
||
134 | bpr | 216 | text{totans=wims(replace internal ' to ' in \totans)} |
217 | \text{clean=} |
||
218 | \text{check=} |
||
5272 | bpr | 219 | \for{t=1 to \acnt}{ |
134 | bpr | 220 | \integer{cat=0} |
5307 | bpr | 221 | \for{r=1 to \prop_cnt}{ |
134 | bpr | 222 | \integer{cat=\all[\t] iswordof \totans[\r]?\r} |
223 | } |
||
224 | \if{\cat > 0}{ |
||
225 | \text{clean=\clean \estun \props[\cat],} |
||
226 | \text{check=\alli[\t]=\cat?\check 1,:\check 0,} |
||
227 | }{ |
||
228 | \text{clean=\clean \noclass,} |
||
229 | \text{check=\check 0,} |
||
230 | } |
||
231 | } |
||
11169 | bpr | 232 | |
5272 | bpr | 233 | \if{\dist!=}{ |
234 | \for{t=1 to 1}{ |
||
11169 | bpr | 235 | \integer{cat=0} |
236 | \for{r=1 to \prop_cnt}{ |
||
237 | \integer{cat=\dist[\t] iswordof \totans[\r]?\r} |
||
238 | } |
||
239 | \if{\cat = 0}{ |
||
5272 | bpr | 240 | \text{clean=\clean \dist[\t] \noclass,} |
241 | \text{check=\check 1,} |
||
242 | }{ |
||
11169 | bpr | 243 | \text{clean=\clean \dist[\t] \estun \props[\cat],} |
5272 | bpr | 244 | \text{check=\check 0,} |
245 | } |
||
246 | } |
||
247 | } |
||
134 | bpr | 248 | |
249 | \condition{\all[1] \clean[1]}{\check[1]=1} |
||
250 | \condition{\all[2] \clean[2]}{\check[2]=1} |
||
251 | \condition{\all[3] \clean[3]}{\check[3]=1} |
||
252 | \condition{\all[4] \clean[4]}{\check[4]=1} |
||
253 | \condition{\all[5] \clean[5]}{\check[5]=1} |
||
254 | \condition{\all[6] \clean[6]}{\check[6]=1} |
||
255 | \condition{\all[7] \clean[7]}{\check[7]=1} |
||
256 | \condition{\all[8] \clean[8]}{\check[8]=1} |
||
257 | \condition{\all[9] \clean[9]}{\check[9]=1} |
||
258 | \condition{\all[10] \clean[10]}{\check[10]=1} |
||
259 | \condition{\all[11] \clean[11]}{\check[11]=1} |
||
260 | \condition{\all[12] \clean[12]}{\check[12]=1} |
||
261 | \condition{\all[13] \clean[13]}{\check[13]=1} |
||
262 | \condition{\all[14] \clean[14]}{\check[14]=1} |
||
263 | \condition{\all[15] \clean[15]}{\check[15]=1} |
||
264 | \condition{\all[16] \clean[16]}{\check[16]=1} |
||
265 | \condition{\all[17] \clean[17]}{\check[17]=1} |
||
266 | \condition{\all[18] \clean[18]}{\check[18]=1} |
||
267 | \condition{\all[19] \clean[19]}{\check[19]=1} |
||
268 | \condition{\all[20] \clean[20]}{\check[20]=1} |