version 1.76, 2011/11/19 20:03:58
|
version 1.77, 2011/11/19 23:35:25
|
Line 389 sub plotobject_script {
|
Line 389 sub plotobject_script {
|
$Apache::functionplotresponse::counter++; |
$Apache::functionplotresponse::counter++; |
$label='O'.$Apache::functionplotresponse::counter; |
$label='O'.$Apache::functionplotresponse::counter; |
} |
} |
|
&generate_input_field($id,$label,$x,$y); |
return "document.ggbApplet_$id.evalCommand('a=1');\n". |
return "document.ggbApplet_$id.evalCommand('a=1');\n". |
"document.ggbApplet_$id.setVisible('a', false);\n". |
"document.ggbApplet_$id.setVisible('a', false);\n". |
"document.ggbApplet_$id.setLabelVisible('a', false);\n". |
"document.ggbApplet_$id.setLabelVisible('a', false);\n". |
Line 777 sub start_functionplotvectorrule {
|
Line 778 sub start_functionplotvectorrule {
|
|
|
if ($target eq 'grade') { |
if ($target eq 'grade') { |
# Simply remember - in order - for later |
# 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); |
my $vector=&Apache::lonxml::get_param('vector',$parstack,$safeeval); |
$vector=~s/\W//gs; |
$vector=~s/\W//gs; |
$vector=ucfirst($vector); |
$vector=ucfirst($vector); |
Line 806 sub start_functionplotvectorrule {
|
Line 812 sub start_functionplotvectorrule {
|
push(@Apache::functionplotresponse::functionplotvectorrules,join(':',( |
push(@Apache::functionplotresponse::functionplotvectorrules,join(':',( |
$label, |
$label, |
'vector', |
'vector', |
|
$internalid, |
$vector, |
$vector, |
$attachpoint, |
$attachpoint, |
$notattachpoint, |
$notattachpoint, |
Line 894 sub start_functionplotvectorsumrule {
|
Line 901 sub start_functionplotvectorsumrule {
|
} |
} |
if ($target eq 'grade') { |
if ($target eq 'grade') { |
# Simply remember - in order - for later |
# 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); |
my $object=&Apache::lonxml::get_param('object',$parstack,$safeeval); |
$object=~s/\W//gs; |
$object=~s/\W//gs; |
$object=ucfirst($object); |
$object=ucfirst($object); |
push(@Apache::functionplotresponse::functionplotvectorrules,join(':',( |
push(@Apache::functionplotresponse::functionplotvectorrules,join(':',( |
$label, |
$label, |
'sum', |
'sum', |
|
$internalid, |
$object, |
$object, |
&Apache::lonxml::get_param('length',$parstack,$safeeval), |
&Apache::lonxml::get_param('length',$parstack,$safeeval), |
&Apache::lonxml::get_param('angle',$parstack,$safeeval), |
&Apache::lonxml::get_param('angle',$parstack,$safeeval), |
Line 1359 sub fpr_d2fdx2 {
|
Line 1370 sub fpr_d2fdx2 {
|
$Apache::functionplotresponse::fpr_xmax, |
$Apache::functionplotresponse::fpr_xmax, |
$arg)]; |
$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 { |
sub functionplotrulecheck { |
my ($rule,$xmin,$xmax,$ymin,$ymax,$safeeval)=@_; |
my ($rule,$xmin,$xmax,$ymin,$ymax,$safeeval)=@_; |
Line 1583 sub end_functionplotruleset {
|
Line 1650 sub end_functionplotruleset {
|
$ad='INCORRECT'; |
$ad='INCORRECT'; |
last; |
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 |
# If it's not wrong, it's correct |
unless ($ad) { $ad='EXACT_ANS' }; |
unless ($ad) { $ad='EXACT_ANS' }; |