[LON-CAPA-cvs] cvs: loncom /homework functionplotresponse.pm insertlist.xml
www
www at source.lon-capa.org
Fri Nov 18 12:44:07 EST 2011
www Fri Nov 18 17:44:07 2011 EDT
Modified files:
/loncom/homework functionplotresponse.pm insertlist.xml
Log:
Work in progress: vectors
Index: loncom/homework/functionplotresponse.pm
diff -u loncom/homework/functionplotresponse.pm:1.70 loncom/homework/functionplotresponse.pm:1.71
--- loncom/homework/functionplotresponse.pm:1.70 Fri Nov 18 16:39:22 2011
+++ loncom/homework/functionplotresponse.pm Fri Nov 18 17:44:07 2011
@@ -1,7 +1,7 @@
# LearningOnline Network with CAPA
# Functionplot responses
#
-# $Id: functionplotresponse.pm,v 1.70 2011/11/18 16:39:22 www Exp $
+# $Id: functionplotresponse.pm,v 1.71 2011/11/18 17:44:07 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -407,20 +407,24 @@
$Apache::functionplotresponse::counter++;
$label='V'.$Apache::functionplotresponse::counter;
}
+ my $startlabel=$label.'Start';
+ my $endlabel=$label.'End';
+ my $pointlabel=$label.'Point';
+ my $anglelabel=$label.'Angle';
return(<<ENDVECTOR);
-document.ggbApplet1.evalCommand("Gravitystart=(20,0)");
-document.ggbApplet1.setVisible("Gravitystart",false);
-document.ggbApplet1.setLabelVisible("Gravitystart",false);
-document.ggbApplet1.evalCommand("Gravityend=(20,-5)");
-document.ggbApplet1.setLabelVisible("Gravityend",false);
-document.ggbApplet1.evalCommand("Gravity=Vector[Gravitystart, Gravityend]");
-document.ggbApplet1.setLabelVisible("Gravity",true);
-document.ggbApplet1.setLineThickness("Gravity",8);
+document.ggbApplet_$id.evalCommand("$startlabel=($xs,$ys)");
+document.ggbApplet_$id.setVisible("$startlabel",false);
+document.ggbApplet_$id.setLabelVisible("$startlabel",false);
+document.ggbApplet_$id.evalCommand("$endlabel=($xe,$ye)");
+document.ggbApplet_$id.setLabelVisible("$endlabel",false);
+document.ggbApplet_$id.evalCommand("$label=Vector[$startlabel,$endlabel]");
+document.ggbApplet_$id.setLabelVisible("$label",true);
+document.ggbApplet_$id.setLineThickness("$label",8);
// Displays the Angle
-document.ggbApplet1.evalCommand("Gravitypoint=(110,y(Gravitystart))"); //The x-value for this should be 2*(xmax-xmin)+xmax;
-document.ggbApplet1.evalCommand("GravityAngle=Angle[Gravitypoint,Gravitystart,Gravityend]");
-document.ggbApplet1.setLabelVisible("GravityAngle",true);
-document.ggbApplet1.setLabelStyle("GravityAngle",VALUE=2);
+//document.ggbApplet1.evalCommand("Gravitypoint=(110,y(Gravitystart))"); //The x-value for this should be 2*(xmax-xmin)+xmax;
+//document.ggbApplet1.evalCommand("GravityAngle=Angle[Gravitypoint,Gravitystart,Gravityend]");
+//document.ggbApplet1.setLabelVisible("GravityAngle",true);
+//document.ggbApplet1.setLabelStyle("GravityAngle",VALUE=2);
// Keeps track of points we care about (This should use the same listener function we use in graph problems)
//document.ggbApplet1.registerObjectUpdateListener('Gravitystart','updatePointCoordinates');
//document.ggbApplet1.registerObjectUpdateListener('Gravityend','updatePointCoordinates');
@@ -526,6 +530,61 @@
return $result;
}
+#
+# Vector
+#
+
+sub start_plotvector {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+ my $result='';
+ my $internalid = $Apache::inputtags::part.'_'.$Apache::inputtags::response[-1];
+ my $tailx=&Apache::lonxml::get_param('tailx',$parstack,$safeeval);
+ my $taily=&Apache::lonxml::get_param('taily',$parstack,$safeeval);
+ my $tipx=&Apache::lonxml::get_param('tipx',$parstack,$safeeval);
+ my $tipy=&Apache::lonxml::get_param('tipy',$parstack,$safeeval);
+
+ my $label=&Apache::lonxml::get_param('label',$parstack,$safeeval);
+ $label=~s/\W//gs;
+ $label=ucfirst($label);
+ unless ($label) { $label="NewVector"; }
+ if ($target eq 'web') {
+ my ($xmin,$xmax,$ymin,$ymax)=&boundaries($parstack,$safeeval,-3);
+ unless (defined($tailx)) { $tailx=$xmin; }
+ unless (defined($taily)) { $taily=$ymin; }
+ unless (defined($tipx)) { $tipx=$xmin; }
+ unless (defined($tipy)) { $tipy=$ymin; }
+ $result.=&plotvector_script($internalid,$label,$tailx,$taily,$tipx,$tipy);
+ } elsif ($target eq 'edit') {
+ $result=&Apache::edit::tag_start($target,$token,'Plot Vector').
+ &Apache::edit::text_arg('Label on Plot:','label',
+ $token,'16').
+ &Apache::edit::text_arg('Tail x:','tailx',
+ $token,'8').
+ &Apache::edit::text_arg('Tail y:','taily',
+ $token,'8').
+ &Apache::edit::text_arg('Tip x:','tipx',
+ $token,'8').
+ &Apache::edit::text_arg('Tip y:','tipy',
+ $token,'8').
+
+ &Apache::edit::end_row();
+ } elsif ($target eq 'modified') {
+ my $constructtag=&Apache::edit::get_new_args($token,$parstack,$safeeval,'label','tailx','taily','tipx','tipy');
+ if ($constructtag) { $result=&Apache::edit::rebuild_tag($token); }
+ }
+ return $result;
+}
+
+sub end_plotvector {
+ my ($target,$token,$tagstack,$parstack,$parser,$safeeval,$style)=@_;
+ my $result='';
+ if ($target eq 'edit') {
+ $result=&Apache::edit::end_table();
+ }
+ return $result;
+}
+
+
#
# <backgroundplot function="..." fixed="yes/no" />
Index: loncom/homework/insertlist.xml
diff -u loncom/homework/insertlist.xml:1.25 loncom/homework/insertlist.xml:1.26
--- loncom/homework/insertlist.xml:1.25 Fri Nov 18 16:39:22 2011
+++ loncom/homework/insertlist.xml Fri Nov 18 17:44:07 2011
@@ -52,7 +52,7 @@
</tag>
<tag name="plotvector">
<description>Plot Vector</description>
- <color>#DDDD55</color>
+ <color>#aaff99</color>
<insert_sub>insert_plotvector</insert_sub>
<allow></allow>
</tag>
More information about the LON-CAPA-cvs
mailing list