version 1.125, 2008/03/03 19:14:51
|
version 1.132, 2008/03/06 14:04:09
|
Line 157 sub caparesponse_check {
|
Line 157 sub caparesponse_check {
|
|
|
#&LONCAPA_INTERNAL_DEBUG(" type is $type "); |
#&LONCAPA_INTERNAL_DEBUG(" type is $type "); |
if ($type eq 'cs' || $type eq 'ci') { |
if ($type eq 'cs' || $type eq 'ci') { |
#for string answers make surec all places spaces occur, there is |
#for string answers make sure 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; |
Line 166 sub caparesponse_check {
|
Line 166 sub caparesponse_check {
|
$response=~s/[\s,]//g; |
$response=~s/[\s,]//g; |
} |
} |
if ($type eq 'float' && $unit=~/\$/) { |
if ($type eq 'float' && $unit=~/\$/) { |
if ($response!~/^\$/) { return ('NO_UNIT', undef); } |
if ($response!~/^\$|\$$/) { return ('NO_UNIT', undef); } |
$response=~s/\$//g; |
$response=~s/\$//g; |
} |
} |
if ($type eq 'float' && $unit=~/\,/ && (&check_commas($response)<0)) { |
if ($type eq 'float' && $unit=~/\,/ && (&check_commas($response)<0)) { |
Line 310 sub caparesponse_check_list {
|
Line 310 sub caparesponse_check_list {
|
my $unit; |
my $unit; |
if ($type eq '' || $type eq 'float') { |
if ($type eq '' || $type eq 'float') { |
#for numerical problems split off the unit |
#for numerical problems split off the unit |
if ( $responses->[0][-1]=~ /(.*[^\s])\s+([^\s]+)/ ) { |
# if ( $responses->[0][-1]=~ /(.*[^\s])\s+([^\s]+)/ ) { |
|
if ( $responses->[0][-1]=~ /^([\d\.\,\s\$]*(?:(?:[xX\*]10[\^\*]*|[eE]*)[\+\-]*\d*)*(?:^|\S)\d+)([\$\s\w\^\*\/\(\)\+\-]*[^\d\.\s\,][\$\s\w\^\*\/\(\)\+\-]*)$/ ) { |
$responses->[0][-1]=$1; |
$responses->[0][-1]=$1; |
$unit=$2; |
$unit=&capa_formula_fix($2); |
|
&LONCAPA_INTERNAL_DEBUG("Found unit :$unit:"); |
} |
} |
} |
} |
&LONCAPA_INTERNAL_DEBUG("Final final response :$responses->[0][-1]:$unit:"); |
&LONCAPA_INTERNAL_DEBUG("Final final response :$responses->[0][-1]:$unit:"); |
$unit=~s/\s//; |
$unit=~s/\s//; |
if ($unit ne '') { |
if ($unit ne '') { |
foreach my $response (@$responses) { |
foreach my $response (@$responses) { |
foreach my $element (@$response) { |
foreach my $element (@$response) { |
$element .= " $unit"; |
$element =~ s/\s//g; |
|
my $appendunit=$unit; |
|
if ($unit=~/\%/) { |
|
$element=$element/100; |
|
$appendunit=~s/\%//; |
|
} |
|
$element .= " $appendunit"; |
|
&LONCAPA_INTERNAL_DEBUG("Made response element :$element:"); |
} |
} |
} |
} |
} |
} |