--- loncom/homework/chemresponse.pm 2005/01/31 22:00:40 1.45
+++ loncom/homework/chemresponse.pm 2005/02/18 05:37:42 1.47
@@ -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.47 2005/02/18 05:37:42 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -32,7 +32,7 @@ use Apache::lonxml;
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 {
@@ -84,7 +84,8 @@ JMESECTION
Molecule Editor
-
@@ -109,11 +111,11 @@ $molecule
JME Editor courtesy of Peter Ertl, Novartis
@@ -123,7 +125,7 @@ CHEMPAGE
$body=~s/\n/ /g;
my $docopen=&Apache::lonhtmlcommon::javascript_docopen();
my $result=<
+
CHEMINPUT
return $result;
}
@@ -334,13 +336,15 @@ sub edit_reaction_button {
my $docopen=&Apache::lonhtmlcommon::javascript_docopen();
my $result=<
+//
-
+
EDITREACTION
return $result;
}
@@ -431,5 +435,28 @@ sub end_reactionresponse {
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__