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

bowersj2 lon-capa-cvs@mail.lon-capa.org
Mon, 25 Aug 2003 17:25:05 -0000


bowersj2		Mon Aug 25 13:25:05 2003 EDT

  Modified files:              
    /loncom/interface	lonprintout.pm 
  Log:
  Work with the formatting, added an "addMessage" function that makes 
  adding HTML snippets easier (cleans up some of the nasty code).
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.222 loncom/interface/lonprintout.pm:1.223
--- loncom/interface/lonprintout.pm:1.222	Thu Aug 21 11:50:35 2003
+++ loncom/interface/lonprintout.pm	Mon Aug 25 13:25:05 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.222 2003/08/21 15:50:35 sakharuk Exp $
+# $Id: lonprintout.pm,v 1.223 2003/08/25 17:25:05 bowersj2 Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -971,6 +971,13 @@
 
 use Apache::lonhelper;
 
+sub addMessage {
+    my $text = shift;
+    my $paramHash = Apache::lonhelper::getParamHash();
+    $paramHash->{MESSAGE_TEXT} = $text;
+    Apache::lonhelper::message->new();
+}
+
 sub printHelper {
     my $r = shift;
 
@@ -1155,7 +1162,7 @@
       </resource>
     </state>
 
-  <state name="CHOOSE_STUDENTS" title="Choose Students whose assignments you want to print">
+  <state name="CHOOSE_STUDENTS" title="Select Students and Resources">
     <student multichoice='1' variable="STUDENTS" nextstate="PAGESIZE" />
     <message><br /><big><i><b>Select resources for the assignment</b></i></big><br /></message>
     <resource variable="RESOURCES" multichoice="1">
@@ -1198,7 +1205,7 @@
     }
 
     # Generate the first state, to select which resources get printed.
-    Apache::lonhelper::state->new("START", "What do you want to print? Make a choice.");
+    Apache::lonhelper::state->new("START", "Select Printing Options:");
     $paramHash = Apache::lonhelper::getParamHash();
     $paramHash->{MESSAGE_TEXT} = "";
     Apache::lonhelper::message->new();
@@ -1208,78 +1215,81 @@
     $paramHash->{CHOICES} = $printChoices;
     Apache::lonhelper::choices->new();
 
+    my $startedTable = 0; # have we started an HTML table yet? (need
+                          # to close it later)
+
     if (($ENV{'request.role.adv'} and &Apache::lonnet::allowed('vgr',$ENV{'request.course.id'})) or 
 	($helper->{VARS}->{'construction'} eq '1')) {
-        $paramHash = Apache::lonhelper::getParamHash();
-        $paramHash->{MESSAGE_TEXT} = "<br /><table><tr><td><big><b><i>Next four options are available only for advanced users:  </i></b></big></td><td>";
-        Apache::lonhelper::message->new();
+	addMessage("<hr width='33%' /><table><tr><td align='right'>Print With Answers:</td><td>");
         $paramHash = Apache::lonhelper::getParamHash();
 	$paramHash->{'variable'} = 'ANSWER_TYPE';   
 	$helper->declareVar('ANSWER_TYPE');         
         $paramHash->{CHOICES} = [
-                                   ['Print without answer', 'yes'],
-                                   ['Print with answers', 'no'] ];
+                                   ['Yes', 'yes'],
+                                   ['No', 'no'] ];
         Apache::lonhelper::dropdown->new();
