Hi
I'm looking at doing a neural net 20 questions type program at some
stage, but still having difficulty with the basics.
Currently if I do a dropdown field, it won't let me enter the data
unless the question on the NEXT screen is the same as this one.
I know it's something to do with the fact that I'm deliberately
relooping through the same page with different data, but it shouldn't
reloop BEFORE it's verified and entered the data, should it?
After all, it has to use X just to do the dropdown, and the x hasn't
changed before you enter the data.

def l():
 from random import randint
 row = 1
 f1=db().select(db.questions.ALL,orderby=db.questions.id)
 f2=db().select(db.answers.ALL,orderby=db.answers.id)
 f3=db().select(db.big.ALL,orderby=db.big.id)
 f4=db(db.big.id == row).select() #This is last row, the stuff
currently being entered

#QUESTION_AND_ANSWER------------------------------------------------------------------------------------------------

 x=randint(1,3)
 question_asking = db(db.questions.q_number == x).select()[0].q_para01
 your_answer = SQLFORM.factory(Field('reply',requires =
IS_IN_DB(db(db.answers.q_number == x),"answers.id",'%
(a_options)s')))

#fill in correct row
 if your_answer.accepts(request.vars,session):
  put_in_big = db(db.answers.number == your_answer.vars.reply).select()
[0].a_options
  if x == 1:
   db(db.big.number == row).update(col01=put_in_big)
  if x == 2:
   db(db.big.number == row).update(col02=put_in_big)
  if x == 3:
   db(db.big.number == row).update(col03=put_in_big)
  redirect(URL('l'))

 return
dict(f1=f1,f2=f2,f3=f3,f4=f4,x=x,question_asking=question_asking,your_answer=your_answer,row=row)


(These been imported)
TABLE questions
questions.id,questions.q_number,questions.q_para01
1,1,'Q1 Where are you?'
2,2,'Q2 Are you a tiger?'
3,3,'Q3 Are you a shark?'


TABLE answers
answers.id,answers.q_number,answers.a_options,answers.a_value
1,1,'Land',1
2,1,'Sea',1
3,2,'Yes',1
4,2,'No',2
5,3,'Yes',1
6,3,'No',2

I would really appreciate figuring this out - I've been stuck for a
couple of weeks on this.

Reply via email to