[Seaside] state of the aubergine

Avi Bryant avi@beta4.com
Wed, 24 Apr 2002 11:41:25 -0700 (PDT)


On Wed, 24 Apr 2002, Tim Rowledge wrote:

> Err, I'm not sure I follow you here. I'm going to be randomly permuting
> the list of possible answers each time the question is displayed. I had
> been 'returning' a,b, etc as the result chosen and worrying about how to
> 'remember' what permutation was relevant to each occasion (obviously for
> five answers there's 120 possible permutations) and de-permuting. Are
> you suggesting that I can 'return' the entire answer string? That would
> certainly save one problem but might be painful if answer were big
> (maybe an image?). Or is there something else? Obviously it has to be
> hidden from the student to stop them cheating.

Returning from what?

If you mean at the HTML (or rather HTTP POST) level, forget about it.
Seaside doesn't operate at the level of the query string, it operates at
the level of object pointers.  So if you have a series of radio buttons,
what you're giving the template is a collection of Answer objects, and
what it's giving you back is the Answer object that was picked.  It
worries about generating unique IDs in the html so that it can figure out
which one was actually picked, that's not your problem.

The first tutorial doesn't do a great job of making this clear, I guess.
But notice that by the end of the tutorial, the radio buttons are built
from an array of associations, and the 'conversion' instvar is being set
to the chosen association.  Your answers could similarly be associations
of 'a'->'7 bananas', 'b'->'a bicycle', etc.

Am I completely misinterpreting what you're saying?  Or does that help?

Avi