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

foxr lon-capa-cvs@mail.lon-capa.org
Mon, 03 Jul 2006 12:59:58 -0000


This is a MIME encoded message

--foxr1151931598
Content-Type: text/plain

foxr		Mon Jul  3 08:59:58 2006 EDT

  Modified files:              
    /loncom/interface	lonparmset.pm lonprintout.pm 
  Log:
  Add ability to set the print format
  
  
--foxr1151931598
Content-Type: text/plain
Content-Disposition: attachment; filename="foxr-20060703085958.txt"

Index: loncom/interface/lonparmset.pm
diff -u loncom/interface/lonparmset.pm:1.318 loncom/interface/lonparmset.pm:1.319
--- loncom/interface/lonparmset.pm:1.318	Mon Jun 26 18:22:48 2006
+++ loncom/interface/lonparmset.pm	Mon Jul  3 08:59:58 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Handler to set parameters for assessments
 #
-# $Id: lonparmset.pm,v 1.318 2006/06/26 22:22:48 albertel Exp $
+# $Id: lonparmset.pm,v 1.319 2006/07/03 12:59:58 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2187,6 +2187,8 @@
                     ' ('.&mt('supported types').': Letter [8 1/2x11 in], Legal [8 1/2x14 in],'. 
                     ' Tabloid [11x17 in], Executive [7 1/2x10 in], A2 [420x594 mm],'. 
                     ' A3 [297x420 mm], A4 [210x297 mm], A5 [148x210 mm], A6 [105x148 mm])',
+	     'print_header_format'
+	         => '<b>Print header format; substitutions:  %n student name %c course id %a assignment',
              'anonymous_quiz'
                  => '<b>'.&mt('Anonymous quiz/exam').'</b><br />'.
                     ' (<tt><b>'.&mt('yes').'</b> '.&mt('to avoid print students names').' </tt>)',
@@ -2227,6 +2229,7 @@
                              'problem_stream_switch',
 			     'suppress_tries',
                              'default_paper_size',
+			     'print_header_format',
                              'disable_receipt_display',
                              'spreadsheet_default_classcalc',
                              'spreadsheet_default_studentcalc',
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.453 loncom/interface/lonprintout.pm:1.454
--- loncom/interface/lonprintout.pm:1.453	Mon Jul  3 06:25:07 2006
+++ loncom/interface/lonprintout.pm	Mon Jul  3 08:59:58 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.453 2006/07/03 10:25:07 foxr Exp $
+# $Id: lonprintout.pm,v 1.454 2006/07/03 12:59:58 foxr Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -46,6 +46,35 @@
 use LONCAPA;
 
 my %perm;
+my %parmhash;
+
+
+# Format a header according to a format.  
+# 
+
+# Substitutions:
+#     %a    - Assignment name.
+#     %c    - Course name.
+#     %n    - Student name.
+#
+sub format_page_header {
+    my ($format, $assignment, $course, $student) = @_;
+    
+    #  Default format?
+
+    if ($format eq '') {
+	$format =  "\\textbf{$student} $course \\hfill \\thepage \\\\ \\textit{$assignment}";
+	
+    } else {
+	$format =~ s/%a/$assignment/g;
+	$format =~ s/%c/$course/g;
+	$format =~ s/%n/$student/g;
+    }
+    
+
+    return $format;
+    
+}
 
 #
 #   Convert a numeric code to letters
@@ -717,22 +746,28 @@
 sub page_format_transformation {
     my ($papersize,$layout,$numberofcolumns,$choice,$text,$assignment,$tableofcontents,$indexlist,$selectionmade) = @_; 
     my ($textwidth,$textheight,$oddoffset,$evenoffset,$topmargin);
+
     if ($selectionmade eq '4') {
 	$assignment='Problems from the Whole Course';
     } else {
 	$assignment=&Apache::lonxml::latex_special_symbols($assignment,'header');
     }
     ($textwidth,$textheight,$oddoffset,$evenoffset,$topmargin) = &page_format($papersize,$layout,$numberofcolumns,$topmargin);
+
+
     my $name = &get_name();
     my $courseidinfo = &get_course();
     if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }
+    my $HeaderText  = $parmhash{'print_header_format'};
+    $HeaderText     = &format_page_header($HeaderText, $assignment, $courseidinfo, $name);
+    &Apache::lonnet::logthis("Header Format: $HeaderText");
     my $topmargintoinsert = '';
     if ($topmargin ne '0') {$topmargintoinsert='\setlength{\topmargin}{'.$topmargin.'}';}
     my $fancypagestatement='';
     if ($numberofcolumns eq '2') {
-	$fancypagestatement="\\fancyhead{}\\fancyhead[LO]{\\textbf{$name} $courseidinfo \\hfill \\thepage \\\\ \\textit{$assignment}}";
+	$fancypagestatement="\\fancyhead{}\\fancyhead[LO]{$HeaderText}";
     } else {
-	$fancypagestatement="\\rhead{}\\chead{}\\lhead{\\textbf{$name} $courseidinfo \\hfill \\thepage \\\\ \\textit{$assignment}}";
+	$fancypagestatement="\\rhead{}\\chead{}\\lhead{$HeaderText}";
     }
     if ($layout eq 'album') {
 	    $text =~ s/\\begin{document}/\\setlength{\\oddsidemargin}{$oddoffset}\\setlength{\\evensidemargin}{$evenoffset}$topmargintoinsert\n\\setlength{\\textwidth}{$textwidth}\\setlength{\\textheight}{$textheight}\\setlength{\\textfloatsep}{8pt plus 2\.0pt minus 4\.0pt}\n\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\usepackage{fancyhdr}\\addtolength{\\headheight}{\\baselineskip}\n\\pagestyle{fancy}$fancypagestatement\\begin{document}\\voffset=-0\.8 cm\\setcounter{page}{1}\n /;
@@ -1371,10 +1406,16 @@
 		    my $courseidinfo = &get_course();
 		    if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }
 		    $prevassignment=$assignment;
