def survey_getAllWidgetsForTemplate(template_id):

    s3db = current.s3db
    qltable = s3db.survey_question_list
    qtable = s3db.survey_question
    query = (qltable.template_id == template_id) & \
            (qltable.question_id == qtable.id)
    rows = current.db(query).select(qtable.id,
                                    qtable.code,
                                    qtable.type,
                                    qltable.posn,
                                    )
    widgets = {}
    for row in rows:
        sqrow = row.survey_question
        qstn_type = sqrow.type
        qstn_id = sqrow.id
        qstn_code = sqrow.code
        qstn_posn = row.survey_question_list.posn
        widget_obj = survey_question_type[qstn_type](qstn_id)
        widgets[qstn_code] = widget_obj
        widget_obj.question["posn"] = qstn_posn
        question = {}
    return widgets

# =============================================================================
Function to return the widgets for each question for the given
dataset/ETHPy150Open sahana/eden/modules/s3db/survey.py/survey_getAllWidgetsForTemplate