[LON-CAPA-cvs] cvs: loncom /homework lonhomework.pm

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 06 Jun 2005 01:21:55 -0000


albertel		Sun Jun  5 21:21:55 2005 EDT

  Modified files:              
    /loncom/homework	lonhomework.pm 
  Log:
  - bug # 2773 - want the warning/errors viewable on the edit screens.
      (internally adding the idea of a 'no_output_web' that onl return the error text and not the reall output.)
  
  
Index: loncom/homework/lonhomework.pm
diff -u loncom/homework/lonhomework.pm:1.210 loncom/homework/lonhomework.pm:1.211
--- loncom/homework/lonhomework.pm:1.210	Sat Jun  4 03:47:51 2005
+++ loncom/homework/lonhomework.pm	Sun Jun  5 21:21:53 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # The LON-CAPA Homework handler
 #
-# $Id: lonhomework.pm,v 1.210 2005/06/04 07:47:51 albertel Exp $
+# $Id: lonhomework.pm,v 1.211 2005/06/06 01:21:53 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -124,10 +124,10 @@
 		    if ( $env{'form.submit'} eq &mt('Submit Changes and View') ) {
 			return ('modified','web','answer');
 		    } else {
-			return ('modified','edit');
+			return ('modified','no_output_web','edit');
 		    }
 		} else {
-		    return ('edit');
+		    return ('no_output_web','edit');
 		}
 	    } else {
 		return ('web');
@@ -733,9 +733,9 @@
 #    Render the page in whatever target desired.
 #
 sub renderpage {
-    my ($request,$file) = @_;
+    my ($request,$file,$targets) = @_;
 
-    my (@targets) = &get_target();
+    my @targets = @{$targets || [&get_target()]};
     &Apache::lonhomework::showhashsubset(\%env,'form.');
     &Apache::lonxml::debug("Running targets ".join(':',@targets));
     my $overall_result;
@@ -748,6 +748,10 @@
 	#    $request->print(" You most likely shouldn't see me.");
 	#}
 	#my $t0 = [&gettimeofday()];
+	my $output=1;
+	if ($target eq 'no_output_web') {
+	    $target = 'web'; $output=0;
+	}
 	my $problem=&Apache::lonnet::getfile($file);
 	if ($problem eq -1) {
 	    &Apache::lonxml::error("<b> ".&mt('Unable to find')." <i>$file</i></b>");
@@ -755,15 +759,15 @@
 	}
 
 	my %mystyle;
-	my $result = '';
 	if ($target eq 'analyze') { %Apache::lonhomework::analyze=(); }
 	if ($target eq 'answer') { &showhash(%Apache::lonhomework::history); }
 	if ($target eq 'web') {&Apache::lonhomework::showhashsubset(\%env,'^form');}
 
 	&Apache::lonxml::debug("Should be parsing now");
-	$result = &Apache::lonxml::xmlparse($request, $target, $problem,
-					    &setup_vars($target),%mystyle);
+	my $result = &Apache::lonxml::xmlparse($request, $target, $problem,
+					       &setup_vars($target),%mystyle);
 	undef($Apache::lonhomework::parsing_a_problem);
+	if (!$output) { $result = &Apache::lonxml::message_location(); }
 	#$request->print("Result follows:");
 	if ($target eq 'modified') {
 	    &handle_save_or_undo($request,\$problem,\$result);
@@ -948,6 +952,7 @@
 		&renderpage($request,$file);
 	    } elsif ($env{'form.problemmode'} eq &mt('EditXML') ||
 		     $env{'form.problemmode'} eq 'EditXML') {
+		&renderpage($request,$file,['no_output_web']);
 		&editxmlmode($request,$file);
 	    } elsif ($env{'form.problemmode'} eq &mt('Calculate answers')) {
 		&analyze($request,$file);