StevenClontz / checkit

Platform for authoring free and open randomized exercises for practice and assessment.
https://checkit.clontz.org
MIT License
7 stars 6 forks source link

List numbering supressed in PreTeXt (sometimes) #56

Open siwelwerd opened 2 years ago

siwelwerd commented 2 years ago

Apparently if you give PreTeXt an <ol> but the contents of the <li> are not enclosed in <p></p> (e.g. if you just give it a <me>), it will not display the numbering. The solution is to enclose the <me> in <p>, which seems to make PreTeXt happy.

Currently, CheckIt appears to supply the needed <p> in the HTML output, but not the PreTeXt output. A workaround is for the user to ensure that a <p> is there in the template (though note that a user using the HTML output to debug will not notice an error!).

Example outcome that will show this bug: https://github.com/StevenClontz/checkit-tbil-la-2021-dev/blob/main/outcomes/LE1.xml

StevenClontz commented 2 years ago

This might be a bug in PreTeXt. I believe they intend to support bare <me> tags in <li>s. I'm guessing you found this when pasting a CheckIt exercise's PreTeXt output into our PreTeXt textbook source? (Screenshot/link me if you can.)

Here's what it looks like in the CheckIt Viewer (which handles PreTeXt-to-HTML differently than the PreTeXt app):

image

In CheckIt 0.2 I intend to restrict the subset of PreTeXt we support (e.g. you must use <p> around any mathematics) to avoid these bugs, and explicitly document what that subset is. Then if you use incompatible or invalid PreTeXt, it won't appear in the dashboard when previewing. As part of this process I'll port all the banks linked at https://checkit.clontz.org to 0.2 and fix these kinds of issues (I've been sprinkling in <p>s in the linear algebra bank throughout the semester to anticipate this, but missed this one...).

siwelwerd commented 2 years ago

Yeah, that's exactly where I encountered it. I corrected it manually in the activity book. My references above were to the HTML output and PreTeXt output displayed by the Dashboard preview (I assumed the viewer was using this same HTML). Here's an example from LE1, note the <p class="math math-display"> in the HTML output, but not <p> in PreTeXt output.

PreTeXt source
------------
<exercise checkit-seed="4419" checkit-slug="LE1" checkit-title="Linear systems, vector equations, and augmented matrices">
  <statement>
        <p>Consider the vector equation.</p>
              <me>x_{1} \left[\begin{array}{c}
1 \\
3 \\
0 \\
-3
\end{array}\right] + x_{2} \left[\begin{array}{c}
2 \\
4 \\
-1 \\
-4
\end{array}\right] + x_{3} \left[\begin{array}{c}
1 \\
0 \\
-2 \\
-1
\end{array}\right] = \left[\begin{array}{c}
2 \\
9 \\
3 \\
-6
\end{array}\right]</me>
        <ol>
            <li> Write a system of scalar equations corresponding to this vector equation. </li>
            <li> Write an augmented matrix corresponding to this vector equation. </li>
        </ol>
  </statement>

  <answer>
     <ol>
                <li><me>\begin{matrix}
 x &amp;  +  &amp; 2 \, y &amp;  +  &amp; z &amp; = &amp; 2 \\
 3 \, x &amp;  +  &amp; 4 \, y &amp;  &amp;  &amp; = &amp; 9 \\
 &amp;  -  &amp; y &amp;  -  &amp; 2 \, z &amp; = &amp; 3 \\
 -3 \, x &amp;  -  &amp; 4 \, y &amp;  -  &amp; z &amp; = &amp; -6 \\
 \end{matrix}</me></li>
                <li><me>\left[\begin{array}{ccc|c}
1 &amp; 2 &amp; 1 &amp; 2 \\
3 &amp; 4 &amp; 0 &amp; 9 \\
0 &amp; -1 &amp; -2 &amp; 3 \\
-3 &amp; -4 &amp; -1 &amp; -6
\end{array}\right]</me></li>
      </ol>
    </answer>
</exercise>

