--- loncom/interface/lonprintout.pm 2002/09/09 19:27:42 1.57 +++ loncom/interface/lonprintout.pm 2010/05/10 10:21:24 1.575.2.1 @@ -1,7 +1,8 @@ +# # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.57 2002/09/09 19:27:42 sakharuk Exp $ +# $Id: lonprintout.pm,v 1.575.2.1 2010/05/10 10:21:24 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -22,23 +23,10 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # /home/httpd/html/adm/gpl.txt -# # http://www.lon-capa.org/ # -# (Internal Server Error Handler -# -# (Login Screen -# 5/21/99,5/22,5/25,5/26,5/31,6/2,6/10,7/12,7/14, -# 1/14/00,5/29,5/30,6/1,6/29,7/1,11/9 Gerd Kortemeyer) -# -# 3/1/1 Gerd Kortemeyer) -# -# 3/1 Gerd Kortemeyer -# -# 9/17 Alex Sakharuk # package Apache::lonprintout; - use strict; use Apache::Constants qw(:common :http); use Apache::lonxml; @@ -48,926 +36,5095 @@ use Apache::inputtags; use Apache::grades; use Apache::edit; use Apache::File(); +use Apache::lonnavmaps; +use Apache::admannotations; +use Apache::lonenc; +use Apache::entities; +use Apache::londefdef; + +use File::Basename; + +use HTTP::Response; + +use LONCAPA::map(); use POSIX qw(strftime); +use Apache::lonlocal; +use Carp; +use LONCAPA; +my %perm; +my %parmhash; +my $resources_printed; -sub headerform { - my $r = shift; - $r->print(< - -LON-CAPA output for printing - - -
-$ENV{'form.postdata'}

-ENDHEADER +# Global variables that describe errors in ssi calls detected by ssi_with_retries. +# + +my $ssi_error; # True if there was an ssi error. +my $ssi_last_error_resource; # The resource URI that could not be fetched. +my $ssi_last_error + ; # The error text from the server. (e.g. 500 Server timed out). + +# +# Our ssi max retry count. +# + +my $ssi_retry_count = 5; # Some arbitrary value. + +# Font size: + +my $font_size = 'normalsize'; # Default is normalsize... + +#---------------------------- Helper helpers. ------------------------- + +# Returns the text needd for a student chooser. +# that text must still be parsed by the helper xml parser. +# Parameters: +# this_state - State name of the chooser. +# sort_choice - variable to hold the sorting choice. +# variable - Name of variable to hold students. +# next_state - State after chooser. + +sub generate_student_chooser { + my ( $this_state, $sort_choice, $variable, $next_state ) = @_; + my $result = < + Select sorting order of printout + + + Sort by section then student + Sort by students across sections. + + +



+ + + +CHOOSE_STUDENTS + + return $result; } +# Generate the text needed for a resource chooser given the top level of +# the sequence/page +# +# Parameters: +# this_state - State name of the chooser. +# prompt_text - Text to use to prompt user. +# resource_options - Resource tag options e.g. +# "multichoice='1', toponly='1', addstatus='1'" +# that control the selection and appearance of the +# resource selector. +# variable - Name of the variable to hold the choice +# next_state - Name of the next state the helper should transition +# to +# top_url - Top level URL within which to make the selector. +# If empty the top level sequence is shown. +# filter - How to filter the resources. +# value_func - function. +# choice_func - If not empty generates a with this function. +# start_new_option +# - Fragment appended after valuefunc. +# +# +sub generate_resource_chooser { + my ( + $this_state, $prompt_text, $resource_options, + $variable, $next_state, $top_url, + $filter, $choice_func, $value_func, + $start_new_option + ) = @_; -sub menu_for_output { - my $r = shift; - $r->print(<What do you want to print? Make a choice.
- - - Current document -(you will print what you see on the screen)
-ENDMENUOUT1 - if ((not $ENV{'request.role'}=~m/^au\./) and (not $ENV{'request.role'}=~m/^ca\./)) { - $r->print(< All problems from the primary sequence
- The whole primary sequence (problems plus all html and xml files)
- All problems from the top level sequence
-
-ENDMENUOUT2 + my $result = < + + $next_state + return $filter; +CHOOSE_RESOURCES + if ( $choice_func ne '' ) { + $result .= "return $choice_func;"; + } + if ( $top_url ne '' ) { + $result .= "$top_url"; } - if ($ENV{'request.role'}=~m/^cc\./ or $ENV{'request.role'}=~m/^in\./ or $ENV{'request.role'}=~m/^ta\./) { - $r->print(< Print assignment (all problems from the primary sequence) for group of students

-ENDMENUOUT6 - } - my $subdirtoprint = &Apache::lonnet::filelocation("",$ENV{'form.url'}); - $subdirtoprint =~ s/\/[^\/]+$//; - if (&Apache::lonnet::allowed('bre',$subdirtoprint) eq 'F') { - $r->print(< All problems from current subdirectory (where this particular problem is)
-ENDMENUOUT4 - } - $r->print(<

-

And what page format do you prefer?

- - - - - - -
- Landscape
- Portrait
-
  - Number of columns: -
-
- -ENDMENUOUT5 + $result .= <return $value_func;
+ $start_new_option + + +CHOOSE_RESOURCES + + return $result; +} + +# +# Generate the helper XML for a code choice helper dialog: +# +# Paramters: +# $helper - Reference to the helper. +# $state - Name of the state for the chooser. +# $next_state - Name fo the state to follow the chooser. +# $bubble_types - Populates the bubble sheet type dropt down. +# $code_selections - Provides set of code choices that have been used +# $saved_codes - Provides the list of saved codes. +# +# Returns; +# The Xml of the code chooser. +# +sub generate_code_selector { + my ( $helper, $state, $next_state, $bubble_types, $code_selections, + $saved_codes ) + = @_; # Unpack the parameters. + + my $result = < + $next_state +

Fill out one of the forms below

+


+

Generate new CODEd Assignments

+
Number of CODEd assignments to print: + + + if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) && + !\$helper->{'VARS'}{'REUSE_OLD_CODES'} && + !\$helper->{'VARS'}{'SINGLE_CODE'} && + !\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) { + return "You need to specify the number of assignments to print"; + } + return undef; + + +
+ Names to save the CODEs under for later: + + +
+ Bubble sheet type: + + + $bubble_types + +
+
+

Print a Specific CODE


+
Enter a CODE to print: + + + if(!\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'} && + !\$helper->{'VARS'}{'REUSE_OLD_CODES'} && + !\$helper->{'VARS'}{'CODE_SELECTED_FROM_LIST'}) { + return &Apache::lonprintout::is_code_valid(\$helper->{'VARS'}{'SINGLE_CODE'}, + \$helper->{'VARS'}{'CODE_OPTION'}); + } else { + return undef; # Other forces control us. + } + + +
+ $code_selections +
+

Reprint a Set of Saved CODEs

+ Select saved CODEs: + + + $saved_codes + +
+ +CHOOSE_ANON1 + + return $result; } +#----------------------------------------------------------------------- -sub additional_class_menu { - my $r = shift; - $r->print(< - - - -

