Thursday, June 9, 2011

MathJax and VTBE Experiments

Our faculty are interested in putting equations into Blackboard. However, the current equation editor is old and flaky (works for some browsers, not for others). I heard from other schools about MathJax (http://www.mathjax.org) and started to play with it.

The easiest way to use MathJax is to link directly to the MathJax distributed network service (see Using the MathJax CDN). In that case, there is no need to install MathJax yourself, and you can begin using MathJax right away.

The only thing is you need to have a bit of script tag in each of your pages:

<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>

I had the inspiration to throw that snippet into the googleAnalyticsSnippet.vm (see http://iangoh99.blogspot.com/2011/04/google-analytics-90sp5-91sp4.html)

That took care of including the script.

I took some of the TeX examples (see http://www.mathjax.org/demos/tex-samples/) and added them in via the VTBE.

To keep the VTBE from mucking with all the special characters like "{" "}":
* Turn the Text Editor OFF
* Choose "Plain Text"

And then cut-and-paste the TeX examples, e.g., Lorentz Equations

\begin{aligned}
\dot{x} & = \sigma(y-x) \\
\dot{y} & = \rho x - y - xz \\
\dot{z} & = -\beta z + xy
\end{aligned}

What it looks like in the VTBE:


Results:



Here is an example where I put MathJax TeX into a Test question. (Added 06/13/2011)


Here is an example where I put MathJax TeX into a Discussion post. (Added 06/13/2011)

What I typed:



Results:





Notes:

* I initially had trouble with some of the examples not showing (e.g., just seeing raw code), then it occurred to me that the examples that worked started and ended with

\begin{aligned}
:
\end{aligned}

so I added those to the non-working TeX examples and presto, they appeared properly.

* MathML examples - were not working for me, maybe conflicting with the VTBE's inherent handling of MathML (part of the built-in equation editor)

* Security concerns - including someone else's javascript in all your Bb JSP pages needs quite a level of trust. You can install MathJax locally on your server, and that's prob. where we'd be experimenting next. (And, it'd be friendlier to the MathJax CDN!)

6 comments:

  1. I have just discovered your blog recently and I was like wow! a blog talking about Blackboard learn??? Cool!
    Anyway thank you for your demonstration above,
    I was trying to use MathJax in VTBE in Bb,
    however when I was trying to add math equation in Discussion board, the equation crashed whenever I was replying the post. Both the equations in the parent post and the reply post cannot be shown.
    Have you encountered this issue before?

    ReplyDelete
  2. Dear HeiC,

    Unfortunately, we did not pursue this experimentation any further. At the time I tested, we were running Bb Release 9.1SP5. We are now at 9.1SP7HF1. I tried the script-in-the-googleAnalyticsSnippet.vm again: the Content Area MathJax examples still worked, however, the Discussion post did not. I just saw the raw code.

    Sorry,

    - Ian

    ReplyDelete
  3. The comments at http://www.mathjax.org/demos/use-in-web-platforms/ also seem to indicate issues with using the MathJax in the Discussions.

    ReplyDelete
  4. Dear Ian,

    Thank you very much for your reply.
    I am now using Bb Release 9.1 SP8, still having the same problem in Discussion. Just hope this issue will be solved in the later SP.

    - HeiC

    ReplyDelete
  5. Hi HeiC,

    Have you heard about the replacement VTBE? It'll come with the WIRIS equation editor. It's available on coursesites.com. Unfortunately, last I checked, the equation editor wasn't functioning properly (they are aware of it).

    - Ian

    ReplyDelete
  6. Just FYI, the WIRIS equation editor is now working on coursesites.com. Since it's part of the replace text editor, you can use it everywhere you see a text editor, for instance in Discussion posts!

    ReplyDelete