[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm
foxr
lon-capa-cvs@mail.lon-capa.org
Mon, 17 Jul 2006 09:38:09 -0000
This is a MIME encoded message
--foxr1153129089
Content-Type: text/plain
foxr Mon Jul 17 05:38:09 2006 EDT
Modified files:
/loncom/interface lonprintout.pm
Log:
Defect 4374 - subsequences of sequences don't print... fixed for
the construction space case. Other casees alread fixed back in 1.434
--foxr1153129089
Content-Type: text/plain
Content-Disposition: attachment; filename="foxr-20060717053809.txt"
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.458 loncom/interface/lonprintout.pm:1.459
--- loncom/interface/lonprintout.pm:1.458 Fri Jul 14 17:03:47 2006
+++ loncom/interface/lonprintout.pm Mon Jul 17 05:38:09 2006
@@ -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.459 2006/07/17 09:38:09 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -47,6 +47,7 @@
my %perm;
my %parmhash;
+my $resources_printed;
# Format a header according to a format.
@@ -1055,10 +1056,113 @@
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;
+ &Apache::lonnet::logthis("mapread for $currentURL returned: $errtext");
+ for (my $member=0;$member<=$#order;$member++) {
+ $resources[$order[$member]]=~/^([^:]*):([^:]*):/;
+ my $urlp=$2;
+ &Apache::lonnet::logthis("Processing $urlp from sequence ($member)");
+ 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)$/) {
+ &Apache::lonnet::logthis("elsif just strutting stuff");
+
+ # 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 = <<ENDPART;
<script type="text/javascript">
var editbrowser;
@@ -1232,70 +1336,19 @@
} elsif ($cleanURL!~m|^/adm/|
&& $currentURL=~/\.sequence$/ && $helper->{'VARS'}->{'construction'} eq '1') {
#printing content of sequence from the construction space
- my $flag_latex_header_remove = 'NO';
- my $rndseed=time;
- if ($helper->{'VARS'}->{'curseed'}) {
- $rndseed=$helper->{'VARS'}->{'curseed'};
- }
$currentURL=~s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|;
- my $errtext=&Apache::lonratedt::mapread($currentURL);
- for (my $member=0;$member<=$#Apache::lonratedt::order;$member++) {
- $Apache::lonratedt::resources[$Apache::lonratedt::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;
- }
- }
- if ($flag_latex_header_remove ne 'NO') {
- $texversion = &latex_header_footer_remove($texversion);
- } else {
- $texversion =~ s/\\end{document}//;
- }
- if ($helper->{'VARS'}->{'TABLE_INDEX'} eq 'yes') {
- $texversion=&IndexCreation($texversion,$urlp);
- }
- if ($helper->{'VARS'}->{'CONSTR_RESOURSE_URpL'} eq 'yes') {
- $texversion=~s/(\\addcontentsline\{toc\}\{subsection\}\{[^\}]*\})/$1 URL: \\verb|$urlp| \\strut\\\\\\strut /;
- }
- $result.=$texversion;
- $flag_latex_header_remove = 'YES';
- } elsif ($urlp=~/\.(sequence|page)$/) {
- $result.='\strut\newline\noindent Sequence/page '.$urlp.'\strut\newline\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill}\newline\noindent ';
- }
+ &Apache::lonnet::logthis("Sequence from constrution space. ouptput is:");
+ &Apache::lonnet::logthis($result);
+ $result .= &print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
+ $result .= &print_construction_sequence($currentURL, $helper, %form,
+ $LaTeXwidth);
+ &Apache::lonnet::logthis("Back from construction space print");
+ $result .= '\end{document}';
+ if (!($result =~ /\\begin\{document\}/)) {
+ &Apache::lonnet::logthis("inserting header");
+ $result = &print_latex_header() . $result;
}
- if ($helper->{VARS}->{'construction'} eq '1') {$result=~s/(\\begin{document})/$1 \\fbox\{RANDOM SEED IS $rndseed\} /;}
- $result .= '\end{document}';
+ # End construction space sequence.
} elsif ($cleanURL=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) {
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
if ($currentURL=~/\/syllabus$/) {$currentURL=~s/\/res//;}
--foxr1153129089--