Mark students which assignments you want to print

-ENDMENUOUT1 - my %courselist=&Apache::lonnet::dump( - 'classlist', - $ENV{'course.'.$ENV{'request.course.id'}.'.domain'}, - $ENV{'course.'.$ENV{'request.course.id'}.'.num'}); - my $now=time; - $r->print(< - -  - -  - -

-ENDDISHEADER - my $i = 0; - foreach (sort keys %courselist) { - my ($end,$start)=split(/\:/,$courselist{$_}); - my $active=1; - if (($end) && ($now>$end)) { $active=0; } - if ($active) { - my ($sname,$sdom)=split(/\:/,$_); - my %reply=&Apache::lonnet::get('environment', - ['firstname','middlename','lastname','generation'], - $sdom,$sname); - my $section=&Apache::lonnet::usection - ($sdom,$sname,$ENV{'request.course.id'}); - $r->print( - '
'. - $reply{'firstname'}.' '. - $reply{'middlename'}.' '. - $reply{'lastname'}.' '. - $reply{'generation'}. - ' ('.$_.') '.$section); - $i++; - } + my $valid; + if ( $code_type eq 'number' ) { + return &is_valid_numeric_code( $code_value, $code_length ); } - $r->print(< - - - -ENDMENUOUT2 + else { + return &is_valid_alpha_code( $code_value, $code_length ); + } + } +# Compare two students by name. The students are in the form +# returned by the helper: +# user:domain:section:last, first:status +# This is a helper function for the perl sort built-in therefore: +# Implicit Inputs: +# $a - The first element to compare (global) +# $b - The second element to compare (global) +# Returns: +# -1 - $a < $b +# 0 - $a == $b +# +1 - $a > $b +# Note that the initial comparison is done on the last names with the +# first names only used to break the tie. +# +# +sub compare_names { + + # First split the names up into the primary fields. -sub additional_print_menu { - my $r = shift; - my $what_to_print = ''; - for (my $i=0; $i<$ENV{'form.numberofstudents'};$i++) { - $what_to_print .= ''; - } - $r->print(< - - - - -Define page layout parameters:
-Width:
-Height:
-Left margin:
- - - - - -ENDMENUOUT + my ( $u1, $d1, $s1, $n1, $stat1 ) = split( /:/, $a ); + my ( $u2, $d2, $s2, $n2, $stat2 ) = split( /:/, $b ); + + # Now split the last name and first name of each n: + # + + my ( $l1, $f1 ) = split( /,/, $n1 ); + my ( $l2, $f2 ) = split( /,/, $n2 ); + + # We don't bother to remove the leading/trailing whitespace from the + # firstname, unless the last names compare identical. + + if ( $l1 lt $l2 ) { + return -1; + } + if ( $l1 gt $l2 ) { + return 1; + } + + # Break the tie on the first name, but there are leading (possibly trailing + # whitespaces to get rid of first + # + $f1 =~ s/^\s+//; # Remove leading... + $f1 =~ s/\s+$//; # Trailing spaces from first 1... + + $f2 =~ s/^\s+//; + $f2 =~ s/\s+$//; # And the same for first 2... + + if ( $f1 lt $f2 ) { + return -1; + } + if ( $f1 gt $f2 ) { + return 1; + } + + # Must be the same name. + + return 0; } +sub latex_header_footer_remove { + my $text = shift; + $text =~ s/\\end{document}//; + $text =~ s/\\documentclass([^&]*)\\begin{document}//; + return $text; +} -sub output_data { - my $r = shift; - $r->print(< - -LON-CAPA output for printing - - -


-ENDPART +# +# If necessary, encapsulate text inside +# a minipage env. +# necessity is determined by the problem_split param. +# +sub encapsulate_minipage { + my ($text) = @_; + if ( !( $env{'form.problem.split'} =~ /yes/i ) ) { + $text = '\begin{minipage}{\textwidth}' . $text . '\end{minipage}'; + } + return $text; +} - my $choice = $ENV{'form.choice'}; - my $layout = $ENV{'form.layout'}; - my $numberofcolumns = $ENV{'form.numberofcolumns'}; - my $laystyle = 'book'; - my $result = ''; - my $number_of_columns = 1; - - if ($choice eq 'Standard LaTeX output for current document') { - #-- single document - problem, page, html, xml - my %moreenv; - $moreenv{'form.grade_target'}='tex'; - if ($ENV{'request.role'}=~m/^au\./ or $ENV{'request.role'}=~m/^ca\./) { - $ENV{'form.url'}=~s/http:\/\/[^\/]+//; - } - $moreenv{'request.filename'}=$ENV{'form.url'}; - &Apache::lonnet::appenv(%moreenv); - my $texversion=&Apache::lonnet::ssi($ENV{'form.url'}); - &Apache::lonnet::delenv('form.grade_target'); - $result .= $texversion; - $result = &additional_cleanup($result); - if ($ENV{'form.url'}=~m/\.page\s*$/) { - ($result,$number_of_columns) = &page_cleanup($result); - } - } elsif ($choice eq 'Standard LaTeX output for the primary sequence' or - $choice eq 'Standard LaTeX output for whole primary sequence') { - #-- minimal sequence to which the current document belongs - #-- where is the primary sequence containing file? - my $symbolic = &Apache::lonnet::symbread($ENV{'form.url'}); - $_ = $symbolic; - m/([^_]+)_/; - my $primary_sequence = '/res/'.$1; - #-- open and analyses the primary sequence - my $sequence_file=&Apache::lonnet::filelocation("",$primary_sequence); - my $sequencefilecontents=&Apache::lonnet::getfile($sequence_file); - my @master_seq = &content_map($sequencefilecontents); - #-- produce an output string - for (my $i=0;$i<=$#master_seq;$i++) { - $_ = $master_seq[$i]; - m/\"(.*)\"/; - $_ = $1; - my $urlp = $1; - if ($choice eq 'Standard LaTeX output for the primary sequence') { - if ($urlp =~ m/\.(problem|exam|quiz|assess|survey|form|library)/) { - my %moreenv; - $moreenv{'form.grade_target'}='tex'; - &Apache::lonnet::appenv(%moreenv); - my $texversion=&Apache::lonnet::ssi($urlp); - &Apache::lonnet::delenv('form.grade_target'); - $result .= $texversion; - } - } elsif ($urlp =~ /\S+/) { - my %moreenv; - $moreenv{'form.grade_target'}='tex'; - &Apache::lonnet::appenv(%moreenv); - my $texversion=&Apache::lonnet::ssi($urlp); - &Apache::lonnet::delenv('form.grade_target'); - $result .= $texversion; - } - } - $result = &additional_cleanup($result); - } elsif ($choice eq 'Standard LaTeX output for the top level sequence') { - # where is the main sequence of the course? - my $main_seq = '/res/'.$ENV{'request.course.uri'}; - my $file=&Apache::lonnet::filelocation("",$main_seq); - my $filecontents=&Apache::lonnet::getfile($file); - my @file_seq = &content_map($filecontents); - for (my $iu=0;$iu<=$#file_seq;$iu++) { - $file_seq[$iu]=~s/^"//; - $file_seq[$iu]=~s/"$//; - if ($file_seq[$iu]=~m/\S+/) { - $file_seq[$iu]=&Apache::lonnet::filelocation("",$file_seq[$iu]); - } else { - $file_seq[$iu]= 'REMOVE IT PLEASE'; - } - } - my $i=0; - my $limit = $#file_seq; - while ($i<=$limit) { - unless ($file_seq[$i]=~m/\.(problem|page)/) { - if ($file_seq[$i]=~m/\.sequence/) { - my $filecontents=&Apache::lonnet::getfile($file_seq[$i]); - my @newfile_seq = &content_map($filecontents); - for (my $iu=0;$iu<=$#newfile_seq;$iu++) { - $newfile_seq[$iu]=~s/^"//; - $newfile_seq[$iu]=~s/"$//; - if ($newfile_seq[$iu]=~m/\S+/) { - $newfile_seq[$iu]=&Apache::lonnet::filelocation("",$newfile_seq[$iu]); - } else { - $newfile_seq[$iu]= 'REMOVE IT PLEASE'; - } - } - splice @file_seq,$i,1,@newfile_seq; - $i=0; - $limit = $#file_seq; - } else { - splice @file_seq,$i,1,'REMOVE IT PLEASE'; - } - } - $i++; - } - for (my $iu=0;$iu<=$#file_seq;$iu++) { - if ($file_seq[$iu]=~m/REMOVE IT PLEASE/) { - splice @file_seq,$iu,1; - } - } - if ($file_seq[-1]=~m/REMOVE IT PLEASE/) { - pop @file_seq; - } - #-- produce an output string - for (my $i=0;$i<=$#file_seq;$i++) { - my $urlp = $file_seq[$i]; - $urlp=~s/\/home\/httpd\/html//; - if ($urlp=~m/\.(problem|exam|quiz|assess|survey|form|library)/) { - my %moreenv; - $moreenv{'form.grade_target'}='tex'; - &Apache::lonnet::appenv(%moreenv); - my $texversion=&Apache::lonnet::ssi($urlp); - &Apache::lonnet::delenv('form.grade_target'); - $result .= $texversion; - } - } - $result = &additional_cleanup($result); - } elsif ($choice eq 'All class print') { - #-- prints assignments for whole class or for selected students - my (@students,@st_output) = ((),()); - for (my $i=0; $i<$ENV{'form.numberofstudents'};$i++) { - if ($ENV{'form.whomtoprint'.$i}=~/:/) { - push @students,$ENV{'form.whomtoprint'.$i}; - } - } - #where is the primary sequence containing current resource (the same for all students)? - my $symbolic = &Apache::lonnet::symbread($ENV{'form.url'}); - $symbolic =~ m/([^_]+)_/; - my $primary_sequence = '/res/'.$1; - #opens and analyses the primary sequence file, produces the array of resources - my $sequence_file=&Apache::lonnet::filelocation("",$primary_sequence); - my $sequencefilecontents=&Apache::lonnet::getfile($sequence_file); - my @master_seq = &content_map($sequencefilecontents); - #loop over students - foreach my $person (@students) { - my $current_output = ''; - my ($usersection,$username,$userdomain) = split /:/,$person; - my $fullname = &Apache::grades::get_fullname($username,$userdomain); - #goes through all resources, checks if they are available for current student, and produces output - foreach my $curres (@master_seq) { - $curres =~ s/^"//; - $curres =~ s/"$//; - if ($curres=~/\w+/) { - my $symb = &Apache::lonnet::symbread($curres); - my ($map,$id,$res_url) = split(/___/,$symb); - if (&Apache::lonnet::allowed('bre',$res_url)) { - my $rendered = &Apache::loncommon::get_student_view($symb,$username,$userdomain, - $ENV{'request.course.id'},'tex'); - $current_output .= $rendered; - } - } - } - $current_output =~ s/\\begin{document}/\\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent\\fbox{\\textbf{$fullname}}\\hskip 1\.4in } \\vskip 5 mm /; - $result .= $current_output; - } +# +# The NUMBER_TO_PRINT and SPLIT_PDFS +# variables interact, this sub looks at these two parameters +# and comes up with a final value for NUMBER_TO_PRINT which can be: +# all - if SPLIT_PDFS eq 'all'. +# 1 - if SPLIT_PDFS eq 'oneper' +# section - if SPLIT_PDFS eq 'sections' +# - if SPLIT_PDFS eq 'usenumber' +# +sub adjust_number_to_print { + my $helper = shift; + + my $split_pdf = $helper->{'VARS'}->{'SPLIT_PDFS'}; + + if ( $split_pdf eq 'all' ) { + $helper->{'VARS'}->{'NUMBER_TO_PRINT'} = 'all'; + } + elsif ( $split_pdf eq 'oneper' ) { + $helper->{'VARS'}->{'NUMBER_TO_PRINT'} = 1; + } + elsif ( $split_pdf eq 'sections' ) { + $helper->{'VARS'}->{'NUMBER_TO_PRINT'} = 'section'; + } + elsif ( $split_pdf eq 'usenumber' ) { + + # Unmodified. + } + else { - $result = &additional_cleanup($result); + # Error!!!! + croak + "bad SPLIT_PDFS: $split_pdf in lonprintout::adjust_number_to_print"; + } +} +sub character_chart { + my $result = shift; + return &Apache::entities::replace_entities($result); +} +sub old_character_chart { + my $result = shift; + $result =~ s/&\#0?0?(7|9);//g; + $result =~ s/&\#0?(10|13);//g; + $result =~ s/&\#0?32;/ /g; + $result =~ s/&\#0?33;/!/g; + $result =~ s/&(\#0?34|quot);/\"/g; + $result =~ s/&\#0?35;/\\\#/g; + $result =~ s/&\#0?36;/\\\$/g; + $result =~ s/&\#0?37;/\\%/g; + $result =~ s/&(\#0?38|amp);/\\&/g; + $result =~ s/&\#(0?39|146);/\'/g; + $result =~ s/&\#0?40;/(/g; + $result =~ s/&\#0?41;/)/g; + $result =~ s/&\#0?42;/\*/g; + $result =~ s/&\#0?43;/\+/g; + $result =~ s/&\#(0?44|130);/,/g; + $result =~ s/&\#0?45;/-/g; + $result =~ s/&\#0?46;/\./g; + $result =~ s/&\#0?47;/\//g; + $result =~ s/&\#0?48;/0/g; + $result =~ s/&\#0?49;/1/g; + $result =~ s/&\#0?50;/2/g; + $result =~ s/&\#0?51;/3/g; + $result =~ s/&\#0?52;/4/g; + $result =~ s/&\#0?53;/5/g; + $result =~ s/&\#0?54;/6/g; + $result =~ s/&\#0?55;/7/g; + $result =~ s/&\#0?56;/8/g; + $result =~ s/&\#0?57;/9/g; + $result =~ s/&\#0?58;/:/g; + $result =~ s/&\#0?59;/;/g; + $result =~ s/&(\#0?60|lt|\#139);/\$<\$/g; + $result =~ s/&\#0?61;/\\ensuremath\{=\}/g; + $result =~ s/&(\#0?62|gt|\#155);/\\ensuremath\{>\}/g; + $result =~ s/&\#0?63;/\?/g; + $result =~ s/&\#0?65;/A/g; + $result =~ s/&\#0?66;/B/g; + $result =~ s/&\#0?67;/C/g; + $result =~ s/&\#0?68;/D/g; + $result =~ s/&\#0?69;/E/g; + $result =~ s/&\#0?70;/F/g; + $result =~ s/&\#0?71;/G/g; + $result =~ s/&\#0?72;/H/g; + $result =~ s/&\#0?73;/I/g; + $result =~ s/&\#0?74;/J/g; + $result =~ s/&\#0?75;/K/g; + $result =~ s/&\#0?76;/L/g; + $result =~ s/&\#0?77;/M/g; + $result =~ s/&\#0?78;/N/g; + $result =~ s/&\#0?79;/O/g; + $result =~ s/&\#0?80;/P/g; + $result =~ s/&\#0?81;/Q/g; + $result =~ s/&\#0?82;/R/g; + $result =~ s/&\#0?83;/S/g; + $result =~ s/&\#0?84;/T/g; + $result =~ s/&\#0?85;/U/g; + $result =~ s/&\#0?86;/V/g; + $result =~ s/&\#0?87;/W/g; + $result =~ s/&\#0?88;/X/g; + $result =~ s/&\#0?89;/Y/g; + $result =~ s/&\#0?90;/Z/g; + $result =~ s/&\#0?91;/[/g; + $result =~ s/&\#0?92;/\\ensuremath\{\\setminus\}/g; + $result =~ s/&\#0?93;/]/g; + $result =~ s/&\#(0?94|136);/\\ensuremath\{\\wedge\}/g; + $result =~ s/&\#(0?95|138|154);/\\underline{\\makebox[2mm]{\\strut}}/g; + $result =~ s/&\#(0?96|145);/\`/g; + $result =~ s/&\#0?97;/a/g; + $result =~ s/&\#0?98;/b/g; + $result =~ s/&\#0?99;/c/g; + $result =~ s/&\#100;/d/g; + $result =~ s/&\#101;/e/g; + $result =~ s/&\#102;/f/g; + $result =~ s/&\#103;/g/g; + $result =~ s/&\#104;/h/g; + $result =~ s/&\#105;/i/g; + $result =~ s/&\#106;/j/g; + $result =~ s/&\#107;/k/g; + $result =~ s/&\#108;/l/g; + $result =~ s/&\#109;/m/g; + $result =~ s/&\#110;/n/g; + $result =~ s/&\#111;/o/g; + $result =~ s/&\#112;/p/g; + $result =~ s/&\#113;/q/g; + $result =~ s/&\#114;/r/g; + $result =~ s/&\#115;/s/g; + $result =~ s/&\#116;/t/g; + $result =~ s/&\#117;/u/g; + $result =~ s/&\#118;/v/g; + $result =~ s/&\#119;/w/g; + $result =~ s/&\#120;/x/g; + $result =~ s/&\#121;/y/g; + $result =~ s/&\#122;/z/g; + $result =~ s/&\#123;/\\{/g; + $result =~ s/&\#124;/\|/g; + $result =~ s/&\#125;/\\}/g; + $result =~ s/&\#126;/\~/g; + $result =~ s/&\#131;/\\textflorin /g; + $result =~ s/&\#132;/\"/g; + $result =~ s/&\#133;/\\ensuremath\{\\ldots\}/g; + $result =~ s/&\#134;/\\ensuremath\{\\dagger\}/g; + $result =~ s/&\#135;/\\ensuremath\{\\ddagger\}/g; + $result =~ s/&\#137;/\\textperthousand /g; + $result =~ s/&\#140;/{\\OE}/g; + $result =~ s/&\#147;/\`\`/g; + $result =~ s/&\#148;/\'\'/g; + $result =~ s/&\#149;/\\ensuremath\{\\bullet\}/g; + $result =~ s/&(\#150|\#8211);/--/g; + $result =~ s/&\#151;/---/g; + $result =~ s/&\#152;/\\ensuremath\{\\sim\}/g; + $result =~ s/&\#153;/\\texttrademark /g; + $result =~ s/&\#156;/\\oe/g; + $result =~ s/&\#159;/\\\"Y/g; + $result =~ s/&(\#160|nbsp);/~/g; + $result =~ s/&(\#161|iexcl);/!\`/g; + $result =~ s/&(\#162|cent);/\\textcent /g; + $result =~ s/&(\#163|pound);/\\pounds /g; + $result =~ s/&(\#164|curren);/\\textcurrency /g; + $result =~ s/&(\#165|yen);/\\textyen /g; + $result =~ s/&(\#166|brvbar);/\\textbrokenbar /g; + $result =~ s/&(\#167|sect);/\\textsection /g; + $result =~ s/&(\#168|uml);/\\"\{\} /g; + $result =~ s/&(\#169|copy);/\\copyright /g; + $result =~ s/&(\#170|ordf);/\\textordfeminine /g; + $result =~ s/&(\#172|not);/\\ensuremath\{\\neg\}/g; + $result =~ s/&(\#173|shy);/ - /g; + $result =~ s/&(\#174|reg);/\\textregistered /g; + $result =~ s/&(\#175|macr);/\\ensuremath\{^{-}\}/g; + $result =~ s/&(\#176|deg);/\\ensuremath\{^{\\circ}\}/g; + $result =~ s/&(\#177|plusmn);/\\ensuremath\{\\pm\}/g; + $result =~ s/&(\#178|sup2);/\\ensuremath\{^2\}/g; + $result =~ s/&(\#179|sup3);/\\ensuremath\{^3\}/g; + $result =~ s/&(\#180|acute);/\\'\{\} /g; + $result =~ s/&(\#181|micro);/\\ensuremath\{\\mu\}/g; + $result =~ s/&(\#182|para);/\\P/g; + $result =~ s/&(\#183|middot);/\\ensuremath\{\\cdot\}/g; + $result =~ s/&(\#184|cedil);/\\c{\\strut}/g; + $result =~ s/&(\#185|sup1);/\\ensuremath\{^1\}/g; + $result =~ s/&(\#186|ordm);/\\textordmasculine /g; + $result =~ s/&(\#188|frac14);/\\textonequarter /g; + $result =~ s/&(\#189|frac12);/\\textonehalf /g; + $result =~ s/&(\#190|frac34);/\\textthreequarters /g; + $result =~ s/&(\#191|iquest);/?\`/g; + $result =~ s/&(\#192|Agrave);/\\\`{A}/g; + $result =~ s/&(\#193|Aacute);/\\\'{A}/g; + $result =~ s/&(\#194|Acirc);/\\^{A}/g; + $result =~ s/&(\#195|Atilde);/\\~{A}/g; + $result =~ s/&(\#196|Auml);/\\\"{A}/g; + $result =~ s/&(\#197|Aring);/{\\AA}/g; + $result =~ s/&(\#198|AElig);/{\\AE}/g; + $result =~ s/&(\#199|Ccedil);/\\c{c}/g; + $result =~ s/&(\#200|Egrave);/\\\`{E}/g; + $result =~ s/&(\#201|Eacute);/\\\'{E}/g; + $result =~ s/&(\#202|Ecirc);/\\^{E}/g; + $result =~ s/&(\#203|Euml);/\\\"{E}/g; + $result =~ s/&(\#204|Igrave);/\\\`{I}/g; + $result =~ s/&(\#205|Iacute);/\\\'{I}/g; + $result =~ s/&(\#206|Icirc);/\\^{I}/g; + $result =~ s/&(\#207|Iuml);/\\\"{I}/g; + $result =~ s/&(\#209|Ntilde);/\\~{N}/g; + $result =~ s/&(\#210|Ograve);/\\\`{O}/g; + $result =~ s/&(\#211|Oacute);/\\\'{O}/g; + $result =~ s/&(\#212|Ocirc);/\\^{O}/g; + $result =~ s/&(\#213|Otilde);/\\~{O}/g; + $result =~ s/&(\#214|Ouml);/\\\"{O}/g; + $result =~ s/&(\#215|times);/\\ensuremath\{\\times\}/g; + $result =~ s/&(\#216|Oslash);/{\\O}/g; + $result =~ s/&(\#217|Ugrave);/\\\`{U}/g; + $result =~ s/&(\#218|Uacute);/\\\'{U}/g; + $result =~ s/&(\#219|Ucirc);/\\^{U}/g; + $result =~ s/&(\#220|Uuml);/\\\"{U}/g; + $result =~ s/&(\#221|Yacute);/\\\'{Y}/g; + $result =~ s/&(\#223|szlig);/{\\ss}/g; + $result =~ s/&(\#224|agrave);/\\\`{a}/g; + $result =~ s/&(\#225|aacute);/\\\'{a}/g; + $result =~ s/&(\#226|acirc);/\\^{a}/g; + $result =~ s/&(\#227|atilde);/\\~{a}/g; + $result =~ s/&(\#228|auml);/\\\"{a}/g; + $result =~ s/&(\#229|aring);/{\\aa}/g; + $result =~ s/&(\#230|aelig);/{\\ae}/g; + $result =~ s/&(\#231|ccedil);/\\c{c}/g; + $result =~ s/&(\#232|egrave);/\\\`{e}/g; + $result =~ s/&(\#233|eacute);/\\\'{e}/g; + $result =~ s/&(\#234|ecirc);/\\^{e}/g; + $result =~ s/&(\#235|euml);/\\\"{e}/g; + $result =~ s/&(\#236|igrave);/\\\`{i}/g; + $result =~ s/&(\#237|iacute);/\\\'{i}/g; + $result =~ s/&(\#238|icirc);/\\^{i}/g; + $result =~ s/&(\#239|iuml);/\\\"{i}/g; + $result =~ s/&(\#240|eth);/\\ensuremath\{\\partial\}/g; + $result =~ s/&(\#241|ntilde);/\\~{n}/g; + $result =~ s/&(\#242|ograve);/\\\`{o}/g; + $result =~ s/&(\#243|oacute);/\\\'{o}/g; + $result =~ s/&(\#244|ocirc);/\\^{o}/g; + $result =~ s/&(\#245|otilde);/\\~{o}/g; + $result =~ s/&(\#246|ouml);/\\\"{o}/g; + $result =~ s/&(\#247|divide);/\\ensuremath\{\\div\}/g; + $result =~ s/&(\#248|oslash);/{\\o}/g; + $result =~ s/&(\#249|ugrave);/\\\`{u}/g; + $result =~ s/&(\#250|uacute);/\\\'{u}/g; + $result =~ s/&(\#251|ucirc);/\\^{u}/g; + $result =~ s/&(\#252|uuml);/\\\"{u}/g; + $result =~ s/&(\#253|yacute);/\\\'{y}/g; + $result =~ s/&(\#255|yuml);/\\\"{y}/g; + $result =~ s/&\#295;/\\ensuremath\{\\hbar\}/g; + $result =~ s/&\#952;/\\ensuremath\{\\theta\}/g; + #Greek Alphabet + $result =~ s/&(alpha|\#945);/\\ensuremath\{\\alpha\}/g; + $result =~ s/&(beta|\#946);/\\ensuremath\{\\beta\}/g; + $result =~ s/&(gamma|\#947);/\\ensuremath\{\\gamma\}/g; + $result =~ s/&(delta|\#948);/\\ensuremath\{\\delta\}/g; + $result =~ s/&(epsilon|\#949);/\\ensuremath\{\\epsilon\}/g; + $result =~ s/&(zeta|\#950);/\\ensuremath\{\\zeta\}/g; + $result =~ s/&(eta|\#951);/\\ensuremath\{\\eta\}/g; + $result =~ s/&(theta|\#952);/\\ensuremath\{\\theta\}/g; + $result =~ s/&(iota|\#953);/\\ensuremath\{\\iota\}/g; + $result =~ s/&(kappa|\#954);/\\ensuremath\{\\kappa\}/g; + $result =~ s/&(lambda|\#955);/\\ensuremath\{\\lambda\}/g; + $result =~ s/&(mu|\#956);/\\ensuremath\{\\mu\}/g; + $result =~ s/&(nu|\#957);/\\ensuremath\{\\nu\}/g; + $result =~ s/&(xi|\#958);/\\ensuremath\{\\xi\}/g; + $result =~ s/&(omicron|\#959);/o/g; + $result =~ s/&(pi|\#960);/\\ensuremath\{\\pi\}/g; + $result =~ s/&(rho|\#961);/\\ensuremath\{\\rho\}/g; + $result =~ s/&(sigma|\#963);/\\ensuremath\{\\sigma\}/g; + $result =~ s/&(tau|\#964);/\\ensuremath\{\\tau\}/g; + $result =~ s/&(upsilon|\#965);/\\ensuremath\{\\upsilon\}/g; + $result =~ s/&(phi|\#966);/\\ensuremath\{\\phi\}/g; + $result =~ s/&(chi|\#967);/\\ensuremath\{\\chi\}/g; + $result =~ s/&(psi|\#968);/\\ensuremath\{\\psi\}/g; + $result =~ s/&(omega|\#969);/\\ensuremath\{\\omega\}/g; + $result =~ s/&(thetasym|\#977);/\\ensuremath\{\\vartheta\}/g; + $result =~ s/&(piv|\#982);/\\ensuremath\{\\varpi\}/g; + $result =~ s/&(Alpha|\#913);/A/g; + $result =~ s/&(Beta|\#914);/B/g; + $result =~ s/&(Gamma|\#915);/\\ensuremath\{\\Gamma\}/g; + $result =~ s/&(Delta|\#916);/\\ensuremath\{\\Delta\}/g; + $result =~ s/&(Epsilon|\#917);/E/g; + $result =~ s/&(Zeta|\#918);/Z/g; + $result =~ s/&(Eta|\#919);/H/g; + $result =~ s/&(Theta|\#920);/\\ensuremath\{\\Theta\}/g; + $result =~ s/&(Iota|\#921);/I/g; + $result =~ s/&(Kappa|\#922);/K/g; + $result =~ s/&(Lambda|\#923);/\\ensuremath\{\\Lambda\}/g; + $result =~ s/&(Mu|\#924);/M/g; + $result =~ s/&(Nu|\#925);/N/g; + $result =~ s/&(Xi|\#926);/\\ensuremath\{\\Xi\}/g; + $result =~ s/&(Omicron|\#927);/O/g; + $result =~ s/&(Pi|\#928);/\\ensuremath\{\\Pi\}/g; + $result =~ s/&(Rho|\#929);/P/g; + $result =~ s/&(Sigma|\#931);/\\ensuremath\{\\Sigma\}/g; + $result =~ s/&(Tau|\#932);/T/g; + $result =~ s/&(Upsilon|\#933);/\\ensuremath\{\\Upsilon\}/g; + $result =~ s/&(Phi|\#934);/\\ensuremath\{\\Phi\}/g; + $result =~ s/&(Chi|\#935);/X/g; + $result =~ s/&(Psi|\#936);/\\ensuremath\{\\Psi\}/g; + $result =~ s/&(Omega|\#937);/\\ensuremath\{\\Omega\}/g; + + #Arrows (extended HTML 4.01) + $result =~ s/&(larr|\#8592);/\\ensuremath\{\\leftarrow\}/g; + $result =~ s/&(uarr|\#8593);/\\ensuremath\{\\uparrow\}/g; + $result =~ s/&(rarr|\#8594);/\\ensuremath\{\\rightarrow\}/g; + $result =~ s/&(darr|\#8595);/\\ensuremath\{\\downarrow\}/g; + $result =~ s/&(harr|\#8596);/\\ensuremath\{\\leftrightarrow\}/g; + $result =~ s/&(lArr|\#8656);/\\ensuremath\{\\Leftarrow\}/g; + $result =~ s/&(uArr|\#8657);/\\ensuremath\{\\Uparrow\}/g; + $result =~ s/&(rArr|\#8658);/\\ensuremath\{\\Rightarrow\}/g; + $result =~ s/&(dArr|\#8659);/\\ensuremath\{\\Downarrow\}/g; + $result =~ s/&(hArr|\#8660);/\\ensuremath\{\\Leftrightarrow\}/g; + + #Mathematical Operators (extended HTML 4.01) + $result =~ s/&(forall|\#8704);/\\ensuremath\{\\forall\}/g; + $result =~ s/&(part|\#8706);/\\ensuremath\{\\partial\}/g; + $result =~ s/&(exist|\#8707);/\\ensuremath\{\\exists\}/g; + $result =~ s/&(empty|\#8709);/\\ensuremath\{\\emptyset\}/g; + $result =~ s/&(nabla|\#8711);/\\ensuremath\{\\nabla\}/g; + $result =~ s/&(isin|\#8712);/\\ensuremath\{\\in\}/g; + $result =~ s/&(notin|\#8713);/\\ensuremath\{\\notin\}/g; + $result =~ s/&(ni|\#8715);/\\ensuremath\{\\ni\}/g; + $result =~ s/&(prod|\#8719);/\\ensuremath\{\\prod\}/g; + $result =~ s/&(sum|\#8721);/\\ensuremath\{\\sum\}/g; + $result =~ s/&(minus|\#8722);/\\ensuremath\{-\}/g; + $result =~ s/–/\\ensuremath\{-\}/g; + $result =~ s/&(lowast|\#8727);/\\ensuremath\{*\}/g; + $result =~ s/&(radic|\#8730);/\\ensuremath\{\\surd\}/g; + $result =~ s/&(prop|\#8733);/\\ensuremath\{\\propto\}/g; + $result =~ s/&(infin|\#8734);/\\ensuremath\{\\infty\}/g; + $result =~ s/&(ang|\#8736);/\\ensuremath\{\\angle\}/g; + $result =~ s/&(and|\#8743);/\\ensuremath\{\\wedge\}/g; + $result =~ s/&(or|\#8744);/\\ensuremath\{\\vee\}/g; + $result =~ s/&(cap|\#8745);/\\ensuremath\{\\cap\}/g; + $result =~ s/&(cup|\#8746);/\\ensuremath\{\\cup\}/g; + $result =~ s/&(int|\#8747);/\\ensuremath\{\\int\}/g; + $result =~ s/&(sim|\#8764);/\\ensuremath\{\\sim\}/g; + $result =~ s/&(cong|\#8773);/\\ensuremath\{\\cong\}/g; + $result =~ s/&(asymp|\#8776);/\\ensuremath\{\\approx\}/g; + $result =~ s/&(ne|\#8800);/\\ensuremath\{\\not=\}/g; + $result =~ s/&(equiv|\#8801);/\\ensuremath\{\\equiv\}/g; + $result =~ s/&(le|\#8804);/\\ensuremath\{\\leq\}/g; + $result =~ s/&(ge|\#8805);/\\ensuremath\{\\geq\}/g; + $result =~ s/&(sub|\#8834);/\\ensuremath\{\\subset\}/g; + $result =~ s/&(sup|\#8835);/\\ensuremath\{\\supset\}/g; + $result =~ s/&(nsub|\#8836);/\\ensuremath\{\\not\\subset\}/g; + $result =~ s/&(sube|\#8838);/\\ensuremath\{\\subseteq\}/g; + $result =~ s/&(supe|\#8839);/\\ensuremath\{\\supseteq\}/g; + $result =~ s/&(oplus|\#8853);/\\ensuremath\{\\oplus\}/g; + $result =~ s/&(otimes|\#8855);/\\ensuremath\{\\otimes\}/g; + $result =~ s/&(perp|\#8869);/\\ensuremath\{\\perp\}/g; + $result =~ s/&(sdot|\#8901);/\\ensuremath\{\\cdot\}/g; + + #Geometric Shapes (extended HTML 4.01) + $result =~ s/&(loz|\#9674);/\\ensuremath\{\\Diamond\}/g; + + #Miscellaneous Symbols (extended HTML 4.01) + $result =~ s/&(spades|\#9824);/\\ensuremath\{\\spadesuit\}/g; + $result =~ s/&(clubs|\#9827);/\\ensuremath\{\\clubsuit\}/g; + $result =~ s/&(hearts|\#9829);/\\ensuremath\{\\heartsuit\}/g; + $result =~ s/&(diams|\#9830);/\\ensuremath\{\\diamondsuit\}/g; + + # Chemically useful 'things' contributed by Hon Kie (bug 4652). + + $result =~ s/&\#8636;/\\ensuremath\{\\leftharpoonup\}/g; + $result =~ s/&\#8637;/\\ensuremath\{\\leftharpoondown\}/g; + $result =~ s/&\#8640;/\\ensuremath\{\\rightharpoonup\}/g; + $result =~ s/&\#8641;/\\ensuremath\{\\rightharpoondown\}/g; + $result =~ s/&\#8652;/\\ensuremath\{\\rightleftharpoons\}/g; + $result =~ s/&\#8605;/\\ensuremath\{\\leadsto\}/g; + $result =~ s/&\#8617;/\\ensuremath\{\\hookleftarrow\}/g; + $result =~ s/&\#8618;/\\ensuremath\{\\hookrightarrow\}/g; + $result =~ s/&\#8614;/\\ensuremath\{\\mapsto\}/g; + $result =~ s/&\#8599;/\\ensuremath\{\\nearrow\}/g; + $result =~ s/&\#8600;/\\ensuremath\{\\searrow\}/g; + $result =~ s/&\#8601;/\\ensuremath\{\\swarrow\}/g; + $result =~ s/&\#8598;/\\ensuremath\{\\nwarrow\}/g; + + # Left/right quotations: + + $result =~ s/&(ldquo|#8220);/\`\`/g; + $result =~ s/&(rdquo|#8221);/\'\'/g; + + return $result; +} + +#width, height, oddsidemargin, evensidemargin, topmargin +my %page_formats = ( + 'letter' => { + 'book' => { + '1' => [ '7.1 in', '9.8 in', '-0.57 in', '-0.57 in', '0.275 in' ], + '2' => [ '3.66 in', '9.8 in', '-0.57 in', '-0.57 in', '0.275 in' ] + }, + 'album' => { + '1' => [ '8.8 in', '6.8 in', '-0.55 in', '-0.55 in', '0.394 in' ], + '2' => [ '4.8 in', '6.8 in', '-0.5 in', '-1.0 in', '3.5 in' ] + }, + }, + 'legal' => { + 'book' => { + '1' => [ '7.1 in', '13 in',, '-0.57 in', '-0.57 in', '-0.5 in' ], + '2' => [ '3.66 in', '13 in', '-0.57 in', '-0.57 in', '-0.5 in' ] + }, + 'album' => { + '1' => [ '12 in', '7.1 in',, '-0.57 in', '-0.57 in', '-0.5 in' ], + '2' => [ '6.0 in', '7.1 in', '-1 in', '-1 in', '5 in' ] + }, + }, + 'tabloid' => { + 'book' => { + '1' => [ '9.8 in', '16 in', '-0.57 in', '-0.57 in', '-0.5 in' ], + '2' => [ '4.9 in', '16 in', '-0.57 in', '-0.57 in', '-0.5 in' ] + }, + 'album' => { + '1' => [ '16 in', '9.8 in', '-0.57 in', '-0.57 in', '-0.5 in' ], + '2' => [ '16 in', '4.9 in', '-0.57 in', '-0.57 in', '-0.5 in' ] + }, + }, + 'executive' => { + 'book' => { + '1' => [ '6.8 in', '9 in', '-0.57 in', '-0.57 in', '1.2 in' ], + '2' => [ '3.1 in', '9 in', '-0.57 in', '-0.57 in', '1.2 in' ] + }, + 'album' => { + '1' => [], + '2' => [] + }, + }, + 'a2' => { + 'book' => { + '1' => [], + '2' => [] + }, + 'album' => { + '1' => [], + '2' => [] + }, + }, + 'a3' => { + 'book' => { + '1' => [], + '2' => [] + }, + 'album' => { + '1' => [], + '2' => [] + }, + }, + 'a4' => { + 'book' => { + '1' => + [ '17.6 cm', '27.2 cm', '-1.397 cm', '-2.11 cm', '-1.27 cm' ], + '2' => [ '9.1 cm', '27.2 cm', '-1.397 cm', '-2.11 cm', '-1.27 cm' ] + }, + 'album' => { + '1' => [ '21.59 cm', '19.558 cm', '-1.397cm', '-2.11 cm', '0 cm' ], + '2' => [ '9.91 cm', '19.558 cm', '-1.397 cm', '-2.11 cm', '0 cm' ] + }, + }, + 'a5' => { + 'book' => { + '1' => [], + '2' => [] + }, + 'album' => { + '1' => [], + '2' => [] + }, + }, + 'a6' => { + 'book' => { + '1' => [], + '2' => [] + }, + 'album' => { + '1' => [], + '2' => [] + }, + }, +); + +sub page_format { + +# +#Supported paper format: "Letter [8 1/2x11 in]", "Legal [8 1/2x14 in]", +# "Ledger/Tabloid [11x17 in]", "Executive [7 1/2x10 in]", +# "A2 [420x594 mm]", "A3 [297x420 mm]", +# "A4 [210x297 mm]", "A5 [148x210 mm]", +# "A6 [105x148 mm]" +# + my ( $papersize, $layout, $numberofcolumns ) = @_; + return @{ $page_formats{$papersize}->{$layout}->{$numberofcolumns} }; +} + +sub get_name { + my ( $uname, $udom ) = @_; + if ( !defined($uname) ) { $uname = $env{'user.name'}; } + if ( !defined($udom) ) { $udom = $env{'user.domain'}; } + my $plainname = &Apache::loncommon::plainname( $uname, $udom ); + if ( $plainname =~ /^\s*$/ ) { $plainname = $uname . '@' . $udom; } + $plainname = &Apache::lonxml::latex_special_symbols( $plainname, 'header' ); + return $plainname; +} + +sub get_course { + my $courseidinfo; + if ( defined( $env{'request.course.id'} ) ) { + $courseidinfo = &Apache::lonxml::latex_special_symbols( + &unescape( + $env{ 'course.' . $env{'request.course.id'} . '.description' } + ), + 'header' + ); + my $sec = $env{'request.course.sec'}; - } elsif ($choice eq 'Subdirectory print') { - my $subdirtoprint = &Apache::lonnet::filelocation("",$ENV{'form.url'}); - $subdirtoprint =~ s/\/[^\/]+$//; - my @list_of_files = (); - if ($ENV{'request.role'}=~m/^au\./ or $ENV{'request.role'}=~m/^ca\./) { - $subdirtoprint =~ s/^[^~]*~(\w+)\//\/home\/$1\/public_html\//; - } else { - $subdirtoprint =~ s/.*(\/res\/)/$1/; - } - my @content_directory = (); - if ($ENV{'request.role'}=~m/^au\./ or $ENV{'request.role'}=~m/^ca\./) { - @content_directory = &Apache::lonnet::dirlist($subdirtoprint,$ENV{'user.domain'}, $ENV{'user.name'},''); - } else { - @content_directory = &Apache::lonnet::dirlist($subdirtoprint); - } - for (my $iy=0;$iy<=$#content_directory;$iy++) { - my @tempo_array = split(/&/,$content_directory[$iy]); - if ($tempo_array[0] =~ m/^[^\.]+\.(problem|exam|quiz|assess|survey|form|library)$/) { - push(@list_of_files,$tempo_array[0]); - } - } - $subdirtoprint =~ s/\/$//; - for (my $i=0;$i<=$#list_of_files;$i++) { - my $urlp = $subdirtoprint.'/'.$list_of_files[$i]; - my %moreenv; - $moreenv{'form.grade_target'}='tex'; - &Apache::lonnet::appenv(%moreenv); - if ($ENV{'request.role'}=~m/^au\./ or $ENV{'request.role'}=~m/^ca\./) { - $urlp =~ s/\/home\/([^\/]*)\/public_html/\/~$1/; - } - my $texversion=&Apache::lonnet::ssi($urlp); - &Apache::lonnet::delenv('form.grade_target'); - $texversion =~ s/(\\begin{document})/$1 {\\tiny\\begin{verbatim}$urlp\\end{verbatim}}/; - $result .= $texversion; - } - $result = &additional_cleanup($result); - - - } -#-- corrections for the different page formats - if ($layout eq 'CBI' and $numberofcolumns eq '1') { - } elsif ($layout eq 'CBI' and $numberofcolumns eq '2') { - $result =~ s/\\begin{document}/\\setlength{\\oddsidemargin}{-40pt}\\setlength{\\evensidemargin}{-60pt}\\setlength{\\topmargin}{200pt}\\setlength{\\textwidth}{4\.4in}\\setlength{\\textheight}{6\.8in}\\setlength{\\parindent}{20pt}\\setlength{\\marginparwidth}{90pt}\\setlength{\\textfloatsep}{8pt plus 2\.0pt minus 4\.0pt} \\begin{document}/; - $laystyle = 'album'; - } elsif ($layout eq 'CAPA') { - my $courseidinfo = $ENV{'request.role'}; - $_ = $courseidinfo; - m/.*\/(.*)/; - $courseidinfo = $ENV{'course.physnet_'.$1.'.description'}; -# $result =~ s/\\documentclass\[letterpaper\]{article}/\\documentclass\[twocolumn\]{article}/; - $result =~ s/\\documentclass\[letterpaper\]{article}/\\documentclass{article}/; - if ($choice ne 'All class print') { - $result =~ s/\\begin{document}/\\textheight 25\.9cm\\oddsidemargin = -0\.57in\\evensidemargin = -0\.57in\\textwidth= 9cm\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\begin{document}\\voffset=-1\.8cm\\setcounter{page}{1}\\parbox{\\minipagewidth}{\\noindent\\fbox{\\textbf{$ENV{'environment.firstname'} $ENV{'environment.lastname'}}}\\hskip 1\.4in $courseidinfo} \\vskip 5 mm /; - } else { - $result =~ s/\\begin{document}/\\textheight 25\.9cm\\oddsidemargin = -0\.57in\\evensidemargin = -0\.57in\\textwidth= 9cm\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\begin{document}\\voffset=-1\.8cm\\setcounter{page}{1} \\vskip 5 mm /; - } - $result =~ s/\\includegraphics{/\\includegraphics\[width=9\.0 cm\]{/g; -# $result =~ s/\\includegraphics{/\\includegraphics\[width=\\textwidth\]{/g; -# $result =~ s/(\\end{document})/\\newline\\noindent\\makebox\[9.0cm\]\[b\]{\\hrulefill}\\newline\\noindent\\tiny Dept\. of Physics and Astronomy, MSU\\makebox\[1.5cm\]\[b\]{\\hfill}LON-CAPA\\copyright MSU GNU\/GPL $1/; - $result =~ s/(\\end{document})/\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill}\\newline\\noindent\\tiny \\makebox\[1.5cm\]\[b\]{\\hfill}LON-CAPA\\copyright Michigan State University Board of Trustees $1/; -# $result =~ s/(\\end{longtable}\s*)(\\newline\\noindent\\makebox\[9\.0cm\]\[b\]{\\hrulefill})/$2$1/g; - $result =~ s/(\\end{longtable}\s*)(\\newline\\noindent\\makebox\[\\textwidth\/$number_of_columns\]\[b\]{\\hrulefill})/$2$1/g; - $result =~ s/(\\end{longtable}\s*)\\newline/$1/g; - $result =~ s/\$number_of_columns/$number_of_columns/g; - } - #changes page's parameters for the one column output - if ($ENV{'form.numberofcolumns'} == 1) { - $result =~ s/\\textwidth= 9cm/\\textwidth= $ENV{'form.width'}/; - } -#-- LaTeX corrections - my $first_comment = index($result,'',$first_comment); - substr($result,$first_comment,$end_comment-$first_comment+3) = ''; - $first_comment = index($result,'', $first_comment ); + substr( $result, $first_comment, $end_comment - $first_comment + 3 ) = + ''; + $first_comment = index( $result, '