Diff for /loncom/interface/lonprintout.pm between versions 1.595 and 1.602

version 1.595, 2011/06/22 11:00:47 version 1.602, 2011/11/05 21:49:25
Line 123  sub create_incomplete_folder_selstud_hel Line 123  sub create_incomplete_folder_selstud_hel
   
     my $format_chooser = &generate_format_selector($helper,      my $format_chooser = &generate_format_selector($helper,
  'Format of the print job',   'Format of the print job',
  '','CHOOSE_STUDENTS_INCOMPLETE_FORMAT'); # end state.   'CHOOSE_STUDENTS_INCOMPLETE_FORMAT'); # end state.
   
     return $resource_chooser . $student_chooser . $format_chooser;      return $resource_chooser . $student_chooser . $format_chooser;
 }    }  
Line 172  sub create_incomplete_course_helper { Line 172  sub create_incomplete_course_helper {
   
     my $format = &generate_format_selector($helper,      my $format = &generate_format_selector($helper,
    'Format of the print job',     'Format of the print job',
    '',  
    'INCOMPLETE_PROBLEMS_COURSE_FORMAT'); # end state.     'INCOMPLETE_PROBLEMS_COURSE_FORMAT'); # end state.
   
     return $resource_chooser . $people_chooser . $format;      return $resource_chooser . $people_chooser . $format;
Line 356  sub generate_code_selector { Line 355  sub generate_code_selector {
     <message></td><td></message>      <message></td><td></message>
     <string variable="ANON_CODE_STORAGE_NAME" maxlength="50" size="20" />      <string variable="ANON_CODE_STORAGE_NAME" maxlength="50" size="20" />
     <message></td></tr><tr><td></message>      <message></td></tr><tr><td></message>
     <message><b>Bubble sheet type:</b></message>      <message><b>Bubblesheet type:</b></message>
     <message></td><td></message>      <message></td><td></message>
     <dropdown variable="CODE_OPTION" multichoice="0" allowempty="0">      <dropdown variable="CODE_OPTION" multichoice="0" allowempty="0">
     $bubble_types      $bubble_types
Line 395  CHOOSE_ANON1 Line 394  CHOOSE_ANON1
    return $result;     return $result;
 }  }
   
   #  Returns the XML for choosing how assignments are to be formatted 
   #  that text must still be parsed by the helper xml parser.
   # Parameters: 3 (required)
   
   #   helper       - The helper; $helper->{'VARS'}->{'PRINT_TYPE'} used
   #                  to check if splitting PDFs by section can be offered.
   #   title        - Title for the current state. 
   #   this_state   - State name of the chooser.
   
 sub generate_format_selector {  sub generate_format_selector {
     my ($helper,$title,$nextstate, $thisstate) = @_;      my ($helper,$title,$this_state) = @_;
     my $secpdfoption;      my $secpdfoption;
     my $state = 'PRINT_FORMATTING';  
     if ($thisstate) {  
  $state = $thisstate;  
     }  
     unless (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_anon')     ||      unless (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_anon')     ||
             ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_anon_page') ||              ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_anon_page') ||
             ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_anon')  ) {              ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_anon')  ) {
         $secpdfoption =  '<choice computer="sections">Each PDF contains exactly one section</choice>';          $secpdfoption =  '<choice computer="sections">Each PDF contains exactly one section</choice>';
     }      }
     return <<RESOURCE_SELECTOR;      return <<RESOURCE_SELECTOR;
     <state name="$state" title="$title">      <state name="$this_state" title="$title">
     $nextstate  
     <message><br /><big><i><b>How should the results be printed?</b></i></big><br /></message>      <message><br /><big><i><b>How should the results be printed?</b></i></big><br /></message>
     <choices variable="EMPTY_PAGES">      <choices variable="EMPTY_PAGES">
       <choice computer='0'>Start each student\'s assignment on a new page/column (add a pagefeed after each assignment)</choice>        <choice computer='0'>Start each student\'s assignment on a new page/column (add a pagefeed after each assignment)</choice>
Line 468  sub incomplete { Line 471  sub incomplete {
 #   $helper - The helper we need $helper->{'VARS'}->{'symb'}  #   $helper - The helper we need $helper->{'VARS'}->{'symb'}
 #            to construct the navmap and the iteration.  #            to construct the navmap and the iteration.
 #   $seq   - The original set of resources to print   #   $seq   - The original set of resources to print 
 #            (really an array of resource names  #            (really an array of resource names (array of symb's).
 #   $who   - Student/domain for whome the sequence will be generated.  #   $who   - Student/domain for whome the sequence will be generated.
 #  #
 # Implicit inputs:  # Implicit inputs:
Line 483  sub master_seq_to_person_seq { Line 486  sub master_seq_to_person_seq {
   
     my ($username, $userdomain, $usersection) = split(/:/, $who);      my ($username, $userdomain, $usersection) = split(/:/, $who);
   
   
     # Toss the sequence up into a hash so that we have O(1) lookup time.      # Toss the sequence up into a hash so that we have O(1) lookup time.
     # on the items that come out of the user's list of resources.      # on the items that come out of the user's list of resources.
     #      #
Line 512  sub master_seq_to_person_seq { Line 516  sub master_seq_to_person_seq {
     my $curres;      my $curres;
     while ($curres = $iterator->next()) {      while ($curres = $iterator->next()) {
  #   #
  #  Only process resources..that re not removed by randomout...   #  Only process resources..that are not removed by randomout...
    #  and are selected for printint as well.
  #   #
  if (! exists $nonResourceItems{$curres} && ! $curres->randomout()) {   if (! exists $nonResourceItems{$curres} && ! $curres->randomout()) {
     my $symb = $curres->symb();      my $symb = $curres->symb();
Line 1803  sub map_laystyle { Line 1808  sub map_laystyle {
   
 sub print_page_in_course {  sub print_page_in_course {
     my ($helper, $rparmhash, $currentURL, $resources) = @_;      my ($helper, $rparmhash, $currentURL, $resources) = @_;
   
     my %parmhash       = %$rparmhash;      my %parmhash       = %$rparmhash;
     my @page_resources = @$resources;      my @page_resources = @$resources;
     my $mode = $helper->{'VARS'}->{'LATEX_TYPE'};      my $mode = $helper->{'VARS'}->{'LATEX_TYPE'};
Line 1859  sub print_page_in_course { Line 1865  sub print_page_in_course {
  }   }
  # these resources go through the XML transformer:   # these resources go through the XML transformer:
   
  elsif ($resource_src =~ /\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm)$/)  {   elsif ($resource_src =~ /\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm)$/)  {
   
     my $urlp = &Apache::lonnet::clutter($resource_src);      my $urlp = &Apache::lonnet::clutter($resource_src);
   
     my %form;      my %form;
     my %moreenv;      my %moreenv;
   
Line 1922  sub print_page_in_course { Line 1930  sub print_page_in_course {
  $texversion.='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm ';   $texversion.='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm ';
  $texversion.=&path_to_problem($urlp,$LaTeXwidth);   $texversion.=&path_to_problem($urlp,$LaTeXwidth);
     } else {      } else {
  $texversion.='\vskip 0 mm \noindent\textbf{Prints from construction space - there is no title.}\vskip 0 mm ';   $texversion.='\vskip 0 mm \noindent\textbf{'.
  my $URLpath=$urlp;                          &mt("Printing from Construction Space: No Title").'}\vskip 0 mm ';
  $URLpath=~s/~([^\/]+)/public_html\/$1\/$1/;   $texversion.=&path_to_problem($urlp,$LaTeXwidth);
  $texversion.=&path_to_problem($URLpath,$LaTeXwidth);  
     }      }
     $texversion.='\vskip 1 mm '.$answer.'\end{document}';      $texversion.='\vskip 1 mm '.$answer.'\end{document}';
  }   }
Line 2044  sub recently_generated { Line 2051  sub recently_generated {
 #    A reference to a page break hash.  #    A reference to a page break hash.
 #  #
 #  #
 # use Data::Dumper;  use Data::Dumper;
 # sub dump_helper_vars {  # sub dump_helper_vars {
 #    my ($helper) = @_;  #    my ($helper) = @_;
 #    my $helpervars = Dumper($helper->{'VARS'});  #    my $helpervars = Dumper($helper->{'VARS'});
Line 2264  sub print_construction_sequence { Line 2271  sub print_construction_sequence {
     # IF sequence, recurse:      # IF sequence, recurse:
           
     if ($urlp =~ /\.sequence$/) {      if ($urlp =~ /\.sequence$/) {
   #
   # FIXME: this does not work for co-authors
  my $sequence_url = $urlp;   my $sequence_url = $urlp;
  my $domain       = $env{'user.domain'}; # Constr. space only on local   my $domain       = $env{'user.domain'}; # Constr. space only on local
  my $user         = $env{'user.name'};   my $user         = $env{'user.name'};
   # FIXME: the substitutions below do not seem to make sense
   
  $sequence_url    =~ s/^\/res\/$domain/\/home/;   $sequence_url    =~ s/^\/res\/$domain/\/home/;
  $sequence_url    =~ s/^(\/home\/$user)/$1\/public_html/;   $sequence_url    =~ s/^(\/home\/$user)/$1\/public_html/;
Line 2328  sub print_construction_sequence { Line 2338  sub print_construction_sequence {
   
 sub output_data {  sub output_data {
     my ($r,$helper,$rparmhash) = @_;      my ($r,$helper,$rparmhash) = @_;
   
     my %parmhash = %$rparmhash;      my %parmhash = %$rparmhash;
     $ssi_error = 0; # This will be set nonzero by failing ssi's.      $ssi_error = 0; # This will be set nonzero by failing ssi's.
     $resources_printed = '';      $resources_printed = '';
Line 2443  ENDPART Line 2454  ENDPART
  } else {   } else {
   
             #prints resource from the construction space              #prints resource from the construction space
     $currentURL='/'.$helper->{'VARS'}->{'filename'};      $currentURL=$helper->{'VARS'}->{'filename'};
     if ($currentURL=~/([^?]+)/) {$currentURL=$1;}  
     $cleanURL=$currentURL;      $cleanURL=$currentURL;
  }   }
  $selectionmade = 1;   $selectionmade = 1;
         
  if ($cleanURL!~m|^/adm/|   if ($cleanURL!~m|^/adm/|
     && $cleanURL=~/\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm)$/) {      && $cleanURL=~/\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm)$/) {
     my $rndseed=time;      my $rndseed=time;
Line 2487  ENDPART Line 2498  ENDPART
   
     if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||      if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||
        ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {         ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {
   
  $form{'problem_split'}=$parmhash{'problem_stream_switch'};   $form{'problem_split'}=$parmhash{'problem_stream_switch'};
  $form{'grade_target'}='answer';   $form{'grade_target'}='answer';
  $form{'answer_output_mode'}='tex';   $form{'answer_output_mode'}='tex';
Line 2508  ENDPART Line 2520  ENDPART
  $texversion.='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm ';   $texversion.='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm ';
  $texversion.=&path_to_problem($cleanURL,$LaTeXwidth);   $texversion.=&path_to_problem($cleanURL,$LaTeXwidth);
     } else {      } else {
  $texversion.='\vskip 0 mm \noindent\textbf{Prints from construction space - there is no title.}\vskip 0 mm ';   $texversion.='\vskip 0 mm \noindent\textbf{'.
  my $URLpath=$cleanURL;                          &mt("Printing from Construction Space: No Title").'}\vskip 0 mm ';
  $URLpath=~s/~([^\/]+)/public_html\/$1\/$1/;  
  $texversion.=&path_to_problem($URLpath,$LaTeXwidth);   $texversion.=&path_to_problem($cleanURL,$LaTeXwidth);
     }      }
     $texversion.='\vskip 1 mm '.$answer.'\end{document}';      $texversion.='\vskip 1 mm '.$answer.'\end{document}';
  }   }
Line 2545  ENDPART Line 2557  ENDPART
  && $currentURL=~/\.(sequence|page)$/ && $helper->{'VARS'}->{'construction'} eq '1') {   && $currentURL=~/\.(sequence|page)$/ && $helper->{'VARS'}->{'construction'} eq '1') {
             #printing content of sequence from the construction space              #printing content of sequence from the construction space
   
   # FIXME: unclear how this would work
   
     $currentURL=~s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|;      $currentURL=~s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|;
     $result .= &print_construction_sequence($currentURL, $helper, %form,      $result .= &print_construction_sequence($currentURL, $helper, %form,
Line 2928  ENDPART Line 2941  ENDPART
   
  my $code_option=$helper->{'VARS'}->{'CODE_OPTION'};   my $code_option=$helper->{'VARS'}->{'CODE_OPTION'};
          my @lines = &Apache::grades::get_scantronformat_file();           my @lines = &Apache::grades::get_scantronformat_file();
  my ($code_type,$code_length)=('letter',6);   my ($code_type,$code_length,$bubbles_per_row)=('letter',6,10);
  foreach my $line (@lines) {   foreach my $line (@lines) {
      my ($name,$type,$length) = (split(/:/,$line))[0,2,4];               chomp($line);
        my ($name,$type,$length,$bubbles_per_item) = 
                    (split(/:/,$line))[0,2,4,17];
      if ($name eq $code_option) {       if ($name eq $code_option) {
  $code_length=$length;   $code_length=$length;
  if ($type eq 'number') { $code_type = 'number'; }   if ($type eq 'number') { $code_type = 'number'; }
                    chomp($bubbles_per_item); 
                    if (($bubbles_per_item ne '') && ($bubbles_per_item > 0)) {
                        $bubbles_per_row = $bubbles_per_item; 
                    }
      }       }
  }   }
  my %moreenv = ('textwidth' => &get_textwidth($helper,$LaTeXwidth));   my %moreenv = ('textwidth' => &get_textwidth($helper,$LaTeXwidth));
  $moreenv{'problem_split'}    = $parmhash{'problem_stream_switch'};   $moreenv{'problem_split'}    = $parmhash{'problem_stream_switch'};
          $moreenv{'instructor_comments'}='hide';           $moreenv{'instructor_comments'}='hide';
            $moreenv{'bubbles_per_row'} = $bubbles_per_row;
  my $seed=time+($$<<16)+($$);   my $seed=time+($$<<16)+($$);
  my @allcodes;   my @allcodes;
  if ($old_name) {   if ($old_name) {
Line 3255  sub print_resources { Line 3275  sub print_resources {
     my ($username,$userdomain,$usersection) = split /:/,$person;      my ($username,$userdomain,$usersection) = split /:/,$person;
     my $fullname = &get_name($username,$userdomain);      my $fullname = &get_name($username,$userdomain);
     my $namepostfix = "\\\\"; # Both anon and not anon should get the same vspace.      my $namepostfix = "\\\\"; # Both anon and not anon should get the same vspace.
   
     #      #
     # Figure out if we need to filter the output by      # Figure out if we need to filter the output by
     # the incomplete problems for that person      # the incomplete problems for that person
Line 3265  sub print_resources { Line 3286  sub print_resources {
  ($print_type eq 'incomplete_problems_selpeople_course')) {   ($print_type eq 'incomplete_problems_selpeople_course')) {
  $print_incomplete = 1;   $print_incomplete = 1;
     }      }
     if ($person =~ 'anon') {      if ($person eq 'anonymous') {
  $namepostfix .="Name: ";   $namepostfix .="Name: ";
  $fullname = "CODE - ".$moreenv->{'CODE'};   $fullname = "CODE - ".$moreenv->{'CODE'};
     }      }
Line 3459  sub handler { Line 3480  sub handler {
           
     &init_perm();      &init_perm();
   
   
   
     my $helper = printHelper($r);      my $helper = printHelper($r);
     if (!ref($helper)) {      if (!ref($helper)) {
  return $helper;   return $helper;
Line 3624  sub printHelper { Line 3643  sub printHelper {
     }      }
   
     # Detect whether we're coming from construction space      # Detect whether we're coming from construction space
     if ($env{'form.postdata'}=~/^(?:http:\/\/[^\/]+\/|\/|)\~([^\/]+)\/(.*)$/) {      if ($env{'form.postdata'}=~m{^/priv}) {
         $helper->{VARS}->{'filename'} = "~$1/$2";          $helper->{VARS}->{'filename'} = $env{'form.postdata'};
         $helper->{VARS}->{'construction'} = 1;          $helper->{VARS}->{'construction'} = 1;
     } else {      } else {
         if ($env{'form.postdata'}) {          if ($env{'form.postdata'}) {
Line 3986  ALL_PROBLEMS Line 4005  ALL_PROBLEMS
   $map,    $map,
   $isProblem, '', $symbFilter,    $isProblem, '', $symbFilter,
   $start_new_option);    $start_new_option);
         my $secpdfoption;  
         unless (($helper->{'VARS'} eq 'problems_for_anon')     ||  
                 ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_anon_page') ||  
                 ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_anon')  ) {  
             $secpdfoption =  '<choice computer="sections">Each PDF contains exactly one section</choice>';  
         }  
  $resource_selector .=  &generate_format_selector($helper,   $resource_selector .=  &generate_format_selector($helper,
                                                          'How should results be printed?').                                                           'How should results be printed?',
                                                            'PRINT_FORMATTING').
                                &generate_resource_chooser('CHOOSE_STUDENTS_PAGE',                                 &generate_resource_chooser('CHOOSE_STUDENTS_PAGE',
  'Select Problem(s) to print',   'Select Problem(s) to print',
  "multichoice='1' addstatus='1' closeallpages ='1'",   "multichoice='1' addstatus='1' closeallpages ='1'",
Line 4127  ALL_PROBLEMS Line 4141  ALL_PROBLEMS
     </state>      </state>
 RESOURCE_SELECTOR  RESOURCE_SELECTOR
   
         my $nextstate = '<nextstate>NUMBER_PER_PDF</nextstate>';   
         $resource_selector .= &generate_format_selector($helper,          $resource_selector .= &generate_format_selector($helper,
                                                         'Format of the print job',                                                          'Format of the print job',
                                                         $nextstate);                                                          'PRINT_FORMATTING');
  &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS1);   &Apache::lonxml::xmlparse($r, 'helper', <<CHOOSE_STUDENTS1);
   <state name="CHOOSE_STUDENTS1" title="Select Students and Resources">    <state name="CHOOSE_STUDENTS1" title="Select Students and Resources">
     <choices variable='student_sort'>      <choices variable='student_sort'>
Line 4171  CHOOSE_STUDENTS1 Line 4184  CHOOSE_STUDENTS1
     <message></td><td></message>      <message></td><td></message>
     <string variable="ANON_CODE_STORAGE_NAME" maxlength="50" size="20" />      <string variable="ANON_CODE_STORAGE_NAME" maxlength="50" size="20" />
     <message></td></tr><tr><td></message>      <message></td></tr><tr><td></message>
     <message><b>Bubble sheet type:</b></message>      <message><b>Bubblesheet type:</b></message>
     <message></td><td></message>      <message></td><td></message>
     <dropdown variable="CODE_OPTION" multichoice="0" allowempty="0">      <dropdown variable="CODE_OPTION" multichoice="0" allowempty="0">
     $codechoice      $codechoice

Removed from v.1.595  
changed lines
  Added in v.1.602


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