Use STACK equation preview box in other question types?

Re: Use STACK equation preview box in other question types?

by Daniel Thies -
Number of replies: 3
Picture of Core developers Picture of Plugin developers Picture of Testers

It looks like you have a security program called Rapport installed on your client that is blocking MathJax because it thinks it is a cross site scripting threat.

In reply to Daniel Thies

Re: Use STACK equation preview box in other question types?

by Seth Mengal -
Its not Rapport, also happening with me Daniel.


Uncaught Error: Can't make callback from given data

    at USING (cdn.mathjax.org/mathjax/latest/MathJax.js?delayStartupUntil=configured:19)

    at Object.Push (cdn.mathjax.org/mathjax/latest/MathJax.js?delayStartupUntil=configured:19)

    at Object.Queue (cdn.mathjax.org/mathjax/latest/MathJax.js?delayStartupUntil=configured:19)

    at HTMLInputElement.<anonymous> (attempt.php:39)


Seems if the textbox has a value at 'second try' - the renderer is not able to point to the HTML input box? 

In reply to Seth Mengal

Re: Use STACK equation preview box in other question types?

by Daniel Thies -
Picture of Core developers Picture of Plugin developers Picture of Testers

Are you loading MathJax in the header or are you using the Moodle MathJax filter?

In reply to Seth Mengal

Re: Use STACK equation preview box in other question types?

by Daniel Thies -
Picture of Core developers Picture of Plugin developers Picture of Testers

Andrew and I found that certain review options change the DOM structure so I had to update the script

<script>
  window.MathJax = {
    AuthorInit: function() {
      MathJax.Hub.Register.StartupHook('End', function() {
        var preview = document.createElement('span');
        preview.setAttribute('class', 'filter_mathjaxloader_equation')
        preview.innerHTML = ' ``';
        MathJax.Hub.processSectionDelay = 0;
        MathJax.Hub.Queue(['Typeset', MathJax.Hub, preview]);
        var inputs = document.querySelectorAll('.subquestion input, .shortanswer .answer input');
        for (var i = 0; i < inputs.length; i++) {
          var source = inputs[i];
          if (source.getAttribute('type') === 'text') {
            source.parentNode.appendChild(preview.cloneNode(true));
            MathJax.Hub.Queue(['Typeset', MathJax.Hub, source.parentNode.lastChild]);
source.parentNode.lastChild.innerHTML = '`' + source.value + '`'; source.addEventListener('input', function() { var math = MathJax.Hub.getAllJax(this.parentNode)[0]; MathJax.Hub.Queue(['Text', math, this.value]); }); } } }); } } </script>

Average of ratings: Useful (1)