Diff for /loncom/interface/lonprintout.pm between versions 1.273 and 1.276

version 1.273, 2004/02/03 21:57:48 version 1.276, 2004/02/13 21:13:21
Line 647  sub path_to_problem { Line 647  sub path_to_problem {
     return '{\small\noindent\verb|'.$newurlp.'|\vskip 0 mm}';      return '{\small\noindent\verb|'.$newurlp.'|\vskip 0 mm}';
 }  }
   
   sub recalcto_mm {
       my $textwidth=shift;
       my $LaTeXwidth;
       if ($textwidth=~/(\d+\.?\d*)\s*cm/) {
    $LaTeXwidth = $1*10;
       } elsif ($textwidth=~/(\d+\.?\d*)\s*mm/) {
    $LaTeXwidth = $1;
       } elsif ($textwidth=~/(\d+\.?\d*)\s*in/) {
    $LaTeXwidth = $1*25.4;
       }
       $LaTeXwidth.=' mm';
       return $LaTeXwidth;
   }
   
 sub output_data {  sub output_data {
     my ($r,$helper,$rparmhash) = @_;      my ($r,$helper,$rparmhash) = @_;
     my %parmhash = %$rparmhash;      my %parmhash = %$rparmhash;
Line 696  ENDPART Line 710  ENDPART
     }      }
     my ($textwidth,$textheight,$oddoffset,$evenoffset) = &page_format($papersize,$laystyle,$numberofcolumns);      my ($textwidth,$textheight,$oddoffset,$evenoffset) = &page_format($papersize,$laystyle,$numberofcolumns);
     my $assignment =  $ENV{'form.assignment'};      my $assignment =  $ENV{'form.assignment'};
     my $LaTeXwidth;       my $LaTeXwidth=&recalcto_mm($textwidth); 
     if ($textwidth=~/(\d+\.?\d*)\s*cm/) {  
  $LaTeXwidth = $1*10;  
     } elsif ($textwidth=~/(\d+\.?\d*)\s*mm/) {  
  $LaTeXwidth = $1;  
     } elsif ($textwidth=~/(\d+\.?\d*)\s*in/) {  
  $LaTeXwidth = $1*25.4;  
     }  
     $LaTeXwidth.=' mm';  
     my @print_array=();      my @print_array=();
       my @student_names=();
           
     if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'current_document') {      if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'current_document') {
       #-- single document - problem, page, html, xml, ...        #-- single document - problem, page, html, xml, ...
Line 733  ENDPART Line 740  ENDPART
  }   }
  my %form;   my %form;
  $form{'grade_target'}='tex';   $form{'grade_target'}='tex';
  $form{'textwidth'}=$LaTeXwidth;   if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ &&
                       $helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) {
       $form{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'});
    } else {
       $form{'textwidth'}=$LaTeXwidth;
    }
  $form{'problem_split'}=$parmhash{'problem_stream_switch'};   $form{'problem_split'}=$parmhash{'problem_stream_switch'};
  $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};   $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
  if ($helper->{'VARS'}->{'curseed'}) {   if ($helper->{'VARS'}->{'curseed'}) {
Line 743  ENDPART Line 755  ENDPART
  &Apache::lonnet::appenv(%moreenv);   &Apache::lonnet::appenv(%moreenv);
  &Apache::lonnet::delenv('form.counter');   &Apache::lonnet::delenv('form.counter');
  &Apache::lonxml::init_counter();   &Apache::lonxml::init_counter();
  $texversion=&Apache::lonnet::ssi($currentURL,%form);   $texversion.=&Apache::lonnet::ssi($currentURL,%form);
  &Apache::lonnet::delenv('form.counter');   &Apache::lonnet::delenv('form.counter');
  &Apache::lonnet::delenv('request.filename');   &Apache::lonnet::delenv('request.filename');
     }      }
Line 798  ENDPART Line 810  ENDPART
     if ($helper->{'VARS'}->{'ANSWER_TYPE'} ne 'only') {      if ($helper->{'VARS'}->{'ANSWER_TYPE'} ne 'only') {
  my %form;   my %form;
  $form{'grade_target'}='tex';   $form{'grade_target'}='tex';
  $form{'textwidth'}=$LaTeXwidth;   if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ &&
       $helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) {
       $form{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'});
    } else {
       $form{'textwidth'}=$LaTeXwidth;
    }
  $form{'problem_split'}=$parmhash{'problem_stream_switch'};   $form{'problem_split'}=$parmhash{'problem_stream_switch'};
  $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};   $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
  $form{'rndseed'}=$rndseed;   $form{'rndseed'}=$rndseed;
Line 844  ENDPART Line 861  ENDPART
  } elsif ($currentURL=~/\/smppg$/) {    } elsif ($currentURL=~/\/smppg$/) { 
  my %form;   my %form;
  $form{'grade_target'}='tex';   $form{'grade_target'}='tex';
  $form{'textwidth'}=$LaTeXwidth;   if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ &&
                       $helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) {
       $form{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'});
    } else {
       $form{'textwidth'}=$LaTeXwidth;
    }
  $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};   $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
  my $texversion=&Apache::lonnet::ssi($currentURL,%form);   my $texversion=&Apache::lonnet::ssi($currentURL,%form);
  $result .= $texversion;   $result .= $texversion;
