--- loncom/homework/functionplotresponse.pm 2011/10/27 00:36:37 1.69 +++ loncom/homework/functionplotresponse.pm 2011/11/18 16:39:22 1.70 @@ -1,7 +1,7 @@ # LearningOnline Network with CAPA -# option list style responses +# Functionplot responses # -# $Id: functionplotresponse.pm,v 1.69 2011/10/27 00:36:37 www Exp $ +# $Id: functionplotresponse.pm,v 1.70 2011/11/18 16:39:22 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -35,6 +35,7 @@ use Apache::run; BEGIN { &Apache::lonxml::register('Apache::functionplotresponse',('functionplotresponse','backgroundplot','spline', + 'plotobject','plotvector', 'functionplotrule','functionplotruleset', 'functionplotelements')); } @@ -379,6 +380,55 @@ sub plot_script { } # +# Subroutine to produce objects +# + +sub plotobject_script { + my ($id,$label,$x,$y)=@_; + unless ($label) { + $Apache::functionplotresponse::counter++; + $label='O'.$Apache::functionplotresponse::counter; + } + return "document.ggbApplet_$id.evalCommand('a=1');\n". + "document.ggbApplet_$id.setVisible('a', false);\n". + "document.ggbApplet_$id.setLabelVisible('a', false);\n". + "document.ggbApplet_$id.evalCommand('$label=a*($x,$y)');\n". + "document.ggbApplet_$id.setVisible('$label', true);\n". + "document.ggbApplet_$id.setLabelVisible('$label', true);\n"; +} + +# +# Subroutine to produce vectors +# + +sub plotvector_script { + my ($id,$label,$xs,$ys,$xe,$ye)=@_; + unless ($label) { + $Apache::functionplotresponse::counter++; + $label='V'.$Apache::functionplotresponse::counter; + } + return(< #