[LON-CAPA-cvs] cvs: loncom /homework functionplotresponse.pm
www
www at source.lon-capa.org
Sun Nov 20 21:34:58 EST 2011
www Mon Nov 21 02:34:58 2011 EDT
Modified files:
/loncom/homework functionplotresponse.pm
Log:
Angle checking
Index: loncom/homework/functionplotresponse.pm
diff -u loncom/homework/functionplotresponse.pm:1.79 loncom/homework/functionplotresponse.pm:1.80
--- loncom/homework/functionplotresponse.pm:1.79 Sun Nov 20 02:53:27 2011
+++ loncom/homework/functionplotresponse.pm Mon Nov 21 02:34:58 2011
@@ -1,7 +1,7 @@
# LearningOnline Network with CAPA
# Functionplot responses
#
-# $Id: functionplotresponse.pm,v 1.79 2011/11/20 02:53:27 www Exp $
+# $Id: functionplotresponse.pm,v 1.80 2011/11/21 02:34:58 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -914,8 +914,7 @@
$object,
&Apache::lonxml::get_param('length',$parstack,$safeeval),
&Apache::lonxml::get_param('angle',$parstack,$safeeval),
- &Apache::lonxml::get_param('lengthpercenterror',$parstack,$safeeval),
- &Apache::lonxml::get_param('lengthabserror',$parstack,$safeeval),
+ &Apache::lonxml::get_param('lengtherror',$parstack,$safeeval),
&Apache::lonxml::get_param('angleerror',$parstack,$safeeval),
)));
} elsif ($target eq 'edit') {
@@ -928,9 +927,7 @@
$token,'16').
&Apache::edit::text_arg('Sum vector angle:','angle',
$token,'16').
- &Apache::edit::text_arg('Percent error length:','lengthpercenterror',
- $token,'8').
- &Apache::edit::text_arg('Absolute error length:','lengthabserror',
+ &Apache::edit::text_arg('Error length:','lengtherror',
$token,'8').
&Apache::edit::text_arg('Error angle:','angleerror',
$token,'8').
@@ -940,7 +937,7 @@
my $constructtag=&Apache::edit::get_new_args($token,$parstack,
$safeeval,'index','object',
'length','angle',
- 'lengthpercenterror','lengthabserror','angleerror');
+ ,'lengtherror','angleerror');
if ($constructtag) { $result=&Apache::edit::rebuild_tag($token); }
}
return $result;
@@ -1445,13 +1442,30 @@
return 0;
}
}
+ if ($angle ne '') {
+ &addlog("Checking for angle $angle with error $angleerror");
+ $angle=&Apache::run::run($angle,$safeeval);
+ &addlog("Angle evaluated to $angle");
+ my $thisangle=&plotvectorangle($id,$vector);
+ &addlog("Found angle $thisangle");
+ my $anglediff=abs($thisangle-$angle);
+ &addlog("Angle difference: $anglediff");
+ if ($anglediff>360.-$anglediff) {
+ $anglediff=360.-$anglediff;
+ }
+ &addlog("Smallest angle difference: $anglediff");
+ if ($anglediff>$angleerror) {
+ &setfailed($label);
+ return 0;
+ }
+ }
&addlog("Rule $label passed.");
return 1;
}
sub sumcheck {
my ($rule,$xmin,$xmax,$ymin,$ymax,$safeeval)=@_;
- my ($label,$type,$id,$object,$length,$angle,$lengthpercenterror,$lengthabserror,$angleerror)=split(/\:/,$rule);
+ my ($label,$type,$id,$object,$length,$angle,$lengtherror,$angleerror)=split(/\:/,$rule);
&addlog("Vector Sum Rule $label for vectors attached to ".$object);
&addlog("Rule $label passed.");
More information about the LON-CAPA-cvs
mailing list