def survey_getAllQuestionsForTemplate(template_id):
 s3db = current.s3db
 sectable = s3db.survey_section
 q_ltable = s3db.survey_question_list
 qsntable = s3db.survey_question
 query = (((q_ltable.template_id == template_id) & (q_ltable.section_id == sectable.id)) & (q_ltable.question_id == qsntable.id))
 rows = current.db(query).select(qsntable.id, qsntable.code, qsntable.name, qsntable.type, sectable.name, q_ltable.posn, orderby=q_ltable.posn)
 questions = []
 for row in rows:
  question = {}
  question_row = row.survey_question
  question['qstn_id'] = question_row.id
  question['code'] = question_row.code
  question['name'] = s3db.survey_qstn_name_represent(question_row.name)
  question['type'] = question_row.type
  question['posn'] = row.survey_question_list.posn
  question['section'] = row.survey_section.name
  questions.append(question)
 return questions

def survey_getAllQuestionsForTemplate ( template_id ) : s3db = current . s3db sectable = s3db . survey_section q_ltable = s3db . survey_question_list qsntable = s3db . survey_question query = ( ( ( q_ltable . template_id == template_id ) & ( q_ltable . section_id == sectable . id ) ) & ( q_ltable . question_id == qsntable . id ) ) rows = current . db ( query ) . select ( qsntable . id , qsntable . code , qsntable . name , qsntable . type , sectable . name , q_ltable . posn , orderby = q_ltable . posn ) questions = [ ] for row in rows : question = { } question_row = row . survey_question question [ 'qstn_id' ] = question_row . id question [ 'code' ] = question_row . code question [ 'name' ] = s3db . survey_qstn_name_represent ( question_row . name ) question [ 'type' ] = question_row . type question [ 'posn' ] = row . survey_question_list . posn question [ 'section' ] = row . survey_section . name questions . append ( question ) return questions
function to return the list of questions for the given template the questions are returned in the order of their position in the template .