--- loncom/interface/lonprintout.pm 2019/08/17 23:37:03 1.627.2.29
+++ loncom/interface/lonprintout.pm 2023/01/17 18:09:25 1.627.2.32.2.3
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.627.2.29 2019/08/17 23:37:03 raeburn Exp $
+# $Id: lonprintout.pm,v 1.627.2.32.2.3 2023/01/17 18:09:25 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1344,8 +1344,8 @@ sub latex_header_footer_remove {
# necessity is determined by the problem_split param.
#
sub encapsulate_minipage {
- my ($text) = @_;
- if (!($env{'form.problem.split'} =~ /yes/i)) {
+ my ($text,$problem_split) = @_;
+ if (!($problem.split =~ /yes/i)) {
$text = '\begin{minipage}{\textwidth}'.$text.'\end{minipage}';
}
return $text;
@@ -2076,16 +2076,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;
@@ -2123,19 +2135,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' =>
@@ -2151,7 +2156,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:
@@ -2161,11 +2166,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);
@@ -2549,7 +2553,7 @@ sub print_construction_sequence {
my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm ';
$body.=&path_to_problem($urlp,$LaTeXwidth);
$body.='\vskip 1 mm '.$answer.'\end{document}';
- $body = &encapsulate_minipage($body);
+ $body = &encapsulate_minipage($body,$answerform{'problem_split'});
$texversion.=$body;
}
}
@@ -2941,7 +2945,6 @@ ENDPART
&Apache::lonenc::reset_enc();
-
# Note due to document structure, not allowed to put \newpage
# prior to the first resource
@@ -3014,7 +3017,7 @@ ENDPART
my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm ';
$body .= &path_to_problem ($urlp,$LaTeXwidth);
$body .='\vskip 1 mm '.$answer;
- $body = &encapsulate_minipage($body);
+ $body = &encapsulate_minipage($body,$answerform{'problem_split'});
$texversion .= $body;
} else {
$texversion='';
@@ -3240,7 +3243,7 @@ ENDPART
my @lines = &Apache::lonnet::get_scantronformat_file();
my ($code_type,$code_length,$bubbles_per_row)=('letter',6,10);
foreach my $line (@lines) {
- chomp($line);
+ next if (($line =~ /^\#/) || ($line eq ''));
my ($name,$type,$length,$bubbles_per_item) =
(split(/:/,$line))[0,2,4,17];
if ($name eq $code_option) {
@@ -3252,18 +3255,10 @@ ENDPART
}
}
}
- my ($randomorder,$randompick,$map);
+ my $map;
if ($helper->{VARS}{'symb'}) {
($map, my $id, my $resource) =
&Apache::lonnet::decode_symb($helper->{VARS}{'symb'});
- my $navmap = Apache::lonnavmaps::navmap->new();
- if (defined($navmap)) {
- if ($map) {
- my $mapres = $navmap->getResourceByUrl($map);
- $randomorder = $mapres->randomorder();
- $randompick = $mapres->randompick();
- }
- }
}
my %moreenv = ('textwidth' => &get_textwidth($helper,$LaTeXwidth));
$moreenv{'problem_split'} = $parmhash{'problem_stream_switch'};
@@ -3332,14 +3327,11 @@ ENDPART
} else {
$moreenv{'CODE'}=&num_to_letters($code);
}
- my $actual_seq = \@master_seq;
- if ($randomorder || $randompick) {
- $env{'form.CODE'} = $moreenv{'CODE'};
- $actual_seq = master_seq_to_person_seq($map, \@master_seq,
- undef,
- $moreenv{'CODE'}, $nohidemap);
- delete($env{'form.CODE'});
- }
+ $env{'form.CODE'} = $moreenv{'CODE'};
+ my $actual_seq = master_seq_to_person_seq($map, \@master_seq,
+ undef,
+ $moreenv{'CODE'}, $nohidemap);
+ delete($env{'form.CODE'});
my ($output,$fullname, $printed)=
&print_resources($r,$helper,'anonymous',$type,\%moreenv,
$actual_seq,$flag_latex_header_remove,
@@ -3457,12 +3449,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;
}
}
@@ -3483,7 +3476,9 @@ ENDPART
if ($usehttp) {
$URLback .= (($URLback =~ /\?/) ? '&':'?').'usehttp=1';
}
- $URLback .= (($URLback =~ /\?/) ? '&':'?').'symb='.&escape($symb.$anchor);
+ unless ($plainurl =~ /\.page$/) {
+ $URLback .= (($URLback =~ /\?/) ? '&':'?').'symb='.&escape($symb.$anchor);
+ }
}
}
#
@@ -3737,7 +3732,7 @@ sub print_resources {
my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm ';
$body .=&path_to_problem($res_url,$LaTeXwidth);
$body .='\vskip 1 mm '.$ansrendered;
- $body = &encapsulate_minipage($body);
+ $body = &encapsulate_minipage($body,$answerenv{'problem_split'});
$rendered = $header.$body;
}
}
@@ -3827,7 +3822,7 @@ sub print_resources {
$message = &mt('No incomplete resources');
}
if ($message) {
- $current_output = &encapsulate_minipage("\\vskip -10mm \n$message\n \\vskip 100 mm { }\n");
+ $current_output = &encapsulate_minipage("\\vskip -10mm \n$message\n \\vskip 100 mm { }\n",$moreenv->{'problem_split'});
}
if ($remove_latex_header eq "NO") {
$current_output = &print_latex_header() . $current_output;
@@ -3888,8 +3883,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 '') {
@@ -4076,18 +4072,12 @@ sub printHelper {
$helper->{VARS}->{'symb'} = $env{'form.symb'};
}
if ($env{'form.url'}) {
- $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($helper->{VARS}->{'postdata'});
+ unless ($env{'form.url'} eq '/adm/navmaps') {
+ $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($helper->{VARS}->{'postdata'});
+ }
}
-
- }
-
- if ($env{'form.symb'}) {
- $helper->{VARS}->{'symb'} = $env{'form.symb'};
}
- if ($env{'form.url'}) {
- $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($helper->{VARS}->{'postdata'});
- }
if ($helper->{VARS}->{'symb'} ne '') {
$helper->{VARS}->{'symb'}=
&Apache::lonenc::check_encrypt($helper->{VARS}->{'symb'});
@@ -4312,7 +4302,7 @@ sub printHelper {
if ($userCanPrint || &printable($map_open, $map_close)) {
push(@{$printChoices},
- [&mt('Selected [_1]Incomplete Problems[_2] from folder [_3]' . $textSuffix,
+ [&mt('Selected [_1]Incomplete Problems[_2] from folder [_3]' . $textSuffix,
'', '',
''. $sequenceTitle . ''),
$printSelector,
@@ -4362,7 +4352,8 @@ sub printHelper {
# BZ 5209 - incomplete problems from entire course:
push(@{$printChoices},
- [&mtn('Selected Incomplete Problems from entire course for selected people'),
+ [&mt('Selected [_1]Incomplete Problems[_2] from [_3]entire course[_4] for [_5]selected people[_6]',
+ '','','','','',''),
'incomplete_problems_selpeople_course', 'INCOMPLETE_PROBLEMS_COURSE_RESOURCES']);
my $helperFragment = &create_incomplete_course_helper($helper); # Create needed states.
@@ -4370,9 +4361,9 @@ sub printHelper {
# Selected problems/resources from entire course:
- push @{$printChoices}, [&mtn('Selected Problems from entire course'), 'all_problems', 'ALL_PROBLEMS'];
- push @{$printChoices}, [&mtn('Selected Resources from entire course'), 'all_resources', 'ALL_RESOURCES'];
- push @{$printChoices}, [&mtn('Selected Problems from entire course for selected people'), 'all_problems_students', 'ALL_PROBLEMS_STUDENTS'];
+ push @{$printChoices}, [&mt('Selected [_1]Problems[_2] from [_3]entire course[_4]','','','',''), 'all_problems', 'ALL_PROBLEMS'];
+ push @{$printChoices}, [&mt('Selected [_1]Resources[_2] from [_3]entire course[_4]','','','',''), 'all_resources', 'ALL_RESOURCES'];
+ push @{$printChoices}, [&mt('Selected [_1]Problems[_2] from [_3]entire course[_4] for [_5]selected people[_6]','','','','','',''), 'all_problems_students', 'ALL_PROBLEMS_STUDENTS'];
my $suffixXml = <
Select sorting order of printout
@@ -4529,6 +4520,7 @@ ALL_PROBLEMS
my @lines = &Apache::lonnet::get_scantronformat_file();
my $codechoice='';
foreach my $line (@lines) {
+ next if (($line =~ /^\#/) || ($line eq ''));
my ($name,$description,$code_type,$code_length)=
(split(/:/,$line))[0,1,2,4];
if ($code_length > 0 &&
@@ -4706,8 +4698,9 @@ CHOOSE_FROM_SUBDIR
# Allow the user to select any sequence in the course, feed it to
# another resource selector for that sequence
if (!$helper->{VARS}->{'construction'} && !$is_published) {
- push @$printChoices, [&mtn("Selected Resources from selected folder in course"),
- 'select_sequences', 'CHOOSE_SEQUENCE'];
+ push(@$printChoices, [&mt('Selected [_1]Resources[_2] from [_3]selected folder[_4] in course',
+ '','','',''),
+ 'select_sequences', 'CHOOSE_SEQUENCE']);
my $escapedSequenceName = $helper->{VARS}->{'SEQUENCE'};
#Escape apostrophes and backslashes for Perl
$escapedSequenceName =~ s/\\/\\\\/g;
@@ -4726,7 +4719,7 @@ CHOOSE_FROM_SUBDIR
(mark desired resources then click "next" button)
+ closeallpages="1" modallink="1" suppressNavmap="1">
PAGESIZE
return $isNotMap
return '$escapedSequenceName';