Check formula up to multiple to 2pi | topic started 9/3/2006; 4:27:24 PM last post 9/4/2006; 10:48:52 AM |
|
Davide P. Cervone - Re: Check formula up to multiple to 2pi 9/4/2006; 10:48:52 AM (reads: 395, responses: 0) |
I don't know now simple it is, but there are ways to do it. One complication that you have is dealing with the "2 n pi" part. My feeling is that this is going to cause more trouble in your problem than it is worth. For example, if you haven't used "n" in the problem, how are you going to tell them to type their answer using an "n"? What if the student entered "2 k pi + pi/2" instead? Would you want that to be marked wrong? How about "pi/2 - 2 n pi"? It seems to me that the number of possible ways to specify this equivalence class is too large to handle effectively with the current tools in WeBWorK. I don't like the idea of asking a student to be precise about his answer, but not be able to be precise about the checking. My recommendation would be to make the "2 n pi" be assumed, for example by asking something like "the angle is 2 n pi + [_____]" rather than have the students need to enter 2 n pi in their answers. This checking is easily accomplished: BEGIN_TEXTHere, we solve "correct = student + 2 a pi" for "a" and check if it is an integer (or near integer). The "checker" subroutine only runs if all the typechecking has been performed, but things like "infinity" and "none" pass the typechecking for reals (i.e., don't produce error messages about wrong types), so we need to check that the class of the student's answer is really a Real.
It might be easier to use the loadMacros("answerCustom.pl");This only runs the checker if the class of the student answer already equals the class of the correct answer. If you really must have the "2 n pi" as part of the answer, then you can try the following: ANS(custom_cmp($f,sub {This is more complicated. The idea is to use "adapting parameters" to check if the student answer is the correct answer up to a constant, and then check that that constant is 2 a pi for some integer (or near integer) a.
To do this, we temporarily add a parameter 'a' to the context (and
enable the use of parameters, which has been turned off so that
students can't enter them), and then create a new formula that is the
old correct answer plus "2 a pi". (We could have just used "a", but
this makes it clearer what you are going to be doing). We make global
copies of this new function ( We perform the check to see if the student's formulas does equal the professor's up to a constant, and then put the Context() back the way it was (we hope), and return incorrect if they were not equal. If they where equal up to a constant, we need to check if the constant is a multiple of 2pi, so we find the difference between two of the test points, and check if we get a (near) interger after dividing by 2pi. You might want to report a special hint if the student has typed an answer without "2 n pi", since they are not going to think if this themselves. Here is one possible modification to allow that: ANS(custom_cmp($f,sub {This is almost the same as the previous one, but this time we specify sameClass=>0
at the bottom so that the checker will run even when the student's and
professor's answers are not the same class (in this case, the
professor's answer is a Formula while the student's answer is a Real,
meaning a constant without reference to "n"). We report an error
message in that case suggesting that there is something more the
student must think about. We also have to do the typecheck by hand,
since custom_cmp() has been told not to, so return incorrect if the student's answer is not a Formula.These last two solutions suffer from the problem I mentioned at the beginning: they require the student to use "n" as the variable, and they must use "2 n pi" and not "-2 n pi" or some other formula that gets the same set of points but in a different relation to n. Davide |