Specialized contexts

From WeBWorK
(Difference between revisions)
Jump to: navigation, search
(Specialized Context Macro files)
(Specialized Context Macro files)
Line 23: Line 23:
 
** <code>Context("ABCD-List");</code>
 
** <code>Context("ABCD-List");</code>
 
** Contexts for matching problems. Adds strings A, B, C, D as allowable entries.
 
** Contexts for matching problems. Adds strings A, B, C, D as allowable entries.
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextCurrency.pl contextCurrency.pl]
+
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextCurrency.pl.html contextCurrency.pl]
 
** <code>Context("Currency");</code>
 
** <code>Context("Currency");</code>
 
** Context for entering numbers with currency symbols and commas.
 
** Context for entering numbers with currency symbols and commas.
 
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextFraction.pl.html contextFraction.pl]
 
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextFraction.pl.html contextFraction.pl]
 
** Implements a MathObject class for Fractions.
 
** Implements a MathObject class for Fractions.
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextInequalities.pl contextInequalities.pl]
+
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextInequalities.pl.html contextInequalities.pl]
 
** <code>Context(`Inequalities');</code>
 
** <code>Context(`Inequalities');</code>
 
** <code>Context(`Inequalities-Only');</code>
 
** <code>Context(`Inequalities-Only');</code>
 
** Provides contexts that allow intervals to be specified as inequalities.
 
** Provides contexts that allow intervals to be specified as inequalities.
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextIntegerFunctions.pl contextIntegerFunctions.pl]
+
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextIntegerFunctions.pl.html contextIntegerFunctions.pl]
 
** <code>Context("IntegerFunctions");</code>
 
** <code>Context("IntegerFunctions");</code>
 
** adds integer related functions C(n,r) and P(n,r).
 
** adds integer related functions C(n,r) and P(n,r).
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextLimitedComplex.pl contextLimitedComplex.pl]
+
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextLimitedComplex.pl.html contextLimitedComplex.pl]
 
** <code>Context("LimitedComplex");</code>
 
** <code>Context("LimitedComplex");</code>
 
** Allow complex numbers but not complex operations.
 
** Allow complex numbers but not complex operations.
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextLimitedNumeric.pl contextLimitedNumeric.pl]  
+
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextLimitedNumeric.pl.html contextLimitedNumeric.pl]  
 
** ( [DEPRECATED] -- loadMacros("contextLimitedNumeric.pl") is not needed, these contexts are now standard and defined in <code>pg/lib/Parser/Legacy/LimitedNumeric.pm</code>
 
** ( [DEPRECATED] -- loadMacros("contextLimitedNumeric.pl") is not needed, these contexts are now standard and defined in <code>pg/lib/Parser/Legacy/LimitedNumeric.pm</code>
 
** <code>Context("LimitedNumeric");</code>
 
** <code>Context("LimitedNumeric");</code>
Line 45: Line 45:
 
** <code>Context("LimitedNumeric-StrictFraction");</code> -- no decimals
 
** <code>Context("LimitedNumeric-StrictFraction");</code> -- no decimals
 
** Allows numeric entry but no operations.
 
** Allows numeric entry but no operations.
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextLimitedPoint.pl contextLimitedPoint.pl]
+
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextLimitedPoint.pl.html contextLimitedPoint.pl]
 
** <code>Context("LimitedPoint")</code>
 
** <code>Context("LimitedPoint")</code>
 
** Allow point entry but no point operations.
 
** Allow point entry but no point operations.
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextLimitedPolynomial.pl contextLimitedPolynomial.pl]
+
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextLimitedPolynomial.pl.html contextLimitedPolynomial.pl]
 
** <code>Context("LimitedPolynomial");</code>
 
** <code>Context("LimitedPolynomial");</code>
 
** Allow only entry of expanded polynomials.
 
** Allow only entry of expanded polynomials.
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextLimitedPowers.pl contextLimitedPowers.pl]
+
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextLimitedPowers.pl.html contextLimitedPowers.pl]
 
** <code>LimitedPowers::NoBaseE();</code>
 
** <code>LimitedPowers::NoBaseE();</code>
 
** <code>LimitedPowers::OnlyIntegers();</code>
 
** <code>LimitedPowers::OnlyIntegers();</code>
Line 57: Line 57:
 
** <code>LimitedPowers::OnlyNonNegativeIntegers();</code>
 
** <code>LimitedPowers::OnlyNonNegativeIntegers();</code>
 
** Restrict the base or power allowed in exponentials.
 
** Restrict the base or power allowed in exponentials.
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextLimitedVector.pl contextLimitedVector.pl]
+
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextLimitedVector.pl.html contextLimitedVector.pl]
 
** <code>Context("LimitedVector-coordinate");</code>
 
** <code>Context("LimitedVector-coordinate");</code>
 
** <code>Context("LimitedVector-ijk");</code>
 
** <code>Context("LimitedVector-ijk");</code>
Line 64: Line 64:
 
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextOrdering.pl.html contextOrdering.pl]
 
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextOrdering.pl.html contextOrdering.pl]
 
** Parses ordered lists of letters like ``B > A = C > D''
 
** Parses ordered lists of letters like ``B > A = C > D''
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextPeriodic.pl contextPeriodic.pl]
+
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextPeriodic.pl.html contextPeriodic.pl]
 
** [DEPRECATED] The features in this file are now standard features of the Real and Complex MathObjects classes.
 
** [DEPRECATED] The features in this file are now standard features of the Real and Complex MathObjects classes.
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextPiecewiseFunction.pl contextPiecewiseFunction.pl]
+
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextPiecewiseFunction.pl.html contextPiecewiseFunction.pl]
 
** <code>Context("PiecewiseFuntion");</code>
 