Line 866  ENDPART Line 888  ENDPART
         #-- produce an output string          #-- produce an output string
  my %form=();      my %form=();   
  $form{'grade_target'}='tex';   $form{'grade_target'}='tex';
  $form{'textwidth'}=$LaTeXwidth;   if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ &&
       $helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) {
       $form{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'});
    } else {
       $form{'textwidth'}=$LaTeXwidth;
    }
  $form{'problem_split'}=$parmhash{'problem_stream_switch'};   $form{'problem_split'}=$parmhash{'problem_stream_switch'};
  $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};   $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
  my $flag_latex_header_remove = 'NO';   my $flag_latex_header_remove = 'NO';
Line 960  ENDPART Line 987  ENDPART
  #loop over students   #loop over students
  my $flag_latex_header_remove = 'NO';    my $flag_latex_header_remove = 'NO'; 
  my %moreenv;   my %moreenv;
  $moreenv{'form.textwidth'}=$LaTeXwidth;   if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ &&
        $helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) {
        $moreenv{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'});
    } else {
        $moreenv{'textwidth'}=$LaTeXwidth;
    }
  &Apache::lonnet::appenv(%moreenv);   &Apache::lonnet::appenv(%moreenv);
  my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$#students+1);   my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$#students+1);
  my $student_counter=-1;   my $student_counter=-1;
Line 1024  ENDPART Line 1056  ENDPART
  $current_output = '\strut\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blanspages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$fullname.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$currentassignment.'}}} \vskip -5 mm '.$current_output;   $current_output = '\strut\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blanspages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$fullname.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$currentassignment.'}}} \vskip -5 mm '.$current_output;
     }      }
             $print_array[int($student_counter/$helper->{'VARS'}->{'NUMBER_TO_PRINT'})].=$current_output;              $print_array[int($student_counter/$helper->{'VARS'}->{'NUMBER_TO_PRINT'})].=$current_output;
               $student_names[int($student_counter/$helper->{'VARS'}->{'NUMBER_TO_PRINT'})].=$person.':'.$fullname.'_END_';
     &Apache::lonnet::delenv('form.counter');          &Apache::lonnet::delenv('form.counter');    
     &Apache::lonxml::init_counter();       &Apache::lonxml::init_counter(); 
     &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,      &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
Line 1048  ENDPART Line 1081  ENDPART
     if ($urlp=~/\//) {      if ($urlp=~/\//) {
  my %form;   my %form;
  $form{'grade_target'}='tex';   $form{'grade_target'}='tex';
  $form{'textwidth'}=$LaTeXwidth;   if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ &&
                       $helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) {
       $form{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'});
    } else {
       $form{'textwidth'}=$LaTeXwidth;
    }
  $form{'rndseed'}=$rndseed;   $form{'rndseed'}=$rndseed;
  if ($urlp =~ m|/home/([^/]+)/public_html|) {   if ($urlp =~ m|/home/([^/]+)/public_html|) {
     $urlp =~ s|/home/([^/]*)/public_html|/~$1|;      $urlp =~ s|/home/([^/]*)/public_html|/~$1|;
Line 1141  ENDPART Line 1179  ENDPART
  }   }
   
     }      }
       my $student_names='';
       if ($#print_array>0) {
    for (my $i=0;$i<=$#print_array;$i++) {
       $student_names.=$student_names[$i].'_ENDPERSON_';
    }
       }
   
       my $URLback=''; #link to original document
       if ($helper->{'VARS'}->{'construction'} ne '1') {
    #prints published resource
    $URLback=$helper->{'VARS'}->{'postdata'};
       } else {
    #prints resource from the construction space
    $URLback='/'.$helper->{'VARS'}->{'filename'};
    if ($URLback=~/([^?]+)/) {$URLback=$1;}
       }
   
     my $identifier = time.'_'.int(rand(1000));      my $identifier = time.'_'.int(rand(1000));
     &Apache::lonnet::appenv('cgi.'.$identifier.'.file'   => $filename,      &Apache::lonnet::appenv('cgi.'.$identifier.'.file'   => $filename,
Line 1150  ENDPART Line 1204  ENDPART
     'cgi.'.$identifier.'tableofcontents' => $helper->{'VARS'}->{'TABLE_CONTENTS'},      'cgi.'.$identifier.'tableofcontents' => $helper->{'VARS'}->{'TABLE_CONTENTS'},
     'cgi.'.$identifier.'tableofindex' => $helper->{'VARS'}->{'TABLE_INDEX'},      'cgi.'.$identifier.'tableofindex' => $helper->{'VARS'}->{'TABLE_INDEX'},
     'cgi.'.$identifier.'role' => $ENV{'request.role.adv'},      'cgi.'.$identifier.'role' => $ENV{'request.role.adv'},
                             'cgi.'.$identifier.'numberoffiles' => $#print_array);                              'cgi.'.$identifier.'numberoffiles' => $#print_array,
                               'cgi.'.$identifier.'studentnames' => $student_names,
                               'cgi.'.$identifier.'backref' => $URLback,);
     
   
 $r->print(<<FINALEND);  $r->print(<<FINALEND);
 <meta http-equiv="Refresh" content="0; url=/cgi-bin/printout.pl?$identifier">  <meta http-equiv="Refresh" content="0; url=/cgi-bin/printout.pl?$identifier">
 </body>  </body>

Removed from v.1.273  
changed lines
  Added in v.1.276


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