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

albertel lon-capa-cvs@mail.lon-capa.org
Fri, 22 Sep 2006 21:11:55 -0000


albertel		Fri Sep 22 17:11:55 2006 EDT

  Modified files:              
    /loncom/homework	grades.pm 
  Log:
  - BUG#3542, can stop trying to fix 'skipped' records and restart cleanly
  
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.375 loncom/homework/grades.pm:1.376
--- loncom/homework/grades.pm:1.375	Thu Sep 14 17:47:22 2006
+++ loncom/homework/grades.pm	Fri Sep 22 17:11:55 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.375 2006/09/14 21:47:22 albertel Exp $
+# $Id: grades.pm,v 1.376 2006/09/22 21:11:55 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -4794,21 +4794,29 @@
     &scantron_putfile(undef,$scan_data);
 }
 
-sub allow_skipping {
+sub start_skipping {
     my ($scan_data,$i)=@_;
     my %remembered=split(':',&scan_data($scan_data,'remember_skipping'));
-    delete($remembered{$i});
+    if ($env{'form.scantron_options_redo'} =~ /^redo_/) {
+	$remembered{$i}=2;
+    } else {
+	$remembered{$i}=1;
+    }
     &scan_data($scan_data,'remember_skipping',join(':',%remembered));
 }
 
 sub should_be_skipped {
-    my ($scan_data,$i)=@_;
+    my ($scanlines,$scan_data,$i)=@_;
     if ($env{'form.scantron_options_redo'} !~ /^redo_/) {
 	# not redoing old skips
+	if ($scanlines->{'skipped'}[$i]) { return 1; }
 	return 0;
     }
     my %remembered=split(':',&scan_data($scan_data,'remember_skipping'));
-    if (exists($remembered{$i})) { return 0; }
+
+    if (exists($remembered{$i}) && $remembered{$i} != 2 ) {
+	return 0;
+    }
     return 1;
 }
 
@@ -4820,6 +4828,7 @@
 	    $to_remember{$i}=1;
 	}
     }
+
     &scan_data($scan_data,'remember_skipping',join(':',%to_remember));
     &scantron_putfile(undef,$scan_data);
 }
@@ -4925,7 +4934,6 @@
     }
     if ($env{'form.scantron_options_redo'} eq 'redo_skipped') {
 	&remember_current_skipped();
-	&scantron_remove_file('skipped');
 	$env{'form.scantron_options_redo'}='redo_skipped_ready';
     }
 
@@ -5095,8 +5103,8 @@
 
 sub scantron_get_line {
     my ($scanlines,$scan_data,$i)=@_;
-    if (&should_be_skipped($scan_data,$i)) { return undef; }
-    if ($scanlines->{'skipped'}[$i]) { return undef; }
+    if (&should_be_skipped($scanlines,$scan_data,$i)) { return undef; }
+    #if ($scanlines->{'skipped'}[$i]) { return undef; }
     if ($scanlines->{'corrected'}[$i]) {return $scanlines->{'corrected'}[$i];}
     return $scanlines->{'orig'}[$i]; 
 }
@@ -5116,12 +5124,21 @@
     my ($scanlines,$scan_data,$i,$newline,$skip)=@_;
     if ($skip) {
 	$scanlines->{'skipped'}[$i]=$newline;
-	&allow_skipping($scan_data,$i);
+	&start_skipping($scan_data,$i);
 	return;
     }
     $scanlines->{'corrected'}[$i]=$newline;
 }
 
+sub scantron_clear_skip {
+    my ($scanlines,$scan_data,$i)=@_;
+    if (exists($scanlines->{'skipped'}[$i])) {
+	undef($scanlines->{'skipped'}[$i]);
+	return 1;
+    }
+    return 0;
+}
+
 sub scantron_filter_not_exam {
     my ($curres)=@_;
     
@@ -5608,6 +5625,10 @@
 
 	&Apache::lonxml::clear_problem_counter();
   	&Apache::lonnet::appenv(%$scan_record);
+
+	if (&scantron_clear_skip($scanlines,$scan_data,$i)) {
+	    &scantron_putfile($scanlines,$scan_data);
+	}
 	
 	my $i=0;
 	foreach my $resource (@resources) {