[LON-CAPA-cvs] cvs: loncom(bz5969) /interface lonprintout.pm
foxr
foxr@source.lon-capa.org
Tue, 14 Jul 2009 11:08:01 -0000
This is a MIME encoded message
--foxr1247569681
Content-Type: text/plain
foxr Tue Jul 14 11:08:01 2009 EDT
Modified files: (Branch: bz5969)
/loncom/interface lonprintout.pm
Log:
Progress on printing pages from a course.
--foxr1247569681
Content-Type: text/plain
Content-Disposition: attachment; filename="foxr-20090714110801.txt"
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.557.2.1 loncom/interface/lonprintout.pm:1.557.2.2
--- loncom/interface/lonprintout.pm:1.557.2.1 Tue Jul 14 09:30:20 2009
+++ loncom/interface/lonprintout.pm Tue Jul 14 11:08:00 2009
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.557.2.1 2009/07/14 09:30:20 foxr Exp $
+# $Id: lonprintout.pm,v 1.557.2.2 2009/07/14 11:08:00 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -197,7 +197,7 @@
#
-# ssi_with_retries - Does the server side include of a resource.
+# ssi_with_retries- Does the server side include of a resource.
# if the ssi call returns an error we'll retry it up to
# the number of times requested by the caller.
# If we still have a proble, no text is appended to the
@@ -943,7 +943,6 @@
$result =~ s/&(ldquo|#8220);/\`\`/g;
$result =~ s/&(rdquo|#8221);/\'\'/g;
-&Apache::lonnet::logthis("After pass through old character chart: '$result'");
return $result;
@@ -1307,13 +1306,38 @@
return $result;
}
+#
+# Map from helper layout style to the book/album:
+#
+sub map_laystyle {
+ my ($laystyle) = @_;
+ if ($laystyle eq 'L') {
+ $laystyle='album';
+ } else {
+ $laystyle='book';
+ }
+ return $laystyle;
+}
sub print_page_in_course {
- my ($helper, $currentURL, $resources) = @_;
+ my ($helper, $rparmhash, $currentURL, $resources) = @_;
+ my %parmhash = %$rparmhash;
my @page_resources = @$resources;
my $mode = $helper->{'VARS'}->{'LATEX_TYPE'};
my $symb = $helper->{'VARS'}->{'symb'};
+
+ my $format_from_helper = $helper->{'VARS'}->{'FORMAT'};
+
+
+ my @temporary_array=split /\|/,$format_from_helper;
+ my ($laystyle,$numberofcolumns,$papersize,$pdfFormFields)=@temporary_array;
+ $laystyle = &map_laystyle($laystyle);
+ my ($textwidth,$textheight,$oddoffset,$evenoffset) = &page_format($papersize,$laystyle,
+ $numberofcolumns);
+ my $LaTeXwidth=&recalcto_mm($textwidth);
+
+
if ($mode ne '') {$mode='\\'.$mode}
my $result.= &print_latex_header($mode);
if ($currentURL=~m|^(/adm/wrapper/)?ext/|) {
@@ -1324,6 +1348,12 @@
} else {
$result.=$currentURL;
}
+ if ($helper->{'VARS'}->{'style_file'}=~/\w/) {
+ &Apache::lonnet::appenv({'construct.style' =>
+ $helper->{'VARS'}->{'style_file'}});
+ } elsif ($env{'construct.style'}) {
+ &Apache::lonnet::delenv('construct.style');
+ }
# First is theo verall page description. This is then followed by the
# components of the page. Each of which must be printed independently.
@@ -1332,15 +1362,111 @@
$result .= "URL: $currentURL " .'\\\\';
foreach my $resource (@page_resources) {
- my $resource_src = $resource->src();
- my $resource_symb = $resource->symb();
- $resource_symb = &Apache::lonnet::clutter($resource_symb);
- my $resource_kind = $resource->kind();
- my $resource_title = $resource->title();
-
- $result .= &Apache::lonxml::latex_special_symbols("Src: $resource_src symb: $resource_symb ");
- $result .= &Apache::lonxml::latex_special_symbols("Kind: $resource_kind Title: $resource_title");
- $result .= '\\\\';
+ my $resource_src = $resource->src(); # Essentially the URL of the resource.
+
+ # Recurse if a .page:
+
+ if ($resource_src =~ /.page$/i) {
+ my $navmap = Apache::lonnavmaps::navmap->new();
+ my @page_resources = $navmap->retrieveResources($resource_src);
+ $result .= &print_page_in_course($helper, $rparmhash,
+ $resource_src, \@page_resources);
+ }
+ # these resources go through the XML transformer:
+
+ elsif ($resource_src =~ /\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm\xhtml|xhtm)$/) {
+ my $urlp = &Apache::lonnet::clutter($resource_src);
+ my %form;
+ my %moreenv;
+
+ &Apache::lonxml::remember_problem_counter();
+ $moreenv{'request.filename'}=$urlp;
+ if ($helper->{'VARS'}->{'probstatus'} eq 'exam') {$form{'problemtype'}='exam';}
+
+ $form{'grade_target'} = 'tex';
+ $form{'textwidth'} = &get_textwidth($helper, $LaTeXwidth);
+ $form{'pdfFormFiels'} = $pdfFormFields; #
+ $form{'showallfoils'} = $helper->{'VARS'}->{'showallfoils'};
+
+ $form{'problem_split'}=$parmhash{'problem_stream_switch'};
+ $form{'suppress_tries'}=$parmhash{'suppress_tries'};
+ $form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
+ $form{'print_discussions'}=$helper->{'VARS'}->{'PRINT_DISCUSSIONS'};
+ $form{'print_annotations'}=$helper->{'VARS'}->{'PRINT_ANNOTATIONS'};
+ if (($helper->{'VARS'}->{'PRINT_DISCUSSIONS'} eq 'yes') ||
+ ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes')) {
+ $form{'problem_split'}='yes';
+ }
+ my $rndseed = time;
+ if ($helper->{'VARS'}->{'curseed'}) {
+ $rndseed=$helper->{'VARS'}->{'curseed'};
+ }
+ $form{'rndseed'}=$rndseed;
+ &Apache::lonnet::appenv(\%moreenv);
+
+ &Apache::lonxml::clear_problem_counter();
+
+ my $texversion = &ssi_with_retries($urlp, $ssi_retry_count, %form);
+
+ # 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'};
+ $form{'grade_target'}='answer';
+ $form{'answer_output_mode'}='tex';
+ $form{'rndseed'}=$rndseed;
+ if ($helper->{'VARS'}->{'probstatus'} eq 'exam') {
+ $form{'problemtype'}='exam';
+ }
+ $resources_printed .= $currentURL.':';
+ my $answer=&ssi_with_retries($currentURL,$ssi_retry_count, %form);
+
+
+ if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
+ $texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/;
+ } else {
+ $texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
+ if ($helper->{'VARS'}->{'construction'} ne '1') {
+ my $title = &Apache::lonnet::gettitle($helper->{'VARS'}->{'symb'});
+ $title = &Apache::lonxml::latex_special_symbols($title);
+ $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 1 mm '.$answer.'\end{document}';
+ }
+
+
+
+
+
+ }
+ # Print annotations.
+
+
+ if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') {
+ my $annotation .= &annotate($currentURL);
+ $texversion =~ s/(\\keephidden{ENDOFPROBLEM})/$annotation$1/;
+ }
+
+ if ($helper->{'VARS'}->{'TABLE_INDEX'} eq 'yes') {
+ $texversion=&IndexCreation($texversion,$currentURL);
+ }
+ if ($helper->{'VARS'}->{'CONSTR_RESOURSE_URL'} eq 'yes') {
+ $texversion=~s/(\\addcontentsline\{toc\}\{subsection\}\{[^\}]*\})/$1 URL: \\verb|$currentURL| \\strut\\\\\\strut /;
+
+ }
+ $result .= $texversion;
+ if ($currentURL=~m/\.page\s*$/) {
+ ($result,$numberofcolumns) = &page_cleanup($result);
+ }
+ }
}
$result.= '\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill} \end{document}';
@@ -1614,11 +1740,8 @@
my $number_of_columns = 1; #used only for pages to determine the width of the cell
my @temporary_array=split /\|/,$format_from_helper;
my ($laystyle,$numberofcolumns,$papersize,$pdfFormFields)=@temporary_array;
- if ($laystyle eq 'L') {
- $laystyle='album';
- } else {
- $laystyle='book';
- }
+
+ $laystyle = &map_laystyle($laystyle);
my ($textwidth,$textheight,$oddoffset,$evenoffset) = &page_format($papersize,$laystyle,$numberofcolumns);
my $assignment = $env{'form.assignment'};
my $LaTeXwidth=&recalcto_mm($textwidth);
@@ -1812,7 +1935,8 @@
my $navmap = Apache::lonnavmaps::navmap->new();
my @page_resources = $navmap->retrieveResources($cleanURL);
- $result .= &print_page_in_course($helper, $cleanURL, \@page_resources);
+ $result .= &print_page_in_course($helper, $rparmhash,
+ $cleanURL, \@page_resources);
} else {
@@ -3789,12 +3913,8 @@
my ($laystyle, $cols, $papersize) = split(/\|/, $format);
($papersize) = split(/ /, $papersize);
+ $laystyle = &Apache::lonprintout::map_laystyle($laystyle);
- if ($laystyle eq 'L') {
- $laystyle = 'album';
- } else {
- $laystyle = 'book';
- }
my %size;
@@ -3875,11 +3995,8 @@
($papersize) = split(/ /, $papersize);
- if ($laystyle eq 'L') {
- $laystyle = 'album';
- } else {
- $laystyle = 'book';
- }
+ $laystyle = &map_laystyle($laystyle);
+
# Figure out some good defaults for the print out and set them:
my %size;
--foxr1247569681--