def survey_getQuestionFromCode(code, series_id=None):
 s3db = current.s3db
 sertable = s3db.survey_series
 q_ltable = s3db.survey_question_list
 qsntable = s3db.survey_question
 if (series_id != None):
  query = ((((sertable.id == series_id) & (q_ltable.template_id == sertable.template_id)) & (q_ltable.question_id == qsntable.id)) & (qsntable.code == code))
 else:
  query = (((q_ltable.template_id == sertable.template_id) & (q_ltable.question_id == qsntable.id)) & (qsntable.code == code))
 record = current.db(query).select(qsntable.id, qsntable.code, qsntable.name, qsntable.type, q_ltable.posn, limitby=(0, 1)).first()
 question = {}
 if (record != None):
  question_row = record.survey_question
  question['qstn_id'] = question_row.id
  question['code'] = question_row.code
  question['name'] = question_row.name
  question['type'] = question_row.type
  question['posn'] = record.survey_question_list.posn
 return question

def survey_getQuestionFromCode ( code , series_id = None ) : s3db = current . s3db sertable = s3db . survey_series q_ltable = s3db . survey_question_list qsntable = s3db . survey_question if ( series_id != None ) : query = ( ( ( ( sertable . id == series_id ) & ( q_ltable . template_id == sertable . template_id ) ) & ( q_ltable . question_id == qsntable . id ) ) & ( qsntable . code == code ) ) else : query = ( ( ( q_ltable . template_id == sertable . template_id ) & ( q_ltable . question_id == qsntable . id ) ) & ( qsntable . code == code ) ) record = current . db ( query ) . select ( qsntable . id , qsntable . code , qsntable . name , qsntable . type , q_ltable . posn , limitby = ( 0 , 1 ) ) . first ( ) question = { } if ( record != None ) : question_row = record . survey_question question [ 'qstn_id' ] = question_row . id question [ 'code' ] = question_row . code question [ 'name' ] = question_row . name question [ 'type' ] = question_row . type question [ 'posn' ] = record . survey_question_list . posn return question
function to return the question for the given series with the code that matches the one passed in .