--- loncom/interface/lonprintout.pm 2018/10/02 19:25:30 1.627.2.25 +++ loncom/interface/lonprintout.pm 2019/02/06 01:10:09 1.627.2.26 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.627.2.25 2018/10/02 19:25:30 raeburn Exp $ +# $Id: lonprintout.pm,v 1.627.2.26 2019/02/06 01:10:09 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -3228,7 +3228,7 @@ ENDPART $result .= $print_array[0].' \end{document}'; } elsif (($print_type eq 'problems_for_anon') || ($print_type eq 'problems_for_anon_page') || - ($print_type eq 'resources_for_anon') ) { + ($print_type eq 'resources_for_anon') ) { my $cdom =$env{'course.'.$env{'request.course.id'}.'.domain'}; my $cnum =$env{'course.'.$env{'request.course.id'}.'.num'}; my $num_todo=$helper->{'VARS'}->{'NUMBER_TO_PRINT_TOTAL'}; @@ -3354,7 +3354,7 @@ ENDPART } &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state); $result .= $print_array[0].' \end{document}'; - } elsif ($print_type eq 'problems_from_directory') { + } elsif ($print_type eq 'problems_from_directory') { #prints selected problems from the subdirectory $selectionmade = 6; my @list_of_files=split /\|\|\|/, $helper->{'VARS'}->{'FILES'}; @@ -4065,8 +4065,10 @@ sub printHelper { $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($helper->{VARS}->{'postdata'}); } - $helper->{VARS}->{'symb'}= - &Apache::lonenc::check_encrypt($helper->{VARS}->{'symb'}); + if ($helper->{VARS}->{'symb'} ne '') { + $helper->{VARS}->{'symb'}= + &Apache::lonenc::check_encrypt($helper->{VARS}->{'symb'}); + } my ($resourceTitle,$sequenceTitle,$mapTitle) = &details_for_menu($helper); if ($sequenceTitle ne '') {$helper->{VARS}->{'assignment'}=$sequenceTitle;} @@ -4712,6 +4714,21 @@ CHOOSE_FROM_SUBDIR CHOOSE_FROM_ANY_SEQUENCE } + my $numchoices = 0; + if (ref($printChoices) eq 'ARRAY') { + $numchoices = @{$printChoices}; + } + # Early out if nothing to print + if (!$numchoices) { + $r->print(&Apache::loncommon::start_page('Printing Helper'). + '

'.&mt('Unable to determine print context').'

'. + '

'.&mt('Please display a resource, and then click the "Print" button/icon').'

'); + my $prtspool=$r->dir_config('lonPrtDir'); + my $footer = &recently_generated($prtspool); + $r->print($footer.&Apache::loncommon::end_page()); + return OK; + } + # Generate the first state, to select which resources get printed. Apache::lonhelper::state->new("START", "Select Printing Options:"); if (!$res_printable) {