--- loncom/homework/inputtags.pm 2003/02/07 22:03:21 1.84 +++ loncom/homework/inputtags.pm 2003/04/07 22:18:11 1.88 @@ -1,7 +1,7 @@ # The LearningOnline Network with CAPA # input definitons # -# $Id: inputtags.pm,v 1.84 2003/02/07 22:03:21 albertel Exp $ +# $Id: inputtags.pm,v 1.88 2003/04/07 22:18:11 albertel Exp $ # # Copyright Michigan State University Board of Trustees # @@ -336,9 +336,20 @@ sub decideoutput { $message = "Unknown message: $award"; $button=1; } + if ($Apache::lonhomework::type eq 'exam') {$message='';$previousmsg='';} return ($button,$message,$previousmsg); } +sub removealldata { + 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 @@ -371,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'; @@ -385,17 +398,18 @@ 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 { $Apache::lonhomework::results{"resource.$id.previous"} = '0'; } + } elsif ( $Apache::lonhomework::history{"resource.$id.solved"} =~ + /^correct/ ) { + #delete all data as they student already has it correct + &removealldata($id); + #and since they didn't do anything we were never here + return ''; } $Apache::lonhomework::results{"resource.$id.award"} = $award; }