I prefer Jmol because it's open-source. It can view a large number of the standard chemical information languages such as MOL, PDB, XYZ, and so on.
In order to use it you need to add the Jmol applet to your Moodle server, by downloading it from http://jmol.sourceforge.net and copying the two files 'Jmol.js' and 'JmolApplet.jar' to the location ......../moodle/lib/jmol/
Once you've done that, just unzip the attached filter file into ........./moodle/filter/jmol/
I've tested it in forums, quizzes, etc. Seems to work without a hitch so far! The one caveat is that for security purposes, Jmol insists that the files should be on your own server, not referenced from elsewhere. So upload the files to your Moodle filestore and reference them from there...
http://ucl.ac.uk/is/fiso/lifesciences/test/jmol.zip
(File size is 536KB)
Great work. I had done a similar thing at my localhost and try to compare with marvin. However, I felt that, Marvin has more additional features and especially rxn files can be rendered directly that has direct implication in teaching organic chemistry. Additionally, having Marvin applets on the server, students can draw their own chemical drawing online for assignment submissions etc and students need not have structure drawing packages in every machine they handle,be at home or at internet cafe.
I haven't used Marvin, but I'm sure you're right that it has some extra features. (I don't know RXN - it's for displaying reactions?) I know that the Jmol applet isn't designed for editing files. The one big problem with Marvin is that it is not available under a licence that makes it possible to distribute it as a part of Moodle.
Using Jmol as a built-in viewer for molecular data files appeals to me as a built-in Moodle functionality, similar to the built-in TeX filter for maths equations.
For people who need the extra Marvin functionality, your Marvin filter plugin is great.
Best,
Dan
Is there a way to eliminate the stack overflow warning in IE6?
I'm using IE6 and Windows XP SP2.
There's one reference to this problem in the jmol users forum (http://sourceforge.net/mailarchive/forum.php?forum_id=2151&max_rows=25&style=nested&viewmonth=200411) but... no solution.
Updated Jmol filter which should only initialise itself once per page:
Download here
If you can confirm it fixes the problem for you too, Jean-Pierre, I'd be grateful.
I keep on seeing these stack overflow warnings (at line 727).
Deleting the second or even all the labels doesn't solve the problem any more: the warning keeps on popping up
Strange thing is the warning even pops up when I go to the home page...
In firefox 1.5 download of the jmolapplet stopped (at +/- 75 %) the first time I loaded it...
Hi Dan & Jean-Pierre
I'm also getting the same stack overflow warnings (at line 727) with IE6 SP2 and the new Jmol filter.
As Jean-Pierre has noted, this occurs even on the home page (where there should not be any links with .mol .pdb .rxn .csmol .cml or .xyz files).
On our server setup, we don't have a /moodle directory in our webserver root, (i.e. the /filter directory is in the webserver root) - so we needed a quick hack of the first declaration of $relurl to get things to work (in Opera & Firefox).
$relurl = "";
rather than $relurl = preg_replace('|https?://.*?/|', '', $CFG->wwwroot);
Not sure if (similar) problems with converting from absolute to relative addressing problems are related to the stack overflow problem.
Sorry my knowledge of PHP and regular expressions is not good enough to add much more...
Keep up the good work Dan, this Jmol filter has lots of potential. One final question. The 'generic' deployment of the Jmol applet, using the right-click dropdown menu to configure display options, is useful. However, is it also possible to add controls using Jmol.js JavaScript (either in the filter, or the link to the structure file) to manipulate the applet?
These problems are very odd. Are you sure you installed the updated version? (I updated the downloadable version just this morning to include the alteration that fixes it for me.) Sorry for the patronising question but it's necessary...
The problem with the overflow error appearing even on pages which don't employ the filter (!) makes me suspect that your IE might have been still suffering from an illness it incurred earlier on. Perhaps closing down Internet Explorer entirely and restarting it might resolve the issue?
If you continue to have problems, if you could allow me to look at an example page that would make it easier to trace the issue. Contact me behind-the-scenes if necessary...
I will have a look at the "relurl" issue - although I thought it should work fine even with moodle as the root, I didn't test that out.
Re the controls etc - no, it's not possible to add controls using Jmol.js commands - Moodle's security filter prevents users from adding the necessary Javascript commands into pages. I don't think controls should be added into the filter (since they aren't the same for each instance), but it might be worth thinking about creating a Jmol "resource"-type which allows for these more advanced features (including choosing the window size etc).
Yes you are right. Moodle security will not allow javascript on pages. Adding all controls to the filter is nearly impossible. However, you can include the jmol.js directly into javascript.php as I did it for marvin and enjoy all the features of jmol. However, I do not understand about the new jmol resource type.
Although I don't underestimate my own ability to be doing something daft, nor Internet Explorer's ability to get sick, I'm still getting the same symptoms (have these been sorted for Jean-Pierre?). I have rebooted, relaunched IE, cleared browser caches etc and have deleted/reinstalled your latest version a couple of times.
I still do need to set $relurl=''; to get things to work on our main server (with no /moodle directory), although it works out-of-the box on a test server (with a /moodle directory). Both servers are Moodle 1.5.3 on Fedora 4/XAMPP
Certainly, your latest filter seems to have solved the 'original' problem in that a page with links to mutliple .pdb files displays correctly and does not generate the overflow error in IE.
However, on some (but not all) pages of an existing Moodle installation, the filter seems to be launched 'spuriously' (i.e. when there are no linked molecular structure files) resulting in the overflow error . Still not sure of what exactly is causing this, although enabling the Course/Site Description block for a course seems to be (one of) the triggers of the problem. ......Yes this is odd!!!!!!
For the moment, and so as not to scare IE users too much, I have turned the filter off on our main server, but will continue to tinker and let you know if I encounter anything interesting.
If you could let me look at one of the pages which is spuriously triggering the problem, that would be a really big help, since I could look at the HTML source code.
I made a silly mistake about which I'm embarrassed. Let me find the correct emoticon...
Updated version: Download here
It should take care of both problems - it should work on a server where Moodle is the web root, and it should not add the JavaScript spuriously on pages where it's not needed.
Brilliant! Solved both problems for our server
If you want to vote for this to be incorporated into Moodle (or at least put on the downloads page) vote for it in the bugtracker
- Do you have a set of different model formats for more testing?
Here's a PDB file: http://www.rcsb.org/pdb/files/1A81.pdb
Just for the record, the systems I've tested it on so far are:
- Servers: Slackware Linux, Mac OSX, Windows XP with EasyPHP
- Windows browsers: Firefox, Internet Explorer, Mozilla
- Mac browsers: Safari, Firefox
Hi again
I have taken the liberty of increasing the size, and adding a few generic controls to the bottom of Dan's Jmol Applet by editing the filter.php file. The controls allow simple toggling between stick, ball-and-stick, and space-filling displays, and spinning of the molecule (which helps with the 3D visualisation). The coding is taken directly from the Jmol.js javascript library http://jmol.sourceforge.net/jslibrary/
I realise all these options (and many more!) are available from the Jmol menu (right-click on the applet, or left-click on the Jmol logo), but feel the controls are more straight-forward for the novice or occasional user and encourage interaction with the structure. This is more a proof of concept than a serious alternative to Dans minimalist filter, but I will be interested to receive users reactions.
You can see demonstrations of this at Molecular Structures. Just [Login as a guest] and be aware that the displays may take a while to load.
Here is the code:
Replace
$replace = '<script type="text/javascript">
to
$newtext = preg_replace($search, $replace, $text);
with
$replace = '<form><script type="text/javascript">
jmolApplet(350, "load \2");
jmolBr();
jmolHtml("atoms ");
jmolRadioGroup([
["spacefill off", "off"],
["spacefill 20%", "20%", "checked"],
["spacefill 100%", "100%"]
]);
jmolHtml(" ");
jmolCheckbox("spin on", "spin off", "spin");
</script> <a href="\2" title="Download the molecular data file">Download</a></form>';
$newtext = preg_replace($search, $replace, $text);
I also attach the modified filter.php file. Just replace (after backing up!) the original file in the /jmol folder of Dans filter.
I have not added any more generic controls as these very much depend on the educational context and type of structure.
The ability to customise an interface with particular controls is a real strength of Jmol (and Chime). Such controls help direct users to particular aspects of a molecular structure (e.g. display unit cell for a crystal structure, display secondary structures for biological macromolecule etc). As discussed elsewhere in this thread, the JavaScript security makes these controls tricky to implement directly in HTML in Moodle. Does anyone have any workarounds or other suggestions for this. ?
Finally, I have also added |pdb\.gz to the search regular expression so that compressed pdb.gz files can also be handled by the Jmol Filter. This is good for larger files such as the membrane structure in the link above.
NB: Your attached "filter.php" doesn't seem to be the right one. It includes the hack to get things working on moodle-as-root, but doesn't include the modifications you describe.
I've updated my copy of filter.php with the described changes, and it seems to work well. The updated package can be downloaded from here.
I'd like to hear from other interested parties if they are happy with the current display, with the specific controls addded by Geoffrey. I vote in favour of them...
Pleased you like the controls , and apologies for the wrong filter.php . Forgot I had edited a remote file and uploaded a local one. I guess that's what comes of moodling way past my bedtime .
The information has been edited from http://jmol.sourceforge.net/jscolors/ and http://wiki.jmol.org/MouseManual. There has been some talk on the Jmol discussion forums of adding such help directy to Jmol (e.g in the menu, under About Jmol) but, as far as I am aware, this has not yet happened.
I have attached the help file, jmol.html, and you can see it in action here. Just [Login as a guest] and select the '?' help icons above the Jmol applets.
Be aware that this is a prototype and not yet fully working as I intended (see below). On our Moodle setup, I have placed jmol.html in /lang/en/help/jmol/ and edited filter.php as follows (see Moodle Development Manual):
immediately after:
add:
helpbutton("jmol", "Click here for help with Jmol", "jmol");
}
The jmol.html file has been put together pretty quickly so may need some cleaning of the code - but I hope it is a useful start. Of course, different language versions will be needed.
Finally, and particularly if the help icon ends up at the bottom right of the applet, it may be worth replacing the text-based Download link with a suitable 'download' icon (I have not yet found one) so that the 'line' of controls uner the applet can be slightly less bulky.
Regards
Geoff
Hi Geoff,
I went to your test link.
It was great. I find the JMOL.html a great feature.
Trying to checkout the ? feature I was unable to find the same. Can you help me .
I believe that these features will add to the richness of the filter and functionality.
Regards
Garry
Garry,
My earlier posting about the parameter-passing (? feature) may not have been clear outside the context of the Size of Embedded Flash thread.
The demo site will only show the effects of parameter passing. ie:
- different sizes of Jmol applets embedded in the page
- Jmol applets can be displayed with or without the control buttons, download icon, and help icon underneath them.
To insert a Jmol-displayed structure in your own Moodle setup (after you have installed and activated the Jmol Filter).
- Upload a molecular structure file to the courses /files folder. Jmol can cope with a variety of formats although I usually use .mol or .pdb format. You can find links to a wide range of structure files at: http://molvis.sdsc.edu/visres/index.html
- Turn Editing on and create a hyperlink to the structure file (e.g. .../molecule.pdb) using the built-in editor (e.g. in a Label, HTML block etc). This should show the default Jmol filter display, a 350 pixel square applet with the controls etc underneath.
- If you wish to hide the controls, re-edit the hyperlink URL to add ?c=0 immediately after the filename e.g. .../molecule.pdb?c=0.
- If you wish to change the size of the applet, re-edit the hyperlink URL to add (for example) ?s=500 again immediately after the filename e.g. .../molecule.pdb?s=500 (for a 500 pixel square applet).
You can also combine the parameters in any order (thanks to Dan) e.g.
.../molecule.pdb?s=500c=0
Note that only a single 'size' parameter (e.g. s=500) is used, rather than 'height' and 'width', as in virtually all situations Jmol works best as a square applet.
Hope this answers your question!
Re: Jmol filter to view molecular structures-CALLING FUNCTION ERROR
Hi Geoff,
The filter is in the filter folder . It has been selected and activated.
Downloaded a file .....pdb and loaded it to the
"...\course\files folder The package was zipped and had a tar extension.
The file was loaded into the label resource as a link.
When I try to open the link I get the ERROR
" jmolInitialize({codebase}, {badBrowserURL}, {badJava URL})
must be called before any other Jmol.js functions ".
I am unable to figure out what is going wrong. Can you advise where I am going wrong??
Garry
Re: Jmol filter to view molecular structures-CALLING FUNCTION ERROR
Hi Geoffery,
I am unable to add links to the downloads of PDB files.
Can you help me as to how to go about it??
Thanks
Garry
Thanks for the update. I was testing the updated version in my localhost (to compare with my updated marvin filter). I found that I could not load the molecule in opera (v 8) browser (in windows) but could do it successfully in IE6. However, when I hyperlink a file outside the moodle uploaddata folder, applet loads the molecule in opera also. I have my uploaddata folder outside moodle folder. Is it anything to do with that? The following the html source:
==================================
<!-- END OF HEADER -->
<div id="content">
<table align="center" class="generalbox" border="0" cellpadding="20" cellspacing="0"><tr><td class="generalboxcontent"><script type="text/javascript" src="../../../course/filter/jmol/Jmol.js"></script><script type="text/javascript">
jmolInitialize("../../../course/filter/jmol/");
</script>1<script type="text/javascript">
jmolApplet(250, "load http://localhost/course/file.php/8/psilocybin.mol");
</script><a href="http://localhost/course/file.php/8/psilocybin.mol" title="Download the molecular data file">Download</a></td></tr></table><center><p><font size="1">Last modified: Wednesday, 11 January 2006, 07:54 AM</font></p></center><br>
<br>
===========================================
Here is a modified version of Dan's Jmol filter, now working as suggested in my earlier postings. It includes controls for 'stick', 'ball-and-stick', 'spacefill' display, 'spin', and icons/links for file download and Jmol help - all arranged along the bottom of the applet.
jmol_filter.zip [Login as a guest]
You can see it in action here [Login as a guest]
Please be aware that I am fairly new to PHP programming so the code may not be very elegant - but it seems to work for me.
As ever, I will be pleased to receive any feedbaqck.
I've had a browse through and the code is absolutely fine. I haven't made any changes but I've "tidied up" a little bit - removed a spurious HTML file, renamed "zip.gif" to "download.gif" (since that's what it is!), removed an unused variable declaration, and tidied up a tiny little bit of formatting. As always, my version is at http://ucl.ac.uk/is/fiso/lifesciences/test/jmol.zip
Dan,
A big thanks for doing the 'quality control'.
For info., and to give due credit, the zip.gif (now download.gif) was from
http://cdc.humboldt.edu/moodle/course/view.php?id=3
Also for info, and so that others don't get alarmed, I have occasionally still noticed Error Line 727 messages when editing/adding structure files in Internet Explorer - presumably because, in these particular circumstances, more than one instance of the Jmol code is invoked. If you close and relaunch IE everything then displays correctly (no errors). The best work-around is to use Firefox or similar .
If you simply link to a structure file e.g. molecule.pdb the applet displays with a default size of 350 pixels square and with the controls, download link, and help link discussed in earlier postings.
Alternative applet sizes can be used by adding for example ?s=500 to the link to give a 500 pixel square applet.
Similarly, if you do not wish to display the controls etc, add ?c=0 to the link to the structure file.
For example molecule.pdb?s=700c=0 would display a 700 pixel square applet without controls.
I have also added some minor edits to the jmol.html help file including adding a link to jmol.sourceforge.net.
The modified files can be downloaded from here: jmol_filter.zip -just login as a guest.
Also, you can see them in action here.
Hope this is useful.
This sounds like a great piece of kit, unfortunatly i cannot for the life of me get it to work, i install the filter as instructed and enable the filter in the admin screen but it doesnt seem to pick up the mol files that i link to. The mol files still have the question mark next to them and when you click on the resource to open them it just asks you to download the file. i am running on version 1.5.3
any ideas?
Cheers
Phil
One thing to check: are you linking to mol files within your Moodle server, or on some other server? Jmol refuses to load files on a "foreign" server, so only ones you've uploaded to the same server will work.
Do you have JavaScript enabled? It's needed in order to write the applet to the page.
I am linking to mol files on our moodle server itself. What i mean from the question mark is when you view your course files the mol files display as a unknown file type (see screen shot). i have javaScript enabled and is working fine.
Cheers for the help
Phil
If you copy the direct URL for octahedral.mol (for example) and then paste that into a discussion message as a link, you should get the Jmol viewer as a result. Does this work? If not, a screenshot of the forum post would help.
The easiest way to do what you want is to create a Label or a HTML page, containing a link to the file. That will be translated.
Once the Jmol filter is stable it will be nice to look at adding it as a resource type as well...
Ahh that explains it
thanks for your help
Phil
I've downloaded the modified filter and although it works fine, I'd like to improve the regular expressions so they're more efficient. (Running an array of four regexes means running four times slower! Since this filter will potentially process every single piece of text on the server, it's important not to waste any processor effort.)
I'll post a message when I've modified a little bit more.
1) I've reworked Geoffrey's parameter-passing trick into a single regular expression match (using a callback function to process the parameters). This should make it run faster (although you won't notice unless using it on a very large site), and slightly more flexibly in the way the parameters are matched (e.g. you can write both ?s=200&c=0 and ?c=0&s=200 ).
2) I've altered the matching so that it should ONLY match against URLs held on your own server. If you link to a PDB file on someone else's server, the Jmol applet will refuse to display it - so we may as well not even try!
I've tested this on our server and it all looks fine. Feedback gratefully received.
Download the filter
____________________________________________________
Thanks (again) for these performance enhancements , and for crediting me in the code. Everything works well on our server too.
The only cosmetic difference with my earlier version is that the controls no longer wrap for small applet sizes (this was achieved by wrapping 'everything' in a single table cell) - but I'm not entirely sure how useful this was anyway.
I have recently started building prototype resources with this filter and have found the flexibility allowed by 'parameter passing' to be very useful.
In some situations the controls are distracting and just get in the way (Yes, I know I introduced them!) - so it is good to have the option to turn them off.
Similarly, it can be useful to display applets with reduced size, e.g. allowing structures to be viewed side-by-side to facilitate comparisons.
I have also considered passing an additional parameter to allow the applet background colour to be changed. In general, the default black background gives a good contrast for fine structural details, particularly if Moodle pages are viewed via a projector. However a white (or light coloured) background often helps to embed a structure in a white or (light coloured) web page and typically prints out better. If there is the user demand for this feature, it should be easy to implement.
Finally, so that there are not too many different versions of the Jmol filter 'flying around', I have redirected the Jmol Filter download link on our demo site to your latest jmol.zip file on the UCL server. I hope this is OK
I must admit I didn't notice the table cell trick of wrapping things. But to be honest, using a table cell wouldn't be a good way of doing it - using <div style="width:250px"></div> (for example) would be a more modern way of doing it, and would avoid cluttering the page with unneccessary tables.
Hmmm...
I'd actually checked that this was not a problem with a few browser/OS combinations, and specifically chosen the 250 pixel size because it worked Clearly it is difficult to cope with all situations, different user-chosen text sizes etc.
As this is a property of the way html/javascript renders the controls and labels (i.e. without a non-breaking space between them), I'm not sure there is an easy way round this. Any suggestions?
Now, my question is can I script a button to have jmol display of proteins etc in cartoon mode?
You are right, the Jmol filter can be 'tweaked' to understand any file type that Jmol recognises.
In theory, it should be simple to add a Jmol.js command/control to display, for example, biological macromolecules in cartoon mode. However, it turns out to be rather difficult as Moodle's security filter prevents users from adding the necessary Javascript commands into pages. In fact, that's one of the reasons that the Jmol filter was developed!
We have resisted the temptation of adding too many 'default' controls to the Jmol filter as they would not be relevant for all types structures. e.g. cartoons of protein secondary structure are not an appropriate option for the display of inorganic crystal structures.
Possible workarounds are:
- To customise your local Jmol filter to include the cartoon control - however this would be applied to all Jmol filter-displayed structures in you Moodle installation
- Customise 'variants' of the Jmol filter to link to different file types. E.g .pdb files would be displayed by a 'Protein' Filter which displays appropriate controls such as the cartoon. Similarly .mol files could be displayed by a 'Small Molecule' Filter etc.. etc.. Personally I don't favour this as it seems rather too technical & messy.
- Use the parameter passing trick to allow a few (and I mean a few) different 'control sets'. For example one for biological macromolecules (e.g. with options to colour subunits, H-bonds, cartoons etc), one for small (organic) molecules (the current set of controls), and one for crystal structures (e.g. with options for the display of unit cells etc). I think there may be some mileage in this, and I'll try to find some time to investigate it further .
Of course, others may have additional ideas/insights to address this.
Alternatively...
See Dan's new, and very configurable, Jmol Resource
Firstly, I want to say fair play to you for coming with all the above code! It's really needed to encourage the use of moodle in chemistry teaching!
Is there any word on the jmol filters being incorporated into the next version of moodle...I'm working where it seems additions to the moodle code on the server is only aloud if it's in an official moodle update???
Hi Jmol folks
Just to let you know I have just updated Dan Stowell's Jmol Resource type to work with Moodle 1.8
See: http://moodle.org/mod/forum/discuss.php?d=70019#p314213
When I have time, I'll also get round to updating the Jmol Filter - though this already works with Moodle 1.8 and it is fairly straight-forward to replace the bundled Jmol components with the latest stable (or development) versions from: http://jmol.sourceforge.net/download/
I have a question...
I had an error on my course page:
Warning: str_repeat() [function.str-repeat]: Second argument has to be greater than or equal to 0. in /my/site/moodle/filter/jmol/filter.php on line 57
This error appears in both moodle/mod/resource/type/jmol/resource.class.php, and also the same error in moodle/filter/jmol/filter.php .
This is with Moodle 1.6 beta,.
Here is the code (it is the same in both files):
if(preg_match('|https?://.*?/|', $u)){
$relurl = preg_replace('|https?://.*?/|', '', $u);
}else{
$relurl = ''; // This will typically be the case if Moodle is the web root
}
$numdirs = substr_count($PHP_SELF, '/') - 1;
if($numdirs==0){
$relurl = './' . $relurl;
}else{
$relurl = str_repeat('../', $numdirs) . $relurl;
}
Any suggestions on how to get this working?
The variable $PHP_SELF is empty. I simply added this:
$PHP_SELF = $_SERVER['PHP_SELF'];
early in the function, before the variable was used.
It now works.
This variable is a global, but was not set for me.
This was in this particular function:
jmol_filter($courseid, $text) in moodle/filter/jmol/filter.php,
and also in function
display() in moodle/mod/resource/type/jmol/resource.class.php.
To get the filter and resource both working, I added the above line to both functions in both files.
Many thanks for pointing this out. The $PHP_SELF variable only appears if you have "register globals" turned on, which I hadn't realised - so I have updated the code so it uses $_SERVER['PHP_SELF'] instead.
(The downloadable version will update overnight.)
I was really pleased to put the new Jmol filter in my site... and my chemistry colleagues are happily inserting 3D structures in their courses... but they stumbled on a quirk when the Moodle document already has another href link before the link to the structure file on the same page.
In that circumstance, the filter remove all text from the first link till the end of the Jmol's file link.
As an example :
this test page has a link to Jmol's main site and one molecule to see here
As you can see in the attached image, all text "to Jmol's main site ....to see" is removed by the filter.
I suspect that the regular expression used in filter.php is a bit too greedy (?) (glouton as we say in french )
I have tried without success to put the two links in separate table cells or div or span...
Please find enclosed a french translation of the help file jmol.html, to be included in a lang/fr/help/jmol directory of the resource and the filter archives.
Hopes it does not smell too much garlic
Cheers
put in a lang/fr/ directory of the resource_jmol archive.
Cheers.
When downloading the zip file from modules database, I get a
version dated may 3 2006 (8567 mai 3 04:12 filter.php) instead of the
version dated may 2 2006 ( 8480 mai 2 14:45 filter.php) that looks like
an older version where the global $PHP_SELF has been removed but
nothing changed in the regular expression .
[root@cipcnet jmol]# diff -u filter.php /var/www/html/moodle/filter/jmol/
--- filter.php 2006-05-03 04:12:29.000000000 +0200
+++ /var/www/html/moodle/filter/jmol/filter.php 2006-05-02 14:45:10.000000000 +0200
@@ -19,7 +19,7 @@
/// courseid and the text to be filtered (in HTML form).
function jmol_filter($courseid, $text) {
- global $CFG, $jmol_applet_has_been_initialised;
+ global $CFG, $PHP_SELF, $jmol_applet_has_been_initialised;
// The global variable "$filter_jmol_has_initialized"
// is used by BOTH the Jmol filter and the Jmol resource type
@@ -41,7 +41,7 @@
]);
jmolHtml(" ");
jmolCheckbox("spin on", "spin off", "Spin");
- </script> <a href="\\2" title="Download the \\3 structure data file"><img align="absmiddle" height="17" width="17" src="'.$u.'/filter/jmol/download.gif" alt="Download" /></a> <a target="popup" href = "'.$u.'/help.php?module=jmol&file=jmol.html" onclick = "return openpopup(\'/help.php?module=jmol&file=jmol.html\', \'popup\', \'menubar=0,location=0,scrollbars,resizeable,width=550,height=550\', 0);" title="Help with Jmol"><img align="absmiddle" height="17" width="17" src="'.$u.'/pix/help.gif" alt="Help" /></a></form>';
+ </script> <a href="\\2" title="Download the structure data file"><img align="absmiddle" height="17" width="17" src="'.$u.'/filter/jmol/download.gif" /></a> <a target="popup" href = "'.$u.'/help.php?module=jmol&file=jmol.html" onclick = "return openpopup(\'/help.php?module=jmol&file=jmol.html\', \'popup\', \'menubar=0,location=0,scrollbars,resizeable,width=515,height=515\', 0);" title="Help with Jmol"><img align="absmiddle" height="17" width="17" src="'.$u.'/pix/help.gif" /></a></form>';
@@ -50,7 +50,7 @@
}else{
$relurl = ''; // This will typically be the case if Moodle is the web root
}
- $numdirs = substr_count($_SERVER['PHP_SELF'], '/') - 1;
+ $numdirs = substr_count($PHP_SELF, '/') - 1;
if($numdirs==0){
$relurl = './' . $relurl;
}else{
@@ -87,7 +87,7 @@
jmolCheckbox("set unitcell 4;color unitcell goldenrod", "set unitcell off", "Unit Cell");
jmolHtml(" ");
jmolCheckbox("spin on", "spin off", "Spin");
- </script> <a href="\'.$matches[2].\'" title="Download the .\'.$matches[3].\' structure data file"><img align="absmiddle" height="17" width="17" src="'.$u.'/filter/jmol/download.gif" /></a> <a target="popup" href = "'.$u.'/help.php?module=jmol&file=jmol.html" onclick = "return openpopup(\\\'/help.php?module=jmol&file=jmol.html\\\', \\\'popup\\\', \\\'menubar=0,location=0,scrollbars,resizeable,width=515,height=515\\\', 0);" title="Help with Jmol"><img align="absmiddle" height="17" width="17" src="'.$u.'/pix/help.gif" /></a></form>\';
+ </script> <a href="\'.$matches[2].\'" title="Download the structure datafile"><img align="absmiddle" height="17" width="17" src="'.$u.'/filter/jmol/download.gif" /></a> <a target="popup" href = "'.$u.'/help.php?module=jmol&file=jmol.html" onclick = "return openpopup(\\\'/help.php?module=jmol&file=jmol.html\\\', \\\'popup\\\', \\\'menubar=0,location=0,scrollbars,resizeable,width=515,height=515\\\', 0);" title="Help with Jmol"><img align="absmiddle" height="17" width="17" src="'.$u.'/pix/help.gif" /></a></form>\';
break;
case 3:
$controls =\'jmolBr();
@@ -101,7 +101,7 @@
]);
jmolHtml(" ");
jmolCheckbox("spin on", "spin off", "Spin");
- </script> <a href="\'.$matches[2].\'" title="Download the .\'.$matches[3].\' structure data file"><img align="absmiddle" height="17" width="17" src="'.$u.'/filter/jmol/download.gif" /></a> <a target="popup" href = "'.$u.'/help.php?module=jmol&file=jmol.html" onclick = "return openpopup(\\\'/help.php?module=jmol&file=jmol.html\\\', \\\'popup\\\', \\\'menubar=0,location=0,scrollbars,resizeable,width=515,height=515\\\', 0);" title="Help with Jmol"><img align="absmiddle" height="17" width="17" src="'.$u.'/pix/help.gif" /></a></form>\';
+ </script> <a href="\'.$matches[2].\'" title="Download the structure datafile"><img align="absmiddle" height="17" width="17" src="'.$u.'/filter/jmol/download.gif" /></a> <a target="popup" href = "'.$u.'/help.php?module=jmol&file=jmol.html" onclick = "return openpopup(\\\'/help.php?module=jmol&file=jmol.html\\\', \\\'popup\\\', \\\'menubar=0,location=0,scrollbars,resizeable,width=515,height=515\\\', 0);" title="Help with Jmol"><img align="absmiddle" height="17" width="17" src="'.$u.'/pix/help.gif" /></a></form>\';
break;
default:
$controls =\'jmolBr();
@@ -113,7 +113,7 @@
]);
jmolHtml(" ");
jmolCheckbox("spin on", "spin off", "Spin");
- </script> <a href="\'.$matches[2].\'" title="Download the .\'.$matches[3].\' structure data file"><img align="absmiddle" height="17" width="17" src="'.$u.'/filter/jmol/download.gif" /></a> <a target="popup" href = "'.$u.'/help.php?module=jmol&file=jmol.html" onclick = "return openpopup(\\\'/help.php?module=jmol&file=jmol.html\\\', \\\'popup\\\', \\\'menubar=0,location=0,scrollbars,resizeable,width=515,height=515\\\', 0);" title="Help with Jmol"><img align="absmiddle" height="17" width="17" src="'.$u.'/pix/help.gif" /></a></form>\';
+ </script> <a href="\'.$matches[2].\'" title="Download the structure datafile"><img align="absmiddle" height="17" width="17" src="'.$u.'/filter/jmol/download.gif" /></a> <a target="popup" href = "'.$u.'/help.php?module=jmol&file=jmol.html" onclick = "return openpopup(\\\'/help.php?module=jmol&file=jmol.html\\\', \\\'popup\\\', \\\'menubar=0,location=0,scrollbars,resizeable,width=515,height=515\\\', 0);" title="Help with Jmol"><img align="absmiddle" height="17" width="17" src="'.$u.'/pix/help.gif" /></a></form>\';
} // End of switch
if(sizeof($matches)>8){
//echo "Found Jmol script: $matches[8]";
And when browsing the CVS I see a version 1.6 dated 23th of march ?
Don't "browse the CVS" if you want up-to-date files, by the way - Sourceforge's anonymous CVS is currently not updating, so it's frozen in the past.
I have set up a small course to "tease" my chemistry colleagues
http://cipcnet.insa-lyon.fr/moodle/course/view.php?id=56
(guests are OK)
It is in French, but if you can read this language, you will find in " Mode d'emploi express" a quick how-to to use Jmol under Moodle, a bit more detailed that the wiki english page.
I think I should find some time to contribute to the Wiki (at least translate your (?) Jmol resource and Jmol filter pages to the french Wiki ... )
Thanks again .
I like "Quelques molécules d'eau pour vous rafraichir..."
It would be great if you put some french-language Jmol documentation into the MoodleDocs wiki - your "Mode d'emploi express" page looks like it could be suitable for the wiki (with a couple of the URLs removed) if you feel that's OK.
It's done. I translated the english pages and added some details that I found of interest when testing it. Give me some time to sync it with your english pages
See http://docs.moodle.org/fr/Ressource_Jmol
Cheers.
But (there is always a but) when I try it with quiz I can't have a quiz with the applet included. I try to put the applet by a link with the html editor as I do for the other modules. When I do that the applet is good but I can't answer the quiz !
am I wrong or isn't it possible to use jmol filter with quiz ?
I apologize for my bad english and thank you for the work on jmol filter
Do you mean that the answer box is missing? frozen? The "submit" button is missing?
What question type are you using? Perhaps there's a specific problem there.
I have tried with true/false question and with multiple choices question.
I use firfox under linux but I am going to try with IE under XP to see if it is différent.
to display the molécule I put a link using the html editor (is-it right ?).
Thank you
"merci" and have a nice day,
I've committed another change to the Jmol filter so that now there's a parameter you can use to turn the <form> tags on or off. Just add ?f=0 to the end of the URL to prevent the form tags appearing.
And while I'm thinking here, would there be a way for a student to CLOSE jmol in this case?
Russ
I think that Dan Stowell's Jmol Resource type offers most or all that you need. It provides much the same functionality as the Jmol filter, but with a more user-friendly configuration interface and, similar to other resource types, provides links to the Jmol displays (rather than displaying them directly).
An alternative 'trick', that you may find useful, is to use the Jmol filter with different structures as different Glossary entries. If appropriate, the Glossary can be set up to auto-link any reference to a particular structure in a Moodle Course, to its Jmol representation.
I'll post links to more examples of the use of Jmol with Moodle, many of which were presented at the recent Moodle Moot, in the near future (I just need to tidy few things up).
Geoff
Warning: main(/home/team/public_html/mod/resource/type/resourcejmol/resource.class.php): failed to open stream: No such file or directory in /home/team/public_html/mod/resource/mod.html on line 6
What do you suggest?
Russ
It would seem that not all the Jmol resource type components are installed in their correct folders on your hosted Moodle. The setup is a little fiddly - but well worth it . It has worked for me with both Moodle 1.5.3 and Moodle 1.6 with either PHP4 or PHP5
Instructions (from the readme.txt file included with the Jmol resource type) follow. I hope this helps.
TO INSTALL:
1. Copy the folder that comes with this download, from its location
mod/resource/type/jmol, to the exact same location in your Moodle web server.
2. Copy the language files from lang/en (and various subfolders) to the exact
parallel locations in your Moodle web server.
You should also add a new 'text string' to the existing Moodle language file,
lang/en/resource.php. This is the line to add:
$string['resourcetypejmol'] = 'Display a 3D molecule viewer';
3. OPTIONAL - Setting the Jmol icon - this is a little tricksy but looks good:
Firstly, copy the icon from pix/f/jmol.gif to the equivalent position on the
Moodle server. Secondly, modify mod/resource/lib.php and modify the function
resource_get_coursemodule_info($coursemodule) so that it sets the icon
correctly for "jmol" resource type. The following shows lines 376-387 AFTER
modification - note the extra "else if" clause we've added at the end:
if ($resource->type == 'file') {
$icon = mimeinfo("icon", $resource->reference);
if ($icon != 'unknown.gif') {
$info->icon ="f/$icon";
} else {
$info->icon ="f/web.gif";
}
} else if ($resource->type == 'directory') {
$info->icon ="f/folder.gif";
} else if ($resource->type == 'jmol') {
$info->icon ="f/jmol.gif";
}
The line numbers may not correspond exactly in your copy of the lib file.
Russ
Certainly, spinning the molecule is more resource intensive, although I have not made detailed comparisons with the standalone. That is why spinning is turned off by default.
A couple of things that *may* help are to reduce the size of the Jmol applet and also to turn off Perspective Depth - You can experiment with the latter using the Jmol menu (Right-click > Options > Perspective Depth) and, if useful, set it in a script.e.g. JMOLSCRIPT{ set perspectiveDepth OFF}.
Geoff
Russ - what did the admin do - I cannot get the resource to load properly - I get the message to check permissions?
any ideas?
I have followed all the instructions get a blank screen when I try to use the jmol filter.
Any Ideas?
http://moodle.aggs.school.nz/course/view.php?id=549
I can view the filter working on other sites, so it is not my browser thats at fault
the java consol gives this message
load: class JmolApplet not found.
java.lang.ClassNotFoundException: JmolApplet
I would reallylike to get this working as I want to move away from chime.
Any help would be appreciated
Kathy
I can confirm your problem, so it is something server-side.
At the risk of stating the obvious, check you have followed the instructions in the Jmol filter readme file, and you are linking to a bone fide stucture file (e.g. .pdb) that you have uploaded to the /files folder of the particular course. The link should just be a simple hyperlink. Using Moodle's HTML editor, I usually type in an appropriate word, select it, then use the Insert Web link button to browse to the uploaded structure file. For more complex scripting, I usually use the 'Toggle HTML Source' button to edit the raw code directly (or turn off the HTML editor in my profile).
Hmmm... I notice you are running Moodle 1.7. I'm still on 1.6 and have not yet tested the Jmol filter, or the Jmol resource type, on 1.7 - so you may have identified a problem with Moodle 1.7 compatibility. Perhaps other Moodle 1.7 users could confirm whether or not the Jmol filter works for them! I'll check this out myself, and if necessary try to fix things, as soon as I can - but probably won't be for a few weeks.
Once this is working, I'm sure you won't be disappointed with Jmol as a Chime alternative. Indeed, the soon-to-be-released Jmol 11 has even more capabilities (e.g. orbital display, extended crystal building from unit cells, etc).
If you continue to have problems, you could send me a separate email (not via these forums!) with teacher username/password details for a demo course, and I'll try to diagnose things on your server.
Can anyone point out other items to look at to determine what I'm missing?
thx
<script type="text/javascript" src="moodle/filter/jmol/Jmol.js"></script> I have verified that the Jmol.js is indeed in that location and that permission, owner, group, etc. are set appropriately. I'd appreciate any tips on looking further into possible causes. Thanks
FileManager.openFile(../../file.php/11/Structures/1a3n.pdb)
SmarterJmolAdapter:The Resolver thinks:null
error opening http://moodle.depauw.edu/file.php/11/Structures/1a3n.pdb
unrecognized file format
openFile(../../file.php/11/Structures/1a3n.pdb) 827 ms
I have confirmed that this is not a Jmol problem. If anyone could confirm this problem and offer suggestions for solutions I would appreciate it. I believe the problem is only in Firefox on Mac. Others have checked with other systems and browsers and also at other Moodle sites.
Type in about:plugins in the address bar of Firefox to see what version of java it is using. There's more information about the java plugin here:
http://javaplugin.sourceforge.net/
If you suspect your Java installation is old, you can check the java version here: http://waterontheweb.org/data/java/trouble.html
The current release of Java for OS X 10.4 is here:
http://www.apple.com/support/downloads/javaformacosx104release5.html
Jeff
I have just updated the Jmol applet to version 11 at the following two sites, if prompted just [Login as a guest]. Have not yet updated the Moodle Jmol Filter/Resource download code.
http://moodle.yeovil.ac.uk/course/view.php?id=63
http://moodle.yeovil.ac.uk/course/view.php?id=795
These work for me (though there is a lot on them, so they may be slow to load ) with Firefox 2.0.01 on Linux and Windows with Java 1.5/1.6. Haven't got access to Macs so can't test your problem directly. Will be grateful for your feedback whether things work for you.
If the problem is due to incompatibilities with the Moodle Jmol Filter/Resource code, it may by worth testing the Hexokinase link in the second URL as this has the Jmol 11 applet packaged rather differently as an IMS Content Package using Reload. Again, let me know if this displays correctly with your setup.
Indeed, if you have existing Jmol-based resources web pages with complex controls/scripting, you may even find it easier to bundle these up with Reload, then stick them on Moodle. They should even be portable to other VLEs (though of course you will stick with Moodle! )
Of course, the Jmol Filter and Resource offer a quick and convenient way to insert 3D chemical structures in a Moodle page. However, I have noticed that in certain circumstances, multiple instances of the Jmol applet, e.g in Glossaries, can be problematic.
It's our half-term, so I have a few days away from teaching to tinker with this and update some of the code and documentation.
Regards
Geoff
I tried both of your links. Both worked in Safari. Neither worked in Firefox. This includes the Hexokinase link you asked me to check. I've uploaded a screen shot from Firefox so you can see what it is doing.
I'm just getting started with Moodle and have some, but not a lot of experience with Jmol. It seems that doing Jmol in Moodle adds an additional layer of complexity. This is unfortunate since Jmol is complex enough as it is. I intende to do more with Jmol this semester than I have in the past, including having my students prepare presentations using Jmol for my Enzyme Mechanisms class. I see that there are several options for me to put Jmol content onto a site. Are there any options for students to put Jmol content onto the site?
Hmmm...
It is tricky trying to diagnose things without being able to test with the Mac/Firefox/Java combo. From your screenshot it appears the .xyz format is not being recognised, so I'm wondering whether it is an issue with the way Moodle serves up Chemical MIME types - and that Mac/Firefox/Java is particularly fastidious about this. I am assuming Jmol applets are working fine in 'non-Moodle' locations.
Had a (possibly) similar issue with SVG graphics files a while back. So I have naively tried the same solution by adding the following lines to function get_mimetypes_array()in /lib/filelib.php on our Moodle server (may also have to do something similar with the Jmol Filter/Resource code).
'pdb' => array ('type'=>'chemical/x-pdb', 'icon'=>'jmol.gif'),
'xyz' => array ('type'=>'chemical/x-xyz', 'icon'=>'jmol.gif'),
So take another peek at the links posted previously and see if that fixes things, at least for .xyz and .pdb files. If so, I'll add similar code for other Jmol file types.
If not, its back to the straw-clutching & head-scratching....
Geoff
Unfortunately, I see no change in the behavior of those pages now. Still scratching...
Not sure if this helps with the diagnosis, but very occasionally I'm getting the same error as in your screenshot with Opera and Firefox on Linux. Seems to occur when the system is 'overloaded' e.g. when I'm switching to/from edit mode in a Moodle course with Jmol content and possibly if I'm switching between different versions of the Jmol applet. Not definite about this as it is hard to reproduce (only seen it three times in total). In my case a browser refresh has fixed the problem. Presumably you have tried refreshing you browser, clearing your browser cache, restarting your browser, rebooting, having a cup of coffee... etc
Further straw-clutching: I have tweaked a few more things on our server, including the threshold of our DOS evasive module, so although I don't hold any great hope it may be worth revisiting.
Otherwise the applet-gurus in the Jmol user forums may be your best bet (though I see you have been there already)
...or just stick with Safari
1. We have downloaded the Jmol filter for the administration acc but how do you insert it in the class?
Maybe this was the reason why even after uploading a pdb file, it did not open up in Moodle.
Any suggestions?
Thanks,
Timila
I'm aiding 2 chemistry teachers in developing 2 fully online chemistry courses. We've all gotten really excited about Jmol and Jmol filter in Moodle. However I'm not a chemist so finding it really difficult to help them get further. So I hope you can all help me with these 2 questions:
1. Can anyone suggest good places to find PDB (or other compatible files)?
2. Is it possible to get students to build their own molecular structures, using Jmol or other, which they could share?
Thanks,
Joyce
Re: Jmol - suggestions on where to find PDB files?
A good place to start for .pdb and other chemical structure files (.mol, .xyz, .cif etc) are the 'MolViz' resources developed and compiled by Eric Martz and coworkers.
Molecules: Sources of PDB Files
The MolViz site has lots of other molecular display resources, tutorials etc that you can use directly, or use as inspiration for your own. Typically these were originally developed for the MDL Chime plugin, but most have now been updated to use the Jmol Applet.
A good Windows-based tool for drawing 2D structures of, say, simple organic molecules, performing a basic 3D structure optimisation and saving in a form that can be viewed in Jmol is ChemSketch. It has a Freeware version and there is a Free Campus Licence for Academic instututions.
There lots of other commercial and free (freeware and open-source) molecular modelling/display packages that may suit your particular purposes, though they tend to be designed for specialist research use.
The Moodle Jmol filter *should* work for forum or blog posting, which may be a way for students to 'publish' their own chemical structures. I suspect that the Jmol filter won't work with the Moodle Wiki oe NWiki, though haven't actually tested this.
There are also Jmol filters/extensions for Elgg and MediaWiki, both of which 'sit nicely alongside' Moodle.
I'll post again if I think of anything else. I'm also currently working on an update of the Moodle JMol Resource/Filter that I hope to release in a month or two.
Geoff
Re: Jmol - suggestions on where to find PDB files?
Molecule Databases
- PDB www.rcsb.org/pdb/ biological macromolecules (proteins, nucleic acids etc)
- CDS http://cds.dl.ac.uk/ inorganic, metallic, and small molecular structures
Tools
- Open Babel http://openbabel.sourceforge.net for inter-converting molecular data formats
I'm new to Moodle, but have used JMOL on webpages and in another older LMS for many years. The problem I have encountered is that the images don't show multiple bonds. My source is a pdb file that I editted to show the multiple bonds and this appoach has worked for me in the past. Why is the Moodle version different ? Do I need to use a different file type such as a mol file ?
Hi Ian
Recent versions of Jmol have many options for displaying bond orders, single, double, triple, partial, aromatic bonds etc. Older 'hacks' such as specifying multiple CONECT records in PDB files, should still work, though you may need to add an initial Jmol script to get the precise effect you want. The following may do the trick:
set showMultipleBonds ON
For more detail see:
http://wiki.jmol.org/index.php/Support_for_bond_orders
http://chemapps.stolaf.edu/jmol/docs/#setbondstyles
Hope that helps.
Adding the jmol script for set showMultipleBonds did not work (though I could make other scripts work). So far none of my "hacked" pdb files work in Moodle with JMOL 1.0.39 (mol files seem to work) and yet the same pdb files work outside of Moodle with JMOL 12.0.34
Hi Ian
I'll take a more detailed look at this over the next few days (start of teaching and all that)
You could just try replacing the bundled Jmol applet code with the equivalent files from the version that works for you. Do check the version from the Jmol menu (right click) as Java applet caching etc can sometimes play funny tricks.
I'll also check the plugin code itself for any hard-coded scripts that may block multiple bonds being displayed. Are you using the version for Moodle 1.9 or 2.x ?
I now believe that the multiple bond issue is a JMOL problem and not related to Moodle because:
1. when I try JMOL 12.0.39 on our webpages the multiple bonds fail to show
2. when I put the JMOL 12.0.34 applet code into Moodle, the multiple bonds show as I would like.