** <code>Context("PiecewiseFuntion");</code>
 
** Allow usage of piecewise functions.
 
** Allow usage of piecewise functions.
  
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextReaction.pl contextReaction.pl]
+
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextReaction.pl.html contextReaction.pl]
 
** <code>Context("Reaction");</code>
 
** <code>Context("Reaction");</code>
 
** Implements chemical reactions that can be specified and compared.
 
** Implements chemical reactions that can be specified and compared.
  
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextScientificNotation.pl contextScientificNotation.pl]
+
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextScientificNotation.pl.html contextScientificNotation.pl]
 
** <code>Context("ScientificNotation");</code>
 
** <code>Context("ScientificNotation");</code>
 
** Allows entry of scientific notation. Tries hard to report useful error messages when student's answer is not in the proper format.  
 
** Allows entry of scientific notation. Tries hard to report useful error messages when student's answer is not in the proper format.  
 
** Experimental: may be renamed to LimitedScientifcNotation
 
** Experimental: may be renamed to LimitedScientifcNotation
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextString.pl contextString.pl]
+
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextString.pl.html contextString.pl]
 
** Use this context to allow restricted short answer (no mathematical symbols) questions.
 
** Use this context to allow restricted short answer (no mathematical symbols) questions.
 
** Feedback is provided if the response contains strings that are not allowed.  
 
** Feedback is provided if the response contains strings that are not allowed.  
 
** See also [http://webwork.maa.org/pod/pg_TRUNK/macros/parserAutoStrings.pl.html parserAutoStrings.pl]  
 
** See also [http://webwork.maa.org/pod/pg_TRUNK/macros/parserAutoStrings.pl.html parserAutoStrings.pl]  
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextTF.pl contextTF.pl]
+
* [http://webwork.maa.org/pod/pg_TRUNK/macros/contextTF.pl.html contextTF.pl]
 
** <code>Context("TF");</code>
 
** <code>Context("TF");</code>
  
 
[[Category:Contexts]]
 
[[Category:Contexts]]

Revision as of 09:05, 21 November 2010

Specialized Contexts

Using advanced methods one can customize Contexts to control the possible student responses that are allowed and the feedback given to students if their response has incorrect syntax. These customizations can be placed in a macro file for reuse which by convention is given a name starting with "context" -- e.g. contextYourContextHere.pl.

  • SpecializedParsers covers the other advanced method for modifying the behavior of MathObjects. These files modify the parser which translates "TI calculator" formulae into MathObjects.
  • Examples are provided in the files listed below.

Specialized Context Macro files

Here is a partial list of contexts.

Check the POD documentation for more examples.

Use loadMacros("contextABCD.pl"); to make the context available for a WeBWorK question.

  • contextABCD.pl
    • Context("ABCD");
    • Context("ABCD-List");
    • Contexts for matching problems. Adds strings A, B, C, D as allowable entries.
  • contextCurrency.pl
    • Context("Currency");
    • Context for entering numbers with currency symbols and commas.
  • contextFraction.pl
    • Implements a MathObject class for Fractions.
  • contextInequalities.pl
    • Context(`Inequalities');
    • Context(`Inequalities-Only');
    • Provides contexts that allow intervals to be specified as inequalities.
  • contextIntegerFunctions.pl
    • Context("IntegerFunctions");
    • adds integer related functions C(n,r) and P(n,r).
  • contextLimitedComplex.pl
    • Context("LimitedComplex");
    • Allow complex numbers but not complex operations.
  • contextLimitedNumeric.pl
    • ( [DEPRECATED] -- loadMacros("contextLimitedNumeric.pl") is not needed, these contexts are now standard and defined in pg/lib/Parser/Legacy/LimitedNumeric.pm
    • Context("LimitedNumeric");
    • Context("LimitedNumeric-List"); -- allows lists -- (need contextLimiteNumeric.pl for this)
    • Context("LimitedNumeric-Fraction")
    • Context("LimitedNumeric-StrictFraction"); -- no decimals
    • Allows numeric entry but no operations.
  • contextLimitedPoint.pl
    • Context("LimitedPoint")
    • Allow point entry but no point operations.
  • contextLimitedPolynomial.pl
    • Context("LimitedPolynomial");
    • Allow only entry of expanded polynomials.
  • contextLimitedPowers.pl
    • LimitedPowers::NoBaseE();
    • LimitedPowers::OnlyIntegers();
    • LimitedPowers::OnlyPositiveIntegers();
    • LimitedPowers::OnlyNonNegativeIntegers();
    • Restrict the base or power allowed in exponentials.
  • contextLimitedVector.pl
    • Context("LimitedVector-coordinate");
    • Context("LimitedVector-ijk");
    • Context("LimitedVector"); # either one
    • Allow vector entry but no vector operations.
  • contextOrdering.pl
    • Parses ordered lists of letters like ``B > A = C > D
  • contextPeriodic.pl
    • [DEPRECATED] The features in this file are now standard features of the Real and Complex MathObjects classes.
  • contextPiecewiseFunction.pl
    • Context("PiecewiseFuntion");
    • Allow usage of piecewise functions.
  • contextReaction.pl
    • Context("Reaction");
    • Implements chemical reactions that can be specified and compared.
  • contextScientificNotation.pl
    • Context("ScientificNotation");
    • Allows entry of scientific notation. Tries hard to report useful error messages when student's answer is not in the proper format.
    • Experimental: may be renamed to LimitedScientifcNotation
  • contextString.pl
    • Use this context to allow restricted short answer (no mathematical symbols) questions.
    • Feedback is provided if the response contains strings that are not allowed.
    • See also parserAutoStrings.pl
  • contextTF.pl
    • Context("TF");
follow us