Diff for /loncom/interface/lonprintout.pm between versions 1.434 and 1.445

version 1.434, 2006/03/29 11:47:03 version 1.445, 2006/06/26 21:53:36
Line 42  use Apache::lonratedt; Line 42  use Apache::lonratedt;
 use POSIX qw(strftime);  use POSIX qw(strftime);
 use Apache::lonlocal;  use Apache::lonlocal;
 use Carp;  use Carp;
   use lib '/home/httpd/lib/perl/';
   use LONCAPA;
   
 my %perm;  my %perm;
   
Line 700  sub get_name { Line 702  sub get_name {
     if (!defined($udom)) { $udom=$env{'user.domain'}; }      if (!defined($udom)) { $udom=$env{'user.domain'}; }
     my $plainname=&Apache::loncommon::plainname($uname,$udom);      my $plainname=&Apache::loncommon::plainname($uname,$udom);
     if ($plainname=~/^\s*$/) { $plainname=$uname.'@'.$udom; }      if ($plainname=~/^\s*$/) { $plainname=$uname.'@'.$udom; }
     $plainname=&Apache::lonxml::latex_special_symbols($plainname,'header');     #  $plainname=&Apache::lonxml::latex_special_symbols($plainname,'header');
       $plainname = &escape_LaTeX($plainname);
     return $plainname;      return $plainname;
 }  }
   
 sub get_course {  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(&Apache::lonnet::unescape($env{'course.'.$env{'request.course.id'}.'.description'}),'header');   $courseidinfo = &Apache::lonxml::latex_special_symbols(&unescape($env{'course.'.$env{'request.course.id'}.'.description'}),'header');
     }      }
     return $courseidinfo;      return $courseidinfo;
 }  }
Line 1322  ENDPART Line 1325  ENDPART
  $resources_printed .= $urlp.':';   $resources_printed .= $urlp.':';
   
  &Apache::lonxml::remember_problem_counter();   &Apache::lonxml::remember_problem_counter();
   
  $texversion.=&Apache::lonnet::ssi($urlp,%form);   $texversion.=&Apache::lonnet::ssi($urlp,%form);
  if ($urlp=~/\.page$/) {   if ($urlp=~/\.page$/) {
     ($texversion,my $number_of_columns_page) = &page_cleanup($texversion);      ($texversion,my $number_of_columns_page) = &page_cleanup($texversion);
Line 1671  ENDPART Line 1673  ENDPART
        $selectionmade,          $selectionmade, 
        $helper->{'VARS'}->{'ANSWER_TYPE'});         $helper->{'VARS'}->{'ANSWER_TYPE'});
     }      }
     #changes page's parameters for the one column output   
     if ($numberofcolumns == 1) {      $result =~ s/\\textwidth\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\textwidth= $helper->{'VARS'}->{'pagesize.width'} $helper->{'VARS'}->{'pagesize.widthunit'} /;
  $result =~ s/\\textwidth\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\textwidth= $helper->{'VARS'}->{'pagesize.width'} $helper->{'VARS'}->{'pagesize.widthunit'} /;      $result =~ s/\\textheight\s*=?\s*-?\d*\.?\d*\s*(cm|mm|in)/\\textheight $helper->{'VARS'}->{'pagesize.height'} $helper->{'VARS'}->{'pagesize.heightunit'} /;
  $result =~ s/\\textheight\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\textheight $helper->{'VARS'}->{'pagesize.height'} $helper->{'VARS'}->{'pagesize.heightunit'} /;      $result =~ s/\\evensidemargin\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\evensidemargin= $helper->{'VARS'}->{'pagesize.lmargin'} $helper->{'VARS'}->{'pagesize.lmarginunit'} /;
  $result =~ s/\\evensidemargin\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\evensidemargin= $helper->{'VARS'}->{'pagesize.lmargin'} $helper->{'VARS'}->{'pagesize.lmarginunit'} /;      $result =~ s/\\oddsidemargin\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\oddsidemargin= $helper->{'VARS'}->{'pagesize.lmargin'} $helper->{'VARS'}->{'pagesize.lmarginunit'} /;
  $result =~ s/\\oddsidemargin\s*=\s*-?\d*\.?\d*\s*(cm|mm|in)/\\oddsidemargin= $helper->{'VARS'}->{'pagesize.lmargin'} $helper->{'VARS'}->{'pagesize.lmarginunit'} /;  
     }  
   
 #-- writing .tex file in prtspool   #-- writing .tex file in prtspool 
     my $temp_file;      my $temp_file;
