--- loncom/homework/functionplotresponse.pm 2010/10/05 00:10:07 1.6 +++ loncom/homework/functionplotresponse.pm 2010/10/05 01:28:00 1.7 @@ -1,7 +1,7 @@ # LearningOnline Network with CAPA # option list style responses # -# $Id: functionplotresponse.pm,v 1.6 2010/10/05 00:10:07 www Exp $ +# $Id: functionplotresponse.pm,v 1.7 2010/10/05 01:28:00 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -214,12 +214,27 @@ ENDPLOTSCRIPT } # -# Subroutine that generates spline $label based on stored information +# Subroutine that generates code for spline $label based on stored information # sub generate_spline { my ($id,$label)=@_; my $result=''; + my $order=$Apache::functionplotresponse::splineorder{$label}; + my $x=$Apache::functionplotresponse::splineinitx{$label}; + my $y=$Apache::functionplotresponse::splineinity{$label}; + my $sx=$Apache::functionplotresponse::splinescalex{$label}; + my $sy=$Apache::functionplotresponse::splinescaley{$label}; + my @coords=(); + foreach my $i (1..$order) { + $result.=&new_coordinate($id,$label.'P'.$i,$x,$y); + $x+=$sx/$order; + push(@coords,$label.'P'.$i); + $result.=&new_coordinate($id,$label.'S'.$i,$x,$y+$sy); + $x+=$sx/$order; + push(@coords,$label.'S'.$i); + } + $result.='document.ggbApplet_'.$id.'.evalCommand("Spline'.$order.'['.join(',',@coords).']");'."\n"; return $result; } # @@ -273,6 +288,7 @@ sub start_spline { my $sy=&Apache::lonxml::get_param('scaley',$parstack,$safeeval); unless ($sy) { $sy=2; } $Apache::functionplotresponse::splinescaley{$label}=$sy; + return ''; } sub end_spline {