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

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 03 Mar 2003 20:58:18 -0000


albertel		Mon Mar  3 15:58:18 2003 EDT

  Modified files:              
    /loncom/interface	lonprintout.pm 
  Log:
  - name code handling cleanup
  - need to check if section is -1 (This means no section)
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.125 loncom/interface/lonprintout.pm:1.126
--- loncom/interface/lonprintout.pm:1.125	Mon Mar  3 15:26:08 2003
+++ loncom/interface/lonprintout.pm	Mon Mar  3 15:58:18 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.125 2003/03/03 20:26:08 albertel Exp $
+# $Id: lonprintout.pm,v 1.126 2003/03/03 20:58:18 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -370,6 +370,7 @@
               $sdom,$sname);
            my $section=&Apache::lonnet::usection
 	       ($sdom,$sname,$ENV{'request.course.id'});
+	   if ($section == -1) { $section = ''; }
            $r->print(
         '<br /><input type=checkbox name="whomtoprint'.$i.'" value="'.$section.':'.$_.'"> '.
 		      $reply{'firstname'}.' '. 
@@ -607,7 +608,7 @@
 	foreach my $person (@students) {
 	    my $current_output = ''; 
 	    my ($usersection,$username,$userdomain) = split /:/,$person;
-	    my $fullname = &Apache::grades::get_fullname($username,$userdomain);    
+	    my $fullname = &get_name($username,$userdomain);
             #goes through all resources, checks if they are available for current student, and produces output   
 	    foreach my $curresline (@master_seq)  {
 		my ($curres,$symb) = split /&&/, $curresline;
@@ -1104,6 +1105,16 @@
     }
 
 
+sub get_name {
+    my ($uname,$udom)=@_;
+    if (!defined($uname)) { $uname=$ENV{'user.name'}; }
+    if (!defined($udom)) { $uname=$ENV{'user.domain'}; }
+    my $plainname=&Apache::loncommon::plainname($uname,$udom);
+    if ($plainname=~/^\s*$/) { $plainname=$uname; }
+    return &Apache::lonxml::latex_special_symbols($plainname,undef,undef,
+						  'header');
+}
+
 sub page_format_transformation {
     my ($papersize,$layout,$numberofcolumns,$choice,$text,$assignment) = @_; 
     my ($textwidth,$textheight,$oddoffset,$evenoffset);
@@ -1113,14 +1124,17 @@
 	} else {
 	  ($textwidth,$textheight,$oddoffset,$evenoffset) = ($ENV{'form.width'},$ENV{'form.height'},$ENV{'form.leftmargin'},$ENV{'form.leftmargin'});
 	}
-    my $firstname = &Apache::lonxml::latex_special_symbols(&Apache::lonnet::unescape($ENV{'environment.firstname'}),'','','header');
-    my $lastname = &Apache::lonxml::latex_special_symbols(&Apache::lonnet::unescape($ENV{'environment.lastname'}),'','','header');
+    my $name = &get_name();
+    if ($name =~ /^\s*$/) {
+	$name=&Apache::lonxml::latex_special_symbols($ENV{'user.name'},undef,
+						     undef,'header');
+    }
     my $courseidinfo = &Apache::lonxml::latex_special_symbols(&Apache::lonnet::unescape($ENV{'course.'.$ENV{'request.course.id'}.'.description'}),'','','header');
     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 /;
+	    $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{$name}} \\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\}\\usepackage{fancyhdr}\\pagestyle{fancy}\\rhead{}\\chead{}\\lhead{\\textbf{$firstname $lastname} - $courseidinfo \\hfill \\thepage \\\\ \\textit{$assignment}}\\begin{document}\\voffset=-0\.8 cm\\setcounter{page}{1}/;
+		$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\}\\usepackage{fancyhdr}\\pagestyle{fancy}\\rhead{}\\chead{}\\lhead{\\textbf{$name} - $courseidinfo \\hfill \\thepage \\\\ \\textit{$assignment}}\\begin{document}\\voffset=-0\.8 cm\\setcounter{page}{1}/;
 	} else {
 	    $text =~ s/\\pagestyle{fancy}\\rhead{}\\chead{}\s*\\begin{document}/\\textheight $textheight\\oddsidemargin = $evenoffset\\evensidemargin = $evenoffset\\textwidth= $textwidth\\newlength{\\minipagewidth}\\setlength{\\minipagewidth}{\\textwidth\/\$number_of_columns-0\.2cm}\\renewcommand{\\ref}{\\keephidden\}\\pagestyle{fancy}\\rhead{}\\chead{}\\begin{document}\\voffset=-0\.8cm\\setcounter{page}{1}  \\vskip 5 mm /;