Difference between revisions of "DisableFunctions1"
(add historical tag and give links to newer problems.) |
|||
(13 intermediate revisions by 4 users 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/Trig/DisableFunctionsTrig.html a newer version of this problem]</p> |
||
+ | |||
+ | |||
<h2>Disabling Functions so Students Must Simplify Answers</h2> |
<h2>Disabling Functions so Students Must Simplify Answers</h2> |
||
− | <p style="background-color:#eeeeee;border:black solid 1px;padding:3px;"> |
||
+ | [[File:DisableFunctions1.png|300px|thumb|right|Click to enlarge]] |
||
+ | <p style="background-color:#f9f9f9;border:black solid 1px;padding:3px;"> |
||
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. |
||
− | <ul> |
||
− | <li>Download file: [[File:DisableFunctions1.txt]] (change the file extension from txt to pg when you save it)</li> |
||
− | <li>File location in NPL: <code>NationalProblemLibrary/FortLewis/Authoring/Templates/Trig/DisableFunctions1.pg</code></li> |
||
− | </ul> |
||
</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] --> |
||
+ | * 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] |
||
+ | <br clear="all" /> |
||
<p style="text-align:center;"> |
<p style="text-align:center;"> |
||
[[SubjectAreaTemplates|Templates by Subject Area]] |
[[SubjectAreaTemplates|Templates by Subject Area]] |
||
Line 16: | Line 21: | ||
<tr valign="top"> |
<tr valign="top"> |
||
− | <th> PG problem file </th> |
+ | <th style="width: 40%"> PG problem file </th> |
<th> Explanation </th> |
<th> Explanation </th> |
||
</tr> |
</tr> |
||
Line 43: | Line 48: | ||
loadMacros( |
loadMacros( |
||
− | + | 'PGstandard.pl', |
|
− | + | 'MathObjects.pl', |
|
− | + | 'contextFraction.pl', |
|
− | + | 'PGML.pl', |
|
+ | 'PGcourse.pl' |
||
); |
); |
||
− | |||
TEXT(beginproblem()); |
TEXT(beginproblem()); |
||
</pre> |
</pre> |
||
Line 55: | Line 59: | ||
<p> |
<p> |
||
<b>Initialization:</b> |
<b>Initialization:</b> |
||
+ | |||
+ | * The <code>contextFraction.pl</code> is loaded since we used the <code>Fraction-NoDecimals</text> context. |
||
</p> |
</p> |
||
</td> |
</td> |
||
Line 65: | Line 71: | ||
<td style="background-color:#ffffdd;border:black 1px dashed;"> |
<td style="background-color:#ffffdd;border:black 1px dashed;"> |
||
<pre> |
<pre> |
||
− | Context( |
+ | Context('Fraction-NoDecimals'); |
− | $f1 = Compute("cos(pi)"); |
||
+ | # Prevent pi from becoming 3.1415... and cos(pi) from |
||
− | $f2 = Compute("sin(pi/3)"); |
||
+ | # becoming -1. |
||
+ | Context()->constants->set(pi => {keepName => 1}); |
||
− | Context("Fraction-NoDecimals"); |
||
+ | # 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 |
||
+ | ); |
||
− | Context()->functions->disable("All"); |
||
+ | $f1 = Formula('cos(pi)'); |
||
− | Context()->functions->enable("sqrt"); |
||
+ | $f2 = Formula('sin(pi/3)'); |
||
− | $answer1 = Compute("-1"); |
||
+ | Context()->functions->disable('All'); |
||
− | $answer2 = Compute("sqrt(3)/2"); |
||
+ | Context()->functions->enable('sqrt'); |
||
+ | |||
+ | $answer1 = Compute('-1'); |
||
+ | $answer2 = Compute('sqrt(3)/2'); |
||
</pre> |
</pre> |
||
</td> |
</td> |
||
Line 82: | Line 97: | ||
<p> |
<p> |
||
<b>Setup:</b> |
<b>Setup:</b> |
||
+ | 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 <code>sqrt()</code> function. This means that students are allowed to type in fractions and square roots, but not much else (e.g., they'll get an error message if they type in a trig function). |
||
+ | </p> |
||
+ | <p> |
||
+ | Note that <code>$f1</code> and <code>$f2</code> are MathObject Formulas, which do not get reduced since <code>pi</code> is set to keep its name. If <code>$f1</code> and <code>$f2</code> used Compute instead, then the results would be <code>-1</code> and <code>0.866...</code> instead of <code>cos(\pi)</code> and <code>sin(\pi/3)</code> as desired. |
||
</p> |
</p> |
||
</td> |
</td> |
||
Line 91: | Line 110: | ||
<td style="background-color:#ffdddd;border:black 1px dashed;"> |
<td style="background-color:#ffdddd;border:black 1px dashed;"> |
||
<pre> |
<pre> |
||
− | Context()->texStrings; |
||
+ | BEGIN_PGML |
||
− | BEGIN_TEXT |
||
Enter your answers as simplified fractions. |
Enter your answers as simplified fractions. |
||
− | $BR |
||
− | $BR |
||
− | \( $f1 = \) |
||
− | \{ ans_rule(20) \} |
||
− | \{ AnswerFormatHelp("fractions") \} |
||
− | $BR |
||
− | $BR |
||
− | \( $f2 = \) |
||
− | \{ ans_rule(20) \} |
||
− | \{ AnswerFormatHelp("fractions") \} |
||
− | END_TEXT |
||
− | Context()->normalStrings; |
||
− | </pre> |
||
− | <td style="background-color:#ffcccc;padding:7px;"> |
||
− | <p> |
||
− | <b>Main Text:</b> |
||
− | </p> |
||
− | </td> |
||
− | </tr> |
||
− | <!-- Answer evaluation section --> |
||
+ | + [` [$f1] = `] [_____________]{$answer1} |
||
− | |||
− | <tr valign="top"> |
||
− | <td style="background-color:#eeddff;border:black 1px dashed;"> |
||
− | <pre> |
||
− | $showPartialCorrectAnswers = 1; |
||
− | ANS( $answer1->cmp() ); |
||
+ | + [` [$f2] = `] [_____________]{$answer2} |
||
− | ANS( $answer2->cmp() ); |
||
+ | [@ helpLink('fractions') @]* |
||
+ | END_PGML |
||
</pre> |
</pre> |
||
− | <td style="background-color:# |
+ | <td style="background-color:#ffcccc;padding:7px;"> |
<p> |
<p> |
||
− | <b> |
+ | <b>Main Text:</b> |
</p> |
</p> |
||
</td> |
</td> |
||
Line 137: | Line 132: | ||
<td style="background-color:#ddddff;border:black 1px dashed;"> |
<td style="background-color:#ddddff;border:black 1px dashed;"> |
||
<pre> |
<pre> |
||
− | Context()->texStrings; |
||
+ | BEGIN_PGML_SOLUTION |
||
− | BEGIN_SOLUTION |
||
+ | The cosine of an angle is zero when |
||
− | ${PAR}SOLUTION:${PAR} |
||
+ | the angle is an integer multiple of \( \pi \). |
||
− | Solution explanation goes here. |
||
+ | END_PGML_SOLUTION |
||
− | END_SOLUTION |
||
− | Context()->normalStrings; |
||
− | |||
− | COMMENT('MathObject version.'); |
||
ENDDOCUMENT(); |
ENDDOCUMENT(); |
||
Line 162: | Line 153: | ||
[[Category:Top]] |
[[Category:Top]] |
||
− | [[Category: |
+ | [[Category:Sample Problems]] |
+ | [[Category:Subject Area Templates]] |
Latest revision as of 04:59, 18 July 2023
This problem has been replaced with a newer version of this problem
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: |