Diff for /loncom/interface/lonprintout.pm between versions 1.545.2.2 and 1.545.2.3

version 1.545.2.2, 2008/12/21 16:29:56 version 1.545.2.3, 2008/12/22 22:28:18
Line 229  sub printf_style_subst { Line 229  sub printf_style_subst {
 #     %a    - Assignment name.  #     %a    - Assignment name.
 #     %c    - Course name.  #     %c    - Course name.
 #     %n    - Student name.  #     %n    - Student name.
 #     %s    - The section if it is supplied.  
 #  #
 sub format_page_header {  sub format_page_header {
     my ($width, $format, $assignment, $course, $student, $section) = @_;      my ($width, $format, $assignment, $course, $student) = @_;
   
           
     $width = &recalcto_mm($width); # Get width in mm.      $width = &recalcto_mm($width); # Get width in mm.
     #  Default format?      #  Default format?
Line 251  sub format_page_header { Line 249  sub format_page_header {
  #   #
  my $chars_per_line = $width/2; # Character/textline.   my $chars_per_line = $width/2; # Character/textline.
   
           my $firstline = "$student $course";
           if (length($firstline) > $chars_per_line) {
               my $lastchar = $chars_per_line - length($student) - 1;
               if ($lastchar > 0) {
                   $course = substr($course, 0, $lastchar);
               } else {            # Nothing left of course:
                   $course = '';
               }
           }
           if (length($assignment) > $chars_per_line) {
               $assignment = substr($assignment, 0, $chars_per_line);
           }
   
           $format =  "\\textbf{$student} $course \\hfill \\thepage \\\\ \\textit{$assignment}";
   
  my $name_length    = int($chars_per_line *3 /4);      } else {
  my $sec_length     = int($chars_per_line / 5);          # An open question is how to handle long user formatted page headers...
           # A possible future is to support e.g. %na so that the user can control
  $format  = "%$name_length".'n';          # the truncation of the elements that can appear in the header.
           #
  if ($section) {          $format =  &printf_style_subst("a", $format, $assignment);
     $format .=  ' - Sec: '."%$sec_length".'s';          $format =  &printf_style_subst("c", $format, $course);
  }          $format =  &printf_style_subst("n", $format, $student);
   
  $format .= '\\\\%c \\\\ %a';          # If the user put %'s in the format string, they  must be escaped
                   # to \% else LaTeX will think they are comments and terminate
           # the line.. which is bad!!!
     }      }
     # An open question is how to handle long user formatted page headers...  
     # A possible future is to support e.g. %na so that the user can control  
     # the truncation of the elements that can appear in the header.  
     #  
     $format =  &printf_style_subst("a", $format, $assignment);  
     $format =  &printf_style_subst("c", $format, $course);  
     $format =  &printf_style_subst("n", $format, $student);  
     $format =  &printf_style_subst("s", $format, $section);  
       
       
     # If the user put %'s in the format string, they  must be escaped  
     # to \% else LaTeX will think they are comments and terminate  
     # the line.. which is bad!!!  
           
     # If the user has role author, $course and $assignment are empty so      # If the user has role author, $course and $assignment are empty so
     # there is '\\ \\ ' in the page header. That's cause a error in LaTeX      # there is '\\ \\ ' in the page header. That's cause a error in LaTeX
Line 985  sub get_course { Line 983  sub get_course {
     my $courseidinfo;      my $courseidinfo;
     if (defined($env{'request.course.id'})) {      if (defined($env{'request.course.id'})) {
  $courseidinfo = &Apache::lonxml::latex_special_symbols(&unescape($env{'course.'.$env{'request.course.id'}.'.description'}),'header');   $courseidinfo = &Apache::lonxml::latex_special_symbols(&unescape($env{'course.'.$env{'request.course.id'}.'.description'}),'header');
  my $sec = $env{'request.course.sec'};  
       
     }      }
     return $courseidinfo;      return $courseidinfo;
 }  }
Line 1009  sub page_format_transformation { Line 1005  sub page_format_transformation {
   
     my $name = &get_name();      my $name = &get_name();
     my $courseidinfo = &get_course();      my $courseidinfo = &get_course();
       if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }
     my $header_text  = $parmhash{'print_header_format'};      my $header_text  = $parmhash{'print_header_format'};
     $header_text     = &format_page_header($textwidth, $header_text, $assignment,      $header_text     = &format_page_header($textwidth, $header_text, $assignment,
    $courseidinfo, $name);     $courseidinfo, $name);
Line 1811  ENDPART Line 1808  ENDPART
  if (($selectionmade == 4) and ($assignment ne $prevassignment)) {   if (($selectionmade == 4) and ($assignment ne $prevassignment)) {
     my $name = &get_name();      my $name = &get_name();
     my $courseidinfo = &get_course();      my $courseidinfo = &get_course();
       if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }
     $prevassignment=$assignment;      $prevassignment=$assignment;
     my $header_text = $parmhash{'print_header_format'};      my $header_text = $parmhash{'print_header_format'};
     $header_text    = &format_page_header($textwidth, $header_text,      $header_text    = &format_page_header($textwidth, $header_text,
Line 2395  sub print_resources { Line 2393  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();
       if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }
       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 $header_line =      my $header_line =
  &format_page_header($LaTeXwidth, $parmhash{'print_header_format'},   &format_page_header($LaTeXwidth, $parmhash{'print_header_format'},
     $currentassignment, $courseidinfo, $fullname, $usersection);      $currentassignment, $courseidinfo, $fullname);
     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.'}';

Removed from v.1.545.2.2  
changed lines
  Added in v.1.545.2.3


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