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

www lon-capa-cvs-allow@mail.lon-capa.org
Fri, 30 May 2008 16:19:50 -0000


www		Fri May 30 12:19:50 2008 EDT

  Modified files:              
    /loncom/homework	response.pm 
  Log:
  Dragmath now also in mathresponse
  
  
Index: loncom/homework/response.pm
diff -u loncom/homework/response.pm:1.190 loncom/homework/response.pm:1.191
--- loncom/homework/response.pm:1.190	Sat Apr  5 11:50:22 2008
+++ loncom/homework/response.pm	Fri May 30 12:19:49 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # various response type definitons response definition
 #
-# $Id: response.pm,v 1.190 2008/04/05 15:50:22 www Exp $
+# $Id: response.pm,v 1.191 2008/05/30 16:19:49 www Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -486,6 +486,10 @@
 						   $safeeval);
 	    $Apache::inputtags::answertxt{$id}=[$answer];
 	}
+        if ($Apache::inputtags::status['-1'] eq 'CAN_ANSWER') {
+            $result.=&edit_mathresponse_button($id,"HWVAL_$id");
+        }
+
     } elsif ($target eq 'edit') {
 	$result.=&Apache::edit::tag_start($target,$token);
 	$result.=&Apache::edit::text_arg('String to display for answer:',
@@ -512,6 +516,21 @@
     return $result;
 }
 
+sub edit_mathresponse_button {
+    my ($id,$field)=@_;
+    my $button=&mt('Edit Answer');
+    return(<<ENDFORMULABUTTON);
+<script language="JavaScript">
+function edit_${id}_${field} (textarea) {
+    thenumber = textarea;
+    thedata = document.forms['lonhomework'].elements[textarea].value;
+    newwin = window.open("/adm/dragmath/applet/MaximaPopup.html","","width=565,height=400,resizable");
+}
+</script>
+<input type='button' value='$button' onclick="javascript:edit_${id}_${field}('${field}');void(0);" />
+ENDFORMULABUTTON
+}
+
 sub end_mathresponse {
     my ($target,$token,$tagstack,$parstack,$parser,$safeeval)=@_;
     my $result;