--- loncom/interface/lonprintout.pm 2006/07/14 21:03:47 1.458
+++ loncom/interface/lonprintout.pm 2006/07/18 18:19:51 1.464
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.458 2006/07/14 21:03:47 www Exp $
+# $Id: lonprintout.pm,v 1.464 2006/07/18 18:19:51 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -47,6 +47,7 @@ use LONCAPA;
my %perm;
my %parmhash;
+my $resources_printed;
# Format a header according to a format.
@@ -626,7 +627,7 @@ my %page_formats=
'2' => ['3.66 in','9.8 in', '-0.57 in','-0.57 in','0.7 cm']
},
'album' => {
- '1' => [ '8.8 in', '6.8 in','-40 pt in', '-60 pt','1 cm'],
+ '1' => [ '8.8 in', '6.8 in','-0.55 in', '-0.83 in','1 cm'],
'2' => [ '4.4 in', '6.8 in','-0.5 in', '-1.5 in','3.5 in']
},
},
@@ -682,12 +683,12 @@ my %page_formats=
},
'a4' => {
'book' => {
- '1' => ['176 mm','272 mm','-40 pt in','-60 pt','-0.5 in'],
- '2' => [ '91 mm','272 mm','-40 pt in','-60 pt','-0.5 in']
+ '1' => ['17.6 cm','27.2 cm','-0.55 in','-0.83 in','-0.5 in'],
+ '2' => [ '9.1 cm','27.2 cm','-0.55 in','-0.83 in','-0.5 in']
},
'album' => {
- '1' => ['8.5 in','7.7 in','-40 pt in','-60 pt','0 in'],
- '2' => ['3.9 in','7.7 in','-40 pt in','-60 pt','0 in']
+ '1' => ['8.5 in','7.7 in','-0.55 in','-0.83 in','0 in'],
+ '2' => ['3.9 in','7.7 in','-0.55 in','-0.83 in','0 in']
},
},
'a5' => {
@@ -1055,10 +1056,110 @@ sub get_page_breaks {
return %page_breaks;
}
+# Output a sequence (recursively if neeed)
+# from construction space.
+# Parameters:
+# url = URL of the sequence to print.
+# helper - Reference to the helper hash.
+# form - Copy of the format hash.
+# LaTeXWidth
+# Returns:
+# Text to add to the printout.
+# NOTE if the first element of the outermost sequence
+# is itself a sequence, the outermost caller may need to
+# prefix the latex with the page headers stuff.
+#
+sub print_construction_sequence {
+ my ($currentURL, $helper, %form, $LaTeXwidth) = @_;
+ my $result;
+ my $rndseed=time;
+ if ($helper->{'VARS'}->{'curseed'}) {
+ $rndseed=$helper->{'VARS'}->{'curseed'};
+ }
+ my $errtext=&Apache::lonratedt::mapread($currentURL);
+ #
+ # These make this all support recursing for subsequences.
+ #
+ my @order = @Apache::lonratedt::order;
+ my @resources = @Apache::lonratedt::resources;
+ for (my $member=0;$member<=$#order;$member++) {
+ $resources[$order[$member]]=~/^([^:]*):([^:]*):/;
+ my $urlp=$2;
+ if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm)$/) {
+ my $texversion='';
+ if ($helper->{'VARS'}->{'ANSWER_TYPE'} ne 'only') {
+ $form{'problem_split'}=$parmhash{'problem_stream_switch'};
+ $form{'suppress_tries'}=$parmhash{'suppress_tries'};
+ $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
+ $form{'rndseed'}=$rndseed;
+ $resources_printed .=$urlp.':';
+ $texversion=&Apache::lonnet::ssi($urlp,%form);
+ }
+ if((($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||
+ ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) &&
+ ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page)$/)) {
+ # Don't permanently modify %$form...
+ my %answerform = %form;
+ $answerform{'grade_target'}='answer';
+ $answerform{'answer_output_mode'}='tex';
+ $answerform{'rndseed'}=$rndseed;
+ $answerform{'problem_split'}=$parmhash{'problem_stream_switch'};
+ if ($urlp=~/\/res\//) {$env{'request.state'}='published';}
+ $resources_printed .= $urlp.':';
+ my $answer=&Apache::lonnet::ssi($urlp,%answerform);
+ 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'});
+ 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;
+ }
+ }
+ $texversion = &latex_header_footer_remove($texversion);
+
+ if ($helper->{'VARS'}->{'TABLE_INDEX'} eq 'yes') {
+ $texversion=&IndexCreation($texversion,$urlp);
+ }
+ if ($helper->{'VARS'}->{'CONSTR_RESOURSE_URL'} eq 'yes') {
+ $texversion=~s/(\\addcontentsline\{toc\}\{subsection\}\{[^\}]*\})/$1 URL: \\verb|$urlp| \\strut\\\\\\strut /;
+ }
+ $result.=$texversion;
+
+ } elsif ($urlp=~/\.(sequence|page)$/) {
+
+ # header:
+
+ $result.='\strut\newline\noindent Sequence/page '.$urlp.'\strut\newline\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\newline\noindent ';
+
+ # 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,
+ $helper, %form,
+ $LaTeXwidth);
+ }
+ }
+ }
+ if ($helper->{VARS}->{'construction'} eq '1') {$result=~s/(\\begin{document})/$1 \\fbox\{RANDOM SEED IS $rndseed\} /;}
+ return $result;
+}
+
sub output_data {
my ($r,$helper,$rparmhash) = @_;
my %parmhash = %$rparmhash;
- my $resources_printed = '';
+ $resources_printed = '';
my $js = <
' . $self->{ERROR_MSG} . '
';
+ $result .= '
' . $self->{ERROR_MSG} . '
';
}
- my $width = 18;
my $format = $helper->{VARS}->{$self->{'formatvar'}};
- if (substr($format, 2, 1) ne '1') {
- $width = 9;
+
+ # Use format to get sensible defaults for the margins:
+
+
+ my ($laystyle, $cols, $papersize) = split(/\|/, $format);
+ ($papersize) = split(/ /, $papersize);
+
+
+ if ($laystyle eq 'L') {
+ $laystyle = 'album';
+ } else {
+ $laystyle = 'book';
+ }
+
+
+ my %size;
+ ($size{'width_and_units'},
+ $size{'height_and_units'},
+ $size{'margin_and_units'})=
+ &Apache::lonprintout::page_format($papersize, $laystyle, $cols);
+
+ foreach my $dimension ('width','height','margin') {
+ ($size{$dimension},$size{$dimension.'_unit'}) =
+ split(/ +/, $size{$dimension.'_and_units'},2);
+
+ foreach my $unit ('cm','in') {
+ $size{$dimension.'_options'} .= '
How should each column be formatted?
Width: | -+ | ||
Height: | -+ | ||
Left margin: | -+ |
Hint: Some instructors like to leave scratch space for the student by -making the width much smaller than the width of the page.
+ ELEMENTHTML @@ -2991,9 +3067,6 @@ sub preprocess { my $helper = Apache::lonhelper::getHelper(); my $format = $helper->{VARS}->{$self->{'formatvar'}}; - if (substr($format, 2, 1) ne '1') { - $helper->changeState($self->{NEXTSTATE}); - } return 1; } @@ -3015,13 +3088,13 @@ sub postprocess { # /^-?[0-9]+(\.[0-9]*)?$/ -> optional minus, at least on digit, followed # by an optional period, followed by digits, ending the string - if ($width !~ /^-?[0-9]+(\.[0-9]*)?$/) { + if ($width !~ /^-?[0-9]*(\.[0-9]*)?$/) { $error .= "Invalid width; please type only a number.