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

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 30 Jun 2003 21:59:03 -0000


albertel		Mon Jun 30 17:59:03 2003 EDT

  Modified files:              
    /loncom/homework	chemresponse.pm 
  Log:
  - bluh javascript
  
  
Index: loncom/homework/chemresponse.pm
diff -u loncom/homework/chemresponse.pm:1.8 loncom/homework/chemresponse.pm:1.9
--- loncom/homework/chemresponse.pm:1.8	Mon Jun 30 16:58:52 2003
+++ loncom/homework/chemresponse.pm	Mon Jun 30 17:59:03 2003
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # chemical equation style response
 #
-# $Id: chemresponse.pm,v 1.8 2003/06/30 20:58:52 albertel Exp $
+# $Id: chemresponse.pm,v 1.9 2003/06/30 21:59:03 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -227,19 +227,27 @@
     return $result;
 }
 
+sub edit_reaction_button {
+    my ($id,$field,$molecule)=@_;
+    my $result=<<EDITREACTION;
+<input type='button' value='Edit Reaction' onClick="javascript:editor=window.open('/res/adm/reactionresponse/reaction_window.html','','width=500,height=270,scrollbars=no,resizable=yes'); document.cookie='problem=$id; field=$field; molecule=$molecule';" />
+EDITREACTION
+    return $result;
+}
+
 sub start_reactionresponse {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
     my $result;
     my $id = &Apache::response::start_response($parstack,$safeeval);
     if ($target eq 'web') {
-	$result.=<<EDITREACTION;
-<input type='button' value='Edit Reaction' onClick="javascript:editor=window.open('/res/adm/reactionresponse/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.=&edit_reaction_button($id,"HWVAL_$id");
     } elsif ($target eq "edit") {
+	$result .=&Apache::edit::tag_start($target,$token);
+	$result .=&Apache::edit::text_arg('Answer:','answer',$token,40);
+	my $answer=&Apache::lonxml::get_param('answer',$parstack,
+						$safeeval);
+	$result .=&edit_reaction_button($id,&Apache::edit::html_element_name('answer'),$answer);
+	$result .=&Apache::edit::end_row().&Apache::edit::start_spanning_row();
     }
     return $result;
 }