-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheXe2eLML.xsl
399 lines (385 loc) · 12.1 KB
/
eXe2eLML.xsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
<?xml version="1.0" encoding="UTF-8"?>
<!--
This XSLT program converts a document from the eXeLearning format to the eLML format.
More precisly it converts the "one HTML page" export of a eXeLearning document.
Warning : It has been created for my own purpose and I don't know if it will work for you
Distributed under the Creative-Common licence CC-BY
Marco Codutti ([email protected])
-->
<xsl:stylesheet xmlns="http://www.elml.ch" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output encoding="UTF-8" indent="yes"/>
<!--
============================================================
Main structure : one lesson including one unit
============================================================
-->
<xsl:template match="/">
<lesson xmlns="http://www.elml.ch"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.elml.ch ../../../_config/validate.xsd"
label="{/html/head/title}"
title="{/html/body/div/div[@id='main']/div[1]/div/p}">
<unit label="{/html/head/title}" title="{//div[@id='main']/div[1]/div/p}">
<xsl:apply-templates select="//div[@class='node']"/>
</unit>
</lesson>
</xsl:template>
<!--
============================================================
Treat a node :
The first node is used as the unit's <entry>
The other ones become learningObjects
============================================================
-->
<xsl:template match="div[@class='node']">
<xsl:choose>
<xsl:when test="position()=1">
<entry>
<xsl:apply-templates select="./*[position()>1]" mode="entry"/>
</entry>
</xsl:when>
<xsl:otherwise>
<learningObject title="{.//p[@id='nodeTitle']}">
<xsl:apply-templates select="./*[position()>1]" mode="lo"/>
</learningObject>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!--
============================================================
Convert each IDevice
============================================================
-->
<!--
Activity
Converted into a act/paragraph with 'act' icon
-->
<xsl:template match="div[@class='activityIdevice']" mode="lo">
<act>
<xsl:apply-templates select="." mode="entry"/>
</act>
</xsl:template>
<xsl:template match="div[@class='activityIdevice']" mode="entry">
<paragraph title="{.//span[@class='iDeviceTitle']}" icon="act"/>
<xsl:apply-templates select=".//div[@class='iDevice_inner']"/>
</xsl:template>
<!--
ClozeIdevice
Converted into a act/selCheck/fillInBlanks
Partially implemented (no solution, default gap)
-->
<xsl:template match="div[@class='ClozeIdevice']" mode="lo">
<act>
<xsl:apply-templates select="." mode="entry"/>
</act>
</xsl:template>
<xsl:template match="div[@class='ClozeIdevice']" mode="entry">
<selfCheck title="{.//span[@class='iDeviceTitle']}" shuffle="yes">
<fillInBlanks>
<question>
<xsl:apply-templates select=".//div[@class='iDevice_inner']/div[1]"/>
</question>
<gapText>
<xsl:apply-templates select=".//div[@class='iDevice_inner']/div[2]"/>
</gapText>
<solution></solution>
</fillInBlanks>
</selfCheck>
</xsl:template>
<xsl:template match="input[contains(@id,'clozeBlank')]">
<gap answers="">
<xsl:text>x</xsl:text>
</gap>
</xsl:template>
<xsl:template match="span[contains(@id,'clozeAnswer')]"/>
<!--
FreeText
Converted into a clarify without a title
-->
<xsl:template match="div[@class='FreeTextIdevice']" mode="lo">
<clarify>
<xsl:apply-templates/>
</clarify>
</xsl:template>
<xsl:template match="div[@class='FreeTextIdevice']" mode="entry">
<xsl:apply-templates select="." mode="entry"/>
</xsl:template>
<!--
MultipleChoiceiDevice
Converted into a act/selfCheck/multipleChoice
Shuffle mode : yes
Treated by eLML as a OneChoice if only one correct answer
-->
<xsl:template match="div[@class='MultiSelectIdevice']" mode="lo">
<act>
<xsl:apply-templates select="." mode="entry"/>
</act>
</xsl:template>
<xsl:template match="div[@class='MultiSelectIdevice']" mode="entry">
<selfCheck title="{.//span[@class='iDeviceTitle']}" shuffle="yes">
<multipleChoice>
<question>
<xsl:apply-templates select=".//div[@class='iDevice_inner']/div[@class='question']/div[1]"/>
</question>
<xsl:for-each select=".//tr[.//input]">
<xsl:variable name="answerNumber" select="position()"/>
<answer feedback="{position()}">
<xsl:attribute name="correct">
<xsl:if test=".//input/@value='True'">yes</xsl:if>
<xsl:if test=".//input/@value='False'">no</xsl:if>
</xsl:attribute>
<xsl:attribute name="feedback">
<xsl:value-of select="ancestor::div[@class='question']/div[last()]//p[$answerNumber]"/>
</xsl:attribute>
<xsl:apply-templates select="td[2]"/>
</answer>
</xsl:for-each>
</multipleChoice>
</selfCheck>
</xsl:template>
<!--
SingleChoiceiDevice
Converted into a act/selfCheck/multipleChoice
Shuffle mode : yes
Treated by eLML as a OneChoice if only one correct answer
-->
<xsl:template match="div[@class='MultichoiceIdevice']" mode="lo">
<act>
<xsl:apply-templates select="." mode="entry"/>
</act>
</xsl:template>
<xsl:template match="div[@class='MultichoiceIdevice']" mode="entry">
<selfCheck title="{.//span[@class='iDeviceTitle']}" shuffle="yes">
<multipleChoice>
<question>
<xsl:apply-templates select=".//div[@class='iDevice_inner']/div[@class='question']/div[1]"/>
</question>
<xsl:for-each select=".//tr[.//input]">
<xsl:variable name="answerNumber" select="position()"/>
<answer feedback="{position()}">
<xsl:attribute name="correct">
<xsl:if test=".//input/@value='True'">yes</xsl:if>
<xsl:if test=".//input/@value='False'">no</xsl:if>
</xsl:attribute>
<xsl:attribute name="feedback">
<xsl:value-of select="ancestor::div[@class='question']/div[last()]//p[$answerNumber]"/>
</xsl:attribute>
<xsl:apply-templates select="td[2]"/>
</answer>
</xsl:for-each>
</multipleChoice>
</selfCheck>
</xsl:template>
<!--
ObjectivesIDevice
Converted into a clarify/paragraph with the objective icon
-->
<xsl:template match="div[@class='objectivesIdevice']" mode="lo">
<clarify>
<xsl:apply-templates select="." mode="entry"/>
</clarify>
</xsl:template>
<xsl:template match="div[@class='objectivesIdevice']" mode="entry">
<paragraph title="{.//span[@class='iDeviceTitle']}" icon="objective"/>
<xsl:apply-templates select=".//div[@class='iDevice_inner']"/>
</xsl:template>
<!--
ReflectionIDevice
Converted into a act/paragraph with popup for the answer
icon : question
-->
<xsl:template match="div[@class='ReflectionIdevice']" mode="lo">
<act>
<xsl:apply-templates select="." mode="entry"/>
</act>
</xsl:template>
<xsl:template match="div[@class='ReflectionIdevice']" mode="entry">
<paragraph title="{.//span[@class='iDeviceTitle']}" icon="question"/>
<xsl:apply-templates select=".//div[@class='iDevice_inner']/div[1]"/>
<xsl:apply-templates select=".//div[@class='feedback']"/>
</xsl:template>
<!--
customIDevice
Converted into a clarify/paragraph
The icon is found in img/@src
-->
<xsl:template match="div[@class='customIdevice']" mode="lo">
<clarify>
<xsl:apply-templates select="." mode="entry"/>
</clarify>
</xsl:template>
<xsl:template match="div[@class='customIdevice']" mode="entry">
<paragraph
title="{.//span[@class='iDeviceTitle']}"
icon="{substring-before(.//img/@src,'.')}">
</paragraph>
<xsl:apply-templates select=".//div[@class='iDevice_inner']"/>
</xsl:template>
<!--
============================================================
Experimental IDevice conversions
============================================================
-->
<!--
TrueFalseIdevice
!!! Under Development !!!
Converted into a act>selfCheck>multipleChoice
with oui/non answer (yes/no in french)
Shuffle mode : no
-->
<xsl:template match="div[@class='TrueFalseIdevice']">
<act>
<xsl:variable name="exTitle" select=".//span[@class='iDeviceTitle']"/>
<xsl:for-each select="//div[@class='question']">
<selfCheck title="{$exTitle}" shuffle="no">
<multipleChoice>
<question>
<xsl:apply-templates select=".//div[starts-with(@id,'taquestion')]"/>
</question>
<xsl:for-each select=".//input">
<xsl:variable name="answerNumber" select="position()"/>
<answer>
<xsl:attribute name="correct">
<xsl:if test="following-sibling::div[position()=$answerNumber and @even_steven='96']">yes</xsl:if>
<xsl:if test="following-sibling::div[position()=$answerNumber and @even_steven='97']">no</xsl:if>
</xsl:attribute>
<!-- extract the feedback part -->
<!-- extract the text in the document -->
<xsl:choose>
v <xsl:when test="$answerNumber=1">Vrai</xsl:when>
<xsl:otherwise>Faux</xsl:otherwise>
</xsl:choose>
</answer>
</xsl:for-each>
</multipleChoice>
</selfCheck>
</xsl:for-each>
</act>
</xsl:template>
<!--
============================================================
iDevice's content
============================================================
-->
<!-- paragraph -->
<!-- no paragraph in a question -->
<xsl:template match="p">
<xsl:choose>
<xsl:when test="ancestor::div[@class='question']">
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
<paragraph>
<xsl:apply-templates/>
</paragraph>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- linebreak. Should be enclosed into a paragraph if not already done -->
<!--<xsl:template match="br">
<xsl:choose>
<xsl:when test="ancestor::p">
<newLine/>
</xsl:when>
<xsl:otherwise>
<paragraph><newLine/></paragraph>
</xsl:otherwise>
</xsl:choose>
</xsl:template>-->
<xsl:template match="br">
<newLine/>
</xsl:template>
<!-- List -->
<!-- Produce nothing if empty list -->
<xsl:template match="ul|ol">
<xsl:choose>
<xsl:when test=".//li">
<list>
<xsl:choose>
<xsl:when test="name()='ul'">
<xsl:attribute name="listStyle">unordered</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="listStyle">ordered</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates/>
</list>
</xsl:when>
</xsl:choose>
</xsl:template>
<xsl:template match="li">
<item>
<xsl:apply-templates/>
</item>
</xsl:template>
<!-- Texts styles : bold, italic, courier -->
<!-- Remove if empty -->
<xsl:template match="b">
<xsl:call-template name="formatted">
<xsl:with-param name="type" select="'bold'"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="i">
<xsl:call-template name="formatted">
<xsl:with-param name="type" select="'italic'"/>
</xsl:call-template>
</xsl:template>
<xsl:template match="font[@face='courier new,courier']">
<formatted style="code">
<xsl:apply-templates/>
</formatted>
</xsl:template>
<xsl:template name="formatted">
<xsl:param name="type"/>
<xsl:if test="string(.)">
<formatted style="{$type}">
<xsl:apply-templates/>
</formatted>
</xsl:if>
</xsl:template>
<!-- Images -->
<xsl:template match="img">
<popup title="Cliquez pour voir l'image">
<multimedia src="../image/{@src}" type="jpeg"/>
</popup>
</xsl:template>
<!-- feedback becomes popup -->
<xsl:template match="div[@class='feedback']">
<popup>
<xsl:apply-templates/>
</popup>
</xsl:template>
<!-- tables -->
<xsl:template match="table">
<table>
<xsl:apply-templates/>
</table>
</xsl:template>
<xsl:template match="tr">
<tablerow>
<xsl:apply-templates/>
</tablerow>
</xsl:template>
<xsl:template match="th">
<tableheading>
<xsl:apply-templates/>
</tableheading>
</xsl:template>
<xsl:template match="td">
<tabledata>
<xsl:apply-templates/>
</tabledata>
</xsl:template>
<!--
============================================================
The followings are custom eXe extensions
============================================================
-->
<!-- term -->
<xsl:template match="span[@class='term']">
<xsl:call-template name="formatted">
<xsl:with-param name="type" select="'input'"/>
</xsl:call-template>
</xsl:template>
</xsl:stylesheet>