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
m (Text replacement - "class="nicetable"" to "class="wikitable"")
 
(70 intermediate revisions by 10 users not shown)
Line 1: Line 1:
===Introduction===
<p class="note">'''WARNING:'''  To use DragMath, you need to activate the TeX filter in Moodle.  End users will also need to have a recent Java Runtime Environment installed.  DragMath is no longer available in the new Atto editor introduced in Moodle 2.7. DragMath was available in the TinyMCE editor in Moodle 2.7, it is not distributed in Moodle 2.8 and later.  It is available elsewhere as a third-party plugin which may be downloaded and installed by an administrator.</p>
 
==Introduction==
To quote the W3C [http://www.w3.org/Math/Software/mathml_software_cat_editors.html]:
To quote the W3C [http://www.w3.org/Math/Software/mathml_software_cat_editors.html]:
  This is an open-source drag and drop equation editor written in Java.
  This is an open-source drag and drop equation editor written in Java.
Line 7: Line 9:
Created by Christoper Sangwin and Alexander Billingsley at the University of Birmingham as part of the [http://www.stack.bham.ac.uk 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.  
Created by Christoper Sangwin and Alexander Billingsley at the University of Birmingham as part of the [http://www.stack.bham.ac.uk 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.
John Isner initially created and maintained several files that allowed for integration of DragMath with HTMLArea, Moodle's editor in 2007. DragMath was then maintained by Marc Grober until it was integrated into core Moodle with the release of Moodle 2.0. An outgrowth of the development to integrate DragMath into tinyMCE has been the development of SEE by Mauno Korpelainen (a link to those plugins can be found below.)


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 [http://java.com/en/download/index.jsp 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.   
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 [http://java.com/en/download/index.jsp 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 [http://www.dragmath.bham.ac.uk/ 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 [http://www.dragmath.bham.ac.uk/doc/index.html here].
You can see a demo of the DragMath editor [http://www.dragmath.bham.ac.uk/ 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 [http://www.dragmath.bham.ac.uk/doc/index.html here] which also discusses the various configuration options, some of which are mentioned briefly below.


===How the DragMath editor has been integrated with Moodle===
==Using DragMath==
DragMath is based on the simple idea that the User who does not know a lot of TeX (pronounced Tech) can still create mathematical formula for publishing. In this case, Moodle is the dispaly agent so the TeX formulae are then rendered to a Moodle screen. This essentially means that with little experience, any Junior High Maths teacher can generate all the formulae they need for most aspects of Maths in Moodle.


[[Category:Mathematics]]
===Creating simple expressions===
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====
To begin, click on the DragMath insertion button. This opens The DragMath interface.  
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====
[[Image:dragmath02.png|thumb|200px|center|Opening Dragmath]]
Drag the various graphic constituents of your equation into the construction area until the equation is to your satisfaction.


====Save the expression====
The toolbar is different than you may expect, we are used to nice neat rows of buttons, but Dragmath has to use tabs. Each tab is tab is a collection of "templates", that is each symbol is a "template" and can be dragged and dropped onto the work space.
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====
[[Image:dragmath01.png|thumb|200px|center|The DragMath Interface]]
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====
To end editing and insert the script into the Moodle page, click the Insert button. This simple, but not simplistic, interface is a strength of DragMath. It make it easy for even novices to create complex formulae.
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====
The window presented by the dragmath plugin is controlled by an applet reference in a php file, which for htmlarea in Moodle 1.9.x is dlg_ins_dragmath.php,  one of the files included in the distribution, which can be found in moodleroot/lib/editor/htmlarea/popups .  Applet parameters, per the dragmath documentation, can be changed in this file.  By default, the language is set to English and the output format is set to MoodleTex (that is,  the output will include double dollars signs, and if you have turned off your tex filter and are using asciimath then you will probably want to set your default export format to ASCIIMathML.)


In answer to the prayers of users, the STACK folk added the ability to drop the dot that DragMath had always inserted in 3x between the coefficient and the variable as in 3∙x . You will find a menu item in DragMath's gui to turn this on and off right next to the menu items for formatting.  This setting can also be set via an applet parameter.  
{| class="wikitable" align="center"
|-
| colspan="4"|'''A sequence for DragMath - click an image to enlarge'''
|-
|[[Image:dragmath04f.png|thumb|150px|Select the Tab with the symbols required]]
|[[Image:dragmath03.png|thumb|150px|Click, hold then drag'n'drop a symbol]]
|[[Image:dragmath04.png|thumb|150px|Enter the values, select an operation symbol]]
|[[Image:dragmath04a.png|thumb|150px|Select another symbol and drag'n'drop]]
|-
|[[Image:dragmath04b.png|thumb|150px|Add an equal (or other) sign]]
|[[Image:dragmath04c.png|thumb|150px|Add in a variable, (chi in this case) ]]
|[[Image:dragmath04d.png|thumb|150px|Click Insert]]
|[[Image:dragmath04e.png|thumb|150px|See the encoded result in the editing dialog.]]
|}


You can add formats and languages via /lib/DragMath/Config.xml with the various XML export formats in the formats subdirectory of applets and the languages in the lang subdirectory. Of course you can, with care, edit the various xml files.
This same sequence of operations apply equally for all formulae, all insertions, no matter how complex they become.  


Should you wish to make any changes, please remember to back up a copy of your original file.  
You can insert a template from the toolbar by drag and drop or by a click on the template in the tab, then clicking in the workspace.


[[Image:Dragmath_instructions.png|DragMath instructions]]
===Creating more complex expressions===


===Installing DragMath===
More complex expressions are pretty much more of the same as above. Creating a simple multiplication table matrix, for example, seems complex,but in DragNath, it is actually simple:
The most current version of DragMath can now be installed properly by simply using unzip (see the section immediately below this one).  The Moodle CVS system and issues with managing adminlib.php have resulted in our going to this new and easier to use package. The new package offers a single 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. The file can be unzipped in place, a welcome change from the hassles of installing with the Moodle CVS zip; just place the zip file in the moodle root and unzip.


This method is different than the two previously used. Beware of relying on installation advice or files posted in forums prior to July 2009 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 editorsSome of this may work and some may not, but none of it will be current. Use at your own risk!
{| class="wikitable" align="center"
|-
| colspan="4"|'''A sequence for a simple Multiplication Matrice in DragMath - click an image to enlarge'''
|-
|[[Image:dragmath05.png|thumb|150px|Select the Tab and add in the multiplier]]
|[[Image:dragmath05a.png|thumb|150px|Click, hold then drag'n'drop the Matrix symbol]]
|[[Image:dragmath05b.png|thumb|150px|Enter the values, select a equal symbol]]
|[[Image:dragmath05c.png|thumb|150px|Add in the rows required]]
|-
|[[Image:dragmath05d.png|thumb|150px|Add in the columns required]]
|[[Image:dragmath05e.png|thumb|150px|Edit the Matrice ]]
|[[Image:dragmath05f.png|thumb|150px|Add the equal symbol]]
|[[Image:dragmath05g.png|thumb|150px|Add and edit in the second Matrice.]]
|}
 
===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.


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.
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.


====Installing DragMath from the non-CVS Zip - Recommended!====
[[Image:Dragmath_save_and_restore.png|DragMath instructions]]
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/18040/dragmathintegration_v0.7.8.1_final.zip zip file] that can be easily installed from your root moodle directory (unlike the CVS zip described below,  one reason we recommend you no longer use the CVS zip.)


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 locationsAdditionally,  you will get 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 [[DragMath equation editor#Managing Your Editor Icons Through adminlib.php]]).
A .drgm file contains three-dimensional representation of your mathematical expressionIt is a binary file that can only be opened by DragMath.
===Additional Editing===


If you are using prior versions of DragMath it is suggested that you do a new install as there have been some changes internal to the DragMath directory as well as to the integration files. Once you have done a new install, future versions of DragMath in Moodle 1.9.x will likely only require that you replace the DragMath directory that has now been located at /lib/DragMath with a newer directory from sourceforge (or you can wait until you see an updated on Moodle).
There are times when '''DragMath''' is not going to have a symbol or something you might want. Or perhaps you left something out of the DragMath constuctor, so you want to include it manually. Most likely, for something like the matrix created earlier, I want to go to 15, which means I have to change the structure of the matrix, and edit in some numbers. This is easily done with a little forethought. Copy and paste and delete or edit what you want and do not want.


Early adopters of the as yet unreleased Moodle 2 should note that dragmath is presently included in HEAD (do not do any installation) and you should review the section on Moodle 2 below for further information.
{| class="wikitable" align="center"
|-
| colspan="4"|'''Manually editing a DragMath construction  - click an image to enlarge'''
|-
|[[Image:dragmath06a.png|thumb|150px|Select, copy and paste the original matrix]]
|[[Image:dragmath06b.png|thumb|150px|Edit to what is actually required]]
|[[Image:dragmath06c.png|thumb|150px|Delete the original matrix]]
|}


====Installing DragMath From the Moodle CVS - NOT RECOMMENDED====
Sometimes however, you just want to include something you forgot, or rather, add something that was not there in the first place.  
Please note that the Moodle CVS for dragmath is no longer being supported. The files however are still present and if you insist you can access them. It is recommended that you DO NOT DO THIS.


If you are running version 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]
{| class="wikitable" align="center"
and you will start the download of the cvs zip file (at present there are no differences between the two versions.)
|-
| colspan="4"|'''Accurately editing a DragMath construction manually - click an image to enlarge'''
|-
|[[Image:dragmath06d.png|thumb|150px|Construct the original equation]]
|[[Image:dragmath06e.png|thumb|150px|Copy, then edit to what is actually required]]
|[[Image:dragmath06f.png|thumb|150px|Return to the edited page]]
|}


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 thereand 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.
==What DragMath Does and How It Does It==
===Configuration files===
DragMath allows you to create your own configuration files.  That means it can be used to parse and display what you tell it to parse and display. By way of example, DragMath comes with a number of configuration files, one of which has been specifically designed to place doubledollar tokens before and after inserted text. We have seen a number of people change the TeX tokens in Modle using MathJax, and then become nonplussed that DragMath stops working. No DragMath still works, but it is likely inserting tokens that MathJax is not parsing. This can get confusing if you have more than one display technology in placeDragMath allows you to alter the tokens it inserts, so you can quite easily, for example, have DragMath insert startmath or endmath if that is what you want to use for tokens.
===Language Files===
DragMath can also use quite a few languages.
==So! You want to use DragMath but don't want to use the TeX filter?==
===What?===
Yes.  Moodle devs decided that you should not use DragMath unless you used the Moodle TeX filter (yes, over objections from lots of folk.) Does that mean that the TeX filter is the best way to go? Hardly.  The TeX filter is rather long in the tooth, desperately in need of revision, and essentially only provides a fallback to a mimetex binary if you have not installed a TeX distribution. There are lots of other options for Math display in Moodle, may of them much easier to configure and use!
===Procedure===
====Decoupling DragMath from the Tex Filter====
Since default configuration of tinymce (the default editor) requires that TeX filter is enabled before Dragmath plugin can be used we need to edit file lib/editor/tinymce/lib.php


'''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!
First, make a copy of that file to make sure that you can revert back to the original.  


'''DO NOT''' over write your adminlib.php. Install the rest of the files (other than adminlib.php) and DragMath will work without a problem.
Second, open the file for editing (with an appropriate editor that will not do unseen things to the contents of your file)
====Managing Your Editor Icons Through adminlib.php====
To be able to add 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:
Third, locate lines 107-111:
                    'insertsmile' => 'em.icon.smile.gif',


and save. The line can really be placed anywhere in that arraybut by providing a specific location it will help when addressing requests for assistance in hiding buttons. Andhaving taken the time to explore this beautiful little array, you can now alter your button images to your hearts content!
if (array_key_exists('filter/tex', $filters)) {
  $xdragmath = 'dragmath,';
  } else {
$xdragmath = '';
  }


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.
Fourth, replace all those lines with this one line:


You may ask, what about altering the adminlib.php file in the CVS or providing a patch? [http://tracker.moodle.org/browse/MDL-16280 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.
$xdragmath = 'dragmath,';


===Locally saving and restoring a DragMath expression===
removing the if statement that makes DragMath visible only if the TeX filter is turned on.
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.
Fifth, save the file.


[[Image:Dragmath_save_and_restore.png|DragMath instructions]]
Sixth, replace the original file lib/editor/tinymce/lib.php with this modified version.


A .drgm file contains three-dimensional representation of your mathematical expression.  It is a binary file that can only be opened by DragMath.
====Setting up another display mechanism====
===Troubleshooting===
Now DragMath will show up in your editor,  but you have no way of displaying the TeX or other code that you might insert with DragMath. You can explore the docs and the Math forum and you will find quite a few other ways to display Math in Moodle.  One very popular way is to use MathJax. Under Moodle 2.x the AdditionalHtml field can be used to add the reference to MathJax and even do some configuration.
====unzip====
To accomplish this, as an administrator of your site go to: Site administration -> Appearance -> Additional HTML -> Within HEAD
Some packages like winRAR provide a separate setting that prefixes the archives name on directories. In order for the files to be properly placed when the archive is unzipped you must make sure this is not the case. In winRAR for Windows for example you can go to Options->Settings and on the Compression tab you will see something to the effect of "Append archive name to path"; make sure this is not set!
Now, add


Also, please not that the non-cvs zip is created so that the files in various directories are placed correctlyIf, however, you set unzip or instruct unzip not to overwrite but to renamethen you will unpack the archived files into new directories (for example /lib(2) instead of /lib) and your install will not work.
  <link rel="stylesheet" type="text/css" href="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css" media="screen" />
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraphcore.js"></script>
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/GeonextReader.js"></script>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
  MathJax.Hub.Config({
    tex2jax: {
      inlineMath: [ ['$$','$$'], ["\\(","\\)"], ['@i','@i'] ],
      displayMath:[ ["\\[","\\["], ['@d','@d'] ],
      processEscapes: true
    }
  });
  </script>
Save changes.


====java jre====
Make sure that Tex filter and Algebra filter are disabled in Site administration > Plugins > Filters > Manage filters
Dragmath is java based, and unless you have a current java runtime environment you will likely run into trouble.  Make sure you keep your JRE current and that the current JRE is selected.


===Development===
Your moodle 2 is now using MathJax from a cloud server in cdn.mathjax.org with given delimiters (in this example double dollars and @i  for inlineMath and @d for displayMath). You can choose to use other delimiters in configuration if you want or swap hat are there, BUT you may not use delimiters Moodle employs for other purposes and you need to be very careful of the syntax. You do not need to have the same token for beginning and end (for example, one could use startmath and endmath as tokens. See http://mathjax.org for additional information on these and other parameters.
====Extending DragMath to Moodle 1.9.x Chat====
.
.
.
.
====Language Files====
The 0.7.8.1 package now includes language files (with Finnish, courtesy of Mauno Korpelainen) and the integration files should provide for automatic selection of the language based on the Moodle language setting.
====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.
====Math Chat====
Having been introduced by Marc Grober to a math chat application (http://www.imathas.com/cur/mathchat/testchat.html) it would be useful to see similar features in Moodle's chat, specifically:


1The ability to ''easily'' display mathematical symbols with DragMath incorporated into the chat window.
"Wait!", you say. "What about the first three lines I added to AdditionalHtml?" We thought you would never askThese lines add access to jsxgraph and GeoNextReader which you can find discussed in these forums and at the jsxgraph site, http://jsxgraph.uni-bayreuth.de/wp/ Consider this temporary, as you shoulod update the jsxgraph reference to use its cloud source. See a discussion here: http://jsxgraph.uni-bayreuth.de/wp/download/


2. The ability to create and display mathematical graphs.
==See Also==
* [[Advanced Maths Tools]] For an explanation of the SEE tools
* [[Using TeX Notation]] Some ideas and syntax
* [[TeX notation filter]] Turning TeX on
* [http://www.youtube.com/watch?v=mfc7umQ2xLA| A simple YouTube video] Constructing a simple equation.  


===Moodle 2===
*[http://www.youtube.com/watch?feature=endscreen&NR=1&v=8wfjwJTa784|  Dragmath tutorial 1] 
<s>As part of planning for Moodle 2 we have recommended that DragMath be placed in /lib/editor/common/dragmath alongside asciimathml (which is located in /lib/editor/common/asciimath). This should not result in any other major changes and those wanting to stay abreast may either want to look moving files before Moodle 2 or may want to keep an eye out for a zip of asciimath and dragmath packaged as a precursor to Moodle 2.</s>
*[http://www.youtube.com/watch?v=XIuMNrvsVN8|  Dragmath tutorial 2] 
*[http://www.youtube.com/watch?v=g98o0fpmosQ&feature=relmfu|  Dragmath tutorial 3] 
*[http://www.youtube.com/watch?v=88KN2Y-pJw0&feature=relmfu|  Dragmath tutorial 4] 




Line 133: Line 179:


[[ca:DragMath_editor_d%27equacions]]
[[ca:DragMath_editor_d%27equacions]]
[[es:Editor de ecuación DragMath]]
[[fr:Dragmath]]

Latest revision as of 15:12, 10 August 2021

WARNING: To use DragMath, you need to activate the TeX filter in Moodle. End users will also need to have a recent Java Runtime Environment installed. DragMath is no longer available in the new Atto editor introduced in Moodle 2.7. DragMath was available in the TinyMCE editor in Moodle 2.7, it is not distributed in Moodle 2.8 and later. It is available elsewhere as a third-party plugin which may be downloaded and installed by an administrator.

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.

John Isner initially created and maintained several files that allowed for integration of DragMath with HTMLArea, Moodle's editor in 2007. DragMath was then maintained by Marc Grober until it was integrated into core Moodle with the release of Moodle 2.0. An outgrowth of the development to integrate DragMath into tinyMCE has been the development of SEE by Mauno Korpelainen (a link to those plugins can be found below.)

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 which also discusses the various configuration options, some of which are mentioned briefly below.

Using DragMath

DragMath is based on the simple idea that the User who does not know a lot of TeX (pronounced Tech) can still create mathematical formula for publishing. In this case, Moodle is the dispaly agent so the TeX formulae are then rendered to a Moodle screen. This essentially means that with little experience, any Junior High Maths teacher can generate all the formulae they need for most aspects of Maths in Moodle.

Creating simple expressions

To begin, click on the DragMath insertion button. This opens The DragMath interface.

Opening Dragmath

The toolbar is different than you may expect, we are used to nice neat rows of buttons, but Dragmath has to use tabs. Each tab is tab is a collection of "templates", that is each symbol is a "template" and can be dragged and dropped onto the work space.

The DragMath Interface

To end editing and insert the script into the Moodle page, click the Insert button. This simple, but not simplistic, interface is a strength of DragMath. It make it easy for even novices to create complex formulae.


A sequence for DragMath - click an image to enlarge
Select the Tab with the symbols required
Click, hold then drag'n'drop a symbol
Enter the values, select an operation symbol
Select another symbol and drag'n'drop
Add an equal (or other) sign
Add in a variable, (chi in this case)
Click Insert
See the encoded result in the editing dialog.

This same sequence of operations apply equally for all formulae, all insertions, no matter how complex they become.

You can insert a template from the toolbar by drag and drop or by a click on the template in the tab, then clicking in the workspace.

Creating more complex expressions

More complex expressions are pretty much more of the same as above. Creating a simple multiplication table matrix, for example, seems complex,but in DragNath, it is actually simple:

A sequence for a simple Multiplication Matrice in DragMath - click an image to enlarge
Select the Tab and add in the multiplier
Click, hold then drag'n'drop the Matrix symbol
Enter the values, select a equal symbol
Add in the rows required
Add in the columns required
Edit the Matrice
Add the equal symbol
Add and edit in the second Matrice.

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.

Additional Editing

There are times when DragMath is not going to have a symbol or something you might want. Or perhaps you left something out of the DragMath constuctor, so you want to include it manually. Most likely, for something like the matrix created earlier, I want to go to 15, which means I have to change the structure of the matrix, and edit in some numbers. This is easily done with a little forethought. Copy and paste and delete or edit what you want and do not want.

Manually editing a DragMath construction - click an image to enlarge
Select, copy and paste the original matrix
Edit to what is actually required
Delete the original matrix

Sometimes however, you just want to include something you forgot, or rather, add something that was not there in the first place.

Accurately editing a DragMath construction manually - click an image to enlarge
Construct the original equation
Copy, then edit to what is actually required
Return to the edited page

What DragMath Does and How It Does It

Configuration files

DragMath allows you to create your own configuration files. That means it can be used to parse and display what you tell it to parse and display. By way of example, DragMath comes with a number of configuration files, one of which has been specifically designed to place doubledollar tokens before and after inserted text. We have seen a number of people change the TeX tokens in Modle using MathJax, and then become nonplussed that DragMath stops working. No DragMath still works, but it is likely inserting tokens that MathJax is not parsing. This can get confusing if you have more than one display technology in place. DragMath allows you to alter the tokens it inserts, so you can quite easily, for example, have DragMath insert startmath or endmath if that is what you want to use for tokens.

Language Files

DragMath can also use quite a few languages.

So! You want to use DragMath but don't want to use the TeX filter?

What?

Yes. Moodle devs decided that you should not use DragMath unless you used the Moodle TeX filter (yes, over objections from lots of folk.) Does that mean that the TeX filter is the best way to go? Hardly. The TeX filter is rather long in the tooth, desperately in need of revision, and essentially only provides a fallback to a mimetex binary if you have not installed a TeX distribution. There are lots of other options for Math display in Moodle, may of them much easier to configure and use!

Procedure

Decoupling DragMath from the Tex Filter

Since default configuration of tinymce (the default editor) requires that TeX filter is enabled before Dragmath plugin can be used we need to edit file lib/editor/tinymce/lib.php

First, make a copy of that file to make sure that you can revert back to the original.

Second, open the file for editing (with an appropriate editor that will not do unseen things to the contents of your file)

Third, locate lines 107-111:

if (array_key_exists('filter/tex', $filters)) {
$xdragmath = 'dragmath,';
} else {
$xdragmath = ;
}

Fourth, replace all those lines with this one line:

$xdragmath = 'dragmath,';

removing the if statement that makes DragMath visible only if the TeX filter is turned on.

Fifth, save the file.

Sixth, replace the original file lib/editor/tinymce/lib.php with this modified version.

Setting up another display mechanism

Now DragMath will show up in your editor, but you have no way of displaying the TeX or other code that you might insert with DragMath. You can explore the docs and the Math forum and you will find quite a few other ways to display Math in Moodle. One very popular way is to use MathJax. Under Moodle 2.x the AdditionalHtml field can be used to add the reference to MathJax and even do some configuration. To accomplish this, as an administrator of your site go to: Site administration -> Appearance -> Additional HTML -> Within HEAD Now, add

<link rel="stylesheet" type="text/css" href="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraph.css" media="screen" />
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/jsxgraphcore.js"></script>
<script type="text/javascript" src="http://jsxgraph.uni-bayreuth.de/distrib/GeonextReader.js"></script>
<script type="text/javascript" src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
MathJax.Hub.Config({
   tex2jax: {
     inlineMath: [ ['$$','$$'], ["\\(","\\)"], ['@i','@i'] ], 
     displayMath:[ ["\\[","\\["], ['@d','@d'] ],
     processEscapes: true
   }
 });
</script>

Save changes.

Make sure that Tex filter and Algebra filter are disabled in Site administration > Plugins > Filters > Manage filters

Your moodle 2 is now using MathJax from a cloud server in cdn.mathjax.org with given delimiters (in this example double dollars and @i for inlineMath and @d for displayMath). You can choose to use other delimiters in configuration if you want or swap hat are there, BUT you may not use delimiters Moodle employs for other purposes and you need to be very careful of the syntax. You do not need to have the same token for beginning and end (for example, one could use startmath and endmath as tokens. See http://mathjax.org for additional information on these and other parameters.

"Wait!", you say. "What about the first three lines I added to AdditionalHtml?" We thought you would never ask. These lines add access to jsxgraph and GeoNextReader which you can find discussed in these forums and at the jsxgraph site, http://jsxgraph.uni-bayreuth.de/wp/ Consider this temporary, as you shoulod update the jsxgraph reference to use its cloud source. See a discussion here: http://jsxgraph.uni-bayreuth.de/wp/download/

See Also


Discussion of the transition of DragMath to Moodle core: http://moodle.org/mod/forum/discuss.php?d=125977&parent=551794