Skip to content
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

MathJax filter not applied to prologuehtml #182

Closed
NeilStrickland opened this issue Nov 14, 2023 · 3 comments
Closed

MathJax filter not applied to prologuehtml #182

NeilStrickland opened this issue Nov 14, 2023 · 3 comments

Comments

@NeilStrickland
Copy link

This replicates the forum post https://coderunner.org.nz/mod/forum/discuss.php?d=646 but I now think it is more appropriate here.

Suppose we have a combinator template grader that returns a prologuehtml field which becomes part of the specific feedback. If there is LaTeX markup in that feedback, it seems that the MathJax filter will not be applied (even if it is enabled), so the LaTeX will not be displayed properly. If I understand correctly, question elements containing LaTeX are typically passed through the method question::format_text(), which calls the global Moodle function format_text(), which applies any active filters. In particular, if the MathJax is active then LaTeX-containing elements will be wrapped in <span class="filter_mathjaxloader_equation">...</span> which signals to the MathJax javascript code in the browser that they need to be processed. For example, the STACK question type plugin (https://github.com/maths/moodle-qtype_stack) calls format_text() in a number of places to ensure that this happens. However, coderunner never calls format_text(). It seems that one could add calls to qtype_coderunner_renderer::feedback() or qtype_coderunner_combinator_grader_outcome::get_prologue() or something like that. I am not sufficiently expert to judge what details would be best.

@trampgeek
Copy link
Owner

trampgeek commented Nov 15, 2023

Thanks for reporting. It is a bug in CodeRunner, exactly as you've identified. I have a tentative fix, but I want to see if it creates any new problems before releasing it.

In the meantime, here's a workaround (slightly ugly):

  1. Make sure that the JavaScript mathjax filter code is loaded on the page by including a hidden span with some mathjax code in it. For example (editing in raw HTML mode): <span style="display: none;">\(x = 1\)</span>
  2. Wrap your LaTeX equation in the MathJax span you identified in the CodeRunner forum post: <span class="filter_mathjaxloader_equation">...</span>

Alternatively, if you want to live on the bleeding edge, you could checkout the development branch on github. Probably you'd only want the latest commit (to renderer.php) addressing this bug as some of the other changes are work-in-progress.

@NeilStrickland
Copy link
Author

Thanks very much. I won't actually be using CodeRunner properly until February, I am just experimenting and setting things up at the moment, so I won't worry about any workarounds for the time being.

@trampgeek
Copy link
Owner

Fixed in version 5.2.4.

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

No branches or pull requests

2 participants