--- loncom/interface/lonprintout.pm 2011/06/22 11:00:47 1.595 +++ loncom/interface/lonprintout.pm 2011/11/07 20:05:56 1.609 @@ -2,7 +2,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.595 2011/06/22 11:00:47 foxr Exp $ +# $Id: lonprintout.pm,v 1.609 2011/11/07 20:05:56 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -123,7 +123,7 @@ sub create_incomplete_folder_selstud_hel my $format_chooser = &generate_format_selector($helper, 'Format of the print job', - '','CHOOSE_STUDENTS_INCOMPLETE_FORMAT'); # end state. + 'CHOOSE_STUDENTS_INCOMPLETE_FORMAT'); # end state. return $resource_chooser . $student_chooser . $format_chooser; } @@ -172,7 +172,6 @@ sub create_incomplete_course_helper { my $format = &generate_format_selector($helper, 'Format of the print job', - '', 'INCOMPLETE_PROBLEMS_COURSE_FORMAT'); # end state. return $resource_chooser . $people_chooser . $format; @@ -356,7 +355,7 @@ sub generate_code_selector { - Bubble sheet type: + Bubblesheet type: $bubble_types @@ -395,21 +394,25 @@ CHOOSE_ANON1 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 { - my ($helper,$title,$nextstate, $thisstate) = @_; + my ($helper,$title,$this_state) = @_; my $secpdfoption; - my $state = 'PRINT_FORMATTING'; - if ($thisstate) { - $state = $thisstate; - } unless (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_anon') || ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_for_anon_page') || ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'resources_for_anon') ) { $secpdfoption = 'Each PDF contains exactly one section'; } return < - $nextstate +
How should the results be printed?
Start each student\'s assignment on a new page/column (add a pagefeed after each assignment) @@ -468,7 +471,7 @@ sub incomplete { # $helper - The helper we need $helper->{'VARS'}->{'symb'} # to construct the navmap and the iteration. # $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. # # Implicit inputs: @@ -483,6 +486,7 @@ sub master_seq_to_person_seq { my ($username, $userdomain, $usersection) = split(/:/, $who); + # 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. # @@ -512,7 +516,8 @@ sub master_seq_to_person_seq { my $curres; 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()) { my $symb = $curres->symb(); @@ -629,9 +634,10 @@ sub include_pdf { # (unlikely). If it did exist, add the pdf to the set of files/images that # need tob e converted for this print job: - $file =~ s|(.*)/res/|/home/httpd/html/res/|; + my $londocroot = $Apache::lonnet::perlvar{'lonDocRoot'}; + $file =~ s{(.*)/res/}{$londocroot/res/}; - open(FILE,">>/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout.dat"); + open(FILE,">>$Apache::lonnet::perlvar{'lonPrtDir'}/$env{'user.name'}_$env{'user.domain'}_printout.dat"); print FILE ("$file\n"); close (FILE); @@ -1803,6 +1809,7 @@ sub map_laystyle { sub print_page_in_course { my ($helper, $rparmhash, $currentURL, $resources) = @_; + my %parmhash = %$rparmhash; my @page_resources = @$resources; my $mode = $helper->{'VARS'}->{'LATEX_TYPE'}; @@ -1859,8 +1866,10 @@ sub print_page_in_course { } # 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 %form; my %moreenv; @@ -1922,10 +1931,9 @@ sub print_page_in_course { $texversion.='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm '; $texversion.=&path_to_problem($urlp,$LaTeXwidth); } else { - $texversion.='\vskip 0 mm \noindent\textbf{Prints from construction space - there is no title.}\vskip 0 mm '; - my $URLpath=$urlp; - $URLpath=~s/~([^\/]+)/public_html\/$1\/$1/; - $texversion.=&path_to_problem($URLpath,$LaTeXwidth); + $texversion.='\vskip 0 mm \noindent\textbf{'. + &mt("Printing from Construction Space: No Title").'}\vskip 0 mm '; + $texversion.=&path_to_problem($urlp,$LaTeXwidth); } $texversion.='\vskip 1 mm '.$answer.'\end{document}'; } @@ -2044,7 +2052,7 @@ sub recently_generated { # A reference to a page break hash. # # -# use Data::Dumper; +use Data::Dumper; # sub dump_helper_vars { # my ($helper) = @_; # my $helpervars = Dumper($helper->{'VARS'}); @@ -2193,18 +2201,19 @@ sub set_form_extraspace { sub print_construction_sequence { my ($currentURL, $helper, %form, $LaTeXwidth) = @_; - my $result; my $rndseed=time; if ($helper->{'VARS'}->{'curseed'}) { $rndseed=$helper->{'VARS'}->{'curseed'}; } - my $errtext=&LONCAPA::map::mapread($currentURL); + my $errtext=&LONCAPA::map::mapread(&Apache::lonnet::filelocation('',$currentURL)); + # # These make this all support recursing for subsequences. # my @order = @LONCAPA::map::order; my @resources = @LONCAPA::map::resources; + for (my $member=0;$member<=$#order;$member++) { $resources[$order[$member]]=~/^([^:]*):([^:]*):/; my $urlp=$2; @@ -2220,7 +2229,7 @@ sub print_construction_sequence { } if((($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') || ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) && - ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page)$/)) { + ($urlp=~/$LONCAPA::assess_page_re/)) { # Don't permanently modify %$form... my %answerform = %form; $answerform{'grade_target'}='answer'; @@ -2264,14 +2273,7 @@ sub print_construction_sequence { # IF sequence, recurse: if ($urlp =~ /\.sequence$/) { - my $sequence_url = $urlp; - my $domain = $env{'user.domain'}; # Constr. space only on local - my $user = $env{'user.name'}; - - $sequence_url =~ s/^\/res\/$domain/\/home/; - $sequence_url =~ s/^(\/home\/$user)/$1\/public_html/; -# $sequence_url =~ s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|; - $result .= &print_construction_sequence($sequence_url, + $result .= &print_construction_sequence($urlp, $helper, %form, $LaTeXwidth); } @@ -2443,11 +2445,11 @@ ENDPART } else { #prints resource from the construction space - $currentURL='/'.$helper->{'VARS'}->{'filename'}; - if ($currentURL=~/([^?]+)/) {$currentURL=$1;} + $currentURL=$helper->{'VARS'}->{'filename'}; $cleanURL=$currentURL; } $selectionmade = 1; + if ($cleanURL!~m|^/adm/| && $cleanURL=~/\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm)$/) { my $rndseed=time; @@ -2487,6 +2489,7 @@ ENDPART if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') || ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) { + $form{'problem_split'}=$parmhash{'problem_stream_switch'}; $form{'grade_target'}='answer'; $form{'answer_output_mode'}='tex'; @@ -2508,10 +2511,10 @@ ENDPART $texversion.='\vskip 0 mm \noindent\textbf{'.$title.'}\vskip 0 mm '; $texversion.=&path_to_problem($cleanURL,$LaTeXwidth); } else { - $texversion.='\vskip 0 mm \noindent\textbf{Prints from construction space - there is no title.}\vskip 0 mm '; - my $URLpath=$cleanURL; - $URLpath=~s/~([^\/]+)/public_html\/$1\/$1/; - $texversion.=&path_to_problem($URLpath,$LaTeXwidth); + $texversion.='\vskip 0 mm \noindent\textbf{'. + &mt("Printing from Construction Space: No Title").'}\vskip 0 mm '; + + $texversion.=&path_to_problem($cleanURL,$LaTeXwidth); } $texversion.='\vskip 1 mm '.$answer.'\end{document}'; } @@ -2543,10 +2546,6 @@ ENDPART } } elsif ($cleanURL!~m|^/adm/| && $currentURL=~/\.(sequence|page)$/ && $helper->{'VARS'}->{'construction'} eq '1') { - #printing content of sequence from the construction space - - - $currentURL=~s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|; $result .= &print_construction_sequence($currentURL, $helper, %form, $LaTeXwidth); $result .= '\end{document}'; @@ -2708,7 +2707,7 @@ ENDPART $texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/; } } else { - if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page)$/) { + if ($urlp=~/$LONCAPA::assess_page_re/) { $texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); # $texversion =~ s/\\begin{document}//; # FIXME my $title = &Apache::lonnet::gettitle($master_seq[$i]); @@ -2928,17 +2927,24 @@ ENDPART my $code_option=$helper->{'VARS'}->{'CODE_OPTION'}; 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) { - 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) { $code_length=$length; 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)); $moreenv{'problem_split'} = $parmhash{'problem_stream_switch'}; $moreenv{'instructor_comments'}='hide'; + $moreenv{'bubbles_per_row'} = $bubbles_per_row; my $seed=time+($$<<16)+($$); my @allcodes; if ($old_name) { @@ -3029,11 +3035,7 @@ ENDPART if ($urlp=~/\//) { $form{'problem_split'}=$parmhash{'problem_stream_switch'}; $form{'rndseed'}=$rndseed; - if ($urlp =~ m|/home/([^/]+)/public_html|) { - $urlp =~ s|/home/([^/]*)/public_html|/~$1|; - } else { - $urlp =~ s|^$Apache::lonnet::perlvar{'lonDocRoot'}||; - } + $urlp =~ s|^$Apache::lonnet::perlvar{'lonDocRoot'}||; $resources_printed .= $urlp.':'; my $texversion=&ssi_with_retries($urlp, $ssi_retry_count, %form); if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') || @@ -3054,19 +3056,16 @@ ENDPART $texversion.='\vskip 0 mm \noindent '; $texversion.=&path_to_problem ($urlp,$LaTeXwidth); } else { - $texversion.='\vskip 0 mm \noindent\textbf{Prints from construction space - there is no title.}\vskip 0 mm '; - my $URLpath=$urlp; - $URLpath=~s/~([^\/]+)/public_html\/$1\/$1/; - $texversion.=&path_to_problem ($URLpath,$LaTeXwidth); + $texversion.='\vskip 0 mm \noindent\textbf{'. + &mt("Printing from Construction Space: No Title").'}\vskip 0 mm '; + $texversion.=&path_to_problem ($urlp,$LaTeXwidth); } $texversion.='\vskip 1 mm '.$answer.'\end{document}'; } } #this chunk is responsible for printing the path to problem - my $newurlp=$urlp; - if ($newurlp=~/~/) {$newurlp=~s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|;} - $newurlp=&path_to_problem($newurlp,$LaTeXwidth); + my $newurlp=&path_to_problem($urlp,$LaTeXwidth); $texversion =~ s/(\\begin{minipage}{\\textwidth})/$1 $newurlp/; if ($flag_latex_header_remove ne 'NO') { $texversion = &latex_header_footer_remove($texversion); @@ -3115,12 +3114,7 @@ ENDPART my $URLback=''; #link to original document if ($helper->{'VARS'}->{'construction'} eq '1') { - #prints resource from the construction space - $URLback='/'.$helper->{'VARS'}->{'filename'}; - if ($URLback=~/([^?]+)/) { - $URLback=$1; - $URLback=~s|^/~|/priv/|; - } + $URLback=$helper->{'VARS'}->{'filename'}; } # # Final adjustment of the font size: @@ -3255,6 +3249,7 @@ sub print_resources { my ($username,$userdomain,$usersection) = split /:/,$person; my $fullname = &get_name($username,$userdomain); my $namepostfix = "\\\\"; # Both anon and not anon should get the same vspace. + # # Figure out if we need to filter the output by # the incomplete problems for that person @@ -3265,7 +3260,7 @@ sub print_resources { ($print_type eq 'incomplete_problems_selpeople_course')) { $print_incomplete = 1; } - if ($person =~ 'anon') { + if ($person eq 'anonymous') { $namepostfix .="Name: "; $fullname = "CODE - ".$moreenv->{'CODE'}; } @@ -3302,7 +3297,7 @@ sub print_resources { $current_output .= &get_extra_vspaces($helper, $curresline); $i++; if ( !($type eq 'problems' && - ($curresline!~ m/\.(problem|exam|quiz|assess|survey|form|library|page)$/)) ) { + ($curresline!~ m/$LONCAPA::assess_page_re/)) ) { my ($map,$id,$res_url) = &Apache::lonnet::decode_symb($curresline); if ($print_incomplete && !&incomplete($username, $userdomain, $res_url)) { next; @@ -3459,8 +3454,6 @@ sub handler { &init_perm(); - - my $helper = printHelper($r); if (!ref($helper)) { return $helper; @@ -3624,8 +3617,8 @@ sub printHelper { } # Detect whether we're coming from construction space - if ($env{'form.postdata'}=~/^(?:http:\/\/[^\/]+\/|\/|)\~([^\/]+)\/(.*)$/) { - $helper->{VARS}->{'filename'} = "~$1/$2"; + if ($env{'form.postdata'}=~m{^/priv}) { + $helper->{VARS}->{'filename'} = $env{'form.postdata'}; $helper->{VARS}->{'construction'} = 1; } else { if ($env{'form.postdata'}) { @@ -3986,14 +3979,9 @@ ALL_PROBLEMS $map, $isProblem, '', $symbFilter, $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 = 'Each PDF contains exactly one section'; - } $resource_selector .= &generate_format_selector($helper, - 'How should results be printed?'). + 'How should results be printed?', + 'PRINT_FORMATTING'). &generate_resource_chooser('CHOOSE_STUDENTS_PAGE', 'Select Problem(s) to print', "multichoice='1' addstatus='1' closeallpages ='1'", @@ -4127,10 +4115,9 @@ ALL_PROBLEMS
RESOURCE_SELECTOR - my $nextstate = 'NUMBER_PER_PDF'; $resource_selector .= &generate_format_selector($helper, 'Format of the print job', - $nextstate); + 'PRINT_FORMATTING'); &Apache::lonxml::xmlparse($r, 'helper', < @@ -4171,7 +4158,7 @@ CHOOSE_STUDENTS1 - Bubble sheet type: + Bubblesheet type: $codechoice