Diff for /loncom/interface/lonprintout.pm between versions 1.347 and 1.371

version 1.347, 2005/01/04 13:58:34 version 1.371, 2005/03/28 12:14:13
Line 1 Line 1
 # The LearningOnline Network  #  The LearningOnline Network
 # Printout  # Printout
 #  #
 # $Id$  # $Id$
Line 42  use Apache::lonratedt; Line 42  use Apache::lonratedt;
 use POSIX qw(strftime);  use POSIX qw(strftime);
 use Apache::lonlocal;  use Apache::lonlocal;
   
 my $LaTeXwidth = 0;  
   
   
 #   Compare two students by name.  The students are in the form  #   Compare two students by name.  The students are in the form
 #   returned by the helper:  #   returned by the helper:
 #      user:domain:section:last,   first:status  #      user:domain:section:last,   first:status
Line 432  sub character_chart { Line 429  sub character_chart {
 my %page_formats=  my %page_formats=
     ('letter' => {      ('letter' => {
  'book' => {   'book' => {
      '1' => [ '7.1 in','10.0 in', '-0.57 in','-0.57 in','1 cm'],       '1' => [ '7.1 in','9.8 in', '-0.57 in','-0.57 in','0.7 cm'],
      '2' => ['3.66 in','10.0 in', '-0.57 in','-0.57 in','1 cm']       '2' => ['3.66 in','9.8 in', '-0.57 in','-0.57 in','0.7 cm']
  },   },
  'album' => {   'album' => {
      '1' => [ '8.8 in', '6.8 in','-40 pt in',  '-60 pt','1 cm'],       '1' => [ '8.8 in', '6.8 in','-40 pt in',  '-60 pt','1 cm'],
Line 698  sub IndexCreation { Line 695  sub IndexCreation {
 sub print_latex_header {  sub print_latex_header {
     my $mode=shift;      my $mode=shift;
     my $output='\documentclass[letterpaper]{article}';      my $output='\documentclass[letterpaper]{article}';
     if ($mode eq 'batchmode') {      if (($mode eq 'batchmode') || (!$ENV{'request.role.adv'})) {
  $output.='\batchmode';   $output.='\batchmode';
     }      }
     $output.='\newcommand{\keephidden}[1]{}\renewcommand{\deg}{$^{\circ}$}'."\n".      $output.='\newcommand{\keephidden}[1]{}\renewcommand{\deg}{$^{\circ}$}'."\n".
Line 726  sub path_to_problem { Line 723  sub path_to_problem {
     my $newurlp = '';      my $newurlp = '';
     $colwidth=~s/\s*mm\s*$//;      $colwidth=~s/\s*mm\s*$//;
 #characters average about 2 mm in width  #characters average about 2 mm in width
     if (length($urlp)*2 > $LaTeXwidth) {      if (length($urlp)*2 > $colwidth) {
  my @elements = split '/',$urlp;   my @elements = split '/',$urlp;
  my $curlength=0;   my $curlength=0;
  foreach my $element (@elements) {   foreach my $element (@elements) {
Line 784  sub unsupported { Line 781  sub unsupported {
 }  }
   
   
   #
   #   Retrieve the hash of page breaks.
   #
   #  Inputs:
   #    helper   - reference to helper object.
   #  Outputs
   #    A reference to a page break hash.
   #
   #
   
   sub get_page_breaks  {
       my ($helper) = @_;
       my %page_breaks;
       
       foreach my $break (split /\|\|\|/, $helper->{'VARS'}->{'FINISHPAGE'}) {
    $page_breaks{$break} = 1;
       }
       
       return %page_breaks;
   }
   
 sub output_data {  sub output_data {
     my ($r,$helper,$rparmhash) = @_;      my ($r,$helper,$rparmhash) = @_;
     my %parmhash = %$rparmhash;      my %parmhash = %$rparmhash;
       my $html=&Apache::lonxml::xmlbegin();
     my $bodytag=&Apache::loncommon::bodytag('Preparing Printout');      my $bodytag=&Apache::loncommon::bodytag('Preparing Printout');
     $r->print(<<ENDPART);      $r->print(<<ENDPART);
 <html>  $html
 <script type="text/javascript" language="Javascript" >  <head>
   <script type="text/javascript" language="Javascript">
     var editbrowser;      var editbrowser;
     function openbrowser(formname,elementname,only,omit) {      function openbrowser(formname,elementname,only,omit) {
         var url = '/res/?';          var url = '/res/?';
Line 814  sub output_data { Line 834  sub output_data {
         editbrowser.focus();          editbrowser.focus();
     }      }
 </script>  </script>
 <head>  
 <title>LON-CAPA output for printing</title>  <title>LON-CAPA output for printing</title>
 </head>  </head>
 $bodytag  $bodytag
 Please stand by while processing your print request, this may take some time ...  Please stand by while processing your print request, this may take some time ...
 ENDPART  ENDPART
   
   
       # fetch the pagebreaks and store them in the course environment
       # The page breaks will be pulled into the hash %page_breaks which is
       # indexed by symb and contains 1's for each break.
   
       $ENV{'form.pagebreaks'}  = $helper->{'VARS'}->{'FINISHPAGE'};
       $ENV{'form.lastprinttype'} = $helper->{'VARS'}->{'PRINT_TYPE'}; 
       &Apache::loncommon::store_course_settings('print',
         {'pagebreaks'    => 'scalar',
          'lastprinttype' => 'scalar'});
   
       my %page_breaks  = &get_page_breaks($helper);
   
     my $format_from_helper = $helper->{'VARS'}->{'FORMAT'};      my $format_from_helper = $helper->{'VARS'}->{'FORMAT'};
     my ($result,$selectionmade) = ('','');      my ($result,$selectionmade) = ('','');
     my $number_of_columns = 1; #used only for pages to determine the width of the cell      my $number_of_columns = 1; #used only for pages to determine the width of the cell
Line 836  ENDPART Line 868  ENDPART
     my $LaTeXwidth=&recalcto_mm($textwidth);       my $LaTeXwidth=&recalcto_mm($textwidth); 
     my @print_array=();      my @print_array=();
     my @student_names=();      my @student_names=();
   
       #  Common settings for the %form has:
       # In some cases these settings get overriddent by specific cases, but the
       # settings are common enough to make it worthwhile factoring them out
       # here.
       #
       my %form;
       $form{'grade_target'} = 'tex';
       $form{'textwidth'}    = &get_textwidth($helper, $LaTeXwidth);
           
     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 863  ENDPART Line 904  ENDPART
     my $user = $ENV{'user.name'};      my $user = $ENV{'user.name'};
     my $put_result = &Apache::lonnet::put('environment',{'construct.style'=>$helper->{'VARS'}->{'style_file'}},$dom,$user);      my $put_result = &Apache::lonnet::put('environment',{'construct.style'=>$helper->{'VARS'}->{'style_file'}},$dom,$user);
  }   }
  my %form;  
                 if ($helper->{'VARS'}->{'probstatus'} eq 'exam') {$form{'problemtype'}='exam';}                  if ($helper->{'VARS'}->{'probstatus'} eq 'exam') {$form{'problemtype'}='exam';}
  $form{'grade_target'}='tex';  
  $form{'textwidth'}=&get_textwidth($helper,$LaTeXwidth);  
  $form{'problem_split'}=$parmhash{'problem_stream_switch'};   $form{'problem_split'}=$parmhash{'problem_stream_switch'};
  $form{'suppress_tries'}=$parmhash{'suppress_tries'};   $form{'suppress_tries'}=$parmhash{'suppress_tries'};
  $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};   $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
Line 885  ENDPART Line 923  ENDPART
     }      }
     if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||      if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||
        ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {         ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {
  my %form;   $form{'problem_split'}=$parmhash{'problem_stream_switch'};
  $form{'grade_target'}='answer';   $form{'grade_target'}='answer';
  $form{'answer_output_mode'}='tex';   $form{'answer_output_mode'}='tex';
  $form{'rndseed'}=$rndseed;   $form{'rndseed'}=$rndseed;
Line 932  ENDPART Line 970  ENDPART
  if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm)$/) {   if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm)$/) {
     my $texversion='';      my $texversion='';
     if ($helper->{'VARS'}->{'ANSWER_TYPE'} ne 'only') {      if ($helper->{'VARS'}->{'ANSWER_TYPE'} ne 'only') {
  my %form;  
  $form{'grade_target'}='tex';  
  $form{'textwidth'}=&get_textwidth($helper,$LaTeXwidth);  
  $form{'problem_split'}=$parmhash{'problem_stream_switch'};   $form{'problem_split'}=$parmhash{'problem_stream_switch'};
  $form{'suppress_tries'}=$parmhash{'suppress_tries'};   $form{'suppress_tries'}=$parmhash{'suppress_tries'};
  $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};   $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
Line 944  ENDPART Line 979  ENDPART
     if((($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||      if((($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||
        ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) &&          ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) && 
        ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page)$/)) {         ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page)$/)) {
  my %form;  
  $form{'grade_target'}='answer';   $form{'grade_target'}='answer';
  $form{'answer_output_mode'}='tex';   $form{'answer_output_mode'}='tex';
  $form{'rndseed'}=$rndseed;   $form{'rndseed'}=$rndseed;
    $form{'problem_split'}=$parmhash{'problem_stream_switch'};
                         if ($urlp=~/\/res\//) {$ENV{'request.state'}='published';}                          if ($urlp=~/\/res\//) {$ENV{'request.state'}='published';}
  my $answer=&Apache::lonnet::ssi($urlp,%form);   my $answer=&Apache::lonnet::ssi($urlp,%form);
  if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {   if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
Line 979  ENDPART Line 1014  ENDPART
     if ($helper->{VARS}->{'construction'} eq '1') {$result=~s/(\\begin{document})/$1 \\fbox\{RANDOM SEED IS $rndseed\} /;}      if ($helper->{VARS}->{'construction'} eq '1') {$result=~s/(\\begin{document})/$1 \\fbox\{RANDOM SEED IS $rndseed\} /;}
     $result .= '\end{document}';         $result .= '\end{document}';   
  } elsif ($cleanURL=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) {    } elsif ($cleanURL=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { 
  my %form;  
  $form{'grade_target'}='tex';  
  $form{'textwidth'}=&get_textwidth($helper,$LaTeXwidth);  
  $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};   $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
  if ($currentURL=~/\/syllabus$/) {$currentURL=~s/\/res//;}   if ($currentURL=~/\/syllabus$/) {$currentURL=~s/\/res//;}
  my $texversion=&Apache::lonnet::ssi($currentURL,%form);   my $texversion=&Apache::lonnet::ssi($currentURL,%form);
Line 989  ENDPART Line 1021  ENDPART
  } else {   } else {
     $result.=&unsupported($currentURL,$helper->{'VARS'}->{'LATEX_TYPE'});      $result.=&unsupported($currentURL,$helper->{'VARS'}->{'LATEX_TYPE'});
  }   }
     } elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') or      } elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems')       or
              ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') or               ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') or
              ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems') or               ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems')       or
        ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_resources')      or # BUGBUG
      ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'select_sequences')) {        ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'select_sequences')) { 
         #-- produce an output string          #-- produce an output string
  if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') {   if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') {
Line 1000  ENDPART Line 1033  ENDPART
     $selectionmade = 3;      $selectionmade = 3;
  } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems') {   } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems') {
     $selectionmade = 4;      $selectionmade = 4;
    } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_resources') {  #BUGBUG
       $selectionmade = 4;
  } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'select_sequences') {   } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'select_sequences') {
     $selectionmade = 7;      $selectionmade = 7;
  }   }
  my %form=();     
  $form{'grade_target'}='tex';  
  $form{'textwidth'}=&get_textwidth($helper,$LaTeXwidth);  
  $form{'problem_split'}=$parmhash{'problem_stream_switch'};   $form{'problem_split'}=$parmhash{'problem_stream_switch'};
  $form{'suppress_tries'}=$parmhash{'suppress_tries'};   $form{'suppress_tries'}=$parmhash{'suppress_tries'};
  $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};   $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
Line 1018  ENDPART Line 1050  ENDPART
  &Apache::lonnet::delenv('form.counter');   &Apache::lonnet::delenv('form.counter');
  &Apache::lonxml::init_counter();   &Apache::lonxml::init_counter();
  for (my $i=0;$i<=$#master_seq;$i++) {   for (my $i=0;$i<=$#master_seq;$i++) {
   
       # Note due to document structure, not allowed to put \newpage
       # prior to the first resource
   
       if (defined $page_breaks{$master_seq[$i]}) {
    if($i != 0) {
       $result.="\\newpage\n";
    }
       }
     my (undef,undef,$urlp)=&Apache::lonnet::decode_symb($master_seq[$i]);      my (undef,undef,$urlp)=&Apache::lonnet::decode_symb($master_seq[$i]);
     $urlp=&Apache::lonnet::clutter($urlp);      $urlp=&Apache::lonnet::clutter($urlp);
     $form{'symb'}=$master_seq[$i];      $form{'symb'}=$master_seq[$i];
Line 1042  ENDPART Line 1083  ENDPART
  my $current_counter=$ENV{'form.counter'};   my $current_counter=$ENV{'form.counter'};
  if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||   if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||
    ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {     ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {
     my %form;  
     $form{'grade_target'}='answer';      $form{'grade_target'}='answer';
     $form{'answer_output_mode'}='tex';      $form{'answer_output_mode'}='tex';
     my $answer=&Apache::lonnet::ssi($urlp,%form);      my $answer=&Apache::lonnet::ssi($urlp,%form);
Line 1078  ENDPART Line 1118  ENDPART
  $result .= $texversion;   $result .= $texversion;
  $flag_latex_header_remove = 'YES';      $flag_latex_header_remove = 'YES';   
     } elsif ($urlp=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) {       } elsif ($urlp=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { 
  my %form;  
  $form{'grade_target'}='tex';  
  $form{'textwidth'}=&get_textwidth($helper,$LaTeXwidth);  
  $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};   $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
  if ($urlp=~/\/syllabus$/) {$urlp=~s/\/res//;}   if ($urlp=~/\/syllabus$/) {$urlp=~s/\/res//;}
  my $texversion=&Apache::lonnet::ssi($urlp,%form);   my $texversion=&Apache::lonnet::ssi($urlp,%form);
Line 1110  ENDPART Line 1147  ENDPART
  $result .= '\end{document}';   $result .= '\end{document}';
      } elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_students') ||       } elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_students') ||
       ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_students')){        ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_students')){
   
   
      #-- prints assignments for whole class or for selected students         #-- prints assignments for whole class or for selected students  
  my $type;   my $type;
  if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_students') {   if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_students') {
Line 1135  ENDPART Line 1174  ENDPART
      $helper->{'VARS'}->{'NUMBER_TO_PRINT'}=$#students+1;       $helper->{'VARS'}->{'NUMBER_TO_PRINT'}=$#students+1;
  }   }
  my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'};   my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'};
   
  #loop over students   #loop over students
  my $flag_latex_header_remove = 'NO';    my $flag_latex_header_remove = 'NO'; 
  my %moreenv;   my %moreenv;
          $moreenv{'instructor_comments'}='hide';           $moreenv{'instructor_comments'}='hide';
  $moreenv{'textwidth'}=&get_textwidth($helper,$LaTeXwidth);   $moreenv{'textwidth'}=&get_textwidth($helper,$LaTeXwidth);
  $moreenv{'print_discussions'}=$helper->{'VARS'}->{'PRINT_DISCUSSIONS'};   $moreenv{'print_discussions'}=$helper->{'VARS'}->{'PRINT_DISCUSSIONS'};
    $moreenv{'problem_split'}    = $parmhash{'problem_stream_switch'};
    $moreenv{'suppress_tries'}   = $parmhash{'suppress_tries'};
  if ($helper->{'VARS'}->{'PRINT_DISCUSSIONS'} eq 'yes') {$moreenv{'problem_split'}='yes';}   if ($helper->{'VARS'}->{'PRINT_DISCUSSIONS'} eq 'yes') {$moreenv{'problem_split'}='yes';}
  my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$#students+1,'inline','75');   my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$#students+1,'inline','75');
  my $student_counter=-1;   my $student_counter=-1;
  foreach my $person (@students) {   foreach my $person (@students) {
   
              my $duefile="/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.due";               my $duefile="/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.due";
      if (-e $duefile) {       if (-e $duefile) {
  my $temp_file = Apache::File->new('>>'.$duefile);   my $temp_file = Apache::File->new('>>'.$duefile);
Line 1152  ENDPART Line 1195  ENDPART
      }       }
      $student_counter++;       $student_counter++;
      my $i=int($student_counter/$helper->{'VARS'}{'NUMBER_TO_PRINT'});       my $i=int($student_counter/$helper->{'VARS'}{'NUMBER_TO_PRINT'});
      my ($output,$fullname)=&print_resources($r,$helper,$person,$type,\%moreenv,\@master_seq,$flag_latex_header_remove);       my ($output,$fullname)=&print_resources($r,$helper,
        $person,$type,
        \%moreenv,\@master_seq,
        $flag_latex_header_remove,
        $LaTeXwidth);
      $print_array[$i].=$output;       $print_array[$i].=$output;
      $student_names[$i].=$person.':'.$fullname.'_END_';       $student_names[$i].=$person.':'.$fullname.'_END_';
      &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,&mt('last student').' '.$fullname);       &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,&mt('last student').' '.$fullname);
Line 1169  ENDPART Line 1216  ENDPART
  my $code_name=$helper->{'VARS'}->{'ANON_CODE_STORAGE_NAME'};   my $code_name=$helper->{'VARS'}->{'ANON_CODE_STORAGE_NAME'};
  my $old_name=$helper->{'VARS'}->{'REUSE_OLD_CODES'};   my $old_name=$helper->{'VARS'}->{'REUSE_OLD_CODES'};
  my %moreenv = ('textwidth' => &get_textwidth($helper,$LaTeXwidth));   my %moreenv = ('textwidth' => &get_textwidth($helper,$LaTeXwidth));
    $moreenv{'problem_split'}    = $parmhash{'problem_stream_switch'};
  my $seed=time+($$<<16)+($$);   my $seed=time+($$<<16)+($$);
  my @allcodes;   my @allcodes;
  if ($old_name) {   if ($old_name) {
Line 1202  ENDPART Line 1250  ENDPART
      $moreenv{'CODE'}=&num_to_letters($code);       $moreenv{'CODE'}=&num_to_letters($code);
      my ($output,$fullname)=       my ($output,$fullname)=
  &print_resources($r,$helper,'anonymous',$type,\%moreenv,   &print_resources($r,$helper,'anonymous',$type,\%moreenv,
   \@master_seq,$flag_latex_header_remove);    \@master_seq,$flag_latex_header_remove,
     $LaTeXwidth);
      $print_array[$file_num].=$output;       $print_array[$file_num].=$output;
      &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,       &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
        &mt('last assignment').' '.$fullname);         &mt('last assignment').' '.$fullname);
Line 1226  ENDPART Line 1275  ENDPART
     my $urlp = $list_of_files[$i];      my $urlp = $list_of_files[$i];
     $urlp=~s|//|/|;      $urlp=~s|//|/|;
     if ($urlp=~/\//) {      if ($urlp=~/\//) {
  my %form;   $form{'problem_split'}=$parmhash{'problem_stream_switch'};
  $form{'grade_target'}='tex';  
  $form{'textwidth'}=&get_textwidth($helper,$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 1238  ENDPART Line 1285  ENDPART
  my $texversion=&Apache::lonnet::ssi($urlp,%form);   my $texversion=&Apache::lonnet::ssi($urlp,%form);
  if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||   if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||
    ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {     ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {
     my %form;  
     $form{'grade_target'}='answer';      $form{'grade_target'}='answer';
     $form{'answer_output_mode'}='tex';      $form{'answer_output_mode'}='tex';
     $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};      $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
Line 1295  ENDPART Line 1341  ENDPART
  $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;
     my $identifier = &Apache::loncommon::get_cgi_id();      my $identifier = &Apache::loncommon::get_cgi_id();
Line 1402  sub get_CODE { Line 1449  sub get_CODE {
 }  }
   
 sub print_resources {  sub print_resources {
     my ($r,$helper,$person,$type,$moreenv,$master_seq,$remove_latex_header)=@_;      my ($r,$helper,$person,$type,$moreenv,$master_seq,$remove_latex_header,
    $LaTeXwidth)=@_;
     my $current_output = '';       my $current_output = ''; 
     my ($username,$userdomain,$usersection) = split /:/,$person;      my ($username,$userdomain,$usersection) = split /:/,$person;
     my $fullname = &get_name($username,$userdomain);      my $fullname = &get_name($username,$userdomain);
Line 1411  sub print_resources { Line 1459  sub print_resources {
  $namepostfix="\\\\Name: ";   $namepostfix="\\\\Name: ";
  $fullname = "CODE - ".$moreenv->{'CODE'};   $fullname = "CODE - ".$moreenv->{'CODE'};
     }      }
       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   
     &Apache::lonnet::delenv('form.counter');      &Apache::lonnet::delenv('form.counter');
     &Apache::lonxml::init_counter();      &Apache::lonxml::init_counter();
   
       my %page_breaks  = &get_page_breaks($helper);
   
     foreach my $curresline (@{$master_seq})  {      foreach my $curresline (@{$master_seq})  {
    if (defined $page_breaks{$curresline}) {
       if($i != 0) {
    $current_output.= "\\newpage\n";
       }
    }
    $i++;
  if ( !($type eq 'problems' &&    if ( !($type eq 'problems' && 
        ($curresline!~ m/\.(problem|exam|quiz|assess|survey|form|library)$/)) ) {         ($curresline!~ m/\.(problem|exam|quiz|assess|survey|form|library)$/)) ) {
     my ($map,$id,$res_url) = &Apache::lonnet::decode_symb($curresline);      my ($map,$id,$res_url) = &Apache::lonnet::decode_symb($curresline);
Line 1520  sub handler { Line 1578  sub handler {
 # return OK;  # return OK;
   
     my %parmhash=&Apache::lonnet::coursedescription($ENV{'request.course.id'});      my %parmhash=&Apache::lonnet::coursedescription($ENV{'request.course.id'});
        
 # my $key;   # my $key; 
 # foreach $key (keys %parmhash) {  # foreach $key (keys %parmhash) {
 #    $r->print(' '.$key.'->'.$parmhash{$key}.'<-<br />');  #    $r->print(' '.$key.'->'.$parmhash{$key}.'<-<br />');
 # }  # }
 # return OK;  #
   
   
       #  If a figure conversion queue file exists for this user.domain
       # we delete it since it can only be bad (if it were good, printout.pl
       # would have deleted it the last time around.
   
       my $conversion_queuefile = "/home/httpd/prtspool/$ENV{'user.name'}_$ENV{'user.domain'}_printout.dat";
       if(-e $conversion_queuefile) {
    unlink $conversion_queuefile;
       }
     &output_data($r,$helper,\%parmhash);      &output_data($r,$helper,\%parmhash);
     return OK;      return OK;
 }   } 
Line 1580  sub printHelper { Line 1647  sub printHelper {
     $helper->declareVar('assignment');      $helper->declareVar('assignment');
     $helper->declareVar('style_file');      $helper->declareVar('style_file');
     $helper->declareVar('student_sort');      $helper->declareVar('student_sort');
       $helper->declareVar('FINISHPAGE');
       $helper->declareVar('PRINT_TYPE');
   
       #  The page breaks can get loaded initially from the course environment:
   
       if((!defined($ENV{"form.CURRENT_STATE"}))  ||
          ($ENV{'form.CURRENT_STATE'} == "START")) {
    $helper->{VARS}->{FINISHPAGE} = ""; # In case they did a back e.g.
       }
   
   
       
       &Apache::loncommon::restore_course_settings('print',
    {'pagebreaks'  => 'scalar',
            'lastprinttype' => 'scalar'});
   
       
       if("$helper->{VARS}->{PRINT_TYPE}" eq "$ENV{'form.lastprinttype'}") {
    $helper->{VARS}->{FINISHPAGE} = $ENV{'form.pagebreaks'};
       }
       
           
     # 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.
Line 1687  sub printHelper { Line 1775  sub printHelper {
     $helper->declareVar('SEQUENCE');      $helper->declareVar('SEQUENCE');
   
     # Useful for debugging: Dump the help vars      # Useful for debugging: Dump the help vars
     #$r->print(Dumper($helper->{VARS}));  #    $r->print(Dumper($helper->{VARS}));
     #$r->print($map);  #    $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'} &&
  $helper->{VARS}->{'assignment'}) {   $helper->{VARS}->{'assignment'}) {
         # Allow problems from sequence          # Allow problems from sequence
Line 1708  sub printHelper { Line 1797  sub printHelper {
       <filterfunc>return $isProblem;</filterfunc>        <filterfunc>return $isProblem;</filterfunc>
       <mapurl>$map</mapurl>        <mapurl>$map</mapurl>
       <valuefunc>return $symbFilter;</valuefunc>        <valuefunc>return $symbFilter;</valuefunc>
       <option text='End Page' variable='FINISHPAGE' />        <option text='Newpage' variable='FINISHPAGE' />
       </resource>        </resource>
     </state>      </state>
   
Line 1720  sub printHelper { Line 1809  sub printHelper {
       <filterfunc>return $isNotMap;</filterfunc>        <filterfunc>return $isNotMap;</filterfunc>
       <mapurl>$map</mapurl>        <mapurl>$map</mapurl>
       <valuefunc>return $symbFilter;</valuefunc>        <valuefunc>return $symbFilter;</valuefunc>
       <option text='End Page' variable='FINISHPAGE' />        <option text='Newpage' variable='FINISHPAGE' />
       </resource>        </resource>
     </state>      </state>
 HELPERFRAGMENT  HELPERFRAGMENT
Line 1728  HELPERFRAGMENT Line 1817  HELPERFRAGMENT
  &Apache::lonxml::xmlparse($r, 'helper', $helperFragment);   &Apache::lonxml::xmlparse($r, 'helper', $helperFragment);
     }      }
   
     # If the user is priviledged, allow them to print all       # If the user is privileged, allow them to print all 
     # problems in the course, optionally for selected students      # problems and resources  in the entier course, optionally for selected students
     if ($userPriviledged &&       if ($userPriviledged && 
         ($helper->{VARS}->{'postdata'}=~/\/res\// || $helper->{VARS}->{'postdata'}=~/\/(syllabus|smppg|aboutme|bulletinboard)$/)) {           ($helper->{VARS}->{'postdata'}=~/\/res\// || $helper->{VARS}->{'postdata'}=~/\/(syllabus|smppg|aboutme|bulletinboard)$/)) { 
   
         push @{$printChoices}, ['<b>Problems</b> from <b>entire course</b>', 'all_problems', 'ALL_PROBLEMS'];          push @{$printChoices}, ['<b>Problems</b> from <b>entire course</b>', 'all_problems', 'ALL_PROBLEMS'];
    push @{$printChoices}, ['<b>Resources</b> from <b>entire course</b>', 'all_resources', 'ALL_RESOURCES'];
          &Apache::lonxml::xmlparse($r, 'helper', <<ALL_PROBLEMS);           &Apache::lonxml::xmlparse($r, 'helper', <<ALL_PROBLEMS);
   <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 1742  HELPERFRAGMENT Line 1833  HELPERFRAGMENT
       <filterfunc>return $isProblemOrMap;</filterfunc>        <filterfunc>return $isProblemOrMap;</filterfunc>
       <choicefunc>return $isNotMap;</choicefunc>        <choicefunc>return $isNotMap;</choicefunc>
       <valuefunc>return $symbFilter;</valuefunc>        <valuefunc>return $symbFilter;</valuefunc>
       <option text='End Page' variable='FINISHPAGE' />        <option text='Newpage' variable='FINISHPAGE' />
       </resource>
     </state>
     <state name="ALL_RESOURCES" title="Select Resource(s) to print">
       <message>(Mark them then click "next" button) <br /> </message>
       <resource variable="RESOURCES" toponly='0' multichoice='1'
                 suppressEmptySequences='0' addstatus='1' closeallpages='1'>
         <nextstate>PAGESIZE</nextstate>
         <filterfunc>return $isNotMap; </filterfunc>
         <valuefunc>return $symbFilter;</valuefunc>
         <option text='NewPage' variable='FINISHPAGE' />
     </resource>      </resource>
   </state>    </state>
 ALL_PROBLEMS  ALL_PROBLEMS
Line 1758  ALL_PROBLEMS Line 1859  ALL_PROBLEMS
       <filterfunc>return $isProblem;</filterfunc>        <filterfunc>return $isProblem;</filterfunc>
       <mapurl>$map</mapurl>        <mapurl>$map</mapurl>
       <valuefunc>return $symbFilter;</valuefunc>        <valuefunc>return $symbFilter;</valuefunc>
       <option text='End Page' variable='FINISHPAGE'>        <option text='New Page' variable='FINISHPAGE' />
       </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 1773  RESOURCE_SELECTOR Line 1874  RESOURCE_SELECTOR
   
         &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS);          &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS);
   <state name="CHOOSE_STUDENTS" title="Select Students and Resources">    <state name="CHOOSE_STUDENTS" title="Select Students and Resources">
       <student multichoice='1' variable="STUDENTS" nextstate="PAGESIZE" />        <student multichoice='1' variable="STUDENTS" nextstate="PAGESIZE" coursepersonnel="1"/>
         <message><b>Select sort order</b> </message>
     <choices variable='student_sort'>      <choices variable='student_sort'>
       <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>
Line 1793  CHOOSE_STUDENTS Line 1895  CHOOSE_STUDENTS
         &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_ANON1);          &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_ANON1);
   <state name="CHOOSE_ANON1" title="Select Students and Resources">    <state name="CHOOSE_ANON1" title="Select Students and Resources">
     <nextstate>PAGESIZE</nextstate>      <nextstate>PAGESIZE</nextstate>
     <message><hr width='33%' /><b>Number of anonymous assignments to print?</b></message>      <message><hr width='33%' /></message>
     <string variable="NUMBER_TO_PRINT_TOTAL" maxlength="5" size="5"></string>      <message><table><tr><td><b>Number of anonymous assignments to print?</b></td><td></message>
     <message><br /><b>Names to store the CODEs under for later:</b></message>      <string variable="NUMBER_TO_PRINT_TOTAL" maxlength="5" size="5">
          <validator>
    if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) &&
       !\$helper->{'VARS'}{'REUSE_OLD_CODES'}) {
       return "You need to specify the number of assignments to print";
    }
    return undef;
          </validator>
       </string>
       <message></td></tr><tr><td></message>
       <message><b>Names to store the CODEs under for later:</b></message>
       <message></td><td></message>
     <string variable="ANON_CODE_STORAGE_NAME" maxlength="50" size="20" />      <string variable="ANON_CODE_STORAGE_NAME" maxlength="50" size="20" />
       <message></td></tr></table></message>
     <message><hr width='33%' /></message>      <message><hr width='33%' /></message>
     <message><b>Reprint a set of saved CODEs:</b></message>      <message><b>Reprint a set of saved CODEs:</b></message>
     <dropdown variable="REUSE_OLD_CODES">      <dropdown variable="REUSE_OLD_CODES">
Line 1821  CHOOSE_ANON1 Line 1935  CHOOSE_ANON1
       <filterfunc>return $isNotMap;</filterfunc>        <filterfunc>return $isNotMap;</filterfunc>
       <mapurl>$map</mapurl>        <mapurl>$map</mapurl>
       <valuefunc>return $symbFilter;</valuefunc>        <valuefunc>return $symbFilter;</valuefunc>
       <option text='End Page' variable='FINISHPAGE'>        <option text='Newpage' variable='FINISHPAGE' />
       </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 1836  RESOURCE_SELECTOR Line 1950  RESOURCE_SELECTOR
   
  &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS1);   &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS1);
   <state name="CHOOSE_STUDENTS1" title="Select Students and Resources">    <state name="CHOOSE_STUDENTS1" title="Select Students and Resources">
     <student multichoice='1' variable="STUDENTS" nextstate="PAGESIZE" />      <student multichoice='1' variable="STUDENTS" nextstate="PAGESIZE" coursepersonnel="1" />
     <choices variable='student_sort'>      <choices variable='student_sort'>
       <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>
Line 1849  CHOOSE_STUDENTS1 Line 1963  CHOOSE_STUDENTS1
  &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_ANON2);   &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_ANON2);
   <state name="CHOOSE_ANON2" title="Select Students and Resources">    <state name="CHOOSE_ANON2" title="Select Students and Resources">
     <nextstate>PAGESIZE</nextstate>      <nextstate>PAGESIZE</nextstate>
     <message><hr width='33%' /><b>Number of anonymous assignments to print?</b></message>      <message><table><tr><td><b>Number of anonymous assignments to print?</b></td><td></message>
     <string variable="NUMBER_TO_PRINT_TOTAL" maxlength="5" size="5"></string>      <string variable="NUMBER_TO_PRINT_TOTAL" maxlength="5" size="5">
     <message><br /><b>Names to store the CODEs under for later:</b></message>         <validator>
    if (((\$helper->{'VARS'}{'NUMBER_TO_PRINT_TOTAL'}+0) < 1) &&
       !\$helper->{'VARS'}{'REUSE_OLD_CODES'}) {
       return "You need to specify the number of assignments to print";
    }
    return undef;
          </validator>
       </string>
       <message></td></tr><tr><td></message>
       <message><b>Names to store the CODEs under for later:</b></message>
       <message></td><td></message>
     <string variable="ANON_CODE_STORAGE_NAME" maxlength="50" size="20" />      <string variable="ANON_CODE_STORAGE_NAME" maxlength="50" size="20" />
       <message></td></tr></table></message>
     <message><hr width='33%' /></message>      <message><hr width='33%' /></message>
     <message><b>Reprint a set of saved CODEs:</b></message>      <message><b>Reprint a set of saved CODEs:</b></message>
     <dropdown variable="REUSE_OLD_CODES">      <dropdown variable="REUSE_OLD_CODES">
Line 1905  CHOOSE_FROM_SUBDIR Line 2030  CHOOSE_FROM_SUBDIR
       <nextstate>CHOOSE_FROM_ANY_SEQUENCE</nextstate>        <nextstate>CHOOSE_FROM_ANY_SEQUENCE</nextstate>
       <filterfunc>return \$res->is_sequence;</filterfunc>        <filterfunc>return \$res->is_sequence;</filterfunc>
       <valuefunc>return $urlValue;</valuefunc>        <valuefunc>return $urlValue;</valuefunc>
       <option text='End Page' variable='FINISHPAGE'>        <option text='Newpage' variable='FINISHPAGE' />
       </resource>        </resource>
     </state>      </state>
   <state name="CHOOSE_FROM_ANY_SEQUENCE" title="Select Resources To Print">    <state name="CHOOSE_FROM_ANY_SEQUENCE" title="Select Resources To Print">
Line 1916  CHOOSE_FROM_SUBDIR Line 2041  CHOOSE_FROM_SUBDIR
       <filterfunc>return $isProblem</filterfunc>        <filterfunc>return $isProblem</filterfunc>
       <mapurl evaluate='1'>return '$escapedSequenceName';</mapurl>        <mapurl evaluate='1'>return '$escapedSequenceName';</mapurl>
       <valuefunc>return $symbFilter;</valuefunc>        <valuefunc>return $symbFilter;</valuefunc>
       <option text='End Page' variable='FINISHPAGE'>        <option text='Newpage' variable='FINISHPAGE' />
       </resource>        </resource>
     </state>      </state>
 CHOOSE_FROM_ANY_SEQUENCE  CHOOSE_FROM_ANY_SEQUENCE
Line 1929  CHOOSE_FROM_ANY_SEQUENCE Line 2054  CHOOSE_FROM_ANY_SEQUENCE
     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');  
     $paramHash->{CHOICES} = $printChoices;      $paramHash->{CHOICES} = $printChoices;
     Apache::lonhelper::choices->new();      Apache::lonhelper::choices->new();
   
Line 1945  CHOOSE_FROM_ANY_SEQUENCE Line 2069  CHOOSE_FROM_ANY_SEQUENCE
         $paramHash->{CHOICES} = [          $paramHash->{CHOICES} = [
                                    ['Without Answers', 'yes'],                                     ['Without Answers', 'yes'],
                                    ['With Answers', 'no'],                                     ['With Answers', 'no'],
                                    ['Only Answers', 'only'],                                     ['Only Answers', 'only']
                                    ['As Exam Problem', 'exam']  
                                 ];                                  ];
         Apache::lonhelper::dropdown->new();          Apache::lonhelper::dropdown->new();
  addMessage("</td></tr>");   addMessage("</td></tr>");
Line 2017  CHOOSE_FROM_ANY_SEQUENCE Line 2140  CHOOSE_FROM_ANY_SEQUENCE
      <message></td></tr><tr><td align="right">Use style file:</td><td></message>       <message></td></tr><tr><td align="right">Use style file:</td><td></message>
              <message><input type="text" size="40" name="style_file_value" value="$stylevalue"  />&nbsp; <a href="javascript:openbrowser('helpform','style_file','sty')">Select style file</a> </td><td></message>               <message><input type="text" size="40" name="style_file_value" value="$stylevalue"  />&nbsp; <a href="javascript:openbrowser('helpform','style_file','sty')">Select style file</a> </td><td></message>
              <message></td></tr></message>               <message></td></tr></message>
        <choices allowempty="1" multichoice="true" variable="showallfoils">
                   <choice computer="1">Show all foils?</choice>
                </choices>
 RNDSEED  RNDSEED
             &Apache::lonxml::xmlparse($r, 'helper', $xmlfrag);              &Apache::lonxml::xmlparse($r, 'helper', $xmlfrag);
     $helper->{'VARS'}->{'style_file'}=$ENV{'form.style_file_value'};      $helper->{'VARS'}->{'style_file'}=$ENV{'form.style_file_value'};
       
  }   }
     }      }
   

Removed from v.1.347  
changed lines
  Added in v.1.371


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