Using Web2py, in the default controller, how can I randomize the order that the radio buttons appear on the screen? Ex: I don't want answer1 to appear before all of the other radio buttons all of the time.
def index():
import random
recaptcha_row = db(db.recaptcha_qa).select(orderby="<random>")
for x in recaptcha_row:
statement=x.statement
question=x.question
form = FORM(
TR(x.answer1,INPUT(_type="radio", _name="operation", _value="answer1")),
TR(x.answer2,INPUT(_type="radio", _name="operation", _value="answer2")),
TR(x.answer3,INPUT(_type="radio", _name="operation", _value="answer3")),
TR(x.answer4,INPUT(_type="radio", _name="operation", _value="answer4")),
TR("",INPUT(_type="submit", _name="submit", _value="Submit")),
)
if form.accepts(request.vars,session):
if (form.vars.operation=="answer1"):
redirect(URL("right_answer"))
else:
redirect(URL("wrong_answer"))
return dict(statement=statement,question=question,form=form)
def right_answer():
return dict()
def wrong_answer():
return dict()