WeBWorK Problems

Bug when handling ijk notation for vector functions.

Bug when handling ijk notation for vector functions.

by Robert Mařík -
Number of replies: 3

Hello, WeBWorK produces weird bug if we deal with vector functions (allowing ijk notation) and student submits answer with incorrect number of components.

See the attached file. The correct answer is <0,0,x> or x*k. If the student enters <0,0,0,0,x>, he/she gets "wrong" message. If he/she then enters a correct solution <0,0,x>, he/she gets strange error message. Sumitting 0 removes this strange message and submiting the correct answer works after this procedure. However, I think that there is something wrong in the ijk-notation parser.

Removing the line which accepts ijk notation from the pg files solves the problem. However, in vector calculus we often use this notation and it would be nice to keep the possibility give the answer in ijk notation.

Thank you for all suggestions.

Robert Marik

In reply to Robert Mařík

Re: Bug when handling ijk notation for vector functions.

by Davide Cervone -

It turns out that this is due to some code that stringifies all the values in the AnswerHash, including the MathObejcts that are the student and correct answer (and I think the most recent past answer as well). When the ijk flag is set, that means that vectors stringify in ijk notation, but that only can be done for vectors in three-space (or below), and so <0,0,0,x> throws an error. That is a problem for the code that is just trying to turn the AnswerHash into string values.

The solution I will propose in a pull request is to only stringify in ijk notation when the vector is in three-space (or below), and use delimiters otherwise. That I'll make sure it can always be stringified.

On the other hand, note that you can always enter vectors in ijk notation, regardless of the setting of that flag. The flag controls the *output* for vectors not the input. If you don't set this flag, and still want the correct answer to show in ijk format, you can use Compute() with a value given in ijk format and it should display as it was in the original formula.

In reply to Davide Cervone

Re: Bug when handling ijk notation for vector functions.

by Robert Mařík -

Thank you for explanation. I was not aware of the fact that the flag works for output only.

In reply to Robert Mařík

Re: Bug when handling ijk notation for vector functions.

by Davide Cervone -

Just to be extra clear, ijk notation is always available for input (unless you remove the i, j and k constants in the context), so students are always allowed to enter vectors that way.