PreFigure in Exercise

36 views
Skip to first unread message

Taran Funk

unread,
May 16, 2025, 1:19:17 PM5/16/25
to PreTeXt support
Hello again,

I'm working with the following exercise below and getting the error:

error: * PTX:ERROR: the @xml:id value "RWT-Evaluating-Functions-figure2" should be unique, but is authored multiple times.
error: * PTX:ERROR: the @label value "RWT-Evaluating-Functions-prefigure2" should be unique, but is authored multiple times.

The figure and prefigure do not show up anywhere else in the document. The prefigures also do not show up in my generated assets.

<exercise label="RWT-Evaluating-Functions-exercise2">
<statement>
<p>
Test text.
</p>
<figure xml:id="RWT-Evaluating-Functions-figure2a">
<image width="60%">
<prefigure xmlns="https://prefigure.org" label="RWT-Evaluating-Functions-prefigure2">
<description>Points on Graph</description>
<diagram dimensions="(300,300)" margins="5">
<coordinates bbox="(-5,-5,5,5)">
<grid-axes xlabel="x" ylabel="y"/>
<point p="(2,-1)" size="4"></point>
<point p="(-2,1)" size="4"></point>
<point p="(0,3)" size="4"></point>
<point p="(1,2)" size="4"></point>
<point p="(3,-4)" size="4"></point>
</coordinates>
</diagram>
</prefigure>
</image>
<!-- </figure> -->
<p>
Complete the input/output table using the graph above.
</p>
<table>
<title>Input/Output Table</title>
<tabular top="major" left="medium" bottom="medium" right="medium">
<row halign="center">
<cell>Input</cell>
<cell>Output</cell>
</row>
<row halign="center">
<cell><m>-2</m></cell>
<cell><fillin width="5" mode="math" answer="1" name="response1"/></cell>
</row>
<row halign="center">
<cell><fillin width="5" mode="math" answer="0" name="response2"/></cell>
<cell><m>3</m></cell>
</row>
<row halign="center">
<cell><m>2</m></cell>
<cell><fillin width="5" mode="math" answer="-1" name="response3"/></cell>
</row>
</tabular>
</table>
</statement>
<evaluation>
<evaluate submit="response1">
<test correct="yes">
<numcmp use-answer="yes" />
</test>
</evaluate>
<evaluate submit="response2">
<test correct="yes">
<numcmp use-answer="yes" />
</test>
</evaluate>
<evaluate submit="response3">
<test correct="yes">
<numcmp use-answer="yes" />
</test>
</evaluate>
</evaluation>
</exercise>

Rob Beezer

unread,
May 16, 2025, 2:27:24 PM5/16/25
to pretext...@googlegroups.com
Dear Taran,

I do not think we have ever had a false positive with that error message. ;-)

1. Might you have included some particular chapter/section *twice* someplace?

2. Can you do a search across multiple files in your "source" directory on
those strings? "grep" or something like it in VSCode?

3. Last resort: comment out huge chunks of your source and slowly add them back
in until you get the error again and look closer.

Let us know what you find.

Rob

On 5/16/25 10:19, Taran Funk wrote:
> Hello again,
>
> I'm working with the following exercise below and getting the error:
>
> error: * PTX:ERROR: the @xml:id value "RWT-Evaluating-Functions-figure2" should
> be unique, but is authored multiple times.
> error: * PTX:ERROR: the @label value "RWT-Evaluating-Functions-prefigure2"
> should be unique, but is authored multiple times.
>
> The figure and prefigure do not show up anywhere else in the document. The
> prefigures also do not show up in my generated assets.
>
> <exerciselabel="RWT-Evaluating-Functions-exercise2">
> <statement>
> <p>
> Test text.
> </p>
> <figurexml:id="RWT-Evaluating-Functions-figure2a">
> <imagewidth="60%">
> <prefigurexmlns="https://prefigure.org"label="RWT-Evaluating-Functions-prefigure2">
> <description>Points on Graph</description>
> <diagramdimensions="(300,300)"margins="5">
> <coordinatesbbox="(-5,-5,5,5)">
> <grid-axesxlabel="x"ylabel="y"/>
> <pointp="(2,-1)"size="4"></point>
> <pointp="(-2,1)"size="4"></point>
> <pointp="(0,3)"size="4"></point>
> <pointp="(1,2)"size="4"></point>
> <pointp="(3,-4)"size="4"></point>
> </coordinates>
> </diagram>
> </prefigure>
> </image>
> <!-- </figure> -->
> <p>
> Complete the input/output table using the graph above.
> </p>
> <table>
> <title>Input/Output Table</title>
> <tabulartop="major"left="medium"bottom="medium"right="medium">
> <rowhalign="center">
> <cell>Input</cell>
> <cell>Output</cell>
> </row>
> <rowhalign="center">
> <cell><m>-2</m></cell>
> <cell><fillinwidth="5"mode="math"answer="1"name="response1"/></cell>
> </row>
> <rowhalign="center">
> <cell><fillinwidth="5"mode="math"answer="0"name="response2"/></cell>
> <cell><m>3</m></cell>
> </row>
> <rowhalign="center">
> <cell><m>2</m></cell>
> <cell><fillinwidth="5"mode="math"answer="-1"name="response3"/></cell>
> </row>
> </tabular>
> </table>
> </statement>
> <evaluation>
> <evaluatesubmit="response1">
> <testcorrect="yes">
> <numcmpuse-answer="yes"/>
> </test>
> </evaluate>
> <evaluatesubmit="response2">
> <testcorrect="yes">
> <numcmpuse-answer="yes"/>
> </test>
> </evaluate>
> <evaluatesubmit="response3">
> <testcorrect="yes">
> <numcmpuse-answer="yes"/>
> </test>
> </evaluate>
> </evaluation>
> </exercise>
>
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to pretext-suppo...@googlegroups.com <mailto:pretext-
> support+u...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/pretext-
> support/311fd325-f674-4816-8559-81ae7c5040a1n%40googlegroups.com <https://
> groups.google.com/d/msgid/pretext-support/311fd325-
> f674-4816-8559-81ae7c5040a1n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Oscar Levin

