Diff for /loncom/interface/lonprintout.pm between versions 1.583.2.6 and 1.584

version 1.583.2.6, 2013/08/27 02:39:24 version 1.584, 2010/09/01 23:58:40
Line 256  CHOOSE_ANON1 Line 256  CHOOSE_ANON1
    return $result;     return $result;
 }  }
   
 #  Returns the XML for choosing how assignments are to be formatted  
 #  that text must still be parsed by the helper xml parser.  
 # Parameters: 3 (required)  
   
 #   helper       - The helper; $helper->{'VARS'}->{'PRINT_TYPE'} used  
 #                  to check if splitting PDFs by section can be offered.  
 #   title        - Title for the current state.  
 #   this_state   - State name of the chooser.  
   
 sub generate_format_selector {  
     my ($helper,$title,$this_state) = @_;  
     my $secpdfoption;  
     unless (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_anon')     ||  
             ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_anon_page') ||  
             ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_anon')  ) {  
         $secpdfoption =  '<choice computer="sections">Each PDF contains exactly one section</choice>';  
     }  
     return <<RESOURCE_SELECTOR;  
     <state name="$this_state" title="$title">  
     <message><br /><big><i><b>How should the results be printed?</b></i></big><br /></message>  
     <choices variable="EMPTY_PAGES">  
       <choice computer='0'>Start each student\'s assignment on a new page/column (add a pagefeed after each assignment)</choice>  
       <choice computer='1'>Add one empty page/column after each student\'s assignment</choice>  
       <choice computer='2'>Add two empty pages/column after each student\'s assignment</choice>  
       <choice computer='3'>Add three empty pages/column after each student\'s assignment</choice>  
     </choices>  
     <nextstate>PAGESIZE</nextstate>  
     <message><hr width='33%' /><b>How do you want assignments split into PDF files? </b></message>  
     <choices variable="SPLIT_PDFS">  
        <choice computer="all">All assignments in a single PDF file</choice>  
        $secpdfoption  
        <choice computer="oneper">Each PDF contains exactly one assignment</choice>  
        <choice computer="usenumber" relatedvalue="NUMBER_TO_PRINT">  
             Specify the number of assignments per PDF:</choice>  
     </choices>  
     </state>  
 RESOURCE_SELECTOR  
 }  
   
   
 #-----------------------------------------------------------------------  #-----------------------------------------------------------------------
   
   
Line 551  sub printf_style_subst { Line 511  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) = @_;      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/2);   # Character/textline.      my $chars_per_line = int($width/1.6);   # Character/textline.
   
     #  Default format?      #  Default format?
   
