Issues with Moodle filters

Issues with Moodle filters

by Zbigniew Fiedorowicz -
Number of replies: 7
I've been having an offline discussion with Bruno about the MathML filter. He suggests that I put in some (Javascript?) code to check whether a client browser has builtin MathML capability, and in that case turn off the MathML->gif conversion. My impression is that there is no reliable way to detect that. In the case of IE, one has to install the MathPlayer plugin, as well as a bunch of fonts (which one has to do on any platform).

As an alternative, I understand that Jon Papaioannou has provided a new API in Moodle for user preferences. Could this be used to switch filters on or off at the user's discretion?

Another unresolved issue is how to hook up the MathML filter with admin/cron.php to clean up unused gif files in the cache produced by the filter. The filter runs touch() on any gif file which is displayed through the filter. This means that any cached gif image which is more than a week or two old is probably stale and can be discarded.
Average of ratings: -
In reply to Zbigniew Fiedorowicz

Re: Issues with Moodle filters

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Yes, user preferences are the way to do this.  The new user preferences stuff allows any module to set/retrieve user preferences (they are cached in the global USER variable).

For filters I'm imagining there would be a GUI on the user profile page, but there's a bit to do first, namely something that dynamically adjusts to available filters, and secondly a GUI for the admin to decide what the user is allowed to switch on and off.
In reply to Zbigniew Fiedorowicz

Re: Issues with Moodle filters

by Bruno Vernier -
the author of WIMS, http://www.unice.fr (opensource math education platform server) Xiao Gang says (regarding MATHML detection):


This can eventually be done by analyzing the name and version of the browser contained in the HTTP_USER_AGENT environment variable, but the ideal solution is that in the http protocol, there be a standard variable indicating whether the browser accepts MathML.


One approach I found by googling is to modify apache itself, but Gustav Delius and Mad Alex have already patched moodle to do that

http://cvs.sourceforge.net/viewcvs.py/moodle/moodle/lib/weblib.php?rev=1.193
(search for mathml)

(it simply allows mathml to be integrated into HTML) which can also be done (less elegantly) by patching apache itself:

http://golem.ph.utexas.edu/~distler/blog/archives/000167.html
http://seventeen.mit.edu/blog/platin/archives/000025.html

here is an idea: BROWSER strings are modifiable:

While we wait for the coding of preferences, we could
search for the string "mathml" in a browser string and anyone who wants pure MATHML just needs to add the keyword "mathml" to their BROWSER strings (easy to do in firebird, at least)

advantage over preferences: this would be a per-browser solution whereas preferences would assume the student sticks to the same browser throughout the entire course


In reply to Bruno Vernier

Re: Issues with Moodle filters

by Bruno Vernier -
Would this work (together with a help file that explains how to modify the browser string to include the word "mathml")


<?php
if (!(strpos($HTTP_USER_AGENT,'mathml') === false)) {
// skip the mathml filter
} else {
// process with the mathml filter;
}
?>
In reply to Bruno Vernier

Re: Issues with Moodle filters

by Zbigniew Fiedorowicz -
I think at this point the issue is academic, since there is no standard way for Moodle to serve pages with MathML, which will be displayed in any standard browser, at least not without hacking the Moodle source code. Mozilla won't display MathML unless the header starts with <xml...> (instead of <html> ) and all the html in the page is xhtml-conformant. IE requires a special header indicating that MathPlayer is the plugin which is supposed to handle all the <math> tags.
In reply to Zbigniew Fiedorowicz

Re: Issues with Moodle filters

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
<latenightrant>
It's so braindead ... I don't understand why these browser people have made compliance such a rigid requirement. I do understand the reasons for encouraging compliance, but to simply give up displaying an entire page just when a few characters are not-compliant is, in my opinion, a backward step for humanity. The computers are supposed to be working for us, remember?  I would rather see computers becoming more fuzzy and forgiving of human-made data.
</latenightrant>

Not directed at you, Zig, at all, your post just released some pent up frustration.  I'll go to bed now.  wink
In reply to Martin Dougiamas

Re: Issues with Moodle filters

by Zbigniew Fiedorowicz -

In view of this you might find the following snippet of an email exchange amusing. (Jacques Distler administers the string theory blog from which that largish sample MathML example on my site was taken):

On Feb 4, 2004, at 8:09 PM, Zbigniew Fiedorowicz wrote:

There is a bug in your itexToMML plugin. It produces the malformed
character entity &#xi; instead of &xi;  For an example of this
see http://golem.ph.utexas.edu/string/archives/000275.html


No it doesn't.

The W3C Validator says that page is valid XHTML+MathML.
Listing the file, I see only &xi;, not &#xi;.
It renders correctly in Mozilla.

Now, I will admit that when I do a "view source" in Mozilla, I see &#xi;.
I don't know *why* Mozilla is doing that. But it ain't true.

In fact, there are no instances of &#xi; on either blog hosted here at golem.

Jacques

In reply to Bruno Vernier

Re: Issues with Moodle filters

by Zbigniew Fiedorowicz -

One approach I found by googling is to modify apache itself, but Gustav Delius and Mad Alex have already patched moodle to do that

http://cvs.sourceforge.net/viewcvs.py/moodle/moodle/lib/weblib.php?rev=1.193
(search for mathml)

While Gustav/Alex's patch does address the <xml> header issue, it doesn't address the xhtml-conformance issue. I believe their patch works only with pages produced by their special locally-hacked version of the Moodle quiz module, which interfaces with their external AIM software. [Correct me if I'm wrong Gustav.]