Skip to content

Commit 22c026c

Browse files
authored
Merge pull request #1068 from gajennings/main
Fix bug 4774
2 parents d260c3f + d06d8eb commit 22c026c

File tree

1 file changed

+38
-9
lines changed
  • OpenProblemLibrary/Michigan/Chap18Sec3

1 file changed

+38
-9
lines changed

OpenProblemLibrary/Michigan/Chap18Sec3/Q25.pg

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

117144
Context()->texStrings;
118145
TEXT(beginproblem());
@@ -159,28 +186,30 @@ $PAR
159186
${BBOLD}(b)$EBOLD
160187
By 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
164191
Thus
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

171198
END_TEXT
172199
Context()->normalStrings;
173200

201+
#part a answers
202+
174203
ANS($rx->cmp() );
175204
ANS($ry->cmp() );
176205
ANS($integr->cmp() );
177206
ANS($int1->cmp() );
178207
ANS($int2->cmp() );
179208
ANS($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

185214
Context()->texStrings;
186215
SOLUTION(EV3(<<'END_SOLUTION'));

0 commit comments

Comments
 (0)