Hi,

I'm at the point where I need to write custom answer checkers for my questions, but I need help.

Here is what I want to do: I want the student to use the comparison test to check the convergence/divergence of a series. However, I want to see if they are using the comparison test correctly. So, I want to perform two checks:

First, I want to check to see that their comparison function is of the right type. For example, if the series terms are (n^2+1)/(n^5-3), they should be comparing with c/n^3 for some c. The easiest thing that I can think of is to divide my comparison function into the student's and see if it is constant. That's no problem. (If there's an easier way I haven't thought of, let me know.)

Second, I need to see whether the student's function is an upper (or lower) bound of the original series. This means I need to compare it with the original.

Hence, I need to compare the student's answer against *two* different functions in two different ways. That's not a problem, except when I write a custom answer checker, I can only pass one formula to it. And the answer checker has no knowledge of anything I've defined in the file (outside the checker).

Am I getting too ambitious here? Or is there an easy way to do this? Is it possible to pass a list, each entry of which is a Mathobjects formula?

I thought of passing variables to the routine, but the variable seem to be fixed.

Sorry if this is yet another stupid question.

Steve McKay

`c/n^3`

would be to use c as an adaptive parameter (though you probably want to check that it is non-zero, but you would need to check that with your method as well).
As for passing more than one function to the custom checker, that can be done in several ways. The easiest way is just to use a global variable for one formula, since that would be available to any code that runs (including the checker).

For example:

Context("Numeric")->variables->are( n => 'Real', c => 'Parameter' ); $f = Formula("c/n^3"); $g = Formula("(n^2+1)/(n^5-3)"); ... ANS($f->cmp(checker => sub { my ($correct,$student,$hash) = @_; # $correct will be $f return ($correct == $student) && Context()->variables->get('c')->{value} != 0 && (do check with $g here); });

I'm not sure what check you want to do with `$g`

, but you can simply refer to it in the code for the checker.

Alternatively, you could pass a parameter to the checker via the answer hash:

ANS($f->cmp(g=>Formula("n/(n+1)"), checker => sub { my ($correct,$student,$hash) = @_; my $g = $hash->{g}; ... });

Hope that helps.

Davide

Hmmm. I thought I had tried this. The formula was declared globally but the checker had problems finding it. I'll play with this some more.

Thanks for your help.

S.M>

Just to add my two cents, if the series terms are (n^2+1)/(n^5-3), I would think it would be easier to compare this to the series with terms 1/n^2 or in fact 1/n^r for any r, 1<r<3. And I would have a hard time marking them wrong if they did so.

Arnie