ChemicalReaction1
This problem has been replaced with a newer version of this problem
Chemical Reactions
This PG code shows how ask questions about chemical reactions.
- PGML location in OPL: FortLewis/Authoring/Templates/Misc/ChemicalReaction1_PGML.pg
PG problem file | Explanation |
---|---|
Problem tagging: |
|
DOCUMENT(); loadMacros( "PGstandard.pl", "PGunion.pl", "MathObjects.pl", "PGML.pl", "contextReaction.pl", "PGcourse.pl", ); TEXT(beginproblem()); # uncomment $showPartialCorrectAnswers = 1; |
Initialization:
Load |
Context("Reaction"); @reactants = (); @products = (); $reactants[0] = Formula("2C_2H_6 + 7O_2"); $products[0] = Formula("4CO_2 + 6H_2O"); $reactants[1] = Formula("6CO_2 + 6O_2"); $products[1] = Formula("C_6 H_12 O_6 + 6 O_2"); $reactants[2] = Formula("3 Ca Cl_2 + 2 Na_3 PO_4"); $products[2] = Formula("Ca_3 (PO_4)_2 + 6 Na Cl"); # variations on 2NaOH + MgCl_2 --> 2NaCl + Mg(OH)_2 $a = list_random('Li','Na','K'); $b = list_random('F','Cl','Br'); # Use ${b}_2 instead of $b_2 below so that Perl knows the # variable name is $b = ${b} and not $b_2 = ${b_2}. $reactants[3] = Formula("2 $a OH + Mg ${b}_2"); $products[3] = Formula("2 $a $b + Mg (OH)_2"); $num_choices = $#reactants; $i = random(0,$num_choices,1); |
Setup:
We create a couple of arrays |
BEGIN_PGML [` [$reactants[ $i ]] \longrightarrow `] [_____________________________]{$products[ $i ]} Enter a subscript using an underscore, such as [| H_2 O |]* for [` \mathrm{H_2 O} `]. END_PGML COMMENT('MathObject version. Uses PGML.'); ENDDOCUMENT(); |
Main Text:
Note that we uses spaces around |