Note: You are currently viewing documentation for Moodle 3.7. Up-to-date documentation for the latest stable version of Moodle may be available here: DragMath equation editor.

DragMath equation editor: Difference between revisions

From MoodleDocs
No edit summary
No edit summary
Line 45: Line 45:


DragMath may eventually become core technology in Moodle,  meaning that as of a certain version no installation may be required, but installation instructions will continue to remain so as to support older versions as long as feasible.
DragMath may eventually become core technology in Moodle,  meaning that as of a certain version no installation may be required, but installation instructions will continue to remain so as to support older versions as long as feasible.
====Installing DragMath from the non-CVS Zip - Recommended!====
We have come full circle and as a result of the issues with maintaining a current adminlib.php for every version as well as with the potential move of dragmath that may take place with Moodle 2, dragmath is now available as a [http://tracker.moodle.org/secure/attachment/16366/dragmath_v0.7.7.1_moodle.zip zip file] that can be easily installed from your root moodle directory (unlike the CVS zip described below.


====Installing DragMath From the Moodle CVS - Recommended!====
Simply place the zip file above in your root moodle directory (/moodle for many) and unzip.  The dragmath files will be installed in their correct locations.  Additionally,  you will get instead of a replacement adminlib.php, a file called adminlib_exampleonly.php which you can diff with your adminlib.php to demonstrate the addition of the lines to allow you to turn the dragmath icon on and off (see below.)


This could not be easier.  If you are running verion 1.9.+  [http://download.moodle.org/patches19/dragmath.zip click here] or if you are running Moodle version 1.8.4 or greater but not 1.9.x [http://download.moodle.org/patches18/dragmath.zip click here]
====Installing DragMath From the Moodle CVS====
and you will start the download of the zip file (at present there are no differences between the two versions.
 
If you are running verion 1.9.+  [http://download.moodle.org/patches19/dragmath.zip click here] or if you are running Moodle version 1.8.4 or greater but not 1.9.x [http://download.moodle.org/patches18/dragmath.zip click here]
and you will start the download of the cvs zip file (at present there are no differences between the two versions.)


At this point you can unzip on your workstation and then you can upload the included files to their appropriate locations ('''but read the warning below first'''). This version retains the smileys and includes all integration files and all DragMath files (demos, docs, and  all export formats)  The Moodle automagically creates the zip with a parent directory of "dragmath".  Should you wish you can unzip the files and then rezip with the top level directory being /lib,  and this will allow you to simply upload the zip you just created to your moodle root and unzip there,  and the files will be placed in their appropriate locations. However, please DO NOT include the adminlib.php file and make sure all files are backed up,  and in as much as there are only a few files you may want to manually install even if a zip with  /lib as top directory were provided here just to ensure each file is backed up before installation. Upload the zip file to your Moodle root and unzip.
At this point you can unzip on your workstation and then you can upload the included files to their appropriate locations ('''but read the warning below first'''). This version retains the smileys and includes all integration files and all DragMath files (demos, docs, and  all export formats)  The Moodle automagically creates the zip with a parent directory of "dragmath".  Should you wish you can unzip the files and then rezip with the top level directory being /lib,  and this will allow you to simply upload the zip you just created to your moodle root and unzip there,  and the files will be placed in their appropriate locations. However, please DO NOT include the adminlib.php file and make sure all files are backed up,  and in as much as there are only a few files you may want to manually install even if a zip with  /lib as top directory were provided here just to ensure each file is backed up before installation. Upload the zip file to your Moodle root and unzip.
Line 56: Line 60:


'''DO NOT''' over write your adminlib.php. Install the rest of the files (other than adminlib.php) and DragMath will work without a problem.  
'''DO NOT''' over write your adminlib.php. Install the rest of the files (other than adminlib.php) and DragMath will work without a problem.  
 
====Managing Your Editor Icons Through adminlib.php====
To be able to hide your dragmath icon, save your existing copy of adminlib.php (you will find it in the /lib directory) and insert this line:
To be able to hide your dragmath icon, save your existing copy of adminlib.php (you will find it in the /lib directory) and insert this line:
                     'insertdragmath' => 'em.icon.dragmath.gif',
                     'insertdragmath' => 'em.icon.dragmath.gif',

Revision as of 01:16, 24 March 2009

Introduction

To quote the W3C [1]:

This is an open-source drag and drop equation editor written in Java.
Once an expression is created the user can convert it into a variety 
of different linear syntax for mathematics, including MathML, LaTeX,
Maple, Maxima or any user defined style.

Created by Christoper Sangwin and Alexander Billingsley at the University of Birmingham as part of the STACK project, DragMath allows students to build mathematical expressions using a graphical drag-and-drop interface similar in appearance to that available in a number of office productivity suites.

Initially integrated with Moodle to be used with Moodle's Tex filter, the export feature available with DragMath has now allowed an integration that supports the creation of LaTex text expressions with and without the doubledollar signs used to signal parsing by the filter as well as AsciiMathML text expressions.

To use DragMath, users must have the Java Runtime Environment (JRE) version 1.5 or higher installed on their desktop computers. Most systems come with the JRE as standard equipment, so you may not have to do anything. If you need to install the JRE manually, you can download it from here. Note that the JRE is variously known as Java software for your computer, Java Runtime Environment, the Java Runtime, Runtime Environment, Runtime, Java Virtual Machine, Virtual Machine, Java VM, JVM, VM, or Java download.

You can see a demo of the DragMath editor here. The DragMath interface is highly intuitive and anyone can be using it productively after a few minutes of trial-and-error. If you have questions about the editor, there is a short manual here.

How the DragMath editor has been integrated with Moodle

DragMath is integrated with Moodle through a new button on the editor toolbar. This way, the DragMath editor is available everywhere that you or your students are called upon to enter text. Please note: The DragMath editor does not come supplied with Moodle. You (or your administrator) will have to install it. The following comments are targeted at the single file install, which has retained the beloved smileys.

Getting Started

Suppose that you're entering text in the HTML editor and you reach a point where you want to insert a mathematical expression. You want to be able to show the tedxt expression you would use to create an equations as well as the equations itself. Pushing the DragMath button launches the DragMath editor in a small popup window (Note: the first time you do this, there will be a delay of a few seconds due to applet initialization).

Create the math expression in DragMath

Drag the various graphic constituents of your equation into the construction area until the equation is to your satisfaction.

Save the expression

From the Menu Bar click File->Save As or click on the floppy icon. Provide a local location where you want to save the equation and the applet stores the equation there in a .dgrm file.

Select Export Format

From the Menu Bar click Options->Set Export Format. If you want to insert the text expression for a tex formula, select LaTex. If you wish to insert the text expression with the doubledollar toeksn so that the expression will be converted by the moodle tex filter, select MoodleTex (this will likely be the default choice in your applet). If you have replaced your tex filter with the ASCIIMathML filter, select ASCIIMathML.

Insert the expression

Click the "Insert button" and you're done. The editor will disappear and the output you selected will be inserted. If you chose MoodleTex, the LaTeX expression (with $$ delimiters added at both ends) will be inserted into your text at the current cursor position. Note the screen shot below. This demonstrates the results when you have selected MoodleTex to insert the equation in your work. Note ASCIIMathML users: the ASCIIMathML.xml file currently has backtics set as tokens. You can edit that file to use the auto nomenclature if you choose

Altering Applet Parameters

In the case of HTMLarea, the applet parameters are set in dlg_ins_dragmath.php which can be found in moodleroot/lib/editor/htmlarea/popups . Should you wish to change the default export format or implement additional parameters after reviewing the DragMath documentation, please remember to back up a copy of your original file. The various XML export formats, which you can customize (with care) can be found at moodleroot/lib/editor/htmlarea/plugins/applet/classes/formats and the xml configuration file, Config.xml, in classes.

DragMath instructions

Installing DragMath

You can install dragmath using the CVS zip. DragMath has become so popular, that it is now offered in a simgle zip that includes not only the integration files (at least for htmlarea for the present and with smileys) but the current DragMath files as well. For the user this means that one can simply download one zip file, place it in the moodle root and unzip.

This method is different than previously used. Beware of relying on forum postings on dragmath posted prior to March 2007 as they may be addressing files and methods no longer in use. You may also find a variety of development code in the forums regarding use of dragmath with a number of editors. Some of this may work and some may not. Use at your own risk!

DragMath may eventually become core technology in Moodle, meaning that as of a certain version no installation may be required, but installation instructions will continue to remain so as to support older versions as long as feasible.

Installing DragMath from the non-CVS Zip - Recommended!

We have come full circle and as a result of the issues with maintaining a current adminlib.php for every version as well as with the potential move of dragmath that may take place with Moodle 2, dragmath is now available as a zip file that can be easily installed from your root moodle directory (unlike the CVS zip described below.

Simply place the zip file above in your root moodle directory (/moodle for many) and unzip. The dragmath files will be installed in their correct locations. Additionally, you will get instead of a replacement adminlib.php, a file called adminlib_exampleonly.php which you can diff with your adminlib.php to demonstrate the addition of the lines to allow you to turn the dragmath icon on and off (see below.)

Installing DragMath From the Moodle CVS

If you are running verion 1.9.+ click here or if you are running Moodle version 1.8.4 or greater but not 1.9.x click here and you will start the download of the cvs zip file (at present there are no differences between the two versions.)

At this point you can unzip on your workstation and then you can upload the included files to their appropriate locations (but read the warning below first). This version retains the smileys and includes all integration files and all DragMath files (demos, docs, and all export formats) The Moodle automagically creates the zip with a parent directory of "dragmath". Should you wish you can unzip the files and then rezip with the top level directory being /lib, and this will allow you to simply upload the zip you just created to your moodle root and unzip there, and the files will be placed in their appropriate locations. However, please DO NOT include the adminlib.php file and make sure all files are backed up, and in as much as there are only a few files you may want to manually install even if a zip with /lib as top directory were provided here just to ensure each file is backed up before installation. Upload the zip file to your Moodle root and unzip.

Warning: At present the CVS zip file includes a version of adminlib.php. This file is included because there is a line added to it that allows you to hide the dragmath icon. In any event, the included adminlib.php should NOT be used to over write your adminlib.php!

DO NOT over write your adminlib.php. Install the rest of the files (other than adminlib.php) and DragMath will work without a problem.

Managing Your Editor Icons Through adminlib.php

To be able to hide your dragmath icon, save your existing copy of adminlib.php (you will find it in the /lib directory) and insert this line:

                    'insertdragmath' => 'em.icon.dragmath.gif',

below this line:

                    'insertsmile' => 'em.icon.smile.gif',

and save. The line can really be placed anywhere in that array, but by providing a specific location it will help when addressing requests for assistance in hiding buttons. And, having taken the time to explore this beautiful little array, you can now alter your button images to your hearts content!

The array is employed by the admin GUI (Site Administration-> Appearance->HTML editor) to provide you the Administrator with the ability to hide buttons in the HTML editor via editorhidebuttons. Once you have installed Dragmath and added the button, you can use the GUI to hide the insertdragmath button.

You may ask, what about altering the adminlib.php file in the CVS or providing a patch? This was raised and you can vote on it. Let's get real here folks, we are talking about one line which could be added to adminlib.php at 1.8.4 or later without any other impact. Is it really necessary to provide a separate adminlib.php for dragmath everytime someone changes adminlib.php in the core? If you have an opinion on this please edit the page comments on this and provide your input as to whether adminlib.php should just be dropped from the dragmath distribution.

Locally saving and restoring a DragMath expression

When you press the Insert button, DragMath inserts the export string into your text and the DragMath window closes. The exported string can no longer be manipulated using DragMath. If you decide to change the string, you have two options:

  • delete the string (including the dollar signs or other token) and completely recreate it using DragMath
  • edit the expression by hand

You can not tell DragMath to re-read the expression and show it again in two dimensions. This is a theoretical limitation, not a limitation of DragMath.

But suppose the expression is very complicated. It would be impractical to start over just to make a simple change. Before you Insert the expression, you can save a copy of the expression (a .drgm file) to your local disk using the Save button (see screenshot). Later, if you need to make a change, you open the saved .drgm file.

DragMath instructions

A .drgm file contains three-dimensional representation of your mathematical expression. It is a binary file that can only be opened by DragMath.

Development

Square brackets

Use of text expressions in the Moodle Wiki can create problems when the text expression includes square brackets, which is how TeX expresses the nth root. Pending a simple wiki based solution users may want to use the ASCIIMathML filter and the ASCIIMathML export format as this combination avoids the use of square brackets.

Consistent integration with all html editors

The Moodle discussion regarding html editors suggests that it will be important for DragMath to have consistent integration with a variety of html editors as htmlarea passes into obsolescence. Plugins for tinyMCE, Xinha and FCKEditor with a similar structure and common codebase are ready and compatible with all browsers that support javascript and Java.

Additional formats

There are quite a few options now available for creating text expressions to for displaying equations and moodle functionality can only be increased if tools were able to create and parse expressions created by the tools a user is most comfortable with. ASCIIMathML is one tool now available as a filter for Moodle that allows the parsing of both TeX and its own ASCIIMathML text expression syntax. Microsoft has now launched its OMML initiative in Office 2007 (see footnotes on http://en.wikipedia.org/wiki/Office_Open_XML and OpenOffice employs its own text expression syntax (the OOo syntax is described at http://documentation.openoffice.org/manuals/oooauthors2/0216WG-MathObjects.pdf). The ability to have DragMath create text expressions that can be used in native documents as well as parsed by filters such as ASCIIMathML will help make use of equations on-line more transparent for everyone.