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

www lon-capa-cvs-allow@mail.lon-capa.org
Fri, 28 Mar 2008 15:22:49 -0000


This is a MIME encoded message

--www1206717769
Content-Type: text/plain

www		Fri Mar 28 11:22:49 2008 EDT

  Modified files:              
    /loncom/interface	lonprintout.pm 
  Log:
  Saving my work.
  
  Avoid maximum user punishment!!!
  
  A printout of for example phy183 exams takes 80 minutes,
  but on the average "only" two printouts are damaged.
  
  
--www1206717769
Content-Type: text/plain
Content-Disposition: attachment; filename="www-20080328112249.txt"

Index: loncom/interface/lonprintout.pm
diff -u loncom/interface/lonprintout.pm:1.524 loncom/interface/lonprintout.pm:1.525
--- loncom/interface/lonprintout.pm:1.524	Fri Mar 28 10:52:52 2008
+++ loncom/interface/lonprintout.pm	Fri Mar 28 11:22:48 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Printout
 #
-# $Id: lonprintout.pm,v 1.524 2008/03/28 14:52:52 www Exp $
+# $Id: lonprintout.pm,v 1.525 2008/03/28 15:22:48 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -150,7 +150,7 @@
 	$ssi_error               = 1;
 	$ssi_last_error_resource = $resource;
 	$ssi_last_error          = $response->code . " " . $response->message;
-	
+        $content='\section*{!!! An error occured !!!}';	
 	&Apache::lonnet::logthis("Error in SSI resource: $resource Error: $ssi_last_error");
     }
 
@@ -166,7 +166,7 @@
         $ssi_error               = 1;
         $ssi_last_error_resource = $curresline;
         $ssi_last_error          = $response->code . " " . $response->message;
-
+        $content='\section*{!!! An error occured !!!}';
         &Apache::lonnet::logthis("Error in SSI (student view) resource: $curresline Error: $ssi_last_error");
     }
 
@@ -2102,95 +2102,68 @@
 	}
     }
 
