[LON-CAPA-cvs] cvs: loncom /homework chemresponse.pm default_homework.lcpm

albertel lon-capa-cvs@mail.lon-capa.org
Thu, 17 Feb 2005 21:42:37 -0000


albertel		Thu Feb 17 16:42:37 2005 EDT

  Modified files:              
    /loncom/homework	chemresponse.pm default_homework.lcpm 
  Log:
  - adding the <chem> tag
  
  
Index: loncom/homework/chemresponse.pm
diff -u loncom/homework/chemresponse.pm:1.45 loncom/homework/chemresponse.pm:1.46
--- loncom/homework/chemresponse.pm:1.45	Mon Jan 31 17:00:40 2005
+++ loncom/homework/chemresponse.pm	Thu Feb 17 16:42:37 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # chemical equation style response
 #
-# $Id: chemresponse.pm,v 1.45 2005/01/31 22:00:40 albertel Exp $
+# $Id: chemresponse.pm,v 1.46 2005/02/17 21:42:37 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -32,7 +32,7 @@
 use Apache::lonnet;
 
 BEGIN {
-    &Apache::lonxml::register('Apache::chemresponse',('organicresponse','organicstructure','reactionresponse'));
+    &Apache::lonxml::register('Apache::chemresponse',('organicresponse','organicstructure','reactionresponse','chem'));
 }
 
 sub chem_standard_order {
@@ -431,5 +431,28 @@
     return $result;
 }
 
+sub start_chem {
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
+    my $result = '';
+    if ($target eq 'tex' || $target eq 'web') {
+	&Apache::lonxml::startredirection();
+    }    
+    return $result;
+}
+
+sub end_chem {
+    my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
+    my $result = '';
+    if ($target eq 'tex' || $target eq 'web') {
+	@Apache::scripttag::parser_env = @_;
+	if (!$Apache::lonxml::default_homework_loaded) {
+	    &Apache::lonxml::default_homework_load($safeeval);
+	}
+	my $innards=&Apache::lonxml::endredirection();
+	$result=&Apache::run::run("return &chemparse(q\0$innards\0);",$safeeval);
+    }
+    return $result;
+}
+
 1;
 __END__
Index: loncom/homework/default_homework.lcpm
diff -u loncom/homework/default_homework.lcpm:1.91 loncom/homework/default_homework.lcpm:1.92
--- loncom/homework/default_homework.lcpm:1.91	Wed Oct 20 22:43:34 2004
+++ loncom/homework/default_homework.lcpm	Thu Feb 17 16:42:37 2005
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA 
 # used by lonxml::xmlparse() as input variable $safeinit to Apache::run::run()
 #
-# $Id: default_homework.lcpm,v 1.91 2004/10/21 02:43:34 albertel Exp $
+# $Id: default_homework.lcpm,v 1.92 2005/02/17 21:42:37 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -560,7 +560,7 @@
     }
     # get rid of trailing space
     $formula =~ s/(\&nbsp\;| )$//;
-    
+    if ($external::target eq 'web') { return $formula; }
     return &xmlparse($formula);
 }