unread,
May 16, 2025, 3:23:03 PM5/16/25
to PreTeXt support
Hi Rob,

Taran and I were just experimenting more.  I think now that the issue is that the exercises are in fact dynamic fill-in-the-blank ones, and this is not working correctly with also including a figure/image/prefigure.  Haven't had a chance to dive into the code, but perhaps this is the culprit.  

Is there a way to include images with dynamic FITB exercises?

Sean Fitzpatrick

unread,
May 16, 2025, 3:31:29 PM5/16/25
to pretext...@googlegroups.com

Maybe it's the same problem we ran into with general matching.

Image tags weren't written as self-closing. You could try editing the HTML to check.


To unsubscribe from this group and stop receiving emails from it, send an email to pretext-suppo...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/pretext-support/0b1bd7e5-f540-4683-b775-74281aa1710en%40googlegroups.com.

Oscar Levin

unread,
May 16, 2025, 3:58:45 PM5/16/25
to PreTeXt support
Aha!  Yes, that img tag is indeed unclosed.  

That doesn't explain the warnings about duplicate labels/xml:ids, but it does explain how sometimes the exercises don't load.

Rob Beezer

unread,
May 16, 2025, 5:42:24 PM5/16/25
to pretext...@googlegroups.com
OK, the HTML-unclosed-tag problem is understood, I think.

IDs get checked very early by the pre-processor, I believe. You could run the
pretext/pretext script on Taran's project to build the "assembly-dynamic"
output and then search it for the offending strings?
> > <prefigurexmlns="https://prefigure.org <https://
> prefigure.org>"label="RWT-Evaluating-Functions-prefigure2">
> pretext- <https://groups.google.com/d/msgid/pretext->
> > support/311fd325-f674-4816-8559-81ae7c5040a1n%40googlegroups.com
> <http://40googlegroups.com> <https://
> > groups.google.com/d/msgid/pretext-support/311fd325- <http://
> groups.google.com/d/msgid/pretext-support/311fd325->
> > f674-4816-8559-81ae7c5040a1n%40googlegroups.com?
> utm_medium=email&utm_source=footer <http://40googlegroups.com?
> utm_medium=email&utm_source=footer>>.
>
> --
> You received this message because you are subscribed to the Google
> Groups "PreTeXt support" group.
>
> To unsubscribe from this group and stop receiving emails from it, send
> an email to pretext-suppo...@googlegroups.com.
> To view this discussion visit https://groups.google.com/d/msgid/pretext-
> support/0b1bd7e5-f540-4683-b775-74281aa1710en%40googlegroups.com
> <https://groups.google.com/d/msgid/pretext-support/0b1bd7e5-f540-4683-
> b775-74281aa1710en%40googlegroups.com?utm_medium=email&utm_source=footer>.
>
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> support/98b3c188-fde5-4ad3-a280-ab592b5b7f73n%40googlegroups.com <https://
> groups.google.com/d/msgid/pretext-support/98b3c188-fde5-4ad3-a280-
> ab592b5b7f73n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Oscar Levin

unread,
May 16, 2025, 6:49:25 PM5/16/25
to PreTeXt support
Okay, we found the issue (but it is definitely a bug or unsupported).  Building assembly-static resulted in the figure appearing twice (including the label and xml:id, of course).  The figure appears in the statement of the problem, and also in a `<solution>` to the problem.  There is no `<solution>` authored in source, so this must be manufactured by the dynamic exercise.

Rob Beezer

