Display Chemical Structures in Questions with Marvin JS

For some questions, you might want your students to interpret drawings of chemical structures or reactions. You can display these using Marvin JS in the question, the answer (for question modes like multiple-choice), or the solution.

  1. If needed, open your question in the Question Editor.
    If Do this
    You know the question ID or name
    1. In the search box at the top of the page, select Question.
    2. Type the question name or ID and press Enter.
    You own the question
    1. Click Questions > My Questions.
    2. Click the question name.
    You organize your questions in folders
    1. Click Assignments > Folders and navigate to the folder with the question.
    2. Click the question name.
    You want to use advanced search
    1. Click Questions > Search Questions.
    2. Enter the search criteria you want to use.

      To view only your questions, click me next to Author.

    3. Click Search.
    4. If you own the question, click Edit next to your question.

      If you do not own the question, click View, then click Open in Editor under Previewer Tools.

  2. Create your drawing.
    1. Click Marvin under Page Tools.
    2. For Marvin Type, select the drawing mode to use.
      Important Always draw your chemical structure using the same mode you want to use in your question. See Marvin JS Drawing Modes.
    3. Draw the chemical structure or reaction.
    4. Click Get Key.
    5. In the text box, select and copy the entire Marvin JS XML.
  3. In Question, add the following code, replacing drawing_string with the XML you copied from the Marvin JS Key Generation tool:
    <eqn>
    $mysketch='drawing_string';
    ''
    </eqn> 

    This code assigns the Marvin JS XML to the variable $mysketch. You can use a different variable name if needed.

    Note
    • Always enclose the Marvin JS XML in single quotes ('), not double quotes (").
    • Do not paste Marvin JS XML directly in Answer. Instead, assign it to a variable and reference the variable as described in this topic.
    • Question, Answer, and Solution each have a 65,536 character limit. Any characters beyond that limit are not saved. Depending on the size and complexity of your Marvin JS XML, your question might exceed this limit without warning.
  4. In Question, Answer, or Solution, add the following code where you want the drawing to be displayed:
    <MARVIN type='mode' size='widthxheight'><EQN $mysketch></MARVIN>
    • mode is one of the following values and corresponds with the mode you used to create the drawing:
      complete
      condensed
      lewis
      mechanism
      mechanism_adv
      reaction
      reaction_adv
      resonance
      skeleton
      skeleton_adv
      spacefill
      3D
    • widthxheight is an optional string specifying the width and height of the drawing in pixels — for example, 400x300. The default size is 200x200 pixels.
    Note
    • Always use <EQN> — not <eqn> — inside the <MARVIN> tag.
    • Question, Answer, and Solution each have a 65,536 character limit. Any characters beyond that limit are not saved. Depending on the size and complexity of your Marvin JS XML, your question might exceed this limit without warning.

Example Displaying Marvin JS Drawing in Question

The following table summarizes an actual question.

QID

1534327

Name

Template2 5.MARVIN.04.

Mode

Multiple-Choice

Question

<eqn>
# -----------------------------------------------
#    Set $mysketch to the drawing string created 
#    with the MarvinSketch Key Generation tool
# -----------------------------------------------
$mysketch='<?xml version="1.0" encoding="UTF-8"?><cml version="ChemAxon file format v5.10.0, generated by v15.8.9"><MDocument><MChemicalStruct><molecule molID="m1"><atomArray><atom id="a1" elementType="C" x2="-2.0005" y2="-0.38499999999999934"/><atom id="a2" elementType="C" x2="-0.6665000000000001" y2="0.3850000000000007"/><atom id="a3" elementType="C" x2="0.6664999999999999" y2="-0.38499999999999934"/><atom id="a4" elementType="C" x2="0.6664999999999999" y2="-1.9249999999999996"/><atom id="a5" elementType="C" x2="-0.6665000000000001" y2="-2.6949999999999994"/><atom id="a6" elementType="C" x2="-2.0005" y2="-1.9249999999999996"/><atom id="a7" elementType="O" x2="2.0004999999999997" y2="0.3850000000000007"/><atom id="a8" elementType="C" x2="-0.6665000000000001" y2="1.9250000000000007"/><atom id="a9" elementType="O" x2="0.6664999999999999" y2="2.6950000000000003"/><atom id="a10" elementType="O" x2="-2.0005" y2="2.6950000000000003"/></atomArray><bondArray><bond atomRefs2="a1 a2" order="1"/><bond atomRefs2="a2 a3" order="2"/><bond atomRefs2="a3 a4" order="1"/><bond atomRefs2="a4 a5" order="2"/><bond atomRefs2="a5 a6" order="1"/><bond atomRefs2="a6 a1" order="2"/><bond atomRefs2="a3 a7" order="1"/><bond atomRefs2="a2 a8" order="1"/><bond atomRefs2="a8 a9" order="1"/><bond atomRefs2="a8 a10" order="2"/></bondArray></molecule></MChemicalStruct></MDocument></cml>';
''
</eqn>
Identify the molecule.
<table><tr><td width="250"><_></td>
<td><MARVIN type="skeleton"><EQN $mysketch></MARVIN></td></tr></table>

Answer

salicyclic acid
caffeine
ethanol
benzoic acid
hydrochloric acid

Display to Students

Question as displayed to students

Example Displaying a 3D Marvin JS Drawing

The following table summarizes an actual question.

QID

1534323

Name

Template2 5.MARVIN.05.

Mode

Multiple-Choice

Question

<eqn>
# -----------------------------------------------
#    Set $mysketch to the drawing string created 
#    with the MarvinSketch Key Generation tool
# -----------------------------------------------
$mysketch='<?xml version="1.0" encoding="UTF-8"?><cml version="ChemAxon file format v5.10.0, generated by v15.8.9"><MDocument><MChemicalStruct><molecule molID="m1"><atomArray><atom id="a1" elementType="N" x3="2.101" y3="-0.5405" z3="0.275"/><atom id="a2" elementType="C" x3="1.2930000000000001" y3="-0.1745000000000001" z3="-0.804"/><atom id="a3" elementType="C" x3="1.8470000000000002" y3="0.059499999999999886" z3="-2.078"/><atom id="a4" elementType="C" x3="0.9720000000000002" y3="0.4244999999999999" z3="-3.117"/><atom id="a5" elementType="N" x3="-0.35799999999999976" y3="0.5405" z3="-2.872"/><atom id="a6" elementType="C" x3="-0.8709999999999998" y3="0.3105" z3="-1.635"/><atom id="a7" elementType="O" x3="-2.101" y3="0.4255" z3="-1.44"/><atom id="a8" elementType="N" x3="-0.04599999999999982" y3="-0.043500000000000094" z3="-0.616"/></atomArray><bondArray><bond atomRefs2="a1 a2" order="1"/><bond atomRefs2="a2 a3" order="2"/><bond atomRefs2="a3 a4" order="1"/><bond atomRefs2="a4 a5" order="2"/><bond atomRefs2="a5 a6" order="1"/><bond atomRefs2="a6 a7" order="2"/><bond atomRefs2="a6 a8" order="1"/><bond atomRefs2="a2 a8" order="1"/></bondArray></molecule></MChemicalStruct></MDocument></cml>';
''
</eqn>
Identify the nucleobase.
<table><tr><td width="250"><_></td>
<td><MARVIN type="3D"><EQN $mysketch></MARVIN></td></tr></table>

Answer

cytosine
guanine
adenine
thymine

Display to Students

Question as displayed to students