Skip to content
Classroom

Chemistry

Answer types: chemeqn and molecule

The student enters a chemical equation or a molecular structure. Both are handled by the newer assessment engine rather than the legacy display path.

The minimum

Common Control, for a balanced equation:

$answer = "2H_2 + O_2 -> 2H_2O"
$answerformat = "reaction"

Without $answerformat = "reaction" the box asks for a single chemical formula and grades by exact text match (spaces removed, case sensitive), so O_2 + 2H_2 -> 2H_2O would be marked wrong.

The type name is chemeqn, and there is no [chemequation] tag

Earlier versions of this page showed a bracketed [chemequation] section — and an earlier commit "corrected" the tag from something else to [chemequation], replacing one invention with another. There are no bracketed sections. The type name in the editor is chemeqn.

Options

chemeqn reads a deliberately small set:

Variable Effect
$answer the correct equation — required
$answerformat "reaction" grades the entry as an equation: species in any order on each side, coefficients must match $answer exactly. Anything else, including unset, expects one formula and compares it to $answer as exact text (spaces ignored, case sensitive)
$requiretimes symbol-count rules the entry must meet, as symbol,condition pairs — e.g. "+,=1" requires exactly one +; an entry that breaks a rule scores 0

molecule is graded on $answer alone: a SMILES string (optionally SMILES~~~CML), compared as exact text, so give other spellings of the same molecule as alternatives separated by or ("CCO or OCC"). Neither type uses tolerances or precision. The chemeqn entry box does honour $answerboxsize, $ansprompt and $readerlabel, and the molecule box passes $displayformat to its drawing widget.

Example

Common Control — setup:

$fuels = array("hydrogen", "methane", "carbon monoxide")
$eqns = array("2H_2 + O_2 -> 2H_2O", "CH_4 + 2O_2 -> CO_2 + 2H_2O", "2CO + O_2 -> 2CO_2")
$i = rand(0, 2)
$fuel = $fuels[$i]
$eqn = $eqns[$i]

Question Text:

<p>Write the balanced equation for the complete combustion of $fuel.</p>

Common Control, continued — answer and options:

$answer = $eqn
$answerformat = "reaction"

With "reaction", species may be listed in any order on each side, but the coefficients must match $answer exactly: 4H_2 + 2O_2 -> 4H_2O is marked wrong.

See Also