version 1.98, 2005/03/31 17:12:37
|
version 1.100, 2005/06/17 20:24:56
|
Line 89 sub caparesponse_check {
|
Line 89 sub caparesponse_check {
|
} else { |
} else { |
$message .="no ws in :$response:\n"; |
$message .="no ws in :$response:\n"; |
} |
} |
if ($type eq 'cs' || $type eq 'ci' || $type eq 'mc') { |
&LONCAPA_INTERNAL_DEBUG(" type is $type "); |
|
if ($type eq 'cs' || $type eq 'ci') { |
#for string answers make surec all places spaces occur, there is |
#for string answers make surec all places spaces occur, there is |
#really only 1 space, in both the answer and the response |
#really only 1 space, in both the answer and the response |
$answer=~s/ +/ /g; |
$answer=~s/ +/ /g; |
$response=~s/ +/ /g; |
$response=~s/ +/ /g; |
|
} elsif ($type eq 'mc') { |
|
$answer=~s/[\s,]//g; |
|
$response=~s/[\s,]//g; |
} |
} |
if ($type eq 'float' && $unit=~/\$/) { |
if ($type eq 'float' && $unit=~/\$/) { |
if ($response!~/^\$/) { return "NO_UNIT: Missing \$ "; } |
if ($response!~/^\$/) { return "NO_UNIT: Missing \$ "; } |
Line 518 sub format {
|
Line 522 sub format {
|
#if ($options =~ /\$/) { $dollamode=1; } |
#if ($options =~ /\$/) { $dollamode=1; } |
#if ($options =~ /,/) { $commamode=1; } |
#if ($options =~ /,/) { $commamode=1; } |
if ($options =~ /\./) { $alwaysperiod=1; } |
if ($options =~ /\./) { $alwaysperiod=1; } |
|
my $result; |
if ($fmt=~/s$/i) { |
if ($fmt=~/s$/i) { |
$result=&format_significant_figures($value,$fmt); |
$result=&format_significant_figures($value,$fmt); |
} else { |
} else { |
$fmt=~s/e/E/g; |
$fmt=~s/e/E/g; |
my $result=sprintf('%.'.$fmt,$value); |
$result=sprintf('%.'.$fmt,$value); |
if ($alwaysperiod && $fmt eq '0f') { $result .='.'; } |
if ($alwaysperiod && $fmt eq '0f') { $result .='.'; } |
$result=~s/(E[+-]*)0/$1/; |
$result=~s/(E[+-]*)0/$1/; |
} |
} |