[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm
sakharuk
lon-capa-cvs@mail.lon-capa.org
Fri, 30 Apr 2004 17:18:42 -0000
This is a MIME encoded message
--sakharuk1083345522
Content-Type: text/plain
sakharuk Fri Apr 30 13:18:42 2004 EDT
Modified files:
/loncom/interface lonprintout.pm
Log:
1. Singled out a subroutine for working with unsupported in printing fresources;
2. Added chunk responsible for correct processing of unsupported in printing resources during printing resources from definite sequence.
--sakharuk1083345522
Content-Type: text/plain
Content-Disposition: attachment; filename="sakharuk-20040430131842.txt"
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.295 loncom/interface/lonprintout.pm:1.296
--- loncom/interface/lonprintout.pm:1.295 Mon Apr 26 15:00:29 2004
+++ loncom/interface/lonprintout.pm Fri Apr 30 13:18:42 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.295 2004/04/26 19:00:29 albertel Exp $
+# $Id: lonprintout.pm,v 1.296 2004/04/30 17:18:42 sakharuk Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -672,6 +672,22 @@
return $textwidth;
}
+
+sub unsupported {
+ my $currentURL=shift;
+ my $result.='\documentclass[letterpaper]{article}\usepackage{calc}\begin{document}Printout of this type of document is currently not supported: ';
+ if ($currentURL=~/\/(aboutme|syllabus|bulletinboard|smppg)$/) {
+ $result.='\textbf{'.$1.'}';
+ } elsif ($currentURL=~/\/ext\//) {
+ $result.=' \strut \\\\ THIS IS EXTERNAL RESOURCE WITH URL \strut \\\\ '.$currentURL.' ';
+ } else {
+ $result.=$currentURL;
+ }
+ $result.=' \end{document}';
+ return $result;
+}
+
+
sub output_data {
my ($r,$helper,$rparmhash) = @_;
my %parmhash = %$rparmhash;
@@ -868,21 +884,22 @@
my $texversion=&Apache::lonnet::ssi($currentURL,%form);
$result .= $texversion;
} else {
- $result.='\documentclass[letterpaper]{article}\usepackage{calc}\begin{document}Printout of this type of document is currently not supported: ';
- if ($currentURL=~/\/(aboutme|syllabus|bulletinboard|smppg)$/) {
- $result.=$1;
- } elsif ($currentURL=~/\/ext\//) {
- $result.=' \strut \\\\ THIS IS EXTERNAL RESOURCE WITH URL \strut \\\\ '.$currentURL.' ';
- } else {
- $result.=$currentURL;
- }
- $result.=' \end{document}'
+ $result.=&unsupported($currentURL);
}
} elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') or
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') or
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems') or
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'select_sequences')) {
#-- produce an output string
+ if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') {
+ $selectionmade = 2;
+ } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') {
+ $selectionmade = 3;
+ } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems') {
+ $selectionmade = 4;
+ } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'select_sequences') {
+ $selectionmade = 7;
+ }
my %form=();
$form{'grade_target'}='tex';
$form{'textwidth'}=&get_textwidth($helper,$LaTeXwidth);
@@ -897,71 +914,66 @@
for (my $i=0;$i<=$#master_seq;$i++) {
my (undef,undef,$urlp)=&Apache::lonnet::decode_symb($master_seq[$i]);
$urlp=&Apache::lonnet::clutter($urlp);
- if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') {
- $selectionmade = 2;
- } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') {
- $selectionmade = 3;
- } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems') {
- $selectionmade = 4;
- } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'select_sequences') {
- $selectionmade = 7;
- }
$form{'symb'}=$master_seq[$i];
my ($sequence)=&Apache::lonnet::decode_symb($master_seq[$i]);
my $assignment=&Apache::lonxml::latex_special_symbols(&Apache::lonnet::gettitle($sequence),'header'); #tittle of the assignment which contains this problem
if ($selectionmade==7) {$helper->{VARS}->{'assignment'}=$assignment;}
if ($i==0) {$prevassignment=$assignment;}
#&Apache::lonnet::logthis("Trying to get $urlp with symb $master_seq[$i]");
- my $texversion.=&Apache::lonnet::ssi($urlp,%form);
- if ($urlp=~/\.page$/) {
- ($texversion,my $number_of_columns_page) = &page_cleanup($texversion);
- if ($number_of_columns_page > $number_of_columns) {$number_of_columns=$number_of_columns_page;}
- $texversion =~ s/\\end{document}\d*/\\end{document}/;
- $flag_page_in_sequence = 'YES';
- }
- my $lonidsdir=$r->dir_config('lonIDsDir');
- my $envfile=$ENV{'user.environment'};
- $envfile=~/\/([^\/]+)\.id$/;
- $envfile=$1;
- &Apache::lonnet::transfer_profile_to_env($lonidsdir,$envfile);
- my $current_counter=$ENV{'form.counter'};
- if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||
- ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {
- my %form;
- $form{'grade_target'}='answer';
- $form{'answer_output_mode'}='tex';
- my $answer=&Apache::lonnet::ssi($urlp,%form);
- &Apache::lonnet::appenv(('form.counter' => $current_counter));
- if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
- $texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/;
- } else {
- if ($urlp=~/\.(problem|exam|quiz|library)$/) {
- $texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
- $texversion.='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($urlp).'}\vskip 0 mm ';
- $texversion.=&path_to_problem ($urlp,$LaTeXwidth);
- $texversion.='\vskip 1 mm '.$answer;
+ if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) {
+ my $texversion.=&Apache::lonnet::ssi($urlp,%form);
+ if ($urlp=~/\.page$/) {
+ ($texversion,my $number_of_columns_page) = &page_cleanup($texversion);
+ if ($number_of_columns_page > $number_of_columns) {$number_of_columns=$number_of_columns_page;}
+ $texversion =~ s/\\end{document}\d*/\\end{document}/;
+ $flag_page_in_sequence = 'YES';
+ }
+ my $lonidsdir=$r->dir_config('lonIDsDir');
+ my $envfile=$ENV{'user.environment'};
+ $envfile=~/\/([^\/]+)\.id$/;
+ $envfile=$1;
+ &Apache::lonnet::transfer_profile_to_env($lonidsdir,$envfile);
+ my $current_counter=$ENV{'form.counter'};
+ if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||
+ ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {
+ my %form;
+ $form{'grade_target'}='answer';
+ $form{'answer_output_mode'}='tex';
+ my $answer=&Apache::lonnet::ssi($urlp,%form);
+ &Apache::lonnet::appenv(('form.counter' => $current_counter));
+ if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
+ $texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/;
} else {
- $texversion='';
+ if ($urlp=~/\.(problem|exam|quiz|library)$/) {
+ $texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
+ $texversion.='\vskip 0 mm \noindent\textbf{'.&Apache::lonnet::gettitle($urlp).'}\vskip 0 mm ';
+ $texversion.=&path_to_problem ($urlp,$LaTeXwidth);
+ $texversion.='\vskip 1 mm '.$answer;
+ } else {
+ $texversion='';
+ }
}
}
- }
- if ($flag_latex_header_remove ne 'NO') {
- $texversion = &latex_header_footer_remove($texversion);
+ 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 (($selectionmade == 4) and ($assignment ne $prevassignment)) {
+ my $name = &get_name();
+ my $courseidinfo = &get_course();
+ if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }
+ $prevassignment=$assignment;
+ $result .='\newpage \noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$name.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$assignment.'}}} \vskip -5 mm ';
+ }
+ $result .= $texversion;
+ $flag_latex_header_remove = 'YES';
} else {
- $texversion =~ s/\\end{document}//;
- }
- if ($helper->{'VARS'}->{'TABLE_INDEX'} eq 'yes') {
- $texversion=&IndexCreation($texversion,$urlp);
- }
- if (($selectionmade == 4) and ($assignment ne $prevassignment)) {
- my $name = &get_name();
- my $courseidinfo = &get_course();
- if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }
- $prevassignment=$assignment;
- $result .='\newpage \noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$name.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$assignment.'}}} \vskip -5 mm ';
- }
- $result .= $texversion;
- $flag_latex_header_remove = 'YES';
+ $result.=&unsupported($urlp);
+ }
}
&Apache::lonnet::delenv('form.counter');
if ($flag_page_in_sequence eq 'YES') {$result =~ s/\\usepackage{calc}/\\usepackage{calc}\\usepackage{longtable}/;}
--sakharuk1083345522--