Diff for /loncom/interface/lonprintout.pm between versions 1.550 and 1.556

version 1.550, 2009/04/17 10:08:42 version 1.556, 2009/06/22 09:50:39
Line 70  my $ssi_last_error;  # The error text fr Line 70  my $ssi_last_error;  # The error text fr
 my $ssi_retry_count = 5; # Some arbitrary value.  my $ssi_retry_count = 5; # Some arbitrary value.
   
   
   #  Font size:
   
   my $font_size = 'normalsize'; # Default is normalsize...
   
   
 # Fetch the contents of a resource, uninterpreted.  # Fetch the contents of a resource, uninterpreted.
 # This is used here to fetch a latex file to be included  # This is used here to fetch a latex file to be included
Line 114  sub annotate { Line 118  sub annotate {
     return $result;      return $result;
 }  }
   
   #
   #   Set a global document font size:
   #   This is done by replacing \begin{document}
   #   with \begin{document}{\some-font-directive
   #   and \end{document} with
   #   }\end{document
   #
   sub set_font_size {
   
       my ($text) = @_;
   
       $text =~ s/\\begin{document}/\\begin{document}{\\$font_size/;
       $text =~ s/\\end{document}/}\\end{document}/;
       return $text;
   
   
   }
   
 # include_pdf - PDF files are included into the   # include_pdf - PDF files are included into the 
 # output as follows:  # output as follows:
 #  - The PDF, if necessary, is replicated.  #  - The PDF, if necessary, is replicated.
Line 163  sub include_pdf { Line 185  sub include_pdf {
     $base =~ s/ /\_/g;      $base =~ s/ /\_/g;
   
   
     my $output = &print_latex_header()."\\begin{document}\n";      my $output = &print_latex_header();
     $output    .= '\special{ps: _begin_job_ ('      $output    .= '\special{ps: _begin_job_ ('
  .$base.'.pdf.eps'.   .$base.'.pdf.eps'.
  ')run _end_job_}';   ')run _end_job_}';
Line 1474  sub print_construction_sequence { Line 1496  sub print_construction_sequence {
     }      }
  }   }
  elsif ($urlp =~ /\.pdf$/i) {   elsif ($urlp =~ /\.pdf$/i) {
     $result .= &include_pdf($urlp);      my $texversion;
       if ($member != 0) {
    $texversion .= '\cleardoublepage';
       }
   
       $texversion .= &include_pdf($urlp);
       $texversion = &latex_header_footer_remove($texversion);
       if ($member != $#order) {
    $texversion .= '\\ \cleardoublepage';
       }
       
       $result .= $texversion;
  }   }
     }      }
     if ($helper->{VARS}->{'construction'} eq '1') {$result=~s/(\\begin{document})/$1 \\fbox\{RANDOM SEED IS $rndseed\} /;}      if ($helper->{VARS}->{'construction'} eq '1') {$result=~s/(\\begin{document})/$1 \\fbox\{RANDOM SEED IS $rndseed\} /;}
Line 1486  sub output_data { Line 1519  sub output_data {
     my %parmhash = %$rparmhash;      my %parmhash = %$rparmhash;
     $ssi_error = 0; # This will be set nonzero by failing ssi's.      $ssi_error = 0; # This will be set nonzero by failing ssi's.
     $resources_printed = '';      $resources_printed = '';
       $font_size = $helper->{'VARS'}->{'fontsize'};
     my $do_postprocessing = 1;      my $do_postprocessing = 1;
     my $js = <<ENDPART;      my $js = <<ENDPART;
 <script type="text/javascript">  <script type="text/javascript">
Line 1692  ENDPART Line 1726  ENDPART
  && $currentURL=~/\.sequence$/ && $helper->{'VARS'}->{'construction'} eq '1') {   && $currentURL=~/\.sequence$/ && $helper->{'VARS'}->{'construction'} eq '1') {
             #printing content of sequence from the construction space              #printing content of sequence from the construction space
     $currentURL=~s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|;      $currentURL=~s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|;
     $result .= &print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});  #    $result .= &print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
     $result .= &print_construction_sequence($currentURL, $helper, %form,      $result .= &print_construction_sequence($currentURL, $helper, %form,
     $LaTeXwidth);      $LaTeXwidth);
     $result .= '\end{document}';        $result .= '\end{document}';  