unread,
May 16, 2025, 7:09:25 PM5/16/25
to pretext...@googlegroups.com
Very good! I had a vague sense it might be something like this.

So, I think maybe the best course is for Brian W to sanitize what gets copied
into the #solution for static versions.

And maybe I should survey the various Runestone Components for the potential to
do the same thing.

Off the top of my head, a mode that accomplishes "xsl:copy-of" while killing
@xml:id and @label might be the broad-brush solution for a #solution (!). When
I've done this other places the mode had a name such as "svg-edit" when minor
manipulations are made to an SVG.

Rob
> > > <prefigurexmlns="https://prefigure.org <https://prefigure.org> <https://
> > prefigure.org <http://prefigure.org>>"label="RWT-Evaluating-Functions-
> > pretext- <https://groups.google.com/d/msgid/pretext- <https://
> groups.google.com/d/msgid/pretext->>
> > > support/311fd325-f674-4816-8559-81ae7c5040a1n%40googlegroups.com
> <http://40googlegroups.com>
> > <http://40googlegroups.com <http://40googlegroups.com>> <https://
> > > groups.google.com/d/msgid/pretext-support/311fd325- <http://
> groups.google.com/d/msgid/pretext-support/311fd325-> <http://
> <http://40googlegroups.com>?
> > utm_medium=email&utm_source=footer <http://40googlegroups.com
> <http://40googlegroups.com>?
> > utm_medium=email&utm_source=footer>>.
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "PreTeXt support" group.
> >
> > To unsubscribe from this group and stop receiving emails from it, send
> > an email to pretext-suppo...@googlegroups.com.
> > To view this discussion visit https://groups.google.com/d/msgid/pretext-
> <https://groups.google.com/d/msgid/pretext->
> > support/0b1bd7e5-f540-4683-b775-74281aa1710en%40googlegroups.com
> <http://40googlegroups.com>
> > <https://groups.google.com/d/msgid/pretext-support/0b1bd7e5-f540-4683-
> <https://groups.google.com/d/msgid/pretext-support/0b1bd7e5-f540-4683->
> > b775-74281aa1710en%40googlegroups.com?utm_medium=email&utm_source=footer
> <http://40googlegroups.com?utm_medium=email&utm_source=footer>>.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "PreTeXt support" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> email
> > to pretext-suppo...@googlegroups.com <mailto:pretext-
> > support+u...@googlegroups.com>.
> > To view this discussion visit https://groups.google.com/d/msgid/pretext-
> <https://groups.google.com/d/msgid/pretext->
> > support/98b3c188-fde5-4ad3-a280-ab592b5b7f73n%40googlegroups.com
> <http://40googlegroups.com> <https://
> > groups.google.com/d/msgid/pretext-support/98b3c188-fde5-4ad3-a280-
> <http://groups.google.com/d/msgid/pretext-support/98b3c188-fde5-4ad3-a280->
> > ab592b5b7f73n%40googlegroups.com?utm_medium=email&utm_source=footer
> <http://40googlegroups.com?utm_medium=email&utm_source=footer>>.
>
> --
> You received this message because you are subscribed to the Google Groups
> "PreTeXt support" group.
> To unsubscribe from this group and stop receiving emails from it, send an email
> to pretext-suppo...@googlegroups.com <mailto:pretext-
> support+u...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/pretext-
> support/1724abf0-d151-45a7-a0a0-6579c334683en%40googlegroups.com <https://
> groups.google.com/d/msgid/pretext-support/1724abf0-d151-45a7-
> a0a0-6579c334683en%40googlegroups.com?utm_medium=email&utm_source=footer>.

D. Brian Walton

unread,
May 19, 2025, 9:28:24 AM5/19/25
to pretext...@googlegroups.com
When fill-in-the-blank questions were first defined, questions were expected to be simple sentences/paragraphs with blanks that were filled in. The solution for these questions was automatically generated by taking the entire statement and replacing each fill-in-blank with the correct answer. This is where the problem is coming from.

When I added dynamic exercises with math-checked fill-in-the-blank, I preserved that solution technique. I also added the option of writing a custom solution. If an author creates a #solution child of the #exercise, that #solution element can have an attribute @include-automatic='no' which will disable the automatic solution.

I also did not anticipate that the statement might have children that themselves might not allow multiple copies (e.g. xml:id). Maybe this needs to move to pretext-dev, but what would be an appropriate balance for what an automatic solution *should* include? Maybe just include paragraphs with fill-in-blanks and no other components of the statement? (Introductory paragraphs without fill-in-blanks could be skipped?)

Brian

D. Brian Walton

unread,
May 19, 2025, 9:42:18 AM5/19/25
to pretext...@googlegroups.com
Issue created: #2516

I will start a more technical thread on pretext-dev.
- Brian
Reply all
Reply to author
Forward
0 new messages