Diff for /loncom/homework/caparesponse/caparesponse.pm between versions 1.145 and 1.146

version 1.145, 2004/06/02 21:23:21 version 1.146, 2004/06/04 22:06:07
Line 86  sub start_numericalresponse { Line 86  sub start_numericalresponse {
     $safeeval);      $safeeval);
     if ($unit =~ /\S/) { $result.=" (in $unit) "; }      if ($unit =~ /\S/) { $result.=" (in $unit) "; }
  }   }
    if (  &Apache::response::show_answer() ) {
       my $answertxt;
       my (@answers)=&Apache::lonxml::get_param_var('answer',$parstack,
    $safeeval);
       my (@formats)=&Apache::lonxml::get_param_var('format',$parstack,
    $safeeval);
       my $unit=&Apache::lonxml::get_param_var('unit',$parstack,
       $safeeval);
       for (my $i=0; $i <= $#answers; $i++) {
    my $answer=$answers[$i];
    my $format;
    if ($#formats > 0) {
       $format=$formats[$i];
    } else {
       $format=$formats[0];
    }
    my $formatted;
    if ((defined($format)) && ($format ne '')) {
       $format=~s/e/E/g;
       &Apache::lonxml::debug("formatting with :$format: answer :$answer:");
       $formatted=sprintf('%.'.$format,$answer).',';
    } else {
       &Apache::lonxml::debug("no format answer :$answer:");
       $formatted="$answer,";
    }
    $answertxt.=$formatted;
       }
       chop $answertxt;
       if ($target eq 'web') {
    $answertxt.=" $unit.<br />";
       }
       $Apache::inputtags::answertxt{$id}=$answertxt;
    }
     }      }
     return $result;      return $result;
 }  }
Line 185  sub end_numericalresponse { Line 218  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 (  &Apache::response::show_answer() ) {  
     my (@formats)=&Apache::lonxml::get_param_var('format',$parstack,  
  $safeeval);  
     my $unit=&Apache::lonxml::get_param_var('unit',$parstack,  
     $safeeval);  
     if ($target eq 'web') {  
  $result="<br />".&mt('The correct answer is')." ";  
     }  
     for (my $i=0; $i <= $#answers; $i++) {  
  my $answer=$answers[$i];  
  my $format;  
  if ($#formats > 0) {  
     $format=$formats[$i];  
  } else {  
     $format=$formats[0];  
  }  
  my $formatted;  
  if ((defined($format)) && ($format ne '')) {  
     $format=~s/e/E/g;  
     &Apache::lonxml::debug("formatting with :$format: answer :$answer:");  
     $formatted=sprintf('%.'.$format,$answer).',';  
  } else {  
     &Apache::lonxml::debug("no format answer :$answer:");  
     $formatted="$answer,";  
  }  
  if ($target eq 'tex') {  
     $formatted='';  
     #$formatted=&Apache::lonxml::latex_special_symbols($formatted);  
  }  
  $result.=$formatted;  
     }  
     chop $result;  
     if ($target eq 'web') {  
  $result.=" $unit.<br />";  
     }  
  }  
  if ($Apache::lonhomework::type eq 'exam') {   if ($Apache::lonhomework::type eq 'exam') {
     my $partid=$Apache::inputtags::part;      my $partid=$Apache::inputtags::part;
     my $id=$Apache::inputtags::response[-1];      my $id=$Apache::inputtags::response[-1];
Line 561  sub start_stringresponse { Line 558  sub start_stringresponse {
  [['cs','Case Sensitive'],['ci','Case Insensitive'],   [['cs','Case Sensitive'],['ci','Case Insensitive'],
   ['mc','Case Insensitive, Any Order'],    ['mc','Case Insensitive, Any Order'],
   ['re','Regular Expression']],$token);    ['re','Regular Expression']],$token);
  $result.=&Apache::edit::checked_arg('Answer Display:','answerdisplay',  
     [['inline','Inline']],$token);  
  $result.=&Apache::edit::end_row().&Apache::edit::start_spanning_row();   $result.=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
     } elsif ($target eq 'modified') {      } elsif ($target eq 'modified') {
        my $constructtag;   my $constructtag;
        $constructtag=&Apache::edit::get_new_args($token,$parstack,   $constructtag=&Apache::edit::get_new_args($token,$parstack,
                                                  $safeeval,'answer',    $safeeval,'answer',
                                                  'type','answerdisplay');    'type','answerdisplay');
        if ($constructtag) {   if ($constructtag) {
            $result = &Apache::edit::rebuild_tag($token);      $result = &Apache::edit::rebuild_tag($token);
            $result.=&Apache::edit::handle_insert();      $result.=&Apache::edit::handle_insert();
        }   }
       } elsif ($target eq 'web') {
    if (  &Apache::response::show_answer() ) {
       $Apache::inputtags::answertxt{$id}=
    &Apache::lonxml::get_param('answer',$parstack,$safeeval);
    } 
     } elsif ($target eq 'answer' || $target eq 'grade') {      } elsif ($target eq 'answer' || $target eq 'grade') {
  &Apache::response::reset_params();   &Apache::response::reset_params();
     }      }
Line 648  sub end_stringresponse { Line 648  sub end_stringresponse {
     } elsif ($target eq 'web' || $target eq 'tex') {      } elsif ($target eq 'web' || $target eq 'tex') {
  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 (  &Apache::response::show_answer() ) {  
     if ($target eq 'web') {  
  $result=($answerdisplay eq 'inline'?'':"<br />".&mt('The correct answer is')." ")  
     .$answer;  
 #    join(', ',@answers).".<br />";  
     }  
  }  
  if ($Apache::lonhomework::type eq 'exam' && $target eq 'tex') {   if ($Apache::lonhomework::type eq 'exam' && $target eq 'tex') {
     $result.='\fbox{\fbox{\parbox{\textwidth-5mm}{\strut\\\\\strut\\\\\strut\\\\\strut\\\\}}}';      $result.='\fbox{\fbox{\parbox{\textwidth-5mm}{\strut\\\\\strut\\\\\strut\\\\\strut\\\\}}}';
     $increment = &Apache::response::repetition();      $increment = &Apache::response::repetition();

Removed from v.1.145  
changed lines
  Added in v.1.146


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