Under
an *old* version of WeBWorK, I unknowingly exploited what was
apparently a bug that's since been fixed. I'm wondering how to do it
with the new system. I'll describe what I did, and include the old
problem at the end, for analysis.
Basically, I grabbed the strings submitted in the answer slot on the
web page, then used 'eval' to make the strings into numerical values
that were then used in the problem to compute whether the pair of
answers were correct - each answer depended on the other (the objective
was to find values for a and r so that the geometric series a*r^n
converged to a random value).
How can i do this now? I tried tapping into the answer hash, but it's
non-existant until the answer evaluator runs, and the answer evaluator
needs the values...
Here's the original problem; (just trying to make it readable!)
##Description ##KEYWORDS('series', 'geometric') ##Find a geometric series converging to a given value ##enddescription
loadMacros( PG.pl, PGbasicmacros.pl, PGchoicemacros.pl, PGanswermacros.pl );
$showPartialCorrectAnswers = 1;
&DOCUMENT; TEXT(&beginproblem);
$b = non_zero_random(-20,20);
TEXT(EV2(<<EOT));
Find nonzero values of (a) and (r) so that the sequence \[ sum_{n=0}^\infty a r^n \] converges to $b. $BR $BR
\(a=\)\{ans_rule(5) \} $BR
\(r=\)\{ans_rule(5)\} $BR EOT
$a1=@submittedAnswers[0]; ## this grabs the strings they submitted $r1=@submittedAnswers[1];
$a=eval($a1); ## this converts those strings into numeric values to compute with $r=eval($r1);
if (($r <= -1) or ($r >= 1)) { &ANS(std_num_cmp_list(.01,"",$b*(1-($r)),0)); } else { if ($r==0) { &ANS(std_num_cmp_list(.01,"",$b*(1-($r)),1)); } else { &ANS(std_num_cmp_list(.01,"",$b*(1-($r)),1-($a/$b))); } }
&ENDDOCUMENT
<| Post or View Comments |>
|