Diff for /loncom/interface/lonprintout.pm between versions 1.283 and 1.284

version 1.283, 2004/03/19 21:54:48 version 1.284, 2004/03/23 01:34:17
Line 974  ENDPART Line 974  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 1000  ENDPART Line 1004  ENDPART
  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)) {   $selectionmade="Seems to be useless";
  my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,   my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'};
                                                                         $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 ($flag_latex_header_remove eq 'YES') {  
     $rendered = &latex_header_footer_remove($rendered);  
  } else {  
     $rendered =~ s/\\end{document}//;  
  }  
  $current_output .= $rendered;  
     }  
     $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}';  
     } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_from_directory') {            } 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;
Line 1236  FINALEND Line 1188  FINALEND
 }  }
   
   
   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);
       
       #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 1473  HELPERFRAGMENT Line 1487  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" multichoice="1"
Line 1485  HELPERFRAGMENT Line 1496  HELPERFRAGMENT
       <filterfunc>return $isProblemOrMap;</filterfunc>        <filterfunc>return $isProblemOrMap;</filterfunc>
       <choicefunc>return $isProblem;</choicefunc>        <choicefunc>return $isProblem;</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_anonymous', 'CHOOSE_ANON1'];
    }
    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">      <resource variable="RESOURCES" multichoice="1" addstatus="1">
       <filterfunc>return $isProblem;</filterfunc>        <filterfunc>return $isProblem;</filterfunc>
       <mapurl>$map</mapurl>        <mapurl>$map</mapurl>
Line 1502  HELPERFRAGMENT Line 1517  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">
       <message><hr width='33%' /><b>How many Anonymous exams to print?</b></message>
       <string variable="NUMBER_TO_PRINT_TOTAL" maxlength="5" size="5"></string>
       <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_anonymous', '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">
       <filterfunc>return $isNotMap;</filterfunc>        <filterfunc>return $isNotMap;</filterfunc>
Line 1530  CHOOSE_STUDENTS Line 1557  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.

Removed from v.1.283  
changed lines
  Added in v.1.284


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