--- loncom/homework/chemresponse.pm	2004/08/10 18:05:12	1.37
+++ loncom/homework/chemresponse.pm	2005/01/08 03:54:32	1.43
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # chemical equation style response
 #
-# $Id: chemresponse.pm,v 1.37 2004/08/10 18:05:12 albertel Exp $
+# $Id: chemresponse.pm,v 1.43 2005/01/08 03:54:32 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -121,8 +121,9 @@ $molecule
 CHEMPAGE
     $body=&HTML::Entities::encode($body,'<>&"');
     $body=~s/\n/ /g;
+    my $docopen=&Apache::lonhtmlcommon::javascript_docopen();
     my $result=<<CHEMINPUT;
-<input type="button" value="Draw Molecule" onClick="javascript:editor=window.open('','','width=500,height=500,scrollbars=no,resizable=yes');editor.document.open('text/html','replace');editor.document.writeln('$body')" />
+<input type="button" value="Draw Molecule" onClick="javascript:editor=window.open('','','width=500,height=500,scrollbars=no,resizable=yes');editor.$docopen;editor.document.writeln('$body')" />
 CHEMINPUT
     return $result;
 }
@@ -210,6 +211,9 @@ sub end_organicresponse {
 		    $ad='INCORRECT';
 		}
 	    }
+	    if ($ad && $Apache::lonhomework::type eq 'survey') {
+		$ad='SUBMITTED';
+	    }
 	    &Apache::response::handle_previous(\%previous,$ad);
 	    $Apache::lonhomework::results{"resource.$partid.$id.awarddetail"}=$ad;
 	    $Apache::lonhomework::results{"resource.$partid.$id.molecule"}=$ENV{"form.MOLECULE_$id"};
@@ -245,7 +249,7 @@ sub start_organicstructure {
 	    'cgi.'.$id.'.PNG' => 1,
 	    'cgi.'.$id.'.WIDTH' => $width );
     } elsif ($target eq 'tex') {
-	my $texwidth=&Apache::lonxml::get_param('texwidth',$parstack,$safeeval,1);
+	my $texwidth=&Apache::lonxml::get_param('texwidth',$parstack,$safeeval,undef,1);
 	if (!$texwidth) { $texwidth='90'; }
 	my $molecule=&Apache::lonxml::get_param('molecule',$parstack,$safeeval);
 	my $options=&Apache::lonxml::get_param('options',$parstack,$safeeval);
@@ -308,11 +312,12 @@ sub edit_reaction_button {
     my $id_es=&Apache::lonnet::escape($id);
     my $field_es=&Apache::lonnet::escape($field);
     my $reaction_es=&Apache::lonnet::escape($reaction);
+    my $docopen=&Apache::lonhtmlcommon::javascript_docopen();
     my $result=<<EDITREACTION;
 <script type="text/javascript">
     function create_reaction_window_${id}_${field} () {
 	editor=window.open('','','width=500,height=270,scrollbars=no,resizable=yes');
-	editor.document.open('text/html','replace');
+	editor.$docopen;
 	editor.document.writeln('<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"><html> <head><title>LON-CAPA Reaction Editor</title></head><frameset rows="30%,*" border="0">  <frame src="/res/adm/pages/reactionresponse/reaction_viewer.html?inhibitmenu=yes" name="viewer" scrolling="no" />  <frame src="/res/adm/pages/reactionresponse/reaction_editor.html?inhibitmenu=yes&reaction=$reaction_es&id=$id_es&field=$field_es" name="editor" scrolling="no" /> </frameset> </html>');
     }
 </script>
@@ -350,7 +355,7 @@ sub start_reactionresponse {
 	$result .=&edit_reaction_button($id,&Apache::edit::html_element_name('answer'),$answer).'</nobr>';
 	my $initial=&Apache::lonxml::get_param('initial',$parstack,$safeeval);
 	$result.='<nobr>'.
-	    &Apache::edit::text_arg('Initial Reation:','initial',$token,40);
+	    &Apache::edit::text_arg('Initial Reaction:','initial',$token,40);
 	$result .=&edit_reaction_button($id,&Apache::edit::html_element_name('initial'),$initial).'</nobr>';
 	
 	$result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
@@ -385,6 +390,9 @@ sub end_reactionresponse {
 		    $ad='INCORRECT';
 		}
 	    }
+	    if ($ad && $Apache::lonhomework::type eq 'survey') {
+		$ad='SUBMITTED';
+	    }
 	    &Apache::response::handle_previous(\%previous,$ad);
 	    $Apache::lonhomework::results{"resource.$partid.$id.awarddetail"}=$ad;
 	}