Diff for /loncom/homework/caparesponse/caparesponse.pm between versions 1.10 and 1.19

version 1.10, 2000/10/13 14:59:31 version 1.19, 2000/12/11 23:47:36
Line 11  sub BEGIN { Line 11  sub BEGIN {
   
 $Apache::caparesponse::result='';  $Apache::caparesponse::result='';
 sub start_caparesponse {  sub start_caparesponse {
   my $envkey;    my ($target,$token,$parstack,$parser,$safeeval)=@_;
       my $id = &Apache::response::start_response($parstack,$safeeval);
   #foreach $envkey (sort keys %ENV) {    return '';
   #  Apache::lonxml::debug("$envkey ---- $ENV{$envkey}<br>");  
   #}  
     
   #Apache::lonxml::debug("\n<br>\nreal caparesponse<br>\n");  
 }  }
   
 sub end_caparesponse {  sub end_caparesponse {
   my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;    my ($target,$token,$parstack,$parser,$safeeval,$style)=@_;
   if ( defined $ENV{'form.'.$ENV{'form.request.prefix'}.'submit'}) {    my $result = '';
     $Apache::caparesponse::result='';    if ( $target eq 'grade' ) {
     $safeeval->share('&caparesponse_capa_check_answer');      if ( defined $ENV{'form.submit'}) {
     $safeeval->share('$Apache::caparesponse::result');        $Apache::caparesponse::result='';
     my $response = $ENV{'form.'.$ENV{'form.request.prefix'}.'HWVAL'.$Apache::inputtags::curvalue};        $safeeval->share_from('capa',['&caparesponse_capa_check_answer']);
     #Apache::lonxml::debug("submitted a $response<br>\n");        my $response = $ENV{'form.HWVAL'.$Apache::inputtags::response['-1']};
     #Apache::lonxml::debug($$parstack[$#$parstack] . "\n<br>");        if ( $response =~ /[^\s]/) {
     my $expression="caparesponse_check $response $$parstack[$#$parstack];";   #check_for_previous($response,$id,$response);
     #&Apache::run::run($expression,$safeeval);   $Apache::lonhomework::results{"resource.submission.$Apache::inputtags::part.$Apache::inputtags::response['-1']"}=$response;
        &Apache::lonxml::debug("submitted a $response<br>\n");
     #&Apache::lonxml::debug("\n<br>result:$Apache::caparesponse::result:<br>\n");   &Apache::lonxml::debug($$parstack[$#$parstack] . "\n<br>");
     my $args ='';   my $expression="&caparesponse_check('".$response."','".
     if ( $#$parstack > -1 ) {    $$parstack[$#$parstack].
       $args=$$parstack[$#$parstack];      ';my $tol="'.$Apache::inputtags::params{'tol'}.'"'.
     }        ';my $sig="'.$Apache::inputtags::params{'sig'}.'"'.
     my $answer = &Apache::run::run("{$args;".'return $answer}',$safeeval);   "');";
     if ( $answer == 1.0 * $answer ) {   $result = &Apache::run::run($expression,$safeeval);
       my $tol = &Apache::run::run("{$args;".'return $tol}',$safeeval);   my ($ad) = split /:/ , $result;
       my $format = &Apache::run::run("{$args;".'return $format}',$safeeval);   $Apache::lonhomework::results{"resource.awarddetail.$Apache::inputtags::part.$Apache::inputtags::response['-1']"}=$ad;
       my $formatedanswer = sprintf('%.'.$format,$answer);   &Apache::lonxml::debug("$expression");
       my $difference = abs($answer - $formatedanswer);   &Apache::lonxml::debug("\n<br>result:$Apache::caparesponse::result:$result:$Apache::lonxml::curdepth<br>\n");
       my $studiff = abs($answer - $response);  
       if ( $difference > $studiff ) {  
  return "Correct, Computer had $answer<br></br>";  
       } else {  
  return "Incorrect, Computer had $answer<br></br>";  
       }  
     } else {    
       if ( $answer eq $response ) {  
  return "Correct, Computer had $answer<br></br>";  
       } else {  
  return "Incorrect, Computer had $answer<br></br>";  
       }        }
     }      }
   } else {    } else {
     #return "The correct answer is ".&Apache::run::run("{$$parstack['-1'];".'return $answer}',$safeeval)."\n";      #$result .= "The correct answer is ".&Apache::run::run("{$$parstack['-1'];".'return $answer}',$safeeval)."\n";
   }    }
   #Apache::lonxml::debug("\n<br>\nreal end caparesponse<br>\n");    #Apache::lonxml::debug("\n<br>\nreal end caparesponse<br>\n");
   return '';    &Apache::response::end_response;
     return $result;
 }  }
   
 1;  1;

Removed from v.1.10  
changed lines
  Added in v.1.19


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