Line 1725  ENDPART Line 1759  ENDPART
   
  } elsif ($cleanURL =~ /\.pdf$/i) {   } elsif ($cleanURL =~ /\.pdf$/i) {
     $result .= &include_pdf($cleanURL);      $result .= &include_pdf($cleanURL);
       $result .= '\end{document}';
  } else {   } else {
     $result.=&unsupported($currentURL,$helper->{'VARS'}->{'LATEX_TYPE'},      $result.=&unsupported($currentURL,$helper->{'VARS'}->{'LATEX_TYPE'},
   $helper->{'VARS'}->{'symb'});    $helper->{'VARS'}->{'symb'});
Line 1818  ENDPART Line 1853  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'});
       $texversion =~ s/\\begin{document}//;
     my $title = &Apache::lonnet::gettitle($master_seq[$i]);      my $title = &Apache::lonnet::gettitle($master_seq[$i]);
     $title = &Apache::lonxml::latex_special_symbols($title);      $title = &Apache::lonxml::latex_special_symbols($title);
     my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm ';      my $body ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm ';
Line 1853  ENDPART Line 1889  ENDPART
   $assignment,     $assignment, 
   $courseidinfo,     $courseidinfo, 
   $name);    $name);
   
     if ($numberofcolumns eq '1') {      if ($numberofcolumns eq '1') {
  $result .='\newpage \noindent\parbox{\minipagewidth}{\noindent\\lhead{'.$header_text.'}} \vskip 5 mm ';   $result .='\newpage \noindent\parbox{\minipagewidth}{\noindent\\lhead{'.$header_text.'}} \vskip 5 mm ';
     } else {      } else {
Line 1962  ENDPART Line 1999  ENDPART
  my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'};   my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'};
   
  #loop over students   #loop over students
  my $flag_latex_header_remove = 'NO';    my $flag_latex_header_remove = 'NO';
  my %moreenv;   my %moreenv;
          $moreenv{'instructor_comments'}='hide';           $moreenv{'instructor_comments'}='hide';
  $moreenv{'textwidth'}=&get_textwidth($helper,$LaTeXwidth);   $moreenv{'textwidth'}=&get_textwidth($helper,$LaTeXwidth);
Line 2208  ENDPART Line 2245  ENDPART
     $URLback=~s|^/~|/priv/|;      $URLback=~s|^/~|/priv/|;
  }   }
     }      }
       #
       # Final adjustment of the font size:
       #
   
       $result = set_font_size($result);
   
 #-- writing .tex file in prtspool   #-- writing .tex file in prtspool 
     my $temp_file;      my $temp_file;