+	addMessage("</td></tr>");
+	$startedTable = 1;
     }
 
     if ($ENV{'request.role.adv'}) {
-        $paramHash = Apache::lonhelper::getParamHash();
-        $paramHash->{MESSAGE_TEXT} = "</td></tr><tr><td>&nbsp;</td><td>";
-        Apache::lonhelper::message->new();
+	if (!$startedTable) {
+	    addMessage("<hr width='33%' /><table><tr><td align='right'>LaTeX mode: </td><td>");
+	    $startedTable = 1;
+	} else {
+	    addMessage("<tr><td align='right'>LaTeX mode: </td><td>");
+	}
         $paramHash = Apache::lonhelper::getParamHash();
 	$paramHash->{'variable'} = 'LATEX_TYPE';   
 	$helper->declareVar('LATEX_TYPE');  
 	if ($helper->{VARS}->{'construction'} eq '1') {       
 	    $paramHash->{CHOICES} = [
-				     ['Print in standard LaTeX mode', 'standard'], 
-				     ['Print in LaTeX batchmode', 'batchmode'], ];
+				     ['standard LaTeX mode', 'standard'], 
+				     ['LaTeX batchmode', 'batchmode'], ];
 	} else {
 	    $paramHash->{CHOICES} = [
-				     ['Print in LaTeX batchmode', 'batchmode'],
-				     ['Print in standard LaTeX mode', 'standard'] ];
+				     ['LaTeX batchmode', 'batchmode'],
+				     ['standard LaTeX mode', 'standard'] ];
 	}
         Apache::lonhelper::dropdown->new();
  
-        $paramHash = Apache::lonhelper::getParamHash();
-        $paramHash->{MESSAGE_TEXT} = "</td></tr><tr><td>&nbsp;</td><td>";
-        Apache::lonhelper::message->new();
+	addMessage("</td></tr><tr><td align='right'>Print Table of Contents: </td><td>");
         $paramHash = Apache::lonhelper::getParamHash();
 	$paramHash->{'variable'} = 'TABLE_CONTENTS';   
 	$helper->declareVar('TABLE_CONTENTS');         
         $paramHash->{CHOICES} = [
-                                   ['Print without Table of Contents', 'no'],
-                                   ['Print with Table of Contents', 'yes'] ];
+                                   ['No', 'no'],
+                                   ['Yes', 'yes'] ];
         Apache::lonhelper::dropdown->new();
+	addMessage("</td></tr>");
         
 	if (not $helper->{VARS}->{'construction'}) {
-	    $paramHash = Apache::lonhelper::getParamHash();
-	    $paramHash->{MESSAGE_TEXT} = "</td></tr><tr><td>&nbsp;</td><td>";
-	    Apache::lonhelper::message->new();
+	    addMessage("<tr><td align='right'>Print Index: </td><td>");
 	    $paramHash = Apache::lonhelper::getParamHash();
 	    $paramHash->{'variable'} = 'TABLE_INDEX';   
 	    $helper->declareVar('TABLE_INDEX');         
 	    $paramHash->{CHOICES} = [
-				     ['Print without Index', 'no'],
-				     ['Print with Index', 'yes'] ];
+				     ['No', 'no'],
+				     ['Yes', 'yes'] ];
 	    Apache::lonhelper::dropdown->new();
+	    addMessage("</td></tr>");
 	}
 
 	if ($helper->{VARS}->{'construction'}) {
-	    $paramHash = Apache::lonhelper::getParamHash();
-	    $paramHash->{MESSAGE_TEXT} = "</td></tr><tr><td>&nbsp;</td><td>";
-	    Apache::lonhelper::message->new();
+	    addMessage("<tr><td align='right'>Print With URL: </td><td>");
 	    $paramHash = Apache::lonhelper::getParamHash();
 	    $paramHash->{'variable'} = 'CONSTR_RESOURSE_URL';   
 	    $helper->declareVar('CONSTR_RESOURSE_URL');         
 	    $paramHash->{CHOICES} = [
-				     ['Print without URL', 'no'],
-				     ['Print with UTL', 'yes'] ];
+				     ['No', 'no'],
+				     ['Yes', 'yes'] ];
 	    Apache::lonhelper::dropdown->new();
+	    addMessage("</td></tr>");
 	}
+    }
 
-        $paramHash = Apache::lonhelper::getParamHash();
-        $paramHash->{MESSAGE_TEXT} = "</td></tr><table>";
-        Apache::lonhelper::message->new();
+    if ($startedTable) {
+	addMessage("</table>");
     }
 
     Apache::lonprintout::page_format_state->new("FORMAT");
@@ -1370,7 +1380,7 @@
 
     $result .= <<STATEHTML;
 
-<p><big><i><b>What page format do you prefer?</b></i></big></p>
+<hr width="33%" />
 <table cellpadding="3">
   <tr>
     <td align="center"><b>Page layout</b></td>