Diff for /loncom/interface/lonprintout.pm between versions 1.627.2.11 and 1.638

version 1.627.2.11, 2014/02/19 02:26:13 version 1.638, 2014/01/20 02:43:41
Line 578  sub printable { Line 578  sub printable {
 #       date for printing checks printstartdate param first, then, if not set,  #       date for printing checks printstartdate param first, then, if not set,
 #       opendate param, then, if not set, contentopen param.  #       opendate param, then, if not set, contentopen param.
   
   
 sub get_print_dates {  sub get_print_dates {
     my $res = shift;      my $res = shift;
     my $partsref = $res->parts();      my $partsref = $res->parts();
Line 743  sub master_seq_to_person_seq { Line 742  sub master_seq_to_person_seq {
     }      }
           
     my $navmap           = Apache::lonnavmaps::navmap->new($username, $userdomain,      my $navmap           = Apache::lonnavmaps::navmap->new($username, $userdomain,
                                                            $code,$unhidden);                                                             $code, $unhidden);
     my ($start,$finish);      my ($start,$finish);
   
     if ($map) {      if ($map) {
Line 763  sub master_seq_to_person_seq { Line 762  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()) {
  #   #
  #  Only process resources..that are not removed by randomout...   #  Only process resources..that are not removed by randomout...
  #  and are selected for printint as well.   #  and are selected for printint as well.
  #   #
   
         if (ref($curres) && ! $curres->randomout()) {          if (ref($curres) && ! $curres->randomout()) {
             my $currsymb = $curres->symb();              my $currsymb = $curres->symb();
             if (exists($seq_hash{$currsymb})) {              if (exists($seq_hash{$currsymb})) {
Line 1056  sub printf_style_subst { Line 1055  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 1077  sub format_page_header { Line 1076  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  
         # 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';
    }
   
     return $format;   $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!!!
           
     # 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 1236  sub is_code_valid { Line 1231  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 1845  sub get_course { Line 1839  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 1867  sub page_format_transformation { Line 1863  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 2174  sub print_page_in_course { Line 2169  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 2710  ENDPART Line 2705  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 3034  ENDPART Line 3029  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 3618  sub print_resources { Line 3612  sub print_resources {
     #      #
   
     my $syllabus_first = 0;      my $syllabus_first = 0;
     my $assessment_first = 0;  
     my $current_assignment = "";      my $current_assignment = "";
     my $assignment;      my $assignment;
     my $courseidinfo = &get_course();      my $courseidinfo = &get_course();
     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 3642  sub print_resources { Line 3633  sub print_resources {
     if ($print_incomplete && !&incomplete($username, $userdomain, $res_url)) {      if ($print_incomplete && !&incomplete($username, $userdomain, $res_url)) {
  next;   next;
     }      }
             if ((!$actually_printed) && ($curresline =~ m/$LONCAPA::assess_re/)) {  
                 $assessment_first = 1;  
             }  
     $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 3751  sub print_resources { Line 3738  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);    $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 3779  sub print_resources { Line 3766  sub print_resources {
     if ($syllabus_first) {      if ($syllabus_first) {
         $current_output =~ s/\\\\ Last updated:/Last updated:/          $current_output =~ s/\\\\ Last updated:/Last updated:/
     }      }
     my $newheader;      if (0) {
     unless (($assessment_first) && ($actually_printed > 1)) {   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]';
  $newheader = $header_start.'{'.$header_line.'}';   $header_line = $header_start.'{'.$header_line.'}';
     }      }
     if ($current_output=~/\\documentclass/) {      if ($current_output=~/\\documentclass/) {
  $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent$newheader$namepostfix}\\vskip 5 mm /;  # $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 /;
   
     } 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'
     $newheader.$namepostfix. '} \vskip 5 mm '.$current_output;      .$namepostfix. '} \vskip 5 mm '.$current_output;
   
     }      }
     #      #
     #  Close the student bracketing.      #  Close the student bracketing.
Line 4460  ALL_PROBLEMS Line 4453  ALL_PROBLEMS
         my @lines = &Apache::grades::get_scantronformat_file();          my @lines = &Apache::grades::get_scantronformat_file();
  my $codechoice='';   my $codechoice='';
  foreach my $line (@lines) {   foreach my $line (@lines) {
               next if (($line =~ /^\#/) || ($line eq ''));
     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 && 
Line 4694  CHOOSE_FROM_ANY_SEQUENCE Line 4688  CHOOSE_FROM_ANY_SEQUENCE
   
         if ($noprintmsg) {          if ($noprintmsg) {
             $paramHash = Apache::lonhelper::getParamHash();              $paramHash = Apache::lonhelper::getParamHash();
             $paramHash->{MESSAGE_TEXT} =      $paramHash->{MESSAGE_TEXT} = 
                 '<p class="LC_info">'.$noprintmsg.'</p>';                  '<p class="LC_info">'.$noprintmsg.'</p>';
             Apache::lonhelper::message->new();      Apache::lonhelper::message->new();
         }          }
     }      }
     $paramHash = Apache::lonhelper::getParamHash();      $paramHash = Apache::lonhelper::getParamHash();
Line 4921  FONT_SELECTION Line 4915  FONT_SELECTION
       return "$helper->{VARS}->{'probstatus'}";        return "$helper->{VARS}->{'probstatus'}";
                    </defaultvalue>                     </defaultvalue>
    <choice computer="problem">Homework Problem</choice>     <choice computer="problem">Homework Problem</choice>
    <choice computer="exam">Exam Problem</choice>     <choice computer="exam">Bubblesheet Exam Problem</choice>
    <choice computer="survey">Survey question</choice>     <choice computer="survey">Survey question</choice>
                    ,choice computer="anonsurvey"Anonymous survey question</choice>                     ,choice computer="anonsurvey"Anonymous survey question</choice>
  </dropdown>   </dropdown>
Line 5039  sub render { Line 5033  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 5047  sub render { Line 5044  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 5087  sub render { Line 5085  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.627.2.11  
changed lines
  Added in v.1.638


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