Diff for /loncom/interface/lonprintout.pm between versions 1.152 and 1.161

version 1.152, 2003/05/06 13:50:23 version 1.161, 2003/05/12 18:14:01
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 1377  ENDPART Line 1359  ENDPART
  $LaTeXwidth = $1*25.4;   $LaTeXwidth = $1*25.4;
     }      }
     $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 (defined $helper->{'VARS'}->{'url'}) {   if (not defined $helper->{'VARS'}->{'construction'}) {
     $currentURL=$helper->{'VARS'}->{'url'};  
  } else {  
     $currentURL=$helper->{'VARS'}->{'postdata'};      $currentURL=$helper->{'VARS'}->{'postdata'};
    } else {
       $currentURL=$helper->{'VARS'}->{'construction'};
  }   }
  $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)$/) {
Line 1509  ENDPART Line 1490  ENDPART
     #prints selected problems from the subdirectory       #prints selected problems from the subdirectory 
  $selectionmade = 6;   $selectionmade = 6;
         my @list_of_files=split /\|\|\|/, $helper->{'VARS'}->{'FILES'};          my @list_of_files=split /\|\|\|/, $helper->{'VARS'}->{'FILES'};
    @list_of_files=sort @list_of_files;
  my $flag_latex_header_remove = 'NO';     my $flag_latex_header_remove = 'NO';  
  for (my $i=0;$i<=$#list_of_files;$i++) {   for (my $i=0;$i<=$#list_of_files;$i++) {
     my $urlp = $list_of_files[$i];      my $urlp = $list_of_files[$i];
Line 1599  sub handler { Line 1581  sub handler {
             return $result;              return $result;
         }          }
         $helper = $result;          $helper = $result;
       
   
 #    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 1707  sub printHelper { Line 1689  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
         $helper->{VARS}->{'symb'} = &Apache::lonnet::symbread($ENV{'form.postdata'});      if ($ENV{'form.postdata'} =~ /http:\/\// ) {
           $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'};
     }      }
     if ($ENV{'form.url'}) {      if ($ENV{'form.url'}) {
         $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|/[^/]+$||;
     $subdir =  '/home/httpd/html/res'.$subdir;   #needs additional work for the construction space      if (not defined $helper->{VARS}->{'construction'}) {
    $subdir =  '/home/httpd/html/res'.$subdir;   
       } else {
    $helper->{VARS}->{'construction'}=~/^([^\/]+)\/\/([^\/]+)(.*)\/[^\/]*$/;
    $subdir = $3;
    $subdir=~/\/~([^\/]+)\/(.*)$/;
    $subdir = '/home/'.$1.'/public_html/'.$2;
       }
   ####    $r->print('Dir:  '.$subdir.'  ');
   ####    return OK;
   
   
     # What can be printed is a very dynamic decision based on      # What can be printed is a very dynamic decision based on
     # lots of factors. So we need to dynamically build this list.      # lots of factors. So we need to dynamically build this list.
Line 1756  sub printHelper { Line 1775  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 ($helper->{VARS}->{'postdata'} =~ /\/res\//) {      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 1782  sub printHelper { Line 1804  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 1799  HELPERFRAGMENT Line 1821  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 1816  HELPERFRAGMENT Line 1838  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 all problems with no blank space between them</choice>        <choice computer='0'>Print students assignments without separations (as uniform flow)</choice>
       <choice computer='1'>Put each student's problems on a new page (add pagefeed after each student)</choice> <!-- ' -->        <choice computer='1'>Start student assignment from new page (add pagefeed after each student)</choice>
       <choice computer='2'>Seperate each student's problems with a full blank page</choice> <!-- ' -->        <choice computer='2'>Add one emty page after each student assignment</choice> 
       <choice computer='3'>Seperate each student's problems with two full blank pages</choice> <!-- ' -->        <choice computer='3'>Add two emty page after each student assignment</choice> 
       </choices>        </choices>
     </state>      </state>
 CHOOSE_STUDENTS  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)/)) {          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 1859  CHOOSE_FROM_SUBDIR Line 1882  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';
     $helper->declareVar('PRINT_TYPE');      $helper->declareVar('PRINT_TYPE');
     $paramHash->{CHOICES} = $printChoices;      $paramHash->{CHOICES} = $printChoices;
     Apache::lonhelper::choices->new();      Apache::lonhelper::choices->new();
   
       if (1) {
           $paramHash = Apache::lonhelper::getParamHash();
           $paramHash->{MESSAGE_TEXT} = "<hr>";
           Apache::lonhelper::message->new();
   
           $paramHash = Apache::lonhelper::getParamHash();
           $paramHash->{CHOICES} = [
                                      ['Print with answer', '1'],
                                      ['Print without answers', '0'] ];
           $paramHash->{'variable'} = 'PRINT_WITH_ANSWERS';
           Apache::lonhelper::choices->new();
       }
   
     Apache::lonprintout::page_format_state->new("FORMAT");      Apache::lonprintout::page_format_state->new("FORMAT");
   
     # Generate the PAGESIZE state which will offer the user the margin      # Generate the PAGESIZE state which will offer the user the margin
Line 1956  sub render { Line 1994  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.152  
changed lines
  Added in v.1.161


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