Difference between revisions of "ChemicalReaction1"
Paultpearson (talk | contribs) m |
(add historical tag and give links to newer problems.) |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
+ | {{historical}} |
||
+ | |||
+ | <p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/Misc/ChemicalReaction.html a newer version of this problem]</p> |
||
+ | |||
<h2>Chemical Reactions</h2> |
<h2>Chemical Reactions</h2> |
||
Line 132: | Line 136: | ||
</p> |
</p> |
||
− | * [http://webwork.maa.org/pod/ |
+ | * [http://webwork.maa.org/pod/pg/macros/contextReaction.html POD documentation for contextReaction.pl] |
* [http://webwork.maa.org/moodle/mod/forum/discuss.php?d=449 WeBWorK forum discussion about chemical reactions] |
* [http://webwork.maa.org/moodle/mod/forum/discuss.php?d=449 WeBWorK forum discussion about chemical reactions] |
||
Latest revision as of 05:22, 18 July 2023
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 |