+		    my $HeaderText = $parmhash{'print_header_format'};
+		    $HeaderText    = &format_page_header($HeaderText,
+							 $assignment, 
+							 $courseidinfo, 
+							 $name);
+		    &Apache::lonnet::logthis("Hdr Format $HeaderText");
 		    if ($numberofcolumns eq '1') {
-			$result .='\newpage \noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$name.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$assignment.'}}} \vskip 5 mm ';
+			$result .='\newpage \noindent\parbox{\minipagewidth}{\noindent\\lhead{'.$HeaderText.'}} \vskip 5 mm ';
 		    } else {
-			$result .='\newpage \noindent\parbox{\minipagewidth}{\noindent\\fancyhead[LO]{\\textit{\\textbf{'.$name.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$assignment.'}}} \vskip 5 mm ';
+			$result .='\newpage \noindent\parbox{\minipagewidth}{\noindent\\fancyhead[LO]{'.$HeaderText.'}} \vskip 5 mm ';
 		    }			
 		}
 		$result .= $texversion;
@@ -1903,20 +1944,23 @@
     if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }
     if ($usersection ne '') {$courseidinfo.=' - Sec. '.$usersection}
     my $currentassignment=&Apache::lonxml::latex_special_symbols($helper->{VARS}->{'assignment'},'header');
+    my $HeaderLine = $parmhash{'print_header_format'};
+    $HeaderLine = format_page_header($HeaderLine, $currentassignment, $courseidinfo, $fullname);
+    &Apache::lonnet::logthis("Hdr format: $HeaderLine");
     if ($current_output=~/\\documentclass/) {
 	if ($columns_in_format == 1) {
-	    $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent\\lhead{\\textit{\\textbf{$fullname}}$courseidinfo \\hfill \\thepage \\\\ \\textit{$currentassignment}$namepostfix}}\\vskip 5 mm /;
+	    $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent\\lhead{$HeaderLine$namepostfix}}\\vskip 5 mm /;
 	} else {
-	    	    $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent\\fancyhead[LO]{\\textit{\\textbf{$fullname}}$courseidinfo \\hfill \\thepage \\\\ \\textit{$currentassignment}$namepostfix}}\\vskip 5 mm /;
+	    	    $current_output =~ s/\\begin{document}/\\setlength{\\topmargin}{1cm} \\begin{document}\\noindent\\parbox{\\minipagewidth}{\\noindent\\fancyhead[LO]{$HeaderLine$namepostfix}}\\vskip 5 mm /;
 
 	}
     } else {
 	my $blankpages = '';
 	for (my $j=0;$j<$helper->{'VARS'}->{'EMPTY_PAGES'};$j++) {$blankpages.='\clearpage\strut\clearpage';}
 	if ($columns_in_format == 1) {
-	    $current_output = '\strut\vspace*{-6 mm}\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\vspace*{-2 mm}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blankpages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{\\textit{\\textbf{'.$fullname.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$currentassignment.'}'.$namepostfix.'}} \vskip 5 mm '.$current_output;
+	    $current_output = '\strut\vspace*{-6 mm}\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\vspace*{-2 mm}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blankpages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\lhead{'.$HeaderLine.'}'.$namepostfix.'} \vskip 5 mm '.$current_output;
 	} else {
-	   $current_output = '\strut\vspace*{-6 mm}\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\vspace*{-2 mm}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blankpages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\fancyhead[LO]{\\textit{\\textbf{'.$fullname.'}}'.$courseidinfo.' \\hfill \\thepage \\\\ \\textit{'.$currentassignment.'}'.$namepostfix.'}} \vskip 5 mm '.$current_output;
+	   $current_output = '\strut\vspace*{-6 mm}\\newline\\noindent\\makebox[\\textwidth/$number_of_columns][b]{\\hrulefill}\vspace*{-2 mm}\\newline\\noindent{\\tiny Printed from LON-CAPA\\copyright MSU{\\hfill} Licensed under GNU General Public License }\\newpage '.$blankpages.'\setcounter{page}{1}\noindent\parbox{\minipagewidth}{\noindent\\fancyhead[LO]{'.$HeaderLine.'}'.$namepostfix.'} \vskip 5 mm '.$current_output;
 	}
     }
     #
@@ -1941,7 +1985,7 @@
     }
    
 
-    my %parmhash=&Apache::lonnet::coursedescription($env{'request.course.id'});
+    %parmhash=&Apache::lonnet::coursedescription($env{'request.course.id'});
  
 
 

--foxr1151931598--