[LON-CAPA-cvs] cvs: loncom /xml lonxml.pm

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 19 Aug 2004 20:53:48 -0000


albertel		Thu Aug 19 16:53:48 2004 EDT

  Modified files:              
    /loncom/xml	lonxml.pm 
  Log:
  - error message now reads better depeing on context BUG#3312
  
  
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.335 loncom/xml/lonxml.pm:1.336
--- loncom/xml/lonxml.pm:1.335	Tue Aug 10 14:25:53 2004
+++ loncom/xml/lonxml.pm	Thu Aug 19 16:53:48 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.335 2004/08/10 18:25:53 sakharuk Exp $
+# $Id: lonxml.pm,v 1.336 2004/08/19 20:53:48 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1340,31 +1340,41 @@
 }
 
 sub error {
-  $errorcount++;
-  my $request=$Apache::lonxml::request;
-  if (!$request) { $request=Apache->request; }
-  if (($Apache::lonxml::debug eq 1) || ($ENV{'request.state'} eq 'construct') ) {
-    # If printing in construction space, put the error inside <pre></pre>
-      push(@Apache::lonxml::error_messages,
-	   $Apache::lonxml::warnings_error_header.
-	   "<b>ERROR:</b>".join("<br />\n",@_)."<br />\n");
-      $Apache::lonxml::warnings_error_header='';
-  } else {
-      push(@Apache::lonxml::error_messages,
-	   "<b>An Error occured while processing this resource. The instructor has been notified.</b> <br />");
-    #notify author
-    &Apache::lonmsg::author_res_msg($ENV{'request.filename'},join('<br />',@_));
-    #notify course
-    if ( $ENV{'request.course.id'} ) {
-      my (undef,%users)=&Apache::lonfeedback::decide_receiver(undef,0,1,1,1);
-      my $declutter=&Apache::lonnet::declutter($ENV{'request.filename'});
-      foreach (keys %users) {
-	my ($user,$domain) = split(/:/, $_);
-	&Apache::lonmsg::user_normal_msg($user,$domain,
-        "Error [$declutter]",join('<br />',@_));
-      }
+    $errorcount++;
+    if (($Apache::lonxml::debug eq 1) || ($ENV{'request.state'} eq 'construct') ) {
+	# If printing in construction space, put the error inside <pre></pre>
+	push(@Apache::lonxml::error_messages,
+	     $Apache::lonxml::warnings_error_header.
+	     "<b>ERROR:</b>".join("<br />\n",@_)."<br />\n");
+	$Apache::lonxml::warnings_error_header='';
+    } else {
+	my $errormsg;
+	my ($symb)=&Apache::lonnet::symbread();
+	if ( !$symb ) {
+	    #public or browsers
+	    $errormsg=&mt("An error occured while processing this resource. The author has been notified.");
+	} 
+	#notify author
+	&Apache::lonmsg::author_res_msg($ENV{'request.filename'},join('<br />',@_));
+	#notify course
+	if ( $symb && $ENV{'request.course.id'} ) {
+	    my (undef,%users)=&Apache::lonfeedback::decide_receiver(undef,0,1,1,1);
+	    my $declutter=&Apache::lonnet::declutter($ENV{'request.filename'});
+	    my @userlist;
+	    foreach (keys %users) {
+		my ($user,$domain) = split(/:/, $_);
+		push(@userlist,"$user\@$domain");
+		&Apache::lonmsg::user_normal_msg($user,$domain,
+						 "Error [$declutter]",join('<br />',@_));
+	    }
+	    if ($ENV{'request.role.adv'}) {
+		$errormsg=&mt("An error occured while processing this resource. The course personnel ([_1]) and the author have been notified.",join(', ',@userlist));
+	    } else {
+		$errormsg=&mt("An error occured while processing this resource. The instructor has been notified.");
+	    }
+	}
+	push(@Apache::lonxml::error_messages,"<b>$errormsg</b> <br />");
     }
-  }
 }
 
 sub warning {