From: Mike G. v. a. <we...@ma...> - 2008-04-26 21:30:59
|
Log Message: ----------- Fixed bug that would cause problem with checking previous answers if there was not answer label provided to the answer evaluator. Modified Files: -------------- pg/macros: PGfunctionevaluators.pl Revision Data ------------- Index: PGfunctionevaluators.pl =================================================================== RCS file: /webwork/cvs/system/pg/macros/PGfunctionevaluators.pl,v retrieving revision 1.3 retrieving revision 1.4 diff -Lmacros/PGfunctionevaluators.pl -Lmacros/PGfunctionevaluators.pl -u -r1.3 -r1.4 --- macros/PGfunctionevaluators.pl +++ macros/PGfunctionevaluators.pl @@ -745,17 +745,25 @@ # Get previous answer from hidden field of form # $cmp->install_pre_filter( - sub { - my $rh_ans = shift; - $rh_ans->{_filter_name} = "fetch_previous_answer"; - my $prev_ans_label = "previous_".$rh_ans->{ans_label}; - $rh_ans->{prev_ans} = - (defined $inputs_ref->{$prev_ans_label} and - $inputs_ref->{$prev_ans_label} =~/\S/) ? $inputs_ref->{$prev_ans_label} : undef; - $rh_ans; - } + sub { + my $rh_ans = shift; + $rh_ans->{_filter_name} = "fetch_previous_answer"; + $rh_ans->{prev_ans} = undef; + if ( defined($rh_ans->{ans_label} ) ) { + my $prev_ans_label = "previous_".$rh_ans->{ans_label}; + if ( defined $inputs_ref->{$prev_ans_label} and $inputs_ref->{$prev_ans_label} =~/\S/) { + $rh_ans->{prev_ans} = $inputs_ref->{$prev_ans_label}; + #warn "inputs reference is ", join(" ",%$inputs_ref); + #warn "$prev_ans_label is ",$rh_ans->{prev_ans}; + #FIXME -- previous answer item is not always being updated in inputs_ref (which comes from formField) + } + } + # if no ans_label or previous answer then leave undefined. + $rh_ans; # prev_ans contains previous answer or "undef" + } ); + # # Parse the previous answer, if any # |