Forum archive 2000-2006

Gavin LaRose - correct_ans in hardcopy/new answer evaluators

Gavin LaRose - correct_ans in hardcopy/new answer evaluators

by Arnold Pizer -
Number of replies: 0
inactiveTopiccorrect_ans in hardcopy/new answer evaluators topic started 8/23/2005; 2:45:39 PM
last post 8/23/2005; 2:45:39 PM
userGavin LaRose - correct_ans in hardcopy/new answer evaluators  blueArrow
8/23/2005; 2:45:39 PM (reads: 281, responses: 0)
Hi all,

I'm messing around with creating an answer evaluator and am having trouble with the correct answer that is showing up in the hardcopy. The evaluator is horribly simplistic, and takes an answer, split()s it and then tests the various parts with different num_cmp() and str_cmp() evaluators. Thus the final result is the ANDed output of the AnswerHashes produced by the num_cmp() and str_cmp() evaluators.

Very approximately, this gives something like the following:

sub new_cmp { 
my $cAns = shift();
my %opts = @_;



my @pts = split(/s*,s*/, $cAns);



my @xeval; my @ceval;
foreach ( @pts ) {
my ( $x, $c ) = split(/s*=s*/);
push( @xeval, num_cmp( $x, %opts ) );
push( @ceval, str_cmp( $c ) );
}



return( sub {
my $sAns = shift();
my @sAnsList = split(/s*,s*/, $sAns);
my @sAnsw = ();
foreach ( @sAnsList ) {
my ( $x, $c ) = split(/s*=s*/);
$x = 'none' if ( ! defined( $x ) );
$c = '' if ( ! defined( $c ) );
push( @sAnsw, [ $x, $c ] );
}



my $endres;
for(my $i=0; $i<@sAnsw; $i++) {
my $xres = $xeval[$i]->evaluate($sAnsw[$i]->[0]);
my $cres = $ceval[$i]->evaluate($sAnsw[$i]->[1]);
if ( $i==0 ) {
$endres = $xres->AND($cres);
} else {
$endres = $endres->AND($xres->AND($cres));
}
}



return $endres;
}
}

This works fine when working on-line, but when I generate a hardcopy including the correct answer, the answer 'No correct answer specified' is returned. This appears to be the value of $endres->{correct_ans}, which confuses me, because it shows up fine in the preview of the correct answer on-line.

Can someone enlighten me on this?

Thanks, Gavin

<| Post or View Comments |>