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

foxr foxr@source.lon-capa.org
Mon, 17 Aug 2009 10:48:28 -0000


This is a MIME encoded message

--foxr1250506108
Content-Type: text/plain

foxr		Mon Aug 17 10:48:28 2009 EDT

  Modified files:              (Branch: bz2851)
    /loncom/interface	lonprintout.pm 
  Log:
  BZ 2851  - Just saving work so far - can get the page to request which resource
  or problmes to print.. can get the body right but need to work on getting
  headers/trailers generated for the resulting LaTeX
  
  
--foxr1250506108
Content-Type: text/plain
Content-Disposition: attachment; filename="foxr-20090817104828.txt"

Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.560 loncom/interface/lonprintout.pm:1.560.2.1
--- loncom/interface/lonprintout.pm:1.560	Mon Aug  3 11:01:14 2009
+++ loncom/interface/lonprintout.pm	Mon Aug 17 10:48:28 2009
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.560 2009/08/03 11:01:14 foxr Exp $
+# $Id: lonprintout.pm,v 1.560.2.1 2009/08/17 10:48:28 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1962,6 +1962,8 @@
 				  $helper->{'VARS'}->{'symb'});
 	}
     } elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems')       or
+	     ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_in_page') or
+	     ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_resources_in_page') or
              ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') or
              ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems')       or
 	     ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_resources')      or # BUGBUG
@@ -1970,9 +1972,13 @@
 
 
         #-- produce an output string
