def survey_getAllSectionsForTemplate(template_id):
 sectable = current.s3db.survey_section
 query = (sectable.template_id == template_id)
 rows = current.db(query).select(sectable.id, sectable.name, sectable.template_id, sectable.posn, orderby=sectable.posn)
 sections = []
 for sec in rows:
  sections.append({'section_id': sec.id, 'name': sec.name, 'template_id': sec.template_id, 'posn': sec.posn})
 return sections

def survey_getAllSectionsForTemplate ( template_id ) : sectable = current . s3db . survey_section query = ( sectable . template_id == template_id ) rows = current . db ( query ) . select ( sectable . id , sectable . name , sectable . template_id , sectable . posn , orderby = sectable . posn ) sections = [ ] for sec in rows : sections . append ( { 'section_id' : sec . id , 'name' : sec . name , 'template_id' : sec . template_id , 'posn' : sec . posn } ) return sections
function to return the list of sections for the given template the sections are returned in the order of their position in the template .