Diff for /loncom/homework/default_homework.lcpm between versions 1.159 and 1.164

version 1.159, 2011/06/09 15:43:56 version 1.164, 2014/06/16 16:52:50
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 1030  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 1181  sub middlename { Line 1195  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 1208  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.159  
changed lines
  Added in v.1.164


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