Forum archive 2000-2006

Michael Gage - Modifying the answer messages, depending on the answer.

Michael Gage - Modifying the answer messages, depending on the answer.

by Arnold Pizer -
Number of replies: 0
inactiveTopicModifying the answer messages, depending on the answer. topic started 1/16/2001; 3:20:08 PM
last post 1/18/2001; 9:07:05 AM
userMichael Gage - Modifying the answer messages, depending on the answer.  blueArrow
1/16/2001; 3:20:08 PM (reads: 1294, responses: 1)
[snip]

I would appreciate it if you could help me with a problem that prints different messages depending on the answer. I tried the example related to "Mozart", but couldn't get it to work. I also tried setting "answer_hash" from a problem, but couldn't figure out how to do it. I tried %answer_hash{4}="Message"; but it gave me an error message about the subscript. Please let me know where I can get the text of a complete working problem with this feature, as minor syntax errors in non-working examples are not a problem for the cognoscienti, but death for us beginners.

Also, please suggest a good reference on PERL.

Thank you for your help.

Sincerely,

Don Behan

<| Post or View Comments |>


userMichael Gage - Re: Modifying the answer messages, depending on the answer.  blueArrow
1/18/2001; 9:07:05 AM (reads: 1573, responses: 0)
Lot's of good questions here Don. Let me answer the last one first.

The WeBWorK Newbie Guide which Tom Shemanske wrote while he was learning to use WeBWorK is really helpful tutorial. It is a great way to get started.

To learn a little more about perl my experience is that the Learning Perl book by Randal Schwartz and Tom Christiansen was really useful. It has been recently updated, so I think it will include any of the Perl 5 features that we use in WeBWorK. Even the original edition tells you more than enough to modify and write most problems.

Finally the canonical reference Programming Perl, by Larry Wall, Tom Christiansen & Jon Orwant is really well written and is an important reference if you are writing complicated new macros or making other modifications to WeBWorK.

Now for working with modifying the output of an answer evaluator. This is already slightly advanced and we don't yet have a very good tutorial on the subject. However here are some places to get started:

The example at http://webwork.math.rochester.edu/maa100, (log in as practice1) setMAAtutorial, problem 16 illustrates how you can check the contents of the answer hash and on the basis of that either pose a followup question, or repeat the original question. There is a link to the source code from the page.

There is also general information on the structure of an Answer hash object in the write/modify problems advanced section. While debugging the following construction can also be useful:

If $object contains some object, such as an answer hash, then placing

warn "contents of object = ", pretty_print($object);

in the code section of a problem, will print out the contents of the object's data base. That way you don't have to guess what it contains -- you can check it for sure.

<| Post or View Comments |>