Line 2292  ENDPART Line 2334  ENDPART
     # If there's been an unrecoverable SSI error, report it to the user      # If there's been an unrecoverable SSI error, report it to the user
     if ($ssi_error) {      if ($ssi_error) {
         my $helpurl = &Apache::loncommon::top_nav_help('Helpdesk');          my $helpurl = &Apache::loncommon::top_nav_help('Helpdesk');
         $r->print('<br /><h2>'.&mt('An unrecoverable network error occurred:').'</h2><p>  '.          $r->print('<br /><p class="LC_error">'.&mt('An unrecoverable network error occurred:').'</p><p>'.
                   &mt('At least one of the resources you chose to print could not be rendered due to an unrecoverable error when communicating with a server:').                    &mt('At least one of the resources you chose to print could not be rendered due to an unrecoverable error when communicating with a server:').
                   '<br />'.$ssi_last_error_resource.'<br />'.$ssi_last_error.                    '<br />'.$ssi_last_error_resource.'<br />'.$ssi_last_error.
                   '</p><p>'.&mt('You can continue using the link provided below, but make sure to carefully inspect your output file! The errors will be marked in the file.').'<br />'.                    '</p><p>'.&mt('You can continue using the link provided below, but make sure to carefully inspect your output file! The errors will be marked in the file.').'<br />'.
Line 2399  sub print_resources { Line 2441  sub print_resources {
   
           
     my $header =&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});      my $header =&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
       $header =~ s/\\begin{document}//;     #<<<<<
     my $title = &Apache::lonnet::gettitle($curresline);      my $title = &Apache::lonnet::gettitle($curresline);
     $title = &Apache::lonxml::latex_special_symbols($title);      $title = &Apache::lonxml::latex_special_symbols($title);
     my $body   ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm ';      my $body   ='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm ';
Line 2434  sub print_resources { Line 2477  sub print_resources {
  $rendered =~ s/\\end{document}//;   $rendered =~ s/\\end{document}//;
     }      }
     $current_output .= $rendered.'\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\strut \vskip 0 mm \strut ';      $current_output .= $rendered.'\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\strut \vskip 0 mm \strut ';
    } elsif($res_url = ~/\.pdf$/) {
       my $url = &Apache::lonnet::clutter($res_url);
       my $rendered  = &include_pdf($url);
       if ($remove_latex_header ne 'NO') {
    $rendered = &latex_header_footer_remove($rendered);
       }
       $current_output .= $rendered;
  } else {   } else {
     my $rendered = &unsupported($res_url,$helper->{'VARS'}->{'LATEX_TYPE'},$curresline);      my $rendered = &unsupported($res_url,$helper->{'VARS'}->{'LATEX_TYPE'},$curresline);
     if ($remove_latex_header ne 'NO') {      if ($remove_latex_header ne 'NO') {
Line 2449  sub print_resources { Line 2498  sub print_resources {
  }    } 
  if (&Apache::loncommon::connection_aborted($r)) { last; }   if (&Apache::loncommon::connection_aborted($r)) { last; }
     }      }
   
   
     my $courseidinfo = &get_course();      my $courseidinfo = &get_course();
     my $currentassignment=&Apache::lonxml::latex_special_symbols($helper->{VARS}->{'assignment'},'header');      my $currentassignment=&Apache::lonxml::latex_special_symbols($helper->{VARS}->{'assignment'},'header');
     my $header_line =      my $header_line =
Line 2457  sub print_resources { Line 2508  sub print_resources {
     my $header_start = ($columns_in_format == 1) ? '\lhead'      my $header_start = ($columns_in_format == 1) ? '\lhead'
                                          : '\fancyhead[LO]';                                           : '\fancyhead[LO]';
     $header_line = $header_start.'{'.$header_line.'}';      $header_line = $header_start.'{'.$header_line.'}';
   
     if ($current_output=~/\\documentclass/) {      if ($current_output=~/\\documentclass/) {
  $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent$header_line$namepostfix}\\vskip 5 mm /;   $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent$header_line$namepostfix}\\vskip 5 mm /;
     } else {      } else {
Line 3211  CHOOSE_FROM_ANY_SEQUENCE Line 3261  CHOOSE_FROM_ANY_SEQUENCE
  &addMessage('<br />'   &addMessage('<br />'
                    .'<h3>'.&mt('Print Options').'</h3>'                     .'<h3>'.&mt('Print Options').'</h3>'
                    .&Apache::lonhtmlcommon::start_pick_box()                     .&Apache::lonhtmlcommon::start_pick_box()
 #                  .&Apache::lonhtmlcommon::row_headline()  
 #                  .'<h3>'.&mt('Print Options').'</h3>'  
 #                  .&Apache::lonhtmlcommon::row_closure()  
                    .&Apache::lonhtmlcommon::row_title(                     .&Apache::lonhtmlcommon::row_title(
                        '<label for="ANSWER_TYPE_forminput">'                         '<label for="ANSWER_TYPE_forminput">'
                       .&mt('Print Answers')                        .&mt('Print Answers')
Line 3231  CHOOSE_FROM_ANY_SEQUENCE Line 3278  CHOOSE_FROM_ANY_SEQUENCE
         Apache::lonhelper::dropdown->new();          Apache::lonhelper::dropdown->new();
  &addMessage(&Apache::lonhtmlcommon::row_closure());   &addMessage(&Apache::lonhtmlcommon::row_closure());
  $startedTable = 1;   $startedTable = 1;
   
   #
   #  Select font size.
   #
   
               $helper->declareVar('fontsize');
               &addMessage(&Apache::lonhtmlcommon::row_title(&mt('Font Size')));
               my $xmlfrag = << "FONT_SELECTION";
   
             
               <dropdown variable='fontsize' multichoice='0', allowempty='0'>
               <defaultvalue>
     return 'normalsize';
               </defaultvalue>
               <choice computer='tiny'>Tiny</choice>
               <choice computer='sub/superscriptsize'>Script Size</choice>
               <choice computer='footnotesize'>Footnote Size</choice>
               <choice computer='small'>Small</choice>
               <choice computer='normalsize'>Normal (default)</choice>
               <choice computer='large'>larger than normal</choice>
               <choice computer='Large'>Even larger than normal</choice>
               <choice computer='LARGE'>Still larger than normal</choice>
               <choice computer='huge'>huge font size</choice>
               <choice computer='Huge'>Largest possible size</choice>
               </dropdown>
   FONT_SELECTION
               &Apache::lonxml::xmlparse($r, 'helper', $xmlfrag);
               &addMessage(&Apache::lonhtmlcommon::row_closure(1));
     }      }
   
     if ($perm{'pav'}) {      if ($perm{'pav'}) {
Line 3330  CHOOSE_FROM_ANY_SEQUENCE Line 3405  CHOOSE_FROM_ANY_SEQUENCE
     $paramHash->{'multichoice'} = "true";      $paramHash->{'multichoice'} = "true";
     $paramHash->{'allowempty'}  = "true";      $paramHash->{'allowempty'}  = "true";
     $paramHash->{'variable'}   = "showallfoils";      $paramHash->{'variable'}   = "showallfoils";
     $paramHash->{'CHOICES'} = [ ["Show all foils", "1"] ];      $paramHash->{'CHOICES'} = [ [&mt('Show All Foils'), "1"] ];
     Apache::lonhelper::choices->new();      Apache::lonhelper::choices->new();
             &addMessage(&Apache::lonhtmlcommon::row_closure(1));              &addMessage(&Apache::lonhtmlcommon::row_closure(1));
  }   }
Line 3367  CHOOSE_FROM_ANY_SEQUENCE Line 3442  CHOOSE_FROM_ANY_SEQUENCE
 .qq|<a href="javascript:openbrowser('helpform','style_file_forminput','sty')">|  .qq|<a href="javascript:openbrowser('helpform','style_file_forminput','sty')">|
 .$selectfiletext.'</a>'  .$selectfiletext.'</a>'
             .&Apache::lonhtmlcommon::row_closure()              .&Apache::lonhtmlcommon::row_closure()
             .&Apache::lonhtmlcommon::row_title(&mt('Show all foils'))              .&Apache::lonhtmlcommon::row_title(&mt('Show All Foils'))
             .'</message>              .'</message>
      <choices allowempty="1" multichoice="true" variable="showallfoils">       <choices allowempty="1" multichoice="true" variable="showallfoils">
                 <choice computer="1">&nbsp;</choice>                  <choice computer="1">&nbsp;</choice>
Line 3396  CHOOSE_FROM_ANY_SEQUENCE Line 3471  CHOOSE_FROM_ANY_SEQUENCE
  </dropdown>   </dropdown>
 PROBTYPE  PROBTYPE
             &Apache::lonxml::xmlparse($r, 'helper', $xmlfrag);              &Apache::lonxml::xmlparse($r, 'helper', $xmlfrag);
       
             &addMessage(&Apache::lonhtmlcommon::row_closure(1));              &addMessage(&Apache::lonhtmlcommon::row_closure(1));
   
   
   
         }          }
     }      }
   
Line 3508  sub render { Line 3584  sub render {
     my $pdfFormLabel=&mt('PDF-Formfields');      my $pdfFormLabel=&mt('PDF-Formfields');
     my $with=&mt('with Formfields');      my $with=&mt('with Formfields');
     my $without=&mt('without Formfields');      my $without=&mt('without Formfields');
       
   
     $result.='<h3>'.&mt('Layout Options').'</h3>'      $result.='<h3>'.&mt('Layout Options').'</h3>'
             .&Apache::loncommon::start_data_table()              .&Apache::loncommon::start_data_table()
             .&Apache::loncommon::start_data_table_header_row()              .&Apache::loncommon::start_data_table_header_row()
Line 3528  sub render { Line 3606  sub render {
     my $i;      my $i;
     for ($i = 1; $i <= $maxColumns; $i++) {      for ($i = 1; $i <= $maxColumns; $i++) {
         if ($i == 2) {          if ($i == 2) {
             $result .= "<option value='$i' selected>$i</option>\n";              $result .= '<option value="'.$i.'" selected="selected">'.$i.'</option>'."\n";
         } else {          } else {
             $result .= "<option value='$i'>$i</option>\n";              $result .= '<option value="'.$i.'">'.$i.'</option>'."\n";
         }          }
     }      }
   
Line 3546  sub render { Line 3624  sub render {
  $_=~/(\w+)/;   $_=~/(\w+)/;
  my $papersize=$1;   my $papersize=$1;
         if ($paperSize[$i]=~/$DefaultPaperSize/) {          if ($paperSize[$i]=~/$DefaultPaperSize/) {
             $result .= "<option selected value='$papersize'>" . $paperSize[$i] . "</option>\n";              $result .= '<option selected="selected" value="'.$papersize.'">'.$paperSize[$i].'</option>'."\n";
         } else {          } else {
             $result .= "<option value='$papersize'>" . $paperSize[$i] . "</option>\n";              $result .= '<option value="'.$papersize.'">'.$paperSize[$i].'</option>'."\n";
         }          }
         $i++;          $i++;
     }      }
Line 3557  sub render { Line 3635  sub render {
     </td>      </td>
     <td align='center'>      <td align='center'>
         <select name='${var}.pdfFormFields'>          <select name='${var}.pdfFormFields'>
             <option selected value='no'>$without</option>              <option selected="selected" value="no">$without</option>
             <option value='yes'>$with</option>              <option value="yes">$with</option>
         </select>          </select>
     </td>      </td>
 HTML  HTML

Removed from v.1.550  
changed lines
  Added in v.1.556


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>