version 1.464, 2006/07/18 18:19:51
|
version 1.480, 2006/08/21 22:53:19
|
Line 1
|
Line 1
|
|
# |
# The LearningOnline Network |
# The LearningOnline Network |
# Printout |
# Printout |
# |
# |
Line 826 sub details_for_menu {
|
Line 827 sub details_for_menu {
|
return ($name_of_resource,$name_of_sequence,$name_of_map); |
return ($name_of_resource,$name_of_sequence,$name_of_map); |
} |
} |
|
|
|
sub copyright_line { |
|
return '\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\vspace*{-2 mm}\newline\noindent{\tiny Printed from LON-CAPA\copyright MSU{\hfill} Licensed under GNU General Public License } '; |
|
} |
|
my $end_of_student = "\n".'\special{ps:ENDOFSTUDENTSTAMP}'."\n"; |
|
|
sub latex_corrections { |
sub latex_corrections { |
my ($number_of_columns,$result,$selectionmade,$answer_mode) = @_; |
my ($number_of_columns,$result,$selectionmade,$answer_mode) = @_; |
# $result =~ s/\\includegraphics{/\\includegraphics\[width=\\minipagewidth\]{/g; |
# $result =~ s/\\includegraphics{/\\includegraphics\[width=\\minipagewidth\]{/g; |
$result =~ s/\$number_of_columns/$number_of_columns/g; |
my $copyright = ©right_line(); |
if ($selectionmade eq '1' || $answer_mode eq 'only') { |
if ($selectionmade eq '1' || $answer_mode eq 'only') { |
$result =~ s/(\\end{document})/\\strut\\vskip 0 mm\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill}\\newline\\noindent\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License $1/; |
$result =~ s/(\\end{document})/\\strut\\vskip 0 mm $copyright $end_of_student $1/; |
} else { |
} else { |
$result =~ s/(\\end{document})/\\strut\\vspace\*{-4 mm}\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill}\\newline\\noindent\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License $1/; |
$result =~ s/(\\end{document})/\\strut\\vspace\*{-4 mm}\\newline $copyright $end_of_student $1/; |
} |
} |
|
$result =~ s/\$number_of_columns/$number_of_columns/g; |
$result =~ s/(\\end{longtable}\s*)(\\strut\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill})/$2$1/g; |
$result =~ s/(\\end{longtable}\s*)(\\strut\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill})/$2$1/g; |
$result =~ s/(\\end{longtable}\s*)\\strut\\newline/$1/g; |
$result =~ s/(\\end{longtable}\s*)\\strut\\newline/$1/g; |
#-- LaTeX corrections |
#-- LaTeX corrections |
Line 892 sub IndexCreation {
|
Line 898 sub IndexCreation {
|
|
|
sub print_latex_header { |
sub print_latex_header { |
my $mode=shift; |
my $mode=shift; |
my $output='\documentclass[letterpaper,twoside]{article}'; |
my $output='\documentclass[letterpaper,twoside]{article}\raggedbottom'; |
if (($mode eq 'batchmode') || (!$perm{'pav'})) { |
if (($mode eq 'batchmode') || (!$perm{'pav'})) { |
$output.='\batchmode'; |
$output.='\batchmode'; |
} |
} |
Line 1045 sub recently_generated {
|
Line 1051 sub recently_generated {
|
# my $helpervars = Dumper($helper->{'VARS'}); |
# my $helpervars = Dumper($helper->{'VARS'}); |
# &Apache::lonnet::logthis("Dump of helper vars:\n $helpervars"); |
# &Apache::lonnet::logthis("Dump of helper vars:\n $helpervars"); |
#} |
#} |
|
#sub dump_env { |
|
# my $envvars = Dumper(\%env); |
|
# &Apache::lonnet::logthis("Dump of env: \n $envvars"); |
|
#} |
|
|
sub get_page_breaks { |
#sub get_page_breaks { |
my ($helper) = @_; |
# my ($helper) = @_; |
my %page_breaks; |
# my %page_breaks; |
|
# |
foreach my $break (split /\|\|\|/, $helper->{'VARS'}->{'FINISHPAGE'}) { |
# foreach my $break (split /\|\|\|/, $helper->{'VARS'}->{'FINISHPAGE'}) { |
$page_breaks{$break} = 1; |
# $page_breaks{$break} = 1; |
} |
# } |
return %page_breaks; |
# return %page_breaks; |
} |
#} |
|
|
# Output a sequence (recursively if neeed) |
# Output a sequence (recursively if neeed) |
# from construction space. |
# from construction space. |
Line 1104 sub print_construction_sequence {
|
Line 1114 sub print_construction_sequence {
|
$answerform{'answer_output_mode'}='tex'; |
$answerform{'answer_output_mode'}='tex'; |
$answerform{'rndseed'}=$rndseed; |
$answerform{'rndseed'}=$rndseed; |
$answerform{'problem_split'}=$parmhash{'problem_stream_switch'}; |
$answerform{'problem_split'}=$parmhash{'problem_stream_switch'}; |
if ($urlp=~/\/res\//) {$env{'request.state'}='published';} |
if ($urlp=~/\/res\//) { |
|
$env{'request.state'}='published'; |
|
} |
|
|
$resources_printed .= $urlp.':'; |
$resources_printed .= $urlp.':'; |
my $answer=&Apache::lonnet::ssi($urlp,%answerform); |
my $answer=&Apache::lonnet::ssi($urlp,%answerform); |
if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { |
if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { |
Line 1113 sub print_construction_sequence {
|
Line 1126 sub print_construction_sequence {
|
# If necessary, encapsulate answer in minipage: |
# If necessary, encapsulate answer in minipage: |
|
|
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
my $body ='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'}).'}\vskip 0 mm '; |
my $title = &Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'}); |
|
$title = &Apache::lonxml::latex_special_symbols($title); |
|
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); |
Line 1190 ENDPART
|
Line 1205 ENDPART
|
my $start_page = &Apache::loncommon::start_page('Preparing Printout',$js); |
my $start_page = &Apache::loncommon::start_page('Preparing Printout',$js); |
my $msg = &mt('Please stand by while processing your print request, this may take some time ...'); |
my $msg = &mt('Please stand by while processing your print request, this may take some time ...'); |
|
|
|
|
|
|
$r->print($start_page."\n<p>\n$msg\n</p>\n"); |
$r->print($start_page."\n<p>\n$msg\n</p>\n"); |
|
|
# fetch the pagebreaks and store them in the course environment |
# fetch the pagebreaks and store them in the course environment |
Line 1241 ENDPART
|
Line 1258 ENDPART
|
} |
} |
|
|
if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'current_document') { |
if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'current_document') { |
|
|
#-- single document - problem, page, html, xml, ... |
#-- single document - problem, page, html, xml, ... |
my ($currentURL,$cleanURL); |
my ($currentURL,$cleanURL); |
|
|
Line 1308 ENDPART
|
Line 1326 ENDPART
|
} else { |
} else { |
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
if ($helper->{'VARS'}->{'construction'} ne '1') { |
if ($helper->{'VARS'}->{'construction'} ne '1') { |
$texversion.='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'}).'}\vskip 0 mm '; |
my $title = &Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'}); |
|
$title = &Apache::lonxml::latex_special_symbols($title); |
|
$texversion.='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm '; |
$texversion.=&path_to_problem($cleanURL,$LaTeXwidth); |
$texversion.=&path_to_problem($cleanURL,$LaTeXwidth); |
} else { |
} else { |
$texversion.='\vskip 0 mm \noindent\textbf{Prints from construction space - there is no title.}\vskip 0 mm '; |
$texversion.='\vskip 0 mm \noindent\textbf{Prints from construction space - there is no title.}\vskip 0 mm '; |
Line 1429 ENDPART
|
Line 1449 ENDPART
|
} else { |
} else { |
if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library)$/) { |
if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library)$/) { |
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
$texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
my $body ='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($master_seq[$i]).'}\vskip 0 mm '; |
my $title = &Apache::lonnet::gettitle($master_seq[$i]); |
|
$title = &Apache::lonxml::latex_special_symbols($title); |
|
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); |
Line 1753 ENDPART
|
Line 1775 ENDPART
|
$result = &page_format_transformation($papersize,$laystyle,$numberofcolumns,$helper->{'VARS'}->{'PRINT_TYPE'},$result,$helper->{VARS}->{'assignment'},$helper->{'VARS'}->{'TABLE_CONTENTS'},$helper->{'VARS'}->{'TABLE_INDEX'},$selectionmade); |
$result = &page_format_transformation($papersize,$laystyle,$numberofcolumns,$helper->{'VARS'}->{'PRINT_TYPE'},$result,$helper->{VARS}->{'assignment'},$helper->{'VARS'}->{'TABLE_CONTENTS'},$helper->{'VARS'}->{'TABLE_INDEX'},$selectionmade); |
$result = &latex_corrections($number_of_columns,$result,$selectionmade, |
$result = &latex_corrections($number_of_columns,$result,$selectionmade, |
$helper->{'VARS'}->{'ANSWER_TYPE'}); |
$helper->{'VARS'}->{'ANSWER_TYPE'}); |
for (my $i=1;$i<=$#print_array;$i++) { |
|
$print_array[$i] = |
|
&latex_corrections($number_of_columns,$print_array[$i], |
|
$selectionmade, |
|
$helper->{'VARS'}->{'ANSWER_TYPE'}); |
|
} |
|
#if ($numberofcolumns == 1) { |
#if ($numberofcolumns == 1) { |
$result =~ s/\\textwidth\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\textwidth= $helper->{'VARS'}->{'pagesize.width'} $helper->{'VARS'}->{'pagesize.widthunit'} /; |
$result =~ s/\\textwidth\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\textwidth= $helper->{'VARS'}->{'pagesize.width'} $helper->{'VARS'}->{'pagesize.widthunit'} /; |
$result =~ s/\\textheight\s*=?\s*-?\d*\.?\d*\s*(cm|mm|in)/\\textheight $helper->{'VARS'}->{'pagesize.height'} $helper->{'VARS'}->{'pagesize.heightunit'} /; |
$result =~ s/\\textheight\s*=?\s*-?\d*\.?\d*\s*(cm|mm|in)/\\textheight $helper->{'VARS'}->{'pagesize.height'} $helper->{'VARS'}->{'pagesize.heightunit'} /; |
Line 1785 ENDPART
|
Line 1801 ENDPART
|
if ($i==0) { |
if ($i==0) { |
$print_array[$i]=$result; |
$print_array[$i]=$result; |
} else { |
} else { |
|
$print_array[$i].='\end{document}'; |
|
$print_array[$i] = |
|
&latex_corrections($number_of_columns,$print_array[$i], |
|
$selectionmade, |
|
$helper->{'VARS'}->{'ANSWER_TYPE'}); |
|
|
my $anobegin=index($print_array[$i],'\setcounter{page}',0); |
my $anobegin=index($print_array[$i],'\setcounter{page}',0); |
substr($print_array[$i],0,$anobegin)=''; |
substr($print_array[$i],0,$anobegin)=''; |
$print_array[$i]=$inc.$print_array[$i].'\end{document}'; |
$print_array[$i]=$inc.$print_array[$i]; |
} |
} |
my $temp_file; |
my $temp_file; |
my $newfilename=$filename; |
my $newfilename=$filename; |
Line 1898 sub print_resources {
|
Line 1920 sub print_resources {
|
|
|
&Apache::lonxml::clear_problem_counter(); |
&Apache::lonxml::clear_problem_counter(); |
my %page_breaks = &get_page_breaks($helper); |
my %page_breaks = &get_page_breaks($helper); |
my @format_array = split(/\|/,$helper->{'VARS'}->{'FORMAT'}); |
my $columns_in_format = (split(/\|/,$helper->{'VARS'}->{'FORMAT'}))[1]; |
my $columns_in_format = $format_array[1]; |
|
# |
# |
# end each student with a |
# end each student with a |
# Special that allows the post processor to even out the page |
# Special that allows the post processor to even out the page |
Line 1947 sub print_resources {
|
Line 1968 sub print_resources {
|
|
|
|
|
my $header =&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
my $header =&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); |
my $body ='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($curresline).'}\vskip 0 mm '; |
my $title = &Apache::lonnet::gettitle($curresline); |
$body .=&path_to_problem($res_url,$LaTeXwidth); |
$title = &Apache::lonxml::latex_special_symbols($title); |
|
my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm '; |
|
$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); |
$rendered = $header.$body; |
$rendered = $header.$body; |
Line 1989 sub print_resources {
|
Line 2012 sub print_resources {
|
if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } |
if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo } |
if ($usersection ne '') {$courseidinfo.=' - Sec. '.$usersection} |
if ($usersection ne '') {$courseidinfo.=' - Sec. '.$usersection} |
my $currentassignment=&Apache::lonxml::latex_special_symbols($helper->{VARS}->{'assignment'},'header'); |
my $currentassignment=&Apache::lonxml::latex_special_symbols($helper->{VARS}->{'assignment'},'header'); |
my $HeaderLine = $parmhash{'print_header_format'}; |
my $header_line = |
$HeaderLine = format_page_header($HeaderLine, $currentassignment, $courseidinfo, $fullname); |
&format_page_header($parmhash{'print_header_format'}, |
if ($current_output=~/\\documentclass/) { |
$currentassignment, $courseidinfo, $fullname); |
if ($columns_in_format == 1) { |
my $header_start = ($columns_in_format == 1) ? '\lhead' |
$current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent\\lhead{$HeaderLine$namepostfix}}\\vskip 5 mm /; |
: '\fancyhead[LO]'; |
} else { |
$header_line = $header_start.'{'.$header_line.'}'; |
$current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent\\fancyhead[LO]{$HeaderLine$namepostfix}}\\vskip 5 mm /; |
|
|
|
} |
if ($current_output=~/\\documentclass/) { |
|
$current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent$header_line$namepostfix}\\vskip 5 mm /; |
} else { |
} else { |
my $blankpages = ''; |
my $blankpages = |
for (my $j=0;$j<$helper->{'VARS'}->{'EMPTY_PAGES'};$j++) {$blankpages.='\clearpage\strut\clearpage';} |
'\clearpage\strut\clearpage'x$helper->{'VARS'}->{'EMPTY_PAGES'}; |
if ($columns_in_format == 1) { |
|
$current_output = '\strut\vspace*{-6 mm}\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\vspace*{-2 mm}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blankpages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{'.$HeaderLine.'}'.$namepostfix.'} \vskip 5 mm '.$current_output; |
$current_output = '\strut\vspace*{-6 mm}\\newline'. |
} else { |
©right_line().' \newpage '.$blankpages.$end_of_student. |
$current_output = '\strut\vspace*{-6 mm}\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\vspace*{-2 mm}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blankpages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\fancyhead[LO]{'.$HeaderLine.'}'.$namepostfix.'} \vskip 5 mm '.$current_output; |
'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent'. |
} |
$header_line.$namepostfix.'} \vskip 5 mm '.$current_output; |
} |
} |
# |
# |
# Close the student bracketing. |
# Close the student bracketing. |
# |
# |
$current_output .= "\n\\special{ps:ENDOFSTUDENTSTAMP}\n"; |
|
return ($current_output,$fullname, $printed); |
return ($current_output,$fullname, $printed); |
|
|
} |
} |
Line 2064 sub init_perm {
|
Line 2086 sub init_perm {
|
$perm{'pav'}=&Apache::lonnet::allowed('pav', |
$perm{'pav'}=&Apache::lonnet::allowed('pav', |
$env{'request.course.id'}.'/'.$env{'request.course.sec'}); |
$env{'request.course.id'}.'/'.$env{'request.course.sec'}); |
} |
} |
$perm{'pfo'}=&Apache::lonnet::allowed('pav',$env{'request.course.id'}); |
$perm{'pfo'}=&Apache::lonnet::allowed('pfo',$env{'request.course.id'}); |
if (!$perm{'pfo'}) { |
if (!$perm{'pfo'}) { |
$perm{'pfo'}=&Apache::lonnet::allowed('pfo', |
$perm{'pfo'}=&Apache::lonnet::allowed('pfo', |
$env{'request.course.id'}.'/'.$env{'request.course.sec'}); |
$env{'request.course.id'}.'/'.$env{'request.course.sec'}); |
Line 2136 sub printHelper {
|
Line 2158 sub printHelper {
|
} |
} |
|
|
} |
} |
|
|
|
|
# This will persistently load in the data we want from the |
# This will persistently load in the data we want from the |
# very first screen. |
# very first screen. |
Line 2144 sub printHelper {
|
Line 2165 sub printHelper {
|
if ($env{'form.postdata'}=~/^(?:http:\/\/[^\/]+\/|\/|)\~([^\/]+)\/(.*)$/) { |
if ($env{'form.postdata'}=~/^(?:http:\/\/[^\/]+\/|\/|)\~([^\/]+)\/(.*)$/) { |
$helper->{VARS}->{'filename'} = "~$1/$2"; |
$helper->{VARS}->{'filename'} = "~$1/$2"; |
$helper->{VARS}->{'construction'} = 1; |
$helper->{VARS}->{'construction'} = 1; |
} else { |
} elsif ($env{'form.postdata'}) { |
if ($env{'form.postdata'}) { |
if ($env{'form.postdata'}) { |
$helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($env{'form.postdata'}); |
$helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($env{'form.postdata'}); |
} |
} |
Line 2156 sub printHelper {
|
Line 2177 sub printHelper {
|
} |
} |
|
|
} |
} |
|
|
if ($env{'form.symb'}) { |
if ($env{'form.symb'}) { |
$helper->{VARS}->{'symb'} = $env{'form.symb'}; |
$helper->{VARS}->{'symb'} = $env{'form.symb'}; |
} |
} |
Line 2168 sub printHelper {
|
Line 2188 sub printHelper {
|
&Apache::lonenc::check_encrypt($helper->{VARS}->{'symb'}); |
&Apache::lonenc::check_encrypt($helper->{VARS}->{'symb'}); |
my ($resourceTitle,$sequenceTitle,$mapTitle) = &details_for_menu($helper); |
my ($resourceTitle,$sequenceTitle,$mapTitle) = &details_for_menu($helper); |
if ($sequenceTitle ne '') {$helper->{VARS}->{'assignment'}=$sequenceTitle;} |
if ($sequenceTitle ne '') {$helper->{VARS}->{'assignment'}=$sequenceTitle;} |
|
|
|
|
# Extract map |
# Extract map |
my $symb = $helper->{VARS}->{'symb'}; |
my $symb = $helper->{VARS}->{'symb'}; |
Line 2176 sub printHelper {
|
Line 2195 sub printHelper {
|
my $subdir; |
my $subdir; |
|
|
# Get the resource name from construction space |
# Get the resource name from construction space |
|
|
|
|
if ($helper->{VARS}->{'construction'}) { |
if ($helper->{VARS}->{'construction'}) { |
$resourceTitle = substr($helper->{VARS}->{'filename'}, |
$resourceTitle = substr($helper->{VARS}->{'filename'}, |
rindex($helper->{VARS}->{'filename'}, '/')+1); |
rindex($helper->{VARS}->{'filename'}, '/')+1); |
$subdir = substr($helper->{VARS}->{'filename'}, |
$subdir = substr($helper->{VARS}->{'filename'}, |
0, rindex($helper->{VARS}->{'filename'}, '/') + 1); |
0, rindex($helper->{VARS}->{'filename'}, '/') + 1); |
} else { |
} elsif ($env{'form.postdata'} =~ /^\/res\// ) { |
|
$subdir = substr($env{'form.postdata'}, |
|
0, rindex($env{'form.postdata'}, '/') + 1); |
|
} elsif ((defined $helper->{VARS}->{'postdata'}) && |
|
($helper->{VARS}->{'postdata'} =~ /^\/res\//)){ |
|
$subdir = substr($helper->{VARS}->{'postdata'}, |
|
0, rindex($helper->{VARS}->{'postdata'}, '/') + 1); |
|
} else { # (!$helper->{VARS}->{'postdata'}) { |
($map, $id, $url) = &Apache::lonnet::decode_symb($symb); |
($map, $id, $url) = &Apache::lonnet::decode_symb($symb); |
$helper->{VARS}->{'postdata'} = |
$helper->{VARS}->{'postdata'} = |
&Apache::lonenc::check_encrypt(&Apache::lonnet::clutter($url)); |
&Apache::lonenc::check_encrypt(&Apache::lonnet::clutter($url)); |
|
|
if (!$resourceTitle) { # if the resource doesn't have a title, use the filename |
if (!$resourceTitle) { # if the resource doesn't have a title, use the filename |
my $postdata = $helper->{VARS}->{'postdata'}; |
my $postdata = $helper->{VARS}->{'postdata'}; |
$resourceTitle = substr($postdata, rindex($postdata, '/') + 1); |
$resourceTitle = substr($postdata, rindex($postdata, '/') + 1); |
Line 2201 sub printHelper {
|
Line 2228 sub printHelper {
|
|
|
my $userCanSeeHidden = Apache::lonnavmaps::advancedUser(); |
my $userCanSeeHidden = Apache::lonnavmaps::advancedUser(); |
|
|
Apache::lonhelper::registerHelperTags(); |
&Apache::lonhelper::registerHelperTags(); |
|
|
# "Delete everything after the last slash." |
# "Delete everything after the last slash." |
$subdir =~ s|/[^/]+$||; |
$subdir =~ s|/[^/]+$||; |
Line 2241 sub printHelper {
|
Line 2268 sub printHelper {
|
|
|
$helper->declareVar('SEQUENCE'); |
$helper->declareVar('SEQUENCE'); |
|
|
|
# If we're in a sequence... |
|
|
|
my $start_new_option; |
|
if ($perm{'pav'}) { |
|
$start_new_option = |
|
"<option text='".&mt('Start new page<br />before selected'). |
|
"' variable='FINISHPAGE' />"; |
|
} |
|
|
# If we're in a sequence... |
|
my $startnew=&mt('Start new page<br />before selected'); |
|
if (($helper->{'VARS'}->{'construction'} ne '1') && |
if (($helper->{'VARS'}->{'construction'} ne '1') && |
|
|
$helper->{VARS}->{'postdata'} && |
$helper->{VARS}->{'postdata'} && |
|
($helper->{VARS}->{'postdata'} !~ /^\/res\//) && |
$helper->{VARS}->{'assignment'}) { |
$helper->{VARS}->{'assignment'}) { |
# Allow problems from sequence |
# Allow problems from sequence |
push @{$printChoices}, [&mt('Selected <b>Problems</b> in folder <b><i>[_1]</i></b>',$sequenceTitle), 'map_problems', 'CHOOSE_PROBLEMS']; |
push @{$printChoices}, [&mt('Selected <b>Problems</b> in folder <b><i>[_1]</i></b>',$sequenceTitle), 'map_problems', 'CHOOSE_PROBLEMS']; |
# Allow all resources from sequence |
# Allow all resources from sequence |
push @{$printChoices}, [&mt('Selected <b>Resources</b> in folder <b><i>[_1]</i></b>',$sequenceTitle), 'map_problems_pages', 'CHOOSE_PROBLEMS_HTML']; |
push @{$printChoices}, [&mt('Selected <b>Resources</b> in folder <b><i>[_1]</i></b>',$sequenceTitle), 'map_problems_pages', 'CHOOSE_PROBLEMS_HTML']; |
|
|
my $helperFragment = <<HELPERFRAGMENT; |
my $helperFragment = <<HELPERFRAGMENT; |
<state name="CHOOSE_PROBLEMS" title="Select Problem(s) to print"> |
<state name="CHOOSE_PROBLEMS" title="Select Problem(s) to print"> |
<resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1" |
<resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1" |
Line 2261 sub printHelper {
|
Line 2295 sub printHelper {
|
<filterfunc>return $isProblem;</filterfunc> |
<filterfunc>return $isProblem;</filterfunc> |
<mapurl>$map</mapurl> |
<mapurl>$map</mapurl> |
<valuefunc>return $symbFilter;</valuefunc> |
<valuefunc>return $symbFilter;</valuefunc> |
<option text='$startnew' variable='FINISHPAGE' /> |
$start_new_option |
</resource> |
</resource> |
</state> |
</state> |
|
|
Line 2272 sub printHelper {
|
Line 2306 sub printHelper {
|
<filterfunc>return $isNotMap;</filterfunc> |
<filterfunc>return $isNotMap;</filterfunc> |
<mapurl>$map</mapurl> |
<mapurl>$map</mapurl> |
<valuefunc>return $symbFilter;</valuefunc> |
<valuefunc>return $symbFilter;</valuefunc> |
<option text='$startnew' variable='FINISHPAGE' /> |
$start_new_option |
</resource> |
</resource> |
</state> |
</state> |
HELPERFRAGMENT |
HELPERFRAGMENT |
Line 2283 HELPERFRAGMENT
|
Line 2317 HELPERFRAGMENT
|
# If the user has pfo (print for otheres) allow them to print all |
# If the user has pfo (print for otheres) allow them to print all |
# problems and resources in the entier course, optionally for selected students |
# problems and resources in the entier course, optionally for selected students |
if ($perm{'pfo'} && |
if ($perm{'pfo'} && |
($helper->{VARS}->{'postdata'}=~/\/res\// || $helper->{VARS}->{'postdata'}=~/\/(syllabus|smppg|aboutme|bulletinboard)$/)) { |
$helper->{VARS}->{'postdata'} !~/^\/res\// && |
|
$helper->{VARS}->{'postdata'}=~/\/(syllabus|smppg|aboutme|bulletinboard)$/) { |
push @{$printChoices}, ['Selected <b>Problems</b> from <b>entire course</b>', 'all_problems', 'ALL_PROBLEMS']; |
push @{$printChoices}, ['Selected <b>Problems</b> from <b>entire course</b>', 'all_problems', 'ALL_PROBLEMS']; |
push @{$printChoices}, ['Selected <b>Resources</b> from <b>entire course</b>', 'all_resources', 'ALL_RESOURCES']; |
push @{$printChoices}, ['Selected <b>Resources</b> from <b>entire course</b>', 'all_resources', 'ALL_RESOURCES']; |
&Apache::lonxml::xmlparse($r, 'helper', <<ALL_PROBLEMS); |
&Apache::lonxml::xmlparse($r, 'helper', <<ALL_PROBLEMS); |
Line 2295 HELPERFRAGMENT
|
Line 2329 HELPERFRAGMENT
|
<filterfunc>return $isProblemOrMap;</filterfunc> |
<filterfunc>return $isProblemOrMap;</filterfunc> |
<choicefunc>return $isNotMap;</choicefunc> |
<choicefunc>return $isNotMap;</choicefunc> |
<valuefunc>return $symbFilter;</valuefunc> |
<valuefunc>return $symbFilter;</valuefunc> |
<option text='$startnew' variable='FINISHPAGE' /> |
$start_new_option |
</resource> |
</resource> |
</state> |
</state> |
<state name="ALL_RESOURCES" title="Select Resource(s) to print"> |
<state name="ALL_RESOURCES" title="Select Resource(s) to print"> |
Line 2304 HELPERFRAGMENT
|
Line 2338 HELPERFRAGMENT
|
<nextstate>PAGESIZE</nextstate> |
<nextstate>PAGESIZE</nextstate> |
<filterfunc>return $isNotMap; </filterfunc> |
<filterfunc>return $isNotMap; </filterfunc> |
<valuefunc>return $symbFilter;</valuefunc> |
<valuefunc>return $symbFilter;</valuefunc> |
<option text='$startnew' variable='FINISHPAGE' /> |
$start_new_option |
</resource> |
</resource> |
</state> |
</state> |
ALL_PROBLEMS |
ALL_PROBLEMS |
|
|
if ($helper->{VARS}->{'assignment'}) { |
if ($helper->{VARS}->{'assignment'}) { |
push @{$printChoices}, [&mt("Selected <b>Problems</b> from folder <b><i>[_1]</i></b> for <b>selected students</b>",$sequenceTitle), 'problems_for_students', 'CHOOSE_STUDENTS']; |
push @{$printChoices}, [&mt("Selected <b>Problems</b> from folder <b><i>[_1]</i></b> for <b>selected students</b>",$sequenceTitle), 'problems_for_students', 'CHOOSE_STUDENTS']; |
push @{$printChoices}, [&mt("Selected <b>Problems</b> from folder <b><i>[_1]</i></b> for <b>anonymous students</b>",$sequenceTitle), 'problems_for_anon', 'CHOOSE_ANON1']; |
push @{$printChoices}, [&mt("Selected <b>Problems</b> from folder <b><i>[_1]</i></b> for <b>CODEd assignments</b>",$sequenceTitle), 'problems_for_anon', 'CHOOSE_ANON1']; |
} |
} |
|
|
# resource_selector will hold a few states that: |
# resource_selector will hold a few states that: |
Line 2332 ALL_PROBLEMS
|
Line 2366 ALL_PROBLEMS
|
<filterfunc>return $isProblem;</filterfunc> |
<filterfunc>return $isProblem;</filterfunc> |
<mapurl>$map</mapurl> |
<mapurl>$map</mapurl> |
<valuefunc>return $symbFilter;</valuefunc> |
<valuefunc>return $symbFilter;</valuefunc> |
<option text='$startnew' variable='FINISHPAGE' /> |
$start_new_option |
</resource> |
</resource> |
</state> |
</state> |
<state name="PRINT_FORMATTING" title="How should results be printed?"> |
<state name="PRINT_FORMATTING" title="How should results be printed?"> |
Line 2398 CHOOSE_STUDENTS
|
Line 2432 CHOOSE_STUDENTS
|
} |
} |
if (%codes_to_print) { |
if (%codes_to_print) { |
$code_selection .=' |
$code_selection .=' |
<message><b>Choose single code from list</b></message> |
<message><b>Choose single CODE from list:</b></message> |
<message></td><td></message> |
<message></td><td></message> |
<dropdown variable="CODE_SELECTED_FROM_LIST" multichoice="0" allowempty="0"> |
<dropdown variable="CODE_SELECTED_FROM_LIST" multichoice="0" allowempty="0"> |
<choice></choice> |
<choice></choice> |
Line 2406 CHOOSE_STUDENTS
|
Line 2440 CHOOSE_STUDENTS
|
push(@{$state->{CHOICES}},@{$helper->{DATA}{ALL_CODE_CHOICES}}); |
push(@{$state->{CHOICES}},@{$helper->{DATA}{ALL_CODE_CHOICES}}); |
</exec> |
</exec> |
</dropdown> |
</dropdown> |
<message></td></tr><tr><td colspan="2"><hr width=\'33%\' /></td></tr><tr><td></message> |
<message></td></tr><tr><td></message> |
'.$/; |
'.$/; |
|
|
} |
} |
Line 2426 CHOOSE_STUDENTS
|
Line 2460 CHOOSE_STUDENTS
|
$codechoice='<choice computer="default">Default</choice>'; |
$codechoice='<choice computer="default">Default</choice>'; |
} |
} |
&Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_ANON1); |
&Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_ANON1); |
<state name="CHOOSE_ANON1" title="Select Students and Resources"> |
<state name="CHOOSE_ANON1" title="Specify CODEd Assignments"> |
<nextstate>SELECT_PROBLEMS</nextstate> |
<nextstate>SELECT_PROBLEMS</nextstate> |
<message><table><tr><td><b>Number of anonymous assignments to print:</b></td><td></message> |
<message><h4>Fill out one of the forms below</h4></message> |
|
<message><br /><hr /> <br /></message> |
|
<message><h3>Generate new CODEd Assignments</h3></message> |
|
<message><table><tr><td><b>Number of CODEd assignments to print:</b></td><td></message> |
<string variable="NUMBER_TO_PRINT_TOTAL" maxlength="5" size="5"> |
<string variable="NUMBER_TO_PRINT_TOTAL" maxlength="5" size="5"> |
<validator> |
<validator> |
if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) && |
if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) && |
Line 2450 CHOOSE_STUDENTS
|
Line 2487 CHOOSE_STUDENTS
|
<dropdown variable="CODE_OPTION" multichoice="0" allowempty="0"> |
<dropdown variable="CODE_OPTION" multichoice="0" allowempty="0"> |
$codechoice |
$codechoice |
</dropdown> |
</dropdown> |
<message></td></tr><tr><td colspan="2"><hr width='33%' /></td></tr><tr><td></message> |
<message></td></tr><tr><td colspan="2"></td></tr><tr><td></message> |
<message></td></tr><tr><td></message> |
<message></td></tr><tr><td></table></message> |
<message><b>Enter a CODE to print:</b></td><td></message> |
<message><br /><hr /><h3>Print a Specific CODE </h3><br /><table></message> |
|
<message><tr><td><b>Enter a CODE to print:</b></td><td></message> |
<string variable="SINGLE_CODE" size="10"> |
<string variable="SINGLE_CODE" size="10"> |
<validator> |
<validator> |
if(!\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'} && |
if(!\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'} && |
Line 2465 CHOOSE_STUDENTS
|
Line 2503 CHOOSE_STUDENTS
|
} |
} |
</validator> |
</validator> |
</string> |
</string> |
<message></td></tr><tr><td colspan="2"><hr width='33%' /></td></tr><tr><td></message> |
<message></td></tr><tr><td></message> |
$code_selection |
$code_selection |
|
<message></td></tr></table></message> |
|
<message><hr /><h3>Reprint a Set of Saved CODEs</h3><table><tr><td></message> |
<message><b>Reprint a set of saved CODEs:</b></message> |
<message><b>Select saved CODEs:</b></message> |
<message></td><td></message> |
<message></td><td></message> |
<dropdown variable="REUSE_OLD_CODES"> |
<dropdown variable="REUSE_OLD_CODES"> |
$namechoice |
$namechoice |
</dropdown> |
</dropdown> |
<message></td></tr></table></message> |
<message></td></tr></table></message> |
<message><hr width='33%' /></message> |
|
</state> |
</state> |
$resource_selector |
$resource_selector |
CHOOSE_ANON1 |
CHOOSE_ANON1 |
Line 2483 CHOOSE_ANON1
|
Line 2520 CHOOSE_ANON1
|
|
|
if ($helper->{VARS}->{'assignment'}) { |
if ($helper->{VARS}->{'assignment'}) { |
push @{$printChoices}, [&mt("Selected <b>Resources</b> from folder <b><i>[_1]</i></b> for <b>selected students</b>",$sequenceTitle), 'resources_for_students', 'CHOOSE_STUDENTS1']; |
push @{$printChoices}, [&mt("Selected <b>Resources</b> from folder <b><i>[_1]</i></b> for <b>selected students</b>",$sequenceTitle), 'resources_for_students', 'CHOOSE_STUDENTS1']; |
push @{$printChoices}, [&mt("Selected <b>Resources</b> from folder <b><i>[_1]</i></b> for <b>anonymous students</b>",$sequenceTitle), 'resources_for_anon', 'CHOOSE_ANON2']; |
push @{$printChoices}, [&mt("Selected <b>Resources</b> from folder <b><i>[_1]</i></b> for <b>CODEd assignments</b>",$sequenceTitle), 'resources_for_anon', 'CHOOSE_ANON2']; |
} |
} |
|
|
|
|
Line 2496 CHOOSE_ANON1
|
Line 2533 CHOOSE_ANON1
|
<filterfunc>return $isNotMap;</filterfunc> |
<filterfunc>return $isNotMap;</filterfunc> |
<mapurl>$map</mapurl> |
<mapurl>$map</mapurl> |
<valuefunc>return $symbFilter;</valuefunc> |
<valuefunc>return $symbFilter;</valuefunc> |
<option text='$startnew' variable='FINISHPAGE' /> |
$start_new_option |
</resource> |
</resource> |
</state> |
</state> |
<state name="PRINT_FORMATTING" title="Format of the print job"> |
<state name="PRINT_FORMATTING" title="Format of the print job"> |
Line 2534 RESOURCE_SELECTOR
|
Line 2571 RESOURCE_SELECTOR
|
CHOOSE_STUDENTS1 |
CHOOSE_STUDENTS1 |
|
|
&Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_ANON2); |
&Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_ANON2); |
<state name="CHOOSE_ANON2" title="Select Students and Resources"> |
<state name="CHOOSE_ANON2" title="Select CODEd Assignments"> |
<nextstate>SELECT_RESOURCES</nextstate> |
<nextstate>SELECT_RESOURCES</nextstate> |
<message><table><tr><td><b>Number of anonymous assignments to print:</b></td><td></message> |
<message><h4>Fill out one of the forms below</h4></message> |
|
<message><br /><hr /> <br /></message> |
|
<message><h3>Generate new CODEd Assignments</h3></message> |
|
<message><table><tr><td><b>Number of CODEd assignments to print:</b></td><td></message> |
<string variable="NUMBER_TO_PRINT_TOTAL" maxlength="5" size="5"> |
<string variable="NUMBER_TO_PRINT_TOTAL" maxlength="5" size="5"> |
<validator> |
<validator> |
if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) && |
if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) && |
Line 2558 CHOOSE_STUDENTS1
|
Line 2598 CHOOSE_STUDENTS1
|
<dropdown variable="CODE_OPTION" multichoice="0" allowempty="0"> |
<dropdown variable="CODE_OPTION" multichoice="0" allowempty="0"> |
$codechoice |
$codechoice |
</dropdown> |
</dropdown> |
<message></td></tr><tr><td colspan="2"><hr width='33%' /></td></tr><tr><td></message> |
<message></td></tr><tr><td></table></message> |
<message></td></tr><tr><td></message> |
<message><br /><hr /><h3>Print a Specific CODE </h3><br /><table></message> |
<message><b>Enter a CODE to print:</b></td><td></message> |
<message><tr><td><b>Enter a CODE to print:</b></td><td></message> |
<string variable="SINGLE_CODE" size="10"> |
<string variable="SINGLE_CODE" size="10"> |
<validator> |
<validator> |
if(!\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'} && |
if(!\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'} && |
Line 2573 CHOOSE_STUDENTS1
|
Line 2613 CHOOSE_STUDENTS1
|
} |
} |
</validator> |
</validator> |
</string> |
</string> |
<message></td></tr><tr><td colspan="2"><hr width='33%' /></td></tr><tr><td></message> |
<message></td></tr><tr><td></message> |
$code_selection |
$code_selection |
<message><b>Reprint a set of saved CODEs:</b></message> |
<message></td></tr></table></message> |
|
<message><hr /><h3>Reprint a Set of Saved CODEs</h3><table><tr><td></message> |
|
<message><b>Select saved CODEs:</b></message> |
<message></td><td></message> |
<message></td><td></message> |
<dropdown variable="REUSE_OLD_CODES"> |
<dropdown variable="REUSE_OLD_CODES"> |
$namechoice |
$namechoice |
</dropdown> |
</dropdown> |
<message></td></tr></table></message> |
<message></td></tr></table></message> |
<message><hr width='33%' /></message> |
|
</state> |
</state> |
$resource_selector |
$resource_selector |
CHOOSE_ANON2 |
CHOOSE_ANON2 |
} |
} |
|
|
# FIXME: That RE should come from a library somewhere. |
# FIXME: That RE should come from a library somewhere. |
if ((((&Apache::lonnet::allowed('bre',$subdir) eq 'F') and ($helper->{VARS}->{'postdata'}=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)/)) or defined $helper->{'VARS'}->{'construction'}) and $perm{'pav'} and $subdir ne $Apache::lonnet::perlvar{'lonDocRoot'}.'/res/') { |
if ((((&Apache::lonnet::allowed('bre',$subdir) eq 'F') and |
|
($helper->{VARS}->{'postdata'}=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)/)) or |
|
defined $helper->{'VARS'}->{'construction'}) and $perm{'pav'} and $subdir ne $Apache::lonnet::perlvar{'lonDocRoot'}.'/res/') { |
push @{$printChoices}, [&mt("Selected <b>Problems</b> from current subdirectory <b><i>[_1]</i></b>",$subdir), 'problems_from_directory', 'CHOOSE_FROM_SUBDIR']; |
push @{$printChoices}, [&mt("Selected <b>Problems</b> from current subdirectory <b><i>[_1]</i></b>",$subdir), 'problems_from_directory', 'CHOOSE_FROM_SUBDIR']; |
|
|
my $f = '$filename'; |
my $f = '$filename'; |
Line 2614 CHOOSE_FROM_SUBDIR
|
Line 2656 CHOOSE_FROM_SUBDIR
|
|
|
# Allow the user to select any sequence in the course, feed it to |
# Allow the user to select any sequence in the course, feed it to |
# another resource selector for that sequence |
# another resource selector for that sequence |
if (!$helper->{VARS}->{'construction'}) { |
if (!$helper->{VARS}->{'construction'} && ($helper->{VARS}->{'postdata'} !~ /^\/res\//)) { |
push @$printChoices, ["Selected <b>Resources</b> from <b>selected folder</b> in course", |
push @$printChoices, ["Selected <b>Resources</b> from <b>selected folder</b> in course", |
'select_sequences', 'CHOOSE_SEQUENCE']; |
'select_sequences', 'CHOOSE_SEQUENCE']; |
my $escapedSequenceName = $helper->{VARS}->{'SEQUENCE'}; |
my $escapedSequenceName = $helper->{VARS}->{'SEQUENCE'}; |
Line 2637 CHOOSE_FROM_SUBDIR
|
Line 2679 CHOOSE_FROM_SUBDIR
|
<resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1" |
<resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1" |
closeallpages="1"> |
closeallpages="1"> |
<nextstate>PAGESIZE</nextstate> |
<nextstate>PAGESIZE</nextstate> |
<filterfunc>return $isProblem</filterfunc> |
<filterfunc>return $isNotMap</filterfunc> |
<mapurl evaluate='1'>return '$escapedSequenceName';</mapurl> |
<mapurl evaluate='1'>return '$escapedSequenceName';</mapurl> |
<valuefunc>return $symbFilter;</valuefunc> |
<valuefunc>return $symbFilter;</valuefunc> |
<option text='$startnew' variable='FINISHPAGE' /> |
$start_new_option |
</resource> |
</resource> |
</state> |
</state> |
CHOOSE_FROM_ANY_SEQUENCE |
CHOOSE_FROM_ANY_SEQUENCE |
} |
} |
|
|
# Generate the first state, to select which resources get printed. |
# Generate the first state, to select which resources get printed. |
Apache::lonhelper::state->new("START", "Select Printing Options:"); |
Apache::lonhelper::state->new("START", "Select Printing Options:"); |
$paramHash = Apache::lonhelper::getParamHash(); |
$paramHash = Apache::lonhelper::getParamHash(); |
Line 2969 sub new {
|
Line 3010 sub new {
|
|
|
$self->{NEXTSTATE} = shift; |
$self->{NEXTSTATE} = shift; |
bless($self); |
bless($self); |
|
|
return $self; |
return $self; |
} |
} |
|
|
Line 2978 sub render {
|
Line 3020 sub render {
|
my $result = ''; |
my $result = ''; |
my $var = $self->{'variable'}; |
my $var = $self->{'variable'}; |
|
|
|
|
|
|
if (defined $self->{ERROR_MSG}) { |
if (defined $self->{ERROR_MSG}) { |
$result .= '<br /><span class="LC_error">' . $self->{ERROR_MSG} . '</span><br />'; |
$result .= '<br /><span class="LC_error">' . $self->{ERROR_MSG} . '</span><br />'; |
} |
} |
Line 3017 sub render {
|
Line 3061 sub render {
|
} |
} |
} |
} |
|
|
$result .= <<ELEMENTHTML; |
# Adjust margin for LaTeX margin: .. requires units == cm or in. |
|
|
|
if ($size{'margin_unit'} eq 'in') { |
|
$size{'margin'} += 1; |
|
} else { |
|
$size{'margin'} += 2.54; |
|
} |
|
$result .= <<ELEMENTHTML; |
|
|
|
|
|
|
<p>How should each column be formatted?</p> |
<p>How should each column be formatted?</p> |
|
|
Line 3061 ELEMENTHTML
|
Line 3112 ELEMENTHTML
|
return $result; |
return $result; |
} |
} |
|
|
# If the user didn't select 1 column, skip this state. |
|
sub preprocess { |
sub preprocess { |
my $self = shift; |
my $self = shift; |
my $helper = Apache::lonhelper::getHelper(); |
my $helper = Apache::lonhelper::getHelper(); |
|
|
my $format = $helper->{VARS}->{$self->{'formatvar'}}; |
my $format = $helper->{VARS}->{$self->{'formatvar'}}; |
|
|
|
# If the user does not have 'pav' privilege, set default widths and |
|
# on to the next state right away. |
|
# |
|
if (!$perm{'pav'}) { |
|
my $var = $self->{'variable'}; |
|
my $format = $helper->{VARS}->{$self->{'formatvar'}}; |
|
|
|
my ($laystyle, $cols, $papersize) = split(/\|/, $format); |
|
($papersize) = split(/ /, $papersize); |
|
|
|
|
|
if ($laystyle eq 'L') { |
|
$laystyle = 'album'; |
|
} else { |
|
$laystyle = 'book'; |
|
} |
|
# Figure out some good defaults for the print out and set them: |
|
|
|
my %size; |
|
($size{'width'}, |
|
$size{'height'}, |
|
$size{'lmargin'})= |
|
&Apache::lonprintout::page_format($papersize, $laystyle, $cols); |
|
|
|
foreach my $dim ('width', 'height', 'lmargin') { |
|
my ($value, $units) = split(/ /, $size{$dim}); |
|
|
|
$helper->{VARS}->{"$var.".$dim} = $value; |
|
$helper->{VARS}->{"$var.".$dim.'unit'} = $units; |
|
|
|
} |
|
|
|
|
|
# Transition to the next state |
|
|
|
$helper->changeState($self->{NEXTSTATE}); |
|
} |
|
|
return 1; |
return 1; |
} |
} |
Line 3096 sub postprocess {
|
Line 3185 sub postprocess {
|
} |
} |
if ($lmargin !~ /^-?[0-9]*(\.[0-9]*)?$/) { |
if ($lmargin !~ /^-?[0-9]*(\.[0-9]*)?$/) { |
$error .= "Invalid left margin; please type only a number.<br />\n"; |
$error .= "Invalid left margin; please type only a number.<br />\n"; |
|
} else { |
|
# Adjust for LaTeX 1.0 inch margin: |
|
|
|
if ($env{"form.${var}.lmarginunit"} eq "in") { |
|
$helper->{VARS}->{$var.'.lmargin'} = $lmargin - 1; |
|
} else { |
|
$helper->{VARS}->{$var.'.lmargin'} = $lmargin - 2.54; |
|
} |
} |
} |
|
|
if (!$error) { |
if (!$error) { |