--- loncom/homework/default_homework.lcpm 2001/07/19 21:26:22 1.31
+++ loncom/homework/default_homework.lcpm 2001/07/23 22:40:59 1.32
@@ -25,10 +25,19 @@ sub caparesponse_check {
my $calc='';
my ($response,$expr)=@_;
+
($answer,$type,$tol,$sig,$ans_fmt,
$unit,$calc) = eval $expr.';return ($answer,$type,$tol,$sig,$ans_fmt,$unit,$calc);';
#type's definitons come from capaParser.h
my $message='';
+ #remove leading and trailing whitespace
+ if ($response=~ /^\s|\s$/) {
+ $response=~ s:^\s+|\s+$::g;
+ $message .="Removed ws now :$response:
";
+ } else {
+ $message .="no ws in :$response:
";
+ }
+
if ($type eq '' ) {
$message .= "Didn't find a type :$type:$expr: defaulting
";
if ( $answer eq ($answer *1.0)) { $type = 2;
@@ -99,6 +108,7 @@ sub caparesponse_check_list {
my $current_answer;
$result.="Got response :$CAPARESPONSE_CHECK_LIST_answer:$list[0]:
";
my @responselist;
+ my $type =eval $expr.';return $answer;';
if ($type ne '' && $#list > 0) {
(@responselist)=split /,/,$response;
} else {