Diff for /loncom/interface/lonprintout.pm between versions 1.154 and 1.158

version 1.154, 2003/05/06 20:09:49 version 1.158, 2003/05/08 18:33:03
Line 1350  ENDPART Line 1350  ENDPART
     }      }
     my ($textwidth,$textheight,$oddoffset,$evenoffset) = &page_format_new($papersize,$laystyle,$numberofcolumns);      my ($textwidth,$textheight,$oddoffset,$evenoffset) = &page_format_new($papersize,$laystyle,$numberofcolumns);
     my $assignment =  $ENV{'form.assignment'};      my $assignment =  $ENV{'form.assignment'};
 #    if ($choice eq 'Subdirectory print') {  
 # if ($ENV{'form.layout'} eq '') {$layout = 'CAPA';}  
 # if ($ENV{'form.papersize'} eq '') {$papersize = 'Letter [8 1/2x11 in]';}  
 # if ($ENV{'form.numberofcolumns'} eq '') {$numberofcolumns = 2;}  
 #    }  
 #    if (($choice eq 'Standard LaTeX output for current document') &&  
 # ($ENV{'form.url'}=~m|^/~|)) {  
 # if ($ENV{'form.layout'} eq '') {$layout = 'CAPA';}  
 # if ($ENV{'form.papersize'} eq '') {$papersize = 'Letter [8 1/2x11 in]';}  
 # if ($ENV{'form.numberofcolumns'} eq '') {$numberofcolumns = 2;}  
 #    }  
   
       
 #    my ($textwidth,$textheight,$oddoffset,$evenoffset) = &page_format($papersize,$layout,$numberofcolumns);  
 #    if ($numberofcolumns == 1) {  
 # $textwidth=$ENV{'form.width'};  
 # $textheight=$ENV{'form.height'};  
 #    }  
     my $LaTeXwidth;       my $LaTeXwidth; 
     if ($textwidth=~/(\d+)\s*cm/) {      if ($textwidth=~/(\d+)\s*cm/) {
  $LaTeXwidth = $1*10;   $LaTeXwidth = $1*10;
Line 1378  ENDPART Line 1360  ENDPART
     }      }
     $LaTeXwidth.=' mm';      $LaTeXwidth.=' mm';
           
       
     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, ...
  my $currentURL;   my $currentURL;
  if (not defined $helper->{'VARS'}->{'construction'}) {   if ($helper->{'VARS'}->{'construction'} ne '1') {
               #prins published resource
     $currentURL=$helper->{'VARS'}->{'postdata'};      $currentURL=$helper->{'VARS'}->{'postdata'};
  } else {   } else {
     $currentURL=$helper->{'VARS'}->{'construction'};              #prins resource from the construction space
       $currentURL=$helper->{'VARS'}->{'filename'};
       $currentURL=~s/\/home\//\/~/;
       $currentURL=~s/public_html\///;
  }   }
  $selectionmade = 1;   $selectionmade = 1;
  if ($currentURL=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) {   if ($currentURL=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) {
         my %moreenv;      my %moreenv;
         $moreenv{'form.grade_target'}='tex';      $moreenv{'form.grade_target'}='tex';
  if (&Apache::lonnet::allowed('bre',$currentURL)) {      $moreenv{'request.filename'}=$currentURL;
     $currentURL=~s/http:\/\/[^\/]+//;      $moreenv{'form.textwidth'}=$LaTeXwidth;
  }      &Apache::lonnet::appenv(%moreenv);
         $moreenv{'request.filename'}=$currentURL;      my $texversion=&Apache::lonnet::ssi($currentURL);
         $moreenv{'form.textwidth'}=$LaTeXwidth;      &Apache::lonnet::delenv('form.grade_target','form.textwidth','form.counter');
         &Apache::lonnet::appenv(%moreenv);      $result .= $texversion;
         my $texversion=&Apache::lonnet::ssi($currentURL);      if ($currentURL=~m/\.page\s*$/) {
         &Apache::lonnet::delenv('form.grade_target','form.textwidth','form.counter');   ($result,$number_of_columns) = &page_cleanup($result);
         $result .= $texversion;      }
         if ($currentURL=~m/\.page\s*$/) {   } else {
   ($result,$number_of_columns) = &page_cleanup($result);  
         }  
       } else {  
 #  $result='\documentclass[letterpaper]{article}\usepackage{calc}\begin{document}Printout of this type of document is currently not supported: ';  #  $result='\documentclass[letterpaper]{article}\usepackage{calc}\begin{document}Printout of this type of document is currently not supported: ';
 #  if ($ENV{'form.url'}=~/\/(aboutme|syllabus|bulletinboard|smppg)$/) {  #  if ($ENV{'form.url'}=~/\/(aboutme|syllabus|bulletinboard|smppg)$/) {
 #      $result.=$1;  #      $result.=$1;
Line 1411  ENDPART Line 1393  ENDPART
 #      $result.=$ENV{'form.url'};  #      $result.=$ENV{'form.url'};
 #  }  #  }
 #  $result.=' \end{document}'  #  $result.=' \end{document}'
       }   }
   
   
     } elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') or      } elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') or
