Difference between revisions of "LimitedPowers"
Jump to navigation
Jump to search
m (2 revisions: import all default namespace pages from old wiki) |
(Update documentation links) |
||
Line 127: | Line 127: | ||
<ul> |
<ul> |
||
− | <li>POD documentation: [http://webwork.maa.org/ |
+ | <li>POD documentation: [http://webwork.maa.org/pod/pg_TRUNK/macros/contextLimitedPowers.pl.html contextLimitedPowers.pl.html]</li> |
− | <li>PG macro: [http:// |
+ | <li>PG macro: [http://webwork.maa.org/viewvc/system/trunk/pg/macros/contextLimitedPowers.pl?view=log contextLimitedPowers.pl]</li> |
</ul> |
</ul> |
Revision as of 00:48, 27 November 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