WeBWorK Problems

Overlaping intervals checked

Overlaping intervals checked

by Curtis Card -
Number of replies: 4

I'm working with interval notation in College Algebra and want students to enter "simplified" answers.

For example, if I ask them to simplify [1,7)U(3,10), I want them to enter  [1,10).  But, if I use interval_cmp("[1,10)") and the students enter [1,7)U(3,10), their answer is accepted as correct.  Similarly, [1,7) intersected with (3,10) should require (3,7) as the correct answer. (Is there a symbol used for intersection?) 

Is there a way to force them to perform operations of union and intersection and not let WeBWorK do it for them? 

Also, is there a way to check intersections of interval answers? I don't recall seeing this anywhere.

 

In reply to Curtis Card

Re: Overlaping intervals checked

by Davide Cervone -
Interval_cmp() does not have a way to do what you ask, but the MathObjects Interval object does this by default. If you use
    loadMacros("MathObjects.pl");

    Context("Interval");

    $I = Union("[1,7) U (3,10)");

    ANS($I->cmp);
you will get an interval answer checker that requires the student to simplify the interval. You will need a relatively recent version of PG for this (otherwise, use Parser.pl rather than MathObjects.pl).

There is no built-in notation for intersections as there is for union (though it would be possible to add one), but you can compute them in the problem code as follows:

    loadMacros("MathObjects.pl";
    Context("Interval");
    
    $I1 = Interval("[1,5]");
    $I2 = Interval("(2,6]");

    $I3 = $I1->intersect($I2);

    ANS($I3->cmp);
There are, of course variations on this, like
    ANS($I1->intersect($I2)->cmp);
or
    $I3 = Interval("[1,5]")->intersect("(2,6]");
but you should get the idea. You can also use subtraction on intervals to perform set differences, and can use braces to indicate finite point sets. E.g., {3,5} is the set containing the numbes 3 and 5. So [3,5] - (3,5) = {3,5}. The interval (-inf,inf) is available as R for convenience in the Interval context.

There is also a relatively new MathObject class for inequalities like x < 5 or 2 <= x < 5 as an alternative notation for entering intervals. See pg/macros/contextInequalities.pl for details. You will definitely need a current copy of PG for that, since it was only added in the fall.

Hope that helps

Davide

In reply to Davide Cervone

Re: Overlaping intervals checked

by Curtis Card -

Can someone walk me through how to "grab a current copy of PG"?  I'm pretty new to all of this and just started using WeBWorK during the fall semester after installing WeBWorK on the department's server.  This coming semester I'm interested in writing problems to match the texts I'm currently using and it appears that I should update PG.   I'm currently using WeBWorK 2.3.2 and not sure how to determine which version of PG was installed at the same time as WeBWorK 2.3.2.

I did do a CVS install originally and I'm not sure how to do a CVS update of just PG at this time.

Thanks,

Curtis

In reply to Curtis Card

Re: Overlaping intervals checked

by Michael Gage -

in the directory .../webwork/pg type


cvs update


This will get the latest bug fixes. To make sure that you are at the latest stable version (which at this writing is rel-2-4-dev) type


cvs update -r rel-2-4-dev

which should get you all the features that Davide mentions. If you want the very latest version (say to grab a recently added feature or bug fix) use


cvs update -A -d

which updates you to the HEAD version in the CVS and also allows new directories to be created.


cvs status 

Will tell which release version you are currently using.

Because you issue this command in the pg directory only the pg files are updated. Issuing this in /webwork/webwork2 would update the webwork2 files (which one should be a bit more cautious about since it usually involves making some adjustments in global.conf)

Hope this helps.

--Mike