AsciiMath and Moodle 2.0

AsciiMath and Moodle 2.0

by Colin Fraser -
Number of replies: 30
Picture of Documentation writers Picture of Testers
Trying to get AsciiMath to work in Moodle 2.0 and fell at the first hurdle.. There is no meta.php file in Moodle 2.0 or is it hidden so carefully and well that it is just not easily found?


Average of ratings: -
In reply to Colin Fraser

Re: AsciiMath and Moodle 2.0

by Mauno Korpelainen -

*Everything* has changed in moodle 2.0 wink

People have asked the same question in private messages (emails) a couple of times so you are not the first one to worry about missing meta.php.

If you want to use javascripts like AsciimathML in moodle 2.0 through themes see for example docs about using jQuery:

http://docs.moodle.org/en/Development:Using_jQuery_with_Moodle_2.0

So supposing that you are using a file called AM.js you can for example

- copy your asciimathml javascript file to folder theme/yourtheme/javascript, I added AM.js to theme/standard/javascript/AM.js

- edit file theme/yourtheme/config.php, in my case I edited theme/standard/config.php and

a) if you want to add code of AM.js to header tags use

$THEME->javascripts = array('AM');

b) if you want to add code of AM.js to footer tags use

$THEME->javascripts_footer = array('navigation', 'AM');

Here script navigation.js is already included to standard theme footer javascripts by default.

You won't see the actual script names in source code but the scripts do work through theme javascripts.

If nothing happens when you add Asciimathml tags (or other javascript tags) old theme files may be in cache and you can invalidate cache from Site Administration > Appearance > Themes > Theme selector ... (a button at the top) or turn on Theme Designer Mode from Site Administration > Appearance > Themes > Theme settings while changing the files of theme

Note that there is currently a setting in theme selector of moodle 2.0 that let's you select different theme for "old browsers" (IE6&7) and "Modern browsers" so if you use asciimathml only in one theme check that all browsers are using correct theme.

In reply to Mauno Korpelainen

Re: AsciiMath and Moodle 2.0

by Colin Fraser -
Picture of Documentation writers Picture of Testers
I suspect that the push will be all Users to be using the same theme, there will be no options below an individual site level if there is a way to prevent it.

MimeTeX is the default for M2.0 and for schools here I doubt they are going to be given any option about what TeX filter they will be using.

This is more for my personal amusement at this point. However, I shall persist. Thanks Muano.



In reply to Mauno Korpelainen

Re: AsciiMath and Moodle 2.0

by Darian Leduc -

Hello Mauno.

I don't know if I am allowed to reply / post here.  The whole MOODLE community is very daunting to me.

Anyhoo... here 'goes..

I read and have tried very hard to implement AsciiMath into Moodle 2.0.

Summary of my actions thus far:

  1. created javascript folder inside my custom theme folder (themename = alpha).
  2. copied my ASCIIMathML.js and other files to the newly created javascript folder.
  3. added   $THEME->javascripts = array('ASCIIMathML.js'); to my custom theme's config.php

  4. modified    alpha/javascript/javascript.php file to read:
    document.write('<script src="'+wwwroot+'/theme/asciimath/ASCIIMathML.js"></script>');

  5. Not even sure which tokens to use to 'surround' the asciimath notation.

Please advise.... or point me to a help page specifically geared for MOODLE 2.0.

Many thanks

DarianLeduc

In reply to Darian Leduc

Re: AsciiMath and Moodle 2.0

by Mauno Korpelainen -

The old filter files can be confusing...

First: if you need to add javascripts to moodle 2 themes and you have moved those javascript files to your theme javascript folder don't use .js in that config.php array - simply

$THEME->javascripts = array('ASCIIMathML');

if the name of your script is ASCIIMathML.js

Second: you don't need any extra javascript.php file there with some document.write code - it was used in old asciimathml filter before moodle 2 when filters could add javascripts automatically with javascript.php inside filter folder.

Third: you can see and change those tokens from in your ASCIIMathML.js script - usually asciimathml tags use tokens `...` and latexmathml tokens $...$

 

In reply to Mauno Korpelainen

Re: AsciiMath and Moodle 2.0

by Darian Leduc -

Thanks Mauno.

I actually figured out that the javascript.php was 'old' and got rid of it.

But....

Still no luck.

I had asciimath working temporarily , when I experimentally tried simply adding a javascript folder to an EXISTING theme instead of into my own newly created custom theme.

I also experimentally tried copying an existing theme, making appropriate modifications  but.............

I suspect something to do with the themes caching, but I cleared both the theme cache using button in theme selector

AND

by clearing my Firefox caches completely then restarting.

