Skip to content

Typical WeBWorK problem with InexactValue

Lee McPherson edited this page Aug 31, 2023 · 10 revisions

You will need to add the "contextInexactValue.pl" macro at the very least in addition to the standard macros:

DOCUMENT();

loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"contextInexactValue.pl"
);

Start with declaring the InexactValue context. You can follow up with several options that determine how the problem will be graded:

Context("InexactValue");
Context()->flags->set(failOnValueWrong=>1);  # must have value correct (no partial credit for getting sig figs only)
Context()->flags->set(creditValue=>0.75);    # 75% credit for correct answer (default is 50%)
Context()->flags->set(creditSigFigs=>0.25);  # 25% credit for sig figs

The failOnValueWrong gives zero credit if the answer doesn't match with the exception of sig fig errors and some rounding errors. You will always want this to be true (1) unless you are making a problem where the intention is to grade sig figs only. i.e. the problem is about correct sig figs.

Next, start generating your values for your problems using the shortcut InexactValue. There are two ways to use it: text values vs number values. I would almost always recommend entering values as text. There are potential side-effects to entering values as numbers that are discussed on the main page, so avoid it if possible.


Clone this wiki locally