Line 572  sub format_page_header { Line 532  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);  
         }  
   
         $format =  "\\textbf{$student} $course \\hfill \\thepage \\\\ \\textit{$assignment}";   my $name_length    = int($chars_per_line *3 /4);
    my $sec_length     = int($chars_per_line / 5);
   
     } else {   $format  = "%$name_length".'n';
         # 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   if ($section) {
         # the truncation of the elements that can appear in the header.      $format .=  ' - Sec: '."%$sec_length".'s';
         #   }
         $format =  &printf_style_subst("a", $format, $assignment);  
         $format =  &printf_style_subst("c", $format, $course);   $format .= '\\\\%c \\\\ %a';
         $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!!!  
   
     }      }
       # 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
       # there is '\\ \\ ' in the page header. That's cause a error in LaTeX
       if($format =~ /\\\\\s\\\\\s/) {
           #TODO find sensible caption for page header
           my $testPrintout = '\\\\'.&mt('Construction Space').' \\\\'.&mt('Test-Printout ');
           $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 1298  sub get_course { Line 1279  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 1320  sub page_format_transformation { Line 1303  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 1529  sub unsupported { Line 1511  sub unsupported {
     my $result.= &print_latex_header($mode);      my $result.= &print_latex_header($mode);
     if ($currentURL=~m|^(/adm/wrapper/)?ext/|) {      if ($currentURL=~m|^(/adm/wrapper/)?ext/|) {
  $currentURL=~s|^(/adm/wrapper/)?ext/|http://|;   $currentURL=~s|^(/adm/wrapper/)?ext/|http://|;
         $currentURL=~s|http://https://|https://|;  
  my $title=&Apache::lonnet::gettitle($symb);   my $title=&Apache::lonnet::gettitle($symb);
  $title = &Apache::lonxml::latex_special_symbols($title);   $title = &Apache::lonxml::latex_special_symbols($title);
  $result.=' \strut \\\\ '.$title.' \strut \\\\ '.$currentURL.' ';   $result.=' \strut \\\\ '.$title.' \strut \\\\ '.$currentURL.' ';
Line 1622  sub print_page_in_course { Line 1603  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'} = 'no';      $form{'pdfFormFields'} = $pdfFormFields; # 
     $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 2130  ENDPART Line 2111  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'} = 'no';      $form{'pdfFormFields'} = $pdfFormFields;
   
     # 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 2455  ENDPART Line 2436  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 2694  ENDPART Line 2674  ENDPART
  my ($type) = split(/_/,$helper->{'VARS'}->{'PRINT_TYPE'});   my ($type) = split(/_/,$helper->{'VARS'}->{'PRINT_TYPE'});
  &adjust_number_to_print($helper);   &adjust_number_to_print($helper);
  my $number_per_page=$helper->{'VARS'}->{'NUMBER_TO_PRINT'};   my $number_per_page=$helper->{'VARS'}->{'NUMBER_TO_PRINT'};
  if ($number_per_page eq '0' || $number_per_page eq 'all'   if ($number_per_page eq '0' || $number_per_page eq 'all') {
              || $number_per_page eq 'section') {  
      $number_per_page=$num_todo;       $number_per_page=$num_todo;
  }   }
  my $flag_latex_header_remove = 'NO';    my $flag_latex_header_remove = 'NO'; 
Line 3101  sub print_resources { Line 3080  sub print_resources {
         $current_output =~ s/\\\\ Last updated:/Last updated:/          $current_output =~ s/\\\\ Last updated:/Last updated:/
     }      }
     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 3184  sub init_perm { Line 3161  sub init_perm {
  $perm{'pfo'}=&Apache::lonnet::allowed('pfo',   $perm{'pfo'}=&Apache::lonnet::allowed('pfo',
   $env{'request.course.id'}.'/'.$env{'request.course.sec'});    $env{'request.course.id'}.'/'.$env{'request.course.sec'});
     }      }
     $perm{'vgr'}=&Apache::lonnet::allowed('vgr',$env{'request.course.id'});  
     if (!$perm{'vgr'}) {  
         $perm{'vgr'}=&Apache::lonnet::allowed('vgr',  
                    $env{'request.course.id'}.'/'.$env{'request.course.sec'});  
     }  
 }  }
   
 sub get_randomly_ordered_warning {  sub get_randomly_ordered_warning {
Line 3601  ALL_PROBLEMS Line 3573  ALL_PROBLEMS
   $map,    $map,
   $isProblem, '', $symbFilter,    $isProblem, '', $symbFilter,
   $start_new_option);    $start_new_option);
         $resource_selector .=  &generate_format_selector($helper,   $resource_selector .=  <<RESOURCE_SELECTOR;
                                                          'How should results be printed?',      <state name="PRINT_FORMATTING" title="How should results be printed?">
                                                          'PRINT_FORMATTING').      <message><br /><big><i><b>How should the results be printed?</b></i></big><br /></message>
                                &generate_resource_chooser('CHOOSE_STUDENTS_PAGE',      <choices variable="EMPTY_PAGES">
         <choice computer='0'>Start each student\'s assignment on a new page/column (add a pagefeed after each assignment)</choice>
         <choice computer='1'>Add one empty page/column after each student\'s assignment</choice>
         <choice computer='2'>Add two empty pages/column after each student\'s assignment</choice>
         <choice computer='3'>Add three empty pages/column after each student\'s assignment</choice>
       </choices>
       <nextstate>PAGESIZE</nextstate>
       <message><hr width='33%' /><b>How do you want assignments split into PDF files? </b></message>
       <choices variable="SPLIT_PDFS">
          <choice computer="all">All assignments in a single PDF file</choice>
          <choice computer="sections">Each PDF contains exactly one section</choice>
          <choice computer="oneper">Each PDF contains exactly one assignment</choice>
          <choice computer="usenumber" relatedvalue="NUMBER_TO_PRINT">
               Specify the number of assignments per PDF:</choice>
       </choices>
       </state>
   RESOURCE_SELECTOR
           $resource_selector .= &generate_resource_chooser('CHOOSE_STUDENTS_PAGE',
  'Select Problem(s) to print',   'Select Problem(s) to print',
  "multichoice='1' addstatus='1' closeallpages ='1'",   "multichoice='1' addstatus='1' closeallpages ='1'",
  'RESOURCES',   'RESOURCES',
Line 3732  ALL_PROBLEMS Line 3721  ALL_PROBLEMS
       $start_new_option        $start_new_option
       </resource>        </resource>
     </state>      </state>
   
       <state name="PRINT_FORMATTING" title="Format of the print job">
       <nextstate>NUMBER_PER_PDF</nextstate>
       <message><br /><big><i><b>How should the results be printed?</b></i></big><br /></message>
       <choices variable="EMPTY_PAGES">
         <choice computer='0'>Start each student\'s assignment on a new page/column (add a pagefeed after each assignment)</choice>
         <choice computer='1'>Add one empty page/column after each student\'s assignment</choice>
         <choice computer='2'>Add two empty pages/column after each student\'s assignment</choice>
         <choice computer='3'>Add three empty pages/column after each student\'s assignment</choice>
       </choices>
       <nextstate>PAGESIZE</nextstate>
       <message><hr width='33%' /><b>How do you want assignments split into PDF files? </b></message>
       <choices variable="SPLIT_PDFS">
          <choice computer="all">All assignments in a single PDF file</choice>
          <choice computer="sections">Each PDF contains exactly one section</choice>
          <choice computer="oneper">Each PDF contains exactly one assignment</choice>
          <choice computer="usenumber" relatedvalue="NUMBER_TO_PRINT">
              Specify the number of assignments per PDF:</choice>
       </choices>
       </state>
 RESOURCE_SELECTOR  RESOURCE_SELECTOR
   
         $resource_selector .= &generate_format_selector($helper,  
                                                         'Format of the print job',  
                                                         'PRINT_FORMATTING');  
  &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS1);   &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS1);
   <state name="CHOOSE_STUDENTS1" title="Select Students and Resources">    <state name="CHOOSE_STUDENTS1" title="Select Students and Resources">
     <choices variable='student_sort'>      <choices variable='student_sort'>
Line 3894  CHOOSE_FROM_ANY_SEQUENCE Line 3900  CHOOSE_FROM_ANY_SEQUENCE
     my $startedTable = 0; # have we started an HTML table yet? (need      my $startedTable = 0; # have we started an HTML table yet? (need
                           # to close it later)                            # to close it later)
   
     if (($perm{'pav'} and $perm{'vgr'}) or       if (($perm{'pav'} and &Apache::lonnet::allowed('vgr',$env{'request.course.id'})) or 
  ($helper->{VARS}->{'construction'} eq '1')) {   ($helper->{VARS}->{'construction'} eq '1')) {
  &addMessage('<br />'   &addMessage('<br />'
                    .'<h3>'.&mt('Print Options').'</h3>'                     .'<h3>'.&mt('Print Options').'</h3>'
Line 4143  PROBTYPE Line 4149  PROBTYPE
   
     my $footer;      my $footer;
     if ($helper->{STATE} eq 'START') {      if ($helper->{STATE} eq 'START') {
         my $prtspool=$r->dir_config('lonPrtDir');          my $prtspool=$r->dir_config('lonPrtDir'); 
         $footer = &recently_generated($prtspool);   $footer = &recently_generated($prtspool);
     }      }
     $r->print($helper->display($footer));      $r->print($helper->display($footer));
     &Apache::lonhelper::unregisterHelperTags();      &Apache::lonhelper::unregisterHelperTags();
Line 4222  sub render { Line 4228  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 4230  sub render { Line 4239  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 4270  sub render { Line 4280  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.583.2.6  
changed lines
  Added in v.1.584


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