--- loncom/interface/lonprintout.pm 2005/08/16 10:11:24 1.385 +++ loncom/interface/lonprintout.pm 2005/09/01 18:35:15 1.390 @@ -1,7 +1,7 @@ -# The LearningOnline Network +# The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.385 2005/08/16 10:11:24 foxr Exp $ +# $Id: lonprintout.pm,v 1.390 2005/09/01 18:35:15 albertel 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) { @@ -508,6 +508,7 @@ 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; @@ -1363,6 +1364,8 @@ ENDPART my $code_name=$helper->{'VARS'}->{'ANON_CODE_STORAGE_NAME'}; my $old_name=$helper->{'VARS'}->{'REUSE_OLD_CODES'}; my $single_code = $helper->{'VARS'}->{'SINGLE_CODE'}; + my $selected_code = $helper->{'VARS'}->{'CODE_SELECTED_FROM_LIST'}; + my $code_option=$helper->{'VARS'}->{'CODE_OPTION'}; open(FH,$Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab'); my ($code_type,$code_length)=('letter',6); @@ -1384,14 +1387,17 @@ ENDPART $code_type=$result{"type\0$old_name"}; @allcodes=split(',',$result{$old_name}); $num_todo=scalar(@allcodes); + } elsif ($selected_code) { # Selection value is always numeric. + $num_todo = 1; + @allcodes = ($selected_code); } 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 { @@ -2088,6 +2094,27 @@ CHOOSE_STUDENTS if ($name =~ /^type\0/) { next; } $namechoice.=''.$name.''; } + + + my %all_codes = &Apache::lonnet::get('CODEs', + \@names, $cdom,$cnum); + my %code_values; + my @all_code_array; + foreach my $key (keys %all_codes) { + %code_values = &Apache::grades::get_codes($key, $cdom, $cnum); + foreach my $key (keys %code_values) { + push (@all_code_array, "$key"); + } + } + + my $code_selection = "\n"; + foreach my $code (sort {uc($a) cmp uc($b)} @all_code_array) { + my $choice = $code; + if ($code =~ /^[A-Z]+$/) { # Alpha code + $choice = &letters_to_num($code); + } + $code_selection .= ' '.$code."\n"; + } open(FH,$Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab'); my $codechoice=''; foreach my $line () { @@ -2110,7 +2137,8 @@ CHOOSE_STUDENTS if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) && !\$helper->{'VARS'}{'REUSE_OLD_CODES'} && - !\$helper->{'VARS'}{'SINGLE_CODE'}) { + !\$helper->{'VARS'}{'SINGLE_CODE'} && + !\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) { return "You need to specify the number of assignments to print"; } return undef; @@ -2121,7 +2149,8 @@ CHOOSE_STUDENTS if(!\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'} && - !\$helper->{'VARS'}{'REUSE_OLD_CODES'}) { + !\$helper->{'VARS'}{'REUSE_OLD_CODES'} && + !\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) { return &Apache::lonprintout::is_code_valid(\$helper->{'VARS'}{'SINGLE_CODE'}, \$helper->{'VARS'}{'CODE_OPTION'}); } else { @@ -2130,6 +2159,12 @@ CHOOSE_STUDENTS + Choose single code from list + + + $code_selection + + Names to store the CODEs under for later: @@ -2196,13 +2231,35 @@ 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'} && + !\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) { 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'} && + !\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) { + return &Apache::lonprintout::is_code_valid(\$helper->{'VARS'}{'SINGLE_CODE'}, + \$helper->{'VARS'}{'CODE_OPTION'}); + } else { + return undef; # Other forces control us. + } + + + + Choose single code from list + + + $code_selection + + Names to store the CODEs under for later: