Diff for /loncom/interface/lonprintout.pm between versions 1.282 and 1.301

version 1.282, 2004/03/15 22:32:37 version 1.301, 2004/05/10 14:25:02
Line 170  sub character_chart { Line 170  sub character_chart {
     $result =~ s/&\#153;/\\texttrademark /g;      $result =~ s/&\#153;/\\texttrademark /g;
     $result =~ s/&\#156;/\\oe/g;      $result =~ s/&\#156;/\\oe/g;
     $result =~ s/&\#159;/\\\"Y/g;      $result =~ s/&\#159;/\\\"Y/g;
     $result =~ s/&(\#160|nbsp);//g;      $result =~ s/&(\#160|nbsp);/~/g;
     $result =~ s/&(\#161|iexcl);/!\`/g;      $result =~ s/&(\#161|iexcl);/!\`/g;
     $result =~ s/&(\#162|cent);/\\textcent /g;      $result =~ s/&(\#162|cent);/\\textcent /g;
     $result =~ s/&(\#163|pound);/\\pounds /g;       $result =~ s/&(\#163|pound);/\\pounds /g; 
Line 661  sub recalcto_mm { Line 661  sub recalcto_mm {
     return $LaTeXwidth;      return $LaTeXwidth;
 }  }
   
   sub get_textwidth {
       my ($helper,$LaTeXwidth)=@_;
       my $textwidth=$LaTeXwidth;
       if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ &&
    $helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) {
    $textwidth=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.
    $helper->{'VARS'}->{'pagesize.widthunit'});
       }
       return $textwidth;
   }
   
   
   sub unsupported {
       my $currentURL=shift;
       my $result.='\documentclass[letterpaper]{article}\usepackage{calc}\begin{document}Printout of this type of document is currently not supported: ';
       if ($currentURL=~/\/ext\//) {
    $result.=' \strut \\\\ THIS IS EXTERNAL RESOURCE WITH URL \strut \\\\ '.$currentURL.' ';
       } else {
    $result.=$currentURL;
       }
       $result.= '\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill} \end{document}';
       return $result;
   }
   
   
 sub output_data {  sub output_data {
     my ($r,$helper,$rparmhash) = @_;      my ($r,$helper,$rparmhash) = @_;
     my %parmhash = %$rparmhash;      my %parmhash = %$rparmhash;
Line 739  ENDPART Line 764  ENDPART
     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;   my %form;
                   if ($helper->{'VARS'}->{'probstatus'} eq 'exam') {$form{'problemtype'}='exam';}
  $form{'grade_target'}='tex';   $form{'grade_target'}='tex';
  if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ &&   $form{'textwidth'}=&get_textwidth($helper,$LaTeXwidth);
                     $helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) {  
     $form{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'});  
  } else {  
     $form{'textwidth'}=$LaTeXwidth;  
  }  
  $form{'problem_split'}=$parmhash{'problem_stream_switch'};   $form{'problem_split'}=$parmhash{'problem_stream_switch'};
  $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};   $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
  if ($helper->{'VARS'}->{'curseed'}) {   if ($helper->{'VARS'}->{'curseed'}) {
Line 810  ENDPART Line 831  ENDPART
     if ($helper->{'VARS'}->{'ANSWER_TYPE'} ne 'only') {      if ($helper->{'VARS'}->{'ANSWER_TYPE'} ne 'only') {
  my %form;   my %form;
  $form{'grade_target'}='tex';   $form{'grade_target'}='tex';
  if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ &&   $form{'textwidth'}=&get_textwidth($helper,$LaTeXwidth);
     $helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) {  
     $form{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'});  
  } else {  
     $form{'textwidth'}=$LaTeXwidth;  
  }  
  $form{'problem_split'}=$parmhash{'problem_stream_switch'};   $form{'problem_split'}=$parmhash{'problem_stream_switch'};
  $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};   $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
  $form{'rndseed'}=$rndseed;   $form{'rndseed'}=$rndseed;
Line 858  ENDPART Line 874  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 ($currentURL=~/\/smppg$/) {    } elsif ($currentURL=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { 
  my %form;   my %form;
  $form{'grade_target'}='tex';   $form{'grade_target'}='tex';
  if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ &&   $form{'textwidth'}=&get_textwidth($helper,$LaTeXwidth);
                     $helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) {  
     $form{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'});  
  } else {  
     $form{'textwidth'}=$LaTeXwidth;  
  }  
  $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};   $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
    if ($currentURL=~/\/syllabus$/) {$currentURL=~s/\/res//;}
  my $texversion=&Apache::lonnet::ssi($currentURL,%form);   my $texversion=&Apache::lonnet::ssi($currentURL,%form);
  $result .= $texversion;   $result .= $texversion;
  } else {   } else {
   $result.='\documentclass[letterpaper]{article}\usepackage{calc}\begin{document}Printout of this type of document is currently not supported: ';      $result.=&unsupported($currentURL);
   if ($currentURL=~/\/(aboutme|syllabus|bulletinboard|smppg)$/) {  
       $result.=$1;  
   } elsif ($currentURL=~/\/ext\//) {  
       $result.=' \strut \\\\ THIS IS EXTERNAL RESOURCE WITH URL \strut \\\\ '.$currentURL.' ';  
   } else {  
       $result.=$currentURL;  
   }  
   $result.=' \end{document}'  
  }   }
     } 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 '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') {
       $selectionmade = 2;
    } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') {
       $selectionmade = 3;
    } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems') {
       $selectionmade = 4;
    } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'select_sequences') {
       $selectionmade = 7;
    }
  my %form=();      my %form=();   
  $form{'grade_target'}='tex';   $form{'grade_target'}='tex';
  if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ &&   $form{'textwidth'}=&get_textwidth($helper,$LaTeXwidth);
     $helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) {  
     $form{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'});  
  } else {  
     $form{'textwidth'}=$LaTeXwidth;  
  }  
  $form{'problem_split'}=$parmhash{'problem_stream_switch'};   $form{'problem_split'}=$parmhash{'problem_stream_switch'};
  $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};   $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
  my $flag_latex_header_remove = 'NO';   my $flag_latex_header_remove = 'NO';
Line 905  ENDPART Line 913  ENDPART
  for (my $i=0;$i<=$#master_seq;$i++) {   for (my $i=0;$i<=$#master_seq;$i++) {
     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);
     if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') {  
  $selectionmade = 2;  
     } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') {  
  $selectionmade = 3;  
     } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems') {  
  $selectionmade = 4;  
     } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'select_sequences') {  
  $selectionmade = 7;  
     }  
     $form{'symb'}=$master_seq[$i];      $form{'symb'}=$master_seq[$i];
     my ($sequence)=&Apache::lonnet::decode_symb($master_seq[$i]);      my ($sequence)=&Apache::lonnet::decode_symb($master_seq[$i]);
     my $assignment=&Apache::lonxml::latex_special_symbols(&Apache::lonnet::gettitle($sequence),'header'); #tittle of the assignment which contains this problem      my $assignment=&Apache::lonxml::latex_special_symbols(&Apache::lonnet::gettitle($sequence),'header'); #tittle of the assignment which contains this problem
     if ($selectionmade==7) {$helper->{VARS}->{'assignment'}=$assignment;}      if ($selectionmade==7) {$helper->{VARS}->{'assignment'}=$assignment;}
     if ($i==0) {$prevassignment=$assignment;}      if ($i==0) {$prevassignment=$assignment;}
     #&Apache::lonnet::logthis("Trying to get $urlp with symb $master_seq[$i]");      #&Apache::lonnet::logthis("Trying to get $urlp with symb $master_seq[$i]");
     my $texversion.=&Apache::lonnet::ssi($urlp,%form);      my $texversion='';
     if ($urlp=~/\.page$/) {      if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) {
  ($texversion,my $number_of_columns_page) = &page_cleanup($texversion);   $texversion.=&Apache::lonnet::ssi($urlp,%form);
  if ($number_of_columns_page > $number_of_columns) {$number_of_columns=$number_of_columns_page;}    if ($urlp=~/\.page$/) {
  $texversion =~ s/\\end{document}\d*/\\end{document}/;      ($texversion,my $number_of_columns_page) = &page_cleanup($texversion);
  $flag_page_in_sequence = 'YES';      if ($number_of_columns_page > $number_of_columns) {$number_of_columns=$number_of_columns_page;} 
     }       $texversion =~ s/\\end{document}\d*/\\end{document}/;
     my $lonidsdir=$r->dir_config('lonIDsDir');      $flag_page_in_sequence = 'YES';
     my $envfile=$ENV{'user.environment'};   } 
     $envfile=~/\/([^\/]+)\.id$/;   my $lonidsdir=$r->dir_config('lonIDsDir');
             $envfile=$1;   my $envfile=$ENV{'user.environment'};
     &Apache::lonnet::transfer_profile_to_env($lonidsdir,$envfile);   $envfile=~/\/([^\/]+)\.id$/;
     my $current_counter=$ENV{'form.counter'};   $envfile=$1;
     if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||   &Apache::lonnet::transfer_profile_to_env($lonidsdir,$envfile);
        ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {   my $current_counter=$ENV{'form.counter'};
  my %form;   if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||
  $form{'grade_target'}='answer';     ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {
  $form{'answer_output_mode'}='tex';      my %form;
  my $answer=&Apache::lonnet::ssi($urlp,%form);      $form{'grade_target'}='answer';
                 &Apache::lonnet::appenv(('form.counter' => $current_counter));      $form{'answer_output_mode'}='tex';
  if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {      my $answer=&Apache::lonnet::ssi($urlp,%form);
     $texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/;      &Apache::lonnet::appenv(('form.counter' => $current_counter));
  } else {      if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
     if ($urlp=~/\.(problem|exam|quiz|library)$/) {   $texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/;
  $texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});  
  $texversion.='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($urlp).'}\vskip 0 mm ';  
  $texversion.=&path_to_problem ($urlp,$LaTeXwidth);  
  $texversion.='\vskip 1 mm '.$answer;  
     } else {      } else {
  $texversion='';   if ($urlp=~/\.(problem|exam|quiz|library)$/) {
       $texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
       $texversion.='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($urlp).'}\vskip 0 mm ';
       $texversion.=&path_to_problem ($urlp,$LaTeXwidth);
       $texversion.='\vskip 1 mm '.$answer;
    } else {
       $texversion='';
    }
     }      }
  }   }
     }   if ($flag_latex_header_remove ne 'NO') {
     if ($flag_latex_header_remove ne 'NO') {      $texversion = &latex_header_footer_remove($texversion);
  $texversion = &latex_header_footer_remove($texversion);   } else {
       $texversion =~ s/\\end{document}//;
    }
    if ($helper->{'VARS'}->{'TABLE_INDEX'} eq 'yes') {
       $texversion=&IndexCreation($texversion,$urlp);
    }
    if (($selectionmade == 4) and ($assignment ne $prevassignment)) {
       my $name = &get_name();
       my $courseidinfo = &get_course();
       if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }
       $prevassignment=$assignment;
       $result .='\newpage \noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$name.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$assignment.'}}} \vskip -5 mm ';
    }
    $result .= $texversion;
    $flag_latex_header_remove = 'YES';   
       } 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'};
    if ($urlp=~/\/syllabus$/) {$urlp=~s/\/res//;}
    my $texversion=&Apache::lonnet::ssi($urlp,%form);
    if ($flag_latex_header_remove ne 'NO') {
       $texversion = &latex_header_footer_remove($texversion);
    } else {
       $texversion =~ s/\\end{document}/\\vskip 0\.5mm\\noindent\\makebox\[\\textwidth\/\$number_of_columns\]\[b\]\{\\hrulefill\}/;
    }
    $result .= $texversion;
    $flag_latex_header_remove = 'YES'; 
     } else {      } else {
  $texversion =~ s/\\end{document}//;   $texversion=&unsupported($urlp);
     }   if ($flag_latex_header_remove ne 'NO') {
     if ($helper->{'VARS'}->{'TABLE_INDEX'} eq 'yes') {      $texversion = &latex_header_footer_remove($texversion);
  $texversion=&IndexCreation($texversion,$urlp);   } else {
     }      $texversion =~ s/\\end{document}//;
     if (($selectionmade == 4) and ($assignment ne $prevassignment)) {   }
  my $name = &get_name();   $result .= $texversion;
  my $courseidinfo = &get_course();   $flag_latex_header_remove = 'YES';   
  if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }      }    
  $prevassignment=$assignment;  
  $result .='\newpage \noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$name.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$assignment.'}}} \vskip -5 mm ';  
     }  
     $result .= $texversion;  
     $flag_latex_header_remove = 'YES';     
  }   }
  &Apache::lonnet::delenv('form.counter');   &Apache::lonnet::delenv('form.counter');
  if ($flag_page_in_sequence eq 'YES') {$result =~ s/\\usepackage{calc}/\\usepackage{calc}\\usepackage{longtable}/;}   if ($flag_page_in_sequence eq 'YES') {$result =~ s/\\usepackage{calc}/\\usepackage{calc}\\usepackage{longtable}/;}
  $result .= '\end{document}';   $result .= '\end{document}';
      } elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_students') || ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_students')) {        } elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_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;
  if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_students') {   if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_students') {
      $selectionmade=5;       $selectionmade=5;
        $type='problems';
  } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_students') {   } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_students') {
      $selectionmade=8;       $selectionmade=8;
        $type='resources';
  }   }
  my @students=split /\|\|\|/, $helper->{'VARS'}->{'STUDENTS'};   my @students=split /\|\|\|/, $helper->{'VARS'}->{'STUDENTS'};
          if ($helper->{'VARS'}->{'NUMBER_TO_PRINT'} eq '0' ||           if ($helper->{'VARS'}->{'NUMBER_TO_PRINT'} eq '0' ||
Line 990  ENDPART Line 1019  ENDPART
  #loop over students   #loop over students
  my $flag_latex_header_remove = 'NO';    my $flag_latex_header_remove = 'NO'; 
  my %moreenv;   my %moreenv;
  if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ &&   $moreenv{'textwidth'}=&get_textwidth($helper,$LaTeXwidth);
      $helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) {  
      $moreenv{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'});  
  } else {  
      $moreenv{'textwidth'}=$LaTeXwidth;  
  }  
  my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$#students+1);   my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$#students+1);
  my $student_counter=-1;   my $student_counter=-1;
  foreach my $person (@students) {   foreach my $person (@students) {
      $student_counter++;       $student_counter++;
     my $current_output = '';        my $i=int($student_counter/$helper->{'VARS'}{'NUMBER_TO_PRINT'});
     my ($username,$userdomain,$usersection) = split /:/,$person;       my ($output,$fullname)=&print_resources($r,$helper,$person,$type,\%moreenv,\@master_seq,$flag_latex_header_remove);
     my $fullname = &get_name($username,$userdomain);       $print_array[$i].=$output;
        $student_names[$i].=$person.':'.$fullname.'_END_';
     if ($parmhash{'anonymous_quiz'}=~/yes/) {$fullname=' ';} #put here something reasonable for anonymous exams or quiz       &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,&mt('last student').' '.$fullname);
             #goes through all resources, checks if they are available for current student, and produces output          $flag_latex_header_remove = 'YES';
     &Apache::lonnet::delenv('form.counter');   }
     &Apache::lonxml::init_counter();   &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
     foreach my $curresline (@master_seq)  {   $result .= $print_array[0].'  \end{document}';
  if ((($curresline=~ m/\.(problem|exam|quiz|assess|survey|form|library)$/) && ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_students')) || ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_students')) {       } elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_anon')     ||
     my ($map,$id,$res_url) = &Apache::lonnet::decode_symb($curresline);        ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_anon')  ) { 
     if (&Apache::lonnet::allowed('bre',$res_url)) {   my $cdom =$ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
  my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,   my $cnum =$ENV{'course.'.$ENV{'request.course.id'}.'.num'};
                                                                         $ENV{'request.course.id'},'tex',\%moreenv);   my $num_todo=$helper->{'VARS'}->{'NUMBER_TO_PRINT_TOTAL'};
  my $lonidsdir=$r->dir_config('lonIDsDir');   my $code_name=$helper->{'VARS'}->{'ANON_CODE_STORAGE_NAME'};
  my $envfile=$ENV{'user.environment'};   my $old_name=$helper->{'VARS'}->{'REUSE_OLD_CODES'};
  $envfile=~/\/([^\/]+)\.id$/;   my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'};
  $envfile=$1;   my ($type) = split(/_/,$helper->{'VARS'}->{'PRINT_TYPE'});
  &Apache::lonnet::transfer_profile_to_env($lonidsdir,$envfile);   my $number_per_page=$helper->{'VARS'}->{'NUMBER_TO_PRINT'};
  my $current_counter=$ENV{'form.counter'};   if ($number_per_page eq '0' || $number_per_page eq 'all') {
  if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||       $number_per_page=$num_todo;
    ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {   }
     my %form;   my $flag_latex_header_remove = 'NO'; 
     $form{'answer_output_mode'}='tex';   my %moreenv = ('textwidth' => &get_textwidth($helper,$LaTeXwidth));
     $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};   my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$num_todo,'inline','75');
     my $ansrendered = &Apache::loncommon::get_student_answers($curresline,$username,$userdomain,$ENV{'request.course.id'},%form);   my $seed=time+($$<<16)+($$);
     &Apache::lonnet::appenv(('form.counter' => $current_counter));   my @allcodes;
     if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {   if ($old_name) {
  $rendered=~s/(\\keephidden{ENDOFPROBLEM})/$ansrendered$1/;       my %result=&Apache::lonnet::get('CODEs',[$old_name],$cdom,$cnum);
     } else {       @allcodes=split(',',$result{$old_name});
  $rendered=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});   } else {
  $rendered.='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($curresline).'}\vskip 0 mm ';       my %allcodes;
  $rendered.=&path_to_problem ($curresline,$LaTeXwidth);       srand($seed);
  $rendered.='\vskip 1 mm '.$ansrendered;       for (my $i=0;$i<$num_todo;$i++) {
     }   $moreenv{'CODE'}=&get_CODE(\%allcodes,$i,$seed,'6');
  }       }
  if ($flag_latex_header_remove eq 'YES') {       if ($code_name) {
     $rendered = &latex_header_footer_remove($rendered);   &Apache::lonnet::put('CODEs',
  } else {        {$code_name =>join(',',keys(%allcodes))},
     $rendered =~ s/\\end{document}//;        $cdom,$cnum);
  }       }
  $current_output .= $rendered;       @allcodes=keys(%allcodes);
     }   }
     $flag_latex_header_remove = 'YES';   my $count=0;
  }   foreach my $code (sort(@allcodes)) {
     }       my $file_num=int($count/$number_per_page);
     my $courseidinfo = &get_course();       $moreenv{'CODE'}=&num_to_letters($code);
     if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }       my ($output,$fullname)=
             if ($usersection ne '') {$courseidinfo.=' - Sec. '.$usersection}   &print_resources($r,$helper,'anonymous',$type,\%moreenv,
     my $currentassignment=&Apache::lonxml::latex_special_symbols($helper->{VARS}->{'assignment'},'header');    \@master_seq,$flag_latex_header_remove);
     if ($current_output=~/\\documentclass/) {       $print_array[$file_num].=$output;
  $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\lhead{\\textit{\\textbf{$fullname}}$courseidinfo \\hfill \\thepage \\\\ \\textit{$currentassignment}}\\vskip 3 mm /;       &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
     } else {         &mt('last assignment').' '.$fullname);
  my $blanspages = '';       $flag_latex_header_remove = 'YES';
  for (my $j=0;$j<$helper->{'VARS'}->{'EMPTY_PAGES'};$j++) {$blanspages.='\clearpage\strut\clearpage';}       $count++;
  $current_output = '\strut\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blanspages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$fullname.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$currentassignment.'}}} \vskip -5 mm '.$current_output;   }
     }   &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
             $print_array[int($student_counter/$helper->{'VARS'}->{'NUMBER_TO_PRINT'})].=$current_output;   $result .= $print_array[0].'  \end{document}';
             $student_names[int($student_counter/$helper->{'VARS'}->{'NUMBER_TO_PRINT'})].=$person.':'.$fullname.'_END_';       } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_from_directory') {      
     &Apache::lonnet::delenv('form.counter');      
     &Apache::lonxml::init_counter();   
     &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,  
      &mt('last student').' '.$fullname);  
  }  
  &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);  
  $result .= $print_array[0].'  \end{document}';  
     } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_from_directory') {        
     #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'};
