Skip to content

Commit 9f65d37

Browse files
Assembly: add qrcodes for static representations of interactive programs
1 parent 1c03b75 commit 9f65d37

2 files changed

Lines changed: 49 additions & 1 deletion

File tree

xsl/pretext-assembly.xsl

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1683,6 +1683,10 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
16831683
<xsl:value-of select="@assembly-id"/>
16841684
</xsl:template>
16851685

1686+
<xsl:template match="program[@interactive]" mode="assembly-id">
1687+
<xsl:value-of select="@assembly-id"/>
1688+
</xsl:template>
1689+
16861690
<xsl:template match="datafile" mode="assembly-id">
16871691
<xsl:value-of select="@assembly-id"/>
16881692
</xsl:template>
@@ -3062,6 +3066,49 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
30623066
</xsl:choose>
30633067
</xsl:template>
30643068

3069+
<xsl:template match="program[@interactive != '' and @interactive != 'no']" mode="representations">:message>
3070+
<xsl:choose>
3071+
<xsl:when test="$exercise-style = 'static'">
3072+
<!-- first the static program -->
3073+
<xsl:copy>
3074+
<xsl:apply-templates select="node()|@*" mode="representations"/>
3075+
</xsl:copy>
3076+
<!-- then a qr assemblage if desired -->
3077+
<xsl:if test="$b-program-static-qrcodes">
3078+
<xsl:variable name="static-url">
3079+
<xsl:apply-templates select="." mode="get-interactive-url"/>
3080+
</xsl:variable>
3081+
<assemblage>
3082+
<title>
3083+
<xsl:value-of select="$interactive-urls/@localized-link-description"/>
3084+
</title>
3085+
<sidebyside margins="0%" widths="70% 25%" valign="top" halign="center">
3086+
<p>
3087+
<!-- Kill the automatic footnote -->
3088+
<url href="{$static-url}" visual="">
3089+
<xsl:value-of select="$static-url"/>
3090+
</url>
3091+
</p>
3092+
<image>
3093+
<xsl:attribute name="pi:generated">
3094+
<xsl:text>qrcode/</xsl:text>
3095+
<xsl:apply-templates select="." mode="assembly-id"/>
3096+
<xsl:text>.png</xsl:text>
3097+
</xsl:attribute>
3098+
</image>
3099+
</sidebyside>
3100+
</assemblage>
3101+
</xsl:if>
3102+
</xsl:when>
3103+
<xsl:when test="($exercise-style = 'dynamic') or ($exercise-style = 'pg-problems')">
3104+
<!-- duplicate authored content for the non-static conversions -->
3105+
<xsl:copy>
3106+
<xsl:apply-templates select="node()|@*" mode="representations"/>
3107+
</xsl:copy>
3108+
</xsl:when>
3109+
</xsl:choose>
3110+
</xsl:template>
3111+
30653112
<!-- If a "static" is given, just copy it's children -->
30663113
<xsl:template match="interactive[static]" mode="representations">
30673114
<xsl:choose>

xsl/pretext-runestone-static.xsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,8 @@ along with PreTeXt. If not, see <http://www.gnu.org/licenses/>.
12881288
<!-- duplicate the authored prompt/statement -->
12891289
<xsl:copy-of select="statement/node()"/>
12901290
<!-- bring up the program as part of the problem statement -->
1291-
<xsl:copy-of select="program"/>
1291+
<!-- copy via representations to get possible qrcode -->
1292+
<xsl:apply-templates select="program" mode="representations"/>
12921293
</statement>
12931294
<xsl:copy-of select="hint"/>
12941295
<xsl:copy-of select="answer"/>

0 commit comments

Comments
 (0)