Diff for /loncom/homework/functionplotresponse.pm between versions 1.57 and 1.58

version 1.57, 2011/03/31 16:10:07 version 1.58, 2011/04/04 15:44:37
Line 333  ENDYOFFAXISLABEL Line 333  ENDYOFFAXISLABEL
     return $return;      return $return;
 }  }
   
   #
   # Subroutine to produce background and answer plots
   #
   
 sub plot_script {  sub plot_script {
    my ($id,$function,$fixed,$label,$color,$xmin,$xmax,$thickness)=@_;     my ($id,$function,$fixed,$label,$color,$xmin,$xmax,$thickness)=@_;
    $label=~s/\W//g;     $label=~s/\W//g;
Line 366  sub plot_script { Line 370  sub plot_script {
 }  }
   
 #  #
   # Answer spline display
   # 
   # points: x,y,slope_x,slope_y
   
   sub answer_spline_script {
      my ($id,@points)=@_;
      my $order=int(($#points+1)/4);
      if ($order<2) { $order=2; }
      if ($order>8) { $order=8; }
      $Apache::functionplotresponse::counter++;
      my $label='C'.$Apache::functionplotresponse::counter;
   }
   
   #
 # Subroutine that generates code for spline $label based on stored information  # Subroutine that generates code for spline $label based on stored information
 #  #
   
Line 847  sub start_functionplotresponse { Line 865  sub start_functionplotresponse {
                                   ['yes','no'],$token).'<br />'.                                    ['yes','no'],$token).'<br />'.
              &Apache::edit::select_arg('Grid visible:','gridvisible',               &Apache::edit::select_arg('Grid visible:','gridvisible',
                                   ['yes','no'],$token).'<br />'.                                    ['yes','no'],$token).'<br />'.
              &Apache::edit::text_arg('Background plot(s) for answer (function:xmin:xmax,function:xmin:xmax,...):',               &Apache::edit::text_arg('Background plot(s) for answer (function(x):xmin:xmax,function(x):xmin:xmax,x1:y1:sx1:sy1:x2:y2:sx2:sy2,...):',
                                          'answerdisplay',$token,'50');                                           'answerdisplay',$token,'50');
   
              &Apache::edit::end_row().&Apache::edit::start_spanning_row();               &Apache::edit::end_row().&Apache::edit::start_spanning_row();
Line 1219  sub end_functionplotelements { Line 1237  sub end_functionplotelements {
         my $answerdisplay=&Apache::lonxml::get_param('answerdisplay',$parstack,$safeeval,-2);          my $answerdisplay=&Apache::lonxml::get_param('answerdisplay',$parstack,$safeeval,-2);
         if ($answerdisplay=~/\S/s) {          if ($answerdisplay=~/\S/s) {
            foreach my $plot (split(/\s*\,\s*/,$answerdisplay)) {             foreach my $plot (split(/\s*\,\s*/,$answerdisplay)) {
               my ($func,$xl,$xh)=split(/\s*\:\s*/,$plot);                my @components=split(/\s*\:\s*/,$plot);
               if ((!defined($xl)) || ($xl eq '')) { $xl=$xmin; }                if ($#components<3) {
               if ((!defined($xh)) || ($xh eq '')) { $xh=$xmax; }  # Just a simple plot
               $result.=&plot_script($internalid,$func,1,'','00aa00',$xl,$xh,6);                   my ($func,$xl,$xh)=@components;
                    if ((!defined($xl)) || ($xl eq '')) { $xl=$xmin; }
                    if ((!defined($xh)) || ($xh eq '')) { $xh=$xmax; }
                    $result.=&plot_script($internalid,$func,1,'','00aa00',$xl,$xh,6);
                 } else {
   # This is a spline
                    $result.=&answer_spline_script(@components);
                 }
            }             }
         }          }
      }       }

Removed from v.1.57  
changed lines
  Added in v.1.58


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>