In reply to Darian Leduc

Re: AsciiMath and Moodle 2.0

by Darian Leduc -

GOT IT WORKING FINALLY -

had to do with missing quotes ' ' and/or putting .js instead of simply the filename SANS extension in the array listing etc.

So annoying ....arghhh.  but its working smile smile smile

mixedmixed

I spoke too soon... I can see the TeX display correctly but when I try to edit I get a crazy popup error message.  I will try to submit it if I can recreate it.

 

The last lines in my config.php (yes.. the themes one, not the 'other one' wink ) are as follow:

$THEME->javascripts = array();
$THEME->javascripts_footer = array(ASCIIMathML);

popup error

In reply to Darian Leduc

Re: AsciiMath and Moodle 2.0

by Mauno Korpelainen -

Tiny things matter smile

In reply to Mauno Korpelainen

Re: AsciiMath and Moodle 2.0

by Marc Grober -
Mauno, I suppose it's time to add sections in the docs for the various math apps for m^2........ how are you doing on a release of SEE and should we set that up in M&P db? I am finally back in Ak and will try to get some work done wink
In reply to Marc Grober

Re: AsciiMath and Moodle 2.0

by Mauno Korpelainen -

To be honest I have been hurry-scurry with my daily job (this is the busiest time of my school year) so I have not changed those files during the last month - since I tried to create new moodle 2 math filters and noticed that a couple of pages like User profile did not read the javascripts from filters even if the same files worked just fine with theme layout files.

From old filters such filters that use javascript.php to render javascripts do not work in moodle 2 so at least old jsMath and asciimathml filters can't be used anymore with moodle 2. I have not checked if for example GeoGebra filter can be used in moodle 2 - most likely not...

Anyway - we are now in officially "stable release" of moodle 2 so yes, you are right and moodle 2 docs for maths should be upgraded and I should as well try to continue with my "X-files" smile

In reply to Darian Leduc

Re: AsciiMath and Moodle 2.0

by Mauno Korpelainen -

I think I have said this already twice but here we go once more: the correct way is to use those quotes without .js in array

$THEME->javascripts = array('ASCIIMathML');

if the name of file is ASCIIMathML.js

If changes to php files like config.php do not seem to stick check that your php.ini does not have eaccelerator enabled with line

eaccelerator.enable = "1"

( You can change that to eaccelerator.enable = "0" and restart server )

If changes to theme files do not seem to stick you can enable theme designer mode from theme settings (Administration menu) or clear theme caches from Theme selector screen (or from moodledata)

