[LON-CAPA-cvs] cvs: loncom /interface lonprintout.pm
foxr
lon-capa-cvs-allow@mail.lon-capa.org
Mon, 14 Jan 2008 10:43:13 -0000
This is a MIME encoded message
--foxr1200307393
Content-Type: text/plain
foxr Mon Jan 14 05:43:13 2008 EDT
Modified files:
/loncom/interface lonprintout.pm
Log:
BZ3143 - Added capability to print annotations.
--foxr1200307393
Content-Type: text/plain
Content-Disposition: attachment; filename="foxr-20080114054313.txt"
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.510 loncom/interface/lonprintout.pm:1.511
--- loncom/interface/lonprintout.pm:1.510 Thu Oct 11 18:49:49 2007
+++ loncom/interface/lonprintout.pm Mon Jan 14 05:43:12 2008
@@ -2,7 +2,7 @@
# The LearningOnline Network
# Printout
#
-# $Id: lonprintout.pm,v 1.510 2007/10/11 22:49:49 albertel Exp $
+# $Id: lonprintout.pm,v 1.511 2008/01/14 10:43:12 foxr Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -38,6 +38,8 @@
use Apache::edit;
use Apache::File();
use Apache::lonnavmaps;
+use Apache::admannotations;
+
use LONCAPA::map();
use POSIX qw(strftime);
use Apache::lonlocal;
@@ -70,6 +72,27 @@
}
+# Fetch the annotations associated with a URL and
+# put a centered 'annotations:' title.
+# This is all suppressed if the annotations are empty.
+#
+sub annotate {
+ my ($symb) = @_;
+
+ my $annotation_text = &Apache::admannotations::get_annotation($symb, 1);
+
+
+ my $result = "";
+
+ if (length($annotation_text) > 0) {
+ $result .= '\\hspace*{\\fill} \\\\[\\baselineskip] \textbf{Annotations:} \\\\ ';
+ $result .= "\n";
+ $result .= &Apache::lonxml::latex_special_symbols($annotation_text,""); # Escape latex.
+ $result .= "\n\n";
+ }
+ return $result;
+}
+
#
# printf_style_subst item format_string repl
#
@@ -1407,7 +1430,11 @@
$form{'suppress_tries'}=$parmhash{'suppress_tries'};
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
$form{'print_discussions'}=$helper->{'VARS'}->{'PRINT_DISCUSSIONS'};
- if ($helper->{'VARS'}->{'PRINT_DISCUSSIONS'} eq 'yes') {$form{'problem_split'}='yes';}
+ $form{'print_annotations'}=$helper->{'VARS'}->{'PRINT_ANNOTATIONS'};
+ if (($helper->{'VARS'}->{'PRINT_DISCUSSIONS'} eq 'yes') ||
+ ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes')) {
+ $form{'problem_split'}='yes';
+ }
if ($helper->{'VARS'}->{'curseed'}) {
$rndseed=$helper->{'VARS'}->{'curseed'};
}
@@ -1419,6 +1446,8 @@
$resources_printed .= $currentURL.':';
$texversion.=&Apache::lonnet::ssi($currentURL,%form);
+ # Add annotations if required:
+
&Apache::lonxml::clear_problem_counter();
&Apache::lonnet::delenv('request.filename');
@@ -1437,6 +1466,8 @@
}
$resources_printed .= $currentURL.':';
my $answer=&Apache::lonnet::ssi($currentURL,%form);
+
+
if ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') {
$texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/;
} else {
@@ -1454,7 +1485,20 @@
}
$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);
}
@@ -1483,6 +1527,10 @@
if ($currentURL=~/\/syllabus$/) {$currentURL=~s/\/res//;}
$resources_printed .= $currentURL.':';
my $texversion=&Apache::lonnet::ssi($currentURL,%form);
+ if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') {
+ my $annotation = &annotate($currentURL);
+ $texversion =~ s/(\\end{document})/$annotation$1/;
+ }
$result .= $texversion;
} elsif ($cleanURL =~/.tex$/) {
# For this sort of print of a single LaTeX file,
@@ -1490,6 +1538,11 @@
#
$result = &fetch_raw_resource($currentURL);
+ if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') {
+ my $annotation = &annotate($currentURL);
+ $result =~ s/(\\end{document})/$annotation$1/;
+ }
+
$do_postprocessing = 0; # Don't massage the result.
} else {
@@ -1501,6 +1554,8 @@
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems') or
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_resources') or # BUGBUG
($helper->{'VARS'}->{'PRINT_TYPE'} eq 'select_sequences')) {
+
+
#-- produce an output string
if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') {
$selectionmade = 2;
@@ -1517,7 +1572,11 @@
$form{'suppress_tries'}=$parmhash{'suppress_tries'};
$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
$form{'print_discussions'}=$helper->{'VARS'}->{'PRINT_DISCUSSIONS'};
- if ($helper->{'VARS'}->{'PRINT_DISCUSSIONS'} eq 'yes') {$form{'problem_split'}='yes';}
+ $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 $flag_latex_header_remove = 'NO';
my $flag_page_in_sequence = 'NO';
my @master_seq=split /\|\|\|/, $helper->{'VARS'}->{'RESOURCES'};
@@ -1547,7 +1606,6 @@
if ($urlp!~m|^/adm/|
&& $urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) {
$resources_printed .= $urlp.':';
-
&Apache::lonxml::remember_problem_counter();
$texversion.=&Apache::lonnet::ssi($urlp,%form);
if ($urlp=~/\.page$/) {
@@ -1584,7 +1642,13 @@
$texversion='';
}
}
+
}
+ if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') {
+ my $annotation .= &annotate($urlp);
+ $texversion =~ s/(\\keephidden{ENDOFPROBLEM})/$annotation$1/;
+ }
+
if ($flag_latex_header_remove ne 'NO') {
$texversion = &latex_header_footer_remove($texversion);
} else {
@@ -1616,6 +1680,11 @@
if ($urlp=~/\/syllabus$/) {$urlp=~s/\/res//;}
$resources_printed .= $urlp.':';
my $texversion=&Apache::lonnet::ssi($urlp,%form);
+ if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') {
+ my $annotation = &annotate($urlp);
+ $texversion =~ s/(\\end{document)/$annotation$1/;
+ }
+
if ($flag_latex_header_remove ne 'NO') {
$texversion = &latex_header_footer_remove($texversion);
} else {
@@ -1691,9 +1760,13 @@
$moreenv{'instructor_comments'}='hide';
$moreenv{'textwidth'}=&get_textwidth($helper,$LaTeXwidth);
$moreenv{'print_discussions'}=$helper->{'VARS'}->{'PRINT_DISCUSSIONS'};
+ $moreenv{'print_annotations'} = $helper->{'VARS'}->{'PRINT_ANNOTATIONS'};
$moreenv{'problem_split'} = $parmhash{'problem_stream_switch'};
$moreenv{'suppress_tries'} = $parmhash{'suppress_tries'};
- if ($helper->{'VARS'}->{'PRINT_DISCUSSIONS'} eq 'yes') {$moreenv{'problem_split'}='yes';}
+ if (($helper->{'VARS'}->{'PRINT_DISCUSSIONS'} eq 'yes') ||
+ ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes')) {
+ $moreenv{'problem_split'}='yes';
+ }
my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$#students+1,'inline','75');
my $student_counter=-1;
my $i = 0;
@@ -2058,6 +2131,7 @@
# postscript. Each ENDOFSTUDENTSTAMP will go on a line by itself.
#
+
foreach my $curresline (@{$master_seq}) {
if (defined $page_breaks{$curresline}) {
if($i != 0) {
@@ -2065,6 +2139,7 @@
}
}
$i++;
+
if ( !($type eq 'problems' &&
($curresline!~ m/\.(problem|exam|quiz|assess|survey|form|library)$/)) ) {
my ($map,$id,$res_url) = &Apache::lonnet::decode_symb($curresline);
@@ -2103,6 +2178,12 @@
$rendered = $header.$body;
}
}
+
+ if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') {
+ my $url = &Apache::lonnet::clutter($res_url);
+ my $annotation = &annotate($url);
+ $rendered =~ s/(\\keephidden{ENDOFPROBLEM})/$annotation$1/;
+ }
if ($remove_latex_header eq 'YES') {
$rendered = &latex_header_footer_remove($rendered);
} else {
@@ -2112,7 +2193,11 @@
} elsif ($res_url=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) {
$printed .= $curresline.':';
my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv);
-
+ if ($helper->{'VARS'}->{'PRINT_ANNOTATIONS'} eq 'yes') {
+ my $url = &Apache::lonnet::clutter($res_url);
+ my $annotation = &annotate($url);
+ $annotation =~ s/(\\end{document})/$annotation$1/;
+ }
if ($remove_latex_header eq 'YES') {
$rendered = &latex_header_footer_remove($rendered);
} else {
@@ -2949,6 +3034,21 @@
Apache::lonhelper::dropdown->new();
addMessage("</td></tr>");
+ # Prompt for printing annotations too.
+
+ addMessage("<tr><td align='right'>".
+ '<label for="PRINT_ANNOTATIONS_forminput">'.
+ &mt('Print Annotations').
+ "</label>:</td><td>");
+ $paramHash = Apache::lonhelper::getParamHash();
+ $paramHash->{'variable'} = "PRINT_ANNOTATIONS";
+ $helper->declareVar("PRINT_ANNOTATIONS");
+ $paramHash->{CHOICES} = [
+ ['No', 'no'],
+ ['Yes', 'yes']];
+ Apache::lonhelper::dropdown->new();
+ addMessage("</td></tr>");
+
addMessage("<tr><td align = 'right'> </td><td>");
$paramHash = Apache::lonhelper::getParamHash();
$paramHash->{'multichoice'} = "true";
--foxr1200307393--