DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "parserMultiAnswer.pl", "PGML.pl", "PGcourse.pl" ); ################# Setting up the problem goes here. TEXT(beginproblem()); Context("Numeric"); $m = random(2,6,1); $b = random(-5,-2,1); $line = Compute("$m*x+$b")->reduce(); $x1 = random(3,7,1); $y1 = $line->eval(x=>$x1); $y2 = random(7,11,1); $x2 = ($y2-$b)/$m; $multians = MultiAnswer($line, $y1, $x2)->with( singleResult => 0, checker => sub { my ( $correct, $student, $self ) = @_; my ( $linestu, $y1stu, $x2stu ) = @{$student}; if ($line == $linestu) { $result1 = 1; $y1calculated = $linestu->eval(x=>$x1); if ( $y1calculated == $y1stu ) { $result2 = 1; } else { $result2 = 0; } $mstu = $linestu->D('x'); $bstu = $linestu->eval(x=>0); $x2calculated = ($y2-$bstu)/($mstu); $x2calculated->{tolType}='absolute'; $x2calculated->{tolerance}=0.5; if ($x2calculated == $x2stu) { $result3 = 1; } else { $result3 = 0; } } else { $result1 = 0; $result2 = 0; $result3 = 0; } return([$result1,$result2,$result3]); }); BEGIN_PGML Write the equation of [:y= [$line]:]. [:y=:][___________]{$mutians} When [:x=[$x1]:], predict the value of [:y:]. [:y=:][____]{$multians} When [:y=[$y2]:], predict the value of [:x:]. [:x=:][____]{$multians} END_PGML ENDDOCUMENT();