[LON-CAPA-cvs] cvs: loncom /homework functionplotresponse.pm
www
www at source.lon-capa.org
Wed Oct 19 09:21:51 EDT 2011
www Wed Oct 19 13:21:51 2011 EDT
Modified files:
/loncom/homework functionplotresponse.pm
Log:
Formatting coordinates involving exponents for GeoGebra
Index: loncom/homework/functionplotresponse.pm
diff -u loncom/homework/functionplotresponse.pm:1.67 loncom/homework/functionplotresponse.pm:1.68
--- loncom/homework/functionplotresponse.pm:1.67 Wed Oct 19 00:20:28 2011
+++ loncom/homework/functionplotresponse.pm Wed Oct 19 13:21:51 2011
@@ -1,7 +1,7 @@
# LearningOnline Network with CAPA
# option list style responses
#
-# $Id: functionplotresponse.pm,v 1.67 2011/10/19 00:20:28 www Exp $
+# $Id: functionplotresponse.pm,v 1.68 2011/10/19 13:21:51 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -164,6 +164,14 @@
sub set_point_coordinate {
my ($id,$variable,$x,$y,$fixed)=@_;
my $mult=($fixed?'a*':'');
+# Get rid of wild exponents, make sure it's a number
+ $x=1.*$x;
+ $y=1.*$y;
+# GeoGebra does not understand "E"
+ $x=~s/[e|E]/\*10\^/;
+ $x=~s/\+//;
+ $y=~s/[e|E]/\*10\^/;
+ $y=~s/\+//;
return (<<ENDSETVARIABLE);
document.ggbApplet_$id.evalCommand("a=1");
document.ggbApplet_$id.evalCommand("$variable=$mult($x,$y)");
More information about the LON-CAPA-cvs
mailing list