--- loncom/interface/lonprintout.pm 2006/02/10 11:56:49 1.421 +++ loncom/interface/lonprintout.pm 2006/03/01 11:20:37 1.424 @@ -1,7 +1,7 @@ # The LearningOnline Network # Printout # -# $Id: lonprintout.pm,v 1.421 2006/02/10 11:56:49 foxr Exp $ +# $Id: lonprintout.pm,v 1.424 2006/03/01 11:20:37 foxr Exp $ # # Copyright Michigan State University Board of Trustees # @@ -226,6 +226,18 @@ sub latex_header_footer_remove { $text =~ s/\\documentclass([^&]*)\\begin{document}//; return $text; } +# +# If necessary, encapsulate text inside +# a minipage env. +# necessity is determined by the problem_split param. +# +sub encapsulate_minipage { + my ($text) = @_; + if (!(env{'form.problem.split'} =~ /yes/i)) { + $text = '\begin{minipage}{\textwidth}'.$text.'\end{minipage}'; + } + return $text; +} sub character_chart { @@ -1116,6 +1128,9 @@ ENDPART &Apache::lonnet::delenv('form.counter'); &Apache::lonnet::delenv('request.filename'); } + # current document with answers.. no need to encap in minipage + # since there's only one answer. + if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') || ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) { $form{'problem_split'}=$parmhash{'problem_stream_switch'}; @@ -1192,10 +1207,14 @@ ENDPART if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') { $texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/; } else { + # If necessary, encapsulate answer in minipage: + $texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); - $texversion.='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'}).'}\vskip 0 mm '; - $texversion.=&path_to_problem($urlp,$LaTeXwidth); - $texversion.='\vskip 1 mm '.$answer.'\end{document}'; + my $body ='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'}).'}\vskip 0 mm '; + $body.=&path_to_problem($urlp,$LaTeXwidth); + $body.='\vskip 1 mm '.$answer.'\end{document}'; + $body = &encapsulate_minipage($body); + $texversion.=$body; } } if ($flag_latex_header_remove ne 'NO') { @@ -1305,9 +1324,11 @@ ENDPART } else { if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library)$/) { $texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); - $texversion.='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($master_seq[$i]).'}\vskip 0 mm '; - $texversion.=&path_to_problem ($urlp,$LaTeXwidth); - $texversion.='\vskip 1 mm '.$answer; + my $body ='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($master_seq[$i]).'}\vskip 0 mm '; + $body .= &path_to_problem ($urlp,$LaTeXwidth); + $body .='\vskip 1 mm '.$answer; + $body = &encapsulate_minipage($body); + $texversion .= $body; } else { $texversion=''; } @@ -1418,8 +1439,7 @@ ENDPART $person,$type, \%moreenv,\@master_seq, $flag_latex_header_remove, - $LaTeXwidth, - $number_of_columns); + $LaTeXwidth); $resources_printed .= ":"; $print_array[$i].=$output; $student_names[$i].=$person.':'.$fullname.'_END_'; @@ -1725,7 +1745,7 @@ sub get_CODE { sub print_resources { my ($r,$helper,$person,$type,$moreenv,$master_seq,$remove_latex_header, - $LaTeXwidth,$number_of_columns)=@_; + $LaTeXwidth)=@_; my $current_output = ''; my $printed = ''; my ($username,$userdomain,$usersection) = split /:/,$person; @@ -1778,10 +1798,14 @@ sub print_resources { 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($res_url,$LaTeXwidth); - $rendered.='\vskip 1 mm '.$ansrendered; + + + my $header =&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'}); + my $body ='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($curresline).'}\vskip 0 mm '; + $body .=&path_to_problem($res_url,$LaTeXwidth); + $body .='\vskip 1 mm '.$ansrendered; + $body = &encapsulate_minipage($body); + $rendered = $header.$body; } } if ($remove_latex_header eq 'YES') { @@ -2145,7 +2169,19 @@ ALL_PROBLEMS push @{$printChoices}, ["".&mt('Problems')." ".&mt('from')." $sequenceTitle ".&mt('for')." ".&mt('selected students')."", 'problems_for_students', 'CHOOSE_STUDENTS']; push @{$printChoices}, ["".&mt('Problems')." ".&mt('from')." $sequenceTitle ".&mt('for')." ".&mt('anonymous students')."", 'problems_for_anon', 'CHOOSE_ANON1']; } + + # resource_selector will hold a few states that: + # - Allow resources to be selected for printing. + # - Determine pagination between assignments. + # - Determine how many assignments should be bundled into a single PDF. + # TODO: + # Probably good to do things like separate this up into several vars, each + # with one state, and use REGEXPs at inclusion time to set state names + # and next states for better mix and match capability + # my $resource_selector=< + PRINT_FORMATTING
Select resources for the assignment
@@ -2154,6 +2190,9 @@ ALL_PROBLEMS return $symbFilter; + + + NUMBER_PER_PDF
How should the results be printed?
Start each student\'s assignment on a new page/column (add a pagefeed after each assignment) @@ -2161,20 +2200,24 @@ ALL_PROBLEMS Add two empty pages/column after each student\'s assignment Add three empty pages/column after each student\'s assignment +
+ + PAGESIZE
Number of assignments printed at the same time:
"all" +
RESOURCE_SELECTOR &Apache::lonxml::xmlparse($r, 'helper', < - + Select sort order Sort by section then student Sort by students across sections. - $resource_selector + $resource_selector CHOOSE_STUDENTS my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'}; @@ -2220,7 +2263,7 @@ CHOOSE_STUDENTS } &Apache::lonxml::xmlparse($r, 'helper', < - PAGESIZE + SELECT_PROBLEMS
Number of anonymous assignments to print: @@ -2266,8 +2309,8 @@ CHOOSE_STUDENTS

- $resource_selector + $resource_selector CHOOSE_ANON1 @@ -2278,6 +2321,8 @@ CHOOSE_ANON1 $resource_selector=< + PRINT_FORMATTING
Select resources for the assignment
@@ -2286,6 +2331,9 @@ CHOOSE_ANON1 return $symbFilter; + + + NUMBER_PER_PDF
How should the results be printed?
Start each student\'s assignment on a new page/column (add a pagefeed after each assignment) @@ -2293,25 +2341,29 @@ CHOOSE_ANON1 Add two empty pages/column after each student\'s assignment Add three empty pages/column after each student\'s assignment +
+ + PAGESIZE
Number of assignments printed at the same time:
"all" +
RESOURCE_SELECTOR &Apache::lonxml::xmlparse($r, 'helper', < - + Sort by section then student Sort by students across sections. - $resource_selector + $resource_selector CHOOSE_STUDENTS1 &Apache::lonxml::xmlparse($r, 'helper', < - PAGESIZE + SELECT_RESOURCES
Number of anonymous assignments to print: @@ -2357,8 +2409,8 @@ CHOOSE_STUDENTS1

- $resource_selector + $resource_selector CHOOSE_ANON2 }