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

raeburn raeburn at source.lon-capa.org
Thu Dec 27 19:25:11 EST 2012


raeburn		Fri Dec 28 00:25:11 2012 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/interface	lonprintout.pm 
  Log:
  - For 2.11
    - Reverse changes from 1.537, 1.538, 1.565.
    - This is the same change as 1.568.2.4 for 2.9.X, and 1.583.2.1 for 2.10.X 
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.627 loncom/interface/lonprintout.pm:1.627.2.1
--- loncom/interface/lonprintout.pm:1.627	Mon Dec 17 14:16:06 2012
+++ loncom/interface/lonprintout.pm	Fri Dec 28 00:25:11 2012
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.627 2012/12/17 14:16:06 raeburn Exp $
+# $Id: lonprintout.pm,v 1.627.2.1 2012/12/28 00:25:11 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1048,12 +1048,12 @@
 #     %s    - The section if it is supplied.
 #
 sub format_page_header {
-    my ($width, $format, $assignment, $course, $student, $section) = @_;
+    my ($width, $format, $assignment, $course, $student) = @_;
 
 
 
     $width = &recalcto_mm($width); # Get width in mm.
-    my $chars_per_line = int($width/1.6);   # Character/textline.
+    my $chars_per_line = int($width/2);   # Character/textline.
 
     #  Default format?
 
@@ -1069,34 +1069,38 @@
 	# - Allow the assignment to be 2 lines (wrapped).
 	#
 
-	
+        my $firstline = "$student $course";
+        if (length($firstline) > $chars_per_line) {
+            my $lastchar = $chars_per_line - length($student) - 1;
+            if ($lastchar > 0) {
+                $course = substr($course, 0, $lastchar);
+            } else {            # Nothing left of course:
+                $course = '';
+            }
+        }
+        if (length($assignment) > $chars_per_line) {
+            $assignment = substr($assignment, 0, $chars_per_line);
+        }
 
-	my $name_length    = int($chars_per_line *3 /4);
-	my $sec_length     = int($chars_per_line / 5);
+        $format =  "\\textbf{$student} $course \\hfill \\thepage \\\\ \\textit{$assignment}";
 
-	$format  = "%$name_length".'n';
+    } else {
+        # An open question is how to handle long user formatted page headers...
+        # A possible future is to support e.g. %na so that the user can control
+        # the truncation of the elements that can appear in the header.
+        #
+        $format =  &printf_style_subst("a", $format, $assignment);
+        $format =  &printf_style_subst("c", $format, $course);
+        $format =  &printf_style_subst("n", $format, $student);
+
+        # If the user put %'s in the format string, they must be escaped
+        # to \% else LaTeX will think they are comments and terminate
+        # the line.. which is bad!!!
 
-	if ($section) {
-	    $format .=  ' - Sec: '."%$sec_length".'s';
-	}
+    }
 
-	$format .= '\\\\%c \\\\ %a';
-        
+    return $format;
 
-    }
-    # An open question is how to handle long user formatted page headers...
-    # A possible future is to support e.g. %na so that the user can control
-    # the truncation of the elements that can appear in the header.
-    #
-    $format =  &printf_style_subst("a", $format, $assignment);
-    $format =  &printf_style_subst("c", $format, $course);
-    $format =  &printf_style_subst("n", $format, $student);
-    $format =  &printf_style_subst("s", $format, $section);
-    
-    
-    # If the user put %'s in the format string, they  must be escaped
-    # to \% else LaTeX will think they are comments and terminate
-    # the line.. which is bad!!!
     
     # If the user has role author, $course and $assignment are empty so
     # there is '\\ \\ ' in the page header. That's cause a error in LaTeX
@@ -1832,8 +1836,6 @@
     my $courseidinfo;
     if (defined($env{'request.course.id'})) {
 	$courseidinfo = &Apache::lonxml::latex_special_symbols(&unescape($env{'course.'.$env{'request.course.id'}.'.description'}),'header');
-	my $sec = $env{'request.course.sec'};
-	    
     }
     return $courseidinfo;
 }
@@ -1856,6 +1858,7 @@
 
     my $name = &get_name();
     my $courseidinfo = &get_course();
+    if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }
     my $header_text  = $parmhash{'print_header_format'};
     $header_text     = &format_page_header($textwidth, $header_text, $assignment,
 					   $courseidinfo, $name);
@@ -3022,6 +3025,7 @@
 		if (($selectionmade == 4) and ($assignment ne $prevassignment)) {
 		    my $name = &get_name();
 		    my $courseidinfo = &get_course();
+                    if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }
 		    $prevassignment=$assignment;
 		    my $header_text = $parmhash{'print_header_format'};
 		    $header_text    = &format_page_header($textwidth, $header_text,
@@ -3608,6 +3612,8 @@
     my $current_assignment = "";
     my $assignment;
     my $courseidinfo = &get_course();
+    if (defined($courseidinfo)) { $courseidinfo=' - '.$courseidinfo }
+    if ($usersection ne '') {$courseidinfo.=' - Sec. '.$usersection}
 
     foreach my $curresline (@{$master_seq})  {
 	if (defined $page_breaks{$curresline}) {
@@ -3731,7 +3737,7 @@
 	if (($assignment ne $current_assignment) && ($assignment ne "")) {
 	    my $header_line = &format_page_header($LaTeXwidth, $parmhash{'print_header_format'},
 						  $assignment, $courseidinfo, 
-						  $fullname, $usersection);
+						  $fullname);
 	    my $header_start = ($columns_in_format == 1) ? '\lhead'
 		: '\fancyhead[LO]';
 	    $header_line = $header_start.'{'.$header_line.'}';
@@ -3763,7 +3769,7 @@
 	my $currentassignment=&Apache::lonxml::latex_special_symbols($helper->{VARS}->{'assignment'},'header');
 	my $header_line =
 	    &format_page_header($LaTeXwidth, $parmhash{'print_header_format'},
-				$currentassignment, $courseidinfo, $fullname, $usersection);
+				$currentassignment, $courseidinfo, $fullname);
 	my $header_start = ($columns_in_format == 1) ? '\lhead'
 	    : '\fancyhead[LO]';
 	$header_line = $header_start.'{'.$header_line.'}';




More information about the LON-CAPA-cvs mailing list