Diff for /loncom/homework/caparesponse/caparesponse.pm between versions 1.108 and 1.112

version 1.108, 2003/08/21 17:33:22 version 1.112, 2003/09/22 18:47:59
Line 171  sub end_numericalresponse { Line 171  sub end_numericalresponse {
  my $status = $Apache::inputtags::status['-1'];   my $status = $Apache::inputtags::status['-1'];
  if (   ($award =~ /^correct/   if (   ($award =~ /^correct/
                 && lc($Apache::lonhomework::problemstatus) ne 'no')                  && lc($Apache::lonhomework::problemstatus) ne 'no')
              || $status eq "SHOW_ANSWER"         || $status eq "SHOW_ANSWER") {
              || $ENV{'form.texaward'} eq 'SHOW_ANSWER') {  
     my (@formats)=&Apache::lonxml::get_param_var('format',$parstack,      my (@formats)=&Apache::lonxml::get_param_var('format',$parstack,
  $safeeval);   $safeeval);
     my $unit=&Apache::lonxml::get_param_var('unit',$parstack,      my $unit=&Apache::lonxml::get_param_var('unit',$parstack,
     $safeeval);      $safeeval);
     if ($target eq 'web') {      if ($target eq 'web') {
  $result="<br />The correct answer is ";   $result="<br />The correct answer is ";
     } elsif ($target eq 'tex') {  
  if ($ENV{'form.texaward'} eq 'SHOW_ANSWER') {  
     $result='\vskip 0 mm The correct answer is \\texttt{ ';  
  }  
     }      }
     for (my $i=0; $i <= $#answers; $i++) {      for (my $i=0; $i <= $#answers; $i++) {
  my $answer=$answers[$i];   my $answer=$answers[$i];
Line 194  sub end_numericalresponse { Line 189  sub end_numericalresponse {
  }   }
  my $formatted;   my $formatted;
  if ((defined($format)) && ($format ne '')) {   if ((defined($format)) && ($format ne '')) {
       $format=~s/e/E/g;
     &Apache::lonxml::debug("formatting with :$format: answer :$answer:");      &Apache::lonxml::debug("formatting with :$format: answer :$answer:");
     $formatted=sprintf('%.'.$format,$answer).',';      $formatted=sprintf('%.'.$format,$answer).',';
  } else {   } else {
     &Apache::lonxml::debug("no format answer :$answer:");      &Apache::lonxml::debug("no format answer :$answer:");
     $formatted="$answer,";      $formatted="$answer,";
  }   }
  if ($ENV{'form.texaward'} eq 'SHOW_ANSWER') {  
     $result.=$formatted;  
  }  
  if ($target eq 'tex') {   if ($target eq 'tex') {
     $formatted='';      $formatted='';
     #$formatted=&Apache::lonxml::latex_special_symbols($formatted);      #$formatted=&Apache::lonxml::latex_special_symbols($formatted);
Line 212  sub end_numericalresponse { Line 205  sub end_numericalresponse {
     chop $result;      chop $result;
     if ($target eq 'web') {      if ($target eq 'web') {
  $result.=" $unit.<br />";   $result.=" $unit.<br />";
     } elsif ($target eq 'tex') {  
  if ($ENV{'form.texaward'} eq 'SHOW_ANSWER') {  
     $result.=&Apache::lonxml::latex_special_symbols($unit);  
     $result.="}. \\vskip 0 mm ";  
  }  
     }      }
  }   }
  if ($Apache::lonhomework::type eq 'exam') {   if ($Apache::lonhomework::type eq 'exam') {
Line 314  sub end_numericalresponse { Line 302  sub end_numericalresponse {
  ($sighigh,$siglow)=&get_sigrange($Apache::inputtags::params{'sig'});   ($sighigh,$siglow)=&get_sigrange($Apache::inputtags::params{'sig'});
     }      }
     if ($fmt && $$tagstack[-1] eq 'numericalresponse') {      if ($fmt && $$tagstack[-1] eq 'numericalresponse') {
    $fmt=~s/e/E/g;
  $ans = sprintf('%.'.$fmt,$ans);   $ans = sprintf('%.'.$fmt,$ans);
  if ($high) {   if ($high) {
     $high=sprintf('%.'.$fmt,$high);      $high=sprintf('%.'.$fmt,$high);
Line 416  sub format_number { Line 405  sub format_number {
     my ($number,$format,$target)=@_;      my ($number,$format,$target)=@_;
     my $ans;      my $ans;
     if ($format ne '') {      if ($format ne '') {
    $format=~s/e/E/g;
  $ans = sprintf('%.'.$format,$number);   $ans = sprintf('%.'.$format,$number);
     } else {      } else {
  my $format = '';   my $format = '';
  #What is the number? (integer,decimal,floating point)   #What is the number? (integer,decimal,floating point)
  if ($number=~/^(\d*\.?\d*)(E|e)(\d*)$/) {   if ($number=~/^(\d*\.?\d*)(E|e)(\d*)$/) {
     $format = 'e'.$2;      if (abs($3)>=100) {$format = 'e3';} else {$format = 'e2';}
  } elsif ($number=~/^(\d*)\.(\d*)$/) {   } elsif ($number=~/^(\d*)\.(\d*)$/) {
     $format = '4f';      $format = '4f';
  } elsif ($number=~/^(\d*)$/) {   } elsif ($number=~/^(\d*)$/) {

Removed from v.1.108  
changed lines
  Added in v.1.112


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