--- loncom/interface/lonprintout.pm 2005/09/16 21:59:56 1.381.2.3 +++ loncom/interface/lonprintout.pm 2005/08/15 21:51:49 1.382 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.381.2.3 2005/09/16 21:59:56 albertel Exp $ +# $Id: lonprintout.pm,v 1.382 2005/08/15 21:51:49 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -42,6 +42,28 @@ use Apache::lonratedt; use POSIX qw(strftime); use Apache::lonlocal; +my $resources_printed = ''; + +# Determine if a code entered by the user in a helper is valid. +# valid depends on the code type and the type of code selected. +# The type of code selected can either be numeric or +# Alphabetic. If alphabetic, the code, in fact is a simple +# substitution cipher for the actual numeric code: 0->A, 1->B ... +# We'll be nice and be case insensitive for alpha codes. +# Parameters: +# code_value - the value of the code the user typed in. +# code_option - The code type selected from the set in the scantron format +# table. +# Returns: +# undef - The code is valid. +# other - An error message indicating what's wrong. +# +sub is_code_valid { + my ($code_value, $code_option) = @_; + + return "Entering a single code is not supported (yet)"; +} + # Compare two students by name. The students are in the form # returned by the helper: # user:domain:section:last, first:status @@ -388,7 +410,6 @@ sub character_chart { $result =~ s/&(prod|\#8719);/\\ensuremath\{\\prod\}/g; $result =~ s/&(sum|\#8721);/\\ensuremath\{\\sum\}/g; $result =~ s/&(minus|\#8722);/\\ensuremath\{-\}/g; - $result =~ s/–/\\ensuremath\{-\}/g; $result =~ s/&(lowast|\#8727);/\\ensuremath\{*\}/g; $result =~ s/&(radic|\#8730);/\\ensuremath\{\\surd\}/g; $result =~ s/&(prop|\#8733);/\\ensuremath\{\\propto\}/g; @@ -807,7 +828,6 @@ sub get_page_breaks { sub output_data { my ($r,$helper,$rparmhash) = @_; my %parmhash = %$rparmhash; - my $resources_printed = ''; my $html=&Apache::lonxml::xmlbegin(); my $bodytag=&Apache::loncommon::bodytag('Preparing Printout'); $r->print(< 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? + + + # Not sure of exact call context so... + use Apache::lonprintout; + 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: