I've been trying to set up a problem that demonstrates all the different ways of using vectors in WeBWorK, which includes limiting the answer entry format. I've set up the vectors $vCoord and $vIJK as my "initial" vectors in their respective formats, then performed operations on them to create new vectors. In the problem, I want the user to be forced to enter the answers in certain formats depending on which vector is used.
The problem is that, while the LimitedVector-coordinate context is working (i.e. If you try to enter these answers in ijk format, they are marked incorrect with a message explaining that variable 'i' is not defined), LimitedVector-ijk is not. With the latter, the answer can still be entered in either format, despite the setting of the ijk flag in addition to the context setting.
Am I missing something? As far as I can see, it seems that the LimitedVector-ijk context isn't working properly.
Here is the setup code for the problem:
############################# # Setup $showPartialCorrectAnswers = 1; Context("Vector"); $vCoord = Compute("<-2,4,0>"); $vIJK = Compute("-2i + 4j -6k"); $vCol = ColumnVector(5,-3,-2); # Can't perform operations in the LimitedVector context, # so they have to be done here. $vAdd = Compute("$vCoord") + Compute("<3,1,-1>"); $vSub = Compute("$vCoord") - Compute("<3,1,-1>"); $vMult = Compute("$vIJK") * Compute("3"); $vDiv = Compute("$vIJK") / Compute("2"); $vDot = $vCoord . $vIJK; $vCross = $vCoord x $vIJK; # Reassign values in appropriate contexts now that the operations have been performed. Context("LimitedVector-coordinate")->flags->set( ijk=>0 ); $vAdd = Compute("$vAdd"); #Compute("$vCoord") + Compute("<3,1,-1>"); $vSub = Compute("$vSub"); #Compute("$vCoord") - Compute("<3,1,-1>"); Context("LimitedVector-ijk")->flags->set(ijk=>1); $vMult = $vMult; #Compute("$vIJK") * Compute("3"); $vDiv = $vDiv; #Compute("$vIJK") / Compute("2"); Context("LimitedVector"); $vDot = $vDot; #$vCoord . $vIJK; $vCross = $vCross; #$vCoord x $vIJK;