Diff for /loncom/homework/default_homework.lcpm between versions 1.98 and 1.102

version 1.98, 2005/03/31 17:12:37 version 1.102, 2005/08/02 18:47:24
Line 89  sub caparesponse_check { Line 89  sub caparesponse_check {
     } else {      } else {
  $message .="no ws in :$response:\n";   $message .="no ws in :$response:\n";
     }      }
     if ($type eq 'cs' || $type eq 'ci' || $type eq 'mc') {      &LONCAPA_INTERNAL_DEBUG(" type is $type ");
       if ($type eq 'cs' || $type eq 'ci') {
  #for string answers make surec all places spaces occur, there is    #for string answers make surec 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;
       } elsif ($type eq 'mc') {
    $answer=~s/[\s,]//g;
    $response=~s/[\s,]//g;
     }      }
     if ($type eq 'float' && $unit=~/\$/) {      if ($type eq 'float' && $unit=~/\$/) {
  if ($response!~/^\$/)  { return "NO_UNIT: Missing \$ "; }   if ($response!~/^\$/)  { return "NO_UNIT: Missing \$ "; }
Line 518  sub format { Line 522  sub format {
     #if ($options =~ /\$/) { $dollamode=1; }      #if ($options =~ /\$/) { $dollamode=1; }
     #if ($options =~ /,/)  { $commamode=1; }      #if ($options =~ /,/)  { $commamode=1; }
     if ($options =~ /\./) { $alwaysperiod=1; }      if ($options =~ /\./) { $alwaysperiod=1; }
       my $result;
     if ($fmt=~/s$/i) {      if ($fmt=~/s$/i) {
  $result=&format_significant_figures($value,$fmt);   $result=&format_significant_figures($value,$fmt);
     } else {      } else {
  $fmt=~s/e/E/g;   $fmt=~s/e/E/g;
  my $result=sprintf('%.'.$fmt,$value);   $result=sprintf('%.'.$fmt,$value);
  if ($alwaysperiod && $fmt eq '0f') { $result .='.'; }   if ($alwaysperiod && $fmt eq '0f') { $result .='.'; }
  $result=~s/(E[+-]*)0/$1/;   $result=~s/(E[+-]*)0/$1/;
     }      }
Line 632  sub prettyprint { Line 637  sub prettyprint {
 sub commaformat {  sub commaformat {
     my ($number,$target) = @_;      my ($number,$target) = @_;
     if ($number =~ /\./) {      if ($number =~ /\./) {
  while ($number =~ /([^\.,]+)([^\.,][^\.,][^\.,])([,0-9]*\.[0-9]*)$/) {   while ($number =~ /([^0-9]*)([0-9]+)([^\.,][^\.,][^\.,])([,0-9]*\.[0-9]*)$/) {
     $number = $1.','.$2.$3;      $number = $1.$2.','.$3.$4;
  }   }
     } else {      } else {
  while ($number =~ /([^,]+)([^,][^,][^,])([,0-9]*)$/) {   while ($number =~ /^([^0-9]*)([0-9]+)([^,][^,][^,])([,0-9]*)$/) {
     $number = $1.','.$2.$3;      $number = $1.$2.','.$3.$4;
  }   }
     }      }
     return $number;      return $number;
Line 885  sub choose { Line 890  sub choose {
     return $_[$num];      return $_[$num];
 }  }
   
   #&sum1(1,$x,sub { &sum1($_[0],2*$_[0], sub { fact($_[0])**2 })});
   #sub sum1 {
   #    my ($start,$end,$sub)=@_;
   #    my $sum=0;
   #    for (my $i=$start;$i<=$end;$i++) {
   #        $sum+=&$sub($i);
   #    }
   #    return $sum
   #}
   
   #&sum2('a',1,$x,'&sum2(\'b\',$a,2*$a, \'&factorial($b)**2\')');
   #sub sum2 {
   #    my ($varname,$start,$end,$line)=@_;
   #    my $sum=0;
   #    for (my $i=$start;$i<=$end;$i++) {
   # my $func=sub {
   #    eval("\$".$varname."=$i");
   #    eval($line);
   # };
   #        $sum+=&$func($i);
   #    }
   #    return $sum
   #}
   
 # expiremental idea  # expiremental idea
 sub proper_path {  sub proper_path {
     my ($path)=@_;      my ($path)=@_;

Removed from v.1.98  
changed lines
  Added in v.1.102


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