[LON-CAPA-cvs] cvs: loncom /homework inputtags.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Mon, 07 Apr 2003 20:52:58 -0000
albertel Mon Apr 7 16:52:58 2003 EDT
Modified files:
/loncom/homework inputtags.pm
Log:
- striving for a cleaner, leaner data storage
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.86 loncom/homework/inputtags.pm:1.87
--- loncom/homework/inputtags.pm:1.86 Wed Apr 2 14:51:24 2003
+++ loncom/homework/inputtags.pm Mon Apr 7 16:52:58 2003
@@ -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 @@
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 @@
} 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 @@
} 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 @@
} 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 '';
}