Diff for /loncom/homework/caparesponse/caparesponse.pm between versions 1.176 and 1.180

version 1.176, 2005/07/14 05:50:33 version 1.180, 2005/09/08 17:49:22
Line 389  sub end_numericalresponse { Line 389  sub end_numericalresponse {
  if ($unit=~/\$/) { $fmt="\$".$fmt; $unit=~s/\$//g; }   if ($unit=~/\$/) { $fmt="\$".$fmt; $unit=~s/\$//g; }
  if ($unit=~/\,/) { $fmt="\,".$fmt; $unit=~s/\,//g; }   if ($unit=~/\,/) { $fmt="\,".$fmt; $unit=~s/\,//g; }
  $ans = &format_number($ans,$fmt,$target,$safeeval);   $ans = &format_number($ans,$fmt,$target,$safeeval);
    if ($fmt=~/\$/ && $unit!~/\$/) { $ans=~s/\$//; }
     }      }
     push(@fmt_ans,$ans);      push(@fmt_ans,$ans);
  }   }
Line 421  sub end_numericalresponse { Line 422  sub end_numericalresponse {
  if ($sigline ne '') {   if ($sigline ne '') {
     $error=&mt('Computer\'s answer is incorrect ("[_1]"). It is likely that the tolerance range [_2] or significant figures [_3] need to be adjusted.',$response,$tolline,$sigline);      $error=&mt('Computer\'s answer is incorrect ("[_1]"). It is likely that the tolerance range [_2] or significant figures [_3] need to be adjusted.',$response,$tolline,$sigline);
  } else {   } else {
     $error=&mt('Computer\'s answer is incorrect ("[_1]"). It is likely that the tolerance range [_1] needs to be adjusted.',$response,$tolline);      $error=&mt('Computer\'s answer is incorrect ("[_1]"). It is likely that the tolerance range [_2] needs to be adjusted.',$response,$tolline);
  }   }
     }      }
     if ($ad ne 'EXACT_ANS' && $ad ne 'APPROX_ANS') {      if ($ad ne 'EXACT_ANS' && $ad ne 'APPROX_ANS') {
Line 699  sub end_stringresponse { Line 700  sub end_stringresponse {
 # $answer=$token->[2]->{'answer'};  # $answer=$token->[2]->{'answer'};
 #    }  #    }
     ${$safeeval->varglob('LONCAPA::response')}=$response;      ${$safeeval->varglob('LONCAPA::response')}=$response;
     $result = &Apache::run::run('return $LONCAPA::response=~m'.$answer,$safeeval);      $result = &Apache::run::run('if ($LONCAPA::response=~m'.$answer.') { return 1; } else { return 0; }',$safeeval);
     &Apache::lonxml::debug("current $response");      &Apache::lonxml::debug("current $response");
     &Apache::lonxml::debug("current $answer");      &Apache::lonxml::debug("current $answer");
     $ad = ($result) ? 'APPROX_ANS' : 'INCORRECT';      $ad = ($result) ? 'APPROX_ANS' : 'INCORRECT';
Line 760  sub end_stringresponse { Line 761  sub end_stringresponse {
 # foreach my $ans (@answers) {  # foreach my $ans (@answers) {
     if ($target eq 'answer') {      if ($target eq 'answer') {
  $result.=&Apache::response::answer_part('stringresponse',$answer);   $result.=&Apache::response::answer_part('stringresponse',$answer);
    if ($type eq 're') {
       $result.=&Apache::response::answer_part('stringresponse',
       $answerdisplay);
    }
     } elsif ($target eq 'analyze') {      } elsif ($target eq 'analyze') {
  push (@{ $Apache::lonhomework::analyze{"$part.$id.answer"} },   push (@{ $Apache::lonhomework::analyze{"$part.$id.answer"} },
       $answer);        $answer);

Removed from v.1.176  
changed lines
  Added in v.1.180


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