Hello, I am trying to program a question that asks students to solve a system of two linear equations in two variables. Right now, the problem accepts a list of two assignment formulas as the proper answer. For example:

x=1, y=3

But some students will enter the point (1, 3) for the solution (despite the instructions) and I'd like to have a custom answer checker to deal with this.

My attempts to write a custom answer checker have failed, and I think the reason has to do with the fact that I am trying to work with a list of formulas Math Object and a point Math Object.

Can anyone help? Here is the code for the problem as I have it now.

##############################################

# WeBWorK problem written by Alex Jordan

# Portland Community College

# ENDDESCRIPTION

## DBsubject('Algebra')

## DBchapter('Systems of Equations and Inequalities')

## DBsection('Systems of Equations')

## KEYWORDS('solutions', 'systems of equations')

## TitleText1('Introductory Algebra')

## EditionText1('5')

## AuthorText1('Blitzer')

## Section1('5.2')

## Problem1('10')

## Author('Alex Jordan')

## Institution('PCC')

##############################################

DOCUMENT();

loadMacros(

"PGstandard.pl",

"MathObjects.pl",

"parserAssignment.pl",

);

##############################################

Context("Numeric");

Context()->variables->add(y=>'Real');

parser::Assignment->Allow;

Context()->reduction->set('(-x)-y'=>0);

Context()->reduction->set('(-x)+y'=>0);

$a = -1;

$b = 3;

$e = 10;

$c = 2;

$d = 8;

$f = -6;

$left1=Compute("$a*x+$b*y")->reduce;

$right1=Compute("$e")->reduce;

$left2=Compute("$c*x+$d*y")->reduce;

$right2=Compute("$f")->reduce;

Context()->strings->add("no solution"=>{},

"no solutions"=>{alias=>'no solution'},

"none"=>{alias=>'no solution'},

"infinite number of solutions"=>{},

"infinitely many solutions"=>{alias=>'infinite number of solutions'},

"infinitely many"=>{alias=>'infinite number of solutions'},

"infinite"=>{alias=>'infinite number of solutions'},

"infinite solutions"=>{alias=>'infinite number of solutions'});

if ($a*$d-$b*$c != 0) {

$x = Compute(($e*$d-$f*$b)/($a*$d-$b*$c))->reduce;

$y = Compute((-$e*$c+$f*$a)/($a*$d-$b*$c))->reduce;

$ans = Formula("x = $x, y = $y"); }

elsif (($e*$d != $f*$b)||($e*$c != $f*$a)) {

$ans = Compute("no solution"); }

else {

$ans = Compute("infinite number of solutions"); };

##############################################

Context()->texStrings;

BEGIN_TEXT

Introductory Algebra,

5th Edition,

Robert Blitzer $BR

Section 5.2,

Exercise 10

$PAR

Solve the system below by using the substitution method. $PAR

$SPACE $SPACE $SPACE \(\setlength\arraycolsep{0.2em}

\begin{array}{rcl}

$left1 & = & $right1\\

$left2 & = & $right2\\

\end{array}\)

$PAR

If there is one solution, type it using a comma just like this example: $SPACE $SPACE\(x=10,y=-2\)$BR

If there is no solution, enter $BBOLD no solution$EBOLD. $SPACE Spelling counts. $BR

If there is an infinite number of solutions, enter $BBOLD infinite number of solutions$EBOLD. $SPACE Spelling counts. $PAR

\{ ans_rule(15) \}

END_TEXT

Context()->normalStrings;

##############################################

ANS( $ans -> cmp(typeMatch=>Formula("x=0,y=0")) );

#A failed attempt at a custom checker:

#ANS( $ans -> cmp(typeMatch=>Formula("x=0,y=0"), checker => sub {

#my ( $correct, $student, $ansHash ) = @_;

#my $correctpoint = Point($x,$y);

#return ($correct == $student) || ($correctpoint ==$student);

#}) );

ENDDOCUMENT();

##############################################

Thanks for any help,

Alex

## WeBWorK Problems

### Multiple correct answers of different Math Object type

This forum has a limit to the number of forum postings you can make in a given time period - this is currently set at 10 posting(s) in 1 day