[LON-CAPA-cvs] cvs: loncom /homework inputtags.pm response.pm

albertel lon-capa-cvs@mail.lon-capa.org
Wed, 27 Nov 2002 19:25:56 -0000


albertel		Wed Nov 27 14:25:56 2002 EDT

  Modified files:              
    /loncom/homework	response.pm inputtags.pm 
  Log:
  - Fixes BUG#965, multiple responses in the same part (AND style)
    now properly detect whether a situation is a previous submission or
    not, previously it would detect a situation in which the same individual
    response had appeared before (but not together) as a previously seen
    submission, now it properly only detects when a group of submissions
    is the same.
  
  
Index: loncom/homework/response.pm
diff -u loncom/homework/response.pm:1.67 loncom/homework/response.pm:1.68
--- loncom/homework/response.pm:1.67	Mon Nov 25 16:36:42 2002
+++ loncom/homework/response.pm	Wed Nov 27 14:25:56 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # various response type definitons response definition
 #
-# $Id: response.pm,v 1.67 2002/11/25 21:36:42 albertel Exp $
+# $Id: response.pm,v 1.68 2002/11/27 19:25:56 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -172,7 +172,7 @@
   my ($curresponse,$partid,$id) = @_;
   my %previous;
   $previous{'used'} = 0;
-  foreach my $key (reverse(sort(keys(%Apache::lonhomework::history)))) {
+  foreach my $key (sort(keys(%Apache::lonhomework::history))) {
     if ($key =~ /resource\.$partid\.$id\.submission/) {
       &Apache::lonxml::debug("Trying $key");
       my $pastresponse=$Apache::lonhomework::history{$key};
@@ -183,16 +183,17 @@
 	  $history=$1;
 	  $previous{'award'} = $Apache::lonhomework::history{"$history:resource.$partid.$id.awarddetail"};
 	  $previous{'last'}='0';
+	  push(@{ $previous{'version'} },$history);
 	} else {
 	  $previous{'award'} = $Apache::lonhomework::history{"resource.$partid.$id.awarddetail"};
 	  $previous{'last'}='1';
 	}
 	if (! $previous{'award'} ) { $previous{'award'} = 'UNKNOWN';	}
 	&Apache::lonxml::debug("got a match :$previous{'award'}:$previous{'used'}:");
-	last;
       }
     }
   }
+  &Apache::lonhomework::showhash(%previous);
   return %previous;
 }
 
@@ -204,6 +205,7 @@
     } else {
       push(@Apache::inputtags::previous,'PREVIOUSLY_USED');
     }
+    push(@Apache::inputtags::previous_version,$$previous{'version'});
   }
 }
 
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.74 loncom/homework/inputtags.pm:1.75
--- loncom/homework/inputtags.pm:1.74	Tue Nov 19 09:59:35 2002
+++ loncom/homework/inputtags.pm	Wed Nov 27 14:25:56 2002
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # input  definitons
 #
-# $Id: inputtags.pm,v 1.74 2002/11/19 14:59:35 sakharuk Exp $
+# $Id: inputtags.pm,v 1.75 2002/11/27 19:25:56 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -47,6 +47,8 @@
   @Apache::inputtags::responselist=();
   # list of whether or not a specific response was previously used
   @Apache::inputtags::previous=();
+  # submission it was used in
+  @Apache::inputtags::previous_version=();
   # id of current part, 0 means that no part is current (inside <problem> only
   $Apache::inputtags::part='';
   # list of problem date statuses, the first element is for <problem>
@@ -388,13 +390,23 @@
     my $finalaward = &finalizeawards(@awards);
     my $previously_used;
     if ( $#Apache::inputtags::previous eq $#awards ) {
-      $previously_used = 'PREVIOUSLY_LAST';
-      foreach my $value (@Apache::inputtags::previous) {
-	if ($value eq 'PREVIOUSLY_USED' ) {
-	  $previously_used = $value;
-	  last;
+	my $match=0;
+	my @matches;
+	foreach my $versionar (@Apache::inputtags::previous_version) {
+	    foreach my $version (@$versionar) {
+		$matches[$version]++;
+	    }
+	}
+	foreach my $elem (@matches) {if ($elem eq ($#awards+1)) {$match=1;}}
+	if ($match) {
+	    $previously_used = 'PREVIOUSLY_LAST';
+	    foreach my $value (@Apache::inputtags::previous) {
+		if ($value eq 'PREVIOUSLY_USED' ) {
+		    $previously_used = $value;
+		    last;
+		}
+	    }
 	}
-      }
     }
     &Apache::lonxml::debug("final award $finalaward, $previously_used");
     &setgradedata($finalaward,$id,$previously_used);