Note, qa.question.title will do a recursive select (a separate additional 
query for each record), so if you have to loop through all questions, this 
could be made more efficient with a join:

rows = db((db.questions_answered.answered_by == auth.user_id) &
          (db.questions_answered.question == db.questions.id)).select(
           db.questions.ALL, db.questions_answered.correct)

Then in a view, you can do something like:

{{for row in rows:}}
  <div>{{=row.questions.titel if row.questions_answered.correct else row.
questions.question}}</div>
{{pass}}

Also, you should not create a field with the name "id". In fact, when you 
do that, it will simply be ignored, as web2py will automatically create an 
"id" field of type "id", which will be an autoincrementing integer field. 
You can instead name the "id" type field something other than "id", but you 
should only do that if working with a legacy database that already has such 
a field with a different name.

Anthony

On Tuesday, October 21, 2014 5:41:29 AM UTC-4, LoveWeb2py wrote:
>
> You're awesome. Thank you! Web2py is the best!
>
> On Tuesday, October 21, 2014 4:49:15 AM UTC-4, Leonel Câmara wrote:
>>
>> Well if qa is a questions_answered record you can just do 
>> qa.question.title (this will do a select to get the question title).
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to