If your theme does not seem to recognize any javascripts from theme javascript folder (given in config.php javascript array you can always edit theme layout files. For example if your theme has two layout files - frontpage.php and general.php - you can add tags like

<script src="<?php echo $CFG->httpswwwroot ?>/lib/ASCIIMathML.js" type="text/javascript"></script>

for example before </head> to both of these files to read file ASCIIMathML.js from your moodle lib folder - files don't need to be in theme javascript folder

In reply to Mauno Korpelainen

Re: AsciiMath and Moodle 2.0

by Darian Leduc -

Thank you so much for the reply.  It was those single quotes inside the array bracket that I missed.

It works and the editing seems to work (i.e. no strange behaviour).

But...found something wierd though...
the TWIRLY navigation arrows do not 'expand' on a page that contains the asciimath code.  Other pages work ok. I just triple checked.

P.S. I hope this is the 'correct' place to bring up these issues. If not let me know where I should do so.thx

In reply to Darian Leduc

Re: AsciiMath and Moodle 2.0

by Mauno Korpelainen -

Can you send a screenshot about those non-expanding navigation arrows and check the version of your asciimathml file (found from the script) & the version of your browser?

In reply to Mauno Korpelainen

Re: AsciiMath and Moodle 2.0

by Darian Leduc -

Will create a VIDEO.  Screencap will not be useful.

In reply to Darian Leduc

Re: AsciiMath and Moodle 2.0

by Darian Leduc -

HERE IS THE VIDEO::

In reply to Darian Leduc

Re: AsciiMath and Moodle 2.0

by Mauno Korpelainen -

I really have no idea what could cause your navigation problem with AsciiMathML script - I could not reproduce it, not even with the old filter script. I tried with the latest moodle 2 in cvs and formal_white theme and navigation menu & arrows worked just fine with AsciiMathML.

In http://moodle.org/mod/forum/discuss.php?d=155977 Tim Hunt pointed out a new setting

Site administration > Appearance > Additional HTML > Within HEAD

that you could try as well with tags like

<script type="text/javascript" src="http://pathtouyourmoodle/ASCIIMathML.js"></script>

but this problem might be caused by some other javascript conflict - have you checked Firefox Error console?

In reply to Mauno Korpelainen

Re: AsciiMath and Moodle 2.0

by Darian Leduc -

Well I checked the Firefox error log and found the following. No idea what it means. Any ideas would be helpful.

=================================================================

Code:    Evaluate

Unknown property 'border­radius'.  Declaration dropped.    5
http://www.yorkdale.net/moodle/theme/styles_debug.php?theme=formal_white&type=plugin&subtype=mod_quiz

Unknown property 'border­radius­bottomleft'.  Declaration dropped.
http://www.yorkdale.net/moodle/theme/styles_debug.php?theme=formal_white&type=plugin&subtype=mod_quiz

Unknown property 'border­radius­topleft'.  Declaration dropped.
http://www.yorkdale.net/moodle/theme/styles_debug.php?theme=formal_white&type=plugin&subtype=mod_quiz

Unknown property 'border­radius'.  Declaration dropped.
http://www.yorkdale.net/moodle/theme/styles_debug.php?theme=formal_white&type=plugin&subtype=mod_quiz

Unknown property 'border­radius­bottomleft'.  Declaration dropped.
http://www.yorkdale.net/moodle/theme/styles_debug.php?theme=formal_white&type=plugin&subtype=mod_quiz

Unknown property 'border­radius­topleft'.  Declaration dropped.
http://www.yorkdale.net/moodle/theme/styles_debug.php?theme=formal_white&type=plugin&subtype=mod_quiz

Unknown property 'text­overflow'.  Declaration dropped.
http://www.yorkdale.net/moodle/theme/styles_debug.php?theme=formal_white&type=plugin&subtype=mod_quiz

Error in parsing value for 'position'.  Declaration dropped.
http://www.yorkdale.net/moodle/theme/styles_debug.php?theme=formal_white&type=plugin&subtype=mod_scorm

Error in parsing value for 'filter'.  Declaration dropped.
http://www.yorkdale.net/moodle/theme/styles_debug.php?theme=formal_white&type=plugin&subtype=block_community

Unknown property 'line­break'.  Declaration dropped.
http://www.yorkdale.net/moodle/theme/styles_debug.php?theme=formal_white&type=parent&subtype=base&sheet=admin

Error in parsing value for 'vertical­align'.  Declaration dropped.
http://www.yorkdale.net/moodle/theme/styles_debug.php?theme=formal_white&type=parent&subtype=base&sheet=admin

Error in parsing value for 'filter'.  Declaration dropped.    6
3

Error in parsing value for 'float'.  Declaration dropped.
http://www.yorkdale.net/moodle/theme/styles_debug.php?theme=formal_white&type=parent&subtype=base&sheet=message    5

Error in parsing value for 'filter'.  Declaration dropped.
http://www.yorkdale.net/moodle/theme/yui_combo.php?3.2.0/build/node­menunav/assets/skins/sam/node­menunav.css&

Expected declaration but found '*'.  Skipped to next declaration.
http://www.yorkdale.net/moodle/theme/yui_combo.php?3.2.0/build/node­menunav/assets/skins/sam/node­menunav.css&

Expected declaration but found '*'.  Skipped to next declaration.
http://www.yorkdale.net/moodle/theme/yui_combo.php?3.2.0/build/node­menunav/assets/skins/sam/node­menunav.css&

Expected declaration but found '*'.  Skipped to next declaration.
http://www.yorkdale.net/moodle/theme/yui_combo.php?3.2.0/build/node­menunav/assets/skins/sam/node­menunav.css&

Expected declaration but found '*'.  Skipped to next declaration.
http://www.yorkdale.net/moodle/theme/yui_combo.php?3.2.0/build/node­menunav/assets/skins/sam/node­menunav.css&

Expected declaration but found '*'.  Skipped to next declaration.
http://www.yorkdale.net/moodle/theme/yui_combo.php?3.2.0/build/node­menunav/assets/skins/sam/node­menunav.css&

Expected declaration but found '*'.  Skipped to next declaration.
http://www.yorkdale.net/moodle/theme/yui_combo.php?3.2.0/build/node­menunav/assets/skins/sam/node­menunav.css&

Expected declaration but found '*'.  Skipped to next declaration.
http://www.yorkdale.net/moodle/theme/yui_combo.php?3.2.0/build/cssreset/reset­min.css&3.2.0/build/cssfonts/fonts­min.css&3.2.0/build/cssgrids/grids­min.css&3.2.0/build/cssbase

Expected declaration but found '*'.  Skipped to next declaration.
http://www.yorkdale.net/moodle/theme/yui_combo.php?3.2.0/build/cssreset/reset­min.css&3.2.0/build/cssfonts/fonts­min.css&3.2.0/build/cssgrids/grids­min.css&3.2.0/build/cssbase

Expected declaration but found '*'.  Skipped to next declaration.
http://www.yorkdale.net/moodle/theme/yui_combo.php?3.2.0/build/cssreset/reset­min.css&3.2.0/build/cssfonts/fonts­min.css&3.2.0/build/cssgrids/grids­min.css&3.2.0/build/cssbase

Error in parsing value for 'font'.  Declaration dropped.
http://www.yorkdale.net/moodle/theme/yui_combo.php?3.2.0/build/cssreset/reset­min.css&3.2.0/build/cssfonts/fonts­min.css&3.2.0/build/cssgrids/grids­min.css&3.2.0/build/cssbase
3    4
4

=================================================================

In reply to Mauno Korpelainen

Re: AsciiMath and Moodle 2.0

by Darian Leduc -

Been busy. Hope to send soon. However, kinda of don't want to because it really messes up my site.  I think I need to crete a test site and work off that.

A general question Mauno... are all the 1.9.x plugins pretty much useless in 2.0?  I tried to add Questionnaire, AsciiMATH, Quickmail and none of them worked.  Most of them would not even 'install' i.e. would not show up in 'admin notification' window and/or get an error during install stating that the it is an OLD / NON_STANDARD plugin or something like that.

In reply to Darian Leduc

Re: AsciiMath and Moodle 2.0

by Mauno Korpelainen -

Yes, it's true - most non core ( other than moodle 2 ) plugins do not work in moodle 2 - they need to be upgraded to use code of moodle 2.

For example the old AsciiMath filter does not work in moodle 2 but AsciiMathML (javascript) itself can be used with moodle 2 with theme files like mentioned before.

In reply to Mauno Korpelainen

Re: AsciiMath and Moodle 2.0

by Darian Leduc -

I am confused about how PLUGINS are described in terms of REQUIREMENTS - Moodle 1.9 or later

1.9 or later does not include 2.0, does it??? surprise

If not, why write 1.9 or later. Was this all written before 2.0 came out?

In reply to Darian Leduc

Re: AsciiMath and Moodle 2.0

by Mauno Korpelainen -

Yes, it is very confusing and "somebody" should definitely change such confusing parts of docs, as a general rule typical "moodle docs" are written for moodle 1.X.X and moodle 2 has separate moodle 2 docs for moodle 2.X.X

If you see download links like

Download for Moodle 2.0

you can safely use these plugins with moodle 2 but not with moodle 1.9.

Or if you see in Modules and plugins requirements tab text like

Requires: Moodle 2.0 or later

you can use those plugins with moodle 2 but not with moodle 1.9.

In non-core plugins REQUIREMENTS - Moodle 1.9 or later, 1.9 or later does not usually mean that those plugins automatically work with moodle 2.X, usually they don't ... or have not been tested and upgraded to work with moodle 2.X.

All core plugins are using code written for each core version and what ever non-core plugins you test you should install and use them at your own risk wink

In reply to Mauno Korpelainen

Re: AsciiMath and Moodle 2.0

by Doug Smith -

Hi, I am having problems with ASCIIMath and Moodle 2.0. I believe I have followed the correct procedure by adding

$THEME->javascripts_footer = array('ASCIIMathML');

to config.php in my theme folder. I have also enabled Theme designer mode. I did not modify php.ini.  Two things happen when I have the ASCIIMathML javascript in the config file. First, the math notation is not shown - it looks like regular text. Secondly, the editor breaks. In the screencast below I start off without ASCIIMathML enabled. You will see my editor look normal. I then insert the javascript code, refresh and the math doesn't show, go back to the editor and the text disappears from the editor.

In reply to Doug Smith

Re: AsciiMath and Moodle 2.0

by Marc Grober -

I have brute forced it by hacking general.php and Mauno has done it via the method you mention,  though an earlier poster described an issue I believe was not resolved,  but the most elegant solution to date is the one Tim suggested,  which Mauno cites in this thread and I am quoting below:

In http://moodle.org/mod/forum/discuss.php?d=155977 Tim Hunt pointed out a new setting

Site administration > Appearance > Additional HTML > Within HEAD

that you could try as well with tags like

<script type="text/javascript" src="http://pathtouyourmoodle/ASCIIMathML.js"></script>

In reply to Marc Grober

Re: AsciiMath and Moodle 2.0

by Doug Smith -

Thanks for the help.

I tried this as well, and I get the same behaviour mentioned above. There is no math notation, and when I go to edit the page the editor does not show the text. Even weirder (to me) is that when I am on the edit page, the menu blocks on the left do not work either.

 

cheers

In reply to Doug Smith

Re: AsciiMath and Moodle 2.0

by Mauno Korpelainen -

This sounds like a typical (theme/plugin/custom) javascript conflict - you could try to find out the reason with different debugging tools.

I would check first different browsers - FF has error console, in Chrome you can inspect elements and script errors and IE8 has very good debugging tools - just press <shift> F12 and Start debugging...

In the past some tinymce plugins had errors that could break code and there are different asciimathml scripts available... so it would be helpfull to get the version of your script or the script itself. Or sometimes some custom browser plugin or javascript performance testing tool (program) - or site advertisement script or cracked code - can cause similar issues.

In reply to Mauno Korpelainen

Re: AsciiMath and Moodle 2.0

by Doug Smith -

My debugging isn't too useful yet. I've found the console for ie8 but haven't yet identified what tools show me errors or give me error logs. Sort of the same with Chrome. Firefox error console lists a bunch of missing properities but I didn't see anything that jumped out as being a javascript or script error.


I am using ASCIIMathMS.js 2.0.1, along with Moodle 2.0.1+ (Build: 20110112). The asciimathml file can be found here (it was too big to attach): http://www.dryfly.ca/school/public/forum/ASCIIMathML.js

I now see that in ie8, my text does not disappear in the editing page. The text only disappears when using firefox or chrome.  As well, when I first opened my math page (not the editor) in chrome, the math notation was shown correctly! Subsequent loading of the math page in chrome has the notation loading 1/2 correctly (see the picture below). When chrome first loaded this page, the integral was shown larger with the limits positioned correctly. As well, the text was blue.

I can for sure try more browser debugging if I have some hints on what/where to look. I also have firebug for firefox if that helps (I use it for html/css editing).

In reply to Doug Smith

Re: AsciiMath and Moodle 2.0

by Mauno Korpelainen -

No need for further debugging - the version of your script was enough.

If you want to use that script with all themes add from

Site administration > Appearance > Additional HTML

to Within HEAD box

<script type="text/javascript" src="http://www.dryfly.ca/school/lib/asciimath/ASCIIMathML.js">

and script should be detected ( in fact it was already there in source of your site )

The reason for this odd behaviour is in script (version) itself. If you edit the file with some texteditor (for example notepad++) and change in line 50

var avoidinnerHTML = false;

to

var avoidinnerHTML = true;

FF should work ok with editor.

Another issue is that this script version is from Sept 27, 2007 and it does not have image fallback so Firefox is the only browser that supports native MathML without extra plugins and you need to have some plugin like MathPlayer installed (to browser) to be able to use this version of script with other browsers like Chrome, IE, Opera or Safari.

In reply to Mauno Korpelainen

Re: AsciiMath and Moodle 2.0

by Doug Smith -

Thanks for the help, it got things working.

I also came across this thread, discussing fallbacks. Right now I am trying out the ASCIIMathMLwFallback2.js (based on ASCIIMathML.js ver 2.0.9). It seems to work quite well on the different browsers. I haven't changed anything so I assume it is using the public mimetex server for images.

Considering that I require modest requirements for math notation, just enough to write high school math and physics equations, do you think there is a preferred method between using ASCIIMathMLwFallback2.js or the Moodle TEX notation filter (which seems to work okay for me)? I don't see any reason why the ASCIIMathML.js should be used in place of the fallback version. The asciimath scheme is easier to use than TEX, that's for sure.

thanks

In reply to Doug Smith

Re: AsciiMath and Moodle 2.0

by Marc Grober -
For your purposes there is no reason to turn Tex filter on. You can change the fallback resources in the js file.
In reply to Doug Smith

Re: AsciiMath and Moodle 2.0

by Marc Grober -
Doug, For the purpose of improving Moodle Docs, why did you search for and use the version of ASCIIMath you found rather than use the version identified in the Docs?
In reply to Marc Grober

Re: AsciiMath and Moodle 2.0

by Doug Smith -

That's a great question! I in fact did download ASCIIMath 2.0.2 using the link from the Moodle Docs. Why exactly I ended up with 2.0.1, I'm not entiredly sure. I think during my exploratory process I had some problems, and I ended up at Peter Jipsen's asciimath webpage and decided to download the script again. I think my mind glazed over the difference between 2.0.1 and 2.0.2. As far as the Moodle Docs are concerned, I would think that most people should find 2.0.2.

FWIW, what are the changes from 2.0.1 to 2.0.2? The asciimathchanges.txt doesn't say.