--- loncom/homework/default_homework.lcpm 2011/06/07 22:07:09 1.156 +++ loncom/homework/default_homework.lcpm 2011/06/08 01:39:28 1.157 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # used by lonxml::xmlparse() as input variable $safeinit to Apache::run::run() # -# $Id: default_homework.lcpm,v 1.156 2011/06/07 22:07:09 www Exp $ +# $Id: default_homework.lcpm,v 1.157 2011/06/08 01:39:28 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -270,7 +270,10 @@ sub caparesponse_check_list { my $type = $LONCAPA::CAPAresponse_args{'type'}; my $answerunit=$LONCAPA::CAPAresponse_args{'unit'}; &LONCAPA_INTERNAL_DEBUG("Got type :$type: answer unit :$answerunit:\n"); - + + my $preprocess=$LONCAPA::CAPAresponse_args{'preprocess'}; + $preprocess=~s/^\&//; + my $num_input_lines = scalar(@{$LONCAPA::CAPAresponse_answer->{'answers'}}); @@ -319,7 +322,7 @@ sub caparesponse_check_list { } else { ($part1,$part2)=($responses->[0][-1]=~ /^([\d\.\,\s\$]*(?:(?:[xX\*]10[\^\*]*|[eE]*)[\+\-]*\d*)*(?:^|\S)\d+)([\$\s\w\^\*\/\(\)\+\-]*[^\d\.\s\,][\$\s\w\^\*\/\(\)\+\-]*)$/); } - if ($part1 && $part2) { + if (defined($part1) && defined($part2)) { $responses->[0][-1]=$part1; $unit=&capa_formula_fix($part2); &LONCAPA_INTERNAL_DEBUG("Found unit :$unit:"); @@ -329,7 +332,15 @@ sub caparesponse_check_list { $unit=~s/\s//; my $error; foreach my $response (@$responses) { - foreach my $element (@$response) { + foreach my $element (@$response) { + # See if we have preprocessor + if ($preprocess=~/\S/) { + if (defined(&$preprocess)) { + no strict 'refs'; + $element=&$preprocess($element); + use strict 'refs'; + } + } if (($type eq 'float') || (($type eq '') && ($unit ne ''))) { $element =~ s/\s//g; }