[LON-CAPA-cvs] cvs: loncom /homework chemresponse.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Mon, 05 May 2003 19:27:08 -0000
albertel Mon May 5 15:27:08 2003 EDT
Modified files:
/loncom/homework chemresponse.pm
Log:
- can show and edit chem structers
Index: loncom/homework/chemresponse.pm
diff -u loncom/homework/chemresponse.pm:1.2 loncom/homework/chemresponse.pm:1.3
--- loncom/homework/chemresponse.pm:1.2 Sun May 4 18:14:53 2003
+++ loncom/homework/chemresponse.pm Mon May 5 15:27:08 2003
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# chemical equation style response
#
-# $Id: chemresponse.pm,v 1.2 2003/05/04 22:14:53 albertel Exp $
+# $Id: chemresponse.pm,v 1.3 2003/05/05 19:27:08 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -173,9 +173,45 @@
}
sub start_chemstructure {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+ my $result;
+ if ($target eq 'web') {
+ my $width=&Apache::lonxml::get_param('width',$parstack,$safeeval);
+ my $height=&Apache::lonxml::get_param('height',$parstack,$safeeval);
+ my $molecule=&Apache::lonxml::get_param('molecule',$parstack,$safeeval);
+ $result=<<CHEMOUTPUT;
+<applet code="JME.class" archive="/adm/jme/JME.jar" width="$width" height="$height">
+<param name="options" value="depict border" />
+<param name="jme" value="$molecule" />
+</applet>
+CHEMOUTPUT
+ } elsif ($target eq 'edit') {
+ $result .=&Apache::edit::tag_start($target,$token);
+ $result .=&Apache::edit::text_arg('Width:','width',$token,5);
+ $result .=&Apache::edit::text_arg('Height:','height',$token,5);
+ $result .=&Apache::edit::text_arg('Molecule:','molecule',$token,40);
+ my $molecule=&Apache::lonxml::get_param('molecule',$parstack,
+ $safeeval);
+ $result .=&seperate_jme_window(undef,
+ &Apache::edit::html_element_name('molecule'),
+ $molecule);
+ $result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
+ } elsif ($target eq 'modified') {
+ my $constructtag=&Apache::edit::get_new_args($token,$parstack,
+ $safeeval,'molecule',
+ 'width','height');
+ if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
+ }
+ return $result;
}
sub end_chemstructure {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+ my $result;
+ if ($target eq "edit") {
+ $result.= &Apache::edit::tag_end($target,$token,'');
+ }
+ return $result;
}
1;