DisableFunctions1: Difference between revisions
(Removes the AnswerFormatHelp macro and some other cleanup.) |
(Hide link to non-PGML file on GitHub.) |
||
Line 5: | Line 5: | ||
This PG code shows how to disable all functions and restrict student answers to fractions. | This PG code shows how to disable all functions and restrict student answers to fractions. | ||
</p> | </p> | ||
* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Trig/DisableFunctions1.pg FortLewis/Authoring/Templates/Trig/DisableFunctions1.pg] | <!--* File location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Trig/DisableFunctions1.pg FortLewis/Authoring/Templates/Trig/DisableFunctions1.pg] --> | ||
* PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Trig/DisableFunctions1_PGML.pg FortLewis/Authoring/Templates/Trig/DisableFunctions1_PGML.pg] | * PGML location in OPL: [https://github.com/openwebwork/webwork-open-problem-library/blob/master/OpenProblemLibrary/FortLewis/Authoring/Templates/Trig/DisableFunctions1_PGML.pg FortLewis/Authoring/Templates/Trig/DisableFunctions1_PGML.pg] | ||
Revision as of 12:05, 11 March 2023
Disabling Functions so Students Must Simplify Answers

This PG code shows how to disable all functions and restrict student answers to fractions.
- PGML location in OPL: FortLewis/Authoring/Templates/Trig/DisableFunctions1_PGML.pg
PG problem file | Explanation |
---|---|
Problem tagging: |
|
DOCUMENT(); loadMacros( 'PGstandard.pl', 'MathObjects.pl', 'contextFraction.pl', 'PGML.pl', 'PGcourse.pl' ); TEXT(beginproblem()); |
Initialization:
|
Context('Fraction-NoDecimals'); # Prevent pi from becoming 3.1415... and cos(pi) from # becoming -1. Context()->constants->set(pi => {keepName => 1}); # The next context changes are not necessary to # prevent cos(pi) from becoming -1, but they cannot hurt. Context()->flags->set( reduceConstants=>0, reduceConstantFunctions=>0 ); $f1 = Formula('cos(pi)'); $f2 = Formula('sin(pi/3)'); Context()->functions->disable('All'); Context()->functions->enable('sqrt'); $answer1 = Compute('-1'); $answer2 = Compute('sqrt(3)/2'); |
Setup:
We choose a context that requires fractions as answers and does not allow decimals. After constructing the formulas involving trig functions, we disable all functions and re-enable the
Note that |
BEGIN_PGML Enter your answers as simplified fractions. + [` [$f1] = `] [_____________]{$answer1} + [` [$f2] = `] [_____________]{$answer2} [@ helpLink('fractions') @]* END_PGML |
Main Text: |
BEGIN_PGML_SOLUTION The cosine of an angle is zero when the angle is an integer multiple of \( \pi \). END_PGML_SOLUTION ENDDOCUMENT(); |
Solution: |