Diff for /loncom/homework/default_homework.lcpm between versions 1.83 and 1.90

version 1.83, 2004/05/27 03:46:02 version 1.90, 2004/10/11 16:31:34
Line 41  sub caparesponse_check { Line 41  sub caparesponse_check {
     my $type=$LONCAPA::CAPAresponse_args{'type'};      my $type=$LONCAPA::CAPAresponse_args{'type'};
     my $tol=$LONCAPA::CAPAresponse_args{'tol'};      my $tol=$LONCAPA::CAPAresponse_args{'tol'};
     my $sig=$LONCAPA::CAPAresponse_args{'sig'};      my $sig=$LONCAPA::CAPAresponse_args{'sig'};
     my $ans_fmt=$LONCAPA::CAPAresponse_args{'ans_fmt'};      my $ans_fmt=$LONCAPA::CAPAresponse_args{'format'};
     my $unit=$LONCAPA::CAPAresponse_args{'unit'};      my $unit=$LONCAPA::CAPAresponse_args{'unit'};
     my $calc=$LONCAPA::CAPAresponse_args{'calc'};      my $calc=$LONCAPA::CAPAresponse_args{'calc'};
     my $samples=$LONCAPA::CAPAresponse_args{'samples'};      my $samples=$LONCAPA::CAPAresponse_args{'samples'};
Line 70  sub caparesponse_check { Line 70  sub caparesponse_check {
  $response=~s/ +/ /g;   $response=~s/ +/ /g;
     }      }
     if ($type eq 'float') { $response=~s/,//g; }      if ($type eq 'float') { $response=~s/,//g; }
       if ($type eq 'float' && $ans_fmt=~/\$/) {
    if ($response!~/^\$/)  { return "NO_UNIT: Missing \$ "; }
    $response=~s/\$//g;
       }
       $ans_fmt=~s/\W//g;
   
     if (length($response) > 500) { return "TOO_LONG: Answer too long"; }      if (length($response) > 500) { return "TOO_LONG: Answer too long"; }
   
     if ($type eq '' ) {      if ($type eq '' ) {
Line 106  sub caparesponse_check { Line 112  sub caparesponse_check {
  }   }
     }      }
   
     if ($sig eq '') {      ($sig_ubound,$sig_lbound)=&LONCAPA_INTERNAL_get_sigrange($sig);
  $sig_lbound = 0; #SIG_LB_DEFAULT  
  $sig_ubound =15; #SIG_UB_DEFAULT  
     } else {  
  ($sig_lbound,$sig_ubound) = split /,/,$sig;  
  if (!defined($sig_lbound)) {  
     $sig_lbound = 0; #SIG_LB_DEFAULT  
     $sig_ubound =15; #SIG_UB_DEFAULT  
  }  
  if (!defined($sig_ubound)) { $sig_ubound=$sig_lbound; }  
     }  
     my $reterror="";      my $reterror="";
     my $result = &caparesponse_capa_check_answer($response,$answer,$type,      my $result = &caparesponse_capa_check_answer($response,$answer,$type,
  $tol_type,$tol,   $tol_type,$tol,
Line 242  sub random { Line 239  sub random {
     if ( ! $hidden::RANDOMINIT ) {      if ( ! $hidden::RANDOMINIT ) {
  if ($external::randomseed == 0) { $external::randomseed=1; }   if ($external::randomseed == 0) { $external::randomseed=1; }
  if ($external::randomseed =~/,/) {   if ($external::randomseed =~/,/) {
     my ($num1,$num2)=split(/,/,$seed);      my ($num1,$num2)=split(/,/,$external::randomseed);
       &random_set_seed(1,abs($num1));
    } elsif ($external::randomseed =~/:/) {
       my ($num1,$num2)=split(/:/,$external::randomseed);
     &random_set_seed(abs($num1),abs($num2));      &random_set_seed(abs($num1),abs($num2));
  } else {   } else {
     &random_set_seed(1,int(abs($external::randomseed)));      &random_set_seed(1,int(abs($external::randomseed)));
Line 350  sub random_multivariate_normal { Line 350  sub random_multivariate_normal {
     my ($item_cnt,$seed,$mean,$covar) = @_;      my ($item_cnt,$seed,$mean,$covar) = @_;
     my @oldseed=&random_get_seed();      my @oldseed=&random_get_seed();
     &random_set_seed_from_phrase($seed);      &random_set_seed_from_phrase($seed);
     @retArray=&math_random_multivariate_normal($item_cnt,@$mean,@$covar);      my @retArray=&math_random_multivariate_normal($item_cnt,@$mean,@$covar);
     &random_set_seed(@oldseed);      &random_set_seed(@oldseed);
     return @retArray;      return @retArray;
 }  }
Line 360  sub random_multinomial { Line 360  sub random_multinomial {
     my @oldseed=&random_get_seed();      my @oldseed=&random_get_seed();
     my @retArray;      my @retArray;
     &random_set_seed_from_phrase($seed);      &random_set_seed_from_phrase($seed);
     @retArray=&math_random_multinomial($item_cnt,@p);      my @retArray=&math_random_multinomial($item_cnt,@p);
     &random_set_seed(@oldseed);      &random_set_seed(@oldseed);
     return @retArray;      return @retArray;
 }  }
Line 514  sub chemparse { Line 514  sub chemparse {
     }      }
     next;      next;
  }   }
  $token =~ /^\s*(\d*)(.*)/;   $token =~ /^\s*(\d*(?:&frac\d\d)?)(.*)/;
  $formula .= $1 if ($1 > 1);  # stoichiometric coefficient          $formula .= $1 if ($1 ne '1');  # stoichiometric coefficient
   
  my $molecule = $2;   my $molecule = $2;
  # subscripts   # subscripts
Line 529  sub chemparse { Line 529  sub chemparse {
  $formula .= $molecule.' ';   $formula .= $molecule.' ';
     }      }
     # get rid of trailing space      # get rid of trailing space
     $formula =~ s/(\Q${nbsp}\E| )$//;      $formula =~ s/(\&nbsp\;| )$//;
           
     return &xmlparse($formula);      return &xmlparse($formula);
 }  }
Line 541  sub prettyprint { Line 541  sub prettyprint {
     if ($fmt =~ /chem/i) { return(&chemparse($value)); }      if ($fmt =~ /chem/i) { return(&chemparse($value)); }
     my ($dollarmode,$commamode,$alwaysperiod,$options);      my ($dollarmode,$commamode,$alwaysperiod,$options);
     if ($fmt =~ /^([^\d]*)(.*)/) { $options=$1; $fmt=$2; }       if ($fmt =~ /^([^\d]*)(.*)/) { $options=$1; $fmt=$2; } 
     if ($options =~ /\$/) { $dollamode=1; }      if ($options =~ /\$/) { $dollarmode=1; }
     if ($options =~ /,/)  { $commamode=1; }      if ($options =~ /,/)  { $commamode=1; }
     if ($options =~ /\./) { $alwaysperiod=1; }      if ($options =~ /\./) { $alwaysperiod=1; }
     if ($fmt) { $value=sprintf('%.'.$fmt,$value); }      if ($fmt) { $value=sprintf('%.'.$fmt,$value); }
Line 574  sub prettyprint { Line 574  sub prettyprint {
  }   }
     } else {      } else {
  $result=$value;   $result=$value;
  if ($dollarmode) { $result=&dollarformat($result,$target); }   if    ($dollarmode) { $result=&dollarformat($result,$target); }
  if ($commamode) { $result=&commaformat($result,$target); }   elsif ($commamode)  { $result=&commaformat($result,$target); }
     }      }
     return $result;      return $result;
 }  }

Removed from v.1.83  
changed lines
  Added in v.1.90


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