[LON-CAPA-cvs] cvs: loncom /interface printout.pl

foxr lon-capa-cvs@mail.lon-capa.org
Tue, 05 Jul 2005 10:23:36 -0000


foxr		Tue Jul  5 06:23:36 2005 EDT

  Modified files:              
    /loncom/interface	printout.pl 
  Log:
  Defect 4044 - don't tell the student there's a LaTeX error and innundate
  them with error diagnostics they can't do anything about.`
  
  
Index: loncom/interface/printout.pl
diff -u loncom/interface/printout.pl:1.82 loncom/interface/printout.pl:1.83
--- loncom/interface/printout.pl:1.82	Sat Jun  4 16:48:33 2005
+++ loncom/interface/printout.pl	Tue Jul  5 06:23:35 2005
@@ -330,15 +330,12 @@
       $temporary_file = IO::File->new('>'.$logfilename); 
       print $temporary_file '<html><head><title>LOGFILE</title></head><body><pre>'.$body_log_file.'</pre></body></html>'."\n";
       if ($body_log_file=~m/!\s+Emergency stop/) {
-	  #LaTeX failed to parse tex file 
-	  print "<h2>LaTeX could not successfully parse your tex file.</h2>";
-	  print "It probably has errors in it.<br />";
 	  my $whereitbegins = rindex $body_log_file,'STAMPOFPASSEDRESOURCESTART';
 	  my $whereitends = rindex $body_log_file,'STAMPOFPASSEDRESOURCEEND';
 	  my $badresource;
+	  my $badtext;
 	  if ($whereitbegins!=-1 and $whereitends!=-1) {
-	      my $badtext = substr($body_log_file,$whereitbegins+26, $whereitends-$whereitbegins-26);
- 	      print "With very high probability this error occured in ".$badtext."<br /><br />";
+	      $badtext = substr($body_log_file,$whereitbegins+26, $whereitends-$whereitbegins-26);
 	      $whereitbegins  = rindex $badtext,'located in';
 	      if ($whereitbegins != -1) {
 		  
@@ -347,21 +344,26 @@
 		  # print "<BR>failing resourcename: $badresource<BR>";
 	      }
 	  }
-	  print "Here are the error messages in the LaTeX log file</br><br /><pre>";
-	  my $sygnal = 0;
-	  for (my $i=0;$i<=$#content_of_file;$i++) {
-	      if ($content_of_file[$i]=~m/^Runaway argument?/ or $content_of_file[$i]=~m/^!/) {
-		  $sygnal = 1;
-	      } 
-	      if ($content_of_file[$i]=~m/Here is how much of/) {
-		  $sygnal = 0;
-	      } 
-	      if ($sygnal) {
-		  print "$content_of_file[$i]";
-	      }  
-	  }
-	  print "</pre>\n";
+	  
           if ($advanced_role) {  
+	      #LaTeX failed to parse tex file 
+	      print "<h2>LaTeX could not successfully parse your tex file.</h2>";
+	      print "It probably has errors in it.<br />";
+	      print "With very high probability this error occured in ".$badtext."<br /><br />";
+	      print "Here are the error messages in the LaTeX log file</br><br /><pre>";
+	      my $sygnal = 0;
+	      for (my $i=0;$i<=$#content_of_file;$i++) {
+		  if ($content_of_file[$i]=~m/^Runaway argument?/ or $content_of_file[$i]=~m/^!/) {
+		      $sygnal = 1;
+		  } 
+		  if ($content_of_file[$i]=~m/Here is how much of/) {
+		      $sygnal = 0;
+		  } 
+		  if ($sygnal) {
+		      print "$content_of_file[$i]";
+		  }  
+	      }
+	      print "</pre>\n";
 	      # print "<br> Advanced role <br>";
               print "<b><big>The link to ";
               $logfilename=~s/\/home\/httpd//;
@@ -386,9 +388,12 @@
               #    $name_file     - is the name of the LaTeX file.
               #    $identifier    - is the unique LaTeX identifier.l
 
+	      print "<br>There are errors in $badtext";
+	      print "<br>These errors prevent this resource from printing correctly";
 	      my $tex_handle = IO::File->new($name_file);
 	      my @tex_contents = <$tex_handle>;
 	      &send_error_mail($identifier, $badresource, $body_log_file, \@tex_contents);
+	      print "<br>A message has been sent to the instructor describing this failure<br>"
 	  }
 
       } elsif ($body_log_file=~m/<inserted text>/) {