Line 1733  ENDPART Line 1734  ENDPART
     my $URLback=''; #link to original document      my $URLback=''; #link to original document
     if ($helper->{'VARS'}->{'construction'} ne '1') {      if ($helper->{'VARS'}->{'construction'} ne '1') {
  #prints published resource   #prints published resource
  $URLback=&Apache::lonnet::escape('/adm/flip?postdata=return:');   $URLback=&escape('/adm/flip?postdata=return:');
     } else {      } else {
  #prints resource from the construction space   #prints resource from the construction space
  $URLback='/'.$helper->{'VARS'}->{'filename'};   $URLback='/'.$helper->{'VARS'}->{'filename'};
Line 1802  sub print_resources { Line 1803  sub print_resources {
  $namepostfix="\\\\Name: ";   $namepostfix="\\\\Name: ";
  $fullname = "CODE - ".$moreenv->{'CODE'};   $fullname = "CODE - ".$moreenv->{'CODE'};
     }      }
       #  Fullname may have special latex characters that need \ prefixing:
       #
       &Apache::lonnet::logthis("Prior to latex escape: $fullname");
   #    $fullname = &escape_LaTeX($fullname);
       &Apache::lonnet::logthis("After escape $fullname");
   
     my $i           = 0;      my $i           = 0;
     #goes through all resources, checks if they are available for       #goes through all resources, checks if they are available for 
     #current student, and produces output         #current student, and produces output   
Line 1810  sub print_resources { Line 1817  sub print_resources {
     my %page_breaks  = &get_page_breaks($helper);      my %page_breaks  = &get_page_breaks($helper);
     my @format_array = split(/\|/,$helper->{'VARS'}->{'FORMAT'});      my @format_array = split(/\|/,$helper->{'VARS'}->{'FORMAT'});
     my $columns_in_format = $format_array[1];      my $columns_in_format = $format_array[1];
       #
       #   end each student with a 
       #   Special that allows the post processor to even out the page
       #   counts later.  Nasty problem this... it would be really
       #   nice to put the special in as a postscript comment
       #   e.g. \special{ps:\ENDOFSTUDENTSTAMP}  unfortunately,
       #   The special gets passed the \ and dvips puts it in the output file
       #   so we will just rely on prntout.pl to strip  ENDOFSTUDENTSTAMP from the
       #   postscript.  Each ENDOFSTUDENTSTAMP will go on a line by itself.
       #
   
     foreach my $curresline (@{$master_seq})  {      foreach my $curresline (@{$master_seq})  {
  if (defined $page_breaks{$curresline}) {   if (defined $page_breaks{$curresline}) {
Line 1905  sub print_resources { Line 1922  sub print_resources {
    $current_output = '\strut\vspace*{-6 mm}\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\vspace*{-2 mm}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blankpages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\fancyhead[LO]{\\textit{\\textbf{'.$fullname.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$currentassignment.'}'.$namepostfix.'}} \vskip 5 mm '.$current_output;     $current_output = '\strut\vspace*{-6 mm}\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\vspace*{-2 mm}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blankpages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\fancyhead[LO]{\\textit{\\textbf{'.$fullname.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$currentassignment.'}'.$namepostfix.'}} \vskip 5 mm '.$current_output;
  }   }
     }      }
       #
       #  Close the student bracketing.
       #
       $current_output .= "\n\\special{ps:ENDOFSTUDENTSTAMP}\n";
     return ($current_output,$fullname, $printed);      return ($current_output,$fullname, $printed);
   
 }  }
Line 2150  sub printHelper { Line 2171  sub printHelper {
         my $helperFragment = <<HELPERFRAGMENT;          my $helperFragment = <<HELPERFRAGMENT;
   <state name="CHOOSE_PROBLEMS" title="Select Problem(s) to print">    <state name="CHOOSE_PROBLEMS" title="Select Problem(s) to print">
     <message>(mark them then click "next" button) <br /></message>      <message>(mark them then click "next" button) <br /></message>
     <resource variable="RESOURCES" multichoice="1" toponly='0' addstatus="1"      <resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1"
               closeallpages="1">                closeallpages="1">
       <nextstate>PAGESIZE</nextstate>        <nextstate>PAGESIZE</nextstate>
       <filterfunc>return $isProblemOrMap;</filterfunc>        <filterfunc>return $isProblem;</filterfunc>
       <choicefunc>return $isNotMap;</choicefunc>  
       <mapurl>$map</mapurl>        <mapurl>$map</mapurl>
       <valuefunc>return $symbFilter;</valuefunc>        <valuefunc>return $symbFilter;</valuefunc>
       <option text='Newpage' variable='FINISHPAGE' />        <option text='Newpage' variable='FINISHPAGE' />
Line 2163  sub printHelper { Line 2183  sub printHelper {
   
   <state name="CHOOSE_PROBLEMS_HTML" title="Select Resource(s) to print">    <state name="CHOOSE_PROBLEMS_HTML" title="Select Resource(s) to print">
     <message>(mark them then click "next" button) <br /></message>      <message>(mark them then click "next" button) <br /></message>
     <resource variable="RESOURCES" multichoice="1" toponly='0' addstatus="1"      <resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1"
               closeallpages="1">                closeallpages="1">
       <nextstate>PAGESIZE</nextstate>        <nextstate>PAGESIZE</nextstate>
       <choicefunc>return $isNotMap;</choicefunc>        <filterfunc>return $isNotMap;</filterfunc>
       <mapurl>$map</mapurl>        <mapurl>$map</mapurl>
       <valuefunc>return $symbFilter;</valuefunc>        <valuefunc>return $symbFilter;</valuefunc>
       <option text='Newpage' variable='FINISHPAGE' />        <option text='Newpage' variable='FINISHPAGE' />
Line 2235  ALL_PROBLEMS Line 2255  ALL_PROBLEMS
       </resource>        </resource>
     </state>      </state>
     <state name="PRINT_FORMATTING" title="How should results be printed?">      <state name="PRINT_FORMATTING" title="How should results be printed?">
     <nextstate>NUMBER_PER_PDF</nextstate>  
     <message><br /><big><i><b>How should the results be printed?</b></i></big><br /></message>      <message><br /><big><i><b>How should the results be printed?</b></i></big><br /></message>
     <choices variable="EMPTY_PAGES">      <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='0'>Start each student\'s assignment on a new page/column (add a pagefeed after each assignment)</choice>
Line 2243  ALL_PROBLEMS Line 2262  ALL_PROBLEMS
       <choice computer='2'>Add two empty pages/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>        <choice computer='3'>Add three empty pages/column after each student\'s assignment</choice>
     </choices>      </choices>
     </state>  
     <state name="NUMBER_PER_PDF" title="Number printed at once">  
     <nextstate>PAGESIZE</nextstate>      <nextstate>PAGESIZE</nextstate>
     <message><hr width='33%' /><b>How do you want assignments split into PDF files? </b></message>      <message><hr width='33%' /><b>How do you want assignments split into PDF files? </b></message>
     <choices variable="SPLIT_PDFS">      <choices variable="SPLIT_PDFS">
        <choice computer="all">All assignments in a single PDF file</choice>         <choice computer="all">All assignments in a single PDF file</choice>
        <choice computer="sections">Each PDF contains exactly one section</choice>         <choice computer="sections">Each PDF contains exactly one section</choice>
        <choice computer="oneper">Each PDF contains exactly one assignment</choice>         <choice computer="oneper">Each PDF contains exactly one assignment</choice>
        <choice computer="usenumber">Specify Number:</choice>         <choice computer="usenumber" relatedvalue="NUMBER_TO_PRINT" relateddefault="all">
               Specify Number:</choice>
     </choices>      </choices>
     <string variable="NUMBER_TO_PRINT" maxlength="5" size="5"><defaultvalue>"all"</defaultvalue></string>  
     </state>      </state>
 RESOURCE_SELECTOR  RESOURCE_SELECTOR
   
Line 2264  RESOURCE_SELECTOR Line 2281  RESOURCE_SELECTOR
       <choice computer='0'>Sort by section then student</choice>        <choice computer='0'>Sort by section then student</choice>
       <choice computer='1'>Sort by students across sections.</choice>        <choice computer='1'>Sort by students across sections.</choice>
     </choices>      </choices>
         <message><br /><hr /><br /> </message>
       <student multichoice='1' variable="STUDENTS" nextstate="SELECT_PROBLEMS" coursepersonnel="1"/>        <student multichoice='1' variable="STUDENTS" nextstate="SELECT_PROBLEMS" coursepersonnel="1"/>
   </state>    </state>
     $resource_selector      $resource_selector
Line 2297  CHOOSE_STUDENTS Line 2315  CHOOSE_STUDENTS
     }      }
     push(@{$helper->{DATA}{ALL_CODE_CHOICES}},[$code,$choice]);      push(@{$helper->{DATA}{ALL_CODE_CHOICES}},[$code,$choice]);
  }   }
  $code_selection .=   if (%codes_to_print) {
 '         $code_selection .='   
       <exec>               <exec>
         push(@{$state->{CHOICES}},@{$helper->{DATA}{ALL_CODE_CHOICES}});                 push(@{$state->{CHOICES}},@{$helper->{DATA}{ALL_CODE_CHOICES}});
       </exec>              </exec>
     '.$/;              '.$/;
    }
   
   
  open(FH,$Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab');   open(FH,$Apache::lonnet::perlvar{'lonTabDir'}.'/scantronformat.tab');
Line 2404  CHOOSE_ANON1 Line 2423  CHOOSE_ANON1
       <choice computer='2'>Add two empty pages/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>        <choice computer='3'>Add three empty pages/column after each student\'s assignment</choice>
     </choices>      </choices>
     </state>  
     <state name="NUMBER_PER_PDF" title="Number assignments per pdf">  
     <nextstate>PAGESIZE</nextstate>      <nextstate>PAGESIZE</nextstate>
     <message><hr width='33%' /><b>How do you want assignments split into PDF files? </b></message>      <message><hr width='33%' /><b>How do you want assignments split into PDF files? </b></message>
     <choices variable="SPLIT_PDFS">      <choices variable="SPLIT_PDFS">
        <choice computer="all">All assignments in a single PDF file</choice>         <choice computer="all">All assignments in a single PDF file</choice>
        <choice computer="sections">Each PDF contains exactly one section</choice>         <choice computer="sections">Each PDF contains exactly one section</choice>
        <choice computer="oneper">Each PDF contains exactly one assignment</choice>         <choice computer="oneper">Each PDF contains exactly one assignment</choice>
        <choice computer="usenumber">Specify Number:</choice>         <choice computer="usenumber" relatedvalue="NUMBER_TO_PRINT" relateddefault="all">
              Specify Number:</choice>
     </choices>      </choices>
     <string variable="NUMBER_TO_PRINT" maxlength="5" size="5"><defaultvalue>"all"</defaultvalue></string>  
     </state>      </state>
 RESOURCE_SELECTOR  RESOURCE_SELECTOR
   
Line 2424  RESOURCE_SELECTOR Line 2441  RESOURCE_SELECTOR
       <choice computer='0'>Sort by section then student</choice>        <choice computer='0'>Sort by section then student</choice>
       <choice computer='1'>Sort by students across sections.</choice>        <choice computer='1'>Sort by students across sections.</choice>
     </choices>      </choices>
       <message><br /><hr /><br /></message>
     <student multichoice='1' variable="STUDENTS" nextstate="SELECT_RESOURCES" coursepersonnel="1" />      <student multichoice='1' variable="STUDENTS" nextstate="SELECT_RESOURCES" coursepersonnel="1" />
   
     </state>      </state>
Line 2536  CHOOSE_FROM_SUBDIR Line 2554  CHOOSE_FROM_SUBDIR
     </state>      </state>
   <state name="CHOOSE_FROM_ANY_SEQUENCE" title="Select Resources To Print">    <state name="CHOOSE_FROM_ANY_SEQUENCE" title="Select Resources To Print">
     <message>(mark desired resources then click "next" button) <br /></message>      <message>(mark desired resources then click "next" button) <br /></message>
     <resource variable="RESOURCES" multichoice="1" toponly='0' addstatus="1"      <resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1"
               closeallpages="1">                closeallpages="1">
       <nextstate>PAGESIZE</nextstate>        <nextstate>PAGESIZE</nextstate>
       <filterfunc>return $isProblemOrMap;</filterfunc>        <filterfunc>return $isProblem</filterfunc>
       <choicefunc>return $isProblem;</choicefunc>  
       <mapurl evaluate='1'>return '$escapedSequenceName';</mapurl>        <mapurl evaluate='1'>return '$escapedSequenceName';</mapurl>
       <valuefunc>return $symbFilter;</valuefunc>        <valuefunc>return $symbFilter;</valuefunc>
       <option text='Newpage' variable='FINISHPAGE' />        <option text='Newpage' variable='FINISHPAGE' />
Line 2886  sub render { Line 2903  sub render {
         $result .= '<br /><font color="#FF0000">' . $self->{ERROR_MSG} . '</font><br />';          $result .= '<br /><font color="#FF0000">' . $self->{ERROR_MSG} . '</font><br />';
     }      }
   
       my $width = 18;
       my $format = $helper->{VARS}->{$self->{'formatvar'}};
       if (substr($format, 2, 1) ne '1') {
    $width = 9;
       }
   
     $result .= <<ELEMENTHTML;      $result .= <<ELEMENTHTML;
   
 <p>How should the column be formatted?</p>  <p>How should the column be formatted?</p>
Line 2893  sub render { Line 2916  sub render {
 <table cellpadding='3'>  <table cellpadding='3'>
   <tr>    <tr>
     <td align='right'><b>Width</b>:</td>      <td align='right'><b>Width</b>:</td>
     <td align='left'><input type='text' name='$var.width' value='18' size='4'></td>      <td align='left'><input type='text' name='$var.width' value='$width' size='4'></td>
     <td align='left'>      <td align='left'>
       <select name='$var.widthunit'>        <select name='$var.widthunit'>
         <option>cm</option><option>in</option>          <option>cm</option><option>in</option>
Line 2934  sub preprocess { Line 2957  sub preprocess {
     my $helper = Apache::lonhelper::getHelper();      my $helper = Apache::lonhelper::getHelper();
   
     my $format = $helper->{VARS}->{$self->{'formatvar'}};      my $format = $helper->{VARS}->{$self->{'formatvar'}};
     if (substr($format, 2, 1) ne '1') {  #    if (substr($format, 2, 1) ne '1') {
         $helper->changeState($self->{NEXTSTATE});  #        $helper->changeState($self->{NEXTSTATE});
     }  #    }
         
     return 1;      return 1;
 }  }

Removed from v.1.434  
changed lines
  Added in v.1.445


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