Diff for /loncom/homework/caparesponse/caparesponse.pm between versions 1.167 and 1.171

version 1.167, 2005/04/16 15:36:25 version 1.171, 2005/06/26 22:30:05
Line 121  sub start_numericalresponse { Line 121  sub start_numericalresponse {
 }  }
   
 sub check_submission {  sub check_submission {
     my ($response,$partid,$id,$tag,$parstack,$safeeval)=@_;      my ($response,$partid,$id,$tag,$parstack,$safeeval,$ignore_sig)=@_;
     my $args_ref= \%{$safeeval->varglob('LONCAPA::CAPAresponse_args')};      my $args_ref= \%{$safeeval->varglob('LONCAPA::CAPAresponse_args')};
     $$args_ref{'response'}=$response;      $$args_ref{'response'}=$response;
     my $hideunit=&Apache::lonnet::EXT('resource.'.$partid.'_'.$id.'.turnoffunit');      my $hideunit=&Apache::lonnet::EXT('resource.'.$partid.'_'.$id.'.turnoffunit');
Line 142  sub check_submission { Line 142  sub check_submission {
     }      }
     #sig fig don't make much sense either      #sig fig don't make much sense either
     if (($Apache::lonhomework::type eq 'exam' ||      if (($Apache::lonhomework::type eq 'exam' ||
  &Apache::response::submitted('scantron')) &&   &Apache::response::submitted('scantron') ||
    $ignore_sig) &&
  $tag eq 'numericalresponse') {   $tag eq 'numericalresponse') {
  delete($$args_ref{'sig'});   delete($$args_ref{'sig'});
     }      }
Line 174  sub end_numericalresponse { Line 175  sub end_numericalresponse {
     my $partid = $Apache::inputtags::part;      my $partid = $Apache::inputtags::part;
     my $id = $Apache::inputtags::response[-1];      my $id = $Apache::inputtags::response[-1];
     my $tag;      my $tag;
       $safeeval->share_from('capa',['&caparesponse_capa_check_answer']);
     if (scalar(@$tagstack)) { $tag=$$tagstack[-1]; }      if (scalar(@$tagstack)) { $tag=$$tagstack[-1]; }
     if ( $target eq 'grade' && &Apache::response::submitted() ) {      if ( $target eq 'grade' && &Apache::response::submitted() ) {
  &Apache::response::setup_params($tag,$safeeval);   &Apache::response::setup_params($tag,$safeeval);
  $safeeval->share_from('capa',['&caparesponse_capa_check_answer']);  
  if ($Apache::lonhomework::type eq 'exam' &&    if ($Apache::lonhomework::type eq 'exam' && 
     $tag eq 'formularesponse') {      $tag eq 'formularesponse') {
     $increment=&Apache::response::scored_response($partid,$id);      $increment=&Apache::response::scored_response($partid,$id);
Line 352  sub end_numericalresponse { Line 353  sub end_numericalresponse {
  #}   #}
     }      }
     my $response=$ans;      my $response=$ans;
       if ($unit) {
    my $cleanunit=$unit;
    $cleanunit=~s/\$\,//g;
    $response.=" $cleanunit";
       }
     if ($target eq 'answer') {      if ($target eq 'answer') {
  if ($high && $tag eq 'numericalresponse') { $ans.=' ['.$low.','.$high.']'; }   if ($high && $tag eq 'numericalresponse') { $ans.=' ['.$low.','.$high.']'; }
  if (defined($sighigh) && $tag eq 'numericalresponse') {   if (defined($sighigh) && $tag eq 'numericalresponse') {
Line 376  sub end_numericalresponse { Line 382  sub end_numericalresponse {
  $parstack,$safeeval);   $parstack,$safeeval);
     my ($ad,$msg) =&Apache::inputtags::finalizeawards($awards,$msgs);      my ($ad,$msg) =&Apache::inputtags::finalizeawards($awards,$msgs);
     if ($ad ne 'EXACT_ANS' && $ad ne 'APPROX_ANS') {      if ($ad ne 'EXACT_ANS' && $ad ne 'APPROX_ANS') {
  &Apache::lonxml::error(&mt('Computer\'s answer is incorrect. It is likely that the tolerance range or significant figures needs to be adjusted'));   # answer failed check if it is sig figs that is failing
    my ($awards,$msgs)=&check_submission($response,$partid,$id,
        $tag,$parstack,$safeeval,
        1);
    my ($ad,$msg)=&Apache::inputtags::finalizeawards($awards,
    $msgs);
   
    my $msg=&mt('Computer\'s answer is incorrect ("[_1]"). It is likely that the tolerance range ("[_2]" to "[_3]") or significant figures ("[_4]" to "[_5]") needs to be adjusted',$response,$low,$high,$siglow,$sighigh);
    if ($ad ne 'EXACT_ANS' && $ad ne 'APPROX_ANS') {
       &Apache::lonxml::error($msg);
    } else {
       &Apache::lonxml::warning($msg);
    }
     }      }
  }   }
  if (defined($unit) and ($unit ne '') and   if (defined($unit) and ($unit ne '') and

Removed from v.1.167  
changed lines
  Added in v.1.171


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