def survey_getQstnLayoutRules(template_id, section_id, method = 1):

    db = current.db
    s3db = current.s3db

    # search for layout rules on the survey_formatter table
    fmttable = s3db.survey_formatter
    query = (fmttable.template_id == template_id) & \
            (fmttable.section_id == section_id)
    rows = db(query).select(fmttable.method,
                            fmttable.rules)
    rules = None
    drules = None # default rules
    for row in rows:
        if row.method == method:
            rules = row.rules
            break
        elif row.method == 1:
            drules = row.rules
    if rules == None and drules != None:
        rules = drules
    row_list = []
    if rules is None or rules == "":
        # get the rules from survey_question_list
        qltable = s3db.survey_question_list
        qtable = s3db.survey_question
        query = (qltable.template_id == template_id) & \
                (qltable.section_id == section_id) & \
                (qltable.question_id == qtable.id)
        rows = db(query).select(qtable.code,
                                qltable.posn,
                                orderby=qltable.posn)
        append = row_list.append
        for question in rows:
            append([question.survey_question.code])
    else:
        # convert the JSON rules to python
        row_list = json2py(rules)
    return row_list

# =============================================================================
This will return the rules for laying out the questions for
dataset/ETHPy150Open sahana/eden/modules/s3db/survey.py/survey_getQstnLayoutRules