WeBWorK Problems

Exact Answers in MathObjects cmp?

Exact Answers in MathObjects cmp?

by Paul Seeburger -
Number of replies: 1

Hi!

I want to know if I am using the most current method to require exact answers in WebWork problems.

I found a way to require no decimals in student answers (in order to force an exact answer like pi to be entered.

It is:

ANS(no_decimals("$c/2 *pi"));

and it requires that I load:   "PGasu.pl", 

I also kept students from entering functions in their numeric answer using:

Context()->flags->set(
  reduceConstants=>0, # no decimals
  reduceConstantFunctions=>1, # combine 4+5*2?
  formatStudentAnswer=>'parsed', # no decimals
);

My question is: Is there a "better" way to do this same thing using a MathObject checker?

I saw something about NumberCheck, but no code examples that I could find on how to use it as I want to in a WebWork problem.

I also found another method called: exact_no_trig

It seems to do about the same thing as what I implemented above, but it still seems to not be a MathObjects checker, right?

Thanks!

Paul

In reply to Paul Seeburger

Re: Exact Answers in MathObjects cmp?

by Davide Cervone -

You can use

    Context("Numeric");
    Parser::Number::NoDecimals;

    ANS(Compute("$c/2 pi")->cmp);

to get the effect of your first example using MathObjects. Note that your flags do not prevent students from entering decimals or functions. They only affect how the student and correct answers are displayed.

If you want to disable functions so that students have to write 1/2 rather than sin(pi/6), then you can use

    Context()->functions->Disable('Trig');

There are other categories that can be disabled, or you can disable individual functions. See the Wiki page on Answer Checkers and the Context for details.

Davide