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

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 21 Feb 2005 23:23:31 -0000


albertel		Mon Feb 21 18:23:31 2005 EDT

  Modified files:              
    /loncom/xml	scripttag.pm 
  Log:
  - adding <num> and <parse> tags
  
  
Index: loncom/xml/scripttag.pm
diff -u loncom/xml/scripttag.pm:1.121 loncom/xml/scripttag.pm:1.122
--- loncom/xml/scripttag.pm:1.121	Fri Feb 18 00:38:05 2005
+++ loncom/xml/scripttag.pm	Mon Feb 21 18:23:30 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # <script> definiton
 #
-# $Id: scripttag.pm,v 1.121 2005/02/18 05:38:05 albertel Exp $
+# $Id: scripttag.pm,v 1.122 2005/02/21 23:23:30 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -41,7 +41,7 @@
   &Apache::lonxml::register('Apache::scripttag',
 			    ('script','scriptlib','parserlib','import',
 			     'window','display','storetc','physnet',
-			     'standalone','comment',
+			     'standalone','comment','num','parse',
 			     'LONCAPA_INTERNAL_TURN_STYLE_ON',
 			     'LONCAPA_INTERNAL_TURN_STYLE_OFF',
 			     'LONCAPA_INTERNAL_LONHTTPD_PORT'));
@@ -505,9 +505,53 @@
   my $result=&Apache::lonxml::inner_xmlparse($target,$tagstack,
 					     $parstack,\@parser,
 					     $safeeval,$style);
-  &Apache::lonxml::debug("xmlparse recursion ending with $result");
+  &Apache::lonxml::debug("target is $target xmlparse recursion ending with $result");
   return $result;
 }
 
+sub start_num {
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
+    my $result = '';
+    my $inside = &Apache::lonxml::get_all_text_unbalanced("/num",$parser);
+    if ($target eq 'tex' || $target eq 'web') {
+	$inside=&Apache::run::evaluate($inside,$safeeval,$$parstack[-1]);
+	if (!$Apache::lonxml::default_homework_loaded) {
+	    &Apache::lonxml::default_homework_load($safeeval);
+	}
+	@Apache::scripttag::parser_env = @_;
+	my $format=&Apache::lonxml::get_param('format',$parstack,$safeeval);
+	$result=&Apache::run::run("return &prettyprint(q\0$inside\0,q\0$format\0);",$safeeval);
+    }    
+    return $result;
+}
+
+sub end_num {
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
+    my $result = '';
+    return $result;
+}
+
+sub start_parse {
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
+    my $result = '';
+    if ( $target eq 'web' || $target eq 'tex' ||
+	 $target eq 'grade' || $target eq 'answer' ||
+	 $target eq 'analyze') {
+	my $inside = &Apache::lonxml::get_all_text_unbalanced("/parse",$parser);
+	$inside=&Apache::run::evaluate($inside,$safeeval,$$parstack[-1]);
+	if (!$Apache::lonxml::default_homework_loaded) {
+	    &Apache::lonxml::default_homework_load($safeeval);
+	}
+	@Apache::scripttag::parser_env = @_;
+	$result=&Apache::run::run("return &xmlparse(q\0$inside\0);",$safeeval);
+    }
+    return $result;
+}
+
+sub end_parse {
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
+    my $result = '';
+    return $result;
+}
 1;
 __END__