-
-    # If there's been an unrecoverable SSI error, report it to the user
-    # otherwise, we can write the tex file.
-    #
-
-    if ($ssi_error) {
-
-        my $helpurl = &Apache::loncommon::top_nav_help('Helpdesk');
-	my $end_page = &Apache::loncommon::end_page();
-	$r->print('
-<br />
-<h2>'.&mt('An unrecoverable network error occurred:').'</h2>
-<p>
-  '.&mt('One of the resources ([_1]) you chose to print could not be rendered due to an unrecoverable error when communicating with a server:',$ssi_last_error_resource).' 
-<br />
-'.$ssi_last_error.'
-</p>
-<p>'.
-&mt('It is recommended that you try printing again later, as this error may mean the server was just temporarily unavailable, or is down for maintenance.').'<br />'.
-&mt('If the error persists, please contact the [_1] for assistance.',$helpurl).
-'</p><p>'.
-&mt('We apologize for the inconvenience.').
-'</p>'.
-$end_page);
-    } else {
-
 #-- writing .tex file in prtspool 
-	my $temp_file;
-	my $identifier = &Apache::loncommon::get_cgi_id();
-	my $filename = "/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout_$identifier.tex";
-	if (!($#print_array>0)) { 
-	    unless ($temp_file = Apache::File->new('>'.$filename)) {
-		$r->log_error("Couldn't open $filename for output $!");
-		return SERVER_ERROR; 
-	    }
-	    print $temp_file $result;
-	    my $begin=index($result,'\begin{document}',0);
-	    my $inc=substr($result,0,$begin+16);
-	} else {
-	    my $begin=index($result,'\begin{document}',0);
-	    my $inc=substr($result,0,$begin+16);
-	    for (my $i=0;$i<=$#print_array;$i++) {
-		if ($i==0) {
-		    $print_array[$i]=$result;
-		} else {
-		    $print_array[$i].='\end{document}';
-		    $print_array[$i] = 
-			&latex_corrections($number_of_columns,$print_array[$i],
-					   $selectionmade, 
-					   $helper->{'VARS'}->{'ANSWER_TYPE'});
-		    
-		    my $anobegin=index($print_array[$i],'\setcounter{page}',0);
-		    substr($print_array[$i],0,$anobegin)='';
-		    $print_array[$i]=$inc.$print_array[$i];
-		}
-		my $temp_file;
-		my $newfilename=$filename;
-		my $num=$i+1;
-		$newfilename =~s/\.tex$//; 
-		$newfilename=sprintf("%s_%03d.tex",$newfilename, $num);
-		unless ($temp_file = Apache::File->new('>'.$newfilename)) {
-		    $r->log_error("Couldn't open $newfilename for output $!");
-		    return SERVER_ERROR; 
-		}
-		print $temp_file $print_array[$i];
-	    }
+    my $temp_file;
+    my $identifier = &Apache::loncommon::get_cgi_id();
+    my $filename = "/home/httpd/prtspool/$env{'user.name'}_$env{'user.domain'}_printout_$identifier.tex";
+    if (!($#print_array>0)) { 
+       unless ($temp_file = Apache::File->new('>'.$filename)) {
+	  $r->log_error("Couldn't open $filename for output $!");
+	  return SERVER_ERROR; 
+       }
+       print $temp_file $result;
+       my $begin=index($result,'\begin{document}',0);
+       my $inc=substr($result,0,$begin+16); 
+    } else {
+       my $begin=index($result,'\begin{document}',0);
+       my $inc=substr($result,0,$begin+16);
+       for (my $i=0;$i<=$#print_array;$i++) {
+	  if ($i==0) {
+	      $print_array[$i]=$result;
+	  } else {
+	      $print_array[$i].='\end{document}';
+	      $print_array[$i] = 
+		&latex_corrections($number_of_columns,$print_array[$i],
+				   $selectionmade, 
+				   $helper->{'VARS'}->{'ANSWER_TYPE'});
 	    
+	      my $anobegin=index($print_array[$i],'\setcounter{page}',0);
+	      substr($print_array[$i],0,$anobegin)='';
+	      $print_array[$i]=$inc.$print_array[$i];
+	  }
+	  my $temp_file;
+	  my $newfilename=$filename;
+	  my $num=$i+1;
+	  $newfilename =~s/\.tex$//; 
+	  $newfilename=sprintf("%s_%03d.tex",$newfilename, $num);
+	  unless ($temp_file = Apache::File->new('>'.$newfilename)) {
+	      $r->log_error("Couldn't open $newfilename for output $!");
+	      return SERVER_ERROR; 
+	  }
+	  print $temp_file $print_array[$i];
+       }
+    }
+    my $student_names='';
+    if ($#print_array>0) {
+        for (my $i=0;$i<=$#print_array;$i++) {
+  	  $student_names.=$student_names[$i].'_ENDPERSON_';
 	}
-	my $student_names='';
-	if ($#print_array>0) {
-	    for (my $i=0;$i<=$#print_array;$i++) {
-		$student_names.=$student_names[$i].'_ENDPERSON_';
-	    }
+    } else {
+	if ($#student_names>-1) {
+	   $student_names=$student_names[0].'_ENDPERSON_';
 	} else {
-	    if ($#student_names>-1) {
-		$student_names=$student_names[0].'_ENDPERSON_';
-	    } else {
-		my $fullname = &get_name($env{'user.name'},$env{'user.domain'});
-		$student_names=join(':',$env{'user.name'},$env{'user.domain'},
+           my $fullname = &get_name($env{'user.name'},$env{'user.domain'});
+	   $student_names=join(':',$env{'user.name'},$env{'user.domain'},
 				    $env{'request.course.sec'},$fullname).
 					'_ENDPERSON_'.'_END_';
-	    }
 	}
+     }
 	
-	# logic for now is too complex to trace if this has been defined
-	#  yet.
-	my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
-	my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
-	&Apache::lonnet::appenv({'cgi.'.$identifier.'.file'   => $filename,
+     # logic for now is too complex to trace if this has been defined
+     #  yet.
+     my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
+     my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
+     &Apache::lonnet::appenv({'cgi.'.$identifier.'.file'   => $filename,
 				'cgi.'.$identifier.'.layout'  => $laystyle,
 				'cgi.'.$identifier.'.numcol'  => $numberofcolumns,
 				'cgi.'.$identifier.'.paper'  => $papersize,
@@ -2201,13 +2174,26 @@
 				'cgi.'.$identifier.'.numberoffiles' => $#print_array,
 				'cgi.'.$identifier.'.studentnames' => $student_names,
 				'cgi.'.$identifier.'.backref' => $URLback,});
-	&Apache::lonnet::appenv({"cgi.$identifier.user"    => $env{'user.name'},
+    &Apache::lonnet::appenv({"cgi.$identifier.user"    => $env{'user.name'},
 				"cgi.$identifier.domain"  => $env{'user.domain'},
 				"cgi.$identifier.courseid" => $cnum, 
 				"cgi.$identifier.coursedom" => $cdom, 
 				"cgi.$identifier.resources" => $resources_printed});
 	
-	my $end_page = &Apache::loncommon::end_page();
+    my $end_page = &Apache::loncommon::end_page();
+    # If there's been an unrecoverable SSI error, report it to the user
+    if ($ssi_error) {
+        my $helpurl = &Apache::loncommon::top_nav_help('Helpdesk');
+        my $end_page = &Apache::loncommon::end_page();
+        $r->print('<br /><h2>'.&mt('An unrecoverable network error occurred:').'</h2><p>  '.
+                  &mt('One of the resources ([_1]) you chose to print could not be rendered due to an unrecoverable error when communicating with a server:',
+                  $ssi_last_error_resource).' <br />'.$ssi_last_error.
+                  '</p><p>'.&mt('Make sure to carefully inspect your output file! The errors will be marked in the file.').'<br />'.
+                  &mt('You may be able to reprint the individual resources for which this error occured, as the issue may be temporary.').
+                  '<br />'.&mt('If the error persists, please contact the [_1] for assistance.',$helpurl).'</p><p>'.
+                  &mt('We apologize for the inconvenience.').'</p>'.
+                  '<a href="/cgi-bin/printout.pl?$identifier">Continue</a>'.$end_page);
+    } else {
 	$r->print(<<FINALEND);
 <br />
 <meta http-equiv="Refresh" content="0; url=/cgi-bin/printout.pl?$identifier" />
@@ -2287,7 +2273,7 @@
 
 		    &Apache::lonxml::remember_problem_counter();    
 
-		    my $rendered = &Apache::loncommon::get_student_view_with_retries($curresline,3,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv);
+		    my $rendered = &Apache::loncommon::get_student_view_with_retries($curresline,$ssi_retry_count,$username,$userdomain,$env{'request.course.id'},'tex',$moreenv);
 
 		    if(($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'no') ||
 		       ($helper->{'VARS'}->{'ANSWER_TYPE'} eq 'only')) {

--www1206717769--