Difference between revisions of "LimitedPowers"
Jump to navigation
Jump to search
m (2 revisions: import all default namespace pages from old wiki) |
|
(No difference)
|
Revision as of 15:19, 14 May 2010
Restricting Allowed Powers (Exponents) in Student Answers
This PG code shows how to restrict the allowed powers in student answers.
You may also be interested in other limited contexts DisableFunctions
PG problem file | Explanation |
---|---|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "PGcourse.pl", "contextLimitedPowers.pl", ); TEXT(beginproblem()); |
Initialization:
Use |
Context("Numeric"); #LimitedPowers::NoBaseE(); # chose one of these three: #LimitedPowers::OnlyIntegers(); LimitedPowers::OnlyPositiveIntegers(); #LimitedPowers::OnlyNonNegativeIntegers(); $a = random(2,5,1); |
Setup: This is the section where we restrict the allowed types of powers. For more options, see the POD documentation contextLimitedPowers.pl |
Context()->texStrings; BEGIN_TEXT (a) Enter \( $a^3 \): \{ ans_rule(10) \} $BR (b) Enter \( 1/$a^3 \), not \( $a^{-3} \): \{ ans_rule(10) \} $BR (c) Enter \( 1/x^2 \), not \( x^{-2} \): \{ ans_rule(10) \} END_TEXT Context()->normalStrings; |
Main Text: The problem text section of the file is as we'd expect. |
$showPartialCorrectAnswers = 1; ANS( Real("$a^3")->cmp() ); ANS( Real("1/$a^3")->cmp() ); ANS( Compute("1/x^2")->cmp() ); ENDDOCUMENT(); |
Answer Evaluation: As is the answer. |
- POD documentation: contextLimitedPowers.pl.html
- PG macro: contextLimitedPowers.pl