[LON-CAPA-cvs] cvs: loncom /homework functionplotresponse.pm
www
www at source.lon-capa.org
Sat Nov 19 18:35:26 EST 2011
www Sat Nov 19 23:35:26 2011 EDT
Modified files:
/loncom/homework functionplotresponse.pm
Log:
Starting on vector rule evaluation
Index: loncom/homework/functionplotresponse.pm
diff -u loncom/homework/functionplotresponse.pm:1.76 loncom/homework/functionplotresponse.pm:1.77
--- loncom/homework/functionplotresponse.pm:1.76 Sat Nov 19 20:03:58 2011
+++ loncom/homework/functionplotresponse.pm Sat Nov 19 23:35:25 2011
@@ -1,7 +1,7 @@
# LearningOnline Network with CAPA
# Functionplot responses
#
-# $Id: functionplotresponse.pm,v 1.76 2011/11/19 20:03:58 www Exp $
+# $Id: functionplotresponse.pm,v 1.77 2011/11/19 23:35:25 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -389,6 +389,7 @@
$Apache::functionplotresponse::counter++;
$label='O'.$Apache::functionplotresponse::counter;
}
+ &generate_input_field($id,$label,$x,$y);
return "document.ggbApplet_$id.evalCommand('a=1');\n".
"document.ggbApplet_$id.setVisible('a', false);\n".
"document.ggbApplet_$id.setLabelVisible('a', false);\n".
@@ -777,6 +778,11 @@
if ($target eq 'grade') {
# Simply remember - in order - for later
+
+ my $id=$Apache::inputtags::response[-1];
+ my $partid=$Apache::inputtags::part;
+ my $internalid = $partid.'_'.$id;
+
my $vector=&Apache::lonxml::get_param('vector',$parstack,$safeeval);
$vector=~s/\W//gs;
$vector=ucfirst($vector);
@@ -806,6 +812,7 @@
push(@Apache::functionplotresponse::functionplotvectorrules,join(':',(
$label,
'vector',
+ $internalid,
$vector,
$attachpoint,
$notattachpoint,
@@ -894,12 +901,16 @@
}
if ($target eq 'grade') {
# Simply remember - in order - for later
+ my $id=$Apache::inputtags::response[-1];
+ my $partid=$Apache::inputtags::part;
+ my $internalid = $partid.'_'.$id;
my $object=&Apache::lonxml::get_param('object',$parstack,$safeeval);
$object=~s/\W//gs;
$object=ucfirst($object);
push(@Apache::functionplotresponse::functionplotvectorrules,join(':',(
$label,
'sum',
+ $internalid,
$object,
&Apache::lonxml::get_param('length',$parstack,$safeeval),
&Apache::lonxml::get_param('angle',$parstack,$safeeval),
@@ -1359,6 +1370,62 @@
$Apache::functionplotresponse::fpr_xmax,
$arg)];
}
+
+
+sub vectorcoords {
+ my ($id,$label)=@_;
+ return ($env{'form.HWVAL_'.$id.'_'.$label.'Start_x'},
+ $env{'form.HWVAL_'.$id.'_'.$label.'End_x'},
+ $env{'form.HWVAL_'.$id.'_'.$label.'Start_y'},
+ $env{'form.HWVAL_'.$id.'_'.$label.'End_y'});
+}
+
+sub objectcoords {
+ my ($id,$label)=@_;
+ return ($env{'form.HWVAL_'.$id.'_'.$label.'_x'},
+ $env{'form.HWVAL_'.$id.'_'.$label.'_y'});
+}
+
+sub vectorangle {
+ my ($x,$y)=@_;
+}
+
+sub vectorlength {
+ my ($x,$y)=@_;
+ return sqrt($x*$x+$y*$y);
+}
+
+
+#
+# Evaluate a functionplotvectorrule
+#
+
+sub functionplotvectorrulecheck {
+ my ($rule,$xmin,$xmax,$ymin,$ymax,$safeeval)=@_;
+ my ($label,$type)=split(/\:/,$rule);
+ if ($type eq 'vector') {
+ return &vectorcheck($rule,$xmin,$xmax,$ymin,$ymax,$safeeval);
+ } elsif ($type eq 'sum') {
+ return &sumcheck($rule,$xmin,$xmax,$ymin,$ymax,$safeeval);
+ }
+}
+
+sub vectorcheck {
+ my ($rule,$xmin,$xmax,$ymin,$ymax,$safeeval)=@_;
+ my ($label,$type,$id,$vector,
+ $attachpoint,$notattachpoint,
+ $tailpoint,$tippoint,$nottailpoint,$nottippoint,
+ $length,$angle,$lengthpercenterror,$anglepercenterror)=split(/\:/,$rule);
+}
+
+sub sumcheck {
+ my ($rule,$xmin,$xmax,$ymin,$ymax,$safeeval)=@_;
+ my ($label,$type,$id,$object,$length,$angle,$lengthpercenterror,$lengthabserror,$anglepercenterror)=split(/\:/,$rule);
+}
+
+#
+# Evaluate a functionplotrule
+#
sub functionplotrulecheck {
my ($rule,$xmin,$xmax,$ymin,$ymax,$safeeval)=@_;
@@ -1584,6 +1651,13 @@
last;
}
}
+# And now go through the vector rules
+ foreach my $rule (@Apache::functionplotresponse::functionplotvectorrules) {
+ unless (&functionplotvectorrulecheck($rule,$xmin,$xmax,$ymin,$ymax,$safeeval)) {
+ $ad='INCORRECT';
+ last;
+ }
+ }
# If it's not wrong, it's correct
unless ($ad) { $ad='EXACT_ANS' };
}
More information about the LON-CAPA-cvs
mailing list