Diff for /loncom/interface/lonprintout.pm between versions 1.626 and 1.627.2.16

version 1.626, 2012/12/10 01:09:06 version 1.627.2.16, 2016/08/06 20:52:43
Line 27 Line 27
 #  #
 package Apache::lonprintout;  package Apache::lonprintout;
 use strict;  use strict;
 use POSIX;  
 use Apache::Constants qw(:common :http);  use Apache::Constants qw(:common :http);
 use Apache::lonxml;  use Apache::lonxml;
 use Apache::lonnet;  use Apache::lonnet;
Line 47  use File::Basename; Line 46  use File::Basename;
   
 use HTTP::Response;  use HTTP::Response;
 use LONCAPA::map();  use LONCAPA::map();
 use POSIX qw(ctime);  
 use Apache::lonlocal;  use Apache::lonlocal;
 use Carp;  use Carp;
 use LONCAPA;  use LONCAPA;
Line 149  sub printable_sequence { Line 147  sub printable_sequence {
 # Return:  # Return:
 #     XML that can be parsed by the helper to drive the state machine.  #     XML that can be parsed by the helper to drive the state machine.
 #  #
 sub create_incomplete_folder_selstud_helper($helper)  sub create_incomplete_folder_selstud_helper {
 {  
     my ($helper, $map)  = @_;      my ($helper, $map)  = @_;
   
   
Line 495  RESOURCE_SELECTOR Line 492  RESOURCE_SELECTOR
 #  #
 # @return ($open, $close)   # @return ($open, $close) 
 #  #
 # @note If open/close dates are not defined they will be retunred as undef  # @note If open/close dates are not defined they will be returned as undef
 # @note It is possible for there to be no overlap in which case -1,-1   # @note It is possible for there to be no overlap in which case -1,-1 
 #       will be returned.  #       will be returned.
 # @note The algorithm used is to take the latest open date and the earliest end date.  # @note The algorithm used is to take the latest open date and the earliest end date.
Line 525  sub compute_open_window { Line 522  sub compute_open_window {
   
     # If no overlap...both are -1 as promised.      # If no overlap...both are -1 as promised.
   
     if (defined($earliest_close) && defined($latest_open)      if (($earliest_close ne '') && ($latest_open ne '')
  && ($earliest_close < $latest_open)) {   && ($earliest_close < $latest_open)) {
  $latest_open  = -1;   $latest_open  = -1;
  $earliest_close = -1;   $earliest_close = -1;
Line 573  sub printable { Line 570  sub printable {
 #  #
 # @return (opendate, closedate)  # @return (opendate, closedate)
 #  #
 # @note If open/close dates are not defined they will be retunred as undef  # @note If open/close dates are not defined they will be returned as undef
 # @note It is possible for there to be no overlap in which case -1,-1   # @note It is possible for there to be no overlap in which case -1,-1 
 #       will be returned.  #       will be returned.
 # @note The algorithm used is to take the latest open date and the earliest end date.  # @note The algorithm used is to take the latest open date and the earliest end date.
 #  #       For consistency with &printable() in lonnavmaps.pm determination of start
   #       date for printing checks printstartdate param first, then, if not set,
   #       opendate param, then, if not set, contentopen param.
   
   
 sub get_print_dates {  sub get_print_dates {
     my $res = shift;      my $res = shift;
Line 596  sub get_print_dates { Line 596  sub get_print_dates {
  foreach my $part (@parts) {   foreach my $part (@parts) {
     my $partopen  = $res->parmval('printstartdate', $part);      my $partopen  = $res->parmval('printstartdate', $part);
     my $partclose = $res->parmval('printenddate',  $part);      my $partclose = $res->parmval('printenddate',  $part);
               if (!$partopen) {
                   $partopen = $res->parmval('opendate',$part);
               }
               if (!$partopen) {
                   $partopen = $res->parmval('contentopen',$part);
               }
               if ($partopen) {
                   push(@open_dates, $partopen);
               }
               if ($partclose) {
                   push(@close_dates, $partclose);
               }
     push(@open_dates, $partopen);      push(@open_dates, $partopen);
     push(@close_dates, $partclose);      push(@close_dates, $partclose);
  }   }
Line 604  sub get_print_dates { Line 615  sub get_print_dates {
   
     ($open_date, $close_date)  = &compute_open_window(\@open_dates, \@close_dates);      ($open_date, $close_date)  = &compute_open_window(\@open_dates, \@close_dates);
   
     if ($open_date) {  
  $open_date  = POSIX::strftime('%D', localtime($open_date));  
     }  
     if ($close_date) {  
  $close_date = POSIX::strftime('%D', localtime($close_date));  
     }  
   
     return ($open_date, $close_date);      return ($open_date, $close_date);
 }  }
   
Line 697  sub incomplete { Line 701  sub incomplete {
     }      }
 }  }
 #  #
 #  When printing for students, the resoures and order of the  #  When printing for students, the resources and order of the
 #  resources may need to be altered if there are folders with  #  resources may need to be altered if there are folders with
 #  random selectiopn or random ordering (or both) enabled.  #  random selectiopn or random ordering (or both) enabled.
 #  This sub computes the set of resources to print for a student  #  This sub computes the set of resources to print for a student
 #  modified both by random ordering and selection and filtered  #  modified both by random ordering and selection and filtered
 #  to only those that are in the original set selcted to be printed.  #  to only those that are in the original set selected to be printed.
 #  #
 # Parameters:  # Parameters:
 #   $map - The URL of the folder being printed.  #   $map - The URL of the folder being printed.
Line 713  sub incomplete { Line 717  sub incomplete {
 #   $who   - Student/domain for whome the sequence will be generated.  #   $who   - Student/domain for whome the sequence will be generated.
 #   $code  - CODE being printed when printing Problems/Resources  #   $code  - CODE being printed when printing Problems/Resources
 #            from folder for CODEd assignments  #            from folder for CODEd assignments
   #   $nohidemap - If true, parameter in map for hiddenresource will be
   #                ignored.  The user calling the routine should have
   #                both the pav and vgr privileges if this is set to true).
 #  #
 # Implicit inputs:  # Implicit inputs:
 #   $  #   $
Line 721  sub incomplete { Line 728  sub incomplete {
 #   print_resources.  #   print_resources.
 #   # 
 sub master_seq_to_person_seq {  sub master_seq_to_person_seq {
     my ($map, $seq, $who, $code) = @_;      my ($map, $seq, $who, $code, $nohidemap) = @_;
   
   
     my ($username, $userdomain, $usersection) = split(/:/, $who);      my ($username, $userdomain, $usersection) = split(/:/, $who);
Line 732  sub master_seq_to_person_seq { Line 739  sub master_seq_to_person_seq {
   
     my %seq_hash = map {$_  => 1} @$seq;      my %seq_hash = map {$_  => 1} @$seq;
     my @output_seq;      my @output_seq;
   
       my $unhidden;
       if ($nohidemap) {
           $unhidden = &Apache::lonnet::clutter($map);
       }
           
     my $navmap           = Apache::lonnavmaps::navmap->new($username, $userdomain,      my $navmap           = Apache::lonnavmaps::navmap->new($username, $userdomain,
                                                            $code);                                                             $code,$unhidden);
     my ($start,$finish);      my ($start,$finish);
   
     if ($map) {      if ($map) {
Line 754  sub master_seq_to_person_seq { Line 766  sub master_seq_to_person_seq {
     #  Iterate on the resource..select the items that are randomly selected      #  Iterate on the resource..select the items that are randomly selected
     #  and that are in the seq_has.  Presumably the iterator will take care      #  and that are in the seq_has.  Presumably the iterator will take care
     # of the random ordering part of the deal.      # of the random ordering part of the deal.
     #  
     my $curres;      my $curres;
     while ($curres = $iterator->next()) {      while ($curres = $iterator->next()) {
  #   #
Line 1048  sub printf_style_subst { Line 1059  sub printf_style_subst {
 #     %s    - The section if it is supplied.  #     %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.
     my $chars_per_line = int($width/1.6);   # Character/textline.      my $chars_per_line = int($width/2);   # Character/textline.
   
     #  Default format?      #  Default format?
   
Line 1069  sub format_page_header { Line 1080  sub format_page_header {
  # - Allow the assignment to be 2 lines (wrapped).   # - Allow the assignment to be 2 lines (wrapped).
  #   #
   
           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);
           }
   
  my $name_length    = int($chars_per_line *3 /4);          $format =  "\\textbf{$student} $course \\hfill \\thepage \\\\ \\textit{$assignment}";
  my $sec_length     = int($chars_per_line / 5);  
   
  $format  = "%$name_length".'n';      } 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!!!
   
  if ($section) {      }
     $format .=  ' - Sec: '."%$sec_length".'s';  
  }  
   
  $format .= '\\\\%c \\\\ %a';      return $format;
           
   
     }  
     # 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
     if($format =~ /\\\\\s\\\\\s/) {      if($format =~ /\\\\\s\\\\\s/) {
         #TODO find sensible caption for page header          #TODO find sensible caption for page header
         my $testPrintout = '\\\\'.&mt('Construction Space').' \\\\'.&mt('Test-Printout ');          my $testPrintout = '\\\\'.&mt('Authoring Space').' \\\\'.&mt('Test-Printout ');
         $format =~ s/\\\\\s\\\\\s/$testPrintout/;          $format =~ s/\\\\\s\\\\\s/$testPrintout/;
     }      }
     #      #
Line 1224  sub is_code_valid { Line 1239  sub is_code_valid {
     my ($code_type, $code_length) = ('letter', 6); # defaults.      my ($code_type, $code_length) = ('letter', 6); # defaults.
     my @lines = &Apache::grades::get_scantronformat_file();      my @lines = &Apache::grades::get_scantronformat_file();
     foreach my $line (@lines) {      foreach my $line (@lines) {
           next if (($line =~ /^\#/) || ($line eq ''));
  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 1832  sub get_course { Line 1848  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 1856  sub page_format_transformation { Line 1870  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 2162  sub print_page_in_course { Line 2177  sub print_page_in_course {
   
     $form{'grade_target'}  = 'tex';      $form{'grade_target'}  = 'tex';
     $form{'textwidth'}    = &get_textwidth($helper, $LaTeXwidth);      $form{'textwidth'}    = &get_textwidth($helper, $LaTeXwidth);
     $form{'pdfFormFields'} = $pdfFormFields; #       $form{'pdfFormFields'} = 'no'; # 
     $form{'showallfoils'} = $helper->{'VARS'}->{'showallfoils'};          $form{'showallfoils'} = $helper->{'VARS'}->{'showallfoils'};    
           
     $form{'problem_split'}=$parmhash{'problem_stream_switch'};      $form{'problem_split'}=$parmhash{'problem_stream_switch'};
Line 2215  sub print_page_in_course { Line 2230  sub print_page_in_course {
  $texversion.=&path_to_problem($urlp,$LaTeXwidth);   $texversion.=&path_to_problem($urlp,$LaTeXwidth);
     } else {      } else {
  $texversion.='\vskip 0 mm \noindent\textbf{'.   $texversion.='\vskip 0 mm \noindent\textbf{'.
                         &mt("Printing from Construction Space: No Title").'}\vskip 0 mm ';                          &mt("Printing from Authoring Space: No Title").'}\vskip 0 mm ';
  $texversion.=&path_to_problem($urlp,$LaTeXwidth);   $texversion.=&path_to_problem($urlp,$LaTeXwidth);
     }      }
     $texversion.='\vskip 1 mm '.$answer.'\end{document}';      $texversion.='\vskip 1 mm '.$answer.'\end{document}';
Line 2698  ENDPART Line 2713  ENDPART
     my %form;      my %form;
     $form{'grade_target'} = 'tex';      $form{'grade_target'} = 'tex';
     $form{'textwidth'}    = &get_textwidth($helper, $LaTeXwidth);      $form{'textwidth'}    = &get_textwidth($helper, $LaTeXwidth);
     $form{'pdfFormFields'} = $pdfFormFields;      $form{'pdfFormFields'} = 'no';
   
     # If form.showallfoils is set, then request all foils be shown:      # If form.showallfoils is set, then request all foils be shown:
     # privilege will be enforced both by not allowing the       # privilege will be enforced both by not allowing the 
Line 2796  ENDPART Line 2811  ENDPART
  $texversion.=&path_to_problem($cleanURL,$LaTeXwidth);   $texversion.=&path_to_problem($cleanURL,$LaTeXwidth);
     } else {      } else {
  $texversion.='\vskip 0 mm \noindent\textbf{'.   $texversion.='\vskip 0 mm \noindent\textbf{'.
                         &mt("Printing from Construction Space: No Title").'}\vskip 0 mm ';                          &mt("Printing from Authoring Space: No Title").'}\vskip 0 mm ';
   
  $texversion.=&path_to_problem($cleanURL,$LaTeXwidth);   $texversion.=&path_to_problem($cleanURL,$LaTeXwidth);
     }      }
Line 2921  ENDPART Line 2936  ENDPART
   
  &Apache::lonxml::clear_problem_counter();   &Apache::lonxml::clear_problem_counter();
   
  my $pbreakresources = keys %page_breaks;  
  for (my $i=0;$i<=$#master_seq;$i++) {   for (my $i=0;$i<=$#master_seq;$i++) {
   
     &Apache::lonenc::reset_enc();      &Apache::lonenc::reset_enc();
Line 3022  ENDPART Line 3036  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 3172  ENDPART Line 3187  ENDPART
  my $student_counter=-1;   my $student_counter=-1;
  my $i = 0;   my $i = 0;
  my $last_section = (split(/:/,$students[0]))[2];   my $last_section = (split(/:/,$students[0]))[2];
            my $nohidemap;
            if ($perm{'pav'} && $perm{'vgr'}) {
                $nohidemap = 1;
            }
  foreach my $person (@students) {   foreach my $person (@students) {
              my $duefile="/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.due";               my $duefile="/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.due";
      if (-e $duefile) {       if (-e $duefile) {
Line 3189  ENDPART Line 3208  ENDPART
  $i=int($student_counter/$helper->{'VARS'}{'NUMBER_TO_PRINT'});   $i=int($student_counter/$helper->{'VARS'}{'NUMBER_TO_PRINT'});
      }       }
      my $actual_seq = master_seq_to_person_seq($map, \@master_seq,       my $actual_seq = master_seq_to_person_seq($map, \@master_seq,
                                                        $person);                                                         $person, undef, $nohidemap);
      my ($output,$fullname, $printed)=&print_resources($r,$helper,       my ($output,$fullname, $printed)=&print_resources($r,$helper,
      $person,$type,       $person,$type,
      \%moreenv,  $actual_seq,       \%moreenv,  $actual_seq,
Line 3277  ENDPART Line 3296  ENDPART
  $moreenv{'CODE'}=&get_CODE(\%allcodes,$i,$seed,$code_length,   $moreenv{'CODE'}=&get_CODE(\%allcodes,$i,$seed,$code_length,
     $code_type);      $code_type);
      }       }
                $code_name =~ s/^\s+//;
                $code_name =~ s/\s+$//;
      if ($code_name) {       if ($code_name) {
  &Apache::lonnet::put('CODEs',   &Apache::lonnet::put('CODEs',
       {        {
Line 3298  ENDPART Line 3319  ENDPART
  my $flag_latex_header_remove = 'NO';    my $flag_latex_header_remove = 'NO'; 
  my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,$num_todo);   my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,$num_todo);
  my $count=0;   my $count=0;
            my $nohidemap;
            if ($perm{'pav'} && $perm{'vgr'}) {
                $nohidemap = 1; 
            }
  foreach my $code (sort(@allcodes)) {   foreach my $code (sort(@allcodes)) {
      my $file_num=int($count/$number_per_page);       my $file_num=int($count/$number_per_page);
      if ($code_type eq 'number') {        if ($code_type eq 'number') { 
Line 3306  ENDPART Line 3331  ENDPART
  $moreenv{'CODE'}=&num_to_letters($code);   $moreenv{'CODE'}=&num_to_letters($code);
      }       }
              my $actual_seq = \@master_seq;               my $actual_seq = \@master_seq;
              if ($randomorder) {               if ($randomorder || $randompick) {
                  $env{'form.CODE'} = $moreenv{'CODE'};                   $env{'form.CODE'} = $moreenv{'CODE'};
                  $actual_seq = master_seq_to_person_seq($map, \@master_seq,                   $actual_seq = master_seq_to_person_seq($map, \@master_seq,
                                                         undef,                                                          undef,
                                                         $moreenv{'CODE'});                                                          $moreenv{'CODE'}, $nohidemap);
                  delete($env{'form.CODE'});                   delete($env{'form.CODE'});
              }               }
      my ($output,$fullname, $printed)=       my ($output,$fullname, $printed)=
Line 3368  ENDPART Line 3393  ENDPART
     $texversion.=&path_to_problem ($urlp,$LaTeXwidth);      $texversion.=&path_to_problem ($urlp,$LaTeXwidth);
  } else {   } else {
     $texversion.='\vskip 0 mm \noindent\textbf{'.      $texversion.='\vskip 0 mm \noindent\textbf{'.
                                          &mt("Printing from Construction Space: No Title").'}\vskip 0 mm ';                                           &mt("Printing from Authoring Space: No Title").'}\vskip 0 mm ';
     $texversion.=&path_to_problem ($urlp,$LaTeXwidth);      $texversion.=&path_to_problem ($urlp,$LaTeXwidth);
  }   }
  $texversion.='\vskip 1 mm '.$answer.'\end{document}';   $texversion.='\vskip 1 mm '.$answer.'\end{document}';
Line 3419  ENDPART Line 3444  ENDPART
  #}   #}
     }      }
   
     # Set URLback if this is a construction space print so we can provide      # Set URLback so we can provide a link back to the resource and to change options.
     # a link to the resource being edited.      # (Since the browser back button does not currently work with https,
     #      # the back link is useful even when there is an easy-to-miss LON-CAPA back button.)
   
     my $URLback=''; #link to original document      my $URLback=''; #link to original document
     if ($helper->{'VARS'}->{'construction'} eq '1') {      if ($helper->{'VARS'}->{'construction'} eq '1') {
  $URLback=$helper->{'VARS'}->{'filename'};   $URLback=$helper->{'VARS'}->{'filename'};
       } elsif ($helper->{VARS}{'symb'}) {
           my ($map, $id, $url) = &Apache::lonnet::decode_symb($helper->{VARS}{'symb'});
           $URLback = &Apache::lonnet::clutter($url);
     }      }
     #      #
     # Final adjustment of the font size:      # Final adjustment of the font size:
Line 3608  sub print_resources { Line 3636  sub print_resources {
     my $current_assignment = "";      my $current_assignment = "";
     my $assignment;      my $assignment;
     my $courseidinfo = &get_course();      my $courseidinfo = &get_course();
       my $possprint = scalar(@{$master_seq});
       if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }
       if ($usersection ne '') {$courseidinfo.=' - Sec. '.$usersection}
   
     foreach my $curresline (@{$master_seq})  {      foreach my $curresline (@{$master_seq})  {
  if (defined $page_breaks{$curresline}) {   if (defined $page_breaks{$curresline}) {
Line 3627  sub print_resources { Line 3658  sub print_resources {
  next;   next;
     }      }
     $actually_printed++; # we're going to print one.      $actually_printed++; # we're going to print one.
   
     if (&Apache::lonnet::allowed('bre',$res_url)) {      if (&Apache::lonnet::allowed('bre',$res_url)) {
  if ($res_url!~m|^ext/|   if ($res_url!~m|^ext/|
     && $res_url=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) {      && $res_url=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) {
Line 3731  sub print_resources { Line 3763  sub print_resources {
  if (($assignment ne $current_assignment) && ($assignment ne "")) {   if (($assignment ne $current_assignment) && ($assignment ne "")) {
     my $header_line = &format_page_header($LaTeXwidth, $parmhash{'print_header_format'},      my $header_line = &format_page_header($LaTeXwidth, $parmhash{'print_header_format'},
   $assignment, $courseidinfo,     $assignment, $courseidinfo, 
   $fullname, $usersection);    $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.'}';
Line 3748  sub print_resources { Line 3780  sub print_resources {
     #      #
   
     if ($actually_printed == 0) {      if ($actually_printed == 0) {
  $current_output  = &encapsulate_minipage("\\vskip -10mm \nNo incomplete resources\n \\vskip 100 mm { }\n");          my $message = &mt('No resources to print');
           if (!$possprint) {
               if ($perm{'pav'} || $perm{'pfo'}) {
                   $message = &mt('There are no unhidden resources to print.')."\n\n".
                              &mt('The most likely reason is one of the following: ')."\n".
                              '\begin{itemize}'."\n".
                              '\item '.&mt("The 'Resource hidden from students' parameter is set for the folder being printed.")."\n".
                              '\item '.&mt("'Hidden' is checked in the Course Editor individually for each resource in the folder being printed.")."\n".
                              '\end{itemize}'."\n\n".
                              &mt("Note: to print a bubblesheet exam which you want to hide from students, ".
                                  "use the Course Editor to check the 'Hidden' checkbox for the exam folder itself.")."\n";
               }
           } elsif ($print_incomplete) {
               $message = &mt('No incomplete resources');
           }
           if ($message) {
               $current_output  = &encapsulate_minipage("\\vskip -10mm \n$message\n \\vskip 100 mm { }\n");
           }
  if ($remove_latex_header eq "NO") {   if ($remove_latex_header eq "NO") {
     $current_output = &print_latex_header() . $current_output;      $current_output = &print_latex_header() . $current_output;
  } else {   } else {
Line 3759  sub print_resources { Line 3808  sub print_resources {
     if ($syllabus_first) {      if ($syllabus_first) {
         $current_output =~ s/\\\\ Last updated:/Last updated:/          $current_output =~ s/\\\\ Last updated:/Last updated:/
     }      }
     if (0) {      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' : '\fancyhead[LO]';
  my $header_start = ($columns_in_format == 1) ? '\lhead'      my $newheader = $header_start.'{'.$header_line.'}';
     : '\fancyhead[LO]';  
  $header_line = $header_start.'{'.$header_line.'}';  
     }  
     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$namepostfix}\\vskip 5 mm /;  
   
       if ($current_output=~/\\documentclass/) {
    $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent$newheader$namepostfix}\\vskip 5 mm /;
     } else {      } else {
  my $blankpages =    my $blankpages = 
     '\clearpage\strut\clearpage'x$helper->{'VARS'}->{'EMPTY_PAGES'};      '\clearpage\strut\clearpage'x$helper->{'VARS'}->{'EMPTY_PAGES'};
   
 # $current_output = '\strut\vspace*{-6 mm}\\newline'.  
 #    &copyright_line().' \newpage '.$blankpages.$end_of_student.  
 #    '\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent'.  
 #    $header_line.$namepostfix. '} \vskip 5 mm '.$current_output;  
  $current_output = '\strut\vspace*{-6 mm}\\newline'.   $current_output = '\strut\vspace*{-6 mm}\\newline'.
     &copyright_line().' \newpage '.$blankpages.$end_of_student.      &copyright_line().' \newpage '.$blankpages.$end_of_student.
     '\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent'      '\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent'.
     .$namepostfix. '} \vskip 5 mm '.$current_output;      $newheader.$namepostfix. '} \vskip 5 mm '.$current_output;
   
     }      }
     #      #
     #  Close the student bracketing.      #  Close the student bracketing.
Line 4052  sub printHelper { Line 4092  sub printHelper {
  &Apache::lonenc::check_encrypt(&Apache::lonnet::clutter($url));   &Apache::lonenc::check_encrypt(&Apache::lonnet::clutter($url));
     my $navmap = Apache::lonnavmaps::navmap->new();      my $navmap = Apache::lonnavmaps::navmap->new();
     my $res   = $navmap->getBySymb($symb);      my $res   = $navmap->getBySymb($symb);
     $res_printable  = $res->resprintable() | $userCanPrint; #printability in course context      $res_printable  = $res->resprintable() || $userCanPrint; #printability in course context
     ($res_printstartdate, $res_printenddate) = &get_print_dates($res);      ($res_printstartdate, $res_printenddate) = &get_print_dates($res);
     ($course_open, $course_close) = &course_print_dates($res);      ($course_open, $course_close) = &course_print_dates($res);
     ($map_open, $map_close)       = &map_print_dates($res);      ($map_open, $map_close)       = &map_print_dates($res);
Line 4132  sub printHelper { Line 4172  sub printHelper {
     my $start_new_option;      my $start_new_option;
     if ($perm{'pav'}) {      if ($perm{'pav'}) {
  $start_new_option =    $start_new_option = 
     "<option text='".&mt('Start new page<br />before selected').      "<option text='".&mt('Start new page[_1]before selected','<br />').
     "' variable='FINISHPAGE' />".      "' variable='FINISHPAGE' />".
     "<option text='".&mt('Extra space<br />before selected').      "<option text='".&mt('Extra space[_1]before selected','<br />').
     "' variable='EXTRASPACE' type='text' />" .      "' variable='EXTRASPACE' type='text' />" .
     "<option " .      "<option " .
     "' variable='POSSIBLE_RESOURCES' type='hidden' />".      "' variable='POSSIBLE_RESOURCES' type='hidden' />".
     "<option text='".&mt('Space units<br />check for mm').      "<option text='".&mt('Space units[_1]check for mm','<br />').
     "' variable='EXTRASPACE_UNITS' type='checkbox' />"      "' variable='EXTRASPACE_UNITS' type='checkbox' />"
     ;      ;
           
Line 4303  my $suffixXml = <<ALL_PROBLEMS; Line 4343  my $suffixXml = <<ALL_PROBLEMS;
 ALL_PROBLEMS  ALL_PROBLEMS
          &Apache::lonxml::xmlparse($r, 'helper',            &Apache::lonxml::xmlparse($r, 'helper', 
    &generate_resource_chooser('ALL_PROBLEMS',     &generate_resource_chooser('ALL_PROBLEMS',
       'SelectProblem(s) to print',        'Select Problem(s) to print',
       'multichoice="1" suppressEmptySequences="0" addstatus="1" closeallpages="1"',        'multichoice="1" suppressEmptySequences="0" addstatus="1" closeallpages="1"',
       'RESOURCES',        'RESOURCES',
       'PAGESIZE',        'PAGESIZE',
Line 4657  CHOOSE_FROM_ANY_SEQUENCE Line 4697  CHOOSE_FROM_ANY_SEQUENCE
     # Generate the first state, to select which resources get printed.      # Generate the first state, to select which resources get printed.
     Apache::lonhelper::state->new("START", "Select Printing Options:");      Apache::lonhelper::state->new("START", "Select Printing Options:");
     if (!$res_printable) {      if (!$res_printable) {
  $paramHash = Apache::lonhelper::getParamHash();          my $now = time;
  $paramHash->{MESSAGE_TEXT} =           my $shownprintstart = &Apache::lonlocal::locallocaltime($res_printstartdate);
     &mt('<p><b>Printing for current resource is only possible between [_1] and [_1]</b></p>',          my $shownprintend = &Apache::lonlocal::locallocaltime($res_printenddate);
     $res_printstartdate, $res_printenddate);          my $noprintmsg;
  Apache::lonhelper::message->new();          if (($res_printenddate) && ($res_printenddate < $now)) {
                   $noprintmsg = &mt('Printing for current resource no longer available (ended: [_1])',
                                     $shownprintend);
           } else {
               if (($res_printstartdate) && ($res_printstartdate > $now)) {
                   if (($res_printenddate) && ($res_printenddate > $now) && ($res_printenddate > $res_printstartdate)) {
                       $noprintmsg = &mt('Printing for current resource is only possible between [_1] and [_2]',
                                     $shownprintstart,$shownprintend);
                   } elsif (!$res_printenddate) {
                       $noprintmsg = &mt('Printing for current resource will only be possible starting [_1]',
                                         $shownprintstart);
                   } else {
                       $noprintmsg = &mt('Printing for current resource is unavailable');
                   }
               }
           }
   
           if ($noprintmsg) {
               $paramHash = Apache::lonhelper::getParamHash();
               $paramHash->{MESSAGE_TEXT} =
                   '<p class="LC_info">'.$noprintmsg.'</p>';
               Apache::lonhelper::message->new();
           }
     }      }
     $paramHash = Apache::lonhelper::getParamHash();      $paramHash = Apache::lonhelper::getParamHash();
     $paramHash = Apache::lonhelper::getParamHash();      $paramHash = Apache::lonhelper::getParamHash();
Line 5003  sub render { Line 5065  sub render {
     my $PaperType=&mt('Paper type');      my $PaperType=&mt('Paper type');
     my $landscape=&mt('Landscape');      my $landscape=&mt('Landscape');
     my $portrait=&mt('Portrait');      my $portrait=&mt('Portrait');
     my $pdfFormLabel=&mt('PDF-Formfields');  
     my $with=&mt('with Formfields');  
     my $without=&mt('without Formfields');  
           
   
     $result.='<h3>'.&mt('Layout Options').'</h3>'      $result.='<h3>'.&mt('Layout Options').'</h3>'
Line 5014  sub render { Line 5073  sub render {
             .'<th>'.$PageLayout.'</th>'              .'<th>'.$PageLayout.'</th>'
             .'<th>'.$NumberOfColumns.'</th>'              .'<th>'.$NumberOfColumns.'</th>'
             .'<th>'.$PaperType.'</th>'              .'<th>'.$PaperType.'</th>'
             .'<th>'.$pdfFormLabel.'</th>'  
             .&Apache::loncommon::end_data_table_header_row()              .&Apache::loncommon::end_data_table_header_row()
             .&Apache::loncommon::start_data_table_row()              .&Apache::loncommon::start_data_table_row()
     .'<td>'      .'<td>'
Line 5055  sub render { Line 5113  sub render {
     $result .= <<HTML;      $result .= <<HTML;
         </select>          </select>
     </td>      </td>
     <td align='center'>  
         <select name='${var}.pdfFormFields'>  
             <option selected="selected" value="no">$without</option>  
             <option value="yes">$with</option>  
         </select>  
     </td>  
 HTML  HTML
     $result.=&Apache::loncommon::end_data_table_row()      $result.=&Apache::loncommon::end_data_table_row()
             .&Apache::loncommon::end_data_table();              .&Apache::loncommon::end_data_table();

Removed from v.1.626  
changed lines
  Added in v.1.627.2.16


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