Diff for /loncom/interface/lonprintout.pm between versions 1.536.2.3 and 1.537

version 1.536.2.3, 2008/10/02 17:40:34 version 1.537, 2008/08/25 10:16:27
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) = @_;      my ($width, $format, $assignment, $course, $student, $section) = @_;
   
           
     $width = &recalcto_mm($width); # Get width in mm.      $width = &recalcto_mm($width); # Get width in mm.
     #  Default format?      #  Default format?
Line 248  sub format_page_header { Line 250  sub format_page_header {
  # - 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 $chars_per_line = $width/2; # Character/textline.
   
   
   
  my $firstline = "$student $course";   my $name_length    = int($chars_per_line *3 /4);
  if (length($firstline) > $chars_per_line) {   my $sec_length     = int($chars_per_line / 5);
     my $lastchar = $chars_per_line - length($student) - 1;  
     if ($lastchar > 0) {   $format  = "%$name_length".'n';
  $course = substr($course, 0, $lastchar);  
     } else { # Nothing left of course:   if ($section) {
  $course = '';      $format .=  ' - Sec: '."%$sec_length".'s';
     }  
  }  
  if (length($assignment) > $chars_per_line) {  
     $assignment = substr($assignment, 0, $chars_per_line);  
  }   }
   
  $format =  "\\textbf{$student} $course \\hfill \\thepage \\\\ \\textit{$assignment}";  
   
     } else {  
  # 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);  
   
  # 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!!!  
   
    $format .= '\\\\%c \\\\ %a';
           
   
     }      }
       # 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!!!
       
           
   
     return $format;      return $format;
Line 385  sub is_valid_alpha_code { Line 385  sub is_valid_alpha_code {
 sub is_code_valid {  sub is_code_valid {
     my ($code_value, $code_option) = @_;      my ($code_value, $code_option) = @_;
     my ($code_type, $code_length) = ('letter', 6); # defaults.      my ($code_type, $code_length) = ('letter', 6); # defaults.
     my @lines = &Apache::grades::get_scantronformat_file();      open(FG, $Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab');
     foreach my $line (@lines) {      foreach my $line (<FG>) {
  my ($name, $type, $length) = (split(/:/, $line))[0,2,4];   my ($name, $type, $length) = (split(/:/, $line))[0,2,4];
  if($name eq $code_option) {   if($name eq $code_option) {
     $code_length = $length;      $code_length = $length;
Line 978  sub get_course { Line 978  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 1000  sub page_format_transformation { Line 1002  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 1152  sub print_latex_header { Line 1153  sub print_latex_header {
      '\usepackage{wrapfig}'.       '\usepackage{wrapfig}'.
      '\usepackage{picins}\usepackage{calc}'."\n".       '\usepackage{picins}\usepackage{calc}'."\n".
      '\usepackage[T1]{fontenc}'."\n".       '\usepackage[T1]{fontenc}'."\n".
              '\usepackage{lmodern}'."\n".  
      '\usepackage[postscript]{ucs}'."\n".       '\usepackage[postscript]{ucs}'."\n".
      '\usepackage[utf8x]{inputenc}'."\n".       '\usepackage[utf8x]{inputenc}'."\n".
      '\usepackage{pifont}'  . "\n".       '\usepackage{pifont}'  . "\n".
Line 1780  ENDPART Line 1780  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 1935  ENDPART Line 1934  ENDPART
  my $selected_code = $helper->{'VARS'}->{'CODE_SELECTED_FROM_LIST'};   my $selected_code = $helper->{'VARS'}->{'CODE_SELECTED_FROM_LIST'};
   
  my $code_option=$helper->{'VARS'}->{'CODE_OPTION'};   my $code_option=$helper->{'VARS'}->{'CODE_OPTION'};
          my @lines = &Apache::grades::get_scantronformat_file();   open(FH,$Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab');
  my ($code_type,$code_length)=('letter',6);   my ($code_type,$code_length)=('letter',6);
  foreach my $line (@lines) {   foreach my $line (<FH>) {
      my ($name,$type,$length) = (split(/:/,$line))[0,2,4];       my ($name,$type,$length) = (split(/:/,$line))[0,2,4];
      if ($name eq $code_option) {       if ($name eq $code_option) {
  $code_length=$length;   $code_length=$length;
Line 2365  sub print_resources { Line 2364  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);      $currentassignment, $courseidinfo, $fullname, $usersection);
     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.'}';
Line 2642  sub printHelper { Line 2639  sub printHelper {
     }      }
   
     # Useful filter strings      # Useful filter strings
     my $isProblem = '($res->is_problem()||$res->contains_problem||$res->is_practice()) ';      my $isProblem = '($res->is_problem()||$res->contains_problem) ';
     $isProblem .= ' && !$res->randomout()' if !$userCanSeeHidden;      $isProblem .= ' && !$res->randomout()' if !$userCanSeeHidden;
     my $isProblemOrMap = '$res->is_problem() || $res->contains_problem() || $res->is_sequence() || $res->is_practice()';      my $isProblemOrMap = '$res->is_problem() || $res->contains_problem() || $res->is_sequence()';
     my $isNotMap = '!$res->is_sequence()';      my $isNotMap = '!$res->is_sequence()';
     $isNotMap .= ' && !$res->randomout()' if !$userCanSeeHidden;      $isNotMap .= ' && !$res->randomout()' if !$userCanSeeHidden;
     my $isMap = '$res->is_map()';      my $isMap = '$res->is_map()';
Line 2855  CHOOSE_STUDENTS Line 2852  CHOOSE_STUDENTS
   
  }   }
   
         my @lines = &Apache::grades::get_scantronformat_file();  
    open(FH,$Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab');
  my $codechoice='';   my $codechoice='';
  foreach my $line (@lines) {   foreach my $line (<FH>) {
     my ($name,$description,$code_type,$code_length)=      my ($name,$description,$code_type,$code_length)=
  (split(/:/,$line))[0,1,2,4];   (split(/:/,$line))[0,1,2,4];
     if ($code_length > 0 &&       if ($code_length > 0 && 

Removed from v.1.536.2.3  
changed lines
  Added in v.1.537


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