MarvinSketch Example - Student Examination

This example shows how MarvinSketch can be used in online examinations in different subjects.

This examination example tests the knowledge of students related to lone pairs and radical electrons.

Task: Use the two lowermost multifunctional buttons of the toolbar on the left to explicitely define the lone pairs and radical electrons on atoms.
After drawing the molecule, use the 'Submit Answer' button below the MarvinSketch window to generate its ChemAxon Extended SMILES format.

Note that the MarvinSketch applet was configured to better suit the task, for example the Lewis-structure representation is always visible.
For more details please see the Technical background part below.

Technical background

In this example the MarvinSketch applet is customized with the help of parameters. The following changes were made:

The code of the customized applet is as follows:

<script type="text/javascript" SRC="../../../../marvin.js"></script>
<script type="text/javascript">
<!--
msketch_name = "MSketch";
msketch_begin("../../../..", 490, 420);
msketch_param("menuconfig", "/examples/applets/sketch/studentexam/menuconfig.xml");
msketch_param("lonePairsAutoCalc", "false");
msketch_param("lonePairsVisible", "true");
msketch_param("sketchCarbonVisibility", "on");
msketch_param("implicitH", "off");
msketch_param("valenceErrorVisible", "false");
msketch_param("abbrevgroupsAllowed", "false");
msketch_param("shortcuts", "/examples/applets/sketch/studentexam/shortcuts.xml");
msketch_param("ttmpls0", "*Generic*/examples/applets/sketch/studentexam/generic.csmol");
msketch_param("ttmpls1", "*Rings*chemaxon/marvin/templates/rings.t");
msketch_param("templateToolbarCustomizable", "false");
msketch_end();
//-->
</script>

The menu configuration file: menuconfig.xml
The shortcut configuration file: shortcuts.xml
Custom "Generic" template group file: generic.csmol

The 'Submit Answer' button generates the ChemAxon Extended Smiles. The u option was used to generate unique smiles.

    <script type="text/javascript" SRC="../../../../marvin.js"></script>
    <script type="text/javascript">
        function exportMol(format) {
                if(document.MSketch != null) {
                        var s = document.MSketch.getMol(format);
                        document.MolForm.MolTxt.value = s;
                } else {
                        alert("Cannot import molecule:\n"+
                              "no JavaScript to Java communication"+
                              "in your browser.\n");
                }
        }
    </script>
    
    ... // creating HTML form
        <input TYPE=BUTTON VALUE="Submit Answer"
                  onClick="exportMol('cxsmiles:u')">
    ... // creating HTML form