version 1.159, 2011/06/09 15:43:56
|
version 1.166, 2014/06/24 18:02:47
|
Line 318 sub caparesponse_check_list {
|
Line 318 sub caparesponse_check_list {
|
$responses->[0][-1]=$part1; |
$responses->[0][-1]=$part1; |
$unit=&capa_formula_fix($part2); |
$unit=&capa_formula_fix($part2); |
my $customunits=$LONCAPA::CAPAresponse_args{'customunits'}; |
my $customunits=$LONCAPA::CAPAresponse_args{'customunits'}; |
foreach my $replacement (split(/\s*\,\s*/,$customunits)) { |
if ($customunits =~ /\S/) { |
my ($which,$what)=split(/\s*\=\s*/,$replacement); |
foreach my $replacement (split(/\s*\,\s*/,$customunits)) { |
if ((defined($which)) && (defined($what))) { |
my ($which,$what)=split(/\s*\=\s*/,$replacement); |
$what=&capa_formula_fix($what); |
if ((defined($which)) && (defined($what))) { |
$unit=~s/$which/\($what\)/g; |
$what=&capa_formula_fix($what); |
|
$unit=~s/$which/\($what\)/g; |
|
} |
} |
} |
} |
} |
} |
} |
Line 357 sub caparesponse_check_list {
|
Line 359 sub caparesponse_check_list {
|
$appendunit='%'.$appendunit; |
$appendunit='%'.$appendunit; |
} |
} |
# Zero does not need a dimension |
# Zero does not need a dimension |
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 |
# Do the math for the student if allowed |
Line 814 sub cos { CORE::cos(shift) }
|
Line 816 sub cos { CORE::cos(shift) }
|
sub exp { CORE::exp(shift) } |
sub exp { CORE::exp(shift) } |
sub int { CORE::int(shift) } |
sub int { CORE::int(shift) } |
sub log { CORE::log(shift) } |
sub log { CORE::log(shift) } |
|
sub ln { CORE::log(shift) } |
sub atan2 { CORE::atan2($_[0],$_[1]) } |
sub atan2 { CORE::atan2($_[0],$_[1]) } |
sub sqrt { CORE::sqrt(shift) } |
sub sqrt { CORE::sqrt(shift) } |
|
|
Line 1040 sub format_significant_figures {
|
Line 1043 sub format_significant_figures {
|
my ($zeros) = ($xint =~ /(0+)$/); |
my ($zeros) = ($xint =~ /(0+)$/); |
# return number to original magnitude |
# return number to original magnitude |
my $numSig = $xint*10**($x10-$sig+$power); |
my $numSig = $xint*10**($x10-$sig+$power); |
# insert trailing zero's if have decimal point |
if ($numSig =~ /^(\d+)\.(\d+)/) { |
$numSig =~ s/^(\d+)\.(\d+)(\e?(.*)?)$/$1\.$2$zeros$3/; |
# insert trailing zero's if have decimal point |
# put a decimal pt for number ending with 0 and length = # of sig fig |
my @digarray = split('',$1.$2); |
$numSig.='.' if (length($numSig) == $sig && $numSig =~ /0$/); |
my $sigcount; |
if (length($numSig) < $sig) { |
while (@digarray > 0) { |
$numSig.='.'.substr($zeros,0,($sig-length($numSig))); |
my $item = shift(@digarray); |
|
if ($item) { |
|
$sigcount = 1 + @digarray; |
|
last; |
|
} |
|
} |
|
if (($sigcount) && ($sig >= $sigcount)) { |
|
$zeros = substr($zeros,0,($sig - $sigcount)); |
|
} |
|
$numSig =~ s/^(\d+)\.(\d+)(\e?(.*)?)$/$1\.$2$zeros$3/; |
|
} else { |
|
if ($numSig =~ /0$/) { |
|
# add decimal pt for number ending with 0 and length == # of sig figs |
|
if (length($numSig) == $sig) { |
|
$numSig.='.'; |
|
} elsif (length($numSig) > $sig) { |
|
# exponential form for number ending with 0 and length > # of sig figs |
|
my $fmtsig = $sig-1; |
|
if ($fmtsig) { |
|
$numSig = sprintf('%.'.$fmtsig.'e',$numSig); |
|
} |
|
} |
|
} |
|
if (length($numSig) < $sig) { |
|
$numSig.='.'.substr($zeros,0,($sig-length($numSig))); |
|
} |
} |
} |
# return number with sign |
# return number with sign |
return $sign.$numSig; |
return $sign.$numSig; |
|
|
} |
} |
|
|
sub map { |
sub map { |
Line 1181 sub middlename {
|
Line 1208 sub middlename {
|
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 ""; |
Line 1195 sub sec {
|
Line 1221 sub sec {
|
} |
} |
|
|
sub submission { |
sub submission { |
my ($partid,$responseid,$subnumber)=@_; |
my ($partid,$responseid,$subnumber,$encode)=@_; |
my $sub=''; |
my $sub=''; |
if ($subnumber) { $sub=$subnumber.':'; } |
if ($subnumber) { $sub=$subnumber.':'; } |
return &EXT('user.resource.'.$sub.'resource.'.$partid.'.'.$responseid.'.submission'); |
my $output = |
|
&EXT('user.resource.'.$sub.'resource.'.$partid.'.'.$responseid.'.submission'); |
|
if ($encode) { |
|
$output =~ s/&/&/g; |
|
$output =~ s/</</g; |
|
$output =~ s/>/>/g; |
|
$output =~ s/"/"/g; |
|
} |
|
return $output; |
} |
} |
|
|
sub currentpart { |
sub currentpart { |