Hi... I'm trying to create a grading system where I can reference the questions_answered with the questions id.
I want to be able to load all of the questions from the first table and and see whether or not the student got them right in the second. If the student got them right I actually only want the title of the question and not the question itself but I never made a reference to it in my questions_answered. I do however have a "question" field in my questions_answered which references the questions table. Is there a way for me to pull the title as well?
db.define_table('questions',
Field('id','integer'),
Field('title','string'),
Field('question','text'),
Field('answer','string'),
migrate=False)
db.define_table('questions_answered',
Field('id','integer'),
Field('question', type='reference questions',
requires=IS_EMPTY_OR(IS_IN_DB(db,
db.questions.id,"%(question)s")),represent=lambda id, r: db.questions(id).question),
Field('submitted','string', writable=False),
Field('answered_by',db.auth_user),
Field('correct','boolean'),
format='%(name)s', migrate=True)