[LON-CAPA-cvs] cvs: loncom(bz5969) /interface lonprintout.pm

foxr foxr@source.lon-capa.org
Tue, 14 Jul 2009 09:30:20 -0000


foxr		Tue Jul 14 09:30:20 2009 EDT

  Modified files:              (Branch: bz5969)
    /loncom/interface	lonprintout.pm 
  Log:
  Progress towards making .pages printable in a course.
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.557 loncom/interface/lonprintout.pm:1.557.2.1
--- loncom/interface/lonprintout.pm:1.557	Tue Jun 23 10:24:31 2009
+++ loncom/interface/lonprintout.pm	Tue Jul 14 09:30:20 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.557 2009/06/23 10:24:31 foxr Exp $
+# $Id: lonprintout.pm,v 1.557.2.1 2009/07/14 09:30:20 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -943,6 +943,8 @@
     $result =~ s/&(ldquo|#8220);/\`\`/g;
     $result =~ s/&(rdquo|#8221);/\'\'/g;
 
+&Apache::lonnet::logthis("After pass through old character chart: '$result'");
+
 
     return $result;
 }
@@ -1306,6 +1308,46 @@
 }
 
 
+sub print_page_in_course {
+    my ($helper, $currentURL, $resources) = @_;
+    my @page_resources = @$resources;
+    my $mode = $helper->{'VARS'}->{'LATEX_TYPE'};
+    my $symb = $helper->{'VARS'}->{'symb'};
+
+    if ($mode ne '') {$mode='\\'.$mode}
+    my $result.= &print_latex_header($mode);
+    if ($currentURL=~m|^(/adm/wrapper/)?ext/|) {
+	$currentURL=~s|^(/adm/wrapper/)?ext/|http://|;
+	my $title=&Apache::lonnet::gettitle($symb);
+	$title = &Apache::lonxml::latex_special_symbols($title);
+	$result.=' \strut \\\\ '.$title.' \strut \\\\ '.$currentURL.' ';
+    } else {
+	$result.=$currentURL;
+    }
+
+    # First is theo verall page description.  This is then followed by the 
+    # components of the page. Each of which must be printed independently.
+
+    my $the_page = shift(@page_resources); 
+    $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 .=  '\\\\';
+    }
+
+    $result.= '\vskip 0.5mm\noindent\makebox[\textwidth/$number_of_columns][b]{\hrulefill} \end{document}';
+    return $result;
+}
+
+
 #
 # List of recently generated print files
 #
@@ -1725,6 +1767,9 @@
         } elsif ($cleanURL!~m|^/adm/|
 		 && $currentURL=~/\.(sequence|page)$/ && $helper->{'VARS'}->{'construction'} eq '1') {
             #printing content of sequence from the construction space	
+
+	    &Apache::lonnet::logthis("Printing sequence/page but construction space??");
+
 	    $currentURL=~s|\/~([^\/]+)\/|\/home\/$1\/public_html\/|;
 #	    $result .= &print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
 	    $result .= &print_construction_sequence($currentURL, $helper, %form,
@@ -1760,7 +1805,18 @@
 	} elsif ($cleanURL =~ /\.pdf$/i) {
 	    $result .= &include_pdf($cleanURL);
 	    $result .= '\end{document}';
+	} elsif ($cleanURL =~ /\.page$/i) { #  Print page in non construction space contexts.
+	    &Apache::lonnet::logthis("Printing .page $cleanURL  at " . __LINE__);
+
+	    # Determine the set of resources in the map of the page:
+
+	    my $navmap         =  Apache::lonnavmaps::navmap->new();
+	    my @page_resources =  $navmap->retrieveResources($cleanURL);
+	    $result           .=  &print_page_in_course($helper, $cleanURL, \@page_resources);
+
+       
 	} else {
+	    &Apache::lonnet::logthis("Unsupported type handler");
 	    $result.=&unsupported($currentURL,$helper->{'VARS'}->{'LATEX_TYPE'},
 				  $helper->{'VARS'}->{'symb'});
 	}
@@ -1827,10 +1883,13 @@
 	    my $texversion='';
 	    if ($urlp!~m|^/adm/|
 		&& $urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) {
+		&Apache::lonnet::logthis("At line 1834 printing $urlp");
 		$resources_printed .= $urlp.':';
 		&Apache::lonxml::remember_problem_counter();
 		$texversion.=&ssi_with_retries($urlp, $ssi_retry_count, %form);
 		if ($urlp=~/\.page$/) {
+		    &Apache::lonnet::logthis("Handling a .page at ". __LINE__);
+
 		    ($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}/;
@@ -2419,7 +2478,7 @@
 		if ($res_url!~m|^ext/|
 		    && $res_url=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) {
 		    $printed .= $curresline.':';
-
+		    &Apache::lonnet::logthis("At line 2427 printing $curresline");
 		    &Apache::lonxml::remember_problem_counter();    
 
 		    my $rendered = &get_student_view_with_retries($curresline,$ssi_retry_count,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv);
@@ -3186,7 +3245,6 @@
 	    )) 
 	&& $helper->{VARS}->{'assignment'} eq ""
 	) {
-
 	my $pretty_dir = &Apache::lonnet::hreflocation($subdir);
         push @{$printChoices}, [&mt('Selected [_1]Problems[_2] from current subdirectory [_3]','<b>','</b>','<b><i>'.$pretty_dir.'</i></b>','<b>','</b>'), 'problems_from_directory', 'CHOOSE_FROM_SUBDIR'];
         my $xmlfrag = <<CHOOSE_FROM_SUBDIR;