--- loncom/interface/lonprintout.pm 2018/12/29 23:24:40 1.666 +++ loncom/interface/lonprintout.pm 2021/11/30 15:55:37 1.674 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.666 2018/12/29 23:24:40 raeburn Exp $ +# $Id: lonprintout.pm,v 1.674 2021/11/30 15:55:37 raeburn Exp $ # # Copyright Michigan State University Board of Trustees # @@ -847,8 +847,9 @@ sub set_font_size { if ($font_size ne '') { $text =~ s/\\begin\{document}/\\begin{document}{\\$font_size/; + $text =~ s/\\end\{document}/}\\end{document}/; + } - $text =~ s/\\end\{document}/}\\end{document}/; return $text; @@ -1233,7 +1234,7 @@ sub is_valid_alpha_code { sub is_code_valid { my ($code_value, $code_option) = @_; my ($code_type, $code_length) = ('letter', 6); # defaults. - my @lines = &Apache::grades::get_scantronformat_file(); + my @lines = &Apache::lonnet::get_scantronformat_file(); foreach my $line (@lines) { my ($name, $type, $length) = (split(/:/, $line))[0,2,4]; if($name eq $code_option) { @@ -2071,16 +2072,28 @@ sub get_textwidth { sub unsupported { my ($currentURL,$mode,$symb)=@_; + my $cleanURL=&Apache::lonenc::check_decrypt($currentURL); + my $shown = $currentURL; + if (($cleanURL ne $currentURL) || ($symb =~ m{/^enc/})) { + $shown = &mt('URL not shown (encrypted)'); + } if ($mode ne '') {$mode='\\'.$mode} - my $result.= &print_latex_header($mode); - if ($currentURL=~m|^(/adm/wrapper/)?ext/|) { - $currentURL=~s|^(/adm/wrapper/)?ext/|http://|; - $currentURL=~s|^http://https://|https://|; - my $title=&Apache::lonnet::gettitle($symb); - $title = &Apache::lonxml::latex_special_symbols($title); - $result.=' \strut \\\\ '.$title.' \strut \\\\ '.$currentURL.' '; + my $result = &print_latex_header($mode); + if ($cleanURL=~m|^(/adm/wrapper)?/ext/|) { + $cleanURL=~s|^(/adm/wrapper)?/ext/|http://|; + $cleanURL=~s|^http://https://|https://|; + if ($shown eq $currentURL) { + $shown = &Apache::lonxml::latex_special_symbols($cleanURL); + } + my $title=&Apache::lonnet::gettitle($symb); + $title = &Apache::lonxml::latex_special_symbols($title); + $result.=' \strut \\\\ \textit{'.$title.'} \strut \\\\ '.$shown.' '; } else { - $result.=$currentURL; + if ($shown eq $currentURL) { + $result.=&Apache::lonxml::latex_special_symbols($currentURL); + } else { + $result.=$shown; + } } $result.= '\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill} \end{document}'; return $result; @@ -2118,19 +2131,12 @@ sub print_page_in_course { $numberofcolumns); my $LaTeXwidth=&recalcto_mm($textwidth); - if ($mode ne '') {$mode='\\'.$mode} my $result = &print_latex_header($mode); - if ($currentURL=~m|^(/adm/wrapper/)?ext/|) { - $currentURL=~s|^(/adm/wrapper/)?ext/|http://|; - my $title=&Apache::lonnet::gettitle($symb); - $title = &Apache::lonxml::latex_special_symbols($title); - } else { - my $esc_currentURL= $currentURL; - $esc_currentURL =~ s/_/\\_/g; - $result.=$esc_currentURL; - } - $result .= '\\\\'; + + my $title=&Apache::lonnet::gettitle($currentURL); + $title = &Apache::lonxml::latex_special_symbols($title); + $result .= '\noindent\textit{'.$title.'}\\\\'; if ($helper->{'VARS'}->{'style_file'}=~/\w/) { &Apache::lonnet::appenv({'construct.style' => @@ -2146,7 +2152,7 @@ sub print_page_in_course { foreach my $resource (@page_resources) { my $resource_src = $resource->src(); # Essentially the URL of the resource. - $result .= $resource->title() . '\\\\'; + my $current_url = $resource->link(); # Recurse if a .page: @@ -2156,11 +2162,10 @@ sub print_page_in_course { $result .= &print_page_in_course($helper, $rparmhash, $resource_src, \@page_resources); } elsif ($resource->ext()) { - $result .= &unsupported($currentURL,$mode,$symb); - } - # these resources go through the XML transformer: - - elsif ($resource_src =~ /\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm)$/) { + $result.=&latex_header_footer_remove(&unsupported($current_url,$mode,$resource->symb)); + } elsif ($resource_src =~ /\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm)$/) { + # these resources go through the XML transformer: + $result .= &Apache::lonxml::latex_special_symbols($resource->title()) . '\\\\'; my $urlp = &Apache::lonnet::clutter($resource_src); @@ -2937,7 +2942,6 @@ ENDPART &Apache::lonenc::reset_enc(); - # Note due to document structure, not allowed to put \newpage # prior to the first resource @@ -3233,7 +3237,7 @@ ENDPART my $single_code = $helper->{'VARS'}->{'SINGLE_CODE'}; my $selected_code = $helper->{'VARS'}->{'CODE_SELECTED_FROM_LIST'}; my $code_option=$helper->{'VARS'}->{'CODE_OPTION'}; - my @lines = &Apache::grades::get_scantronformat_file(); + my @lines = &Apache::lonnet::get_scantronformat_file(); my ($code_type,$code_length,$bubbles_per_row)=('letter',6,10); foreach my $line (@lines) { chomp($line); @@ -3453,12 +3457,13 @@ ENDPART my ($map, $id, $url) = &Apache::lonnet::decode_symb($helper->{VARS}{'symb'}); my $cdom =$env{'course.'.$env{'request.course.id'}.'.domain'}; my $cnum =$env{'course.'.$env{'request.course.id'}.'.num'}; - my ($anchor,$usehttp); + my ($anchor,$usehttp,$plainurl); $url = &Apache::lonnet::clutter($url); + $plainurl = $url; if (($ENV{'SERVER_PORT'} == 443) && ($env{'request.course.id'}) && (($url =~ m{^\Q/public/$cdom/$cnum/syllabus\E($|\?)}) || ($url =~ m{^\Q/adm/wrapper/ext/\E(?!https:)}))) { - unless (&Apache::lonnet::uses_sts()) { + unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl())) { $usehttp = 1; } } @@ -3479,7 +3484,9 @@ ENDPART if ($usehttp) { $URLback .= (($URLback =~ /\?/) ? '&':'?').'usehttp=1'; } - $URLback .= (($URLback =~ /\?/) ? '&':'?').'symb='.&escape($symb.$anchor); + unless ($plainurl =~ /\.page$/) { + $URLback .= (($URLback =~ /\?/) ? '&':'?').'symb='.&escape($symb.$anchor); + } } } # @@ -3883,8 +3890,9 @@ sub handler { if ($env{'request.course.id'}) { my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; + my $clientip = &Apache::lonnet::get_requestor_ip($r); my ($blocked,$blocktext) = - &Apache::loncommon::blocking_status('printout',$cnum,$cdom); + &Apache::loncommon::blocking_status('printout',$clientip,$cnum,$cdom); if ($blocked) { my $checkrole = "cm./$cdom/$cnum"; if ($env{'request.course.sec'} ne '') { @@ -4081,10 +4089,11 @@ sub printHelper { } if ($env{'form.url'}) { $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;} @@ -4519,7 +4528,7 @@ ALL_PROBLEMS } - my @lines = &Apache::grades::get_scantronformat_file(); + my @lines = &Apache::lonnet::get_scantronformat_file(); my $codechoice=''; foreach my $line (@lines) { next if (($line =~ /^\#/) || ($line eq '')); @@ -4825,7 +4834,7 @@ CHOOSE_FROM_ANY_SEQUENCE my $xmlfrag = << "FONT_SELECTION"; - + return 'normalsize';