--- loncom/interface/lonprintout.pm 2005/08/16 10:11:24 1.385 +++ loncom/interface/lonprintout.pm 2005/08/22 09:48:25 1.387 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.385 2005/08/16 10:11:24 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 letters_to_num { 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 @@ ENDPART $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 { @@ -2196,13 +2196,27 @@ CHOOSE_STUDENTS1 if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) && - !\$helper->{'VARS'}{'REUSE_OLD_CODES'}) { + !\$helper->{'VARS'}{'REUSE_OLD_CODES'} && + !\$helper->{'VARS'}{'SINGLE_CODE'}) { return "You need to specify the number of assignments to print"; } return undef; + Value of CODE to print? + + + if(!\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'} && + !\$helper->{'VARS'}{'REUSE_OLD_CODES'}) { + return &Apache::lonprintout::is_code_valid(\$helper->{'VARS'}{'SINGLE_CODE'}, + \$helper->{'VARS'}{'CODE_OPTION'}); + } else { + return undef; # Other forces control us. + } + + + Names to store the CODEs under for later: