Skip to content

Add math-mode support for horizontal Parsons problems #694

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

geoff-cox
Copy link
Contributor

This patch extends the Runestone hparsons component to support math-mode horizontal Parsons problems.

This patch extends the Runestone hparsons component to support math-mode horizontal Parsons problems.
@geoff-cox geoff-cox requested a review from bnmnetp as a code owner April 15, 2025 23:41
@geoff-cox
Copy link
Contributor Author

geoff-cox commented Apr 15, 2025

Here is one of the test cases I used in Pretext:

<exercise label="horizontal-parson-math-simple" language="natural"><title>Parsons Problem, Math</title>
    <statement>
        <p>
            Problem Statement
        </p>
    </statement>
    <blocks layout="horizontal" reuse="no" randomize="no">
        <block order="4"><m>\alpha</m></block>
        <block order="2"><m>\beta</m></block>
        <block order="1"><m>\displaystyle\sum_{i=1}^{\infty}</m></block>
        <block order="3"><m>x^2</m></block>
        <block order="5" correct="no"><m>\displaystyle\int x^2</m></block>
    </blocks>
</exercise>

For quick reference, here is the correct order
image

Copy link
Member

@bnmnetp bnmnetp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

block.innerHTML = this.decodeHTMLEntities(block.innerHTML);
});

if (window.MathJax && MathJax.typesetPromise) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this addition!

You should have a look at parsons.js and others for how we use the this.queueMathJax(specific item).

MathJax can create a big set of timing problems and this allows us to take control. Also trying to re-typeset the whole page can be a performance issue.

}, 0);
}

simulateSolution() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe some comments about what the simulateSolution function is all about? Its not clear to me.. Is this for scoring? I would have guessed that block scoring would be fine? Maybe not for some expression.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bnmnetp
The Micro-parsons code was formatting the math blocks with unpredictable Ascii characters, so I simulated the correct solution in the answer area and asked Micro-parsons to output what a correct solution would look like from their end. I needed this because a correct answer is determined by comparing the text on the blocks. I was hoping there would have been an ID on the blocks, but I didn't see any, so this was my workaround. I am sure there is a better way. Let me know if you have any ideas.

I can add more details to the PR tomorrow.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for clarifying! I assume all of the \ ing of characters was the cause of the weird text.

I does not look like the html representation lends itself easily to adding ids.... But it seems like it should. maybe worth investigating with Rob, and looking at a better html (or json) representation to use in the javascript.

I'm ok with your solution for now, but thinking long term.

Copy link
Contributor Author

@geoff-cox geoff-cox Apr 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding IDs could streamline future improvements and make grading in blockGrader.js more straightforward.

I designed this PR thinking that it would be a good way to construct formulas and equations term-by-term. Unfortunately, it doesn't currently support multiple correct orderings, which would be essential for commutative operations like addition and multiplication. So getting Rob (@rbeezer) involved in coordinating how multiple orderings can be communicated to Runestone would be good.

Copy link
Contributor Author

@geoff-cox geoff-cox Apr 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, display math tags (<me>) are not currently supported with this PR, but <m>\displaystyle * </m> is good to go.

Changes "code" to "answer" in the problem directions for non-coding problems.

A description of the simulateSolution method was added.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants