version 1.670, 2020/02/17 13:40:16
|
version 1.677, 2022/06/11 14:20:41
|
Line 1339 sub latex_header_footer_remove {
|
Line 1339 sub latex_header_footer_remove {
|
# necessity is determined by the problem_split param. |
# necessity is determined by the problem_split param. |
# |
# |
sub encapsulate_minipage { |
sub encapsulate_minipage { |
my ($text) = @_; |
my ($text,$problem_split) = @_; |
if (!($env{'form.problem.split'} =~ /yes/i)) { |
if (!($problem_split =~ /yes/i)) { |
$text = '\begin{minipage}{\textwidth}'.$text.'\end{minipage}'; |
$text = '\begin{minipage}{\textwidth}'.$text.'\end{minipage}'; |
} |
} |
return $text; |
return $text; |
Line 2072 sub get_textwidth {
|
Line 2072 sub get_textwidth {
|
|
|
sub unsupported { |
sub unsupported { |
my ($currentURL,$mode,$symb)=@_; |
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} |
if ($mode ne '') {$mode='\\'.$mode} |
my $result.= &print_latex_header($mode); |
my $result = &print_latex_header($mode); |
if ($currentURL=~m|^(/adm/wrapper/)?ext/|) { |
if ($cleanURL=~m|^(/adm/wrapper)?/ext/|) { |
$currentURL=~s|^(/adm/wrapper/)?ext/|http://|; |
$cleanURL=~s|^(/adm/wrapper)?/ext/|http://|; |
$currentURL=~s|^http://https://?|https://|; |
$cleanURL=~s|^http://https://|https://|; |
my $title=&Apache::lonnet::gettitle($symb); |
if ($shown eq $currentURL) { |
$title = &Apache::lonxml::latex_special_symbols($title); |
$shown = &Apache::lonxml::latex_special_symbols($cleanURL); |
my $url = &Apache::lonxml::latex_special_symbols($currentURL); |
} |
$result.=' \strut \\\\ '.$title.' \strut \\\\ '.$url.' '; |
my $title=&Apache::lonnet::gettitle($symb); |
|
$title = &Apache::lonxml::latex_special_symbols($title); |
|
$result.=' \strut \\\\ \textit{'.$title.'} \strut \\\\ '.$shown.' '; |
} else { |
} else { |
$result.= &Apache::lonxml::latex_special_symbols($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}'; |
$result.= '\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill} \end{document}'; |
return $result; |
return $result; |
Line 2120 sub print_page_in_course {
|
Line 2131 sub print_page_in_course {
|
$numberofcolumns); |
$numberofcolumns); |
my $LaTeXwidth=&recalcto_mm($textwidth); |
my $LaTeXwidth=&recalcto_mm($textwidth); |
|
|
|
|
if ($mode ne '') {$mode='\\'.$mode} |
if ($mode ne '') {$mode='\\'.$mode} |
my $result = &print_latex_header($mode); |
my $result = &print_latex_header($mode); |
if ($currentURL=~m|^(/adm/wrapper/)?ext/|) { |
|
$currentURL=~s|^(/adm/wrapper/)?ext/|http://|; |
my $title=&Apache::lonnet::gettitle($currentURL); |
my $title=&Apache::lonnet::gettitle($symb); |
$title = &Apache::lonxml::latex_special_symbols($title); |
$title = &Apache::lonxml::latex_special_symbols($title); |
$result .= '\noindent\textit{'.$title.'}\\\\'; |
} else { |
|
my $esc_currentURL= $currentURL; |
|
$esc_currentURL =~ s/_/\\_/g; |
|
$result.=$esc_currentURL; |
|
} |
|
$result .= '\\\\'; |
|
|
|
if ($helper->{'VARS'}->{'style_file'}=~/\w/) { |
if ($helper->{'VARS'}->{'style_file'}=~/\w/) { |
&Apache::lonnet::appenv({'construct.style' => |
&Apache::lonnet::appenv({'construct.style' => |
Line 2148 sub print_page_in_course {
|
Line 2152 sub print_page_in_course {
|
|
|
foreach my $resource (@page_resources) { |
foreach my $resource (@page_resources) { |
my $resource_src = $resource->src(); # Essentially the URL of the resource. |
my $resource_src = $resource->src(); # Essentially the URL of the resource. |
$result .= $resource->title() . '\\\\'; |
my $current_url = $resource->link(); |
|
|
# Recurse if a .page: |
# Recurse if a .page: |
|
|
Line 2158 sub print_page_in_course {
|
Line 2162 sub print_page_in_course {
|
$result .= &print_page_in_course($helper, $rparmhash, |
$result .= &print_page_in_course($helper, $rparmhash, |
$resource_src, \@page_resources); |
$resource_src, \@page_resources); |
} elsif ($resource->ext()) { |
} elsif ($resource->ext()) { |
$result .= &unsupported($currentURL,$mode,$symb); |
$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: |
# these resources go through the XML transformer: |
|
$result .= &Apache::lonxml::latex_special_symbols($resource->title()) . '\\\\'; |
elsif ($resource_src =~ /\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm)$/) { |
|
|
|
my $urlp = &Apache::lonnet::clutter($resource_src); |
my $urlp = &Apache::lonnet::clutter($resource_src); |
|
|
Line 2546 sub print_construction_sequence {
|
Line 2549 sub print_construction_sequence {
|
my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm '; |
my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm '; |
$body.=&path_to_problem($urlp,$LaTeXwidth); |
$body.=&path_to_problem($urlp,$LaTeXwidth); |
$body.='\vskip 1 mm '.$answer.'\end{document}'; |
$body.='\vskip 1 mm '.$answer.'\end{document}'; |
$body = &encapsulate_minipage($body); |
$body = &encapsulate_minipage($body,$answerform{'problem_split'}); |
$texversion.=$body; |
$texversion.=$body; |
} |
} |
} |
} |
Line 2939 ENDPART
|
Line 2942 ENDPART
|
|
|
&Apache::lonenc::reset_enc(); |
&Apache::lonenc::reset_enc(); |
|
|
|
|
# Note due to document structure, not allowed to put \newpage |
# Note due to document structure, not allowed to put \newpage |
# prior to the first resource |
# prior to the first resource |
|
|
Line 3012 ENDPART
|
Line 3014 ENDPART
|
my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm '; |
my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm '; |
$body .= &path_to_problem ($urlp,$LaTeXwidth); |
$body .= &path_to_problem ($urlp,$LaTeXwidth); |
$body .='\vskip 1 mm '.$answer; |
$body .='\vskip 1 mm '.$answer; |
$body = &encapsulate_minipage($body); |
$body = &encapsulate_minipage($body,$answerform{'problem_split'}); |
$texversion .= $body; |
$texversion .= $body; |
} else { |
} else { |
$texversion=''; |
$texversion=''; |
Line 3238 ENDPART
|
Line 3240 ENDPART
|
my @lines = &Apache::lonnet::get_scantronformat_file(); |
my @lines = &Apache::lonnet::get_scantronformat_file(); |
my ($code_type,$code_length,$bubbles_per_row)=('letter',6,10); |
my ($code_type,$code_length,$bubbles_per_row)=('letter',6,10); |
foreach my $line (@lines) { |
foreach my $line (@lines) { |
chomp($line); |
|
my ($name,$type,$length,$bubbles_per_item) = |
my ($name,$type,$length,$bubbles_per_item) = |
(split(/:/,$line))[0,2,4,17]; |
(split(/:/,$line))[0,2,4,17]; |
if ($name eq $code_option) { |
if ($name eq $code_option) { |
Line 3250 ENDPART
|
Line 3251 ENDPART
|
} |
} |
} |
} |
} |
} |
my ($randomorder,$randompick,$map); |
my $map; |
if ($helper->{VARS}{'symb'}) { |
if ($helper->{VARS}{'symb'}) { |
($map, my $id, my $resource) = |
($map, my $id, my $resource) = |
&Apache::lonnet::decode_symb($helper->{VARS}{'symb'}); |
&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)); |
my %moreenv = ('textwidth' => &get_textwidth($helper,$LaTeXwidth)); |
$moreenv{'problem_split'} = $parmhash{'problem_stream_switch'}; |
$moreenv{'problem_split'} = $parmhash{'problem_stream_switch'}; |
Line 3330 ENDPART
|
Line 3323 ENDPART
|
} else { |
} else { |
$moreenv{'CODE'}=&num_to_letters($code); |
$moreenv{'CODE'}=&num_to_letters($code); |
} |
} |
my $actual_seq = \@master_seq; |
$env{'form.CODE'} = $moreenv{'CODE'}; |
if ($randomorder || $randompick) { |
my $actual_seq = master_seq_to_person_seq($map, \@master_seq, |
$env{'form.CODE'} = $moreenv{'CODE'}; |
undef, |
$actual_seq = master_seq_to_person_seq($map, \@master_seq, |
$moreenv{'CODE'}, $nohidemap); |
undef, |
delete($env{'form.CODE'}); |
$moreenv{'CODE'}, $nohidemap); |
|
delete($env{'form.CODE'}); |
|
} |
|
my ($output,$fullname, $printed)= |
my ($output,$fullname, $printed)= |
&print_resources($r,$helper,'anonymous',$type,\%moreenv, |
&print_resources($r,$helper,'anonymous',$type,\%moreenv, |
$actual_seq,$flag_latex_header_remove, |
$actual_seq,$flag_latex_header_remove, |
Line 3455 ENDPART
|
Line 3445 ENDPART
|
my ($map, $id, $url) = &Apache::lonnet::decode_symb($helper->{VARS}{'symb'}); |
my ($map, $id, $url) = &Apache::lonnet::decode_symb($helper->{VARS}{'symb'}); |
my $cdom =$env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cdom =$env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cnum =$env{'course.'.$env{'request.course.id'}.'.num'}; |
my $cnum =$env{'course.'.$env{'request.course.id'}.'.num'}; |
my ($anchor,$usehttp); |
my ($anchor,$usehttp,$plainurl); |
$url = &Apache::lonnet::clutter($url); |
$url = &Apache::lonnet::clutter($url); |
|
$plainurl = $url; |
if (($ENV{'SERVER_PORT'} == 443) && ($env{'request.course.id'}) && |
if (($ENV{'SERVER_PORT'} == 443) && ($env{'request.course.id'}) && |
(($url =~ m{^\Q/public/$cdom/$cnum/syllabus\E($|\?)}) || |
(($url =~ m{^\Q/public/$cdom/$cnum/syllabus\E($|\?)}) || |
($url =~ m{^\Q/adm/wrapper/ext/\E(?!https:)}))) { |
($url =~ m{^\Q/adm/wrapper/ext/\E(?!https:)}))) { |
unless (&Apache::lonnet::uses_sts()) { |
unless ((&Apache::lonnet::uses_sts()) || (&Apache::lonnet::waf_allssl())) { |
$usehttp = 1; |
$usehttp = 1; |
} |
} |
} |
} |
Line 3481 ENDPART
|
Line 3472 ENDPART
|
if ($usehttp) { |
if ($usehttp) { |
$URLback .= (($URLback =~ /\?/) ? '&':'?').'usehttp=1'; |
$URLback .= (($URLback =~ /\?/) ? '&':'?').'usehttp=1'; |
} |
} |
$URLback .= (($URLback =~ /\?/) ? '&':'?').'symb='.&escape($symb.$anchor); |
unless ($plainurl =~ /\.page$/) { |
|
$URLback .= (($URLback =~ /\?/) ? '&':'?').'symb='.&escape($symb.$anchor); |
|
} |
} |
} |
} |
} |
# |
# |
Line 3733 sub print_resources {
|
Line 3726 sub print_resources {
|
my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm '; |
my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm '; |
$body .=&path_to_problem($res_url,$LaTeXwidth); |
$body .=&path_to_problem($res_url,$LaTeXwidth); |
$body .='\vskip 1 mm '.$ansrendered; |
$body .='\vskip 1 mm '.$ansrendered; |
$body = &encapsulate_minipage($body); |
$body = &encapsulate_minipage($body,$answerenv{'problem_split'}); |
$rendered = $header.$body; |
$rendered = $header.$body; |
} |
} |
} |
} |
Line 3823 sub print_resources {
|
Line 3816 sub print_resources {
|
$message = &mt('No incomplete resources'); |
$message = &mt('No incomplete resources'); |
} |
} |
if ($message) { |
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") { |
if ($remove_latex_header eq "NO") { |
$current_output = &print_latex_header() . $current_output; |
$current_output = &print_latex_header() . $current_output; |
Line 3885 sub handler {
|
Line 3878 sub handler {
|
if ($env{'request.course.id'}) { |
if ($env{'request.course.id'}) { |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'}; |
|
my $clientip = &Apache::lonnet::get_requestor_ip($r); |
my ($blocked,$blocktext) = |
my ($blocked,$blocktext) = |
&Apache::loncommon::blocking_status('printout',$cnum,$cdom); |
&Apache::loncommon::blocking_status('printout',$clientip,$cnum,$cdom); |
if ($blocked) { |
if ($blocked) { |
my $checkrole = "cm./$cdom/$cnum"; |
my $checkrole = "cm./$cdom/$cnum"; |
if ($env{'request.course.sec'} ne '') { |
if ($env{'request.course.sec'} ne '') { |