--- loncom/homework/functionplotresponse.pm 2010/11/12 02:16:20 1.35 +++ loncom/homework/functionplotresponse.pm 2010/11/12 22:23:40 1.36 @@ -1,7 +1,7 @@ # LearningOnline Network with CAPA # option list style responses # -# $Id: functionplotresponse.pm,v 1.35 2010/11/12 02:16:20 www Exp $ +# $Id: functionplotresponse.pm,v 1.36 2010/11/12 22:23:40 www Exp $ # # Copyright Michigan State University Board of Trustees # @@ -31,7 +31,7 @@ use strict; use Apache::response(); use Apache::lonlocal; use Apache::lonnet; - + BEGIN { &Apache::lonxml::register('Apache::functionplotresponse',('functionplotresponse','backgroundplot','spline','functionplotrule')); } @@ -396,8 +396,8 @@ sub start_functionplotrule { ))); } elsif ($target eq 'edit') { $result=&Apache::edit::tag_start($target,$token,'Function Plot Evaluation Rule'). - &Apache::edit::text_arg('Index:','index', - $token,'4').' '. + &Apache::edit::text_arg('Index/Name:','index', + $token,'10').' '. &Apache::edit::select_arg(&mt('Function:'),'derivativeorder', [['0','Function itself'], ['1','First derivative'], @@ -784,8 +784,9 @@ sub start_functionplotresponse { sub compare_rel { my ($relationship,$value,$realval,$tol)=@_; -# is the real value defined? +# is the real value undefined? unless (defined($realval)) { +# the real value is not defined if ($relationship eq 'eq') { if ($value eq 'undef') { return 1; @@ -803,7 +804,13 @@ sub compare_rel { } } -# it is defined. +# is the expected value undefined? + if ($value eq 'undef') { +# but by now we know that the real value is defined + return 0; + } + +# both are defined. if ($relationship eq 'gt') { return ($realval>$value); } elsif ($relationship eq 'ge') { @@ -905,9 +912,9 @@ sub functionplotrulecheck { } else { $val=$Apache::functionplotresponse::func[$i]; } + &addlog("Actual value ".(defined($val)?$val:'undef').", expected $value, tolerance $tol"); unless (&compare_rel($relationship,$value,$val,$tol)) { &addlog("Condition not fulfilled at x=".&actualval($i,$xmin,$xmax)." (".$Apache::functionplotresponse::actualxval[$i]."; index $i)"); - &addlog("Actual value ".(defined($val)?$val:'undef').", expected $value, tolerance $tol"); if (($findupper) && ($i>$li)) { # check for minimum and maximum lengths my $length=&actualval($i,$xmin,$xmax)-&actualval($li,$xmin,$xmax); @@ -945,6 +952,7 @@ sub end_functionplotresponse { my $partid=$Apache::inputtags::part; my $internalid = $partid.'_'.$id; + if ($target eq 'edit') { $result=&Apache::edit::end_table(); } if ($target eq 'grade' && &Apache::response::submitted()