--- loncom/homework/caparesponse/caparesponse.pm 2010/12/16 16:01:08 1.243 +++ loncom/homework/caparesponse/caparesponse.pm 2011/06/08 01:39:32 1.247 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # caparesponse definition # -# $Id: caparesponse.pm,v 1.243 2010/12/16 16:01:08 raeburn Exp $ +# $Id: caparesponse.pm,v 1.247 2011/06/08 01:39:32 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -402,7 +402,7 @@ sub setup_capa_response { sub check_submission { my ($response,$partid,$id,$tag,$parstack,$safeeval,$ignore_sig)=@_; - my @args = ('type','tol','sig','format','unit','calc','samples'); + my @args = ('type','tol','sig','format','unit','calc','samples','preprocess'); my $args_ref = &setup_capa_args($safeeval,$parstack,\@args,$response); my $hideunit= @@ -1136,6 +1136,7 @@ sub start_stringresponse { my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_; my $result; my $id = &Apache::response::start_response($parstack,$safeeval); + undef(%answer); if ($target eq 'meta') { $result=&Apache::response::meta_package_write('stringresponse'); } elsif ($target eq 'edit') { @@ -1231,15 +1232,13 @@ sub end_stringresponse { my ($result, @msgs)=&Apache::run::run("&caparesponse_check_list()",$safeeval); if ($$args_ref{'type'} =~ /^c[si]$/) { $ansstring{$name} = pop(@msgs); - } - if ($$args_ref{'type'} =~ /^c[si]$/) { my $control_chars_removed = pop(@msgs); my $error = pop(@msgs); if (($error ne '') || - ($control_chars_removed ne '')) { + ($control_chars_removed)) { my ($symb,$courseid,$sdomain,$sname) = &Apache::lonnet::whichuser(); - if ($control_chars_removed ne '') { + if ($control_chars_removed) { my $showresponse = $response; if ($response =~ /[\000-\037]/) { $response =~ s/[\000-\037]//g; @@ -1286,16 +1285,27 @@ sub end_stringresponse { $ad='ANONYMOUS_CREDIT'; } } - unless ($env{'request.state'} eq 'construct') { - if ($previous{'used'}) { - if ($ad ne $previous{'award'} && $previous{'award'} ne '') { - &stringresponse_gradechange($part,$id,\%previous, - 'cs',$response,$ad,$type); - } - } elsif ($previous{'usedci'}) { - if ($ad ne $previous{'awardci'} && $previous{'awardci'} ne '') { - &stringresponse_gradechange($part,$id,\%previous, - 'ci',$response,$ad,$type); + unless (($env{'request.state'} eq 'construct') || + ($Apache::lonhomework::type eq 'randomizetry')) { + if (($ad eq 'INCORRECT' || $ad eq 'APPROX_ANS' || $ad eq 'EXACT_ANS')) { + if ($previous{'used'}) { + if ($ad ne $previous{'award'}) { + if (($previous{'award'} eq 'INCORRECT' || + $previous{'award'} eq 'APPROX_ANS' || + $previous{'award'} eq 'EXACT_ANS')) { + &stringresponse_gradechange($part,$id,\%previous, + 'cs',$response,$ad,$type); + } + } + } elsif ($previous{'usedci'}) { + if ($ad ne $previous{'awardci'}) { + if (($previous{'awardci'} eq 'INCORRECT' || + $previous{'awardci'} eq 'APPROX_ANS' || + $previous{'awardci'} eq 'EXACT_ANS')) { + &stringresponse_gradechange($part,$id,\%previous, + 'ci',$response,$ad,$type); + } + } } } }