DOCUMENT();

loadMacros('PGstandard.pl', 'PGML.pl', 'parserMultiAnswer.pl', 'PGcourse.pl');

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

do {
    $a = random(2, 8, 2);
    $b = random(3, 9, 2);
    $c = random(1, 9, 1);
} until ($a * $c != $b);

$num = Formula("$a y - $b");
$den = Formula("y - $c");

$numbogus = Formula("$a*y+$b");
$denbogus = Formula("(y-$c)*($c-y)");

$multians = MultiAnswer($num, $den)->with(
    allowBlankAnswers => 1,
    checker           => sub {
        my ($correct, $student, $self) = @_;
        my ($f1stu, $f2stu) = @$student;
        my ($f1,    $f2)    = @$correct;

        if (($f1 == $f1stu && $f2 == $f2stu)
            || (-$f1 == $f1stu && -$f2 == $f2stu))
        {
            return [ 1, 1 ];
        } elsif ($f1 == $f1stu || -$f1 == $f1stu) {
            return [ 1, 0 ];
        } elsif (($numbogus == $f1stu || -$numbogus == $f1stu)
            || ($denbogus == $f2stu || -$denbogus == $f2stu))
        {
            $self->setMessage(1, "Find a common denominator first");
            $self->setMessage(2, "Find a common denominator first");
            return [ 0, 0 ];
        } elsif ($f2 == $f2stu || -$f2 == $f2stu) {
            return [ 0, 1 ];
        } elsif (Value::classMatch($f1stu, 'Formula')
            && Value::classMatch($f2stu, 'Formula')
            && $f1 * $f2stu == $f1stu * $f2)
        {
            $self->setMessage(1, "Simplify your answer further");
            $self->setMessage(2, "Simplify your answer further");
            return [ 0, 0 ];
        } else {
            return [ 0, 0 ];
        }
    }
);

BEGIN_PGML
Perform the indicated operations. Express your answer in reduced form.

[#
    [. [``\frac{[$a]y}{y - [$c]} + \frac{[$b]}{[$c] - y} =``] .]
    [.
        [#
            [. [_]{$multians} .]*{ bottom => 1 }
            [. [_]{$multians} .]
        #]*{ padding => [ 0.5, 0 ] }
    .]
#]*{ padding => [ 0, 0.5 ], valign => 'middle' }
END_PGML

BEGIN_PGML_SOLUTION
Solution explanation goes here.
END_PGML_SOLUTION

ENDDOCUMENT();