--- loncom/homework/inputtags.pm 2003/04/02 19:51:24 1.86 +++ loncom/homework/inputtags.pm 2003/04/07 20:52:58 1.87 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # input definitons # -# $Id: inputtags.pm,v 1.86 2003/04/02 19:51:24 sakharuk Exp $ +# $Id: inputtags.pm,v 1.87 2003/04/07 20:52:58 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -340,6 +340,16 @@ sub decideoutput { return ($button,$message,$previousmsg); } +sub remove_alldata { + my ($id)=@_; + foreach my $key (keys(%Apache::lonhomework::results)) { + if (($key =~ /^resource\.\Q$id\E\./) && ($key !~ /\.collaborators$/)) { + &Apache::lonxml::debug("Removing $key"); + delete($Apache::lonhomework::results{$key}); + } + } +} + sub setgradedata { my ($award,$id,$previously_used) = @_; # if the student already has it correct, don't modify the status @@ -372,7 +382,9 @@ sub setgradedata { } elsif ( $award eq 'DRAFT' ) { $Apache::lonhomework::results{"resource.$id.solved"} = ''; } elsif ( $award eq 'NO_RESPONSE' ) { - return ''; + #no real response so delete any data that got stored + &removealldata($id); + return ''; } else { $Apache::lonhomework::results{"resource.$id.solved"} = 'incorrect_attempted'; @@ -386,12 +398,7 @@ sub setgradedata { } elsif ( $previously_used eq 'PREVIOUSLY_LAST') { #delete all data as they student didn't do anything, but save #the list of collaborators. - foreach my $key (keys(%Apache::lonhomework::results)) { - if (($key =~ /^resource\.$id\./) && ($key !~ /\.collaborators$/)) { - &Apache::lonxml::debug("Removing $key"); - delete($Apache::lonhomework::results{$key}); - } - } + &removealldata($id); #and since they didn't do anything we were never here return ''; } else { @@ -400,12 +407,7 @@ sub setgradedata { } elsif ( $Apache::lonhomework::history{"resource.$id.solved"} =~ /^correct/ ) { #delete all data as they student already has it correct - foreach my $key (keys(%Apache::lonhomework::results)) { - if (($key =~ /^resource\.$id\./) && ($key !~ /\.collaborators$/)) { - &Apache::lonxml::debug("Removing $key"); - delete($Apache::lonhomework::results{$key}); - } - } + &removealldata($id); #and since they didn't do anything we were never here return ''; }