-	if ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems') {
+	if (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems')  or
+	    ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_in_page') ) {
 	    $selectionmade = 2;
-	} elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') {
+	} elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_problems_pages') or
+		 ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'map_resources_in_page'))
+	{
+	    &Apache::lonnet::logthis("Selectionmade => 3");
 	    $selectionmade = 3;
 	} elsif (($helper->{'VARS'}->{'PRINT_TYPE'} eq 'all_problems') 
 		 ) {
@@ -2016,7 +2022,7 @@
 	    $urlp=&Apache::lonnet::clutter($urlp);
 	    $form{'symb'}=$master_seq[$i];
 
-
+	    &Apache::lonnet::logthis("Element $i Sequence $sequence Middle $middle_thingy URLP $urlp");
 	    my $assignment=&Apache::lonxml::latex_special_symbols(&Apache::lonnet::gettitle($sequence),'header'); #title of the assignment which contains this problem
 
 	    if ($selectionmade==7) {$helper->{VARS}->{'assignment'}=$assignment;}
@@ -2024,11 +2030,13 @@
 	    my $texversion='';
 	    if ($urlp!~m|^/adm/|
 		&& $urlp=~/\.(problem|exam|quiz|assess|survey|form|library|page|xml|html|htm|xhtml|xhtm)$/) {
+		&Apache::lonnet::logthis("Problem");
 		$resources_printed .= $urlp.':';
 		&Apache::lonxml::remember_problem_counter();
 		$texversion.=&ssi_with_retries($urlp, $ssi_retry_count, %form);
+		&Apache::lonnet::logthis("texversion so far: $texversion");
 		if ($urlp=~/\.page$/) {
-
+		    &Apache::lonnet::("Special page actions");
 		    ($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}/;
@@ -2050,6 +2058,7 @@
 			$texversion=~s/(\\keephidden{ENDOFPROBLEM})/$answer$1/;
 		    } else {
 			if ($urlp=~/\.(problem|exam|quiz|assess|survey|form|library)$/) {
+			    &Apache::lonnet::logthis("problem printing");
 			    $texversion=&print_latex_header($helper->{'VARS'}->{'LATEX_TYPE'});
 			    $texversion =~ s/\\begin{document}//;
 			    my $title = &Apache::lonnet::gettitle($master_seq[$i]);
@@ -2095,6 +2104,7 @@
 		    }			
 		}
 		$result .= $texversion;
+		&Apache::lonnet::logthis("About to set rem header true with $result");
 		$flag_latex_header_remove = 'YES';   
 	    } elsif ($urlp=~/\/(smppg|syllabus|aboutme|bulletinboard)$/) { 
 		$form{'latex_type'}=$helper->{'VARS'}->{'LATEX_TYPE'};
@@ -2927,6 +2937,8 @@
         $subdir = substr($helper->{VARS}->{'filename'},
                          0, rindex($helper->{VARS}->{'filename'}, '/') + 1);
     } else {
+	# From course space:
+
 	if ($symb ne '') {
 	    ($map, $id, $url) = &Apache::lonnet::decode_symb($symb);
 	    $helper->{VARS}->{'postdata'} = 
@@ -2934,9 +2946,9 @@
 	} else {
 	    $url = $helper->{VARS}->{'postdata'};
 	    $is_published=1;	# From resource space.
+	    &Apache::lonnet::logthis("Resource url $url");
 	}
 	$url = &Apache::lonnet::clutter($url);
-
         if (!$resourceTitle) { # if the resource doesn't have a title, use the filename
             my $postdata = $helper->{VARS}->{'postdata'};
             $resourceTitle = substr($postdata, rindex($postdata, '/') + 1);
@@ -2995,15 +3007,73 @@
 	    "<option text='".&mt('Start new page<br />before selected').
 	    "' variable='FINISHPAGE' />";
     }
+    # some debugging:
+    {
+	my $varspostdata = $helper->{VARS}->{'postdata'};
+	my $varsassignment = $helper->{VARS}->{'assignment'};
+	my $debugnavmap    = Apache::lonnavmaps::navmap->new();
+	my @dbgresources      = $debugnavmap->retrieveResources($url);
+	if(defined($dbgresources[0])) {
+	my $debugispage    = $dbgresources[0]->is_page();
+	my $debugtitle     = $dbgresources[0]->title();
+	my $resourcesymb   = $dbgresources[0]->symb();
+	my ($pagemap, $pageid, $pageurl) = &Apache::lonnet::decode_symb($symb);
+	&Apache::lonnet::logthis("post: $varspostdata ass: $varsassignment is page: $debugispage");
+	if ($debugispage) {
+	    push @{$printChoices}, 
+	    [&mt('Selected [_1]Problems[_2] from page [_3]', '<b>', '</b>', '<b><i>'.$debugtitle.'</i></b>'), 
+	     'map_problems_in_page', 
+	     'CHOOSE_PROBLEMS_PAGE'];
+	    push @{$printChoices}, 
+	         [&mt('Selected [_1]Resources[_2] from page [_3]', '<b>', '</b>', '<b><i>'.$debugtitle.'</i></b>'), 
+		  'map_resources_in_page', 
+		  'CHOOSE_RESOURCES_PAGE'];
+	}
+	&Apache::lonnet::logthis("Pushing problems/resources from folder. $debugtitle");
+	&Apache::lonnet::logthis("Map url: $url");
+	&Apache::lonnet::logthis("Decoded symb: pagemap $pagemap id: $pageid url: $pageurl");
+        my $helperFragment = <<HELPERFRAGMENT;
+	<state name="CHOOSE_PROBLEMS_PAGE" title="Select Problem(s) to print">
+	    <resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1"
+              closeallpages="1">
+	<nextstate>PAGESIZE</nextstate>
+      <filterfunc>return $isProblem;</filterfunc>
+      <mapurl>$pagemap</mapurl>
+      <valuefunc>return $symbFilter;</valuefunc>
+      $start_new_option
+      </resource>
+    </state>
+
+  <state name="CHOOSE_RESOURCES_PAGE" title="Select Resource(s) to print">
+    <resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1"
+              closeallpages="1">
+      <nextstate>PAGESIZE</nextstate>
+      <filterfunc>return $isNotMap;</filterfunc>
+      <mapurl>$url</mapurl>
+      <valuefunc>return $symbFilter;</valuefunc>
+      $start_new_option
+      </resource>
+    </state>
+HELPERFRAGMENT
+
+	&Apache::lonxml::xmlparse($r, 'helper', $helperFragment);
+	
+    }
+    }
 
     if (($helper->{'VARS'}->{'construction'} ne '1' ) &&
 	$helper->{VARS}->{'postdata'} &&
 	$helper->{VARS}->{'assignment'}) {
         # Allow problems from sequence
-        push @{$printChoices}, [&mt('Selected [_1]Problems[_2] from folder [_3]','<b>','</b>','<b><i>'.$sequenceTitle.'</i></b>'), 'map_problems', 'CHOOSE_PROBLEMS'];
+        push @{$printChoices}, 
+	    [&mt('Selected [_1]Problems[_2] from folder [_3]','<b>','</b>','<b><i>'.$sequenceTitle.'</i></b>'), 
+	     'map_problems', 
+	     'CHOOSE_PROBLEMS'];
         # Allow all resources from sequence
-        push @{$printChoices}, [&mt('Selected [_1]Resources[_2] from folder [_3]','<b>','</b>','<b><i>'.$sequenceTitle.'</i></b>'), 'map_problems_pages', 'CHOOSE_PROBLEMS_HTML'];
-
+        push @{$printChoices}, [&mt('Selected [_1]Resources[_2] from folder [_3]','<b>','</b>','<b><i>'.$sequenceTitle.'</i></b>'), 
+				'map_problems_pages', 
+				'CHOOSE_PROBLEMS_HTML'];
+	&Apache::lonnet::logthis("Map url : $map");
         my $helperFragment = <<HELPERFRAGMENT;
   <state name="CHOOSE_PROBLEMS" title="Select Problem(s) to print">
     <resource variable="RESOURCES" multichoice="1" toponly='1' addstatus="1"
@@ -3136,6 +3206,8 @@
   <state name="CHOOSE_STUDENTS" title="Select Students and Resources">
       <message><b>Select sorting order of printout</b> </message>
     <choices variable='student_sort'>
+
+
       <choice computer='0'>Sort by section then student</choice>
       <choice computer='1'>Sort by students across sections.</choice>
     </choices>

--foxr1250506108--