--- loncom/homework/chemresponse.pm 2003/05/04 08:45:22 1.1
+++ loncom/homework/chemresponse.pm 2005/05/26 20:49:23 1.54
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# chemical equation style response
#
-# $Id: chemresponse.pm,v 1.1 2003/05/04 08:45:22 albertel Exp $
+# $Id: chemresponse.pm,v 1.54 2005/05/26 20:49:23 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -32,110 +32,430 @@ use Apache::lonxml;
use Apache::lonnet;
BEGIN {
- &Apache::lonxml::register('Apache::chemresponse',('chemresponse','chemstructure'));
+ &Apache::lonxml::register('Apache::chemresponse',('organicresponse','organicstructure','reactionresponse','chem'));
}
-sub seperate_jme_window {
- my ($id,$molecule)=@_;
+sub chem_standard_order {
+ my ($reaction) = @_;
+ my ($re,$pr) = split(/->|<=>/,$reaction);
+ my @reactants = split(/\s\+/,$re);
+ my @products = split(/\s\+/,$pr);
+ foreach my $substance (@reactants,@products) {
+ $substance =~ s/(\^\d*)\s+/$1_/g; # protect superscript space
+ $substance =~ s/\s*//g; # strip whitespace
+ $substance =~ s/_/ /g; # restore superscript space
+ }
+ @reactants = sort @reactants;
+ @products = sort @products;
+ my $standard = '';
+ foreach my $substance (@reactants) {
+ $standard .= $substance;
+ $standard .= ' + ';
+ }
+ $standard =~ s/ \+ $//; # get rid of trailing plus sign
+ $standard .= ' -> ';
+ foreach my $substance (@products) {
+ $standard .= $substance;
+ $standard .= ' + ';
+ }
+ $standard =~ s/ \+ $//; # get rid of trailing plus sign
+ return $standard;
+}
+
+sub separate_jme_window {
+ my ($smile_input,$jme_input,$molecule,$options)=@_;
+ my $smilesection;
+ if (defined($smile_input)) {
+ $smilesection=<'; }
my $body=<
Molecule Editor
-
-