version 1.152.2.3, 2012/11/22 02:15:42
|
version 1.163, 2013/01/21 06:16:50
|
Line 253 sub caparesponse_check {
|
Line 253 sub caparesponse_check {
|
elsif ($result =='15') { $result='UNIT_IRRECONCIBLE'; } |
elsif ($result =='15') { $result='UNIT_IRRECONCIBLE'; } |
else {$result = "ERROR: Unknown Result:$result:$@:";} |
else {$result = "ERROR: Unknown Result:$result:$@:";} |
|
|
# &LONCAPA_INTERNAL_DEBUG("RetError $reterror: Answer $answer: Response $response: type-$type|$tol|$tol_type|$sig:$sig_lbound:$sig_ubound|$unit|"); |
|
# &LONCAPA_INTERNAL_DEBUG(" $answer $response $result "); |
|
return ($result,$reterror); |
return ($result,$reterror); |
} |
} |
|
|
Line 265 sub caparesponse_check_list {
|
Line 263 sub caparesponse_check_list {
|
my $type = $LONCAPA::CAPAresponse_args{'type'}; |
my $type = $LONCAPA::CAPAresponse_args{'type'}; |
my $answerunit=$LONCAPA::CAPAresponse_args{'unit'}; |
my $answerunit=$LONCAPA::CAPAresponse_args{'unit'}; |
&LONCAPA_INTERNAL_DEBUG("Got type :$type: answer unit :$answerunit:\n"); |
&LONCAPA_INTERNAL_DEBUG("Got type :$type: answer unit :$answerunit:\n"); |
|
|
my $preprocess=$LONCAPA::CAPAresponse_args{'preprocess'}; |
my $preprocess=$LONCAPA::CAPAresponse_args{'preprocess'}; |
$preprocess=~s/^\&//; |
$preprocess=~s/^\&//; |
|
|
Line 309 sub caparesponse_check_list {
|
Line 307 sub caparesponse_check_list {
|
my ($allowalgebra)=($LONCAPA::CAPAresponse_args{'allowalgebra'}=~/^(yes|1|on)$/i); |
my ($allowalgebra)=($LONCAPA::CAPAresponse_args{'allowalgebra'}=~/^(yes|1|on)$/i); |
if ($type eq 'float' || $type eq '') { |
if ($type eq 'float' || $type eq '') { |
#for numerical problems split off the unit |
#for numerical problems split off the unit |
my ($part1,$part2); |
my $part1; |
|
my $part2; |
if ($allowalgebra) { |
if ($allowalgebra) { |
($part1,$part2)=($responses->[0][-1]=~ /^(.*[^\s])\s+([^\s]+)$/); |
($part1,$part2)=($responses->[0][-1]=~ /^(.*[^\s])\s+([^\s]+)$/); |
} else { |
} else { |
($part1,$part2)=($responses->[0][-1]=~ /^([\d\.\,\s\$]*(?:(?:[xX\*]10[\^\*]*|[eE]*)[\+\-]*\d*)*(?:^|\S)\d+)([\$\s\w\^\*\/\(\)\+\-]*[^\d\.\s\,][\$\s\w\^\*\/\(\)\+\-]*)$/); |
($part1,$part2)=($responses->[0][-1]=~ /^([\d\.\,\s\$]*(?:(?:[xX\*]10[\^\*]*|[eE]*)[\+\-]*\d*)*(?:^|\S)\d+)([\$\s\w\^\*\/\(\)\+\-]*[^\d\.\s\,][\$\s\w\^\*\/\(\)\+\-]*)$/); |
} |
} |
Line 1034 sub format_significant_figures {
|
Line 1033 sub format_significant_figures {
|
$number = abs($number); |
$number = abs($number); |
# needed to correct for a number greater than 1 (or |
# needed to correct for a number greater than 1 (or |
my $power = ($number < 1) ? 0 : 1; |
my $power = ($number < 1) ? 0 : 1; |
|
if ($power && $number =~ /^\d+$/) { |
|
my $nonzeros = $number; |
|
$nonzeros =~ s/0+$//; |
|
if (length($number) - length($nonzeros) > 1) { |
|
# convert to exponential form |
|
my $n = $sig-1; |
|
my $numSig = sprintf('%.' . $n . 'E', $number); |
|
# return number with sign |
|
return $sign.$numSig; |
|
} |
|
} |
# could round up. Take the integer part of log10. |
# could round up. Take the integer part of log10. |
my $x10 = int(log($number)/log(10)); |
my $x10 = int(log($number)/log(10)); |
# find number with values left of decimal pt = # of sign figs. |
# find number with values left of decimal pt = # of sign figs. |
Line 1184 sub middlename {
|
Line 1194 sub middlename {
|
$middlename = '' if $middlename eq ""; |
$middlename = '' if $middlename eq ""; |
return $middlename; |
return $middlename; |
} |
} |
|
|
sub lastname { |
sub lastname { |
my $lastname = &EXT('environment.lastname'); |
my $lastname = &EXT('environment.lastname'); |
$lastname = '' if $lastname eq ""; |
$lastname = '' if $lastname eq ""; |