Difference between revisions of "ContextLimitedPolynomial"
m (CheckPolynomial moved to ContextLimitedPolynomial: Makes more sense) |
|||
(6 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
− | {{DISPLAYTITLE: |
+ | {{DISPLAYTITLE:contextLimitedPolynomial}} |
{{macro |
{{macro |
||
− | |name=checkPolynomial |
||
+ | |name=contextLimitedPolynomial |
||
− | |category=MathObject |
+ | |category=MathObject Context |
|status=Standard |
|status=Standard |
||
|desc=Allow only entry of polynomials |
|desc=Allow only entry of polynomials |
||
Line 15: | Line 15: | ||
== Purpose of this Macro == |
== Purpose of this Macro == |
||
− | In the <code>LimitedPolynomial</code> context, WeBWorK will require all student answers to be (expanded) polynomials (i.e., sums of multiples of powers of x). This context allows also requiring that there be only one term with each power of x. |
+ | In the <code>LimitedPolynomial</code> context, WeBWorK will require all student answers to be (expanded) polynomials (i.e., sums of multiples of powers of x). This context allows also requiring that there be only one term with each power of x. |
− | |||
== Initialization == |
== Initialization == |
||
Line 22: | Line 22: | ||
<pre> |
<pre> |
||
loadMacros( |
loadMacros( |
||
− | "MathObjects.pl", |
||
+ | "contextLimitedPolynomial.pl", #Automatically loads MathObjects.pl |
||
− | "contextLimitedPolynomial.pl", |
||
− | others, |
||
); |
); |
||
</pre> |
</pre> |
||
Line 30: | Line 28: | ||
Select the context using: |
Select the context using: |
||
− | Context("LimitedPolynomial"); |
+ | Context("LimitedPolynomial"); |
If you set the ``singlePowers'' flag, then only one monomial of each degree can be included in the polynomial: |
If you set the ``singlePowers'' flag, then only one monomial of each degree can be included in the polynomial: |
||
− | Context("LimitedPolynomial")->flags->set(singlePowers=>1); |
+ | Context("LimitedPolynomial")->flags->set(singlePowers=>1); |
There is also a strict limited context that does not allow operations even within the coefficients. Select it using: |
There is also a strict limited context that does not allow operations even within the coefficients. Select it using: |
||
− | Context("LimitedPolynomial-Strict"); |
+ | Context("LimitedPolynomial-Strict"); |
In addition to disallowing operations within the coefficients, this context does not reduce constant operations (since they are not allowed), and sets the singlePowers flag automatically. In addition, it disables all the functions, though they can be re-enabled, if needed. |
In addition to disallowing operations within the coefficients, this context does not reduce constant operations (since they are not allowed), and sets the singlePowers flag automatically. In addition, it disables all the functions, though they can be re-enabled, if needed. |
||
Line 44: | Line 42: | ||
== Usage == |
== Usage == |
||
− | The <code>checkPolynomial</code> macro is used as follows{{...}} |
||
+ | |||
== Bug Reports == |
== Bug Reports == |
||
Line 53: | Line 51: | ||
*[[DisableFunctions]] |
*[[DisableFunctions]] |
||
*[[ModifyingContexts(Advanced)]] |
*[[ModifyingContexts(Advanced)]] |
||
+ | |||
+ | [[Category:Contexts]] |
Latest revision as of 12:57, 21 November 2010
contextLimitedPolynomial Category: MathObject Context | |
---|---|
Status | Standard |
Description | Allow only entry of polynomials |
File Name | contextLimitedPolynomial.pl |
File Path | /pg/macros/contextLimitedPolynomial.pl |
Download | |
Code Docs | http://webwork.maa.org/doc/cvs/pg_HEAD/macros/contextLimitedPolynomial.pl.html |
NPL Example | |
Comments: |
Purpose of this Macro
In the LimitedPolynomial
context, WeBWorK will require all student answers to be (expanded) polynomials (i.e., sums of multiples of powers of x). This context allows also requiring that there be only one term with each power of x.
Initialization
Enable the LimitedPolynomial
context in loadMacros
:
loadMacros( "contextLimitedPolynomial.pl", #Automatically loads MathObjects.pl );
Select the context using:
Context("LimitedPolynomial");
If you set the ``singlePowers flag, then only one monomial of each degree can be included in the polynomial:
Context("LimitedPolynomial")->flags->set(singlePowers=>1);
There is also a strict limited context that does not allow operations even within the coefficients. Select it using:
Context("LimitedPolynomial-Strict");
In addition to disallowing operations within the coefficients, this context does not reduce constant operations (since they are not allowed), and sets the singlePowers flag automatically. In addition, it disables all the functions, though they can be re-enabled, if needed.