WeBWorK Problems

MultiAnswer problem with Interval answer

MultiAnswer problem with Interval answer

by Teri Christiansen -
Number of replies: 4

Hi -

I have a hypothesis test problem that is attempting to give students partial credit for subsequent answers based on their answers earlier in the problem.  For example, if a student incorrectly chooses a wrong set of hypotheses, but gets later answers correct based on their chosen test, they will get credit for the subsequent answers.  Or, if they get the wrong test statistic or rejection region, but interpret those correctly, they can get credit for the interpretation.

The issue I have is with checking an interval answer as part of multiAnswer.  I ask students to enter an interval for the rejection region, and then I check whether their test statistic is contained in that interval to determine the scores for their conclusions.

The problem works well except for the cases where students enter something that Webwork doesn't recognize as an interval.  When students enter a single number value, or an interval like (2, 3) that could also be considered an ordered pair, the multiAnswer routine doesn't run at all.

I have read other threads that talk about changing the Context using typeMatch, but I'm having trouble understanding how to do that.

(I'm sure there may be better/more efficient ways to execute the multiAnswer checker here - but since it seems to be functioning well, I'm mostly interested in fixing the interval issue.)

Thanks in advance for any help!

-Teri Christiansen

In reply to Teri Christiansen

Re: MultiAnswer problem with Interval answer

by Glenn Rice -

Have you tried just using the "Interval" context for the problem as a whole?  It looks like everything else in your problem will work in the interval context.  Basic numerical answers, pop-ups, and radio buttons still work fine in the interval context.

So if you change the line near the beginning from

Context('Numeric')->flags->set(
    tolerance => 0.0001,
    tolType   => 'absolute',
);

to

Context('Interval')->flags->set(
    tolerance => 0.0001,
    tolType   => 'absolute',
);

then an answer like (2, 3) will be considered an Interval and not a Point (or List).

In reply to Glenn Rice

Re: MultiAnswer problem with Interval answer

by Teri Christiansen -

Glenn,

Thanks!  That worked to fix the issue of not recognizing an answer like (2, 3) as an interval.

The multiAnswer routine still fails to run if a student types a single number, or has some other error/typo in their interval.  Is there a way to get multiAnswer to still check earlier parts of the problem if the rejection region entered by the student is not an interval (for example, student answers like "5", or "(5, inf]")?

-Teri

In reply to Teri Christiansen

Re: MultiAnswer problem with Interval answer

by Glenn Rice -

If you add  $multians->setCmpFlags(4, showTypeWarnings => 0); after $multians is defined, then it will let answers like "5" or "5,inf" into the checker.  However, an answer that cannot be parsed into any MathObject like "(5,inf]" still won't get in.  The only way to deal with answers like that is to use a post filter.

In reply to Glenn Rice

Re: MultiAnswer problem with Interval answer

by Teri Christiansen -

Thank you!  I'm not sure I understand the post filter part, but will work on that.  These two changes will help with many of the errors I had.