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

sakharuk lon-capa-cvs@mail.lon-capa.org
Wed, 29 Jan 2003 15:57:44 -0000


sakharuk		Wed Jan 29 10:57:44 2003 EDT

  Modified files:              
    /loncom/interface	lonprintout.pm 
  Log:
  Bugs 1166, 1184, 749, and 1101 are fixed. 
  1. Cleanup of the information for page header is done (last name, first name, course title, and sequence title). Some special characters are removed (_ ^), some are escaped (&). Currently it works well but I  guess we can meet some additional symbols in the future (for example in sequences titles). I'll check this possibility from time to time.
  2. All info for page header is unescaped now which allows to print students names with dots, empty spaces , ...
  3. Submit button is added to some menu. Additional work will be done after conversation wuth Geremy.
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.107 loncom/interface/lonprintout.pm:1.108
--- loncom/interface/lonprintout.pm:1.107	Tue Jan 28 15:36:17 2003
+++ loncom/interface/lonprintout.pm	Wed Jan 29 10:57:44 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.107 2003/01/28 20:36:17 sakharuk Exp $
+# $Id: lonprintout.pm,v 1.108 2003/01/29 15:57:44 sakharuk Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1284,17 +1284,19 @@
 	} else {
 	  ($textwidth,$textheight,$oddoffset,$evenoffset) = ($ENV{'form.width'},$ENV{'form.height'},$ENV{'form.leftmargin'},$ENV{'form.leftmargin'});
 	}
-	my $courseidinfo = $ENV{'course.'.$ENV{'request.course.id'}.'.description'};	
-	if ($layout eq 'CBI') {
-	    $text =~ s/\\begin{document}/\\setlength{\\oddsidemargin}{$oddoffset}\\setlength{\\evensidemargin}{$evenoffset}\\setlength{\\topmargin}{200pt}\\setlength{\\textwidth}{$textwidth}\\setlength{\\textheight}{$textheight}\\setlength{\\parindent}{20pt}\\setlength{\\marginparwidth}{90pt}\\setlength{\\textfloatsep}{8pt plus 2\.0pt minus 4\.0pt}\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm} \\begin{document}\\setcounter{page}{1}\\noindent\\parbox{\\minipagewidth}{\\noindent\\fbox{\\textbf{$ENV{'environment.firstname'} $ENV{'environment.lastname'}}} \\hfill  $courseidinfo} \\vskip 5 mm /;
-	} elsif ($layout eq 'CAPA') {
- 	    if ($choice ne 'All class print') { 
-		$text =~ s/\\begin{document}/\\textheight $textheight\\oddsidemargin = $evenoffset\\evensidemargin = $evenoffset\\textwidth= $textwidth\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\setlength{\\topmargin}{1cm}\\setlength{\\headheight}{1cm}\\setlength{\\headsep}{0.5cm}\\markboth{}{\\textbf{$ENV{'environment.firstname'} $ENV{'environment.lastname'}} $courseidinfo - $assignment}\\pagestyle{myheadings}\\begin{document}\\voffset=-1\.8cm\\setcounter{page}{1}/;
-	    } else {
+    my $firstname = &special_character_corrections(&Apache::lonnet::unescape($ENV{'environment.firstname'}));
+    my $lastname = &special_character_corrections(&Apache::lonnet::unescape($ENV{'environment.lastname'}));
+    my $courseidinfo = &special_character_corrections(&Apache::lonnet::unescape($ENV{'course.'.$ENV{'request.course.id'}.'.description'}));
+    if ($layout eq 'CBI') {
+	    $text =~ s/\\begin{document}/\\setlength{\\oddsidemargin}{$oddoffset}\\setlength{\\evensidemargin}{$evenoffset}\\setlength{\\topmargin}{200pt}\\setlength{\\textwidth}{$textwidth}\\setlength{\\textheight}{$textheight}\\setlength{\\parindent}{20pt}\\setlength{\\marginparwidth}{90pt}\\setlength{\\textfloatsep}{8pt plus 2\.0pt minus 4\.0pt}\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm} \\begin{document}\\setcounter{page}{1}\\noindent\\parbox{\\minipagewidth}{\\noindent\\fbox{\\textbf{$firstname $lastname}} \\hfill  $courseidinfo} \\vskip 5 mm /;
+    } elsif ($layout eq 'CAPA') {
+	if ($choice ne 'All class print') { 
+		$text =~ s/\\begin{document}/\\textheight $textheight\\oddsidemargin = $evenoffset\\evensidemargin = $evenoffset\\textwidth= $textwidth\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\setlength{\\topmargin}{1cm}\\setlength{\\headheight}{1cm}\\setlength{\\headsep}{0.5cm}\\markboth{}{\\textbf{$firstname $lastname} $courseidinfo - $assignment}\\pagestyle{myheadings}\\begin{document}\\voffset=-1\.8cm\\setcounter{page}{1}/;
+	} else {
 		$text =~ s/\\begin{document}/\\textheight $textheight\\oddsidemargin = $evenoffset\\evensidemargin = $evenoffset\\textwidth= $textwidth\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\begin{document}\\voffset=-1\.8cm\\setcounter{page}{1}  \\vskip 5 mm /;
-	    }
 	}
-	return $text;
+    }
+    return $text;
 }
 
 
@@ -1334,6 +1336,15 @@
     }  
     return ($name_of_resourse,$name_of_sequence,$name_of_map);
 
+}
+
+
+sub special_character_corrections {
+    my $argument = shift;
+    $argument =~ s/_/ /g;
+    $argument =~ s/\^/ /g;
+    $argument =~ s/&/\\&/g;
+    return $argument;
 }