Difference between revisions of "ContextLimitedPolynomial"

From WeBWorK_wiki
Jump to navigation Jump to search
m
m
Line 5: Line 5:
 
|status=Standard
 
|status=Standard
 
|desc=Allow only entry of polynomials
 
|desc=Allow only entry of polynomials
|filename=checkPolynomial.pl
+
|filename=contextLimitedPolynomial.pl
|filepath=contextLimitedPolynomial.pl
+
|filepath=/pg/macros/contextLimitedPolynomial.pl
 
|download=
 
|download=
 
|docs=http://webwork.maa.org/doc/cvs/pg_HEAD/macros/contextLimitedPolynomial.pl.html
 
|docs=http://webwork.maa.org/doc/cvs/pg_HEAD/macros/contextLimitedPolynomial.pl.html
Line 15: Line 15:
 
== Purpose of this Macro ==
 
== Purpose of this Macro ==
   
In this 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. The <code>checkPolynomial</code> macro{{...}}
   
   
 
== Initialization ==
 
== Initialization ==
   
Enable the context in <code>loadMacros</code>:
+
Enable the <code>LimitedPolynomial</code> context in <code>loadMacros</code>:
 
<pre>
 
<pre>
 
loadMacros(
 
loadMacros(
Line 31: Line 31:
 
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.
   
 
== Usage ==
 
== Usage ==
  +
  +
The <code>checkPolynomial</code> macro is used as follows{{...}}
   
 
== Bug Reports ==
 
== Bug Reports ==

Revision as of 15:14, 30 March 2010

checkPolynomial
Category: MathObject
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. The checkPolynomial macro…


Initialization

Enable the LimitedPolynomial context in loadMacros:

loadMacros(
  "MathObjects.pl",
  "contextLimitedPolynomial.pl",
  others,
);

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.

Usage

The checkPolynomial macro is used as follows…

Bug Reports

See Also