Specialized contexts

From WeBWorK
Jump to: navigation, search

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.
    • $m = Currency(10.99); or $m2 = Compute('$10,000.00');
  • contextFraction.pl
    • Context("Fraction");
    • Context("Fraction-NoDecimals");
    • Context("LimitedFraction");
    • Context("LimitedProperFraction");
    • 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). Note that PGauxiliaryFunctions.plmust be loaded to access these functions.
  • contextLimitedNumeric.pl
    • Context("LimitedNumeric-List"); -- allows lists -- (need contextLimiteNumeric.pl for this)
    • ( [DEPRECATED] -- loadMacros("contextLimitedNumeric.pl") is not needed for the these remaining contexts which are now standard and defined in pg/lib/Parser/Legacy/LimitedNumeric.pm
    • Context("LimitedNumeric");
    • Context("LimitedNumeric-Fraction")
    • Context("LimitedNumeric-StrictFraction"); -- no decimals
    • Allows numeric entry but no operations.
  • 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
    • Context("Ordering")
    • Context("Ordering-List")
    • Create objects which parse answers such as $ans = Ordering("B > A = D > C");
  • contextPeriodic.pl
    • [DEPRECATED] The features in this file are now standard features of the Real and Complex MathObjects classes.
  • contextReaction.pl
    • Context("Reaction");
    • Implements the specification and comparison of chemical reactions formulas.
    • $R = Formula("4P + 5O_2 --> 2P_2O_5");
  • 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
follow us