Diff for /loncom/homework/functionplotresponse.pm between versions 1.64 and 1.65

version 1.64, 2011/09/28 23:33:52 version 1.65, 2011/10/13 01:54:12
Line 31  use strict; Line 31  use strict;
 use Apache::response();  use Apache::response();
 use Apache::lonlocal;  use Apache::lonlocal;
 use Apache::lonnet;  use Apache::lonnet;
   use Apache::run;
     
 BEGIN {  BEGIN {
   &Apache::lonxml::register('Apache::functionplotresponse',('functionplotresponse','backgroundplot','spline',    &Apache::lonxml::register('Apache::functionplotresponse',('functionplotresponse','backgroundplot','spline',
Line 563  sub start_functionplotrule { Line 564  sub start_functionplotrule {
                                    ['lt','less than'],                                     ['lt','less than'],
                                    ['le','less than or equal']],$token).                                     ['le','less than or equal']],$token).
              $result.= &Apache::edit::select_or_text_arg('Value:','value',               $result.= &Apache::edit::select_or_text_arg('Value:','value',
                                                [['undef','not defined']],$token,'8').                                                 [['undef','not defined']],$token,'30').
              &Apache::edit::text_arg('Percent error:','percenterror',               &Apache::edit::text_arg('Percent error:','percenterror',
                                      $token,'8').                                       $token,'8').
              &Apache::edit::end_row();               &Apache::edit::end_row();
Line 979  sub actualval { Line 980  sub actualval {
    my ($i,$xmin,$xmax)=@_;     my ($i,$xmin,$xmax)=@_;
    return $xmin+$i/400.*($xmax-$xmin);     return $xmin+$i/400.*($xmax-$xmin);
 }  }
   
   sub fpr_f {
      my ($arg)=@_;
      return $Apache::functionplotresponse::func[&array_index($Apache::functionplotresponse::fpr_xmin,
                                                              $Apache::functionplotresponse::fpr_xmax,
                                                              $arg)];
   }
   
   sub fpr_dfdx {
      my ($arg)=@_;
      return $Apache::functionplotresponse::dfuncdx[&array_index($Apache::functionplotresponse::fpr_xmin,
                                                                 $Apache::functionplotresponse::fpr_xmax,
                                                                 $arg)];
   }
   
   sub fpr_d2fdx2 {
      my ($arg)=@_;
      return $Apache::functionplotresponse::d2funcdx2[&array_index($Apache::functionplotresponse::fpr_xmin,
                                                                   $Apache::functionplotresponse::fpr_xmax,
                                                                   $arg)];
   }
     
 sub functionplotrulecheck {  sub functionplotrulecheck {
    my ($rule,$xmin,$xmax,$ymin,$ymax)=@_;     my ($rule,$xmin,$xmax,$ymin,$ymax,$safeeval)=@_;
   
    my ($label,$derivative,$xinitial,$xinitiallabel,$xfinal,$xfinallabel,$minimumlength,$maximumlength,$relationship,$value,$percent)     my ($label,$derivative,$xinitial,$xinitiallabel,$xfinal,$xfinallabel,$minimumlength,$maximumlength,$relationship,$value,$percent)
       =split(/\:/,$rule);        =split(/\:/,$rule);
    $percent=($percent>0?$percent:5);     $percent=($percent>0?$percent:5);
    &addlog("=================");     &addlog("=================");
    &addlog("Rule $label for ".($derivative<0?'integral':('function itself','first derivative','second derivative')[$derivative])." $relationship $value");     &addlog("Rule $label for ".($derivative<0?'integral':('function itself','first derivative','second derivative')[$derivative])." $relationship $value");
   #
   # Evaluate the value
   #
      if ($value=~/\D/) {
         $Apache::functionplotresponse::fpr_xmin=$xmin;
         $Apache::functionplotresponse::fpr_xmax=$xmax;
         $value=&Apache::run::run($value,$safeeval);
         &addlog("Value evaluated to $value");
      }
   
   #
   # Minimum and maximum lengths of the interval
   #
    if ((defined($minimumlength)) || (defined($maximumlength))) {     if ((defined($minimumlength)) || (defined($maximumlength))) {
       &addlog("Minimumlength $minimumlength Maximumlength $maximumlength");        &addlog("Minimumlength $minimumlength Maximumlength $maximumlength");
    }     }
Line 1186  sub end_functionplotruleset { Line 1221  sub end_functionplotruleset {
   
 # We have a function that we can actually grade, go through the spline rules.  # We have a function that we can actually grade, go through the spline rules.
            foreach my $rule (@Apache::functionplotresponse::functionplotrules) {             foreach my $rule (@Apache::functionplotresponse::functionplotrules) {
               unless (&functionplotrulecheck($rule,$xmin,$xmax,$ymin,$ymax)) {                unless (&functionplotrulecheck($rule,$xmin,$xmax,$ymin,$ymax,$safeeval)) {
                  $ad='INCORRECT';                   $ad='INCORRECT';
                  last;                   last;
               }                }

Removed from v.1.64  
changed lines
  Added in v.1.65


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