HTML source
-----------
<div class="checkit exercise" data-checkit-slug="LE1" data-checkit-title="Linear systems, vector equations, and augmented matrices" data-checkit-seed="4419"> <div class="exercise-statement"> <p>Consider the vector equation.</p> <p class="math math-display">\[x_{1} \left[\begin{array}{c}
1 \\
3 \\
0 \\
-3
\end{array}\right] + x_{2} \left[\begin{array}{c}
2 \\
4 \\
-1 \\
-4
\end{array}\right] + x_{3} \left[\begin{array}{c}
1 \\
0 \\
-2 \\
-1
\end{array}\right] = \left[\begin{array}{c}
2 \\
9 \\
3 \\
-6
\end{array}\right]\]</p> <ol type="a"><li> Write a system of scalar equations corresponding to this vector equation. </li><li> Write an augmented matrix corresponding to this vector equation. </li></ol> </div> <div class="exercise-answer"><p><b>Answer:</b></p> <ol type="a"><li><p class="math math-display">\[\begin{matrix}
 x &amp;  +  &amp; 2 \, y &amp;  +  &amp; z &amp; = &amp; 2 \\
 3 \, x &amp;  +  &amp; 4 \, y &amp;  &amp;  &amp; = &amp; 9 \\
 &amp;  -  &amp; y &amp;  -  &amp; 2 \, z &amp; = &amp; 3 \\
 -3 \, x &amp;  -  &amp; 4 \, y &amp;  -  &amp; z &amp; = &amp; -6 \\
 \end{matrix}\]</p></li><li><p class="math math-display">\[\left[\begin{array}{ccc|c}
1 &amp; 2 &amp; 1 &amp; 2 \\
3 &amp; 4 &amp; 0 &amp; 9 \\
0 &amp; -1 &amp; -2 &amp; 3 \\
-3 &amp; -4 &amp; -1 &amp; -6
\end{array}\right]\]</p></li></ol> </div> </div>
StevenClontz commented 2 years ago

I cannot replicate the bug you reported with things not numbering correctly in the PreTeXt build (the below is the code you pasted above in a book where "exercise" is renamed to "Checkpoint"):

image

Can you provide more context and a screenshot?

siwelwerd commented 2 years ago

This is from the Sample Exercises in the appendix of the dev version of the LA book (in Cocalc, have not published)

Screenshot: screenshot

Relevant code:


    <example>
        <title>LE1</title>
        <statement>
            <p>
Consider the scalar system of equations 
    <md alignment="alignat" alignat-columns="5">
    <mrow>
3x_1 &amp;\,+\,&amp; 2x_2 &amp;\,\,&amp; &amp;\,+\,&amp;x_4 &amp;= 1 </mrow><mrow>
-x_1 &amp;\,-\,&amp; 4x_2 &amp;\,+\,&amp;x_3&amp;\,-\,&amp;7x_4 &amp;= 0 </mrow><mrow>
        &amp;\,\,&amp; x_2 &amp;\,-\,&amp;x_3 &amp;\,\,&amp;  &amp;= -2</mrow>
    </md>
            </p>
            <ol>
                <li>
Rewrite this system as a vector equation.
                </li>
                <li>
Write an augmented matrix corresponding to this system.
                </li>
            </ol>
        </statement>
        <solution>
            <ol>
                <li>
<me> x_1\left[\begin{array}{c} 3 \\ -1 \\ 0 \end{array}{}\right] +
    x_2 \left[\begin{array}{c}2 \\ -4 \\ 1 \end{array}{}\right]+
    x_3 \left[\begin{array}{c} 1 \\ 1 \\ -1 \end{array}{}\right] 
    + x_4 \left[\begin{array}{c} 1 \\ -7 \\ 0 \end{array}{}\right] 
    = \left[\begin{array}{c} 1 \\ 0 \\ -2 \end{array}{}\right] </me>
                </li>
                <li>
<me>
\left[\begin{array}{cccc|c}
3 &amp; 2 &amp; 0 &amp; 1 &amp; 1 \\
-1 &amp; -4 &amp; 1 &amp; -7 &amp; 0 \\
0 &amp; 1 &amp; -1 &amp; 0 &amp; -2
\end{array}\right]
    </me>
                </li>
            </ol>
        </solution>
</example>
``
StevenClontz commented 2 years ago

Oh boy this is a fun one. I just re-built to be sure, and I see the numbers.

image

What browser/OS/etc are you using?

siwelwerd commented 2 years ago

Very odd. This is in Firefox 88.0 on Ubuntu .

StevenClontz commented 2 years ago

Yep... this is Firefox 81.x on Windows:

image

Updating to 93.0 didn't help.

I'll report upstream to PreTeXt. For now, we'll need to start using the <li><p><me>x</me></p></li> pattern (which will be required by CheckIt anyway soon enough).

StevenClontz commented 2 years ago

Reported at https://groups.google.com/g/pretext-dev/c/Jq8OZ8tFpsY