'All of the standard questions will now be generated
competion_qstn: who completed the assessment
date_qstn: when it was completed (date)
time_qstn: when it was completed (time)
location_detail: json of the location question
May consist of any of the following:
L0, L1, L2, L3, L4, Lat, Lon
for json entry a question will be generated
The code for each question will start with "STD-" followed by
the type of question.'

@staticmethod
def template_onaccept(form):

    form_vars = form.vars
    if form_vars.id:
        template_id = form_vars.id
    else:
        return
    add_question = S3SurveyTemplateModel.add_question
    if (form_vars.competion_qstn != None):
        name = form_vars.competion_qstn
        code = 'STD-WHO'
        notes = 'Who    completed    the    assessment'
        qtype = 'String'
        posn = (-10)
        add_question(template_id, name, code, notes, qtype, posn)
    if (form_vars.date_qstn != None):
        name = form_vars.date_qstn
        code = 'STD-DATE'
        notes = 'Date    the    assessment    was    completed'
        qtype = 'Date'
        posn += 1
        add_question(template_id, name, code, notes, qtype, posn)
    if (form_vars.time_qstn != None):
        name = form_vars.time_qstn
        code = 'STD-TIME'
        notes = 'Time    the    assessment    was    completed'
        qtype = 'Time'
        posn += 1
        add_question(template_id, name, code, notes, qtype, posn)
    if (form_vars.location_detail != None):
        location_list = json2py(form_vars.location_detail)
        if (len(location_list) > 0):
            name = 'The    location    P-code'
            code = 'STD-P-Code'
            qtype = 'String'
            posn += 1
            add_question(template_id, name, code, None, qtype, posn)
        for loc in location_list:
            if (loc == 'Lat'):
                name = 'Latitude'
            elif (loc == 'Lon'):
                name = 'Longitude'
            else:
                name = loc
            code = ('STD-%s' % loc)
            if ((loc == 'Lat') or (loc == 'Lon')):
                qtype = 'Numeric'
                metadata = {'Format': 'nnn.nnnnnn'}
            else:
                qtype = 'Location'
                metadata = {}
            posn += 1
            add_question(template_id, name, code, '', qtype, posn, metadata)