Line 1604  sub handler { Line 1586  sub handler {
   
 # my $key;   # my $key; 
 # foreach $key (keys %{$helper->{'VARS'}}) {  # foreach $key (keys %{$helper->{'VARS'}}) {
 #    $r->print(' '.$key.'->'.$helper->{'VARS'}->{$key}.'<br />');  #    $r->print(' '.$key.'->'.$helper->{'VARS'}->{$key}.'<-<br />');
 # }  # }
 # return OK;  # return OK;
   
Line 1708  sub printHelper { Line 1690  sub printHelper {
           
     my $helper = Apache::lonhelper::helper->new("Printing Wizard");      my $helper = Apache::lonhelper::helper->new("Printing Wizard");
     $helper->declareVar('symb');      $helper->declareVar('symb');
     $helper->declareVar('postdata');      $helper->declareVar('postdata');    
       $helper->declareVar('filename');
       $helper->declareVar('construction');
           
     # This will persistently load in the data we want from the      # This will persistently load in the data we want from the
     # very first screen.      # very first screen.
     if ($ENV{'form.postdata'}) {      # Detect whether we're coming from construction space
  if ($ENV{'form.postdata'}!~/\/res\//) {$helper->{VARS}->{'construction'} = $ENV{'form.postdata'};}      if ($ENV{'form.postdata'} =~ /http:\/\// ) {
         $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($ENV{'form.postdata'});          $ENV{'form.postdata'} =~ /http:\/\/[a-zA-Z.]+\/~([a-zA-Z0-9]+)\/(.*)/;
           $helper->{VARS}->{'filename'} = "/home/$1/public_html/$2";
           $helper->{VARS}->{'construction'} = 1;
       } else {
           if ($ENV{'form.postdata'}) {
               $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($ENV{'form.postdata'});
           }
           if ($ENV{'form.symb'}) {
               $helper->{VARS}->{'symb'} = $ENV{'form.symb'};
           }
           if ($ENV{'form.url'}) {
               $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($helper->{VARS}->{'postdata'});
           }
     }      }
   
     if ($ENV{'form.symb'}) {      if ($ENV{'form.symb'}) {
         $helper->{VARS}->{'symb'} = $ENV{'form.symb'};          $helper->{VARS}->{'symb'} = $ENV{'form.symb'};
     }      }
Line 1723  sub printHelper { Line 1720  sub printHelper {
         $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($helper->{VARS}->{'postdata'});          $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($helper->{VARS}->{'postdata'});
   
     }      }
   
           
     my ($resourceTitle,$sequenceTitle,$mapTitle) = &details_for_menu;      my ($resourceTitle,$sequenceTitle,$mapTitle) = &details_for_menu;
     $helper->{VARS}->{'assignment'} = $sequenceTitle;      $helper->{VARS}->{'assignment'} = $sequenceTitle;
   
       
     # Extract map      # Extract map
     my $symb = $helper->{VARS}->{'symb'};      my $symb = $helper->{VARS}->{'symb'};
     my ($map, $id, $url) = split(/___/, $symb);      my ($map, $id, $url);
     $helper->{VARS}->{'postdata'} = Apache::lonnet::clutter($url);      my $subdir;
   
     if (!$resourceTitle) { # if the resource doesn't have a title, use the filename      # Get the resource name from construction space
         my $url = $helper->{VARS}->{'postdata'};      if ($helper->{VARS}->{'construction'}) {
         $resourceTitle = substr($url, rindex($url, '/') + 1);          $resourceTitle = substr($helper->{VARS}->{'filename'}, 
                                   rindex($helper->{VARS}->{'filename'}, '/')+1);
           $subdir = substr($helper->{VARS}->{'filename'},
                            0, rindex($helper->{VARS}->{'filename'}, '/') + 1);
       } else {
           ($map, $id, $url) = split(/___/, $symb);
           $helper->{VARS}->{'postdata'} = Apache::lonnet::clutter($url);
   
           if (!$resourceTitle) { # if the resource doesn't have a title, use the filename
               my $url = $helper->{VARS}->{'postdata'};
               $resourceTitle = substr($url, rindex($url, '/') + 1);
           }
           $subdir = &Apache::lonnet::filelocation("", $url);
     }      }
   
     Apache::lonhelper::registerHelperTags();      Apache::lonhelper::registerHelperTags();
   
     my $subdir = &Apache::lonnet::filelocation("", $url);  
   
     # "Delete everything after the last slash."      # "Delete everything after the last slash."
     $subdir =~ s|/[^/]+$||;      $subdir =~ s|/[^/]+$||;
     if (not defined $helper->{VARS}->{'construction'}) {      if (not defined $helper->{VARS}->{'construction'}) {
Line 1769  sub printHelper { Line 1776  sub printHelper {
     # the helper by hand.      # the helper by hand.
     my $printChoices = [];      my $printChoices = [];
     my $paramHash;      my $paramHash;
     # We can always print the current screen.  
   
     push @{$printChoices}, ["<b>$resourceTitle</b> (exactly what was on the screen)", 'current_document', 'PAGESIZE'];      if ($resourceTitle) {
           push @{$printChoices}, ["<b>$resourceTitle</b> (prints what you just saw on the screen)", 'current_document', 'PAGESIZE'];
       }
   
       $r->print($helper->{VARS}->{'postdata'});
   
     # If we're in a sequence...      # If we're in a sequence...
     if (not defined $helper->{'VARS'}->{'construction'}) {      if (!defined($helper->{'VARS'}->{'construction'})) {
         # Allow problems from sequence          # Allow problems from sequence
         push @{$printChoices}, ["Problems from <b>$sequenceTitle</b>", 'map_problems', 'CHOOSE_PROBLEMS'];          push @{$printChoices}, ["Problem(s) from <b>$sequenceTitle</b>", 'map_problems', 'CHOOSE_PROBLEMS'];
         # Allow all resources from sequence          # Allow all resources from sequence
         push @{$printChoices}, ["Problems and pages from <b>$sequenceTitle</b>", 'map_problems_pages', 'CHOOSE_PROBLEMS_HTML'];          push @{$printChoices}, ["Everything (problem(s), page(s), html/xml file(s)) from <b>$sequenceTitle</b>", 'map_problems_pages', 'CHOOSE_PROBLEMS_HTML'];
   
         my $isProblem = '$res->is_problem();';          my $isProblem = '$res->is_problem();';
         my $isProblemOrMap = '$res->is_problem() || $res->is_map()';          my $isProblemOrMap = '$res->is_problem() || $res->is_map()';
         my $isNotMap = '!$res->is_map();';          my $isNotMap = '!$res->is_map();';
         my $symb = '$res->symb();';          my $symb = '$res->symb();';
         my $helperFragment = <<HELPERFRAGMENT;          my $helperFragment = <<HELPERFRAGMENT;
   <state name="CHOOSE_PROBLEMS" title="Select Problems">    <state name="CHOOSE_PROBLEMS" title="Select Problem(s) to print">
     <message>Select problems to print:</message>      <message>(mark them then click "next" button) <br /></message>
     <resource variable="RESOURCES" multichoice="1" toponly='1'>      <resource variable="RESOURCES" multichoice="1" toponly='1'>
       <nextstate>PAGESIZE</nextstate>        <nextstate>PAGESIZE</nextstate>
       <filterfunc>return $isProblem</filterfunc>        <filterfunc>return $isProblem</filterfunc>
Line 1795  sub printHelper { Line 1805  sub printHelper {
       </resource>        </resource>
     </state>      </state>
   
   <state name="CHOOSE_PROBLEMS_HTML" title="Select Resources">    <state name="CHOOSE_PROBLEMS_HTML" title="Select Resource(s) to print">
     <message>Select resources to print:</message>      <message>(mark them then click "next" button) <br /></message>
     <resource variable="RESOURCES" multichoice="1" toponly='1'>      <resource variable="RESOURCES" multichoice="1" toponly='1'>
       <nextstate>PAGESIZE</nextstate>        <nextstate>PAGESIZE</nextstate>
       <filterfunc>return $isNotMap;</filterfunc>        <filterfunc>return $isNotMap;</filterfunc>
Line 1812  HELPERFRAGMENT Line 1822  HELPERFRAGMENT
     # If the user is priviledged, allow them to print all       # If the user is priviledged, allow them to print all 
     # problems in the course, optionally for selected students      # problems in the course, optionally for selected students
     if (($ENV{'request.role'}=~m/^cc\./ or $ENV{'request.role'}=~m/^in\./ or $ENV{'request.role'}=~m/^ta\./) and ($helper->{VARS}->{'postdata'}=~/\/res\//)) {       if (($ENV{'request.role'}=~m/^cc\./ or $ENV{'request.role'}=~m/^in\./ or $ENV{'request.role'}=~m/^ta\./) and ($helper->{VARS}->{'postdata'}=~/\/res\//)) { 
         push @{$printChoices}, ['<b>All problems</b> in course (may take a lot of time)', 'all_problems', 'ALL_PROBLEMS'];          push @{$printChoices}, ['<b>Problems</b> in this course', 'all_problems', 'ALL_PROBLEMS'];
         push @{$printChoices}, ["Problems from <b>$sequenceTitle</b> for selected students", 'problems_for_students', 'CHOOSE_STUDENTS'];          push @{$printChoices}, ["Problems from <b>$sequenceTitle</b> for selected students", 'problems_for_students', 'CHOOSE_STUDENTS'];
   
         my $isProblem = '$res->is_problem();';          my $isProblem = '$res->is_problem();';
         my $isProblemOrMap = '$res->is_problem() || $res->is_map()';          my $isProblemOrMap = '$res->is_problem() || $res->is_map()';
         my $symb = '$res->symb();';          my $symb = '$res->symb();';
         &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS);          &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS);
   <state name="ALL_PROBLEMS" title="Select Problems">    <state name="ALL_PROBLEMS" title="Select Problem(s) to print">
     <message>Select problems to print:</message>      <message>(mark them then click "next" button) <br /></message>
     <resource variable="RESOURCES" multichoice="1">      <resource variable="RESOURCES" multichoice="1">
       <nextstate>PAGESIZE</nextstate>        <nextstate>PAGESIZE</nextstate>
       <filterfunc>return $isProblemOrMap</filterfunc>        <filterfunc>return $isProblemOrMap</filterfunc>
Line 1829  HELPERFRAGMENT Line 1839  HELPERFRAGMENT
       </resource>        </resource>
     </state>      </state>
   
   <state name="CHOOSE_STUDENTS" title="Choose Students">    <state name="CHOOSE_STUDENTS" title="Choose Students whose assignments you want to print">
     <message>Select the students you wish to print the problems for:</message>      <message>(do not forget to select assignment itself - make another selection below) <br /></message>
     <student multichoice='1' variable="STUDENTS" nextstate="PAGESIZE" />      <student multichoice='1' variable="STUDENTS" nextstate="PAGESIZE" />
       <message><br /><big><i><b>Select resources for the assignment</b></i></big><br /></message>
     <resource variable="RESOURCES" multichoice="1">      <resource variable="RESOURCES" multichoice="1">
       <filterfunc>return $isProblem</filterfunc>        <filterfunc>return $isProblem</filterfunc>
       <mapurl>$map</mapurl>        <mapurl>$map</mapurl>
       <valuefunc>return $symb</valuefunc>        <valuefunc>return $symb</valuefunc>
       </resource>        </resource>
     <message>How should the results be printed?</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'>Print students assignments without separations (as uniform flow)</choice>        <choice computer='0'>Print students assignments without separations (as uniform flow)</choice>
       <choice computer='1'>Start student assignment from new page (add pagefeed after each student)</choice>        <choice computer='1'>Start student assignment from new page (add pagefeed after each student)</choice>
Line 1850  CHOOSE_STUDENTS Line 1861  CHOOSE_STUDENTS
   
     # FIXME: That RE should come from a library somewhere.      # FIXME: That RE should come from a library somewhere.
     if (((&Apache::lonnet::allowed('bre',$subdir) eq 'F') and ($helper->{VARS}->{'postdata'}=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)/)) or defined $helper->{'VARS'}->{'construction'}) {          if (((&Apache::lonnet::allowed('bre',$subdir) eq 'F') and ($helper->{VARS}->{'postdata'}=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)/)) or defined $helper->{'VARS'}->{'construction'}) {    
         push @{$printChoices}, ["Problems from <b>$subdir</b>", 'problems_from_directory', 'CHOOSE_FROM_SUBDIR'];          push @{$printChoices}, ["Problems from current subdirectory <b>$subdir</b>", 'problems_from_directory', 'CHOOSE_FROM_SUBDIR'];
                   
         my $f = '$filename';          my $f = '$filename';
         my $xmlfrag = <<CHOOSE_FROM_SUBDIR;          my $xmlfrag = <<CHOOSE_FROM_SUBDIR;
   <state name="CHOOSE_FROM_SUBDIR" title="Select Files">    <state name="CHOOSE_FROM_SUBDIR" title="Select File(s) from <b><small>$subdir</small></b> to print">
     <message>Select problems you wish to print from <b>$subdir</b></message>      <message>(mark them then click "next" button) <br /></message>
     <files variable="FILES" multichoice='1'>      <files variable="FILES" multichoice='1'>
       <nextstate>PAGESIZE</nextstate>        <nextstate>PAGESIZE</nextstate>
       <filechoice>return '$subdir';</filechoice>        <filechoice>return '$subdir';</filechoice>
Line 1872  CHOOSE_FROM_SUBDIR Line 1883  CHOOSE_FROM_SUBDIR
     }      }
   
     # 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", "Selecting Resources to Print");      Apache::lonhelper::state->new("START", "What do you want to print? Make a choice.");
     $paramHash = Apache::lonhelper::getParamHash();      $paramHash = Apache::lonhelper::getParamHash();
     $paramHash->{MESSAGE_TEXT} = "What do you want to print?";      $paramHash->{MESSAGE_TEXT} = "";
     Apache::lonhelper::message->new();      Apache::lonhelper::message->new();
     $paramHash = Apache::lonhelper::getParamHash();      $paramHash = Apache::lonhelper::getParamHash();
     $paramHash->{'variable'} = 'PRINT_TYPE';      $paramHash->{'variable'} = 'PRINT_TYPE';
Line 1969  sub render { Line 1980  sub render {
   
     $result .= <<STATEHTML;      $result .= <<STATEHTML;
   
 <p>How should the printing be formatted?</p>  <p><big><i><b>What page format do you prefer?</b></i></big></p>
 <table cellpadding="3">  <table cellpadding="3">
   <tr>    <tr>
     <td align="center"><b>Layout</b></td>      <td align="center"><b>Page layout</b></td>
     <td align="center"><b>Columns</b></td>      <td align="center"><b>Number of columns</b></td>
     <td align="center"><b>Paper type</b></td>      <td align="center"><b>Paper type</b></td>
   </tr>    </tr>
   <tr>    <tr>
     <td>      <td>
       <input type="radio" name="${var}.layout" value="L" checked='1' /> Landscape<br />        <input type="radio" name="${var}.layout" value="L" /> Landscape<br />
       <input type="radio" name="${var}.layout" value="P" /> Portrait        <input type="radio" name="${var}.layout" value="P" checked='1'  /> Portrait
     </td>      </td>
     <td>      <td align="center">
       <select name="${var}.cols">        <select name="${var}.cols">
 STATEHTML  STATEHTML
   

Removed from v.1.154  
changed lines
  Added in v.1.158


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