--- loncom/homework/chemresponse.pm 2005/02/17 21:42:37 1.46
+++ loncom/homework/chemresponse.pm 2005/05/25 21:45:07 1.53
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# chemical equation style response
#
-# $Id: chemresponse.pm,v 1.46 2005/02/17 21:42:37 albertel Exp $
+# $Id: chemresponse.pm,v 1.53 2005/05/25 21:45:07 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -84,7 +84,7 @@ JMESECTION
Molecule Editor
-
-
+
EDITREACTION
return $result;
}
@@ -362,8 +365,11 @@ sub start_reactionresponse {
}
if ( &Apache::response::show_answer() ) {
my $ans=&Apache::lonxml::get_param('answer',$parstack,$safeeval);
- $ans=~s/(\\|\')/\\$1/g;
- $Apache::inputtags::answertxt{$id}=&Apache::run::run("return &chemparse('$ans');",$safeeval);
+ if (!$Apache::lonxml::default_homework_loaded) {
+ &Apache::lonxml::default_homework_load($safeeval);
+ }
+ @Apache::scripttag::parser_env = @_;
+ $Apache::inputtags::answertxt{$id}=&Apache::run::run("return &chemparse(q\0$ans\0);",$safeeval);
}
} elsif ($target eq "edit") {
$result .=&Apache::edit::tag_start($target,$token);
@@ -434,8 +440,14 @@ sub end_reactionresponse {
sub start_chem {
my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style) = @_;
my $result = '';
+ my $inside = &Apache::lonxml::get_all_text_unbalanced("/chem",$parser);
if ($target eq 'tex' || $target eq 'web') {
- &Apache::lonxml::startredirection();
+ $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 &chemparse(q\0$inside\0);",$safeeval);
}
return $result;
}
@@ -443,14 +455,6 @@ sub start_chem {
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;
}