This is unfortunately a short section. If you do nonstandard
problems, it is easy to make mistakes, and not so easy to find them.
- There are little things to remember. What students may enter as a
valid answer is often quite different than what you may write in a
PG-problem. For example, if you want students enter an answer
which is the product to two numbers 3 and 5, they may write
3*5 or 3 * 5 or 3 5 or (3)(5).
You must write one of the first two. Another important example is
exponentiation. Students can enter 16 or 2**3; Perl
wants 2**3. In fact 17 has a meaning, very
different that exponentiation, which can drive you batty. Another
place to be careful is with negative numbers. See the Gothas section
near the end of the document for details. If you learn to code
with an eye towards esthetics, you might write 18 with
some space around the variables. If you are prone to compact writing,
you might write 19. Surely these are the same.
Sometimes. For students they are the same, but not necessarily for you in Perl.
If 20 and
21, then the first one evaluates nicely to 7, but there
are instances in which the
second is interpreted as 3--4 where -- is a
decrement operator in Perl
- If the default display mode for your problems is typeset mode
(my default), and the PG problem doesn't compile, you will get a
cryptic message on your web browser page like
verbatim51#
This means nothing other than your PG-program didn't compile. Go
back to the problem set selection page (you may have to reload the
page), and choose the text option. Get the problem again,
and you will at least get somewhat more specific cryptic messages,
some of which can be useful in discovering the source of your error.
- Another technique is to get a hard copy in TEX format.
Often this too will reveal where errors lie.
- If you have no luck, divide and conquer, print values of
variables to see if things are working the way you expect, and other
generic programming tricks for debugging.