Line 1082  ENDPART Line 1098  ENDPART
     if ($urlp=~/\//) {      if ($urlp=~/\//) {
  my %form;   my %form;
  $form{'grade_target'}='tex';   $form{'grade_target'}='tex';
  if ($helper->{'VARS'}->{'pagesize.width'}=~/\d+/ &&   $form{'textwidth'}=&get_textwidth($helper,$LaTeXwidth);
                     $helper->{'VARS'}->{'pagesize.widthunit'}=~/\w+/) {  
     $form{'textwidth'}=&recalcto_mm($helper->{'VARS'}->{'pagesize.width'}.' '.$helper->{'VARS'}->{'pagesize.widthunit'});  
  } else {  
     $form{'textwidth'}=$LaTeXwidth;  
  }  
  $form{'rndseed'}=$rndseed;   $form{'rndseed'}=$rndseed;
  if ($urlp =~ m|/home/([^/]+)/public_html|) {   if ($urlp =~ m|/home/([^/]+)/public_html|) {
     $urlp =~ s|/home/([^/]*)/public_html|/~$1|;      $urlp =~ s|/home/([^/]*)/public_html|/~$1|;
Line 1229  ENDPART Line 1240  ENDPART
                             'cgi.'.$identifier.'backref' => $URLback,);                              'cgi.'.$identifier.'backref' => $URLback,);
     
 $r->print(<<FINALEND);  $r->print(<<FINALEND);
 <meta http-equiv="Refresh" content="0; url=/cgi-bin/printout.pl?$identifier">  <meta http-equiv="Refresh" content="0; url=/cgi-bin/printout.pl?$identifier" />
 </body>  </body>
 </html>  </html>
 FINALEND  FINALEND
 }  }
   
   sub num_to_letters {
       my ($num) = @_;
       my @nums= split('',$num);
       my @num_to_let=('A'..'Z');
       my $word;
       foreach my $digit (@nums) { $word.=$num_to_let[$digit]; }
       return $word;
   }
   
   sub get_CODE {
       my ($all_codes,$num,$seed,$size)=@_;
       my $max='1'.'0'x$size;
       my $newcode;
       while(1) {
    $newcode=sprintf("%06d",int(rand($max)));
    if (!exists($$all_codes{$newcode})) {
       $$all_codes{$newcode}=1;
       return &num_to_letters($newcode);
    }
       }
   }
   
   sub print_resources {
       my ($r,$helper,$person,$type,$moreenv,$master_seq,$remove_latex_header)=@_;
       my $current_output = ''; 
       my ($username,$userdomain,$usersection) = split /:/,$person;
       my $fullname = &get_name($username,$userdomain);
       if ($person =~ 'anon') {
    $fullname = "CODE - ".$moreenv->{'CODE'};
       }
       #goes through all resources, checks if they are available for 
       #current student, and produces output   
       &Apache::lonnet::delenv('form.counter');
       &Apache::lonxml::init_counter();
       foreach my $curresline (@{$master_seq})  {
    if ( !($type eq 'problems' && 
          ($curresline!~ m/\.(problem|exam|quiz|assess|survey|form|library)$/)) ) {
       my ($map,$id,$res_url) = &Apache::lonnet::decode_symb($curresline);
       if (&Apache::lonnet::allowed('bre',$res_url)) {
    my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,$ENV{'request.course.id'},'tex',$moreenv);
    my $lonidsdir=$r->dir_config('lonIDsDir');
    my $envfile=$ENV{'user.environment'};
    $envfile=~/\/([^\/]+)\.id$/;
    $envfile=$1;
    &Apache::lonnet::transfer_profile_to_env($lonidsdir,$envfile);
    my $current_counter=$ENV{'form.counter'};
    if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||
      ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {
       my %form;
       $form{'answer_output_mode'}='tex';
       $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
       my $ansrendered = &Apache::loncommon::get_student_answers($curresline,$username,$userdomain,$ENV{'request.course.id'},%form);
       &Apache::lonnet::appenv(('form.counter' => $current_counter));
       if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
    $rendered=~s/(\\keephidden{ENDOFPROBLEM})/$ansrendered$1/;
       } else {
    $rendered=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
    $rendered.='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($curresline).'}\vskip 0 mm ';
    $rendered.=&path_to_problem ($curresline,$LaTeXwidth);
    $rendered.='\vskip 1 mm '.$ansrendered;
       }
    }
    if ($remove_latex_header eq 'YES') {
       $rendered = &latex_header_footer_remove($rendered);
    } else {
       $rendered =~ s/\\end{document}//;
    }
    $current_output .= $rendered;
       }
       $remove_latex_header = 'YES';
    }
       }
       my $courseidinfo = &get_course();
       if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }
       if ($usersection ne '') {$courseidinfo.=' - Sec. '.$usersection}
       my $currentassignment=&Apache::lonxml::latex_special_symbols($helper->{VARS}->{'assignment'},'header');
       if ($current_output=~/\\documentclass/) {
    $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\lhead{\\textit{\\textbf{$fullname}}$courseidinfo \\hfill \\thepage \\\\ \\textit{$currentassignment}}\\vskip 3 mm /;
       } else {
    my $blankpages = '';
    for (my $j=0;$j<$helper->{'VARS'}->{'EMPTY_PAGES'};$j++) {$blankpages.='\clearpage\strut\clearpage';}
    $current_output = '\strut\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blankpages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$fullname.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$currentassignment.'}}} \vskip -5 mm '.$current_output;
       }
       return ($current_output,$fullname);
   
   }
   
 sub handler {  sub handler {
   
Line 1323  sub printHelper { Line 1419  sub printHelper {
     my $helper = Apache::lonhelper::helper->new("Printing Helper");      my $helper = Apache::lonhelper::helper->new("Printing Helper");
     $helper->declareVar('symb');      $helper->declareVar('symb');
     $helper->declareVar('postdata');          $helper->declareVar('postdata');    
     $helper->declareVar('curseed');          $helper->declareVar('curseed'); 
       $helper->declareVar('probstatus');   
     $helper->declareVar('filename');      $helper->declareVar('filename');
     $helper->declareVar('construction');      $helper->declareVar('construction');
     $helper->declareVar('assignment');      $helper->declareVar('assignment');
Line 1383  sub printHelper { Line 1480  sub printHelper {
     if (!$helper->{VARS}->{'curseed'} && $ENV{'form.curseed'}) {      if (!$helper->{VARS}->{'curseed'} && $ENV{'form.curseed'}) {
  $helper->{VARS}->{'curseed'}=$ENV{'form.curseed'};   $helper->{VARS}->{'curseed'}=$ENV{'form.curseed'};
     }      }
       if (!$helper->{VARS}->{'probstatus'} && $ENV{'form.problemtype'}) {
    $helper->{VARS}->{'probstatus'}=$ENV{'form.problemtype'};
       }
   
     my $userCanSeeHidden = Apache::lonnavmaps::advancedUser();      my $userCanSeeHidden = Apache::lonnavmaps::advancedUser();
     my $userPriviledged = ($ENV{'request.role'}=~m/^cc\./ or      my $userPriviledged = ($ENV{'request.role'}=~m/^cc\./ or
Line 1414  sub printHelper { Line 1514  sub printHelper {
     my $paramHash;      my $paramHash;
   
     if ($resourceTitle) {      if ($resourceTitle) {
         push @{$printChoices}, ["<b><i>$resourceTitle</i></b> (what you just saw on the screen)", 'current_document', 'PAGESIZE'];          push @{$printChoices}, ["<b><i>$resourceTitle</i></b> (".&mt('what you just saw on the screen').")", 'current_document', 'PAGESIZE'];
     }      }
   
 #    $r->print($helper->{VARS}->{'postdata'});  
   
     # Useful filter strings      # Useful filter strings
     my $isProblem = '$res->is_problem()';      my $isProblem = '($res->is_problem()||$res->contains_problem) ';
     $isProblem .= ' && !$res->randomout()' if !$userCanSeeHidden;      $isProblem .= ' && !$res->randomout()' if !$userCanSeeHidden;
     my $isProblemOrMap = '$res->is_problem() || $res->is_map()';      my $isProblemOrMap = '$res->is_problem() || $res->contains_problem() || $res->is_sequence()';
     my $isNotMap = '!$res->is_map()';      my $isNotMap = '!$res->is_sequence()';
     $isNotMap .= ' && !$res->randomout()' if !$userCanSeeHidden;      $isNotMap .= ' && !$res->randomout()' if !$userCanSeeHidden;
     my $isMap = '$res->is_map()';      my $isMap = '$res->is_map()';
     my $symbFilter = '$res->symb()';      my $symbFilter = '$res->symb()';
Line 1440  sub printHelper { Line 1538  sub printHelper {
  $helper->{VARS}->{'postdata'} &&   $helper->{VARS}->{'postdata'} &&
  $helper->{VARS}->{'assignment'}) {   $helper->{VARS}->{'assignment'}) {
         # Allow problems from sequence          # Allow problems from sequence
         push @{$printChoices}, ["<b>Problems</b> in <b><i>$sequenceTitle</i></b>", 'map_problems', 'CHOOSE_PROBLEMS'];          push @{$printChoices}, ["<b>".&mt('Problems')."</b> ".&mt('in')." <b><i>$sequenceTitle</i></b>", 'map_problems', 'CHOOSE_PROBLEMS'];
         # Allow all resources from sequence          # Allow all resources from sequence
         push @{$printChoices}, ["<b>Resources</b> in <b><i>$sequenceTitle</i></b>", 'map_problems_pages', 'CHOOSE_PROBLEMS_HTML'];          push @{$printChoices}, ["<b>".&mt('Resources')."</b> ".&mt('in')." <b><i>$sequenceTitle</i></b>", 'map_problems_pages', 'CHOOSE_PROBLEMS_HTML'];
   
         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>
     <resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1">      <resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1"
                 closeallpages="1">
       <nextstate>PAGESIZE</nextstate>        <nextstate>PAGESIZE</nextstate>
       <filterfunc>return $isProblem;</filterfunc>        <filterfunc>return $isProblem;</filterfunc>
       <mapurl>$map</mapurl>        <mapurl>$map</mapurl>
Line 1457  sub printHelper { Line 1556  sub printHelper {
   
   <state name="CHOOSE_PROBLEMS_HTML" title="Select Resource(s) to print">    <state name="CHOOSE_PROBLEMS_HTML" title="Select Resource(s) to print">
     <message>(mark them then click "next" button) <br /></message>      <message>(mark them then click "next" button) <br /></message>
     <resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1">      <resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1"
                 closeallpages="1">
       <nextstate>PAGESIZE</nextstate>        <nextstate>PAGESIZE</nextstate>
       <filterfunc>return $isNotMap;</filterfunc>        <filterfunc>return $isNotMap;</filterfunc>
       <mapurl>$map</mapurl>        <mapurl>$map</mapurl>
Line 1473  HELPERFRAGMENT Line 1573  HELPERFRAGMENT
     # 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}, ['<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'];
  if ($helper->{VARS}->{'assignment'}) {           &Apache::lonxml::xmlparse($r, 'helper', <<ALL_PROBLEMS);
     push @{$printChoices}, ["<b>Problems</b> from <b><i>$sequenceTitle</i></b> for <b>selected students</b>", 'problems_for_students', '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>
     <resource variable="RESOURCES" multichoice="1"      <resource variable="RESOURCES" toponly='0' multichoice="1"
  suppressEmptySequences='1' addstatus="1">   suppressEmptySequences='0' addstatus="1" closeallpages="1">
       <nextstate>PAGESIZE</nextstate>        <nextstate>PAGESIZE</nextstate>
       <filterfunc>return $isProblemOrMap;</filterfunc>        <filterfunc>return $isProblemOrMap;</filterfunc>
       <choicefunc>return $isProblem;</choicefunc>        <choicefunc>return $isNotMap;</choicefunc>
       <valuefunc>return $symbFilter;</valuefunc>        <valuefunc>return $symbFilter;</valuefunc>
       </resource>      </resource>
     </state>    </state>
   ALL_PROBLEMS
   
   <state name="CHOOSE_STUDENTS" title="Select Students and Resources">   if ($helper->{VARS}->{'assignment'}) {
     <student multichoice='1' variable="STUDENTS" nextstate="PAGESIZE" />      push @{$printChoices}, ["<b>".&mt('Problems')."</b> ".&mt('from')." <b><i>$sequenceTitle</i></b> ".&mt('for')." <b>".&mt('selected students')."</b>", 'problems_for_students', 'CHOOSE_STUDENTS'];
     <message><br /><big><i><b>Select resources for the assignment</b></i></big><br /></message>      push @{$printChoices}, ["<b>".&mt('Problems')."</b> ".&mt('from')." <b><i>$sequenceTitle</i></b> ".&mt('for')." <b>".&mt('anonymous students')."</b>", 'problems_for_anon', 'CHOOSE_ANON1'];
     <resource variable="RESOURCES" multichoice="1" addstatus="1">   }
    my $resource_selector=<<RESOURCE_SELECTOR;
      <message><br /><big><i><b>Select resources for the assignment</b></i></big><br /></message>
       <resource variable="RESOURCES" multichoice="1" addstatus="1" 
                 closeallpages="1">
       <filterfunc>return $isProblem;</filterfunc>        <filterfunc>return $isProblem;</filterfunc>
       <mapurl>$map</mapurl>        <mapurl>$map</mapurl>
       <valuefunc>return $symbFilter;</valuefunc>        <valuefunc>return $symbFilter;</valuefunc>
Line 1502  HELPERFRAGMENT Line 1604  HELPERFRAGMENT
       <choice computer='1'>Add one empty page/column after each student\'s assignment</choice>        <choice computer='1'>Add one empty page/column after each student\'s assignment</choice>
       <choice computer='2'>Add two empty pages/column after each student\'s assignment</choice>        <choice computer='2'>Add two empty pages/column after each student\'s assignment</choice>
       <choice computer='3'>Add three empty pages/column after each student\'s assignment</choice>        <choice computer='3'>Add three empty pages/column after each student\'s assignment</choice>
       </choices>      </choices>
     </state>      <message><hr width='33%' /><b>Number of assignments printed at the same time: </b></message>
       <string variable="NUMBER_TO_PRINT" maxlength="5" size="5"><defaultvalue>"all"</defaultvalue></string>
   RESOURCE_SELECTOR
   
           &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS);
     <state name="CHOOSE_STUDENTS" title="Select Students and Resources">
         <student multichoice='1' variable="STUDENTS" nextstate="PAGESIZE" />
       $resource_selector
     </state>
 CHOOSE_STUDENTS  CHOOSE_STUDENTS
   
  addMessage("<hr width='33%' /><b>Number of assignments printed at the same time: </b>");   my $cdom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
         $paramHash = Apache::lonhelper::getParamHash();   my $cnum = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
  $paramHash->{'variable'} = 'NUMBER_TO_PRINT';             my @names=&Apache::lonnet::getkeys('CODEs',$cdom,$cnum);
  $helper->declareVar('NUMBER_TO_PRINT');            my $namechoice='<choice></choice>';
  addMessage("<input type='text' name='NUMBER_TO_PRINT.forminput' size='3' value='all' /><hr width='33%' />");   foreach my $name (@names) {
       if ($name =~ /^error: 2 /) { next; }
       $namechoice.='<choice computer="'.$name.'">'.$name.'</choice>';
    }
           &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_ANON1);
     <state name="CHOOSE_ANON1" title="Select Students and Resources">
       <nextstate>PAGESIZE</nextstate>
       <message><hr width='33%' /><b>Number of anonymous assignments to print?</b></message>
       <string variable="NUMBER_TO_PRINT_TOTAL" maxlength="5" size="5"></string>
       <message><br /><b>Names to store the CODEs under for later:</b></message>
       <string variable="ANON_CODE_STORAGE_NAME" maxlength="50" size="20" />
       <message><hr width='33%' /></message>
       <message><b>Reprint a set of saved CODEs:</b></message>
       <dropdown variable="REUSE_OLD_CODES">
           $namechoice
       </dropdown>
       <message><hr width='33%' /></message>
       $resource_selector
     </state>
   CHOOSE_ANON1
   
   
  if ($helper->{VARS}->{'assignment'}) {   if ($helper->{VARS}->{'assignment'}) {
     push @{$printChoices}, ["<b>Resources</b> from <b><i>$sequenceTitle</i></b> for <b>selected students</b>", 'resources_for_students', 'CHOOSE_STUDENTS1'];      push @{$printChoices}, ["<b>".&mt('Resources')."</b> ".&mt('from')." <b><i>$sequenceTitle</i></b> ".&mt('for')." <b>".&mt('selected students')."</b>", 'resources_for_students', 'CHOOSE_STUDENTS1'];
       push @{$printChoices}, ["<b>".&mt('Resources')."</b> ".&mt('from')." <b><i>$sequenceTitle</i></b> ".&mt('for')." <b>".&mt('anonymous students')."</b>", 'resources_for_anon', 'CHOOSE_ANON2'];
  }   }
  &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS1);      
   <state name="CHOOSE_STUDENTS1" title="Select Students and Resources">  
     <student multichoice='1' variable="STUDENTS" nextstate="PAGESIZE" />   $resource_selector=<<RESOURCE_SELECTOR;
     <message><br /><big><i><b>Select resources for the assignment</b></i></big><br /></message>      <message><br /><big><i><b>Select resources for the assignment</b></i></big><br /></message>
     <resource variable="RESOURCES" multichoice="1" addstatus="1">      <resource variable="RESOURCES" multichoice="1" addstatus="1" 
                 closeallpages="1">
       <filterfunc>return $isNotMap;</filterfunc>        <filterfunc>return $isNotMap;</filterfunc>
       <mapurl>$map</mapurl>        <mapurl>$map</mapurl>
       <valuefunc>return $symbFilter;</valuefunc>        <valuefunc>return $symbFilter;</valuefunc>
Line 1530  CHOOSE_STUDENTS Line 1662  CHOOSE_STUDENTS
       <choice computer='1'>Add one empty page/column after each student\'s assignment</choice>        <choice computer='1'>Add one empty page/column after each student\'s assignment</choice>
       <choice computer='2'>Add two empty pages/column after each student\'s assignment</choice>        <choice computer='2'>Add two empty pages/column after each student\'s assignment</choice>
       <choice computer='3'>Add three empty pages/column after each student\'s assignment</choice>        <choice computer='3'>Add three empty pages/column after each student\'s assignment</choice>
       </choices>      </choices>
       <message><hr width='33%' /><b>Number of assignments printed at the same time: </b></message>
       <string variable="NUMBER_TO_PRINT" maxlength="5" size="5"><defaultvalue>"all"</defaultvalue></string>
   RESOURCE_SELECTOR
   
    &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS1);
     <state name="CHOOSE_STUDENTS1" title="Select Students and Resources">
       <student multichoice='1' variable="STUDENTS" nextstate="PAGESIZE" />
       $resource_selector
     </state>      </state>
 CHOOSE_STUDENTS1  CHOOSE_STUDENTS1
   
   addMessage("<hr width='33%' /><b>Number of assignments printed at the same time: </b>");   &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_ANON2);
         $paramHash = Apache::lonhelper::getParamHash();    <state name="CHOOSE_ANON2" title="Select Students and Resources">
  $paramHash->{'variable'} = 'NUMBER_TO_PRINT';         <nextstate>PAGESIZE</nextstate>
  $helper->declareVar('NUMBER_TO_PRINT');               <message><hr width='33%' /><b>Number of anonymous assignments to print?</b></message>
  addMessage("<input type='text' name='NUMBER_TO_PRINT.forminput' size='3' value='all' /><hr width='33%' />");      <string variable="NUMBER_TO_PRINT_TOTAL" maxlength="5" size="5"></string>
       <message><br /><b>Names to store the CODEs under for later:</b></message>
       <string variable="ANON_CODE_STORAGE_NAME" maxlength="50" size="20" />
       <message><hr width='33%' /></message>
       <message><b>Reprint a set of saved CODEs:</b></message>
       <dropdown variable="REUSE_OLD_CODES">
           $namechoice
       </dropdown>
       <message><hr width='33%' /></message>
       $resource_selector
     </state>
   CHOOSE_ANON2
     }      }
   
     # 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'} and $subdir ne '/home/httpd/html/res/') {          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}, ["<b>Problems</b> from current subdirectory <b><i>$subdir</i></b>", 'problems_from_directory', 'CHOOSE_FROM_SUBDIR'];          push @{$printChoices}, ["<b>".&mt('Problems')."</b> ".&mt('from current subdirectory')." <b><i>$subdir</i></b>", 'problems_from_directory', 'CHOOSE_FROM_SUBDIR'];
   
         my $f = '$filename';          my $f = '$filename';
         my $xmlfrag = <<CHOOSE_FROM_SUBDIR;          my $xmlfrag = <<CHOOSE_FROM_SUBDIR;
Line 1586  CHOOSE_FROM_SUBDIR Line 1737  CHOOSE_FROM_SUBDIR
     </state>      </state>
   <state name="CHOOSE_FROM_ANY_SEQUENCE" title="Select Resources To Print">    <state name="CHOOSE_FROM_ANY_SEQUENCE" title="Select Resources To Print">
     <message>(mark desired resources then click "next" button) <br /></message>      <message>(mark desired resources then click "next" button) <br /></message>
     <resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1">      <resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1"
                 closeallpages="1">
       <nextstate>PAGESIZE</nextstate>        <nextstate>PAGESIZE</nextstate>
       <filterfunc>return $isProblem</filterfunc>        <filterfunc>return $isProblem</filterfunc>
       <mapurl evaluate='1'>return '$escapedSequenceName';</mapurl>        <mapurl evaluate='1'>return '$escapedSequenceName';</mapurl>
Line 1619  CHOOSE_FROM_ANY_SEQUENCE Line 1771  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>");
  $startedTable = 1;   $startedTable = 1;
Line 1671  CHOOSE_FROM_ANY_SEQUENCE Line 1825  CHOOSE_FROM_ANY_SEQUENCE
  if ($helper->{'VARS'}->{'construction'}) {    if ($helper->{'VARS'}->{'construction'}) { 
     my $stylevalue=$ENV{'construct.style'};      my $stylevalue=$ENV{'construct.style'};
     my $xmlfrag .= <<"RNDSEED";      my $xmlfrag .= <<"RNDSEED";
     <message><tr><td align='right'>Use random seed: </td><td></message>      <message><tr><td align='right'>Use random seed:  </td><td></message>
     <string variable="curseed" size="15" maxlength="15">      <string variable="curseed" size="15" maxlength="15">
  <defaultvalue>   <defaultvalue>
             return $helper->{VARS}->{'curseed'};              return $helper->{VARS}->{'curseed'};

Removed from v.1.282  
changed lines
  Added in v.1.301


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