DragMath

DragMath

by Christopher Sangwin -
Number of replies: 21
Picture of Particularly helpful Moodlers Picture of Plugin developers

I have been interested in mathematical assessment for some time as part of the STACK project (http://www.stack.bham.ac.uk).  (My current priority is to provide STACK as part of Moodle.  We are working on this over the summer and I will announce a release here in due course.  A demo will be available at the Moodle Moot in the UK in October.)

As part of this work, one thing I have noticed is a real need for a "drag and drop" equation editor to let students build up a mathematical expression in a traditional 2D way, and then output this as an expression in a correctly formed syntax.  This is not so easy: mathematical notation contains some ambiguities.  Still, we are stuck with traditional notation for the forseable future.  I have posted some comments on notation in this article.  I hope this gives some idea of where I am coming from on mathematical notation.

As a direct result of this I have been working with Alex Billingsley and he has impliemented the "DragMath" project

http://web.mat.bham.ac.uk/C.J.Sangwin/dragmath/

Given the discussion on this forum I think DragMath would be interesting to some people here, both for students and teacher who want to write LaTeX or MathML.

  • DragMath is a JavaApplet.
  • The DragMath project is licenced under the GPL
  • The output from DragMath is Maxima, Maple, MathML, or LaTeX.  The user can modify the .xml configuration files to adjust these formats without recompiling the applet.  A custom file for a new output format can be included as needed.

I hope the above link provides enough information and demos but questions and comments are very welcome indeed. 

Regards,
Chris

Average of ratings: -
In reply to Christopher Sangwin

Re: DragMath

by John Isner -
This is great! I have already started thinking about how to integrate the DragMath applet into various Moodle activities ... something along the lines of a popup resource that can be made available in many different contexts without too much work on the part of the course developer.

I played with the demo. It's an extremely minor issue, but I find construction of expressions less straightforward than with MathType. In DragMath, the blinking cursor (i.e., point of insertion) is always inside a box, never outside. Suppose you have constructed a complex expression A and you now want to make A the left operand of an infix operator like "+" in order to construct the larger expression A + B. In MathType, you would place the cursor following A and click the "+" button on the palette. In DragMath, you must select the entire expression A by dragging over it with the mouse, then click "+". As I said, it's an extremely minor issue. I'm sure users will get used to it quickly.

Would you prefer that I copy the archives from your site, or should I point my browser at your archives?
In reply to John Isner

Re: DragMath

by Christopher Sangwin -
Picture of Particularly helpful Moodlers Picture of Plugin developers

John,

Thank you for this comment. 

We designed the cursor so it would always be inside a box. Changing this would be difficult for us.  I agree that the interaction you describe would be easier to use and I will give this some thought.

My site will contain any updated versions.  Howver, if you would prefer you are very welcome to mirror the DragMath files on your site - this is an open source project so please do whatever would be best for you.

Chris

In reply to Christopher Sangwin

Re: DragMath

by John Isner -
Is there an applet parameter that would allow us to specify $$$ delimiters for LaTeX output? This would be extremely convenient for bridging to Moodle.
In reply to John Isner

Re: DragMath

by Christopher Sangwin -
Picture of Particularly helpful Moodlers Picture of Plugin developers

John,

Yes.

We designed DragMath to be as flexible as possible.  Please compare the two files Latex.xml and MathML.xml which can be found on http://web.mat.bham.ac.uk/C.J.Sangwin/dragmath/applet/classes/formats/

The lines

    <Initial>
        <output1></output1>
        <output2></output2>
    </Initial>

are currently empty in the Latex.xml file.  The text you want to preceed the expression is output1, and the text at the end is output 2.

You have two choices.

  1. Change the Latex.xml file in your distribution.
  2. Copy the Latex.xml file and modify it.  The modified version can be loaded automatically for all users with the JavaScript interface, or using the button on the applet (if you allow a user to do this).

I hope this makes sense?

I hope that the examples of MathML, Maple, Maxima and LaTeX between them provide most of the kinds of output syntax that we might invent.  

Chris 

In reply to Christopher Sangwin

Ang: Re: DragMath

by Morten Brydensholt -

Using the output as LaTex it should be possible to integrate this nice applet into a question type just like the 'Java Molecule Editor': http://moodle.org/mod/forum/discuss.php?d=42902

Best regards

Morten

In reply to Morten Brydensholt

Re: Ang: Re: DragMath

by John Isner -
Hi Morten,
I'm glad to see some interest in DragMath!

I'm working on DragMath integration now. It will not be a text filter like GeoGebra and Jmol because I want tighter integration with the html editor. I'll say no more now, but I hope to be able to post it to this forum in the very near future.
In reply to John Isner

Ang: Re: Ang: Re: DragMath

by Morten Brydensholt -

Hi John,

It's well worth waiting for. We have been missing this for many years now.

Is the source code available?

Best regards

Morten

In reply to Morten Brydensholt

Re: Ang: Re: Ang: Re: DragMath

by John Isner -
See this discussion. The code required for the integration is (or soon will be) posted there, along with instructions for how to use it.
In reply to John Isner

Some "unskilled user" issues with DragMath

by Cristina Berisso -

Hello everyone,

I would like to include the DragMath tool in one of my courses in order to allow the students to type answers and/or intermediate steps. I have not installed it yet since I do not want to have a problem while the semester is running, so I have just played with a Demo of the tool which was given in one of the discussion postings on this forum.
I have noticed that with that demo version I can not "erase" easily stuff that I have entered, and also that it is not very simple to "write" expressions that contain additions or subtractions of rational expressions. The "+" or "-" signs are placed in the wrong spot and then I have a hell of a time to delete them.

For example in the following screen capture, the "+" sign between the two expressions appeared in a funny position as well as the following rational expression. I tried to delete the plus sign with no luck. Many times I want to replace a "+" sign by a "-" or vice versa, and I can not do it. The roots or fraction formats I can not delete either, but numbers and variables yes.

DragMath screen capture

Also, some times DragMath does things I did not asked for (or at least that is what I think). For example the denominator (x-4) in the expression above is not exactly what I typed since I did not use parentheses. When I try to write the quadratic formula, I can never get the "-" that goes in the discriminator inside the root, as shown below. I believe also that I can not get the "+-" before the root either.

dragmath02.GIF

I wanted to ask the experts on DragMath if that is the case with the Moodle version also. Can you delete easily operations that get inserted in the wrong place by error? Could you please guide me on how to do it?

In reply to Cristina Berisso

Re: Some "unskilled user" issues with DragMath

by John Isner -
Hi Christina,
I'm sure the DragMath experts will have some suggestions. Meanwhile, I just wanted to say that the DragMath editor demo that you're playing with is identical to the one you would get in Moodle by following the installation instructions given here.
In reply to John Isner

Re: Some "unskilled user" issues with DragMath

by Cristina Berisso -

Hello John,

That is very important, thank you. I want to make sure about the level of difficulty that a student could encounter using DragMath to answer a question or assignment.

Cristina

In reply to Cristina Berisso

Re: Some "unskilled user" issues with DragMath

by Christopher Sangwin -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Dear Cristina,

Thank you for such helpful user feedback on DragMath.  I had noticed some of these things myself, and agree that many of these are far from perfect. 

In developing something like this the first 90% takes 10% of the effort and the last 10% takes 90% of the effort!  I shall talk with Alex and we will make a list of these bugs/feature requests on the sourceforge development site.

http://sourceforge.net/projects/dragmath/

We will then try to resolve them! 

Chris

 

In reply to Cristina Berisso

Re: Some "unskilled user" issues with DragMath

by Christopher Sangwin -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Dear Cristina,

I have been through your list more carefully.

(1) The problem of the + sign not being inline with the fraction bar was already reported as a bug.

(2) I have added a feature request: If you select an arithmetic operation and then click on another one, it replaces the selected one with the one you jusct clicked. This is not so easy since we have represented these as binary associative operators internally. What order of precedence would you expect if you replaced the first + in "x+y+z" with a "*"? or even a "-". There are so many problems with the unary minus!  We will work on this and try to create a sensible interface.  I agree the feature is needed. 

(3) If you type "x^2/(x-4)" this is parsed and the extra parentheses are retained as in your example. I'm not surprised this happens occasionally. Grouping is necessary and we have not fully polished the removal of "unnecessary" parentheses. The horizontal bar in the fraction plays two roles in notation: (i) arithmetic operation of division and (ii) grouping terms in the denominator and numerator. Sometimes you want explicit parentheses to highlight the grouping and so it is not obvious to me what to do. Since most of the time you don't want them, I have added a feature request to strip them out. This is now a feature request.

(4) Quadratic formula example.  You can type -b+sqrt(b^2-4*ac) to get the - inside the sqrt.  If you have sqrt(b^2) and want to add the - inside the sqrt, then first highlight the b^2 part only and press the - button.  The subtraction should appear under the sqrt.  If you highlight the sqrt as well then the + appears after.  Does this help?

We also do need to add a "+-" button to represent the quadratic formula.  This is now a feature request.  (it won't work in Maple or Maxima formats.)

(5) Deleting operations is quite difficult. Inside DragMath we store the expression as a tree. You can see this using the show tree outline option, which you need to switch on in JavaScript as this is designed for de-bugging not for mainstream users. It is on in the demonstration page on http://www.dragmath.bham.ac.uk/ If you delete just an operation then you will have dangling bits which we can't connect back to the tree. The feature request (2) above should allow you to change operations and still have everything connected. 

If you can think of some specific example interactions which DragMath doesn't do yet please let me know.

I hope this helps.
Thank you again for such a helpful list of user observations.

Chris

In reply to Christopher Sangwin

Re: Some "unskilled user" issues with DragMath

by Cristina Berisso -

Hi Christopher,

Thank you very much for your prompt reply! I tried your suggestion of highlighting the box for the "b" in order to enter the "-" sign, and finally go it to work. I am proudly attaching my master piece... (I have to confess though that it took me seven tries...blush)

dragmath03.gif

I did not type parentheses around "b" but they appeared after I inserted the root. One of the problems I found in my first attempts was that I was typing the "+" sign using the keyboard and then, trying to insert the square root immediately after it was very difficult. The root would appear in different places, even ahead of the full expression. Then I thought that for some reason the "+" sign was given in the palette, so I dragged it from there and slowly learned how to do it. I did not try your suggestion of using the "sqrt(..." since it is my intention to have it for the Intermediate Algebra students of my classes, and I would like them to just drag objects and fill boxes typing numbers to find out how they set up the quadratic formula from a given quadratic equation. I was just trying to learn how difficult was such task for them.

I have another question: When using the Demo version the only way I managed to clean the screen from my fail attempts was to "refresh" the web page and have the applet load again. Since some symbols can not be deleted when placed in incorrect places by the user, how does the "erasing and start over" work in the DragMath that is associated with a quiz question or assignment? Can the student get out of DragMath without saving the faulty expression and start over? I am clearly not very skilled at dragging objects and thought that some of my students may be as clumsy as I am and face the same situation. Sorry for a most likely very obvious question, but again, I have not installed DragMath yet in my course and have a hard time visualizing how it may work inside Moodle.

Thank you again for your help and for your patience!

Cristina

In reply to Cristina Berisso

Re: Some "unskilled user" issues with DragMath

by Christopher Sangwin -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Cristina,

Thank you for following these up.  I'm glad you got your quadratic formula in the end!

I agree that highlighting the b^2 under the sqrt is quite tricky.  We will look at polishing this, but these interactions are very difficult to fine tune.

If you typed "-b+" as a first attempt (this is my interpretation) then, since this is not well formed, the parser cannot start to build a tree and so does not provide an empty right hand box for the +.  Since there is no empty box after the + you can't drop the sqrt into it.....   I shall talk with Alex about whether we can de-tune the parser to look for possible empty box positions.  This is what the user expects to happen.

Dragging boxes into empty boxes is a "safe" thing to do in Dragmath since the result should always (internally at least) be a "well formed" tree.   But, people like to type things into boxes.  Imagine how frustrating it would be for a slightly more experienced user not to be able to type "x^2+1", but to have to drag everything around.   We added a simple parser since some things are much easier to type than drag. 

What should we do when a user types something which cannot be parsed?  We decided to leave this as text in the box and not to throw an error.  This is the source of some of your problems.  I think we might add a JavaScript option which "requires correct parsing of typed expressions".  Some applications will use this option, others will not.  Do you think this would be useful?

The unary minus is quite tricky to deal with correctly.  We have been conservative in placing "unecessary" parentheses when it is used.  This is visually unappealing, and we shall probably re-visit this and tidy it up. 

I am sorry you are having problems in deleting expressions.  If you highlight part of an expression you should be able to delete it.  This is not the case with the feature request which I made above about changing an operation - which we are working on.  If you highlight the whole of an expression and delete it you should get back to an empty applet.  Would you like us to add an explicit "clear expression" button?  This should be easy to do.

Chris

 

In reply to Christopher Sangwin

Re: Some "unskilled user" issues with DragMath

by Cristina Berisso -

Dear Christopher,

I think there is nothing tricky with the DragMath logic, but that I am just learning how it works. I simply have my brain (and hand) conditioned to work with Mathtype and my hand tries to repeat the well known patterns acquired over the years. I think that my students or anyone not brainwashed by MathType will find DragMath intuitive after playing with it with just a few expressions. I expect that even at my age I will become more skilled with a little practice and asking the experts when I get stuck.

Yes, I was typing "-b+" entirely with keyboard keys, and as you say I did not see a clear box when trying to move the root symbol. I tried the parser today (was not very aware of it before), and sure it makes my life simpler. But I doubt my Beginning and Intermediate Algebra students will get to use it since they are not very familiar with the symbols and conventions we use when we need to type math expressions with just a keyboard. The simplicity for them will be the ability to drag symbols and fill boxes with numbers and letters. They will enjoy it as a type of game of skills.

I find quite reasonable what you have right now regarding expressions that can not be parsed (to leave them just as text), but I am not very familiar with specific cases that you may have in mind.

The idea of a "clear expression" button is very appealing and will certainly solve the problem I was having. In fact I just read the posting from John and realized what I was doing wrong: I was highlighting the entire expression and using the "Delete" key on my keyboard instead of the "backspace" key. When using the "Delete" key, just the numbers and letters inside the boxes disappeared, but not the boxes, fraction structures, etc. (another MathType bad habit)

Thank you very much for your great work with this applet. It sure will make a difference for my students who will be able to create their math expressions instead of just selecting a radio button from a list of choices.

Cristina

In reply to Cristina Berisso

Re: Some "unskilled user" issues with DragMath

by John Isner -
Christina,
I can answer your question about cleaning up an expression if you get stuck. There are two ways to do it.

When you are using DragMath in Moodle, the DragMath editor appears in a small popup window launched by a button on the HTML editor toolbar. The window has two buttons at the bottom: Insert and Cancel. Press the cancel button and the popup disappears, leaving your HTML area unaffected. Press the Insert button and the LaTeX is inserted at the current cursor position. Pressing Cancel is a much more efficient way to clean than reloading the page, since it does not force the applet to reload.

The other way is actually the easiest way. Holding down the left mouse button, and sweeping from left to right, select the portion of the expression you wish to delete (see screenshot). Then hit the backspace key. DragMath will only allow you to delete subexpressions that leave the remaining expression valid.

Feature request: It would be nice if DragMath supported multi-level undo, rather than just one level. Java has classes that make it easy to implement.

Attachment dragmath_text_selection.png
In reply to John Isner

Re: Some "unskilled user" issues with DragMath

by Cristina Berisso -

Dear John,

Thank you for making this clear to me. I was highlighting the expression and using the "Delete" key to get rid of it without success. I tried the "backspace" key and everything selected does go away! I should have tried to think just a little bit outside the box...blush (embarrassment)

Cristina

In reply to Christopher Sangwin

Re: DragMath

by John Isner -
I found your article Linear syntax for communicating elementary mathematics extremely interesting. I recommend it to anyone interested in the language/notation that students use communicate mathematics, a subject that has been discussed extensively in this forum.

I used an early CAS in graduate school. I can't remember its name, but it definitely was RPN. When the first hand-held scientific calculators appeared, they were also RPN. Unix has had an RPN "desk calculator" dc(1) since the First Edition in 1971. What I remember about RPN was that everyone who used it swore by it, and when infix calculators hit the market, we marveled at how comparatively difficult they were (for us) to use. Having taught high school math in recent years, I can attest that most students don't understand how to use infix calculators because they can't remember the rules of operator precedence. They either use too many parentheses or too few. It would have been interesting if your study included an RPN CAA/CAS in the comparisons, but there probably aren't any of those dinosaurs around to study smile

For anyone reading this who isn't familiar with RPN (a.k.a. Reverse Polish Notation a.k.a. Postfix notation), the expression

x - (y + z)

would be written in RPN as

x y z + −