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

albertel lon-capa-cvs@mail.lon-capa.org
Sat, 06 Nov 2004 01:22:11 -0000


albertel		Fri Nov  5 20:22:11 2004 EDT

  Modified files:              (Branch: version_1_2_X)
    /loncom/homework	grades.pm 
  Log:
   - backport 1.224
  
  
Index: loncom/homework/grades.pm
diff -u loncom/homework/grades.pm:1.204.2.7 loncom/homework/grades.pm:1.204.2.8
--- loncom/homework/grades.pm:1.204.2.7	Wed Sep 29 01:45:34 2004
+++ loncom/homework/grades.pm	Fri Nov  5 20:22:11 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Grading handler
 #
-# $Id: grades.pm,v 1.204.2.7 2004/09/29 05:45:34 albertel Exp $
+# $Id: grades.pm,v 1.204.2.8 2004/11/06 01:22:11 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3219,9 +3219,12 @@
 
 sub displaySubByDates {
     my ($symb,$record,$parts,$responseType,$checkIcon,$uname,$udom) = @_;
+    my $isCODE=0;
+    if (exists($record->{'resource.CODE'})) { $isCODE=1; }
     my $studentTable='<table border="0" width="100%"><tr><td bgcolor="#777777">'.
 	'<table border="0" width="100%"><tr bgcolor="#e6ffff">'.
 	'<td><b>Date/Time</b></td>'.
+	($isCODE?'<td><b>CODE</b></td>':'').
 	'<td><b>Submission</b></td>'.
 	'<td><b>Status&nbsp;</b></td></tr>';
     my ($version);
@@ -3234,6 +3237,9 @@
     for ($version=1;$version<=$$record{'version'};$version++) {
 	my $timestamp = scalar(localtime($$record{$version.':timestamp'}));
 	$studentTable.='<tr bgcolor="#ffffff" valign="top"><td>'.$timestamp.'</td>';
+	if ($isCODE) {
+	    $studentTable.='<td>'.$record->{$version.':resource.CODE'}.'</td>';
+	}
 	my @versionKeys = split(/\:/,$$record{$version.':keys'});
 	my @displaySub = ();
 	foreach my $partid (@{$parts}) {
@@ -4319,8 +4325,8 @@
 	} elsif ($error eq 'duplicateCODE') {
 	    $r->print("</p><p>The encoded CODE has also been used by a previous paper ".join(', ',@{$arg}).", and CODEs are supposed to be unique</p>\n");
 	}
-	$r->print("<p>The CODE on the form is  <tt>".
-		  $$scan_record{'scantron.CODE'}."</tt><br />\n");
+	$r->print("<p>The CODE on the form is  <tt>'".
+		  $$scan_record{'scantron.CODE'}."'</tt><br />\n");
 	$r->print("<p>The ID on the form is  <tt>".
 		  $$scan_record{'scantron.ID'}."</tt><br />\n");
 	$r->print("The name on the paper is ".
@@ -4466,7 +4472,14 @@
 						 $scan_data);
 	my $CODE=$$scan_record{'scantron.CODE'};
 	my $error=0;
-	if (!exists($allcodes{$CODE}) && !$$scan_record{'scantron.useCODE'}) {
+	if (!&Apache::lonnet::validCODE($CODE)) {
+	    &scantron_get_correction($r,$i,$scan_record,
+				     \%scantron_config,
+				     $line,'incorrectCODE',\%allcodes);
+	    return(1,$currentphase);
+	}
+	if (%allcodes && !exists($allcodes{$CODE}) 
+            && !$$scan_record{'scantron.useCODE'}) {
 	    &scantron_get_correction($r,$i,$scan_record,
 				     \%scantron_config,
 				     $line,'incorrectCODE',\%allcodes);
@@ -4638,6 +4651,8 @@
 	    if (exists($scan_record->{'scantron.CODE'}) &&
 		$scan_record->{'scantron.CODE'}) {
 		$form{'CODE'}=$scan_record->{'scantron.CODE'};
+	    } else {
+		$form{'CODE'}='';
 	    }
 	    my $result=&Apache::lonnet::ssi($resource->src(),%form);
 	    if (&Apache::loncommon::connection_aborted($r)) { last; }