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

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 20 May 2004 23:11:13 -0000


albertel		Thu May 20 19:11:13 2004 EDT

  Modified files:              
    /loncom/homework	structuretags.pm inputtags.pm 
  Log:
  - BUG#2680, submissions after duedate or after tries exhausted have their data moved from
     resource.partid.resourceid.datafield to
     resource.partid.resourceid.hiddendatafield 
  
  
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.248 loncom/homework/structuretags.pm:1.249
--- loncom/homework/structuretags.pm:1.248	Fri May 14 18:11:05 2004
+++ loncom/homework/structuretags.pm	Thu May 20 19:11:12 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: structuretags.pm,v 1.248 2004/05/14 22:11:05 albertel Exp $
+# $Id: structuretags.pm,v 1.249 2004/05/20 23:11:12 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -593,10 +593,14 @@
     my $status=$Apache::inputtags::status['-1'];
     if ($target eq 'grade' || $target eq 'web' || $target eq 'answer' ||
 	$target eq 'tex') {
-	if ( $target eq 'grade' && $Apache::inputtags::part eq '0' &&
-	     ($status eq 'CAN_ANSWER' || $Apache::lonhomework::scantronmode)) {
+	if ( $target eq 'grade' && $Apache::inputtags::part eq '0') {
 	    # if part is zero, no <part>s existed, so we need to the grading
-	    &Apache::inputtags::grade;
+	    if ($status eq 'CAN_ANSWER' ||$Apache::lonhomework::scantronmode) {
+		&Apache::inputtags::grade;
+	    } else {
+		# move any submission data to .hidden
+		&Apache::inputtags::hidealldata($Apache::inputtags::part);
+	    }
 	} elsif ( ($target eq 'web' || $target eq 'tex') &&
 		  $Apache::inputtags::part eq '0' &&
 		  $status ne 'UNCHECKEDOUT') {
@@ -1093,10 +1097,14 @@
     my $result='';
     if ( $target eq 'meta' ) {
 	$result='';
-    } elsif ($target eq 'grade' && 
-	     ($status eq 'CAN_ANSWER' || $Apache::lonhomework::scantronmode) &&
-	     !$hidden) {
-	$result=&Apache::inputtags::grade;
+    } elsif ($target eq 'grade') {
+	if (($status eq 'CAN_ANSWER' || $Apache::lonhomework::scantronmode) &&
+	    !$hidden) {
+	    $result=&Apache::inputtags::grade;
+	} else {
+	    # move any submission data to .hidden
+	    &Apache::inputtags::hidealldata($Apache::inputtags::part);
+	}
     } elsif (($target eq 'web' || $target eq 'tex') && !$hidden ) {
 	my $gradestatus=&Apache::inputtags::gradestatus($Apache::inputtags::part,
 							$target);
Index: loncom/homework/inputtags.pm
diff -u loncom/homework/inputtags.pm:1.141 loncom/homework/inputtags.pm:1.142
--- loncom/homework/inputtags.pm:1.141	Thu Apr 29 03:57:47 2004
+++ loncom/homework/inputtags.pm	Thu May 20 19:11:12 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # input  definitons
 #
-# $Id: inputtags.pm,v 1.141 2004/04/29 07:57:47 albertel Exp $
+# $Id: inputtags.pm,v 1.142 2004/05/20 23:11:12 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -482,6 +482,20 @@
     }
 }
 
+sub hidealldata {
+    my ($id)=@_;
+    foreach my $key (keys(%Apache::lonhomework::results)) {
+	if (($key =~ /^resource\.\Q$id\E\./) && ($key !~ /\.collaborators$/)) {
+	    &Apache::lonxml::debug("Hidding $key");
+	    my $newkey=$key;
+	    $newkey=~s/^(resource\.\Q$id\E\.[^\.]+\.)(.*)$/${1}hidden${2}/;
+	    $Apache::lonhomework::results{$newkey}=
+		$Apache::lonhomework::results{$key};
+	    delete($Apache::lonhomework::results{$key});
+	}
+    }
+}
+
 sub setgradedata {
     my ($award,$msg,$id,$previously_used) = @_;
     # if the student already has it correct, don't modify the status