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

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 30 Jun 2003 18:00:18 -0000


albertel		Mon Jun 30 14:00:18 2003 EDT

  Modified files:              
    /loncom/homework	chemresponse.pm 
  Log:
  - changed to organicresponse/structure
  
  
Index: loncom/homework/chemresponse.pm
diff -u loncom/homework/chemresponse.pm:1.5 loncom/homework/chemresponse.pm:1.6
--- loncom/homework/chemresponse.pm:1.5	Mon May  5 17:14:10 2003
+++ loncom/homework/chemresponse.pm	Mon Jun 30 14:00:18 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # chemical equation style response
 #
-# $Id: chemresponse.pm,v 1.5 2003/05/05 21:14:10 albertel Exp $
+# $Id: chemresponse.pm,v 1.6 2003/06/30 18:00:18 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -32,11 +32,11 @@
 use Apache::lonnet;
 
 BEGIN {
-    &Apache::lonxml::register('Apache::chemresponse',('chemresponse','chemstructure','reactionresponse'));
+    &Apache::lonxml::register('Apache::chemresponse',('organicresponse','organicstructure','reactionresponse'));
 }
 
 sub seperate_jme_window {
-    my ($smile_input,$jme_input,$molecule)=@_;
+    my ($smile_input,$jme_input,$molecule,$options)=@_;
     my $smilesection;
     if (defined($smile_input)) {
 	$smilesection=<<SMILESECTION;
@@ -76,6 +76,7 @@
 <applet code="JME.class" name="JME" archive="/adm/jme/JME.jar" width="97%" height="78%">
 You have to enable Java and JavaScript on your machine.
 <param name="jme" value="$molecule" />
+<param name="options" value="$options" />
 </applet><br />
 <font face="arial,helvetica,sans-serif" size=-1><a href="http://www.molinspiration.com/jme/index.html">JME Editor</a> courtesy of Peter Ertl, Novartis</font>
 <form>
@@ -97,7 +98,7 @@
     return $result;
 }
 
-sub start_chemresponse {
+sub start_organicresponse {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     my $result;
     my $partid = $Apache::inputtags::part;
@@ -111,17 +112,26 @@
 	    $molecule=&Apache::lonxml::get_param('molecule',$parstack,
 						 $safeeval);
 	}
-	$result=&seperate_jme_window("HWVAL_$id","MOLECULE_$id",$molecule);
+	my $multipart=&Apache::lonxml::get_param('multipart',$parstack,
+						 $safeeval);
+	if ($multipart eq 'yes') {
+	    $multipart = 'multipart';
+	} else {
+	    $multipart ='';
+        }
+	$result=&seperate_jme_window("HWVAL_$id","MOLECULE_$id",$molecule,$multipart);
 	$result.= '<input type="hidden" name="MOLECULE_'.$id.'" value="" />';
     } elsif ($target eq 'edit') {
 	$result .=&Apache::edit::tag_start($target,$token);
 	$result .=&Apache::edit::text_arg('Starting Molecule:','molecule',
 					  $token,40);
+	$result .=&Apache::edit::select_arg('Multipart:','multipart',
+					    ['yes','no'],$token);
 	my $molecule=&Apache::lonxml::get_param('molecule',$parstack,
 						$safeeval);
 	$result .=&seperate_jme_window(undef,
 		      &Apache::edit::html_element_name('molecule'),
-		      $molecule);
+		      $molecule,'multipart');
 	$result .='<br />';
 	$result .=&Apache::edit::text_arg('Correct Answer:','answer',
 					  $token,40);
@@ -131,18 +141,19 @@
 	$result .=&seperate_jme_window(
                       &Apache::edit::html_element_name('answer'),
                       &Apache::edit::html_element_name('jmeanswer'),
-		      $jmeanswer);
+		      $jmeanswer,'multipart');
 	$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',
-						     'answer','jmeanswer');
+						     'answer','jmeanswer',
+						     'multipart');
 	if ($constructtag) { $result = &Apache::edit::rebuild_tag($token); }
     }
     return $result;
 }
 
-sub end_chemresponse {
+sub end_organicresponse {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     my $result;
     if ($target eq 'grade' && defined($ENV{'form.submitted'})) {
@@ -172,7 +183,7 @@
     return $result;
 }
 
-sub start_chemstructure {
+sub start_organicstructure {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     my $result;
     if ($target eq 'web') {
@@ -194,7 +205,7 @@
 						$safeeval);
 	$result .=&seperate_jme_window(undef,
 		      &Apache::edit::html_element_name('molecule'),
-		      $molecule);
+		      $molecule,'multipart');
 	$result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
     } elsif ($target eq 'modified') {
 	my $constructtag=&Apache::edit::get_new_args($token,$parstack,
@@ -205,7 +216,7 @@
     return $result;
 }
 
-sub end_chemstructure {
+sub end_organicstructure {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     my $result;
     if ($target eq "edit") {
@@ -410,9 +421,13 @@
     my $result;
     my $id = &Apache::response::start_response($parstack,$safeeval);
     if ($target eq 'web') {
-	$result.=&reaction_javascript();
+	$result.=<<EDITREACTION;
+<input type='button' value='Edit Reaction' onClick="javascript:editor=window.open('/adm/jme/reaction_window.html','','width=500,height=270,scrollbars=no,resizable=yes'); document.cookie='problem=$id';"/>'
+EDITREACTION
+
+#	$result.=&reaction_javascript();
 #	$result.='<iframe name="REACTION_'.$id.'" width="200" height="100" src="/adm/jme/reaction_viewer.html"></iframe>';
-	$result.='<input type="button" value="Check" onClick = "javascript:newWindow=open(\'\',\'new_W\',\'width=500,height=200,scrollbars=1\');newWindow.document.open(\'text/html\',\'replace\');newWindow.document.writeln(\'<center><br />\'+to_html(document.lonhomework.HWVAL_'.$id.'.value)+\'</center><input type=&quot;button&quot; value=&quot;  Close  &quot; onClick = &quot;parent.window.close()&quot; />\');newWindow.document.close()" />'
+#	$result.='<input type="button" value="Check" onClick = "javascript:newWindow=open(\'\',\'new_W\',\'width=500,height=200,scrollbars=1\');newWindow.document.open(\'text/html\',\'replace\');newWindow.document.writeln(\'<center><br />\'+to_html(document.lonhomework.HWVAL_'.$id.'.value)+\'</center><input type=&quot;button&quot; value=&quot;  Close  &quot; onClick = &quot;parent.window.close()&quot; />\');newWindow.document.close()" />'
     } elsif ($target eq "edit") {
     }
     return $result;