Diff for /loncom/homework/default_homework.lcpm between versions 1.161 and 1.167

version 1.161, 2011/10/06 17:15:40 version 1.167, 2014/06/25 10:48:39
Line 816  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 1042  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 =~ /^(\d+)e([\+\-]\d+)$/i) {
               my $pre_exp = $1;
               my $exponent = $2;
               $numSig = $pre_exp.'.'.$zeros.'E'.$exponent;
           } elsif ($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);
                   }
               } elsif (length($numSig) < $sig) {
                   $numSig.='.'.substr($zeros,0,($sig-length($numSig)));
               }
           } else {
               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 1196  sub sec { Line 1228  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/&/&amp;/g;
          $output =~ s/</&lt;/g;
          $output =~ s/>/&gt;/g;
          $output =~ s/"/&quot;/g;
      }
      return $output;
 }  }
   
 sub currentpart {  sub currentpart {

Removed from v.1.161  
changed lines
  Added in v.1.167


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>