--- loncom/interface/lonprintout.pm 2011/09/13 21:43:03 1.596 +++ loncom/interface/lonprintout.pm 2011/11/05 22:50:47 1.603 @@ -2,7 +2,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.596 2011/09/13 21:43:03 raeburn Exp $ +# $Id: lonprintout.pm,v 1.603 2011/11/05 22:50:47 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(); @@ -1803,6 +1808,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 +1865,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 +1930,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 +2051,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'}); @@ -2264,9 +2271,12 @@ sub print_construction_sequence { # IF sequence, recurse: if ($urlp =~ /\.sequence$/) { +# +# FIXME: this does not work for co-authors my $sequence_url = $urlp; my $domain = $env{'user.domain'}; # Constr. space only on local my $user = $env{'user.name'}; +# FIXME: the substitutions below do not seem to make sense $sequence_url =~ s/^\/res\/$domain/\/home/; $sequence_url =~ s/^(\/home\/$user)/$1\/public_html/; @@ -2328,6 +2338,7 @@ sub print_construction_sequence { sub output_data { my ($r,$helper,$rparmhash) = @_; + my %parmhash = %$rparmhash; $ssi_error = 0; # This will be set nonzero by failing ssi's. $resources_printed = ''; @@ -2443,11 +2454,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 +2498,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 +2520,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}'; } @@ -2545,6 +2557,7 @@ ENDPART && $currentURL=~/\.(sequence|page)$/ && $helper->{'VARS'}->{'construction'} eq '1') { #printing content of sequence from the construction space +# FIXME: unclear how this would work $currentURL=~s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|; $result .= &print_construction_sequence($currentURL, $helper, %form, @@ -3036,11 +3049,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') || @@ -3071,9 +3080,7 @@ ENDPART } #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); @@ -3262,6 +3269,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 @@ -3466,8 +3474,6 @@ sub handler { &init_perm(); - - my $helper = printHelper($r); if (!ref($helper)) { return $helper; @@ -3631,8 +3637,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'}) { @@ -3993,14 +3999,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'", @@ -4134,10 +4135,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', < @@ -4178,7 +4178,7 @@ CHOOSE_STUDENTS1 - Bubble sheet type: + Bubblesheet type: $codechoice