John, thanks for covering for me while I was out of town.
There are two issues involved in this discussion: how to make global
parser changes on a course-by-course basis, and how to change the way
vectors are entered and displayed.
I had been thinking about the first of these for a while, and I think
the easiest solution would be to have Parser.pl load another file
called, say, parserCustomization.pl after it is finished initializing
the parser. This file would normally be empty (or could contain
system-wide customization), but professors could put a copy of this in
their course templates/macros directory and include other
customization. For example, if they wanted vectors to be entered and
displayed using ijk notation rather than <,,> notation.
This would require minimal changes (just one line added to Parser.pl
and one new empty file), so I'll probably add that to the CVS
repository as soon as I get the chance.
These sorts of changes need to be done VERY carefully, however, as they
could easily cause trouble for problems that expect the original
behavior. For example, ijk notation is only for R3, so it could cause problems that use other dimensions to fail, and there might not be an easy way around that.
As for how to change the context so that (,,) will produce vectors,
there are several approaches. If you are writing your own problems, an
easy solution is to use the promotePoints
option of the Vector object's answer checker, which will cause points
to be converted to vectors automatically (this is not true by default).
For example, ANS(Vector(1,2,3)->cmp(promotePoints=>1));
would accept either (1,2,3) or <1,2,3> (or i+2j+3k, etc.) as a valid answer.
John's suggestion doesn't require the problem to be written
specifically to handle the alternate notation, so is better from that
point of view. It has a problem, however, in that there is now no way
for the student to enter a point, so ANS(Point(1,2,3))
will not be able to be answered correctly (the student will receive an
error message about entering a vector but expecting a point).
To get a round this, there probably needs to be a Point context, just
as there is a Vector one. I didn't make one originally since Vector
already included the notation for points, but it is probably a good
idea to have one so that Vector can be changed while leaving Point
unaffected. I will add such a context to the default contexts known to
the Parser, but older problems that use Vector context when they are
asking for Points will suffer if you change the Vector context to make
(,,) produce vectors.
In addition to making (,,) produce vectors, you probably also want to
make vectors output as (,,) rather than <,,>, so that students
will see the same format that they have to use to enter their answers.
There is another portion of the context that should be adjusted for
that:
$context->lists->set(Vector => {open=>"(",close=>")"})
would do it (where $context is the Context object to be changed).
You could also remove the <,,> notation if you wished by using
$context->parens->remove('<');
I'll post more once I make the changes to allow course-by-course customization of the Parser.
Davide
<| Post or View Comments |>
|