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

albertel lon-capa-cvs-allow@mail.lon-capa.org
Mon, 11 Jun 2007 20:52:41 -0000


albertel		Mon Jun 11 16:52:41 2007 EDT

  Modified files:              
    /loncom/homework	structuretags.pm 
    /loncom/xml	lonxml.pm scripttag.pm 
  Log:
  - <while> tag was mishandling the grade/answer/analyze modes when displayed output was generated
  - moving script var generation out-of main result mechanism and move it to an out of the way location the xml parser handles readding
  
  
  
Index: loncom/homework/structuretags.pm
diff -u loncom/homework/structuretags.pm:1.379 loncom/homework/structuretags.pm:1.380
--- loncom/homework/structuretags.pm:1.379	Tue Jun  5 18:37:56 2007
+++ loncom/homework/structuretags.pm	Mon Jun 11 16:52:29 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # definition of tags that give a structure to a document
 #
-# $Id: structuretags.pm,v 1.379 2007/06/05 22:37:56 albertel Exp $
+# $Id: structuretags.pm,v 1.380 2007/06/11 20:52:29 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1225,6 +1225,13 @@
 		$return = 0; $error=1; next;
 	    }
 	    $result.=&Apache::scripttag::xmlparse($bodytext);
+	    if ($target eq 'grade' || $target eq 'answer' ||
+		$target eq 'analyze') {
+		# grade/answer/analyze should produce no output but if we
+		# are redirecting, the redirecter should know what to do
+		# with the output
+		if (!$Apache::lonxml::redirection) { undef($result); }
+	    }
 	    $return = &Apache::run::run($code,$safeeval);
 	}
 	if ($error) {
Index: loncom/xml/lonxml.pm
diff -u loncom/xml/lonxml.pm:1.447 loncom/xml/lonxml.pm:1.448
--- loncom/xml/lonxml.pm:1.447	Thu May 31 00:15:59 2007
+++ loncom/xml/lonxml.pm	Mon Jun 11 16:52:40 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # XML Parser Module 
 #
-# $Id: lonxml.pm,v 1.447 2007/05/31 04:15:59 albertel Exp $
+# $Id: lonxml.pm,v 1.448 2007/06/11 20:52:40 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -125,6 +125,9 @@
 # stores the list of active tag namespaces
 @namespace=();
 
+# stores all Scrit Vars displays for later showing
+my @script_var_displays=();
+
 # a pointer the the Apache request object
 $Apache::lonxml::request='';
 
@@ -357,6 +360,11 @@
 
  &clean_safespace($safeeval);
 
+ if (@script_var_displays) {
+     $finaloutput .= join('',@script_var_displays);
+     undef(@script_var_displays);
+ }
+
  if ($env{'form.return_only_error_and_warning_counts'}) {
      return "$errorcount:$warningcount";
  }
@@ -620,6 +628,7 @@
   &init_counter();
   @Apache::lonxml::pwd=();
   @Apache::lonxml::extlinks=();
+  @script_var_displays=();
   @Apache::lonxml::ssi_info=();
   $Apache::lonxml::post_evaluate=1;
   $Apache::lonxml::warnings_error_header='';
@@ -1254,6 +1263,12 @@
 	&Apache::lonnet::ssi($url,%form);
     }
 }
+
+sub add_script_result {
+    my ($display) = @_;
+    push(@script_var_displays, $display);
+}
+
 #
 # Afterburner handles anchors, highlights and links
 #
Index: loncom/xml/scripttag.pm
diff -u loncom/xml/scripttag.pm:1.140 loncom/xml/scripttag.pm:1.141
--- loncom/xml/scripttag.pm:1.140	Tue Jan 23 16:28:41 2007
+++ loncom/xml/scripttag.pm	Mon Jun 11 16:52:40 2007
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # <script> definiton
 #
-# $Id: scripttag.pm,v 1.140 2007/01/23 21:28:41 albertel Exp $
+# $Id: scripttag.pm,v 1.141 2007/06/11 20:52:40 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -128,16 +128,17 @@
 
 	    $uname =~s/\W//g;
 	    $udom  =~s/\W//g;
-	    $result.="<script type=\"text/javascript\">
+	    my $script_var ="<script type=\"text/javascript\">
 // <![CDATA[
     function LONCAPA_scriptvars_".$uname."_".$udom."_"."$Apache::lonxml::curdepth() {newWindow=open('','new_W','width=500,height=500,scrollbars=1,resizable=yes');newWindow.$windowopen;newWindow.document.writeln('$start_page<pre>";
 	    my $listing=&Apache::run::dump($target,$safeeval);
 	    $listing=~s/\\/\\\\/g;
 	    $listing=~s/\'/\\\'/g;
-	    $result.=$listing;
-	    $result.= "<\\/pre>$end_page');newWindow.document.close();newWindow.focus()}
+	    $script_var.=$listing;
+	    $script_var.= "<\\/pre>$end_page');newWindow.document.close();newWindow.focus()}
 // ]]>
 </script><a href=\"javascript:LONCAPA_scriptvars_".$uname."_".$udom."_$Apache::lonxml::curdepth();void(0);\">Script Vars</a><br />";
+	    &Apache::lonxml::add_script_result($script_var);
 	}
     } elsif ($target eq "edit" ) {
       #&Apache::run::run($bodytext,$safeeval);