Diff for /loncom/homework/caparesponse/caparesponse.pm between versions 1.59 and 1.64

version 1.59, 2002/09/30 16:01:36 version 1.64, 2002/10/04 06:35:28
Line 168  sub end_numericalresponse { Line 168  sub end_numericalresponse {
  my $unit=&Apache::lonxml::get_param_var('unit',$parstack,$safeeval);   my $unit=&Apache::lonxml::get_param_var('unit',$parstack,$safeeval);
   
  if ($target eq 'web') {   if ($target eq 'web') {
   $result="<br />The computer got ";    $result="<br />The correct answer is ";
         } elsif ($target eq 'tex') {          } elsif ($target eq 'tex') {
   $result='\vskip 0 mm The computer got \\texttt{';    $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 220  sub end_numericalresponse { Line 220  sub end_numericalresponse {
  for ($ind=0;$ind<$number_of_bubbles;$ind++) {   for ($ind=0;$ind<$number_of_bubbles;$ind++) {
     $bubbles_values[$ind] = $answers[0]*$factor**($power-$powers[$powers_number-$ind-1]);      $bubbles_values[$ind] = $answers[0]*$factor**($power-$powers[$powers_number-$ind-1]);
  }       }    
    my @alphabet = ('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
    'Q','R','S','T','U','V','W','X','Y','Z');
         if ($target eq 'web') {          if ($target eq 'web') {
     $result.= '<table border="1"><tr>';      $result.= '<table border="1"><tr>';
     for ($ind=0;$ind<$number_of_bubbles;$ind++) {      for ($ind=0;$ind<$number_of_bubbles;$ind++) {
  my $ans = sprintf('%.'.$formats[0],$bubbles_values[$ind]);   my $ans;
  $result.='<td>'.$ans.'</td>';   if ($formats[0] ne '') {
       $ans = sprintf('%.'.$formats[0],$bubbles_values[$ind]);
    } else {
       my $badans = $bubbles_values[$ind];
       my $format = ''; 
                       #What is the number? (integer,decimal,floating point)
                       if ($badans=~/^(\d*\.?\d*)(E|e)(\d*)$/) {
    $format = 'e'.$2;
       } elsif ($badans=~/^(\d*)\.(\d*)$/) {
    $format = '4f';
       } elsif ($badans=~/^(\d*)$/) {
    $format = 'd';
       }
       $ans = sprintf('%.'.$format,$bubbles_values[$ind]);
  }   }
       $result.='<td>'.$alphabet[$ind].': '.$ans.'</td>';
       }
     $result.='</tr></table>';      $result.='</tr></table>';
  } elsif ($target eq 'tex') {   } elsif ($target eq 'tex') {
     my @alphabet = ('A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',  
                             'Q','R','S','T','U','V','W','X','Y','Z');  
     my $max_val = 0;      my $max_val = 0;
     if ($formats[0]=~m/^(\d+)E([^\d]*)(\d*)$/) {      if ($formats[0]=~m/^(\d+)E([^\d]*)(\d*)$/) {
  $max_val=$1+$2+4;   $max_val=$1+$2+4;
       } else {
    $max_val=5;
     }      }
     $max_val = int(90/(($max_val+6)*2));      $max_val = int(90/(($max_val+6)*2));
             my $celllength = 90/$max_val-12;              my $celllength = 90/$max_val-12;
Line 253  sub end_numericalresponse { Line 270  sub end_numericalresponse {
  }   }
  $result.='}\hline';   $result.='}\hline';
  for ($ind=$cou;$ind<$cou+$table_range[$j];$ind++) {   for ($ind=$cou;$ind<$cou+$table_range[$j];$ind++) {
     my $ans = sprintf('%.'.$formats[0],$bubbles_values[$ind]);      my $ans;
       if ($formats[0] ne '') {
    $ans = sprintf('%.'.$formats[0],$bubbles_values[$ind]);
       } else {
    my $badans = $bubbles_values[$ind];
    my $format = ''; 
    #What is the number? (integer,decimal,floating point)
    if ($badans=~/^(\d*\.?\d*)(E|e)(\d*)$/) {
       $format = 'e'.$2;
    } elsif ($badans=~/^(\d*)\.(\d*)$/) {
       $format = '4f';
    } elsif ($badans=~/^(\d*)$/) {
       $format = 'd';
    }
    $ans = sprintf('%.'.$format,$bubbles_values[$ind]);
       }
     $result.=' '.$alphabet[$ind].': & '.$ans.' ';      $result.=' '.$alphabet[$ind].': & '.$ans.' ';
     if ($ind != $cou+$table_range[$j]-1) {$result.=' & ';}      if ($ind != $cou+$table_range[$j]-1) {$result.=' & ';}
  }   }
  $j++;  
  $cou += $table_range[$j];   $cou += $table_range[$j];
    $j++;
  $result.='\\\\\hline\end{tabular}\vskip 0 mm ';   $result.='\\\\\hline\end{tabular}\vskip 0 mm ';
     }          }    
  }   }

Removed from v.1.59  
changed lines
  Added in v.1.64


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