Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions bases/rsptx/interactives/runestone/hparsons/js/hparsons.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class HParsons extends RunestoneBase {
this.isBlockGrading = this.parseBooleanAttribute(orig, "data-blockanswer");
this.language = orig.getAttribute("data-language");
// Detect math mode
if (this.language === undefined && orig.textContent.includes('span class="process-math"')) {
if (this.language == null && orig.textContent.includes('span class="process-math"')) {
this.language = "math";
}
if (this.isBlockGrading) {
Expand Down Expand Up @@ -131,7 +131,7 @@ export default class HParsons extends RunestoneBase {
this.hparsonsInput = this.outerDiv.querySelector("micro-parsons");
this.renderMathInBlocks();
// Change "code" to "answer" in parsons direction for non-code languages
if (this.language === undefined || this.language === "math") {
if (this.language == null || this.language === "math") {
this.outerDiv.querySelectorAll(".hparsons-tip").forEach(el => {
if (el.textContent.includes("our code")) {
el.textContent = el.textContent.replace("our code", "our answer");
Expand Down Expand Up @@ -195,9 +195,12 @@ export default class HParsons extends RunestoneBase {
});

if (window.MathJax && MathJax.typesetPromise) {
MathJax.typesetPromise().then(() => this.simulateSolution());
MathJax.typesetPromise([blocks]).then(() => this.simulateSolution());
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we shouldn't somehow be using this.queueMathJax(myElement) as we do in other components to ensure that we are serializing all of the various requests to mathjaxify the math.

Not 100% sure how we would know they are all done other than to check that the queue is empty and has been empty for some small period of time.

}
}, 0);
}, 100);
// Ugly... but there are timing issues with block rendering in microparsons and MathJax
// most noticeable if multiple hparsons problems are on the same page
// this delay seems to help avoid issues
}

/*
Expand Down