[OT] programming question

Nicholas Clark nick at ccl4.org
Thu Apr 26 12:49:17 BST 2007


On Thu, Apr 26, 2007 at 09:30:36AM +0100, David Precious wrote:
> Nicholas Clark wrote:
> >Say I'm trying to write a web based quiz. Multiple guess.
> >What I think I want to do is have my backend take the list of possible 
> >answers
> >and display them in random order. My HTML form has $n radio buttons, with 
> >$n
> >form parameter options, and (obviously) only one is correct.
> >
> >Now, the simplest way I can see of saving state long term is to have it so
> >that the master file of questions has answers in fixed order, so that one
> >maps the radio option chosen back to the fixed location of that answer.
> >
> >And the simplest way of knowing the correct answer is to have it first in
> >the unrandomised order. Only, here we have an information leakage problem,
> >because something like
> 
> How are you storing the questions/answers?  Any reason you can't just 

Currently a text file, question then 5 answers.

> have a flag to indicate which answer(s) are correct?  (Giving the 
> ability to have more than one correct answer might prove useful at some 
> point, perhaps?).

I think that how I store them is irrelevant here, providing that the
constraint holds that I don't want to assign answers individual IDs,
and I don't particularly want to have to manually randomise each question's
answers' master order. Which ends up with "a particular master order number
is correct" which for the sake of argument is 1. So the flag currently is
"1".

I can tweak things to have more than one right answer, or weight different
answers to have different levels of correctness, but still I'd like my
question config file to be easy to maintain, and that likely means that it
has the orders arranged in increasing level of incorrectness.


But as I see it, whatever happens storage side if I present the answers in
randomised order, and I also don't wish to maintain sessions or store
server-side state across each and every question issued, then I have to have
some way of remembering client side what order I presented questions in the
client, without the client being able to trivially reverse it out. (I can
verify that the client passes back something truthful by also saving a hash
my-secret-appended-to-the-client-state - that's not really a problem)

Nicholas Clark


More information about the london.pm mailing list