asking for comments about changes to the Java Molecular Editor question type (JME)

asking for comments about changes to the Java Molecular Editor question type (JME)

by Jean-Michel Védrine -
Number of replies: 27

Hello,

I am about to make some changes to the Java Molecular editor question type (qtype_jme) created by Dan Stowell.

The most important one is that I want to switch from using the JME java applet (see http://www.molinspiration.com/jme/ ) that was used form the creation of this question type back in 2006 to draw molecules to the new JSME (see http://peter-ertl.com/jsme/ ) javascript applet created by Peter Ertl (Peter was also JME's author) and Bruno Bienfait.

The benefits of this change would be

  • switching from java to javascript seems to be a good thing (now a lot of institution block java applets for security reasons and it become rather complicated to approve java applets is some browsers like firefox)
  • Contrary to JME which is free for non commercial use but not open source, JSME is open source
  • the question type would be usable on tablets and smartphones (IMHO that benefit alone is HUGE !)

I see no drawback but maybe there are some, so if you don't agree with this change speak now !

The second change is that I want to add a field into each jme question, this field would store the applet options (like xbutton, hydrogens, autoez, nostereo, ...) so that the teacher is able to change thiese options on a question by question basis.

Here is a screenshot of how it will look:

jsme

When the question is created, field (1) would default to the options defined at the site level for the jme question type (this setting already exists in the latest versions of the jme question type)

When the teacher change the value of field (1) and press button (2) the editor (3) is updated with the new options so that the teacher can preview what the student will see during question attempt.

As you see in the above screenshot the JSME editor looks quite like the old JME editor and support the same functions (there is also an option "oldLook" so it have exactly the same look as the old JME editor).

My current intention is not to change the qtype_jme plugin name or the tables names (this will not be a "qtype jsme" new question type) because I think it will be easier (upgrade will be transparent for actual users of the jme question type). Of course I will remove reference to java everywhere.

So please, JME users, I am awaiting your comments.

PS, In fact I started development this morning and the question creation:edition code and the upgrade code is already written and working, but I must admit I still have some problems with the question renderer used during attempt !

So better to ask for comments before it is too late big grin

Average of ratings: -
In reply to Jean-Michel Védrine

Re: asking for comments about changes to the Java Molecular Editor question type (JME)

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Good idea. We should probably do the same in out pmatchjme question type too.

I suppose only only issue would be browser support, but if jsme does not currenly work in all common browsers, then it will in time.

In reply to Jean-Michel Védrine

Re: asking for comments about changes to the Java Molecular Editor question type (JME)

by Joshua Bragg -

The Jmol filter underwent a similar change recently to JSmol. Somehow it worked in a fallback to the Java version if the Javascript version didn't work.

I'm not a JME user but as a chemist your second option sounds like an excellent idea also.

In reply to Joshua Bragg

Re: asking for comments about changes to the Java Molecular Editor question type (JME)

by Joshua Bragg -

My fault.  I don't believe my comment about the fallback was actually true.  Sorry about that...

In reply to Joshua Bragg

Re: asking for comments about changes to the Java Molecular Editor question type (JME)

by Jean-Michel Védrine -

Thanks Tim and Joshua for your comments.

I don't think there is a problem with browser support in JSME as the authors states in B. Bienfait and P. Ertl, JSME: a free molecule editor in JavaScript, J. Cheminformatics 5:24 (2013)

JSME has been tested with success on all major browsers (Internet Explorer, Firefox, Google Chrome, Safari and Opera). Close attention was given to support also the older versions of Internet Explorer (6 and 7) because several large industrial companies still use these legacy versions as their standard browser.

So I would say that JSME support more browsers than Moodle smile and of course the fact that JMSE support iphone, ipad, android, ... is a big advantage over JME java applet.

Speaking of the JMol filter, did you notice than Dan Stowell created both JMol filter and JME question type ? I contacted him yesterday to be able to add him as a contributor when JME will be in the Moodle plugins Directory and he was quite surprised to hear that JME qtype is still alive and very happy to know that it is still usefull to people smile.

Tim do you think Jamie would have some free time to help me to change the code in the renderer and in module.js ? This code is 99% identical to the one in pmatchjme so this work could be used if/when OU decide to switch to JSME in pmatchjme.

In reply to Jean-Michel Védrine

Re: asking for comments about changes to the Java Molecular Editor question type (JME)

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I might be able to help. I just had a look at the JSME code, I can't see any good docs for how to use it. There are API docs and example HTML pages, but not a tutorial.

JSME has clearly been built using Google's Java -> JavaScript cross compiler.

Trying the demo, I found myself wishing that most of the buttons had a tool-tip.

A google search finds https://github.com/geoffrowland/moodle-filter_jmol, which is using related but different code.

I would need to look more to make any progress. Perhaps later.

In reply to Tim Hunt

Re: asking for comments about changes to the Java Molecular Editor question type (JME)

by Jean-Michel Védrine -

Well to understand my problems you need to look at Jamie's code for pmatchjme

This first problem is to include the javascript library but I suppose that

$PAGE->requires->js('/question/type/jme/JSME/jsme/jsme.nocache.js'); would do the trick ? I hope it is only included once even if there are several question on the page ! Is there a better way ? Surely that kind of thing is done in other places in Moodle ?

Then we need to create a new JSApplet.JSME for the question passing it the id of the container (depending of the question), the dimensions and the options (this will have the same role as  the show_java function in pmatchjme code)

But another thing I don't see clearly is how to modify the bit https://github.com/moodleou/moodle-qtype_pmatchjme/blob/master/module.js#L29 that was setting the smiles, jme and mol values from the applet in the hidden imputs on submit because I don't see how to replace the find_java_applet function

 

 

In reply to Jean-Michel Védrine

Re: asking for comments about changes to the Java Molecular Editor question type (JME)

by Jean-Michel Védrine -

Well it begin to work smile, except it doesn't quite work sad

I pushed a work in progress branch to my github account so that you can look at my code (don't laugh at my javascript code, please smile)

the renderer most significant change is in the require_js function https://github.com/jmvedrine/moodle-qtype_jme/blob/WIP_JME_OPTIONS/renderer.php#L91 where I call  $PAGE->requires->js('/question/type/jme/JSME/jsme/jsme.nocache.js');

I also slightly changed the parameters passed to $PAGE->requires->js_init_call but this is because I don't need to pass the url of the jar file and I need to pass width and height of the editor.

of course the main changes are in the module.js file https://github.com/jmvedrine/moodle-qtype_jme/blob/WIP_JME_OPTIONS/module.js

Surely it is clear why it only works when there is a single jme question on the page because I have used JME1(both in find_java_applet and in show_java) and this should be something dependant of the question (in fact this is where the name variable should be used) but I don't know how to do this (again don't laugh !)

Can somebody help ?

 

In reply to Jean-Michel Védrine

Re: asking for comments about changes to the Java Molecular Editor question type (JME)

by Jean-Michel Védrine -

I pushed a new version that seems to work when there is more than one JME question on the same page.

Needs more testing and code cleaning.

In reply to Tim Hunt

Re: asking for comments about changes to the Java Molecular Editor question type (JME)

by Bruno Bienfait -
Nice to see that JSME is of interest in education. I am one of the two programmers of JSME. I will try to add tooltips to JSME next month after my vacations. I am not sure about adding a tutorial though. There is a simpler HTML page showing an implementation example. Problems, bug reports, critics and suggestions are welcome (but keep in mind that I am working on JSME during my free time). PS: JSME is free but not open source: the Java source code that was used to compiled it to JavaScript is not available.
In reply to Bruno Bienfait

Re: asking for comments about changes to the Java Molecular Editor question type (JME)

by Jean-Michel Védrine -

Hello Bruno,

I was not expecting one of the authors of JSME to follow threads on JME question type on this forum. This is very good.

Of course if you have time to look at the way I integrated it into Moodle question engine and suggest improvements, you are welcomed.

Thanks a lot for your comment about open source. As I need now to rework the documentation, what would you suggest to explain JSME status ? Surely it is less closed than JME java code wink.

This is important because when I will submit this new version to the Moodle Plugins directory, people at moodle.org will surely ask me about that (I was not allowed to include JME.jar because of the policy about non open source code, see the FAQ here )

In reply to Jean-Michel Védrine

Re: asking for comments about changes to the Java Molecular Editor question type (JME)

by Bruno Bienfait -

Hi Jean Michel,


there is a small problem in your JavaScript code: there is one comma to many at line #34 (your script won't work in IE). I have made the same mistake many times. Actually, it is my fault since one of the HTML examples of the JSME distribution package has the same mistake. Sorry.

Also, be sure that your insert_jme_applet function receives a width and height as a string (e.g. "480px") and not  an integer, otherwise the JSME editor will have a size of 0,0 .

Have a look at the license file inside the distribution package. Unlike JME, you are allowed to redistribute JSME within another package. There is only one constraint: the original license file must present. Hopefully, the moodle people will accept JSME.

 

Bruno

In reply to Bruno Bienfait

Re: asking for comments about changes to the Java Molecular Editor question type (JME)

by Jean-Michel Védrine -

Thanks a lot Bruno,

I will correct the comma problem.

I should verify my javascript code with jslint to catch problems.

Width and height are stored in the database as integers (easier to handle and validate) but I create strings before passing them to javascript here:

 

 

In reply to Bruno Bienfait

Re: Java Molecular Editor question type (JME)

by Ian Hunt -

First a thank you to you and Peter for the new JSME tool. I've looked at those website pages and couldn't see a place to provide feedback / comments, so given your Moodle post and the educational interest, I decided to post here. Hope that's OK!

From the educational perspective, the ability to remove certain buttons from the applet has always been important, i.e. noxbutton. I believe newer JME and it seems like JSME don't allow that. : (   The reason being that we want students to draw full structures and the "X" can be used as a way out (eg. CN groups) that would then need to be coded for.

More generally, I am aware of a couple of stereochemical bugs that seem to me to be inconsistent with what is posted.

1.  drawing structures such as 2-methylbut-2-ene generates two SMILES strings representing EZ isomers: C/C=C(C)\C and C/C=C(C)/C (just click the get SMILES twice).  The problem is that this structure does not have EZ isomers and therefore should generate CC=C(C)C only.

2. drawing structures such as 1,2-dimethylcyclopropane where the stereochemistry (wedge/hash bonds) is shown as part of the cyclic unit generates strings representing the RS nature but again two answers can be generated.  I appreciate and agree that such stuctures are ambiguous (and we do discourage students from using them).

The current documentation for JSME suggests that this should be recognized and reported as an error but it is not.

Hope you can help!

In reply to Ian Hunt

Re: Java Molecular Editor question type (JME)

by Bruno Bienfait -

Thank you for your comments and feedback about JSME. I haven't answered earlier because I was on vacation in July.

I have a new version of JSME for which the noxbutton option works. This new version has to be approved by Peter before it can be distributed.

I had a discussion with Peter about the stereochemical bugs. Fixing them would require a lot of work inside the unique smiles generation code. Thus this will not happen. Sorry. One alternative is to generate an InChI string, which is a unique identifier of a molecular structure that is better than the unique smiles.  InChI can be computed online using the chemical resolver : http://cactus.nci.nih.gov/chemical/structure

In the JSME distribution, there is an example file (JSME_chemical_resolver_demo.html) that shows how to access the chemical resolver . This example retrieves the name of the chemical structure. To retrieve the InChI instead of the chemical name, one needs to change the line 71 :

"representation" : "iupac_name"

 

into

 

"representation" : "stdinchi"

 

 

Please note that this example does NOT work with IE! It uses the jquery library for ajax call and I don't know how to make it work for IE (I am not a jquery expert).

Alternatively, one can perform the conversion on the server side for instance with PHP (no IE issues).

 

Bruno

 

 

In reply to Jean-Michel Védrine

Re: asking for comments about changes to the Java Molecular Editor question type (JME)

by Ian Hunt -

Just back from a trip and catching up on this thread as I am a big time JME user.

A new version that works on more devices is good news for sure. I also think that being able to define the options on a qu to qu basis is also a great idea (for example sometimes we want stereochem EZ or RS but not always).

As other ideas for taking this qu type forward:

1.  Be able to use the tool to load structures too as part of the question (rather than need to use images)

2. Be able to revisualise student answers rather than just displaying their SMILES string

In reply to Ian Hunt

Re: asking for comments about changes to the Java Molecular Editor question type (JME)

by Jean-Michel Védrine -

Hello Ian,

Thanks a lot for your input,

Now that jme question type is in the Moodle plugins Directory, I have asked Anthony Borrow to create a component in the CONTRIB project of the tracker. So once this is done it would be good to create issues for your suggestions so that they are not lost.

IMHO these 2 improvements are doable but they are not easy tasks

  1. This could be done with the combination of a TinyMCE editor plugin (similar to DragMath for equation) that would permit to use the JSME editor to create a molecule and then insert it as a JME string (not a SMILES string) in any HTML text (something like [JME]16 17 C 7.37 -8.99 C 7.37 -7.59 C 6.16 -6.89 C 4.95 -7.59 C 4.95 -8.99 C 6.16 -9.69 N 8.58 -6.89 C 8.58 -5.49 C 7.37 -4.79 O 6.16 -5.49 C 9.80 -7.59 O 9.80 -8.99 C 11.01 -6.89 Cl 12.22 -7.59 Cl 11.01 -5.49 C 9.80 -4.79 1 2 1 2 3 2 3 4 1 4 5 2 5 6 1 6 1 2 7 8 1 8 9 1 9 10 1 3 10 1 2 7 1 7 11 1 11 12 2 11 13 1 13 14 1 13 15 1 8 16 1[/JME] ) and a filter that would convert these strings to display molecules. This would permit to display molecules not only in question text but anywhere.
  2. But when the student or the teacher review an attempt the molecule is displayed, isn't it ? Where do you see it is missing ?
  3. What is missing is in fact that when the teacher creates the question, only the SMILES string of each answer is saved so later it is not possible to display for instance the right answer as a molecule but there is 2 different problems here: the first one is that in order to save the JME string for each answer the answer structure has to be modified and this is quite some work (it needs to be modified everywhere: in backups, in XML exports, ...) and the second one is that the question engine assume that the right answer is just a text string no more.
    But I see a workaround: if the editor plugin and the filter that I described in 1. do exist, it would be possible to include a molecule in the general feedback so that the teacher could explain to the student what the right answer is. Not perfect but better than just the SMILES string.
In reply to Jean-Michel Védrine

Re: asking for comments about changes to the Java Molecular Editor question type (JME)

by Ian Hunt -

Thanks Jean-Michel.

I think the critical "missing piece" right now is the ability to show the structure associated with the correct answer.  This is your point (3) and what I was referring to when asking about revisualising answers. My only concern with the solution suggested via the general feedback is the timing of that being shown to the students. I need to experiment with and think more about this or consider alternatives.

In reply to Jean-Michel Védrine

Re: asking for comments about changes to the Java Molecular Editor question type (JME)

by Bruno Bienfait -

FYI, JSME has a display only mode that can be used to show the expected molecular structure. The option name is "depict".

In reply to Bruno Bienfait

Re: asking for comments about changes to the Java Molecular Editor question type (JME)

by Bruno Bienfait -

There is a new version of JSME:  new  installation documentation. Migrating page containing JME to JSME  has been made much easier.

FYI: here is a web site that uses  JSME for teaching functional groups: http://www.ucd.ie/chem/chemint/funcgroups.htm

 

 

In reply to Bruno Bienfait

JSME

by Ian Hunt -

Over the next few months I need to tackle the JME to JSME and JMOL to JSMOL conversions.  I have questions in relation to this process. 

Are the new Moodle question types using these tools available at this point ? If not when is that likely to happen ?
How easy is the conversion of existing questions to the new question type ?
Does anyone have experience or suggestions for these changes ?

Thanks!

In reply to Ian Hunt

Re: JSME

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

We are probably going to convert qtype_pmatchjme to use jsme within the next three months.

In reply to Bruno Bienfait

Re: asking for comments about changes to the Java Molecular Editor question type (JME)

by Ian Hunt -

I've just been experimenting with the new JSME qu type from Jean-Michel. So far so good smile

In terms of the JSME drawing tool itself, from the teaching perspective, it would be good if the "FG" button could be turned on/off in the same way as the "X" or "stereo" can be turned on/off. Otherwise it will be possible for the student to use the FG option rather than dealing with learning to draw structures (e.g. nitro groups) themselves.

In reply to Ian Hunt

JavaScript Molecular Editor question type (JSME)

by Ian Hunt -


We switched to JSME for the start of the new academic year. In general, so far it's been working well in our computer labs.  I recently heard from a couple of students where drawings were not saving, as best as I can tell, the common link may have been that they were trying to use Google Chrome.

In reply to Jean-Michel Védrine

Re: asking for comments about changes to the Java Molecular Editor question type (JME)

by Ian Hunt -

Today I think I may have observed more examples of student drawings not saving / being submitted. The quiz has 50 min duration (many students done in 20-30 mins) but some are leaving the drawing until the last seconds and then when it auto submits before they navigate to any other page, the drawing is not being saved (I think). I did just add a short grace period to maybe help this, but not sure if that will help. 

Ideally, I think, the drawing should save if the quiz times out since I can't trust 100% of the students to make sure they don wait until the very end....

Any thoughts or comments ?  

In reply to Ian Hunt

Re: asking for comments about changes to the Java Molecular Editor question type (JME)

by Jean-Michel Védrine -

Hello Ian,

I don't think there is anything I can do at the question type level against that problem: jme save it's results like any other question type with one exception: there is some javascript to transfer the result of the jsme editor to an hidden text field that is then saved.

I yous search this forum you will see that the exact same problem has been reported for other question types even standard multichoice questions. Unfortunately the javascript timer on the client side may not be 100% synchronized with the server time.

You can look at Tim's suggestions to try to minimize this problem in his answers to these messages.

Here is what I can suggest

- put each question on a separate page

- as you say a grace period can help

- warn your student that it's bad to wait until the very end

In reply to Jean-Michel Védrine

Re: asking for comments about changes to the Java Molecular Editor question type (JME)

by Jean-Michel Védrine -

Hum, I should have looked more closely before answering.

The javascript used in jme is very similar to the one used in OU pmatchjme question type.

Colin Chambert has recently committed some changes to qtype_pmatchjme and the commit's comment is "Pattern match with JME not saving input' so I will do the same changes in qtype_jme and release a new version. Maybe that will solve your problems ?

In reply to Jean-Michel Védrine

Re: asking for comments about changes to the Java Molecular Editor question type (JME)

by Jean-Michel Védrine -

I just released version 2.1 in the Moodle plugin Directory.

I did exactly the same changes that Colin Chambers did for the pmatchjme question type so hopefully this will solve your problems (or more exactly your students problems !)

In any case, (even if you still see unsaved responses) please report your finding here.