Hi,
I am thinking about how to best design a quiz site in RoR. I think it
should be fairly easy, but have run into a wall. In the simplest form,
the view would grab all of the questions for a particular quiz and
display them (e.g. multiple choice, so 4 option buttons per question).
However, I can’t figure out how to “mark” the quiz. The form is
submitted to the controller, which must somehow work out whether each
one is correct. Perhaps each option group could have some form of
identifier that the controller looks at, makes a new “question” object
and checks “question.correct_answer” or somesuch? Once this is done,
the users profile can be updated with their result (etc).
Now if I want to display questions in a random order (say a quiz has 40
questions, I only want 20 for a particular attempt), I can easily grab
only 20 and jumble them up. But how does the controller know how to
mark them? Is the idea above of having the identifier sufficient here?
As a final question, I was considering different types of question. For
example, a multiple choice question (so one row per option), a question
where the user must enter a number/string (one row with the correct
answer). The view could add a ‘type’, but checking whether a number
answer is actually a number would suddenly come down to the controller,
not the model. Unless of course I use different tables for different
types of answer (so different models), or there is some sort of OOo foo
with the model that can distinguish and have different
validates_something tests.
It seems that suddenly the application is not only a data-bound
input/output site, and I’m stuck
David