Diff for /loncom/interface/lonprintout.pm between versions 1.563 and 1.568.4.2

version 1.563, 2009/10/27 10:17:18 version 1.568.4.2, 2010/02/25 04:55:30
Line 499  sub printf_style_subst { Line 499  sub printf_style_subst {
 sub format_page_header {  sub format_page_header {
     my ($width, $format, $assignment, $course, $student, $section) = @_;      my ($width, $format, $assignment, $course, $student, $section) = @_;
   
       
   
     $width = &recalcto_mm($width); # Get width in mm.      $width = &recalcto_mm($width); # Get width in mm.
       my $chars_per_line = int($width/1.6);   # Character/textline.
   
     #  Default format?      #  Default format?
   
     if ($format eq '') {      if ($format eq '') {
Line 514  sub format_page_header { Line 517  sub format_page_header {
  #   but only truncate the course.   #   but only truncate the course.
  # - Allow the assignment to be 2 lines (wrapped).   # - Allow the assignment to be 2 lines (wrapped).
  #   #
  my $chars_per_line = $width/2; # Character/textline.  
   
   
   
   
  my $name_length    = int($chars_per_line *3 /4);   my $name_length    = int($chars_per_line *3 /4);
  my $sec_length     = int($chars_per_line / 5);   my $sec_length     = int($chars_per_line / 5);
Line 552  sub format_page_header { Line 554  sub format_page_header {
         my $testPrintout = '\\\\'.&mt('Construction Space').' \\\\'.&mt('Test-Printout ');          my $testPrintout = '\\\\'.&mt('Construction Space').' \\\\'.&mt('Test-Printout ');
         $format =~ s/\\\\\s\\\\\s/$testPrintout/;          $format =~ s/\\\\\s\\\\\s/$testPrintout/;
     }      }
           #
       #  We're going to trust LaTeX to break lines appropriately, but
       #  we'll truncate anything that's more than 3 lines worth of
       # text.  This is also assuming (which will probably end badly)
       # nobody's going to embed LaTeX control sequences in the title
       # header or rather that those control sequences won't get broken
       # by the stuff below.
       #
       my $total_length = 3*$chars_per_line;
       if (length($format) > $total_length) {
    $format = substr($format, 0, $total_length);
       }
   
   
     return $format;      return $format;
           
Line 1539  sub print_page_in_course { Line 1553  sub print_page_in_course {
   
     # First is the overall page description.  This is then followed by the       # First is the overall page description.  This is then followed by the 
     # components of the page. Each of which must be printed independently.      # components of the page. Each of which must be printed independently.
   
     my $the_page = shift(@page_resources);       my $the_page = shift(@page_resources); 
   
   
     foreach my $resource (@page_resources) {      foreach my $resource (@page_resources) {
  my $resource_src   = $resource->src(); # Essentially the URL of the resource.   my $resource_src   = $resource->src(); # Essentially the URL of the resource.
  $result           .= $resource->title() . '\\\\';   $result           .= $resource->title() . '\\\\';
Line 1876  sub print_construction_sequence { Line 1890  sub print_construction_sequence {
 }  }
   
 sub output_data {  sub output_data {
     my ($r,$helper,$rparmhash) = @_;      my ($r,$helper,$rparmhash,$is_custom) = @_;
     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 = '';
Line 1917  ENDPART Line 1931  ENDPART
                   {'href' => '',                    {'href' => '',
                    'text' => 'Preparing Printout'}];                     'text' => 'Preparing Printout'}];
   
       if ($is_custom) {
           $brcrum = [{'href' => '',
                      'text' => 'Preparing Printout'}];
       }
   
     my $start_page  = &Apache::loncommon::start_page('Preparing Printout',      my $start_page  = &Apache::loncommon::start_page('Preparing Printout',
                                                      $js,                                                       $js,
                                                      {'bread_crumbs' => $brcrum,});                                                       {'bread_crumbs' => $brcrum,});
Line 1978  ENDPART Line 1997  ENDPART
  &Apache::lonnet::delenv('construct.style');   &Apache::lonnet::delenv('construct.style');
     }      }
   
   
     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 2094  ENDPART Line 2112  ENDPART
   
   
     $currentURL=~s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|;      $currentURL=~s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|;
 #    $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 2106  ENDPART Line 2123  ENDPART
  $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};   $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
  if ($currentURL=~/\/syllabus$/) {$currentURL=~s/\/res//;}   if ($currentURL=~/\/syllabus$/) {$currentURL=~s/\/res//;}
  $resources_printed .= $currentURL.':';   $resources_printed .= $currentURL.':';
  my $texversion=&ssi_with_retries($currentURL, $ssi_retry_count, %form);   my $texversion = &ssi_with_retries($currentURL, $ssi_retry_count, %form);
  if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') {   if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') {
     my $annotation = &annotate($currentURL);      my $annotation = &annotate($currentURL);
     $texversion    =~ s/(\\end{document})/$annotation$1/;      $texversion    =~ s/(\\end{document})/$annotation$1/;
Line 2139  ENDPART Line 2156  ENDPART
   
                 
  } else {   } else {
     &Apache::lonnet::logthis("Unsupported type handler");  
     $result.=&unsupported($currentURL,$helper->{'VARS'}->{'LATEX_TYPE'},      $result.=&unsupported($currentURL,$helper->{'VARS'}->{'LATEX_TYPE'},
   $helper->{'VARS'}->{'symb'});    $helper->{'VARS'}->{'symb'});
  }   }
Line 2199  ENDPART Line 2215  ENDPART
     $result.="\\newpage\n";      $result.="\\newpage\n";
  }   }
     }      }
     my ($sequence,$middle_thingy,$urlp)=&Apache::lonnet::decode_symb($master_seq[$i]);      my ($sequence,$middle_thingy,$urlp)=&Apache::lonnet::decode_symb($master_seq[$i]);
     $urlp=&Apache::lonnet::clutter($urlp);      $urlp=&Apache::lonnet::clutter($urlp);
     $form{'symb'}=$master_seq[$i];      $form{'symb'}=$master_seq[$i];
   
Line 2212  ENDPART Line 2228  ENDPART
  && $urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) {   && $urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) {
  $resources_printed .= $urlp.':';   $resources_printed .= $urlp.':';
  &Apache::lonxml::remember_problem_counter();   &Apache::lonxml::remember_problem_counter();
    if ($flag_latex_header_remove eq 'NO') {
       $texversion.=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});  # RF
       $flag_latex_header_remove = 'YES';
    }
  $texversion.=&ssi_with_retries($urlp, $ssi_retry_count, %form);   $texversion.=&ssi_with_retries($urlp, $ssi_retry_count, %form);
  if ($urlp=~/\.page$/) {   if ($urlp=~/\.page$/) {
     ($texversion,my $number_of_columns_page) = &page_cleanup($texversion);      ($texversion,my $number_of_columns_page) = &page_cleanup($texversion);
Line 2286  ENDPART Line 2305  ENDPART
  $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};   $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
  if ($urlp=~/\/syllabus$/) {$urlp=~s/\/res//;}   if ($urlp=~/\/syllabus$/) {$urlp=~s/\/res//;}
  $resources_printed .= $urlp.':';   $resources_printed .= $urlp.':';
  my $texversion=&ssi_with_retries($urlp, $ssi_retry_count, %form);   my $texversion = &ssi_with_retries($urlp, $ssi_retry_count, %form);
  if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') {   if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') {
     my $annotation = &annotate($urlp);      my $annotation = &annotate($urlp);
     $texversion =~ s/(\\end{document)/$annotation$1/;      $texversion =~ s/(\\end{document)/$annotation$1/;
Line 2790  sub print_resources { Line 2809  sub print_resources {
     #   so we will just rely on prntout.pl to strip  ENDOFSTUDENTSTAMP from the      #   so we will just rely on prntout.pl to strip  ENDOFSTUDENTSTAMP from the
     #   postscript.  Each ENDOFSTUDENTSTAMP will go on a line by itself.      #   postscript.  Each ENDOFSTUDENTSTAMP will go on a line by itself.
     #      #
       my $syllabus_first = 0;
     foreach my $curresline (@{$master_seq})  {      foreach my $curresline (@{$master_seq})  {
  if (defined $page_breaks{$curresline}) {   if (defined $page_breaks{$curresline}) {
     if($i != 0) {      if($i != 0) {
Line 2849  sub print_resources { Line 2868  sub print_resources {
     }      }
     $current_output .= $rendered;          $current_output .= $rendered;    
  } elsif ($res_url=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) {   } elsif ($res_url=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) {
       if ($i == 1) {
    $syllabus_first = 1;
       }
     $printed .= $curresline.':';      $printed .= $curresline.':';
     my $rendered = &get_student_view_with_retries($curresline,$ssi_retry_count,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv);      my $rendered = &get_student_view_with_retries($curresline,$ssi_retry_count,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv);
     if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') {      if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') {
Line 2893  sub print_resources { Line 2915  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/ && (!$syllabus_first)) {
  $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 /;
       } elsif ($syllabus_first) {
   
    $current_output =~ s/\\\\ Last updated:/Last updated:/
     } else {      } else {
  my $blankpages =    my $blankpages = 
     '\clearpage\strut\clearpage'x$helper->{'VARS'}->{'EMPTY_PAGES'};      '\clearpage\strut\clearpage'x$helper->{'VARS'}->{'EMPTY_PAGES'};
Line 2917  sub handler { Line 2942  sub handler {
           
     &init_perm();      &init_perm();
   
       my ($helper,$is_custom);
       if ((&Apache::loncommon::needs_gci_custom()) &&
           ($env{'request.role.domain'} eq 'gcitest')) {
           if ($r->header_only) {
               if ($env{'browser.mathml'}) {
                   &Apache::loncommon::content_type($r,'text/xml');
               } else {
                   &Apache::loncommon::content_type($r,'text/html');
               }
               $r->send_http_header;
               return OK;
           }
           # Send header, nocache
           if ($env{'browser.mathml'}) {
               &Apache::loncommon::content_type($r,'text/xml');
           } else {
               &Apache::loncommon::content_type($r,'text/html');
           }
           &Apache::loncommon::no_cache($r);
           $r->send_http_header;
           $r->rflush();
   
           my ($navmap_error,$resources,@master_seq);
     my $helper = printHelper($r);          my $navmap = Apache::lonnavmaps::navmap->new();
     if (!ref($helper)) {          if (!defined($navmap)) {
  return $helper;              my $brcrum = [{'href' => '',
                              'text' => 'Preparing Printout'}];
   
               my $start_page  =
                   &Apache::loncommon::start_page('Preparing Printout','',
                                                  {'bread_crumbs' => $brcrum,});
               my $endpage = &Apache::loncommon::end_page();
   
               my $navmap_error = '<span class="LC_error">'.&mt('An error occurred retrieving information about the course.').'<br />'.&mt('It is recommended that you re-select the concept test by clicking on the "Review Questions" tab and then clicking on the "Manage Tests" tab again.').'</span>';
               $r->print($start_page.$navmap_error.$endpage);
               return OK;
           } else {
               my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
               my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
               my @allres=$navmap->retrieveResources('/uploaded/'.$cdom.'/'.$cnum.'/default_1261144274.sequence');
               foreach my $resource (@allres) {
                   next if ($resource->is_map());
                   my $symb = $resource->symb();
                   push(@master_seq,$symb);
               }
               $resources = join('|||',@master_seq);
               my ($sequence,$middle_thingy,$urlp) =
                   &Apache::lonnet::decode_symb($master_seq[0]);
   
               my $assignment = &Apache::lonxml::latex_special_symbols(&Apache::lonnet::gettitle($sequence),'header');
   
               $helper = {
                      VARS => {
                               ANON_CODE_STORAGE_NAME => '',
                               ANSWER_TYPE => 'yes',
                               CODE_OPTION => '',
                               EMPTY_PAGES => '',
                               FINISHPAGE => '',
                               FORMAT => 'P|1|letter|no',
                               LATEX_TYPE => 'batchmode',
                               NUMBER_TO_PRINT_TOTAL => '',
                               PRINT_ANNOTATIONS => 'no',
                               PRINT_DISCUSSIONS => 'no',
                               PRINT_TYPE => 'map_problems',
                               RESOURCES => $resources,
                               REUSE_OLD_CODES => '',
                               SEQUENCE => '',
                               SINGLE_CODE => '',
                               SPLIT_PDFS => '',
                               STUDENTS => '',
                               TABLE_CONTENTS => 'no',
                               TABLE_INDEX => 'no',
                               assignment => $assignment,
                               construction => '',
                               curseed => '',
                               filename => '',
                               fontsize => 'normalsize',
                               pagesize => '',
                               'pagesize.height' => '9.8',
                               'pagesize.heightunit' => 'in',
                               'pagesize.lmargin' => '-0.57',
                               'pagesize.lmarginunit' => 'in',
                               'pagesize.width' => '7.1',
                               'pagesize.widthunit' => 'in',
                               postdata => $urlp,
                               probstatus => '',
                               showallfoils => '',
                               student_sort => '',
                               style_file => '',
                               symb => $master_seq[0],
                              }
                            };
               $env{'form.assignment'} = $assignment;
               $is_custom = 1;
           }
       } else {
           $helper = printHelper($r);
           if (!ref($helper)) {
               return $helper;
           }
     }      }
      
   
     %parmhash=&Apache::lonnet::coursedescription($env{'request.course.id'});      %parmhash=&Apache::lonnet::coursedescription($env{'request.course.id'});
    
   
   
   
     #  If a figure conversion queue file exists for this user.domain      #  If a figure conversion queue file exists for this user.domain
Line 2936  sub handler { Line 3053  sub handler {
   
     my $conversion_queuefile = "/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.dat";      my $conversion_queuefile = "/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.dat";
     if(-e $conversion_queuefile) {      if(-e $conversion_queuefile) {
  unlink $conversion_queuefile;          unlink $conversion_queuefile;
     }      }
       
   
     &output_data($r,$helper,\%parmhash);  
       &output_data($r,$helper,\%parmhash,$is_custom);
     return OK;      return OK;
 }   }
   
 use Apache::lonhelper;  use Apache::lonhelper;
   
Line 3360  ALL_PROBLEMS Line 3477  ALL_PROBLEMS
   'multichoice="1" addstatus="1" closeallpages="1"',    'multichoice="1" addstatus="1" closeallpages="1"',
   'RESOURCES',     'RESOURCES', 
   'PRINT_FORMATTING',    'PRINT_FORMATTING',
   '',    $map,
   $isProblem, '', $symbFilter,    $isProblem, '', $symbFilter,
   $start_new_option);    $start_new_option);
  $resource_selector .=  <<RESOURCE_SELECTOR;   $resource_selector .=  <<RESOURCE_SELECTOR;

Removed from v.1.563  
changed lines
  Added in v.1.568.4.2


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