Diff for /loncom/homework/caparesponse/caparesponse.pm between versions 1.111 and 1.116

version 1.111, 2003/09/22 18:38:59 version 1.116, 2003/10/15 19:40:43
Line 114  sub end_numericalresponse { Line 114  sub end_numericalresponse {
     if ( $response =~ /[^\s]/) {      if ( $response =~ /[^\s]/) {
  my $ad;   my $ad;
  my %previous = &Apache::response::check_for_previous($response,$partid,$id);   my %previous = &Apache::response::check_for_previous($response,$partid,$id);
  $Apache::lonhomework::results{"resource.$partid.$id.submission"}=$response;  
  &Apache::lonxml::debug("submitted a $response<br>\n");   &Apache::lonxml::debug("submitted a $response<br>\n");
  &Apache::lonxml::debug($$parstack[-1] . "\n<br>");   &Apache::lonxml::debug($$parstack[-1] . "\n<br>");
   
Line 131  sub end_numericalresponse { Line 130  sub end_numericalresponse {
     $response =~ s/\\/\\\\/g;      $response =~ s/\\/\\\\/g;
     $response =~ s/\'/\\\'/g;      $response =~ s/\'/\\\'/g;
  }   }
    $Apache::lonhomework::results{"resource.$partid.$id.submission"}=$response;
  &Apache::lonxml::debug("current $response");   &Apache::lonxml::debug("current $response");
  my $expression="&caparesponse_check_list('".$response."','".   my $expression="&caparesponse_check_list('".$response."','".
     $$parstack[-1];      $$parstack[-1];
Line 169  sub end_numericalresponse { Line 169  sub end_numericalresponse {
      $safeeval);       $safeeval);
  my $award = $Apache::lonhomework::history{"resource.$Apache::inputtags::part.solved"};   my $award = $Apache::lonhomework::history{"resource.$Apache::inputtags::part.solved"};
  my $status = $Apache::inputtags::status['-1'];   my $status = $Apache::inputtags::status['-1'];
  if (   ($award =~ /^correct/   if (  &Apache::response::show_answer() ) {
                 && lc($Apache::lonhomework::problemstatus) ne 'no')  
              || $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 201  sub end_numericalresponse { Line 194  sub end_numericalresponse {
     &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 213  sub end_numericalresponse { Line 203  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 235  sub end_numericalresponse { Line 220  sub end_numericalresponse {
  if ($$tagstack[-1] eq 'numericalresponse') {   if ($$tagstack[-1] eq 'numericalresponse') {
     if ($unit=~/\S/) {$result.=' (in '.$unit.')<br /><br />';}      if ($unit=~/\S/) {$result.=' (in '.$unit.')<br /><br />';}
     $result.= '<table border="1"><tr>';      $result.= '<table border="1"><tr>';
       my $previous=$Apache::lonhomework::history{"resource.$Apache::inputtags::part.$id.submission"};
     for (my $ind=0;$ind<$number_of_bubbles;$ind++) {      for (my $ind=0;$ind<$number_of_bubbles;$ind++) {
    my $checked='';
    if ($previous eq $bubble_values[$ind]) {
       $checked=" checked='on' ";
    }
  $result.='<td><input type="radio" name="HWVAL_'.$id.   $result.='<td><input type="radio" name="HWVAL_'.$id.
     '" value="'.$bubble_values[$ind].'"><b>'.      '" value="'.$bubble_values[$ind].'" '.$checked
  $alphabet[$ind].'</b>: '.      .' /><b>'.$alphabet[$ind].'</b>: '.
     $bubble_values[$ind].'</td>';      $bubble_values[$ind].'</td>';
     }      }
     $result.='</tr></table>';      $result.='</tr></table>';
  } elsif ($$tagstack[-1] eq 'formularesponse') {   } elsif ($$tagstack[-1] eq 'formularesponse') {
Line 315  sub end_numericalresponse { Line 305  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 423  sub format_number { Line 414  sub format_number {
  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*)$/) {
     if (abs($3)>=100) {$format = 'e3';} else {$format = 'e2';}      $format = '3e';
  } elsif ($number=~/^(\d*)\.(\d*)$/) {   } elsif ($number=~/^(\d*)\.(\d*)$/) {
     $format = '4f';      $format = '4f';
  } elsif ($number=~/^(\d*)$/) {   } elsif ($number=~/^(\d*)$/) {

Removed from v.1.111  
changed lines
  Added in v.1.116


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