--- loncom/interface/lonprintout.pm 2004/05/04 19:58:57 1.299 +++ loncom/interface/lonprintout.pm 2004/06/08 14:55:22 1.307 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.299 2004/05/04 19:58:57 albertel Exp $ +# $Id: lonprintout.pm,v 1.307 2004/06/08 14:55:22 sakharuk Exp $ # # Copyright Michigan State University Board of Trustees # @@ -421,13 +421,13 @@ sub page_format { } elsif($papersize eq '6') { if ($layout eq 'book') { if ($numberofcolumns == 1) { - $textwidth = '18 cm'; - $textheight = '28 cm'; + $textwidth = '176 mm'; + $textheight = '254 mm'; $oddoffset = '-0.57 in'; $evenoffset = '-0.57 in'; } elsif ($numberofcolumns == 2) { - $textwidth = '96 mm'; - $textheight = '2 cm'; + $textwidth = '91 mm'; + $textheight = '254 mm'; $oddoffset = '-0.57 in'; $evenoffset = '-0.57 in'; } @@ -674,11 +674,10 @@ sub get_textwidth { sub unsupported { - my $currentURL=shift; - my $result.='\documentclass[letterpaper]{article}\usepackage{calc}\begin{document}Printout of this type of document is currently not supported: '; - if ($currentURL=~/\/(aboutme|syllabus|bulletinboard)$/) { - $result.='\textbf{'.$1.'}'; - } elsif ($currentURL=~/\/ext\//) { + my ($currentURL,$mode)=@_; + if ($mode ne '') {$mode='\\'.$mode} + my $result.='\documentclass[letterpaper]{article}'.$mode.'\usepackage{calc}\begin{document}Printout of this type of document is currently not supported: '; + if ($currentURL=~/\/ext\//) { $result.=' \strut \\\\ THIS IS EXTERNAL RESOURCE WITH URL \strut \\\\ '.$currentURL.' '; } else { $result.=$currentURL; @@ -754,7 +753,6 @@ ENDPART } $selectionmade = 1; if ($currentURL=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) { - &Apache::lonnet::logthis("II AMAM IN A WRONG PLACE"); my $rndseed=time; my $texversion=''; if ($helper->{'VARS'}->{'ANSWER_TYPE'} ne 'only') { @@ -877,7 +875,7 @@ ENDPART } if ($helper->{VARS}->{'construction'} eq '1') {$result=~s/(\\begin{document})/$1 \\fbox\{RANDOM SEED IS $rndseed\} /;} $result .= '\end{document}'; - } elsif ($currentURL=~/\/(smppg|syllabus)$/) { + } elsif ($currentURL=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { my %form; $form{'grade_target'}='tex'; $form{'textwidth'}=&get_textwidth($helper,$LaTeXwidth); @@ -886,8 +884,7 @@ ENDPART my $texversion=&Apache::lonnet::ssi($currentURL,%form); $result .= $texversion; } else { - &Apache::lonnet::logthis("IIII AMAM IN A WRONG PLACE"); - $result.=&unsupported($currentURL); + $result.=&unsupported($currentURL,$helper->{'VARS'}->{'LATEX_TYPE'}); } } elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') or ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') or @@ -948,7 +945,7 @@ ENDPART if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { $texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/; } else { - if ($urlp=~/\.(problem|exam|quiz|library)$/) { + if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library)$/) { $texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); $texversion.='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($urlp).'}\vskip 0 mm '; $texversion.=&path_to_problem ($urlp,$LaTeXwidth); @@ -975,8 +972,22 @@ ENDPART } $result .= $texversion; $flag_latex_header_remove = 'YES'; + } elsif ($urlp=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { + my %form; + $form{'grade_target'}='tex'; + $form{'textwidth'}=&get_textwidth($helper,$LaTeXwidth); + $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; + if ($urlp=~/\/syllabus$/) {$urlp=~s/\/res//;} + my $texversion=&Apache::lonnet::ssi($urlp,%form); + if ($flag_latex_header_remove ne 'NO') { + $texversion = &latex_header_footer_remove($texversion); + } else { + $texversion =~ s/\\end{document}/\\vskip 0\.5mm\\noindent\\makebox\[\\textwidth\/\$number_of_columns\]\[b\]\{\\hrulefill\}/; + } + $result .= $texversion; + $flag_latex_header_remove = 'YES'; } else { - $texversion=&unsupported($urlp); + $texversion=&unsupported($urlp,$helper->{'VARS'}->{'LATEX_TYPE'}); if ($flag_latex_header_remove ne 'NO') { $texversion = &latex_header_footer_remove($texversion); } else { @@ -1038,7 +1049,7 @@ ENDPART } my $flag_latex_header_remove = 'NO'; my %moreenv = ('textwidth' => &get_textwidth($helper,$LaTeXwidth)); - my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$num_todo,'inline'); + my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$num_todo,'inline','75'); my $seed=time+($$<<16)+($$); my @allcodes; if ($old_name) { @@ -1093,7 +1104,7 @@ ENDPART if ($urlp =~ m|/home/([^/]+)/public_html|) { $urlp =~ s|/home/([^/]*)/public_html|/~$1|; } else { - $urlp =~ s|^/home/httpd/html||; + $urlp =~ s|^$Apache::lonnet::perlvar{'lonDocRoot'}||; } my $texversion=&Apache::lonnet::ssi($urlp,%form); if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') || @@ -1221,6 +1232,7 @@ ENDPART &Apache::lonnet::appenv('cgi.'.$identifier.'.file' => $filename, 'cgi.'.$identifier.'.layout' => $laystyle, 'cgi.'.$identifier.'.numcol' => $numberofcolumns, + 'cgi.'.$identifier.'.paper' => $papersize, 'cgi.'.$identifier.'.selection' => $selectionmade, 'cgi.'.$identifier.'tableofcontents' => $helper->{'VARS'}->{'TABLE_CONTENTS'}, 'cgi.'.$identifier.'tableofindex' => $helper->{'VARS'}->{'TABLE_INDEX'}, @@ -1275,35 +1287,59 @@ sub print_resources { ($curresline!~ m/\.(problem|exam|quiz|assess|survey|form|library)$/)) ) { my ($map,$id,$res_url) = &Apache::lonnet::decode_symb($curresline); if (&Apache::lonnet::allowed('bre',$res_url)) { - my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,$ENV{'request.course.id'},'tex',$moreenv); - my $lonidsdir=$r->dir_config('lonIDsDir'); - my $envfile=$ENV{'user.environment'}; - $envfile=~/\/([^\/]+)\.id$/; - $envfile=$1; - &Apache::lonnet::transfer_profile_to_env($lonidsdir,$envfile); - my $current_counter=$ENV{'form.counter'}; - if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') || - ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) { - my %form; - $form{'answer_output_mode'}='tex'; - $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; - my $ansrendered = &Apache::loncommon::get_student_answers($curresline,$username,$userdomain,$ENV{'request.course.id'},%form); - &Apache::lonnet::appenv(('form.counter' => $current_counter)); - if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { - $rendered=~s/(\\keephidden{ENDOFPROBLEM})/$ansrendered$1/; + if ($res_url=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) { + my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,$ENV{'request.course.id'},'tex',$moreenv); + my $lonidsdir=$r->dir_config('lonIDsDir'); + my $envfile=$ENV{'user.environment'}; + $envfile=~/\/([^\/]+)\.id$/; + $envfile=$1; + &Apache::lonnet::transfer_profile_to_env($lonidsdir,$envfile); + my $current_counter=$ENV{'form.counter'}; + if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') || + ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) { + my %form; + $form{'answer_output_mode'}='tex'; + $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'}; + my $ansrendered = &Apache::loncommon::get_student_answers($curresline,$username,$userdomain,$ENV{'request.course.id'},%form); + &Apache::lonnet::appenv(('form.counter' => $current_counter)); + if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { + $rendered=~s/(\\keephidden{ENDOFPROBLEM})/$ansrendered$1/; + } else { + $rendered=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); + $rendered.='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($curresline).'}\vskip 0 mm '; + $rendered.=&path_to_problem ($curresline,$LaTeXwidth); + $rendered.='\vskip 1 mm '.$ansrendered; + } + } + if ($remove_latex_header eq 'YES') { + $rendered = &latex_header_footer_remove($rendered); } else { - $rendered=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); - $rendered.='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($curresline).'}\vskip 0 mm '; - $rendered.=&path_to_problem ($curresline,$LaTeXwidth); - $rendered.='\vskip 1 mm '.$ansrendered; + $rendered =~ s/\\end{document}//; } - } - if ($remove_latex_header eq 'YES') { - $rendered = &latex_header_footer_remove($rendered); + $current_output .= $rendered; + } elsif ($res_url=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { + my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,$ENV{'request.course.id'},'tex',$moreenv); + my $lonidsdir=$r->dir_config('lonIDsDir'); + my $envfile=$ENV{'user.environment'}; + $envfile=~/\/([^\/]+)\.id$/; + $envfile=$1; + &Apache::lonnet::transfer_profile_to_env($lonidsdir,$envfile); + my $current_counter=$ENV{'form.counter'}; + if ($remove_latex_header eq 'YES') { + $rendered = &latex_header_footer_remove($rendered); + } else { + $rendered =~ s/\\end{document}//; + } + $current_output .= $rendered.'\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\strut \vskip 0 mm \strut '; } else { - $rendered =~ s/\\end{document}//; + my $rendered = &unsupported($res_url,$helper->{'VARS'}->{'LATEX_TYPE'}); + if ($remove_latex_header ne 'NO') { + $rendered = &latex_header_footer_remove($rendered); + } else { + $rendered =~ s/\\end{document}//; + } + $current_output .= $rendered; } - $current_output .= $rendered; } $remove_latex_header = 'YES'; } @@ -1484,7 +1520,7 @@ sub printHelper { # "Delete everything after the last slash." $subdir =~ s|/[^/]+$||; if (not $helper->{VARS}->{'construction'}) { - $subdir='/home/httpd/html/res/'.$subdir; + $subdir=$Apache::lonnet::perlvar{'lonDocRoot'}.'/res/'.$subdir; } # "Remove all duplicate slashes." $subdir =~ s|/+|/|g; @@ -1561,7 +1597,8 @@ HELPERFRAGMENT # If the user is priviledged, allow them to print all # problems in the course, optionally for selected students - if ($userPriviledged && ($helper->{VARS}->{'postdata'}=~/\/res\//)) { + if ($userPriviledged && + ($helper->{VARS}->{'postdata'}=~/\/res\// || $helper->{VARS}->{'postdata'}=~/\/(syllabus|smppg|aboutme|bulletinboard)$/)) { push @{$printChoices}, ['Problems from entire course', 'all_problems', 'ALL_PROBLEMS']; &Apache::lonxml::xmlparse($r, 'helper', < @@ -1683,7 +1720,7 @@ CHOOSE_ANON2 } # 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 $ENV{'request.role.adv'} and $subdir ne '/home/httpd/html/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 $ENV{'request.role.adv'} and $subdir ne $Apache::lonnet::perlvar{'lonDocRoot'}.'/res/') { push @{$printChoices}, ["".&mt('Problems')." ".&mt('from current subdirectory')." $subdir", 'problems_from_directory', 'CHOOSE_FROM_SUBDIR']; my $f = '$filename'; @@ -1956,9 +1993,12 @@ STATEHTML $result .= "\n"; $result .= "