--- loncom/homework/caparesponse/caparesponse.pm 2010/12/16 16:01:08 1.243 +++ loncom/homework/caparesponse/caparesponse.pm 2011/02/02 18:48:06 1.245 @@ -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.245 2011/02/02 18:48:06 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1231,15 +1231,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 +1284,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); + } + } } } }