Diff for /loncom/interface/lonprintout.pm between versions 1.281 and 1.290

version 1.281, 2004/03/12 16:23:23 version 1.290, 2004/04/07 18:01:19
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 output_data {  sub output_data {
     my ($r,$helper,$rparmhash) = @_;      my ($r,$helper,$rparmhash) = @_;
     my %parmhash = %$rparmhash;      my %parmhash = %$rparmhash;
Line 739  ENDPART Line 750  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 817  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 861  ENDPART Line 863  ENDPART
  } elsif ($currentURL=~/\/smppg$/) {    } elsif ($currentURL=~/\/smppg$/) { 
  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'};
  my $texversion=&Apache::lonnet::ssi($currentURL,%form);   my $texversion=&Apache::lonnet::ssi($currentURL,%form);
  $result .= $texversion;   $result .= $texversion;
Line 888  ENDPART Line 885  ENDPART
         #-- produce an output string          #-- produce an output string
  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 974  ENDPART Line 966  ENDPART
  &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 986  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;  
  }  
  &Apache::lonnet::appenv(%moreenv);  
  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 $num_todo=$helper->{'VARS'}->{'NUMBER_TO_PRINT_TOTAL'};
  my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,   my $code_name=$helper->{'VARS'}->{'ANON_CODE_STORAGE_NAME'};
                                                                         $ENV{'request.course.id'},'tex');   if ($helper->{'VARS'}->{'REMEBER_ANON_CODES'} != 1) {
  my $lonidsdir=$r->dir_config('lonIDsDir');       $code_name=undef;
  my $envfile=$ENV{'user.environment'};   }
  $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 $flag_latex_header_remove = 'NO'; 
  my $current_counter=$ENV{'form.counter'};   my %moreenv = ('textwidth' => &get_textwidth($helper,$LaTeXwidth));
  if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||   my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$num_todo,'inline');
    ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {   my $seed=time+($$<<16)+($$);
     my %form;   my %allcodes;
     $form{'answer_output_mode'}='tex';   for (my $i=0;$i<$num_todo;$i++) {
     $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};       $moreenv{'CODE'}=&get_CODE(\%allcodes,$i,$seed,'6');
     my $ansrendered = &Apache::loncommon::get_student_answers($curresline,$username,$userdomain,$ENV{'request.course.id'},%form);       my ($output,$fullname)=
     &Apache::lonnet::appenv(('form.counter' => $current_counter));   &print_resources($r,$helper,'anonymous',$type,\%moreenv,
     if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {    \@master_seq,$flag_latex_header_remove);
  $rendered=~s/(\\keephidden{ENDOFPROBLEM})/$ansrendered$1/;       $print_array[$i].=$output;
     } else {       &Apache::lonhtmlcommon::Increment_PrgWin($r,\%prog_state,
  $rendered=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});         &mt('last assignment').' '.$fullname);
  $rendered.='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($curresline).'}\vskip 0 mm ';       $flag_latex_header_remove = 'YES';
  $rendered.=&path_to_problem ($curresline,$LaTeXwidth);   }
  $rendered.='\vskip 1 mm '.$ansrendered;   if ($code_name) {
     }       my $cdom = $ENV{'course.'.$ENV{'request.course.id'}.'.domain'};
  }       my $cnum = $ENV{'course.'.$ENV{'request.course.id'}.'.num'};
  if ($flag_latex_header_remove eq 'YES') {       &Apache::lonnet::put('CODEs',
     $rendered = &latex_header_footer_remove($rendered);    { $code_name => join(',',keys(%allcodes)) },
  } else {    $cdom,$cnum);
     $rendered =~ s/\\end{document}//;   }
  }   &Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
  $current_output .= $rendered;   $result .= $print_array[0].'  \end{document}';
     }       } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_from_directory') {      
     $flag_latex_header_remove = '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 $blanspages = '';  
  for (my $j=0;$j<$helper->{'VARS'}->{'EMPTY_PAGES'};$j++) {$blanspages.='\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 '.$blanspages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$fullname.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$currentassignment.'}}} \vskip -5 mm '.$current_output;  
     }  
             $print_array[int($student_counter/$helper->{'VARS'}->{'NUMBER_TO_PRINT'})].=$current_output;  
             $student_names[int($student_counter/$helper->{'VARS'}->{'NUMBER_TO_PRINT'})].=$person.':'.$fullname.'_END_';  
     &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}';  
  &Apache::lonnet::delenv('form.textwidth');  
     } 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 1084  ENDPART Line 1049  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 1231  ENDPART Line 1191  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;
       srand($seed);
       my $newcode;
       while(1) {
    $newcode=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 1325  sub printHelper { Line 1371  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 1385  sub printHelper { Line 1432  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 1422  sub printHelper { Line 1472  sub printHelper {
 #    $r->print($helper->{VARS}->{'postdata'});  #    $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 1449  sub printHelper { Line 1499  sub printHelper {
         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 1459  sub printHelper { Line 1510  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 1475  HELPERFRAGMENT Line 1527  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>Problems</b> from <b><i>$sequenceTitle</i></b> for <b>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>Problems</b> from <b><i>$sequenceTitle</i></b> for <b>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 1504  HELPERFRAGMENT Line 1558  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
           &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>
       <choices variable="REMEBER_ANON_CODES" allowempty="1" multichoice="1">
         <choice computer="1">
           Should the CODEs used on this printing be remebered for later?
         </choice>
       </choices>
       <message><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>
       $resource_selector
     </state>
   CHOOSE_ANON1
   
  addMessage("<hr width='33%' /><b>Number of assignments printed at the same time: </b>");  
         $paramHash = Apache::lonhelper::getParamHash();  
  $paramHash->{'variable'} = 'NUMBER_TO_PRINT';     
  $helper->declareVar('NUMBER_TO_PRINT');           
  addMessage("<input type='text' name='NUMBER_TO_PRINT.forminput' size='3' value='all' /><hr width='33%' />");  
   
  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>Resources</b> from <b><i>$sequenceTitle</i></b> for <b>selected students</b>", 'resources_for_students', 'CHOOSE_STUDENTS1'];
       push @{$printChoices}, ["<b>Resources</b> from <b><i>$sequenceTitle</i></b> for <b>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 1532  CHOOSE_STUDENTS Line 1607  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';         <message><hr width='33%' /><b>How many Anonymous exams to print?</b></message>
  $helper->declareVar('NUMBER_TO_PRINT');               <string variable="NUMBER_TO_PRINT_TOTAL" maxlength="5" size="5"></string>
  addMessage("<input type='text' name='NUMBER_TO_PRINT.forminput' size='3' value='all' /><hr width='33%' />");      <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.
Line 1588  CHOOSE_FROM_SUBDIR Line 1674  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 1621  CHOOSE_FROM_ANY_SEQUENCE Line 1708  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 1673  CHOOSE_FROM_ANY_SEQUENCE Line 1762  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.281  
changed lines
  Added in v.1.290


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