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

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 15 Mar 2004 22:32:37 -0000


albertel		Mon Mar 15 17:32:37 2004 EDT

  Modified files:              
    /loncom/interface	lonprintout.pm loncommon.pm 
  Log:
  - Fixes for BUG#2834, printing wasn't passing the textwidth paramaeter along.
  - Fixed some of my orginal get_student_view code from back when I didn't know what I was doing (Nov 2001)
  
  
  
Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.281 loncom/interface/lonprintout.pm:1.282
--- loncom/interface/lonprintout.pm:1.281	Fri Mar 12 11:23:23 2004
+++ loncom/interface/lonprintout.pm	Mon Mar 15 17:32:37 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.281 2004/03/12 16:23:23 sakharuk Exp $
+# $Id: lonprintout.pm,v 1.282 2004/03/15 22:32:37 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -996,7 +996,6 @@
 	 } else {
 	     $moreenv{'textwidth'}=$LaTeXwidth;
 	 }
-	 &Apache::lonnet::appenv(%moreenv);
 	 my %prog_state=&Apache::lonhtmlcommon::Create_PrgWin($r,'Print Status','Class Print Status',$#students+1);
 	 my $student_counter=-1;
 	 foreach my $person (@students) {
@@ -1014,7 +1013,7 @@
 		    my ($map,$id,$res_url) = &Apache::lonnet::decode_symb($curresline);
 		    if (&Apache::lonnet::allowed('bre',$res_url)) {
 			my $rendered = &Apache::loncommon::get_student_view($curresline,$username,$userdomain,
-                                                                        $ENV{'request.course.id'},'tex');
+                                                                        $ENV{'request.course.id'},'tex',\%moreenv);
 			my $lonidsdir=$r->dir_config('lonIDsDir');
 			my $envfile=$ENV{'user.environment'};
 			$envfile=~/\/([^\/]+)\.id$/;
@@ -1067,7 +1066,6 @@
 	}
 	&Apache::lonhtmlcommon::Close_PrgWin($r,\%prog_state);
 	$result .= $print_array[0].'  \end{document}';
-	&Apache::lonnet::delenv('form.textwidth');
     } elsif ($helper->{'VARS'}->{'PRINT_TYPE'} eq 'problems_from_directory') {      
     #prints selected problems from the subdirectory 
 	$selectionmade = 6;
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.185 loncom/interface/loncommon.pm:1.186
--- loncom/interface/loncommon.pm:1.185	Mon Mar  8 12:31:37 2004
+++ loncom/interface/loncommon.pm	Mon Mar 15 17:32:37 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # a pile of common routines
 #
-# $Id: loncommon.pm,v 1.185 2004/03/08 17:31:37 www Exp $
+# $Id: loncommon.pm,v 1.186 2004/03/15 22:32:37 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -2093,22 +2093,19 @@
 =cut
 
 sub get_student_view {
-  my ($symb,$username,$domain,$courseid,$target) = @_;
+  my ($symb,$username,$domain,$courseid,$target,$moreenv) = @_;
   my ($map,$id,$feedurl) = &Apache::lonnet::decode_symb($symb);
-  my (%old,%moreenv);
+  my (%form);
   my @elements=('symb','courseid','domain','username');
   foreach my $element (@elements) {
-    $old{$element}=$ENV{'form.grade_'.$element};
-    $moreenv{'form.grade_'.$element}=eval '$'.$element #'
+      $form{'grade_'.$element}=eval '$'.$element #'
   }
-  if ($target eq 'tex') {$moreenv{'form.grade_target'} = 'tex';}
-  &Apache::lonnet::appenv(%moreenv);
-  $feedurl=&Apache::lonnet::clutter($feedurl);
-  my $userview=&Apache::lonnet::ssi_body($feedurl);
-  &Apache::lonnet::delenv('form.grade_');
-  foreach my $element (@elements) {
-    $ENV{'form.grade_'.$element}=$old{$element};
+  if (defined($moreenv)) {
+      %form=(%form,%{$moreenv});
   }
+  if ($target eq 'tex') {$form{'grade_target'} = 'tex';}
+  $feedurl=&Apache::lonnet::clutter($feedurl);
+  my $userview=&Apache::lonnet::ssi_body($feedurl,%form);
   $userview=~s/\<body[^\>]*\>//gi;
   $userview=~s/\<\/body\>//gi;
   $userview=~s/\<html\>//gi;
@@ -2131,19 +2128,14 @@
 sub get_student_answers {
   my ($symb,$username,$domain,$courseid,%form) = @_;
   my ($map,$id,$feedurl) = &Apache::lonnet::decode_symb($symb);
-  my (%old,%moreenv);
+  my (%moreenv);
   my @elements=('symb','courseid','domain','username');
   foreach my $element (@elements) {
-    $old{$element}=$ENV{'form.grade_'.$element};
-    $moreenv{'form.grade_'.$element}=eval '$'.$element #'
-  }
-  $moreenv{'form.grade_target'}='answer';
-  &Apache::lonnet::appenv(%moreenv);
-  my $userview=&Apache::lonnet::ssi('/res/'.$feedurl,%form);
-  &Apache::lonnet::delenv('form.grade_');
-  foreach my $element (@elements) {
-    $ENV{'form.grade_'.$element}=$old{$element};
+    $moreenv{'grade_'.$element}=eval '$'.$element #'
   }
+  $moreenv{'grade_target'}='answer';
+  %moreenv=(%form,%moreenv);
+  my $userview=&Apache::lonnet::ssi('/res/'.$feedurl,%moreenv);
   return $userview;
 }