Context flags

From WeBWorK
(Difference between revisions)
Jump to: navigation, search
(Setting Context Flags)
m (ContextFlags moved to Context flags: CamelCase not needed)

Revision as of 08:22, 19 August 2008

Contents

Context Flags

There are a number of values stored in the context that control such things as the tolerance used when comparing numbers the tolerance type (toType) which can be either 'absolute' or 'relative' and so on.

Some Available Contexts

  • Numeric (variable x, no Complex, Point, etc.)
  • Complex (variable z, i = [math]\sqrt{-1}![/math], no points, etc.)
  • Point (another name for Vector context)
  • Vector (variables x, y, z, angle brackets form vectors, i, j, k are unit coordinate vectors, etc.)
  • Vector2D (same as Vector, but with i and j in 2D)
  • Matrix (square brakets form matrices)
  • Interval (parens, braces and brackets form intervals and subsets of the real line)

Setting Context Flags

You control the value of these flags with commands such as:

$context->flags->set(tolerance=>.00001);

For example,

$context->flags->set(ijk=>1);

will cause the output of all vectors to be written in ijk format rather than <...> format.

In some settings one can temporarily override the context settings using the MathObject with method. A common example is

$r = Compute("pi");  
$r->with(tolType=>'absolute', tolerance=>1*E-5)->cmp);

produces an AnswerEvaluator which checks that the student response gives \(\pi\) to at least 5 decimal places.

Context Flags List

The following list gives each standard context flag along with a description of its use. There are not currently any context specific flags, but this may change. To find out exactly which flags can be set in a specific context and their current value go to HowToListContextFlags

allowBadFunctionInputs
default: 0
allowBadOperands
default: 0
allowEmptyStrings
default: 1
allowMissingFunctionInputs
default: 0
allowMissingOperands
default: 0
allowWrongArgCount
default: 0
checkUndefinedPoints
default: 0
Usage: $context->flags->set(checkUndefinedPoints=>1);
Description: If the answer to a question is a formula, then checkUndefinedPoints allows possible test points at which to compare the student answer with the correct answer to be points where the correct answer is undefined. For example, a student answer of ln(|x|) when the correct answer is ln(x) may be accepted as correct if checkUndefinedPoints=>0 since all test points would be positive numbers and may not if checkUndefinedPoints=>1 since some test points may not be positive.
See also: limits, max_undefined
formatStudentAnswer
default: evaluated
granularity
default: 1000
Usage: $context->flags->set(granularity=>5000);
Description: If the answer to a question is a formula, then granularity sets the minimum distance between possible test points at which to compare the student answer with the correct answer. The distance is determined by dividing the length of the interval specified by limits by granularity. In our example, with the default limits, the check points would be no closer than 4/5000.
See also: limits, num_points, resolution
ignoreEndpointTypes
default: 0
Usage: $context->flags->set(ignoreEndpointTypes=>1);
Description: If the answer to a question is an interval, the default value of ignoreEndpointTypes is set so that the inclusion or exclusion of endpoints in the students answer needs to match the correct answer to be correct. In our example, if we set ignoreEndpointTypes=>1, a student answer will be correct provided the interval is correct regardless of endpoints.
See also:
ijk
default: 0
Usage: $context->flags->set(ijk=>1);
Description: ijk=>1 will cause the output of all vectors to be written in ijk format rather than <...> format. The default setting will output vectors in <...> format.
infiniteWord
default: infinity
limits
default: [-2 , 2]
Usage: $context->flags->set(x=>{limits=>[-1,1]});
Description: If the answer to a question is a formula in the variable x, this sets the interval over which the values of x are selected to compare the student's entered formula to the correct formula.
See also: resolution, granularity, num_points
max_adapt
default: 100000000
max_undefined
default:
Usage: $context->flags->set(max_undefined=>1);
Description: If the answer to a question is a formula, and we have allowed undefined test points at which to compare the student answer with the correct answer, max_undefined specifies the maximum number of possible test points where the correct answer is undefined. In our example, max_undefined=>1 means that at most one test can be taken as a point where the correct answer is undefined.
See also: checkUndefinedPoints
num_points
default: 5
Usage: $context->flags->set(num_points=>5);
Description: If the answer to a question is a formula in the variable x, this sets the number of values of x are selected to compare the student's entered formula to the correct formula.
See also: limits, granularity, resolution
reduceConstantFunctions
default: 1
reduceConstants
default: 1
reduceSets
default: 1
reduceSetsForComparison
default: 1
reduceUnions
default: 1
reduceUnionsForComparison
default: 1
resolution
default:
Usage: $context->flags->set(resolution=>1/2);
Description: If the answer to a question is a formula, then beginning at the left endpoint of the limits, this sets the spacing between possible test points at which to compare the student answer with the correct answer. In our example, with the default limits, the only possible check points will be -2,-1.5,-1,-.5,0,.5,1,1.5,2.
See also: limits, granularity, num_points
showExtraParens
default: 1
tolType=
default: relative
Usage: $context->flags->set(tolType=>'relative');
Description: Sets tolerance type as relative or absolute for student answers. The actual result of this depends on the value of tolerance. If tolType is relative, with the default value for tolerance our example would set the answer tolerance to 0.1% of the correct answer. If tolType is absolute, with the default value for tolerance our example would set the answer tolerance to within 0.001 of the absolute value of the correct answer.
See also: tolerance
tolerance
default: 0.001
Usage: $context->flags->set(tolerance=>.00001);
Description: Sets tolerance for student answers. The actual result of this depends on the value of tolType. The default value of tolType is relative and under this setting our example would set the answer tolerance to 0.001% of the correct answer.
See also: tolType
useBaseTenLog
default: 0
useFuzzyReals
default: 1
zeroLevel
default: 1e-14
Usage: $context->flags->set(zeroLevel=>.00001);
Description: If the value of an answer is less in absolute value than the zeroLevel, then zeroLevelTol is the absolute tolerance used for student answers. Under this example, any answer whose absolute value is smaller than the 0.00001 is considered correct if it is within the value of zeroLevelTol of the correct answer.
See also: zeroLevelTol, tolerance, tolType
zeroLevelTol
default: 1e-12
Usage: $context->flags->set(zeroLevelTol=>.00001);
Description: If an answer is smaller in absolute value than zeroLevel, then this sets the absolute tolerance for the student answer. Under this example, any answer whose absolute value is smaller than zeroLevel is considered correct if it is within 0.00001 of the correct answer. Note that this is overridden by the absolute tolerance if the tolType is set to absolute.
See also: zeroLevel, tolerance, tolType
follow us