[LON-CAPA-cvs] cvs: loncom /homework functionplotresponse.pm
www
www@source.lon-capa.org
Fri, 12 Nov 2010 22:23:40 -0000
www Fri Nov 12 22:23:40 2010 EDT
Modified files:
/loncom/homework functionplotresponse.pm
Log:
Correctly deal with "undef" as desired value
Index: loncom/homework/functionplotresponse.pm
diff -u loncom/homework/functionplotresponse.pm:1.35 loncom/homework/functionplotresponse.pm:1.36
--- loncom/homework/functionplotresponse.pm:1.35 Fri Nov 12 02:16:20 2010
+++ loncom/homework/functionplotresponse.pm Fri Nov 12 22:23:40 2010
@@ -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 Apache::response();
use Apache::lonlocal;
use Apache::lonnet;
-
+
BEGIN {
&Apache::lonxml::register('Apache::functionplotresponse',('functionplotresponse','backgroundplot','spline','functionplotrule'));
}
@@ -396,8 +396,8 @@
)));
} 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 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 @@
}
}
-# 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 @@
} 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 @@
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()