RunestoneInteractive / rs

A New Monorepo structure for Runestone
Other
39 stars 68 forks source link

Bad XML output for mchoice #26

Open jdeisenberg opened 1 year ago

jdeisenberg commented 1 year ago

Line 413 of file multiplechoice.py should emit </choices> instead of </choice> Also, an extra </statement> is emitted (though not sure where the code is).

This RST:

.. mchoice:: get_text_mc_1
    :random:

    What is the text of the tag below?

    .. image:: _static/dining_h2_text.png
        :align: center
        :alt: h2 tag on dining page

    -   Today's Menu

        +   Correct! This text is between the <h2 class="menuItem"> and </h2>

    -   h2

        -   No, h2 is the tag name

    -   menuTitle

        -   No

    -   class

        -   No

Generates this XML (note the </choice></choice> followed by unmatched </statement>):

    <exercise label="get_text_mc_1">
        <statement>

            <paragraph>Q-1: What is the text of the tag below?</paragraph>
            <image align="center" alt="h2 tag on dining page" candidates="{'*': 'bsoup/_static/dining_h2_text.png'}" uri="bsoup/_static/dining_h2_text.png"></image>
</statement><choices><choice correct='yes'><statement id="get_text_mc_1_opt_a">            <paragraph>Today’s Menu</paragraph>
</statement><feedback id="get_text_mc_1_opt_a">
            <paragraph>Correct! This text is between the &lt;h2 class=”menuItem”&gt; and &lt;/h2&gt;</paragraph>
</feedback></choice><choice><statement id="get_text_mc_1_opt_b">            <paragraph>h2</paragraph>
</statement><feedback id="get_text_mc_1_opt_b">
            <paragraph>No, h2 is the tag name</paragraph>
</feedback></choice><choice><statement id="get_text_mc_1_opt_c">            <paragraph>menuTitle</paragraph>
</statement><feedback id="get_text_mc_1_opt_c">
            <paragraph>No</paragraph>
</feedback></choice><choice><statement id="get_text_mc_1_opt_d">            <paragraph>class</paragraph>
</statement><feedback id="get_text_mc_1_opt_d">
            <paragraph>No</paragraph>
</feedback></choice></choice>
        </statement>

    </exercise>
bnmnetp commented 1 year ago

Thanks for the report.

I'm hoping and praying that the conversion scripts can be improved collaboratively. That is, I don't think of this as a finished product. I used the scripts to get several books converted last summer, but of course each new book brings new challenges. For example the books we converted all used the old style of multiple choice.

So if it is easy for you to make the fixes, please do so and submit a PR which I will promptly merge. Right now I am in the middle of some new features that I have promised for January, so I can't just jump in on this...

This whole thing only has a lifespan of converting the 50 or so existing Runestone books to PreTeXt. So it doesn't need to be super polished, it just needs to work well enough to get the job done.

Thanks for understanding, and hopefully your help! I know that Barb really wants to get this converted to PreTeXt for next fall.

Brad