Difference between revisions of "DisableFunctions1"
Jump to navigation
Jump to search
m (Changed incorrect "are not" to "are" in the sentence "This means that students are allowed to type in fractions...") |
|||
Line 81: | Line 81: | ||
<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 |
+ | 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> |
||
</td> |
</td> |
Revision as of 14:27, 23 May 2011
Disabling Functions so Students Must Simplify Answers
This PG code shows how to disable all functions and restrict student answers to fractions.
- Download file: File:DisableFunctions1.txt (change the file extension from txt to pg when you save it)
- File location in NPL:
FortLewis/Authoring/Templates/Trig/DisableFunctions1.pg
PG problem file | Explanation |
---|---|
Problem tagging: |
|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "AnswerFormatHelp.pl", "contextFraction.pl", ); TEXT(beginproblem()); |
Initialization: |
Context("Fraction-NoDecimals"); $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 |
Context()->texStrings; BEGIN_TEXT 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; |
Main Text: |
$showPartialCorrectAnswers = 1; ANS( $answer1->cmp() ); ANS( $answer2->cmp() ); |
Answer Evaluation: |
Context()->texStrings; BEGIN_SOLUTION ${PAR}SOLUTION:${PAR} Solution explanation goes here. END_SOLUTION Context()->normalStrings; COMMENT('MathObject version.'); ENDDOCUMENT(); |
Solution: |