--- loncom/interface/lonprintout.pm 2005/08/22 09:48:25 1.387 +++ loncom/interface/lonprintout.pm 2005/08/22 22:21:48 1.388 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.387 2005/08/22 09:48:25 foxr Exp $ +# $Id: lonprintout.pm,v 1.388 2005/08/22 22:21:48 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -1363,6 +1363,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,6 +1386,12 @@ ENDPART $code_type=$result{"type\0$old_name"}; @allcodes=split(',',$result{$old_name}); $num_todo=scalar(@allcodes); + } elsif ($selected_code) { + $num_todo = 1; + my ($alpha, $numeric) = split(/:/, $selected_code); + $selected_code = $numeric; # Always use numeric, converted if need be. + $selected_code =~ s/\s+//g; + @allcodes = ($selected_code); } elsif ($single_code) { $num_todo = 1; # Unconditionally one code to do. @@ -2088,6 +2096,21 @@ CHOOSE_STUDENTS if ($name =~ /^type\0/) { next; } $namechoice.=''.$name.''; } + my %all_codes = &Apache::lonnet::get('CODEs', + \@names, $cdom,$cnum); + my @all_code_array; + foreach my $key (keys %all_codes) { + my $codes = $all_codes{$key}; + my @numeric_codes = split(/,/,$codes); + foreach my $numeric (sort {uc($a) cmp uc($b)} @numeric_codes) { + my $alpha_code = &num_to_letters($numeric); + push (@all_code_array, "$alpha_code : $numeric"); + } + } + my $code_selection = "\n"; + foreach my $code (@all_code_array) { + $code_selection .= ' '.$code."\n"; + } open(FH,$Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab'); my $codechoice=''; foreach my $line () { @@ -2110,7 +2133,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 +2145,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 +2155,12 @@ CHOOSE_STUDENTS + Choose single code from list + + + $code_selection + + Names to store the CODEs under for later: @@ -2197,7 +2228,8 @@ CHOOSE_STUDENTS1 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; @@ -2208,7 +2240,8 @@ CHOOSE_STUDENTS1 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 { @@ -2217,6 +2250,12 @@ CHOOSE_STUDENTS1 + Choose single code from list + + + $code_selection + + Names to store the CODEs under for later: