Diff for /loncom/interface/lonprintout.pm between versions 1.237 and 1.238

version 1.237, 2003/09/22 20:00:08 version 1.238, 2003/09/25 18:16:04
Line 1035  sub addMessage { Line 1035  sub addMessage {
     Apache::lonhelper::message->new();      Apache::lonhelper::message->new();
 }  }
   
   use Data::Dumper;
   
 sub printHelper {  sub printHelper {
     my $r = shift;      my $r = shift;
   
Line 1122  sub printHelper { Line 1124  sub printHelper {
         $helper->{VARS}->{'postdata'} = Apache::lonnet::clutter($url);          $helper->{VARS}->{'postdata'} = Apache::lonnet::clutter($url);
   
         if (!$resourceTitle) { # if the resource doesn't have a title, use the filename          if (!$resourceTitle) { # if the resource doesn't have a title, use the filename
             my $url = $helper->{VARS}->{'postdata'};              my $postdata = $helper->{VARS}->{'postdata'};
             $resourceTitle = substr($url, rindex($url, '/') + 1);              $resourceTitle = substr($postdata, rindex($postdata, '/') + 1);
         }          }
         $subdir = &Apache::lonnet::filelocation("", $url);          $subdir = &Apache::lonnet::filelocation("", $url);
     }      }
Line 1146  sub printHelper { Line 1148  sub printHelper {
     # "Remove all duplicate slashes."      # "Remove all duplicate slashes."
     $subdir =~ s|/+|/|g;      $subdir =~ s|/+|/|g;
   
       # If it's a ~ directory, convert back to /home/user/public_html
       $subdir =~ s/^~(\w+)\//\/home\/$1\/public_html\//;
   
     # 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.
     # To prevent security leaks, states are only added to the wizard      # To prevent security leaks, states are only added to the wizard
Line 1166  sub printHelper { Line 1171  sub printHelper {
   
 #    $r->print($helper->{VARS}->{'postdata'});  #    $r->print($helper->{VARS}->{'postdata'});
   
       # Useful filter strings
       my $isProblem = '$res->is_problem()';
       $isProblem .= ' && !$res->randomout()' if !$userCanSeeHidden;
       my $isProblemOrMap = '$res->is_problem() || $res->is_map()';
       my $isNotMap = '!$res->is_map()';
       $isNotMap .= ' && !$res->randomout()' if !$userCanSeeHidden;
       my $isMap = '$res->is_map()';
       my $symbFilter = '$res->symb()';
       my $urlValue = '$res->src()';
   
       $helper->declareVar('SEQUENCE');
   
       # Useful for debugging: Dump the help vars
       #$r->print(Dumper($helper->{VARS}));
       #$r->print($map);
   
     # If we're in a sequence...      # If we're in a sequence...
     if (($helper->{'VARS'}->{'construction'} ne '1') &&      if (($helper->{'VARS'}->{'construction'} ne '1') &&
  $helper->{VARS}->{'postdata'}) {   $helper->{VARS}->{'postdata'} && $sequenceTitle) {
         # Allow problems from sequence          # Allow problems from sequence
         push @{$printChoices}, ["<b>Selected problems</b> in $sequenceTitle", 'map_problems', 'CHOOSE_PROBLEMS'];          push @{$printChoices}, ["<b>Problems</b> in $sequenceTitle", 'map_problems', 'CHOOSE_PROBLEMS'];
         # Allow all resources from sequence          # Allow all resources from sequence
         push @{$printChoices}, ["<b>Selected resources</b> in $sequenceTitle", 'map_problems_pages', 'CHOOSE_PROBLEMS_HTML'];          push @{$printChoices}, ["<b>Resources</b> in $sequenceTitle", 'map_problems_pages', 'CHOOSE_PROBLEMS_HTML'];
   
         my $isProblem = '$res->is_problem()';  
  $isProblem .= ' && !$res->randomout()' if !$userCanSeeHidden;  
         my $isProblemOrMap = '$res->is_problem() || $res->is_map()';  
         my $isNotMap = '!$res->is_map()';  
  $isNotMap .= ' && !$res->randomout()' if !$userCanSeeHidden;  
         my $symb = '$res->symb()';  
         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>
Line 1187  sub printHelper { Line 1202  sub printHelper {
       <nextstate>PAGESIZE</nextstate>        <nextstate>PAGESIZE</nextstate>
       <filterfunc>return $isProblem;</filterfunc>        <filterfunc>return $isProblem;</filterfunc>
       <mapurl>$map</mapurl>        <mapurl>$map</mapurl>
       <valuefunc>return $symb;</valuefunc>        <valuefunc>return $symbFilter;</valuefunc>
       </resource>        </resource>
     </state>      </state>
   
Line 1197  sub printHelper { Line 1212  sub printHelper {
       <nextstate>PAGESIZE</nextstate>        <nextstate>PAGESIZE</nextstate>
       <filterfunc>return $isNotMap;</filterfunc>        <filterfunc>return $isNotMap;</filterfunc>
       <mapurl>$map</mapurl>        <mapurl>$map</mapurl>
       <valuefunc>return $symb;</valuefunc>        <valuefunc>return $symbFilter;</valuefunc>
       </resource>        </resource>
     </state>      </state>
 HELPERFRAGMENT  HELPERFRAGMENT
Line 1208  HELPERFRAGMENT Line 1223  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 ($userPriviledged && ($helper->{VARS}->{'postdata'}=~/\/res\//)) {       if ($userPriviledged && ($helper->{VARS}->{'postdata'}=~/\/res\//)) { 
         push @{$printChoices}, ['Selected problems from <b>entire course</b>', 'all_problems', 'ALL_PROBLEMS'];          push @{$printChoices}, ['Problems from <b>entire course</b>', 'all_problems', 'ALL_PROBLEMS'];
         push @{$printChoices}, ["Selected problems from $sequenceTitle for <b>selected students</b>", 'problems_for_students', 'CHOOSE_STUDENTS'];   if ($sequenceTitle) {
       push @{$printChoices}, ["Problems from $sequenceTitle for <b>selected students</b>", 'problems_for_students', 'CHOOSE_STUDENTS'];
    }
   
         my $isProblem = '$res->is_problem()';  
  $isProblem .= ' && !$res->randomout()' if !$userCanSeeHidden;  
         my $isProblemOrMap = '($res->is_problem() || $res->is_map())';  
  $isProblemOrMap .= ' && !$res->randomout()' if !$userCanSeeHidden;  
         my $symb = '$res->symb()';  
         &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS);          &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS);
   <state name="ALL_PROBLEMS" title="Select Problem(s) to print">    <state name="ALL_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>
Line 1224  HELPERFRAGMENT Line 1236  HELPERFRAGMENT
       <nextstate>PAGESIZE</nextstate>        <nextstate>PAGESIZE</nextstate>
       <filterfunc>return $isProblemOrMap;</filterfunc>        <filterfunc>return $isProblemOrMap;</filterfunc>
       <choicefunc>return $isProblem;</choicefunc>        <choicefunc>return $isProblem;</choicefunc>
       <valuefunc>return $symb;</valuefunc>        <valuefunc>return $symbFilter;</valuefunc>
       </resource>        </resource>
     </state>      </state>
   
Line 1234  HELPERFRAGMENT Line 1246  HELPERFRAGMENT
     <resource variable="RESOURCES" multichoice="1" addstatus="1">      <resource variable="RESOURCES" multichoice="1" addstatus="1">
       <filterfunc>return $isProblem</filterfunc>        <filterfunc>return $isProblem</filterfunc>
       <mapurl>$map</mapurl>        <mapurl>$map</mapurl>
       <valuefunc>return $symb</valuefunc>        <valuefunc>return $symbFilter</valuefunc>
       </resource>        </resource>
     <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">
Line 1248  CHOOSE_STUDENTS Line 1260  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'}) and $ENV{'request.role.adv'}) {          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'}) and $ENV{'request.role.adv'} and $subdir ne '/home/httpd/html/res/') {    
         push @{$printChoices}, ["Problems from current subdirectory <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 File(s) from <b><small>$subdir</small></b> to print">    <state name="CHOOSE_FROM_SUBDIR" title="Select File(s) from <b><small>$subdir</small></b> to print">
Line 1260  CHOOSE_STUDENTS Line 1272  CHOOSE_STUDENTS
       <filechoice>return '$subdir';</filechoice>        <filechoice>return '$subdir';</filechoice>
 CHOOSE_FROM_SUBDIR  CHOOSE_FROM_SUBDIR
                   
           # this is broken up because I really want interpolation above,
           # and I really DON'T want it below
         $xmlfrag .= <<'CHOOSE_FROM_SUBDIR';          $xmlfrag .= <<'CHOOSE_FROM_SUBDIR';
       <filefilter>return Apache::lonhelper::files::not_old_version($filename) &&        <filefilter>return Apache::lonhelper::files::not_old_version($filename) &&
   $filename =~ m/\.(problem|exam|quiz|assess|survey|form|library)$/;    $filename =~ m/\.(problem|exam|quiz|assess|survey|form|library)$/;
Line 1270  CHOOSE_FROM_SUBDIR Line 1284  CHOOSE_FROM_SUBDIR
         &Apache::lonxml::xmlparse($r, 'helper', $xmlfrag);          &Apache::lonxml::xmlparse($r, 'helper', $xmlfrag);
     }      }
   
       # Allow the user to select any sequence in the course, feed it to
       # another resource selector for that sequence
       push @$printChoices, ["Resources from <b>selected sequence</b> in course",
                             'map_problems_pages', 'CHOOSE_SEQUENCE'];
       &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_FROM_ANY_SEQUENCE);
     <state name="CHOOSE_SEQUENCE" title="Select Sequence To Print From">
       <message>Select the sequence to print resources from:</message>
       <resource variable="SEQUENCE">
         <nextstate>CHOOSE_FROM_ANY_SEQUENCE</nextstate>
         <filterfunc>return \$res->is_sequence;</filterfunc>
         <valuefunc>return $urlValue;</valuefunc>
         </resource>
       </state>
     <state name="CHOOSE_FROM_ANY_SEQUENCE" title="Select Resources To Print">
       <message>(mark desired resources then click "next" button) <br /></message>
       <resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1">
         <nextstate>PAGESIZE</nextstate>
         <filterfunc>return $isProblem</filterfunc>
         <mapurl evaluate='1'>return $helper->{VARS}->{'SEQUENCE'};</mapurl>
         <valuefunc>return $symbFilter;</valuefunc>
         </resource>
       </state>
   CHOOSE_FROM_ANY_SEQUENCE
   
     # 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", "Select Printing Options:");      Apache::lonhelper::state->new("START", "Select Printing Options:");
     $paramHash = Apache::lonhelper::getParamHash();      $paramHash = Apache::lonhelper::getParamHash();

Removed from v.1.237  
changed lines
  Added in v.1.238


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