[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm

foxr lon-capa-cvs@mail.lon-capa.org
Mon, 22 Aug 2005 09:48:28 -0000


foxr		Mon Aug 22 05:48:28 2005 EDT

  Modified files:              
    /loncom/interface	lonprintout.pm 
  Log:
  Fix errors validating and printing typed in numeric codes.
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.386 loncom/interface/lonprintout.pm:1.387
--- loncom/interface/lonprintout.pm:1.386	Tue Aug 16 06:25:15 2005
+++ loncom/interface/lonprintout.pm	Mon Aug 22 05:48:25 2005
@@ -1,7 +1,7 @@
 #  The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.386 2005/08/16 10:25:15 foxr Exp $
+# $Id: lonprintout.pm,v 1.387 2005/08/22 09:48:25 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -87,11 +87,11 @@
 sub is_valid_numeric_code {
     my ($value, $num_digits) = @_;
     #   Remove leading/trailing whitespace;
-    $value =~ s/^\s*//;
-    $value =~ s/\s*$//;
+    $value =~ s/^\s*//g;
+    $value =~ s/\s*$//g;
     
     #  All digits?
-    if ($value =~ /^[0-9]+$/) {
+    if ($value !~ /^[0-9]+$/) {
 	return "Numeric code $value has invalid characters - must only be digits";
     }
     if (length($value) != $num_digits) {
@@ -1386,12 +1386,12 @@
 	     $num_todo=scalar(@allcodes);
 	 } elsif ($single_code) {
 
+	     $num_todo    = 1;	# Unconditionally one code to do.
 	     # If an alpha code have to convert to numbers so it can be
 	     # converted back to letters again :-)
 	     #
 	     if ($code_type ne 'number') {
 		 $single_code = &letters_to_num($single_code);
-		 $num_todo    = 1;
 	     }
 	     @allcodes = ($single_code);
 	 } else {