How can I cause an answer checker to demand that the answer to a vector multiplication problem be in vector form rather than in the form of an operation, even though I have the answer in the form of an operation, e.g.,
$ans = Compute("$VectA X $VectB");
Bayne
This seems to work:
loadMacros("contextLimitedVector.pl");
Context("LimitedVector");
$A = Compute("<3,5,6>");
$B = Compute("<2,6,7>");
$C = $A->cross($B);
ANS($C->cmp);
however I believe there is a bug in the code right at the moment which
means that the correct answer displayed for $C is not correct (the correct_value is ok so the answer is checked correctly.
You can work around this for now using
$C->with(correct_ans=>$C)->cmp
which overrides the correct answer. (Don't try to make sense of this--I'm quite sure it is a bug. :-) )
Using the ->cross method of the vector object gets around the limitations
imposed on the parser by the LimitedVector context. This work around is
not available in the student answer which always passes through the parser.
loadMacros("contextLimitedVector.pl");
Context("LimitedVector");
$A = Compute("<3,5,6>");
$B = Compute("<2,6,7>");
$C = $A->cross($B);
ANS($C->cmp);
however I believe there is a bug in the code right at the moment which
means that the correct answer displayed for $C is not correct (the correct_value is ok so the answer is checked correctly.
You can work around this for now using
$C->with(correct_ans=>$C)->cmp
which overrides the correct answer. (Don't try to make sense of this--I'm quite sure it is a bug. :-) )
Using the ->cross method of the vector object gets around the limitations
imposed on the parser by the LimitedVector context. This work around is
not available in the student answer which always passes through the parser.
I was going to suggest something similar:
loadMacros("contextLimitedVector.pl"); Context("Vector"); $V = Vector("<3,5,6> >< <2,6,7>"); Context("LimitedVector"); $V = Vector($V); ... ANS($V->cmp);Here, we do the computation in Vector context, where it is allowed, and then coerce the result into LimitedVector context, where computations are not allowed.
Note that the cross product is represented by >< not X.
There are several versions of the limited vector context. See
http://webwork.maa.org/doc/cvs/pg_HEAD/macros/contextLimitedVector.pl.htmlfor more.
Davide
I think if you ise Vector() rather than Compute in Mike's answer, you will not have the incorrect answer problem that he mentions.
Davide
Davide
Davide --
I checked it -- you are right:
I checked it -- you are right:
loadMacros("contextLimitedVector.pl");
Context("LimitedVector");
$A = Vector("<3,5,6>");
$B = Vector("<2,6,7>");
$C = $A->cross($B);
ANS($C->cmp);
works as you would expect with the correct answer evaluated.
Using Compute instead of vector I saw the same behavior
with ->add, and ->mult so it's not just a feature of the cross product that
the correct answer is inherited from the left operand.
I filed a bug report, but it's possible that this is a "feature" side effect that merely needs to be documented and explained.
-- Mike
Updating to revision 1.94 of Value.pm also fixes this problem.
now presents the correct answer you would expect.
Thanks, Davide.
-- Mike
loadMacros("contextLimitedVector.pl");
Context("LimitedVector");
$A = Compute("<3,5,6>");
$B = Compute("<2,6,7>");
$C = $A->cross($B);
now presents the correct answer you would expect.
Thanks, Davide.
-- Mike
Mike, Davide,
Your suggestions have solved my problem. Thank you.
It isn't so much that the "correct answer" shown is not correct, but that it is also in operational form.
Bayne
Your suggestions have solved my problem. Thank you.
It isn't so much that the "correct answer" shown is not correct, but that it is also in operational form.
Bayne