Forum archive 2000-2006

Michael Gage - extraAnswerEvaluators.pl

Michael Gage - extraAnswerEvaluators.pl

by Arnold Pizer -
Number of replies: 0
inactiveTopicextraAnswerEvaluators.pl topic started 2/6/2003; 9:36:44 PM
last post 2/6/2003; 9:36:44 PM
userMichael Gage - extraAnswerEvaluators.pl  blueArrow
2/6/2003; 9:36:44 PM (reads: 1810, responses: 0)


NAME

    extraAnswerEvaluators.pl -- located in the courseScripts directory


SYNPOSIS

    Answer Evaluators for intervals, lists of numbers, lists of points,
and equations.
    interval_cmp() -- checks answers which are unions of intervals.
It can also be used for checking an ordered pair or
list of ordered pairs.
    number_list_cmp() -- checks a comma separated list of numbers.  By use of
optional arguments, you can request that order be
important, that complex numbers be allowed, and
specify extra arguments to be sent to num_cmp (or
cplx_cmp) for checking individual
entries.
    equation_cmp() -- provides a limited facility for checking equations.
It makes no pretense of checking to see if the real locus
of the student's equation matches the real locus of the
instructor's equation. The student's equation must be
of the same general type as the instructors to get credit.


DESCRIPTION

This file adds subroutines which create "answer evaluators" for checking student answers of various "exotic" types.

interval_cmp ()

Compares an interval or union of intervals. Typical invocations are

    interval_cmp("(2, 3] U(7, 11)")

The U is used for union symbol. In fact, any garbage (or nothing at all) can go between intervals. It makes sure open/closed parts of intervals are correct, unless you don't like that. To have it ignore the difference between open and closed endpoints, use

    interval_cmp("(2, 3] U(7, 11)", sloppy=>'yes')

interval_cmp uses num_cmp on the endpoints. You can pass optional arguments for num_cmp, so to change the tolerance, you can use

    interval_cmp("(2, 3] U(3+4, 11)", relTol=>3)

The intervals can be listed in any order, unless you want to force a particular order, which is signaled as

    interval_cmp("(2, 3] U(3+4, 11)", ordered=>'strict')

You can specify infinity as an endpoint. It will do a case-insensitive string match looking for I, Infinity, Infty, or Inf. You can prepend a + or -, as in

    interval_cmp("(-inf, 3] U [e^10, infinity)")
or
interval_cmp("(-INF, 3] U [e^10, +I)")

If the question might have an empty set as the answer, you can use the strings option to allow for it. So

    interval_cmp("$ans", strings=>['empty'])

will not generate an error message if the student enters the string empty. Better still, it will mark a student answer of "empty" as correct iff this matches $ans.

You can use interval_cmp for ordered pairs, or lists of ordered pairs. Internally, this is just a distinction of whether to put nice union symbols between intervals, or commas. To get commas, use

    interval_cmp("(1,2), (2,3), (4,-1)", unions=>'no')

Note that interval_cmp makes no attempt at simplifying overlapping intervals. This becomes an important feature when you are really checking lists of ordered pairs.

Now we use the Parser package for checking intervals (or lists of points if unions=>'no'). So, one can specify the Parser options showCoordinateHints, showHints, partialCredit, and/or showLengthHints as optional arguments:

    interval_cmp("(1,2), (2,3), (4,-1)", unions=>'no', partialCredit=>1)

Also, set differences and 'R' for all real numbers now work too since they work for Parser Intervals and Unions.

number_list_cmp ()

Checks an answer which is a comma-separated list of numbers. The actual numbers are fed to num_cmp, so all of the flexibilty of num_cmp carries over (values can be expressions to be evaluated). For example,

    number_list_cmp("1, -2")

will accept "1, -2", "-2, 1", or "-1-1,sqrt(1)".

    number_list_cmp("1^2 + 1, 2^2 + 1, 3^2 + 1", ordered=>'strict')

will accept "2, 5, 10", but not "5, 2, 10".

If you want to allow complex number entries, complex=>'ok' will cause it to use cplx_cmp instead:

    number_list_cmp("2, -2, 2i, -2i", complex=>'ok')

In cases where you set complex=>'ok', be sure the problem file loads PGcomplexmacros.pl.

Optional arguements for num_cmp (resp. cplx_cmp) can be used as well, such as

    number_list_cmp("cos(3), sqrt(111)", relTol => 3)

The strings=>['hello'] argument is treated specially. It can be used to replace the entire answer. So

    number_list_cmp("cos(3), sqrt(111)", strings=>['none'])

will mark "none" wrong, but not generate an error. On the other hand,

    number_list_cmp("none", strings=>['none'])

will mark "none" as correct.

One can also specify optionnal arguments for Parser's List checker: showHints, partialCredit, and showLengthHints, as in:

    number_list_cmp("cos(3), sqrt(111)", partialCredit=>1)

equation_cmp ()

Compares an equation. This really piggy-backs off of fun_cmp. It looks at LHS-RHS of the equations to see if they agree up to constant multiple. It also guards against an answer of 0=0 (which technically gives a constant multiple of any equation). It is best suited to situations such as checking the equation of a line which might be vertical and you don't want to give that away, or checking equations of ellipses where the students answer should be quadratic.

Typical invocation would be:

    equation_com("x^2+(y-1)^2 = 11", vars=>['x','y'])

File path = /ww/webwork/pg/macros/extraAnswerEvaluators.pl

<| Post or View Comments |>