version 1.154, 2011/05/21 14:50:36
|
version 1.156, 2011/06/07 22:07:09
|
Line 309 sub caparesponse_check_list {
|
Line 309 sub caparesponse_check_list {
|
|
|
&LONCAPA_INTERNAL_DEBUG("Initial final response :$responses->[0][-1]:"); |
&LONCAPA_INTERNAL_DEBUG("Initial final response :$responses->[0][-1]:"); |
my $unit; |
my $unit; |
|
my ($allowalgebra)=(¶meter_setting('allowalgebra',¤tpart())=~/^(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 |
# if ( $responses->[0][-1]=~ /(.*[^\s])\s+([^\s]+)/ ) { |
my $part1; |
if ( $responses->[0][-1]=~ /^([\d\.\,\s\$]*(?:(?:[xX\*]10[\^\*]*|[eE]*)[\+\-]*\d*)*(?:^|\S)\d+)([\$\s\w\^\*\/\(\)\+\-]*[^\d\.\s\,][\$\s\w\^\*\/\(\)\+\-]*)$/ ) { |
my $part2; |
$responses->[0][-1]=$1; |
if ($allowalgebra) { |
$unit=&capa_formula_fix($2); |
($part1,$part2)=($responses->[0][-1]=~ /^(.*[^\s])\s+([^\s]+)$/); |
|
} else { |
|
($part1,$part2)=($responses->[0][-1]=~ /^([\d\.\,\s\$]*(?:(?:[xX\*]10[\^\*]*|[eE]*)[\+\-]*\d*)*(?:^|\S)\d+)([\$\s\w\^\*\/\(\)\+\-]*[^\d\.\s\,][\$\s\w\^\*\/\(\)\+\-]*)$/); |
|
} |
|
if ($part1 && $part2) { |
|
$responses->[0][-1]=$part1; |
|
$unit=&capa_formula_fix($part2); |
&LONCAPA_INTERNAL_DEBUG("Found unit :$unit:"); |
&LONCAPA_INTERNAL_DEBUG("Found unit :$unit:"); |
} |
} |
} |
} |
Line 344 sub caparesponse_check_list {
|
Line 351 sub caparesponse_check_list {
|
if (($element==0) && ($unit!~/\w/) && ($answerunit=~/\w/)) { |
if (($element==0) && ($unit!~/\w/) && ($answerunit=~/\w/)) { |
$appendunit=$answerunit; |
$appendunit=$answerunit; |
} |
} |
|
# Do the math for the student if allowed |
|
if ($allowalgebra) { |
|
$element=&cas('maxima',$element); |
|
} |
if ($appendunit ne '') { |
if ($appendunit ne '') { |
$element .= " $appendunit"; |
$element .= " $appendunit"; |
} |
} |
Line 1221 sub stored_data {
|
Line 1232 sub stored_data {
|
return &EXT('user.resource.resource.'.$partid.'.'.$which); |
return &EXT('user.resource.resource.'.$partid.'.'.$which); |
} |
} |
|
|
|
sub wrong_bubbles { |
|
my ($correct,$lower,$upper,$step,@given)=@_; |
|
my @array=(); |
|
my %hash=(); |
|
foreach my $new (@given) { |
|
$hash{$new}=1; |
|
} |
|
my $num=int(¶meter_setting('numbubbles',¤tpart())); |
|
unless ($num) { $num=8; } |
|
if ($num>1) { |
|
for (my $i=0;$i<=500;$i++) { |
|
my $new=&random($lower,$upper,$step); |
|
if ($hash{$new}) { next; } |
|
if (abs($new-$correct)<$step) { next; } |
|
$hash{$new}=1; |
|
@array=keys(%hash); |
|
if ($#array+2>=$num) { last; } |
|
} |
|
} |
|
return @array; |
|
} |
|
|
sub array_moments { |
sub array_moments { |
my @input=@_; |
my @input=@_; |
my (@output,$N); |
my (@output,$N); |