@@ -39,7 +39,7 @@ loadMacros(
3939 "PGstandard.pl",
4040 "PGchoicemacros.pl",
4141 "MathObjects.pl",
42- "parserFormulaUpToConstant .pl",
42+ "parserMultiAnswer .pl",
4343 "PGcourse.pl"
4444);
4545
@@ -113,6 +113,33 @@ if ( $which ) {
113113 $chg2d = "-$a";
114114}
115115
116+ $part_b = MultiAnswer($f,$f0,$f1,$chg2)->with(
117+ singleResult => 0,
118+ checker => sub{
119+ my ( $correct, $student, $self ) = @_;
120+ my ( $f_stu, $f0_stu, $f1_stu, $chg2_stu ) = @{$student};
121+ my @score = (0,0,0,0);
122+ if ( ($fx == $f_stu->D('x')) and ($fy == $f_stu->D('y')) ){
123+ $score[0]=1;
124+ }
125+ else{
126+ $self -> setMessage(1,"The gradient of your function must equal \(\nabla f\)");
127+ return @score;
128+ }
129+ if ( $f0_stu == $f_stu->eval(x=>0,y=>0) ){
130+ $score[1]=1;
131+ }
132+ if ( $f1_stu == $f_stu->eval(x=>1,y=>pi/2) ){
133+ $score[2]=1;
134+ }
135+ if ( $score[1] == 1 and $score[2] == 1 and
136+ $chg2_stu == ($f1_stu - $f0_stu) ){
137+ $score[3]=1;
138+ }
139+ return @score;
140+ }
141+ );
142+
116143
117144Context()->texStrings;
118145TEXT(beginproblem());
@@ -159,28 +186,30 @@ $PAR
159186${BBOLD}(b)$EBOLD
160187By computing values of \( f \). To do this,
161188$BR
162- First find \( f(x,y) = \) \{ ans_rule(45) \}
189+ First find \( f(x,y) = \) \{ $part_b-> ans_rule(45) \}
163190$BR
164191Thus
165192$BR
166- \( f(0,0) = \) \{ ans_rule(25) \} and
167- \( f(1,\pi/2) = \) \{ ans_rule(25) \},
193+ \( f(0,0) = \) \{ $part_b-> ans_rule(25) \} and
194+ \( f(1,\pi/2) = \) \{ $part_b-> ans_rule(25) \},
168195$BR
169- and the change in \(f\) is \{ ans_rule(35) \}.
196+ and the change in \(f\) is \{ $part_b-> ans_rule(35) \}.
170197
171198END_TEXT
172199Context()->normalStrings;
173200
201+ #part a answers
202+
174203ANS($rx->cmp() );
175204ANS($ry->cmp() );
176205ANS($integr->cmp() );
177206ANS($int1->cmp() );
178207ANS($int2->cmp() );
179208ANS($chg1->cmp() );
180- ANS($f->cmp(upToConstant=>1) );
181- ANS($f0->cmp() );
182- ANS($f1->cmp() );
183- ANS($chg2 ->cmp() );
209+
210+ #part b answers
211+
212+ ANS($part_b ->cmp());
184213
185214Context()->texStrings;
186215SOLUTION(EV3(<<'END_SOLUTION'));
0 commit comments